diff options
author | Ted Gould <ted@gould.cx> | 2009-12-07 13:41:55 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2009-12-07 13:41:55 -0600 |
commit | bfb9e7775ff9a688690558cade7e2778e56a1f3c (patch) | |
tree | a2c8d775fae9192f1c57094d35889c3d67de88e8 | |
parent | 2906ee43d836d60912a8aa66f202a63cadc083d1 (diff) | |
parent | 95ecb480de8da2e06b07be2313537093bb47069a (diff) | |
download | ayatana-indicator-application-bfb9e7775ff9a688690558cade7e2778e56a1f3c.tar.gz ayatana-indicator-application-bfb9e7775ff9a688690558cade7e2778e56a1f3c.tar.bz2 ayatana-indicator-application-bfb9e7775ff9a688690558cade7e2778e56a1f3c.zip |
Adding in an activate signal.
-rw-r--r-- | example/simple-client.c | 14 | ||||
-rw-r--r-- | src/libappindicator/app-indicator.c | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/example/simple-client.c b/example/simple-client.c index ab2e24d..ea4da9d 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -26,6 +26,14 @@ with this program. If not, see <http://www.gnu.org/licenses/>. GMainLoop * mainloop = NULL; +static void +item_clicked_cb (GtkWidget *widget, gpointer data) +{ + const gchar *text = (const gchar *)data; + + g_print ("%s clicked!\n", text); +} + int main (int argc, char ** argv) { @@ -46,12 +54,18 @@ main (int argc, char ** argv) menu = gtk_menu_new (); GtkWidget *item = gtk_menu_item_new_with_label ("1"); + g_signal_connect (item, "activate", + G_CALLBACK (item_clicked_cb), "1"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_menu_item_new_with_label ("2"); + g_signal_connect (item, "activate", + G_CALLBACK (item_clicked_cb), "2"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_menu_item_new_with_label ("3"); + g_signal_connect (item, "activate", + G_CALLBACK (item_clicked_cb), "3"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); app_indicator_set_menu (ci, GTK_MENU (menu)); diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index f61723d..bd72499 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -633,6 +633,14 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) } static void +activate_menuitem (DbusmenuMenuitem *mi, gpointer user_data) +{ + GtkWidget *widget = (GtkWidget *)user_data; + + gtk_menu_item_activate (GTK_MENU_ITEM (widget)); +} + +static void container_iterate (GtkWidget *widget, gpointer data) { @@ -643,6 +651,9 @@ container_iterate (GtkWidget *widget, dbusmenu_menuitem_property_set (child, DBUSMENU_MENUITEM_PROP_LABEL, gtk_menu_item_get_label (GTK_MENU_ITEM (widget))); + g_signal_connect (G_OBJECT(child), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_menuitem), widget); dbusmenu_menuitem_child_append (root, child); } |