mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add new routine to initialize an option menu that also sets a callback
signal on each of the menu items so gnucash can know when the user changed the selection. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7295 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -532,6 +532,39 @@ gnc_option_menu_init(GtkWidget * w)
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int i;
|
||||
GtkSignalFunc f;
|
||||
gpointer cb_data;
|
||||
} menu_init_data;
|
||||
|
||||
static void
|
||||
gnc_option_menu_set_one_item (gpointer loop_data, gpointer user_data)
|
||||
{
|
||||
GtkObject *item = GTK_OBJECT(loop_data);
|
||||
menu_init_data *args = (menu_init_data *) user_data;
|
||||
|
||||
gtk_object_set_data(item, "option_index", GINT_TO_POINTER(args->i++));
|
||||
gtk_signal_connect(item, "activate", args->f, args->cb_data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_option_menu_init_w_signal(GtkWidget * w, GtkSignalFunc f, gpointer cb_data)
|
||||
{
|
||||
GtkWidget * menu;
|
||||
menu_init_data foo;
|
||||
|
||||
foo.i = 0;
|
||||
foo.f = f;
|
||||
foo.cb_data = cb_data;
|
||||
|
||||
menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
|
||||
g_list_foreach(GTK_MENU_SHELL(menu)->children,
|
||||
gnc_option_menu_set_one_item, &foo);
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
gnc_option_menu_get_active(GtkWidget * w)
|
||||
|
||||
@@ -71,6 +71,9 @@ void gnc_save_window_size (const char *prefix, int width, int height);
|
||||
void gnc_fill_menu_with_data (GnomeUIInfo *info, gpointer data);
|
||||
|
||||
void gnc_option_menu_init (GtkWidget * option_menu);
|
||||
void gnc_option_menu_init_w_signal(GtkWidget * w,
|
||||
GtkSignalFunc f,
|
||||
gpointer cb_data);
|
||||
int gnc_option_menu_get_active (GtkWidget * option_menu);
|
||||
|
||||
void gnc_window_adjust_for_screen (GtkWindow * window);
|
||||
|
||||
Reference in New Issue
Block a user