static void status_icon_popup_menu_cb (GtkStatusIcon * icon, guint button, guint time) { GtkMenu *popup_menu = GTK_MENU (gtk_menu_new ()); GtkMenu *groups_menu = GTK_MENU (gtk_menu_new ()); int i = 0; gchar **current_name = gkbd_status_get_group_names (); GtkWidget *item = gtk_menu_item_new_with_mnemonic (_("_Groups")); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (groups_menu)); item = gtk_menu_item_new_with_mnemonic (_("Keyboard _Preferences")); gtk_widget_show (item); g_signal_connect (item, "activate", popup_menu_launch_capplet, NULL); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item); item = gtk_menu_item_new_with_mnemonic (_("Show Current _Layout")); gtk_widget_show (item); g_signal_connect (item, "activate", popup_menu_show_layout, NULL); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item); for (i = 0; *current_name; i++, current_name++) { gchar *image_file = gkbd_status_get_image_filename (i); if (image_file == NULL) { item = gtk_menu_item_new_with_label (*current_name); } else { GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size (image_file, 24, 24, NULL); GtkWidget *img = gtk_image_new_from_pixbuf (pixbuf); item = gtk_image_menu_item_new_with_label (*current_name); gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), img); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE); g_free (image_file); } gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (groups_menu), item); g_signal_connect (item, "activate", G_CALLBACK (popup_menu_set_group), GINT_TO_POINTER (i)); } gtk_menu_popup (popup_menu, NULL, NULL, gtk_status_icon_position_menu, (gpointer) icon, button, time); }
static GtkMenu * create_status_menu (void) { GtkMenu *popup_menu = GTK_MENU (gtk_menu_new ()); int i = 0; GtkMenu *groups_menu = GTK_MENU (gtk_menu_new ()); gchar **current_name = gkbd_status_get_group_names (); GtkWidget *item = gtk_menu_item_new_with_mnemonic (_("_Layouts")); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (groups_menu)); item = gtk_menu_item_new_with_mnemonic (_("Show _Keyboard Layout...")); gtk_widget_show (item); g_signal_connect (item, "activate", popup_menu_show_layout, NULL); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item); /* translators note: * This is the name of the sagarmatha-settings "region" panel */ item = gtk_menu_item_new_with_mnemonic (_("Region and Language Settings")); gtk_widget_show (item); g_signal_connect (item, "activate", popup_menu_launch_capplet, NULL); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item); for (i = 0; current_name && *current_name; i++, current_name++) { gchar *image_file = gkbd_status_get_image_filename (i); if (image_file == NULL) { item = gtk_menu_item_new_with_label (*current_name); } else { GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size (image_file, 24, 24, NULL); GtkWidget *img = gtk_image_new_from_pixbuf (pixbuf); item = gtk_image_menu_item_new_with_label (*current_name); gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), img); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE); g_free (image_file); } gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (groups_menu), item); g_signal_connect (item, "activate", G_CALLBACK (popup_menu_set_group_cb), GINT_TO_POINTER (i)); } return popup_menu; }