#include <glib.h>
#include "frame-common.h"
#include "func-list.h"
Go to the source code of this file.
Functions | |
void | func_list_add_new_func (GList **list, const char *name, void(*func)(GtkMenuItem *, gpointer)) |
Adds a function menu item to a func_list_t list. | |
void | func_list_add_new_submenu (GList **list, const char *name, GList *children) |
Adds a submenu menu item to a func_list_t list. | |
void | func_list_add_new_separator (GList **list) |
void | func_list_t_free (func_list_t *fn) |
Frees a func_list_t struct. | |
GtkWidget * | func_list_t_setup_submenu (func_list_t *parent, frame_t *f) |
Turns a func_list_t's children list into a GtkMenu and frees the list. |
void func_list_add_new_func | ( | GList ** | list, | |
const char * | name, | |||
void(*)(GtkMenuItem *, gpointer) | func | |||
) |
Adds a function menu item to a func_list_t list.
This function adds a menu item of type FUNCTION to a list of menu items, and updates the pointer to the list passed as a parameter.
[out] | list | a pointer to the list where to add the menu item |
[in] | name | the display name (must be unique in the list) of the menu item |
[in] | func | the function to call when this menu item is clicked |
Definition at line 32 of file func-list.c.
00033 { 00034 func_list_t *f = g_malloc (sizeof (func_list_t)); 00035 00036 f->type = FUNCTION; 00037 f->name = g_strdup (name); 00038 f->data.func = func; 00039 00040 *list = g_list_prepend (*list, f); 00041 }
void func_list_add_new_separator | ( | GList ** | list | ) |
Definition at line 58 of file func-list.c.
00059 { 00060 func_list_t *f = g_malloc (sizeof (func_list_t)); 00061 00062 f->type = SEPARATOR; 00063 f->name = NULL; 00064 00065 *list = g_list_prepend (*list, f); 00066 }
void func_list_add_new_submenu | ( | GList ** | list, | |
const char * | name, | |||
GList * | children | |||
) |
Adds a submenu menu item to a func_list_t list.
Adds a separator to a func_list_t list.
This function adds a menu item of type SUBMENU to a list of menu items, and updates the pointer to the list passed as a parameter.
[out] | list | a pointer to the list where to add the menu item |
[in] | name | the display name (must be unique in the list) of the menu item |
[in] | children | the list of menu items in the submenu of the newly created one |
This function adds a menu item of type SEPARATOR to a list of menu items, and updates the pointer to the list passed as a parameter.
[out] | list | a pointer to the list where to add the separator |
Definition at line 45 of file func-list.c.
00046 { 00047 func_list_t *f = g_malloc (sizeof (func_list_t)); 00048 00049 f->type = SUBMENU; 00050 f->name = g_strdup (name); 00051 f->data.children = children; 00052 00053 *list = g_list_prepend (*list, f); 00054 }
void func_list_t_free | ( | func_list_t * | fn | ) |
Frees a func_list_t struct.
This function frees the data in a func_list_t struct, and the struct itself.
[out] | fn | the func_list_t struct to free |
Definition at line 70 of file func-list.c.
GtkWidget * func_list_t_setup_submenu | ( | func_list_t * | parent, | |
frame_t * | f | |||
) |
Turns a func_list_t's children list into a GtkMenu and frees the list.
This function, given a func_list_t of type SUBMENU, turns its children list into a proper GtkMenu and returns it.
[in,out] | parent | the func_list_t whose submenu should be setup |
[in] | f | the frame in whose menu the parent func_list_t will be added |
Definition at line 82 of file func-list.c.
00083 { 00084 g_return_val_if_fail (parent != NULL, NULL); 00085 g_return_val_if_fail (parent->type == SUBMENU, NULL); 00086 00087 GList *iter = parent->data.children; 00088 GtkWidget *menu = gtk_menu_new (); 00089 GtkWidget *childmenu = NULL; 00090 00091 if (iter) { 00092 do { 00093 func_list_t *fn = iter->data; 00094 GtkWidget *item = NULL; 00095 00096 switch (fn->type) { 00097 case FUNCTION: 00098 item = gtk_menu_item_new_with_label (fn->name); 00099 00100 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); 00101 00102 g_signal_connect (item, "activate", G_CALLBACK (fn->data.func), (gpointer) f); 00103 gtk_widget_show (item); 00104 break; 00105 case SEPARATOR: 00106 item = gtk_separator_menu_item_new (); 00107 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); 00108 gtk_widget_show (item); 00109 break; 00110 case SUBMENU: 00111 item = gtk_menu_item_new_with_label (fn->name); 00112 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); 00113 00114 childmenu = func_list_t_setup_submenu (fn, f); 00115 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), childmenu); 00116 00117 gtk_widget_show (item); 00118 break; 00119 } 00120 func_list_t_free (fn); 00121 } while ((iter = g_list_next (iter)) != NULL); 00122 00123 g_list_free (parent->data.children); 00124 parent->data.children = NULL; 00125 } 00126 00127 return menu; 00128 }