From: John Darrington Date: Thu, 1 Jan 2009 01:19:37 +0000 (+0900) Subject: Add actions to the menuitem signals X-Git-Tag: v0.7.3~296^2~16 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4421e7aa84036f685ddbd406368f273f44f39ef4;p=pspp-builds.git Add actions to the menuitem signals --- diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 3da046ab..b40ccf14 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -258,17 +258,42 @@ psppire_window_base_finalize (PsppireWindowClass *class, { } +static void +menu_toggled (GtkCheckMenuItem *mi, gpointer data) +{ + /* Prohibit changes to the state */ + mi->active = !mi->active; +} + + +/* Look up the window associated with this menuitem and present it to the user */ +static void +menu_activate (GtkMenuItem *mi, gpointer data) +{ + const gchar *key = data; + + PsppireWindowRegister *reg = psppire_window_register_new (); + + PsppireWindow *window = psppire_window_register_lookup (reg, key); + + gtk_window_present (GTK_WINDOW (window)); +} + static void insert_menuitem_into_menu (PsppireWindow *window, gpointer key) { GtkWidget *item = gtk_check_menu_item_new_with_label (key); + g_signal_connect (item, "toggled", G_CALLBACK (menu_toggled), NULL); + g_signal_connect (item, "activate", G_CALLBACK (menu_activate), key); + gtk_widget_show (item); gtk_menu_shell_append (window->menu, item); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (psppire_window_register_lookup (psppire_window_register_new (), key) == window)); + /* Set the state without emitting a signal */ + GTK_CHECK_MENU_ITEM (item)->active = + (psppire_window_register_lookup (psppire_window_register_new (), key) == window); g_hash_table_insert (window->menuitem_table, key, item); }