示例#1
0
static GtkWidget *
make_menubar (void)
{
    GtkWidget *w, *menu;
    GtkWidget *menubar = gtk_menu_bar_new ();

    /* FIXME: add translatable string here */
    w = gtk_menu_item_new_with_label ("Menu");
    gtk_menu_shell_append (GTK_MENU_SHELL (menubar), w);
    gtk_widget_show (GTK_WIDGET (w));

    menu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (w), menu);

    w = gtk_image_menu_item_new_with_mnemonic (_("Select _Language..."));
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (w),
                                   gtk_image_new_from_icon_name ("preferences-desktop-locale", GTK_ICON_SIZE_MENU));

    gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
    gtk_widget_show (GTK_WIDGET (w));
    g_signal_connect (G_OBJECT (w), "activate",
                      G_CALLBACK (activate_button),
                      "language_button");

    w = gtk_image_menu_item_new_with_mnemonic (_("Select _Session..."));
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (w),
                                   gtk_image_new_from_icon_name ("user-desktop", GTK_ICON_SIZE_MENU));

    gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
    gtk_widget_show (GTK_WIDGET (w));
    g_signal_connect (G_OBJECT (w), "activate",
                      G_CALLBACK (activate_button),
                      "session_button");

    greeter_system_append_system_menu (menu);

    /* Add a quit/disconnect item when in xdmcp mode or flexi mode */
    /* Do note that the order is important, we always want "Quit" for
     * flexi, even if not local (non-local xnest).  and Disconnect
     * only for xdmcp */
    if ( ! ve_string_empty (g_getenv ("MDM_FLEXI_SERVER"))) {
        w = gtk_image_menu_item_new_with_mnemonic (_("_Quit"));
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (w),
                                       gtk_image_new_from_icon_name ("system-log-out", GTK_ICON_SIZE_MENU));
    } else if (ve_string_empty (g_getenv ("MDM_IS_LOCAL"))) {
        w = gtk_image_menu_item_new_with_mnemonic (_("D_isconnect"));
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (w),
                                       gtk_image_new_from_icon_name ("system-log-out", GTK_ICON_SIZE_MENU));
    } else {
        w = NULL;
    }
    if (w != NULL) {
        GtkWidget *sep;
        /* add separator before the quit */
        sep = gtk_separator_menu_item_new ();
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), sep);
        gtk_widget_show (GTK_WIDGET (sep));

        gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
        gtk_widget_show (GTK_WIDGET (w));
        g_signal_connect (G_OBJECT (w), "activate",
                          G_CALLBACK (gtk_main_quit), NULL);
    }

    g_signal_connect (G_OBJECT(gtk_menu_item_get_submenu(
                                   gtk_container_get_children(GTK_CONTAINER(menubar))->data)), "selection-done", G_CALLBACK (menubar_done), NULL);

    return menubar;
}
示例#2
0
static GtkWidget *create_popup_menu(void)
{
	GtkWidget *item, *menu, *image;

	menu = gtk_menu_new();

	image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	item = gtk_image_menu_item_new_with_mnemonic(_("New Project"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_new_project), NULL);
	popup_items.new_project = item;

	image = gtk_image_new_from_stock(GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	item = gtk_image_menu_item_new_with_mnemonic(_("Delete Project"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_delete_project), NULL);
	popup_items.delete_project = item;

	item = gtk_separator_menu_item_new();
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);

	image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	item = gtk_image_menu_item_new_with_mnemonic(_("Add File"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_add_file), NULL);
	popup_items.add_file = item;

	image = gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	item = gtk_image_menu_item_new_with_mnemonic(_("Remove File"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_remove_files), NULL);
	popup_items.remove_files = item;

	item = gtk_separator_menu_item_new();
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);

	image = gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	item = gtk_image_menu_item_new_with_mnemonic(_("Preferences"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_preferences), NULL);
	popup_items.preferences = item;

	item = gtk_separator_menu_item_new();
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);

	image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	item = gtk_image_menu_item_new_with_mnemonic(_("Find in Project"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_find_in_project), NULL);
	popup_items.find_in_files = item;

	item = gtk_separator_menu_item_new();
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);

	item = gtk_image_menu_item_new_with_mnemonic(_("H_ide Sidebar"));
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
				      gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
	gtk_widget_show(item);
	gtk_container_add(GTK_CONTAINER(menu), item);
	g_signal_connect_swapped((gpointer) item, "activate",
				 G_CALLBACK(keybindings_send_command),
				 GINT_TO_POINTER(GEANY_KEYS_VIEW_SIDEBAR));

	return menu;
}
示例#3
0
/* [gtk thread] */
static GtkWidget *build_menu_item(ALLEGRO_MENU_ITEM *aitem)
{
   GtkWidget *gitem;
   
   if (!aitem->caption) {
      gitem = gtk_separator_menu_item_new();
   }
   else {
      ALLEGRO_USTR *caption = al_ustr_dup(aitem->caption);
      
      /* convert & to _ using unprintable chars as placeholders */
      al_ustr_find_replace_cstr(caption, 0, "_", "\x01\x02");
      al_ustr_find_replace_cstr(caption, 0, "&", "_");
      al_ustr_find_replace_cstr(caption, 0, "\x01\x02", "__");
      
      if (aitem->flags & ALLEGRO_MENU_ITEM_CHECKBOX) {
         gitem = gtk_check_menu_item_new_with_mnemonic(al_cstr(caption));
         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gitem), aitem->flags & ALLEGRO_MENU_ITEM_CHECKED);
         g_signal_connect_swapped (gitem, "toggled", G_CALLBACK(checkbox_on_toggle),
            (gpointer) aitem);
      }
      else {
         /* always create an image menu item, in case the user ever sets an icon */
         gitem = gtk_image_menu_item_new_with_mnemonic(al_cstr(caption));
         
         if (aitem->icon) {
            const int w = al_get_bitmap_width(aitem->icon), h = al_get_bitmap_height(aitem->icon);
            const int stride = w * 4;
            int x, y, i;
            GdkPixbuf *pixbuf;
            uint8_t *data = al_malloc(stride * h);
            
            if (data) {
               for (y = 0, i = 0; y < h; ++y) {
                  for (x = 0; x < w; ++x, i += 4) {
                     al_unmap_rgba(al_get_pixel(aitem->icon, x, y),
                        &data[i],
                        &data[i + 1],
                        &data[i + 2],
                        &data[i + 3]
                     );
                  }
               }
               
               pixbuf = gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB, TRUE, 8,
                  w, h, stride, destroy_pixbuf, NULL);
               
               aitem->extra2 = gtk_image_new_from_pixbuf(pixbuf);
               
               gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gitem), aitem->extra2);
               
               /* Subtract the main reference. the image still holds a reference, so the
                * pixbuf won't be destroyed until the image itself is. */
               g_object_unref(pixbuf);
            }
         }
      }
      
      al_ustr_free(caption);
      
      gtk_widget_set_sensitive(gitem, !(aitem->flags & ALLEGRO_MENU_ITEM_DISABLED));
      
      aitem->extra1 = gitem;
      
      if (aitem->popup) {
         GtkWidget *gsubmenu = gtk_menu_new();
         build_menu(gsubmenu, aitem->popup);
         aitem->popup->extra1 = gsubmenu;
         gtk_widget_show(gsubmenu);
         gtk_menu_item_set_submenu(GTK_MENU_ITEM(gitem), gsubmenu);
      }
      else if (aitem->id) {
         g_signal_connect_swapped (gitem, "activate",
            G_CALLBACK(menuitem_response), (gpointer) aitem);
      }
   }
      
   gtk_widget_show(gitem);
   
   return gitem;
}
示例#4
0
GtkWidget *
create_window1 (void)
{
	GtkWidget *vbox1;

	/* menu */
	GtkWidget *menubar1;
	GtkWidget *menuitem1;
	GtkWidget *menuitem1_menu;
	GtkWidget *open;
	GtkWidget *apply;
	GtkWidget *save;
	GtkWidget *separatormenuitem1;
	GtkWidget *save_picture;
	GtkWidget *save_picture_image;
	GtkWidget *xsane;
	GtkWidget *separatormenuitem2;
	GtkWidget *quit;
	GtkWidget *menuitem2;
	GtkWidget *menuitem2_menu;
	GtkWidget *font;
	GtkWidget *separator2;
	GtkWidget *spell_check;
	GtkWidget *separator3;
	GtkWidget *menuitem3;
	GtkWidget *menuitem3_menu;
	GtkWidget *zoom_in;
	GtkWidget *zoom_out;
	GtkWidget *normal_size;
	GtkWidget *menuitem4;
	GtkWidget *menuitem4_menu;
	GtkWidget *about;
	GtkAccelGroup *accel_group;

	/* toolbar */
	GtkWidget *toolbar;
	GtkIconSize tmp_toolbar_icon_size;
	GtkWidget *toolbutton_open;
	GtkWidget *toolbutton_apply;
	GtkWidget *toolbutton_save;
	GtkWidget *toolitem1;
	GtkWidget *vseparator1;
	GtkWidget *toolbutton_spell;
	GtkWidget *toolitem2;
	GtkWidget *vseparator2;
	GtkWidget *toolbutton_zoom_in;
	GtkWidget *toolbutton_zoom_out;
	GtkWidget *toolbutton_zoom_fit;

	/* image */
	GtkWidget *vpaned1;
	GtkWidget *scrolledwindow_image;

	/* text */
	GtkTooltips *tooltips;

	PangoFontDescription *font_desc;

	tooltips = gtk_tooltips_new ();
	accel_group = gtk_accel_group_new ();

	window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (window1, 600, 300);
	gtk_window_maximize (GTK_WINDOW (window1));
	gtk_window_set_title (GTK_WINDOW (window1), _("hocr-gtk"));

	vbox1 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox1);
	gtk_container_add (GTK_CONTAINER (window1), vbox1);

	/* menu */

	menubar1 = gtk_menu_bar_new ();
	gtk_widget_show (menubar1);
	gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);

	menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File"));
	gtk_widget_show (menuitem1);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);

	menuitem1_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);

	open = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
	gtk_widget_show (open);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), open);

	apply = gtk_image_menu_item_new_from_stock ("gtk-apply", accel_group);
	gtk_widget_show (apply);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), apply);

	save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
	gtk_widget_show (save);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), save);

	separatormenuitem1 = gtk_separator_menu_item_new ();
	gtk_widget_show (separatormenuitem1);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem1);
	gtk_widget_set_sensitive (separatormenuitem1, FALSE);

	save_picture = gtk_image_menu_item_new_with_label (_("Save Picture"));
	save_picture_image =
		gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
	gtk_widget_show (save_picture_image);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_picture),
				       save_picture_image);
	gtk_widget_show (save_picture);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), save_picture);

	xsane = gtk_menu_item_new_with_label (_("Xsane"));
	gtk_widget_show (xsane);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), xsane);
	
	separatormenuitem2 = gtk_separator_menu_item_new ();
	gtk_widget_show (separatormenuitem2);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem2);
	gtk_widget_set_sensitive (separatormenuitem2, FALSE);

	quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
	gtk_widget_show (quit);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit);

	menuitem2 = gtk_menu_item_new_with_mnemonic (_("_Edit"));
	gtk_widget_show (menuitem2);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem2);

	menuitem2_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem2), menuitem2_menu);

	font = gtk_image_menu_item_new_from_stock ("gtk-select-font",
						   accel_group);
	gtk_widget_show (font);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), font);

	separator2 = gtk_separator_menu_item_new ();
	gtk_widget_show (separator2);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), separator2);
	gtk_widget_set_sensitive (separator2, FALSE);

#ifdef WITH_GTKSPELL
	spell_check =
		gtk_image_menu_item_new_from_stock ("gtk-spell-check",
						    accel_group);
	gtk_widget_show (spell_check);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), spell_check);

	separator3 = gtk_separator_menu_item_new ();
	gtk_widget_show (separator3);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), separator3);
	gtk_widget_set_sensitive (separator3, FALSE);
#endif

	color_text_box =
		gtk_check_menu_item_new_with_mnemonic (_("Color boxes"));
	gtk_widget_show (color_text_box);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), color_text_box);
	gtk_tooltips_set_tip (tooltips, color_text_box, _("Color text boxes"),
			      NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (color_text_box),
					TRUE);

	color_misread =
		gtk_check_menu_item_new_with_mnemonic (_("Color misread"));
	gtk_widget_show (color_misread);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), color_misread);
	gtk_tooltips_set_tip (tooltips, color_misread, _("Color misread fonts"),
			      NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (color_misread),
					TRUE);

	clear_text = gtk_check_menu_item_new_with_mnemonic (_("Clear"));
	gtk_widget_show (clear_text);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), clear_text);
	gtk_tooltips_set_tip (tooltips, clear_text,
			      _("Clear text each time you ocr new scan"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (clear_text), TRUE);

	ocr = gtk_check_menu_item_new_with_mnemonic (_("Ocr"));
	gtk_widget_show (ocr);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), ocr);
	gtk_tooltips_set_tip (tooltips, ocr,
			      _("Try to recognize fonts in scaned text"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (ocr), TRUE);

	use_dict = gtk_check_menu_item_new_with_mnemonic (_("Use dictionary"));
	gtk_widget_show (use_dict);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_dict);
	gtk_tooltips_set_tip (tooltips, use_dict,
			      _
			      ("Try to guess unrecognized fonts in scaned text using internal dictionary"),
			      NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_dict), FALSE);

	use_nikud = gtk_check_menu_item_new_with_mnemonic (_("Use nikud"));
	gtk_widget_show (use_nikud);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_nikud);
	gtk_tooltips_set_tip (tooltips, use_nikud,
			      _("Try to guess nikud"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_nikud), TRUE);

	use_spaces = gtk_check_menu_item_new_with_mnemonic (_("Use spaces"));
	gtk_widget_show (use_spaces);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_spaces);
	gtk_tooltips_set_tip (tooltips, use_spaces,
			      _("Use spaces for tabs"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_spaces),
					FALSE);

	use_indent =
		gtk_check_menu_item_new_with_mnemonic (_("Use indentation"));
	gtk_widget_show (use_indent);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_indent);
	gtk_tooltips_set_tip (tooltips, use_indent,
			      _("Try to guess line indentation"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_indent),
					FALSE);

	menuitem3 = gtk_menu_item_new_with_mnemonic (_("_View"));
	gtk_widget_show (menuitem3);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem3);

	menuitem3_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem3), menuitem3_menu);

	zoom_in =
		gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group);
	gtk_widget_show (zoom_in);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), zoom_in);

	zoom_out =
		gtk_image_menu_item_new_from_stock ("gtk-zoom-out",
						    accel_group);
	gtk_widget_show (zoom_out);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), zoom_out);

	normal_size =
		gtk_image_menu_item_new_from_stock ("gtk-zoom-100",
						    accel_group);
	gtk_widget_show (normal_size);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), normal_size);

	menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Help"));
	gtk_widget_show (menuitem4);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);

	menuitem4_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

	about = gtk_menu_item_new_with_mnemonic (_("_About"));
	gtk_widget_show (about);
	gtk_container_add (GTK_CONTAINER (menuitem4_menu), about);

	/* toolbar */
	toolbar = gtk_toolbar_new ();
	gtk_widget_show (toolbar);
	gtk_box_pack_start (GTK_BOX (vbox1), toolbar, FALSE, FALSE, 0);
	gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH);
	tmp_toolbar_icon_size =
		gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar));

	toolbutton_open =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-open");
	gtk_widget_show (toolbutton_open);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_open);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_open), tooltips,
				   _("Open a new picture for the OCR"), NULL);

	toolbutton_apply =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-apply");
	gtk_widget_show (toolbutton_apply);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_apply);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_apply), tooltips,
				   _("Convert picture to text"), NULL);

	toolbutton_save =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-save");
	gtk_widget_show (toolbutton_save);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_save);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_save), tooltips,
				   _("Save the text created by the OCR"), NULL);

	toolitem1 = (GtkWidget *) gtk_tool_item_new ();
	gtk_widget_show (toolitem1);
	gtk_container_add (GTK_CONTAINER (toolbar), toolitem1);
	vseparator1 = gtk_vseparator_new ();
	gtk_widget_show (vseparator1);
	gtk_container_add (GTK_CONTAINER (toolitem1), vseparator1);

#ifdef WITH_GTKSPELL
	toolbutton_spell =
		(GtkWidget *)
		gtk_tool_button_new_from_stock ("gtk-spell-check");
	gtk_widget_show (toolbutton_spell);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_spell);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_spell), tooltips,
				   _("Spell check the text"), NULL);

	toolitem2 = (GtkWidget *) gtk_tool_item_new ();
	gtk_widget_show (toolitem2);
	gtk_container_add (GTK_CONTAINER (toolbar), toolitem2);
	vseparator2 = gtk_vseparator_new ();
	gtk_widget_show (vseparator2);
	gtk_container_add (GTK_CONTAINER (toolitem2), vseparator2);
#endif

	toolbutton_zoom_in =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-zoom-in");
	gtk_widget_show (toolbutton_zoom_in);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_zoom_in);

	toolbutton_zoom_out =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-zoom-out");
	gtk_widget_show (toolbutton_zoom_out);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_zoom_out);

	toolbutton_zoom_fit =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-zoom-fit");
	gtk_widget_show (toolbutton_zoom_fit);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_zoom_fit);

	/* image */
	vpaned1 = gtk_vpaned_new ();
	gtk_widget_show (vpaned1);
	gtk_container_add (GTK_CONTAINER (vbox1), vpaned1);

	scrolledwindow_image = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy ((GtkScrolledWindow *)
					scrolledwindow_image,
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_widget_show (scrolledwindow_image);
	gtk_container_add (GTK_CONTAINER (vpaned1), scrolledwindow_image);

	viewport1 = gtk_viewport_new (NULL, NULL);
	gtk_widget_show (viewport1);
	gtk_container_add (GTK_CONTAINER (scrolledwindow_image), viewport1);

	image = gtk_image_new ();
	gtk_widget_show (image);
	gtk_container_add (GTK_CONTAINER (viewport1), image);

	/* text */
	scrolledwindow_text = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy ((GtkScrolledWindow *)
					scrolledwindow_text,
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_widget_show (scrolledwindow_text);
	gtk_container_add (GTK_CONTAINER (vpaned1), scrolledwindow_text);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
					     (scrolledwindow_text),
					     GTK_SHADOW_IN);

	textview = gtk_text_view_new ();
	gtk_widget_show (textview);
	gtk_container_add (GTK_CONTAINER (scrolledwindow_text), textview);
	font_desc = pango_font_description_from_string (font_name);
	gtk_widget_modify_font (textview, font_desc);

	font_name = g_strdup (TEXT_FONT_NAME);

	/* progress bar */
	hbox2 = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox2);
	gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);

	pbar = gtk_progress_bar_new ();
	gtk_widget_show (pbar);
	gtk_box_pack_start (GTK_BOX (hbox2), pbar, FALSE, FALSE, 0);
	gtk_widget_set_size_request (pbar, 100, -1);

	statusbar1 = gtk_statusbar_new ();
	gtk_widget_show (statusbar1);
	gtk_box_pack_start (GTK_BOX (hbox2), statusbar1, TRUE, TRUE, 0);

	/* main window */
	g_signal_connect ((gpointer) window1, "delete_event",
			  G_CALLBACK (on_window1_delete_event), NULL);

	/* toolbar */
	g_signal_connect ((gpointer) toolbutton_open, "clicked",
			  G_CALLBACK (on_toolbutton_open_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_apply, "clicked",
			  G_CALLBACK (on_toolbutton_apply_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_save, "clicked",
			  G_CALLBACK (on_toolbutton_save_clicked), NULL);

	g_signal_connect ((gpointer) toolbutton_zoom_in, "clicked",
			  G_CALLBACK (on_toolbutton_zoom_in_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_zoom_out, "clicked",
			  G_CALLBACK (on_toolbutton_zoom_out_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_zoom_fit, "clicked",
			  G_CALLBACK (on_toolbutton_zoom_fit_clicked), NULL);

#ifdef WITH_GTKSPELL
	g_signal_connect ((gpointer) toolbutton_spell, "clicked",
			  G_CALLBACK (on_toolbutton_spell_clicked), NULL);
#endif

	/* menu */
	g_signal_connect ((gpointer) open, "activate",
			  G_CALLBACK (on_open_activate), NULL);
	g_signal_connect ((gpointer) apply, "activate",
			  G_CALLBACK (on_apply_activate), NULL);
	g_signal_connect ((gpointer) save, "activate",
			  G_CALLBACK (on_save_activate), NULL);
	g_signal_connect ((gpointer) save_picture, "activate",
			  G_CALLBACK (on_save_picture_activate), NULL);
	g_signal_connect ((gpointer) xsane, "activate",
			  G_CALLBACK (on_xsane_activate), NULL);
	g_signal_connect ((gpointer) quit, "activate",
			  G_CALLBACK (on_quit_activate), NULL);
	g_signal_connect ((gpointer) font, "activate",
			  G_CALLBACK (on_font_activate), NULL);
#ifdef WITH_GTKSPELL
	g_signal_connect ((gpointer) spell_check, "activate",
			  G_CALLBACK (on_spell_check_activate), NULL);
#endif
	g_signal_connect ((gpointer) zoom_in, "activate",
			  G_CALLBACK (on_zoom_in_activate), NULL);
	g_signal_connect ((gpointer) zoom_out, "activate",
			  G_CALLBACK (on_zoom_out_activate), NULL);
	g_signal_connect ((gpointer) normal_size, "activate",
			  G_CALLBACK (on_normal_size_activate), NULL);
	g_signal_connect ((gpointer) about, "activate",
			  G_CALLBACK (on_about_activate), NULL);

	gtk_window_add_accel_group (GTK_WINDOW (window1), accel_group);

	return window1;
}
示例#5
0
/** \brief Show popup menu for a pass.
 *
 *
 */
void
pass_popup_menu_exec (qth_t *qth, pass_t *pass, GdkEventButton *event, GtkWidget *toplevel)
{
     GtkWidget        *menu;
     GtkWidget        *menuitem;
     GtkWidget        *image;
     gchar            *buff;


     menu = gtk_menu_new ();

     /* pass details */
     menuitem = gtk_image_menu_item_new_with_label (_("Show details"));
     image = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_FILL,
                           GTK_ICON_SIZE_MENU);
     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
     g_object_set_data (G_OBJECT (menuitem), "pass", pass);
     g_object_set_data (G_OBJECT (menuitem), "qth", qth);
     g_signal_connect (menuitem, "activate",
                 G_CALLBACK (show_pass_details),
                 toplevel);
     gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
     
     /* separator */
     menuitem = gtk_separator_menu_item_new ();
     gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);


     /* Polar plot pass */
     menuitem = gtk_image_menu_item_new_with_label (_("Polar plot"));
     buff = icon_file_name ("gpredict-polar-small.png");
     image = gtk_image_new_from_file (buff);
     g_free (buff);
     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
     g_object_set_data (G_OBJECT (menuitem), "pass", pass);
     g_object_set_data (G_OBJECT (menuitem), "qth", qth);
     g_signal_connect (menuitem, "activate",
                 G_CALLBACK (polar_plot_pass_details),
                 toplevel);
     gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
     gtk_widget_set_sensitive (menuitem, FALSE);
          
     /* Az/El plot pass */
     menuitem = gtk_image_menu_item_new_with_label (_("Az/El plot"));
     buff = icon_file_name ("gpredict-azel-small.png");
     image = gtk_image_new_from_file (buff);
     g_free (buff);
     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
     g_object_set_data (G_OBJECT (menuitem), "pass", pass);
     g_object_set_data (G_OBJECT (menuitem), "qth", qth);
     g_signal_connect (menuitem, "activate",
                 G_CALLBACK (azel_plot_pass_details),
                 toplevel);
     gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
     gtk_widget_set_sensitive (menuitem, FALSE);


     gtk_widget_show_all (menu);

     /* Note: event can be NULL here when called from view_onPopupMenu;
      *  gdk_event_get_time() accepts a NULL argument */
     gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
               (event != NULL) ? event->button : 0,
               gdk_event_get_time ((GdkEvent*) event));
          

}
示例#6
0
static gboolean
gtk_tool_button_create_menu_proxy (GtkToolItem *item)
{
  GtkToolButton *button = GTK_TOOL_BUTTON (item);
  GtkWidget *menu_item;
  GtkWidget *menu_image = NULL;
  GtkStockItem stock_item;
  gboolean use_mnemonic = TRUE;
  const char *label;

  if (_gtk_tool_item_create_menu_proxy (item))
    return TRUE;

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

  if (GTK_IS_LABEL (button->priv->label_widget))
    {
      label = gtk_label_get_label (GTK_LABEL (button->priv->label_widget));
      use_mnemonic = gtk_label_get_use_underline (GTK_LABEL (button->priv->label_widget));
    }
  else if (button->priv->label_text)
    {
      label = button->priv->label_text;
      use_mnemonic = button->priv->use_underline;
    }
  else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item))
    {
      label = stock_item.label;
    }
  else
    {
      label = "";
    }

  if (use_mnemonic)
    menu_item = gtk_image_menu_item_new_with_mnemonic (label);
  else
    menu_item = gtk_image_menu_item_new_with_label (label);

  if (GTK_IS_IMAGE (button->priv->icon_widget))
    {
      menu_image = clone_image_menu_size (GTK_IMAGE (button->priv->icon_widget));
    }
  else if (button->priv->stock_id)
    {
      menu_image = gtk_image_new_from_stock (button->priv->stock_id, GTK_ICON_SIZE_MENU);
    }

  if (menu_image)
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), menu_image);

  G_GNUC_END_IGNORE_DEPRECATIONS;

  g_signal_connect_closure_by_id (menu_item,
				  g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
				  g_cclosure_new_object_swap (G_CALLBACK (gtk_button_clicked),
							      G_OBJECT (GTK_TOOL_BUTTON (button)->priv->button)),
				  FALSE);

  gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (button), MENU_ID, menu_item);
  
  return TRUE;
}
示例#7
0
void ptk_menu_add_items_from_data( GtkWidget* menu,
                                   PtkMenuItemEntry* entries,
                                   gpointer cb_data,
                                   GtkAccelGroup* accel_group )
{
  PtkMenuItemEntry* ent;
  GtkWidget* menu_item = NULL;
  GtkWidget* sub_menu;
  GtkWidget* image;
  GSList* radio_group = NULL;
  const char* signal;

  for( ent = entries; ; ++ent )
  {
    if( G_LIKELY( ent->label ) )
    {
      /* Stock item */
      signal = "activate";
      if( G_UNLIKELY( PTK_IS_STOCK_ITEM(ent) ) )  {
        menu_item = gtk_image_menu_item_new_from_stock( ent->label, accel_group );
      }
      else if( G_LIKELY(ent->stock_icon) )  {
        if( G_LIKELY( ent->stock_icon > (char *)2 ) )  {
          menu_item = gtk_image_menu_item_new_with_mnemonic(_(ent->label));
          image = gtk_image_new_from_stock( ent->stock_icon, GTK_ICON_SIZE_MENU );
          gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menu_item), image );
        }
        else if( G_UNLIKELY( PTK_IS_CHECK_MENU_ITEM(ent) ) )  {
          menu_item = gtk_check_menu_item_new_with_mnemonic(_(ent->label));
          signal = "toggled";
        }
        else if( G_UNLIKELY( PTK_IS_RADIO_MENU_ITEM(ent) ) )  {
          menu_item = gtk_radio_menu_item_new_with_mnemonic( radio_group, _(ent->label) );
          if( G_LIKELY( PTK_IS_RADIO_MENU_ITEM( (ent + 1) ) ) )
            radio_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(menu_item) );
          else
            radio_group = NULL;
          signal = "toggled";
        }
      }
      else  {
        menu_item = gtk_menu_item_new_with_mnemonic(_(ent->label));
      }

      if( G_LIKELY(accel_group) && ent->key ) {
        gtk_widget_add_accelerator (menu_item, "activate", accel_group,
                                    ent->key, ent->mod, GTK_ACCEL_VISIBLE);
      }

      if( G_LIKELY(ent->callback) )  { /* Callback */
        g_signal_connect( menu_item, signal, ent->callback, cb_data);
      }

      if( G_UNLIKELY( ent->sub_menu ) )  { /* Sub menu */
        sub_menu = ptk_menu_new_from_data( ent->sub_menu, cb_data, accel_group );
        gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu_item), sub_menu );
        ent->menu = sub_menu;  //MOD
      }
    }
    else
    {
      if( ! ent->stock_icon ) /* End of menu */
        break;
        menu_item = gtk_separator_menu_item_new();      
    }

    gtk_menu_shell_append ( GTK_MENU_SHELL(menu), menu_item );
    if( G_UNLIKELY(ent->ret) ) {// Return
      *ent->ret = menu_item;
      ent->ret = NULL;
    }

  }
}
示例#8
0
XttTblGtk::XttTblGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
    sevcli_tCtx a_sevcli, sevcli_sHistItem* itemlist, int item_cnt)
    : XttTbl(a_parent_ctx, a_sevcli), parent_wid(a_parent_wid)
{
  int sts;
  pwr_tFileName fname;

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 700,
      "default-width", 500, "title", "SevXtt Navigator", NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(xtttbl_focus_in_event), this);

  CoWowGtk::SetWindowIcon(toplevel);

  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_print = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Print"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(file_print),
      gtk_image_new_from_stock("gtk-print", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  GtkWidget* file_login
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Login"));
  g_signal_connect(file_login, "activate", G_CALLBACK(activate_login), this);

  GtkWidget* file_logout
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Log_Out"));
  g_signal_connect(file_logout, "activate", G_CALLBACK(activate_logout), this);

  GtkWidget* file_close
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_close), this);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_login);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_logout);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget* functions_opensevhist = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Open Process History"));
  g_signal_connect(functions_opensevhist, "activate",
      G_CALLBACK(activate_opensevhist), this);
  gtk_widget_add_accelerator(functions_opensevhist, "activate", accel_g, 'g',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_command
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Co_mmand"));
  g_signal_connect(
      functions_command, "activate", G_CALLBACK(activate_command), this);
  gtk_widget_add_accelerator(functions_command, "activate", accel_g, 'b',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_delete_item = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Delete Item"));
  g_signal_connect(functions_delete_item, "activate",
      G_CALLBACK(activate_delete_item), this);

  GtkMenu* functions_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_opensevhist);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_command);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_delete_item);

  GtkWidget* functions
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(
      GTK_MENU_ITEM(functions), GTK_WIDGET(functions_menu));

  // View menu
  GtkWidget* view_tree_layout = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Tree Layout"));
  g_signal_connect(
      view_tree_layout, "activate", G_CALLBACK(activate_tree_layout), this);

  GtkWidget* view_list_layout = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_List Layout"));
  g_signal_connect(
      view_list_layout, "activate", G_CALLBACK(activate_list_layout), this);

  GtkWidget* view_zoom_in = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(view_zoom_in),
      gtk_image_new_from_stock("gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect(
      view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
  gtk_widget_add_accelerator(view_zoom_in, "activate", accel_g, 'i',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* view_zoom_out = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(view_zoom_out),
      gtk_image_new_from_stock("gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect(
      view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
  gtk_widget_add_accelerator(view_zoom_out, "activate", accel_g, 'o',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(view_zoom_reset),
      gtk_image_new_from_stock("gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect(
      view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);

  GtkMenu* view_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_tree_layout);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_list_layout);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);

  GtkWidget* view
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Help entry
  GtkWidget* help_overview = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Overview"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(help_overview),
      gtk_image_new_from_stock("gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_overview, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator(help_overview, "activate", accel_g, 'h',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* help_project
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Project"));
  g_signal_connect(
      help_project, "activate", G_CALLBACK(activate_help_project), this);

  GtkWidget* help_proview = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_About Proview"));
  g_signal_connect(
      help_proview, "activate", G_CALLBACK(activate_help_proview), this);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_overview);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_project);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_proview);

  GtkWidget* help
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Toolbar
  GtkToolbar* tools = (GtkToolbar*)g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget* tools_opensevhist = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_meth_trend.png");
  gtk_container_add(
      GTK_CONTAINER(tools_opensevhist), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_opensevhist, "clicked", G_CALLBACK(activate_opensevhist), this);
  g_object_set(tools_opensevhist, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(tools, tools_opensevhist,
      CoWowGtk::translate_utf8("Open history item"), "");

  GtkWidget* tools_zoom_in = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add(
      GTK_CONTAINER(tools_zoom_in), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_zoom_in, "clicked", G_CALLBACK(activate_zoom_in), this);
  g_object_set(tools_zoom_in, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(
      tools, tools_zoom_in, CoWowGtk::translate_utf8("Zoom in"), "");

  GtkWidget* tools_zoom_out = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add(
      GTK_CONTAINER(tools_zoom_out), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_zoom_out, "clicked", G_CALLBACK(activate_zoom_out), this);
  g_object_set(tools_zoom_out, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(
      tools, tools_zoom_out, CoWowGtk::translate_utf8("Zoom out"), "");

  GtkWidget* tools_zoom_reset = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add(
      GTK_CONTAINER(tools_zoom_reset), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_zoom_reset, "clicked", G_CALLBACK(activate_zoom_reset), this);
  g_object_set(tools_zoom_reset, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(
      tools, tools_zoom_reset, CoWowGtk::translate_utf8("Zoom reset"), "");

  // Statusbar and cmd input
  GtkWidget* statusbar = gtk_hbox_new(FALSE, 0);
  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);
  cmd_prompt = gtk_label_new("xtt > ");
  gtk_widget_set_size_request(cmd_prompt, -1, 25);

  cmd_recall = new CoWowRecall();
  cmd_entry = new CoWowEntryGtk(cmd_recall);
  cmd_input = cmd_entry->widget();
  gtk_widget_set_size_request(cmd_input, -1, 25);
  g_signal_connect(
      cmd_input, "activate", G_CALLBACK(valchanged_cmd_input), this);

  gtk_box_pack_start(GTK_BOX(statusbar), msg_label, FALSE, FALSE, 20);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 20);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 20);
  gtk_widget_show_all(statusbar);

  tblnav
      = new TblNavGtk(this, toplevel, itemlist, item_cnt, &brow_widget, &sts);
  tblnav->message_cb = &XttTbl::message;
  tblnav->is_authorized_cb = &XttTbl::is_authorized;
  tblnav->command_cb = &XttTbl::command_cb;

  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 3);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all(toplevel);

  g_object_set(cmd_prompt, "visible", FALSE, NULL);
  g_object_set(cmd_input, "visible", FALSE, NULL);

  // Create help window
  CoXHelp* xhelp = new CoXHelpGtk(toplevel, this, xhelp_eUtility_Xtt, &sts);
  CoXHelp::set_default(xhelp);

  wow = new CoWowGtk(toplevel);

  if (!is_authorized(pwr_mAccess_AllSev, 0))
    open_login();

  if (!quiet) {
    if (cologin)
      // Set login window as parent to warranty as focus is left to parent.
      ((CoWowGtk*)wow)->SetParent(((CoLoginGtk*)cologin)->widgets.toplevel);

    wow->DisplayWarranty();

    if (cologin)
      ((CoWowGtk*)wow)->SetParent(toplevel);
  }
}
static void
deskmenu_construct_item (DeskmenuObject *dm_object)
{
	DeskmenuItem *item = dm_object->current_item;
	GtkWidget *menu_item, *submenu;
	gchar *name, *icon, *command, *vpicon;
	gboolean images;
	gint w, h;
	//constructs the items in menu
	switch (item->type)
	{
		case DESKMENU_ITEM_LAUNCHER:
			if (item->name_exec)
			{
				GtkWidget *label;
				GHook *hook;

				name = g_strstrip (item->name->str);

				menu_item = gtk_image_menu_item_new ();
				label = gtk_label_new_with_mnemonic (NULL);
				gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

				g_object_set_data (G_OBJECT (label), "exec", g_strdup (name));
				gtk_container_add (GTK_CONTAINER (menu_item), label);
				hook = g_hook_alloc (dm_object->show_hooks);

				hook->data = (gpointer) label;
				hook->func = (GHookFunc *) launcher_name_exec_update;
				g_hook_append (dm_object->show_hooks, hook);
			}
			else
			{
				if (item->name)
					name = g_strstrip (item->name->str);
				else
					name = "";

				menu_item = gtk_image_menu_item_new_with_mnemonic (name);

			}
			if (item->icon)
			{
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                   )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
						gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU));
					}
			}
			if (item->command_pipe)
			{
				command = g_strstrip (item->command->str);
				if (item->cache_output)
				{
					g_object_set_data(G_OBJECT(menu_item), "cached", g_strdup("yes"));
				}
				else
				{
					g_object_set_data(G_OBJECT(menu_item), "cached", g_strdup("no"));
				}
				g_object_set_data(G_OBJECT(menu_item), "menu", dm_object);
				g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (pipe_menu_recreate), g_strdup(command));
				submenu = gtk_menu_new();
				gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			}
			else
			{
				if (item->command)
				{
					command = g_strstrip (item->command->str);
					g_signal_connect (G_OBJECT (menu_item), "activate",
						G_CALLBACK (launcher_activated), g_strdup (command));
				}
			}
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
				menu_item);
			break;
#if HAVE_WNCK
		case DESKMENU_ITEM_WINDOWLIST:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("_Windows");
			images = FALSE;
			gboolean this_vp = FALSE;
			gboolean mini_only = FALSE;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->thisvp
				&& strcmp (g_strstrip (item->thisvp->str), "true") == 0)
				this_vp = TRUE;
			if (item->mini_only
				&& strcmp (g_strstrip (item->mini_only->str), "true") == 0)
				mini_only = TRUE;
			g_object_set_data(G_OBJECT(menu_item), "windowlist", deskmenu_windowlist_initialize (images, this_vp, mini_only));
			g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (refresh_windowlist_item), NULL);
			submenu = gtk_menu_new();
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), menu_item);
			break;


		case DESKMENU_ITEM_DESKTOPLIST:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("_Desktops");
			gboolean file;
			images = FALSE;
			file = FALSE;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->vpicon)
			{
				vpicon = g_strstrip (parse_expand_tilde(item->vpicon->str));
				if (item->vpicon_file)
				{
					file = TRUE;
				}
			}
			else
			{
				vpicon = "";
			}
			g_object_set_data(G_OBJECT(menu_item), "dplist", deskmenu_dplist_initialize (images, file, vpicon));
			g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (refresh_desktoplist_item), NULL);
			submenu = gtk_menu_new();
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), menu_item);
			break;

		case DESKMENU_ITEM_VIEWPORTLIST:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("_Viewports");
			gboolean wrap;
			wrap = FALSE;
			images = FALSE;
			file = FALSE;
			if (item->wrap && strcmp (g_strstrip (item->wrap->str), "true") == 0)
				wrap = TRUE;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->vpicon)
			{
				vpicon = g_strstrip (parse_expand_tilde(item->vpicon->str));
				if (item->vpicon_file)
				{
					file = TRUE;
				}
			}
			else
			{
				vpicon = "";
			}
			g_object_set_data(G_OBJECT(menu_item), "vplist", deskmenu_vplist_initialize (wrap, images, file, vpicon));
			g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (refresh_viewportlist_item), NULL);
			submenu = gtk_menu_new();
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), menu_item);
			break;
#endif
		case DESKMENU_ITEM_RELOAD:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("Reload");

			if (item->icon)
			{
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			g_signal_connect (G_OBJECT (menu_item), "activate",
				G_CALLBACK (quit), NULL);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
				menu_item);
			break;

		case DESKMENU_ITEM_DOCUMENTS:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("Recent Doc_uments");
			gint limit, age;
			gchar *sort_type;
			images = FALSE;
			sort_type = "least used";
			age = 25;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->age)
			{
				age = atoi(g_strstrip (item->age->str));
			}
			if (item->sort_type)
			{
				sort_type = g_strstrip (item->sort_type->str);
			}
			if (item->quantity)
			{
				limit = atoi(g_strstrip (item->quantity->str));
			}
			else
			{
				limit = -1;
			}
			if (item->command)
			{
				command = g_strstrip (item->command->str);
			}
			else
			{
				command = g_strdup ("xdg-open");
			}
			GtkWidget *docs = make_recent_documents_list(images, command, limit, age, sort_type);
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item),
				docs);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
				menu_item);
			break;

		default:
			break;
	}

}
示例#10
0
static void
gnumeric_create_popup_menu_list (GSList *elements,
                                 GnumericPopupMenuHandler handler,
                                 gpointer user_data,
                                 int display_filter,
                                 int sensitive_filter,
                                 GdkEventButton *event)
{
    GtkWidget *menu, *item;
    char const *trans;

    menu = gtk_menu_new ();

    for (; elements != NULL ; elements = elements->next)
    {
        GnumericPopupMenuElement const *element = elements->data;
        char const * const name = element->name;
        char const * const pix_name = element->pixmap;

        item = NULL;

        if (element->display_filter != 0 &&
                !(element->display_filter & display_filter))
            continue;

        if (name != NULL && *name != '\0')
        {
            trans = _(name);
            item = gtk_image_menu_item_new_with_mnemonic (trans);
            if (element->sensitive_filter != 0 &&
                    (element->sensitive_filter & sensitive_filter))
                gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
            if (pix_name != NULL)
            {
                GtkWidget *image = gtk_image_new_from_stock (pix_name,
                                   GTK_ICON_SIZE_MENU);
                gtk_widget_show (image);
                gtk_image_menu_item_set_image (
                    GTK_IMAGE_MENU_ITEM (item),
                    image);
            }
        }
        else
        {
            /* separator */
            item = gtk_menu_item_new ();
            gtk_widget_set_sensitive (item, FALSE);
        }

        if (element->index != 0)
        {
            g_signal_connect (G_OBJECT (item),
                              "activate",
                              G_CALLBACK (&popup_item_activate), user_data);
            g_object_set_data (
                G_OBJECT (item), "descriptor", (gpointer)(element));
            g_object_set_data (
                G_OBJECT (item), "handler", (gpointer)handler);
        }

        gtk_widget_show (item);
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
    }

    gnumeric_popup_menu (GTK_MENU (menu), event);
}
示例#11
0
文件: theme.c 项目: seanregan/browser
void nsgtk_theme_implement(struct gtk_scaffolding *g)
{
	struct nsgtk_theme *theme[IMAGE_SET_COUNT];
	int i;
	struct nsgtk_button_connect *button;
	struct gtk_search *search;

	for (i = 0; i <= IMAGE_SET_POPUP_MENU; i++)
		theme[i] = nsgtk_theme_load(GTK_ICON_SIZE_MENU);

	theme[IMAGE_SET_BUTTONS] =
		nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);

	for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
		if ((i == URL_BAR_ITEM) || (i == THROBBER_ITEM) ||
		    (i == WEBSEARCH_ITEM))
			continue;
		button = nsgtk_scaffolding_button(g, i);
		if (button == NULL)
			continue;
		/* gtk_image_menu_item_set_image accepts NULL image */
		if ((button->main != NULL) &&
		    (theme[IMAGE_SET_MAIN_MENU] != NULL)) {
			gtk_image_menu_item_set_image(button->main,
						      GTK_WIDGET(
							      theme[IMAGE_SET_MAIN_MENU]->
							      image[i]));
			gtk_widget_show_all(GTK_WIDGET(button->main));
		}
		if ((button->rclick != NULL)  &&
		    (theme[IMAGE_SET_RCLICK_MENU] != NULL)) {
			gtk_image_menu_item_set_image(button->rclick,
						      GTK_WIDGET(
							      theme[IMAGE_SET_RCLICK_MENU]->
							      image[i]));
			gtk_widget_show_all(GTK_WIDGET(button->rclick));
		}
		if ((button->popup != NULL) &&
		    (theme[IMAGE_SET_POPUP_MENU] != NULL)) {
			gtk_image_menu_item_set_image(button->popup,
						      GTK_WIDGET(
							      theme[IMAGE_SET_POPUP_MENU]->
							      image[i]));
			gtk_widget_show_all(GTK_WIDGET(button->popup));
		}
		if ((button->location != -1) && (button->button	!= NULL) &&
		    (theme[IMAGE_SET_BUTTONS] != NULL)) {
			gtk_tool_button_set_icon_widget(
				GTK_TOOL_BUTTON(button->button),
				GTK_WIDGET(
					theme[IMAGE_SET_BUTTONS]->
					image[i]));
			gtk_widget_show_all(GTK_WIDGET(button->button));
		}
	}

	/* set search bar images */
	search = nsgtk_scaffolding_search(g);
	if ((search != NULL) && (theme[IMAGE_SET_MAIN_MENU] != NULL)) {
		/* gtk_tool_button_set_icon_widget accepts NULL image */
		if (search->buttons[SEARCH_BACK_BUTTON] != NULL) {
			gtk_tool_button_set_icon_widget(
				search->buttons[SEARCH_BACK_BUTTON],
				GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->
					   searchimage[SEARCH_BACK_BUTTON]));
			gtk_widget_show_all(GTK_WIDGET(
						    search->buttons[SEARCH_BACK_BUTTON]));
		}
		if (search->buttons[SEARCH_FORWARD_BUTTON] != NULL) {
			gtk_tool_button_set_icon_widget(
				search->buttons[SEARCH_FORWARD_BUTTON],
				GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->
					   searchimage[SEARCH_FORWARD_BUTTON]));
			gtk_widget_show_all(GTK_WIDGET(
						    search->buttons[
							    SEARCH_FORWARD_BUTTON]));
		}
		if (search->buttons[SEARCH_CLOSE_BUTTON] != NULL) {
			gtk_tool_button_set_icon_widget(
				search->buttons[SEARCH_CLOSE_BUTTON],
				GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->
					   searchimage[SEARCH_CLOSE_BUTTON]));
			gtk_widget_show_all(GTK_WIDGET(
						    search->buttons[SEARCH_CLOSE_BUTTON]));
		}
	}
	for (i = 0; i < IMAGE_SET_COUNT; i++) {
		if (theme[i] != NULL) {
			free(theme[i]);
		}
	}
}
示例#12
0
bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
{
    GtkWidget *menuItem;
    GtkWidget* prevRadio = m_prevRadio;
    m_prevRadio = NULL;
    switch (mitem->GetKind())
    {
        case wxITEM_SEPARATOR:
            menuItem = gtk_separator_menu_item_new();
            break;
        case wxITEM_CHECK:
            menuItem = gtk_check_menu_item_new_with_label("");
            break;
        case wxITEM_RADIO:
            {
                GSList* group = NULL;
                if (prevRadio)
                    group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(prevRadio));
                menuItem = gtk_radio_menu_item_new_with_label(group, "");
                m_prevRadio = menuItem;
            }
            break;
        default:
            wxFAIL_MSG("unexpected menu item kind");
            // fall through
        case wxITEM_NORMAL:
            const wxBitmap& bitmap = mitem->GetBitmap();
            const char* stockid;
            if (bitmap.IsOk())
            {
                // always use pixbuf, because pixmap mask does not
                // work with disabled images in some themes
                GtkWidget* image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf());
                menuItem = gtk_image_menu_item_new_with_label("");
                gtk_widget_show(image);
                gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuItem), image);
            }
            else if ((stockid = wxGetStockGtkID(mitem->GetId())) != NULL)
                // use stock bitmap for this item if available on the assumption
                // that it never hurts to follow GTK+ conventions more closely
                menuItem = gtk_image_menu_item_new_from_stock(stockid, NULL);
            else
                menuItem = gtk_menu_item_new_with_label("");
            break;
    }
    mitem->SetMenuItem(menuItem);

    gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);

    gtk_widget_show( menuItem );

    if ( !mitem->IsSeparator() )
    {
        mitem->SetGtkLabel();
        g_signal_connect (menuItem, "select",
                          G_CALLBACK(menuitem_select), mitem);
        g_signal_connect (menuItem, "deselect",
                          G_CALLBACK(menuitem_deselect), mitem);

        if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK )
        {
            gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );

            gtk_widget_show( mitem->GetSubMenu()->m_menu );
        }
        else
        {
            g_signal_connect(menuItem, "can_activate_accel",
                G_CALLBACK(can_activate_accel), this);
            g_signal_connect (menuItem, "activate",
                              G_CALLBACK(menuitem_activate),
                              mitem);
        }
    }

    return true;
}
示例#13
0
static void create_menu()
{
	GtkWidget *i;
	gchar *s;

	menu = GTK_MENU(gtk_menu_new());
	g_assert(menu != NULL);

	s = toutf("_Dostêpny");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "1");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_AVAILABLE));
	
	s = toutf("_Porozmawiajmy");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "2");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_CHATTY));

	s = toutf("_Jestem zajêty");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "3");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_DND));

	s = toutf("_Zaraz wracam");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "4");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_AWAY));

	s = toutf("_Wrócê pó¼niej");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "5");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_EXT_AWAY));

	s = toutf("_Niewidoczny");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "6");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_INVISIBLE));

	s = toutf("Niedostêpn_y");
	i = gtk_image_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "7");
	gtk_widget_show(i);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(i),
		get_status_icon_new(TLEN_PRESENCE_UNAVAILABLE));

	/* separator */
	i = gtk_menu_item_new();
	gtk_container_add(GTK_CONTAINER(menu), i);
	gtk_widget_set_sensitive(i, FALSE);
	gtk_widget_show(i);

	s = toutf("_Ustaw stan opisowy");
	i = gtk_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "8");
	gtk_widget_show(i);
	
	/* separator */
	i = gtk_menu_item_new();
	gtk_container_add(GTK_CONTAINER(menu), i);
	gtk_widget_set_sensitive(i, FALSE);
	gtk_widget_show(i);
	
	s = toutf("_Koniec");
	i = gtk_menu_item_new_with_mnemonic(s);
	g_free(s);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), i);
	g_signal_connect_swapped(G_OBJECT(i), "activate",
		G_CALLBACK(menu_item_cb), "9");
	gtk_widget_show(i);
}
/** \brief Show satellite popup menu.
 *  \param sat Pointer to the satellite data.
 *  \param qth The current location.
 *  \param pview The GtkPolarView widget.
 *  \param event The mouse-click related event info
 *  \param toplevel The toplevel window or NULL.
 *
 */
void
        gtk_polar_view_popup_exec (sat_t *sat,
                                   qth_t *qth,
                                   GtkPolarView *pview,
                                   GdkEventButton *event,
                                   GtkWidget *toplevel)
{
    GtkWidget        *menu;
    GtkWidget        *menuitem;
    GtkWidget        *label;
    GtkWidget        *image;
    gchar            *buff;
    sat_obj_t  *obj = NULL;
    gint           *catnum;



    menu = gtk_menu_new ();

    /* first menu item is the satellite name, centered */
    menuitem = gtk_image_menu_item_new ();
    label = gtk_label_new (NULL);
    gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
    buff = g_strdup_printf ("<b>%s</b>", sat->nickname);
    gtk_label_set_markup (GTK_LABEL (label), buff);
    g_free (buff);
    gtk_container_add (GTK_CONTAINER (menuitem), label);
    image = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);

    /* attach data to menuitem and connect callback */
    g_object_set_data (G_OBJECT (menuitem), "sat", sat);
    g_object_set_data (G_OBJECT (menuitem), "qth", qth);
    g_signal_connect (menuitem, "activate", G_CALLBACK (show_sat_info_menu_cb), toplevel);

    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* next pass and predict passes */
    menuitem = gtk_image_menu_item_new_with_label (_("Show next pass"));
    image = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_FILL, GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    g_object_set_data (G_OBJECT (menuitem), "sat", sat);
    g_object_set_data (G_OBJECT (menuitem), "qth", qth);
    g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_pass_cb), pview);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    menuitem = gtk_image_menu_item_new_with_label (_("Future passes"));
    image = gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    g_object_set_data (G_OBJECT (menuitem), "sat", sat);
    g_object_set_data (G_OBJECT (menuitem), "qth", qth);
    g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_passes_cb), pview);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* get sat obj since we'll need it for the remaining items */
    catnum = g_new0 (gint, 1);
    *catnum = sat->tle.catnr;
    obj = SAT_OBJ (g_hash_table_lookup (pview->obj, catnum));
    g_free (catnum);

    /* show track */
    menuitem = gtk_check_menu_item_new_with_label (_("Sky track"));
    g_object_set_data (G_OBJECT (menuitem), "sat", sat);
    g_object_set_data (G_OBJECT (menuitem), "qth", qth);
    g_object_set_data (G_OBJECT (menuitem), "obj", obj);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), obj->showtrack);
    g_signal_connect (menuitem, "activate", G_CALLBACK (track_toggled), pview);

    /* disable menu item if satellite is geostationary */
    if (sat->otype == ORBIT_TYPE_GEO)
        gtk_widget_set_sensitive (menuitem, FALSE);

    /* target */
    /*      menuitem = gtk_check_menu_item_new_with_label (_("Set as target")); */
    /*      g_object_set_data (G_OBJECT (menuitem), "sat", sat); */
    /*      g_object_set_data (G_OBJECT (menuitem), "qth", qth); */
    /*      g_object_set_data (G_OBJECT (menuitem), "obj", obj); */
    /*      gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); */
    /*      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), obj->istarget); */
    /*      g_signal_connect (menuitem, "activate", G_CALLBACK (target_toggled), pview); */

    gtk_widget_show_all (menu);

    /* Note: event can be NULL here when called from view_onPopupMenu;
         *  gdk_event_get_time() accepts a NULL argument */
    gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
                    (event != NULL) ? event->button : 0,
                    gdk_event_get_time ((GdkEvent*) event));


}
示例#15
0
WPkgGtk::WPkgGtk( 
	GtkWidget      	*wa_parent_wid,
	void 		*wa_parent_ctx)
  : WPkg(wa_parent_ctx), parent_wid(wa_parent_wid),
    clock_cursor(0)
{
  const int	window_width = 600;
  const int    	window_height = 600;
  int 		sts;
  pwr_tFileName fname;

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
			   "default-height", window_height,
			   "default-width", window_width,
			   "title", "Distributor",
			   NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  GtkWidget *file_history = gtk_menu_item_new_with_mnemonic( "_History");
  g_signal_connect( file_history, "activate", 
		    G_CALLBACK(WPkgGtk::activate_history), this);

  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(WPkgGtk::activate_exit), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_history);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions Entry
  GtkWidget *functions_distribute = gtk_menu_item_new_with_mnemonic( "_Distribute");
  g_signal_connect( functions_distribute, "activate", 
		    G_CALLBACK(WPkgGtk::activate_distribute), this);
  gtk_widget_add_accelerator( functions_distribute, "activate", accel_g,
			      'd', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_createpkg = gtk_menu_item_new_with_mnemonic( "_Create Package");
  g_signal_connect( functions_createpkg, "activate", 
		    G_CALLBACK(WPkgGtk::activate_createpkg), this);

  GtkWidget *functions_deletepkg = gtk_menu_item_new_with_mnemonic( "D_elete Package");
  g_signal_connect( functions_deletepkg, "activate", 
		    G_CALLBACK(WPkgGtk::activate_deletepkg), this);

  GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_distribute);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_createpkg);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_deletepkg);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic("F_unctions");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(functions_menu));

  // View menu
  GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
  g_signal_connect(view_zoom_in, "activate", G_CALLBACK(WPkgGtk::activate_zoom_in), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
  g_signal_connect(view_zoom_out, "activate", G_CALLBACK(WPkgGtk::activate_zoom_out), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
  g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(WPkgGtk::activate_zoom_reset), this);

  GtkWidget *view_dmode_filediff = gtk_menu_item_new_with_mnemonic( "_Display File Differences");
  g_signal_connect( view_dmode_filediff, "activate", 
		    G_CALLBACK(WPkgGtk::activate_dmode_filediff), this);

  GtkWidget *view_dmode_filetime = gtk_menu_item_new_with_mnemonic( "Display Files In _Time Order");
  g_signal_connect( view_dmode_filetime, "activate", 
		    G_CALLBACK(WPkgGtk::activate_dmode_filetime), this);

  GtkWidget *view_dmode_filepath = gtk_menu_item_new_with_mnemonic( "Display File _Path");
  g_signal_connect( view_dmode_filepath, "activate", 
		    G_CALLBACK(WPkgGtk::activate_dmode_filepath), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_dmode_filediff);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_dmode_filetime);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_dmode_filepath);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic("_Help");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(WPkgGtk::activate_help), this);
  gtk_widget_add_accelerator( help_help, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Toolbar
  GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget *tools_distribute = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/wpkg_distribute.png");
  gtk_container_add( GTK_CONTAINER(tools_distribute), 
	  gtk_image_new_from_file( fname));
  g_signal_connect(tools_distribute, "clicked", G_CALLBACK(WPkgGtk::activate_distribute), this);
  g_object_set( tools_distribute, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_distribute, "Distribute", "");

  GtkWidget *tools_zoom_in = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_in), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(WPkgGtk::activate_zoom_in), this);
  g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_in, "Zoom in", "");

  GtkWidget *tools_zoom_out = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_out), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(WPkgGtk::activate_zoom_out), this);
  g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_out, "Zoom out", "");

  GtkWidget *tools_zoom_reset = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_reset), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(WPkgGtk::activate_zoom_reset), this);
  g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_reset, "Zoom reset", "");

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);

  utility = ((WUtility *)parent_ctx)->utype;
  wpkgnav = new WPkgNavGtk( (void *)this, vbox, "Packages",
		utility, &brow_widget, &sts);
  ((WPkgNav *)wpkgnav)->message_cb = message_cb;
  ((WPkgNav *)wpkgnav)->set_clock_cursor_cb = set_clock_cursor_cb;
  ((WPkgNav *)wpkgnav)->reset_cursor_cb = reset_cursor_cb;

  GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
  msg_label = gtk_label_new( "");

  gtk_box_pack_start( GTK_BOX(statusbar), msg_label, FALSE, FALSE, 20);
  gtk_widget_show_all( statusbar);

  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 3);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all( toplevel);

  wow = new CoWowGtk( toplevel);

  if ( utility == wb_eUtility_Wtt) {
    ((Wtt *)parent_ctx)->register_utility( (void *) this,
	wb_eUtility_Distributor);
  }
}
示例#16
0
static void
start_element (GMarkupParseContext *context,
               const gchar         *element_name,
               const gchar        **attr_names,
               const gchar        **attr_values,
               gpointer             user_data,
               GError             **error)
{
	DeskmenuObject *dm_object = user_data;

	DeskmenuElementType element_type;
	const gchar **ncursor = attr_names, **vcursor = attr_values;
	GtkWidget *item, *menu;
	gint w, h;

	element_type = GPOINTER_TO_INT (g_hash_table_lookup
		(element_hash, element_name));

	if ((dm_object->menu && !dm_object->current_menu)
	   || (!dm_object->menu && element_type != DESKMENU_ELEMENT_MENU))
	{
		gint line_num, char_num;
		g_markup_parse_context_get_position (context, &line_num, &char_num);
		g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
			"Error on line %d char %d: Element '%s' declared outside of "
			"toplevel menu element", line_num, char_num, element_name);
		return;
	}

	switch (element_type)
	{
		case DESKMENU_ELEMENT_MENU:

			if (dm_object->current_item != NULL)
			{
				gint line_num, char_num;
				g_markup_parse_context_get_position (context, &line_num,
					&char_num);
				g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
					"Error on line %d char %d: Element 'menu' cannot be nested "
					"inside of an item element", line_num, char_num);
				return;
			}
			if (!dm_object->menu)
			{
				/*if (strcmp (*ncursor, "size") == 0) {
					deskmenu->w = g_strdup (*vcursor);
					deskmenu->h = g_strdup (*vcursor);
					}
				else {
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, deskmenu->w, deskmenu->h);
				}*/
				dm_object->menu = gtk_menu_new ();
				g_object_set_data (G_OBJECT (dm_object->menu), "parent menu",
					NULL);
				dm_object->current_menu = dm_object->menu;
			}
			else
			{
				gchar *name = NULL;
				gchar *icon = NULL;
				gboolean name_exec = FALSE;
				gboolean icon_file = FALSE;
				while (*ncursor)
				{
					if (strcmp (*ncursor, "name") == 0)
						name = g_strdup (*vcursor);
					else if (strcmp (*ncursor, "icon") == 0)
						icon = g_strdup (*vcursor);
					else if ((strcmp (*ncursor, "mode") == 0)
						&& (strcmp (*vcursor, "exec") == 0))
						name_exec = TRUE;
					else if ((strcmp (*ncursor, "mode1") == 0)
						&& (strcmp (*vcursor, "file") == 0))
						icon_file = TRUE;
					else
						g_set_error (error, G_MARKUP_ERROR,
							G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
							"Unknown attribute: %s", *ncursor);
					ncursor++;
					vcursor++;
				}
				if (name_exec)
				{
					GtkWidget *label;
					GHook *hook;

					item = gtk_image_menu_item_new ();
					label = gtk_label_new_with_mnemonic (NULL);
					gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

					g_object_set_data (G_OBJECT (label), "exec", g_strdup (name));
					gtk_container_add (GTK_CONTAINER (item), label);
					hook = g_hook_alloc (dm_object->show_hooks);

					hook->data = (gpointer) label;
					hook->func = (GHookFunc *) launcher_name_exec_update;
					g_hook_append (dm_object->show_hooks, hook);
				}
				else
				{
					if (name)
						item = gtk_image_menu_item_new_with_mnemonic (name);
					else
						item = gtk_image_menu_item_new_with_mnemonic ("");
				}
				if (icon)
				{
					if (icon_file)
					{
						gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
						gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item), 
													   gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_file_at_size (parse_expand_tilde(icon), w, h, NULL)));
					}
					else {
						gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
													   gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU));
					}
				}
				gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), item);
				menu = gtk_menu_new ();
				g_object_set_data (G_OBJECT (menu), "parent menu",
					dm_object->current_menu);
				dm_object->current_menu = menu;
				gtk_menu_item_set_submenu (GTK_MENU_ITEM (item),
					dm_object->current_menu);

				if (!dm_object->make_from_pipe)
				{
					GtkWidget *pin = gtk_tearoff_menu_item_new();
					gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
						pin); //add a pin menu item
					dm_object->pin_items = g_slist_prepend (dm_object->pin_items, pin);
				}
				else
				{
					if (gtk_menu_get_tearoff_state (GTK_MENU(dm_object->menu)))
					{
						GtkWidget *pin = gtk_tearoff_menu_item_new();
						gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
							pin); //add a pin menu item
					}
				}

				g_free (name);
				g_free (icon);
			}
			break;

		case DESKMENU_ELEMENT_SEPARATOR:
		if (dm_object->current_item != NULL)
		{
				gint line_num, char_num;
				g_markup_parse_context_get_position (context, &line_num,
					&char_num);
				g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
					"Error on line %d char %d: Element 'menu' cannot be nested "
					"inside of an item element", line_num, char_num);
				return;
		}
		else {
				gchar *name = NULL;
				gchar *icon = NULL;
				gboolean name_exec = FALSE;
				gboolean icon_file = FALSE;
				gboolean decorate = FALSE;
				gint w, h;
				item = gtk_separator_menu_item_new();
				while (*ncursor)
				{
					if (strcmp (*ncursor, "name") == 0)
					{
						name = g_strdup (*vcursor);
						if (!decorate)
						{
							decorate = TRUE;
						}
					}
					else if (strcmp (*ncursor, "icon") == 0)
					{
						icon = g_strdup (*vcursor);
						if (!decorate)
						{
							decorate = TRUE;
						}
					}
					else if ((strcmp (*ncursor, "mode") == 0)
					         && (strcmp (*vcursor, "exec") == 0))
						name_exec = TRUE;
					else if ((strcmp (*ncursor, "mode1") == 0)
					         && (strcmp (*vcursor, "file") == 0))
						icon_file = TRUE;
					else
						g_set_error (error, G_MARKUP_ERROR,
							G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
							"Unknown attribute: %s", *ncursor);
					ncursor++;
					vcursor++;
				}
				if (decorate)
				{
					GtkWidget *box = gtk_hbox_new (FALSE, 3);
					gtk_container_add (GTK_CONTAINER(item), GTK_WIDGET(box));
					if (name_exec)
					{
						GtkWidget *label;
						GHook *hook;

						label = gtk_label_new_with_mnemonic (NULL);

						g_object_set_data (G_OBJECT (label), "exec", g_strdup (name));
						gtk_box_pack_end (GTK_BOX(box), label, TRUE, FALSE, 0);
						hook = g_hook_alloc (dm_object->show_hooks);

						hook->data = (gpointer) label;
						hook->func = (GHookFunc *) launcher_name_exec_update;
						g_hook_append (dm_object->show_hooks, hook);
					}
					else
					{
						gtk_box_pack_end (GTK_BOX(box), gtk_label_new_with_mnemonic (name), TRUE, FALSE, 0);
					}
					if (icon)
					{
						GtkWidget *image;
						if (icon_file)
						{
							gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
							image = gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_file_at_size (parse_expand_tilde(icon), w, h, NULL));
						}
						else {
							image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
						}
						gtk_box_pack_start (GTK_BOX(box), image, FALSE, FALSE, 0);
					}
					gtk_widget_set_state (item, GTK_STATE_PRELIGHT); /*derive colors from menu hover*/
					g_free (name);
					g_free (icon);
				}
				gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), item);
			}
			break;

		case DESKMENU_ELEMENT_ITEM:

			if (dm_object->current_item != NULL)
			{
				gint line_num, char_num;
				g_markup_parse_context_get_position (context, &line_num,
					&char_num);
				g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
					"Error on line %d char %d: Element 'item' cannot be nested "
					"inside of another item element", line_num, char_num);
				return;
			}

			dm_object->current_item = g_slice_new0 (DeskmenuItem);
				while (*ncursor)
				{
					if (strcmp (*ncursor, "type") == 0)
						dm_object->current_item->type = GPOINTER_TO_INT
						(g_hash_table_lookup (item_hash, *vcursor));
					else
						g_set_error (error, G_MARKUP_ERROR,
							G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
							"Unknown attribute: %s", *ncursor);
					ncursor++;
					vcursor++;
				}
			break;

		case DESKMENU_ELEMENT_NAME:
			 while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode") == 0)
						&& (strcmp (*vcursor, "exec") == 0))
						dm_object->current_item->name_exec = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_ICON:
				while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode1") == 0)
						&& (strcmp (*vcursor, "file") == 0))
						dm_object->current_item->icon_file = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_VPICON:
				while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode1") == 0)
						&& (strcmp (*vcursor, "file") == 0))
						dm_object->current_item->vpicon_file = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_COMMAND:
				while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode2") == 0)
						&& (strcmp (*vcursor, "pipe") == 0))
						dm_object->current_item->command_pipe = TRUE;
					if (dm_object->current_item->command_pipe == TRUE
						&& (strcmp (*ncursor, "cache") == 0)
						&& (strcmp (*vcursor, "true") == 0))
						dm_object->current_item->cache_output = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_WRAP:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_THISVP:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_MINIONLY:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_QUANTITY:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_SORT:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_AGE:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;

		default:
			g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
				"Unknown element: %s", element_name);
			break;
	}
}
示例#17
0
文件: wldlg.c 项目: jheusala/freeciv
/****************************************************************
  Worklist editor shell.
*****************************************************************/
GtkWidget *create_worklist(void)
{
  GtkWidget *editor, *table, *sw, *bbox;
  GtkWidget *src_view, *dst_view, *label, *button;
  GtkWidget *menubar, *item, *menu, *image;
  GtkWidget *table2, *arrow, *check;
  GtkSizeGroup *group;
  GtkListStore *src_store, *dst_store;
  struct worklist_data *ptr;

  ptr = fc_malloc(sizeof(*ptr));

  src_store = gtk_list_store_new(1, G_TYPE_INT);
  dst_store = gtk_list_store_new(1, G_TYPE_INT);

  ptr->global_worklist_id = -1;
  ptr->pcity = NULL;
  ptr->src = src_store;
  ptr->dst = dst_store;
  ptr->future = FALSE;


  /* create shell. */ 
  editor = gtk_grid_new();
  gtk_grid_set_row_spacing(GTK_GRID(editor), 6);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(editor),
                                 GTK_ORIENTATION_VERTICAL);
  g_signal_connect(editor, "destroy", G_CALLBACK(worklist_destroy), ptr);
  g_object_set_data(G_OBJECT(editor), "data", ptr);

  ptr->editor = editor;

  /* add source and target lists.  */
  table = gtk_grid_new();
  gtk_container_add(GTK_CONTAINER(editor), table);

  group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
				      GTK_SHADOW_ETCHED_IN);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_grid_attach(GTK_GRID(table), sw, 3, 1, 2, 1);

  src_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(src_store));
  gtk_widget_set_hexpand(src_view, TRUE);
  gtk_widget_set_vexpand(src_view, TRUE);
  g_object_unref(src_store);
  gtk_size_group_add_widget(group, src_view);
  gtk_widget_set_name(src_view, "small_font");

  populate_view(GTK_TREE_VIEW(src_view), &ptr->pcity, &ptr->src_col);
  gtk_container_add(GTK_CONTAINER(sw), src_view);

  label = g_object_new(GTK_TYPE_LABEL,
		       "use-underline", TRUE,
		       "mnemonic-widget", src_view,
		       "label", _("Source _Tasks:"),
		       "xalign", 0.0, "yalign", 0.5, NULL);
  gtk_grid_attach(GTK_GRID(table), label, 3, 0, 1, 1);

  check = gtk_check_button_new_with_mnemonic(_("Show _Future Targets"));
  gtk_grid_attach(GTK_GRID(table), check, 4, 0, 1, 1);
  g_signal_connect(check, "toggled", G_CALLBACK(future_callback), ptr);


  table2 = gtk_grid_new();
  gtk_grid_attach(GTK_GRID(table), table2, 2, 1, 1, 1);

  button = gtk_button_new();
  gtk_widget_set_margin_top(button, 24);
  gtk_widget_set_margin_bottom(button, 24);
  ptr->prepend_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 0, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_prepend), ptr);
  gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE);

  button = gtk_button_new();
  ptr->up_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 1, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_NONE);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_bubble_up), ptr);
  gtk_widget_set_sensitive(ptr->up_cmd, FALSE);

  button = gtk_button_new();
  ptr->down_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 2, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_bubble_down), ptr);
  gtk_widget_set_sensitive(ptr->down_cmd, FALSE);

  button = gtk_button_new();
  gtk_widget_set_margin_top(button, 24);
  gtk_widget_set_margin_bottom(button, 24);
  ptr->append_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 3, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_append), ptr);
  gtk_widget_set_sensitive(ptr->append_cmd, FALSE);

  button = gtk_button_new();
  gtk_widget_set_margin_top(button, 24);
  gtk_widget_set_margin_bottom(button, 24);
  ptr->remove_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 4, 1, 1);
  
  arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
                           G_CALLBACK(queue_remove), ptr);
  gtk_widget_set_sensitive(ptr->remove_cmd, FALSE);

  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
				      GTK_SHADOW_ETCHED_IN);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_grid_attach(GTK_GRID(table), sw, 0, 1, 2, 1);

  dst_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dst_store));
  gtk_widget_set_hexpand(dst_view, TRUE);
  gtk_widget_set_vexpand(dst_view, TRUE);
  g_object_unref(dst_store);
  gtk_size_group_add_widget(group, dst_view);
  gtk_widget_set_name(dst_view, "small_font");

  populate_view(GTK_TREE_VIEW(dst_view), &ptr->pcity, &ptr->dst_col);
  gtk_container_add(GTK_CONTAINER(sw), dst_view);

  label = g_object_new(GTK_TYPE_LABEL,
		       "use-underline", TRUE,
		       "mnemonic-widget", dst_view,
		       "label", _("Target _Worklist:"),
		       "xalign", 0.0, "yalign", 0.5, NULL);
  gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);

  /* add bottom menu and buttons. */
  bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
  gtk_box_set_spacing(GTK_BOX(bbox), 10);
  gtk_container_add(GTK_CONTAINER(editor), bbox);

  menubar = gtk_aux_menu_bar_new();
  gtk_container_add(GTK_CONTAINER(bbox), menubar);
  gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), menubar, TRUE);

  menu = gtk_menu_new();

  image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
  item = gtk_image_menu_item_new_with_mnemonic(_("_Add Global Worklist"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
  g_signal_connect(menu, "show",
		   G_CALLBACK(popup_add_menu), ptr);
  ptr->add_cmd = item;
  gtk_widget_set_sensitive(ptr->add_cmd, FALSE);

  button = gtk_button_new_from_stock(GTK_STOCK_HELP);
  gtk_container_add(GTK_CONTAINER(bbox), button);
  g_signal_connect(button, "clicked",
		   G_CALLBACK(help_callback), ptr);
  ptr->help_cmd = button;
  gtk_widget_set_sensitive(ptr->help_cmd, FALSE);

  button = gtk_button_new_with_mnemonic(_("Change Prod_uction"));
  gtk_container_add(GTK_CONTAINER(bbox), button);
  g_signal_connect(button, "clicked",
		   G_CALLBACK(change_callback), ptr);
  ptr->change_cmd = button;
  gtk_widget_set_sensitive(ptr->change_cmd, FALSE);

  ptr->src_view = src_view;
  ptr->dst_view = dst_view;
  ptr->src_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(src_view));
  ptr->dst_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dst_view));
  gtk_tree_selection_set_mode(ptr->dst_selection, GTK_SELECTION_MULTIPLE);

  /* DND and other state changing callbacks. */
  gtk_tree_view_set_reorderable(GTK_TREE_VIEW(dst_view), TRUE);
  g_signal_connect(dst_view, "drag_end",
		   G_CALLBACK(dst_dnd_callback), ptr);

  g_signal_connect(src_view, "row_activated",
		   G_CALLBACK(src_row_callback), ptr);
  g_signal_connect(src_view, "key_press_event",
		   G_CALLBACK(src_key_press_callback), ptr);

  g_signal_connect(dst_view, "row_activated",
		   G_CALLBACK(dst_row_callback), ptr);
  g_signal_connect(dst_view, "key_press_event",
		   G_CALLBACK(dst_key_press_callback), ptr);

  g_signal_connect(ptr->src_selection, "changed",
      		   G_CALLBACK(src_selection_callback), ptr);
  g_signal_connect(ptr->dst_selection, "changed",
      		   G_CALLBACK(dst_selection_callback), ptr);


  gtk_widget_show_all(table);
  gtk_widget_show_all(bbox);

  return editor;
}
示例#18
0
文件: applet.c 项目: dnk/mate-panel
GtkWidget *
mate_panel_applet_create_menu (AppletInfo *info)
{
	GtkWidget   *menu;
	GtkWidget   *menuitem;
	GList       *l;
	PanelWidget *panel_widget;
	gboolean     added_anything = FALSE;

	panel_widget = mate_panel_applet_get_panel_widget (info);

	menu = g_object_ref_sink (gtk_menu_new ());

	/* connect the show & deactivate signal, so that we can "disallow" and
	 * "re-allow" autohide when the menu is shown/deactivated.
	 */
	g_signal_connect (menu, "show",
			  G_CALLBACK (applet_menu_show), info);
	g_signal_connect (menu, "deactivate",
			  G_CALLBACK (applet_menu_deactivate), info);

	for (l = info->user_menu; l; l = l->next) {
		AppletUserMenu *user_menu = l->data;

		if (user_menu->is_enabled_func && !user_menu->is_enabled_func ())
			continue;

		add_to_submenus (info, "", user_menu->name, user_menu,
				 menu, info->user_menu);

		added_anything = TRUE;
	}

	if (!panel_lockdown_get_locked_down ()) {
		GtkWidget *image;
		gboolean   locked;
		gboolean   lockable;
		gboolean   movable;
		gboolean   removable;

		lockable = mate_panel_applet_lockable (info);
		movable = mate_panel_applet_can_freely_move (info);
		removable = panel_profile_id_lists_are_writable ();

		locked = panel_widget_get_applet_locked (panel_widget, info->widget);

		if (added_anything) {
			menuitem = gtk_separator_menu_item_new ();
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
			gtk_widget_show (menuitem);
		}

		menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Panel"));
		image = gtk_image_new_from_icon_name ("list-remove",
						      GTK_ICON_SIZE_MENU);
		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
					       image);
		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (applet_remove_callback), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, (!locked || lockable) && removable);

		menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (move_applet_callback), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, !locked && movable);

		g_assert (info->move_item == NULL);

		info->move_item = menuitem;
		g_object_add_weak_pointer (G_OBJECT (menuitem),
					   (gpointer *) &info->move_item);

		menuitem = gtk_separator_menu_item_new ();
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_show (menuitem);

		menuitem = gtk_check_menu_item_new_with_mnemonic (_("Loc_k To Panel"));
		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
						locked);
		g_signal_connect (menuitem, "toggled",
				  G_CALLBACK (mate_panel_applet_lock), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, lockable);

		added_anything = TRUE;
	}

	if ( ! added_anything) {
		g_object_unref (menu);
		return NULL;
	}

/* Set up theme and transparency support */
	GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
	GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
	GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); 
/* Set menu and it's toplevel window to follow panel theme */
	GtkStyleContext *context;
	context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
	gtk_style_context_add_class(context,"gnome-panel-menu-bar");
	gtk_style_context_add_class(context,"mate-panel-menu-bar");

	return menu;
}
示例#19
0
//
//	Create a new ute window
//
WUtedGtk::WUtedGtk( void	       	*wu_parent_ctx,
		    GtkWidget		*wu_parent_wid,
		    const char	       	*wu_name,
		    const char	       	*wu_iconname,
		    ldh_tWBContext	wu_ldhwb,
		    ldh_tSesContext	wu_ldhses,
		    int	       	wu_editmode,
		    void 	       	(*wu_quit_cb)(void *),
		    pwr_tStatus     	*status) :
  WUted(wu_parent_ctx,wu_name,wu_iconname,wu_ldhwb,wu_ldhses,wu_editmode,wu_quit_cb,
	status), parent_wid(wu_parent_wid), cursor(0)
{
  const int	window_width = 800;
  const int    	window_height = 400;

  memset( &widgets, 0, sizeof(widgets));

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
			   "default-height", window_height,
			   "default-width", window_width,
			   NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_quit), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // View Entry
  GtkWidget *view_show_cmd = gtk_menu_item_new_with_mnemonic( "_Show Current Command");
  g_signal_connect( view_show_cmd, "activate", 
		    G_CALLBACK(activate_show_cmd), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_show_cmd);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Commands entry
  GtkMenu *commands_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  GtkMenu *current_menu = commands_menu;
  
  int j = 0;
  int in_submenu = 0;
  uted_sCommand *next_cmd;
  for ( uted_sCommand *command_ptr = commands; command_ptr->command[0]; command_ptr++) {

    // Build submenu if first command verb is equal to next
    char cmd_verb[5][80];
    int num;
    char next_cmd_verb[5][80];
    int next_num;
    num = dcli_parse( command_ptr->command, " ", "", (char *)cmd_verb, 
		      sizeof( cmd_verb) / sizeof( cmd_verb[0]), sizeof( cmd_verb[0]), 0);

    
    next_cmd = command_ptr + 1;
    int close_submenu = 0;
    if ( next_cmd->command[0]) {
      next_num = dcli_parse( next_cmd->command, " ", "", (char *)next_cmd_verb, 
			     sizeof( next_cmd_verb) / sizeof( next_cmd_verb[0]), 
			     sizeof( next_cmd_verb[0]), 0);

      if ( in_submenu) {
	// Check if time to close menu
	if ( strcmp( cmd_verb[0], next_cmd_verb[0]) != 0) {
	  // Close submenu
	  close_submenu = 1;
	}
      }
      else if ( strcmp( cmd_verb[0], next_cmd_verb[0]) == 0) {
	// Open submenu
	GtkWidget *submenu_item = gtk_menu_item_new_with_label( cmd_verb[0]);
	GtkMenu *submenu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenu_item),
				  GTK_WIDGET(submenu));
	gtk_menu_shell_append(GTK_MENU_SHELL(commands_menu), submenu_item);
	current_menu = submenu;
	in_submenu = 1;
      }
    }
    else if ( in_submenu) {
      // Last command
      close_submenu = 1;
    }


    widgets.optmenubuttons[j] = gtk_menu_item_new();
    widgets.optmenubuttonslabel[j] = gtk_label_new( command_ptr->command);
    gtk_misc_set_alignment( GTK_MISC(widgets.optmenubuttonslabel[j]), 0.0, 0.5);
    gtk_container_add( GTK_CONTAINER(widgets.optmenubuttons[j]), 
		       widgets.optmenubuttonslabel[j]);
    
    g_signal_connect( widgets.optmenubuttons[j], "activate", 
		      G_CALLBACK(activate_command), this);
    gtk_menu_shell_append(GTK_MENU_SHELL(current_menu), widgets.optmenubuttons[j]);

    if ( close_submenu) {
      current_menu = commands_menu;
      in_submenu = 0;
    }

    j++;
  }

  GtkWidget *commands = gtk_menu_item_new_with_mnemonic("_Commands");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), commands);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(commands), GTK_WIDGET(commands_menu));

  // Menu Help
  GtkWidget *help_utils = gtk_image_menu_item_new_with_mnemonic("_On Window");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_utils), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_utils, "activate", G_CALLBACK(activate_helputils), this);
  gtk_widget_add_accelerator( help_utils, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *help_cmd = gtk_menu_item_new_with_mnemonic( "On _Commands");
  g_signal_connect( help_cmd, "activate", 
		    G_CALLBACK(activate_helppwr_plc), this);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_utils);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_cmd);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Qualifier labels, entries and checkboxes
  GtkWidget *qual_box_qual = gtk_vbox_new( FALSE, 0);
  GtkWidget *qual_box_value = gtk_vbox_new( FALSE, 0);
  for ( j = 0; j < 10; j++) {
    widgets.qualifier[j] = gtk_label_new( "Qual");
    gtk_widget_set_size_request( widgets.qualifier[j], 120, 20);
    gtk_misc_set_alignment( GTK_MISC(widgets.qualifier[j]), 0.0, 0.5);
    gtk_box_pack_start( GTK_BOX(qual_box_qual), widgets.qualifier[j], FALSE, FALSE, 5);
    GtkWidget *box = gtk_hbox_new( FALSE, 0);
    widgets.value[j] = gtk_entry_new();
    gtk_widget_set_size_request( widgets.value[j], -1, 20);
    gtk_box_pack_start( GTK_BOX(box), widgets.value[j], TRUE, TRUE, 0);
    widgets.present[j] = gtk_check_button_new();
    gtk_widget_set_size_request( widgets.present[j], -1, 20);
    gtk_box_pack_start( GTK_BOX(box), widgets.present[j], FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(qual_box_value), box, FALSE, FALSE, 5);
  }

  g_signal_connect( widgets.present[0], "toggled", G_CALLBACK(activate_present1), this);
  g_signal_connect( widgets.present[1], "toggled", G_CALLBACK(activate_present2), this);
  g_signal_connect( widgets.present[2], "toggled", G_CALLBACK(activate_present3), this);
  g_signal_connect( widgets.present[3], "toggled", G_CALLBACK(activate_present4), this);
  g_signal_connect( widgets.present[4], "toggled", G_CALLBACK(activate_present5), this);
  g_signal_connect( widgets.present[5], "toggled", G_CALLBACK(activate_present6), this);
  g_signal_connect( widgets.present[6], "toggled", G_CALLBACK(activate_present7), this);
  g_signal_connect( widgets.present[7], "toggled", G_CALLBACK(activate_present8), this);
  g_signal_connect( widgets.present[8], "toggled", G_CALLBACK(activate_present9), this);
  g_signal_connect( widgets.present[9], "toggled", G_CALLBACK(activate_present10), this);

  // Command label
  GtkWidget *cmdlabel = gtk_label_new( "Command");
  widgets.commandlabel = gtk_label_new( "No command selected");
  gtk_misc_set_alignment( GTK_MISC(widgets.commandlabel), 0.0, 0.5);
  gtk_widget_set_size_request( widgets.commandlabel, 140, -1);

  GtkWidget *vbox_command = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox_command), cmdlabel, FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(vbox_command), widgets.commandlabel, FALSE, FALSE, 10);

  // Apply button
  GtkWidget *applybutton = gtk_button_new_with_label( "Apply");
  gtk_widget_set_size_request( applybutton, 70, 25);
  g_signal_connect( applybutton, "clicked", 
  		    G_CALLBACK(activate_ok), this);

  GtkWidget *left_box = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(left_box), vbox_command, FALSE, FALSE, 10);

  GtkWidget *button_box = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(button_box), applybutton, FALSE, FALSE, 50);

  GtkWidget *qual_box = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(qual_box), left_box, FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(qual_box), gtk_vseparator_new(), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(qual_box), qual_box_qual, FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(qual_box), qual_box_value, TRUE, TRUE, 10);


  // Statusbar
  GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
  widgets.label = gtk_label_new( "");
  gtk_box_pack_start( GTK_BOX(statusbar), widgets.label, FALSE, FALSE, 20);


  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), qual_box, TRUE, TRUE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 3);
  gtk_box_pack_start( GTK_BOX(vbox), button_box, FALSE, FALSE, 3);
  gtk_box_pack_start( GTK_BOX(vbox), statusbar, FALSE, FALSE, 3);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all( toplevel);

  batch_sts = UTED_BATCH_CURRSESS;
  reset_qual();
  enable_entries( wu_editmode);

#if 0
  Arg		args[20];
  pwr_tStatus	sts;
  int i;
  MrmHierarchy	s_MrmH;
  MrmType	dclass;

  /* DRM database hierarchy related variables */
  static Pixmap icon = 0;
  Dimension	icon_w;
  Dimension	icon_h;

  static Atom	MwmDeleteWind = 0;
  char		uid_filename[200] = {"pwr_exe:wb_uted.uid"};
  char		*uid_filename_p = uid_filename;

  static MrmRegisterArg	reglist[] = {
    /* First the context variable */
    { "uted_ctx", 0 },

    /* Callbacks for the controlled foe widget */
    {"uted_create_adb",(caddr_t)create_adb},
    {"uted_create_quit",(caddr_t)create_quit},
    {"uted_activate_quit",(caddr_t)activate_quit},
    {"uted_create_commandlabel",(caddr_t)create_commandlabel},
    {"uted_create_batchoptmenu",(caddr_t)create_batchoptmenu},
    {"uted_create_batch",(caddr_t)create_batch},
    {"uted_create_currsess",(caddr_t)create_currsess},
    {"uted_create_file_entry",(caddr_t)create_file_entry},
    {"uted_create_label",(caddr_t)create_label},
    {"uted_create_adb",(caddr_t)create_adb},
    {"uted_activate_command",(caddr_t)activate_command},
    {"uted_create_command",(caddr_t)create_command},
    {"uted_activate_batch",(caddr_t)activate_batch},
    {"uted_activate_currsess",(caddr_t)activate_currsess},
    {"uted_activate_ok",(caddr_t)activate_ok},
    {"uted_activate_cancel",(caddr_t)activate_cancel},
    {"uted_activate_show_cmd",(caddr_t)activate_show_cmd},
    {"uted_create_commandwind_button",(caddr_t)create_commandwind_button},
    {"uted_activate_cmd_wind",(caddr_t)activate_cmd_wind},
    {"uted_create_cmd_wind",(caddr_t)create_cmd_wind},
    {"uted_create_timelabel",(caddr_t)create_timelabel},
    {"uted_create_timevalue",(caddr_t)create_timevalue},
    {"uted_create_qualifier1",(caddr_t)create_qualifier1},
    {"uted_create_value1",(caddr_t)create_value1},
    {"uted_activate_present1",(caddr_t)activate_present1},
    {"uted_create_present1",(caddr_t)create_present1},
    {"uted_create_qualifier2",(caddr_t)create_qualifier2},
    {"uted_create_value2",(caddr_t)create_value2},
    {"uted_activate_present2",(caddr_t)activate_present2},
    {"uted_create_present2",(caddr_t)create_present2},
    {"uted_create_qualifier3",(caddr_t)create_qualifier3},
    {"uted_create_value3",(caddr_t)create_value3},
    {"uted_activate_present3",(caddr_t)activate_present3},
    {"uted_create_present3",(caddr_t)create_present3},
    {"uted_create_qualifier4",(caddr_t)create_qualifier4},
    {"uted_create_value4",(caddr_t)create_value4},
    {"uted_activate_present4",(caddr_t)activate_present4},
    {"uted_create_present4",(caddr_t)create_present4},
    {"uted_create_qualifier5",(caddr_t)create_qualifier5},
    {"uted_create_value5",(caddr_t)create_value5},
    {"uted_activate_present5",(caddr_t)activate_present5},
    {"uted_create_present5",(caddr_t)create_present5},
    {"uted_create_qualifier6",(caddr_t)create_qualifier6},
    {"uted_create_value6",(caddr_t)create_value6},
    {"uted_activate_present6",(caddr_t)activate_present6},
    {"uted_create_present6",(caddr_t)create_present6},
    {"uted_create_qualifier7",(caddr_t)create_qualifier7},
    {"uted_create_value7",(caddr_t)create_value7},
    {"uted_activate_present7",(caddr_t)activate_present7},
    {"uted_create_present7",(caddr_t)create_present7},
    {"uted_create_qualifier8",(caddr_t)create_qualifier8},
    {"uted_create_value8",(caddr_t)create_value8},
    {"uted_activate_present8",(caddr_t)activate_present8},
    {"uted_create_present8",(caddr_t)create_present8},
    {"uted_create_qualifier9",(caddr_t)create_qualifier9},
    {"uted_create_value9",(caddr_t)create_value9},
    {"uted_activate_present9",(caddr_t)activate_present9},
    {"uted_create_present9",(caddr_t)create_present9},
    {"uted_create_qualifier10",(caddr_t)create_qualifier10},
    {"uted_create_value10",(caddr_t)create_value10},
    {"uted_activate_present10",(caddr_t)activate_present10},
    {"uted_create_present10",(caddr_t)create_present10},
    {"uted_activate_helputils",(caddr_t)activate_helputils},
    {"uted_activate_helppwr_plc",(caddr_t)activate_helppwr_plc},
    {"uted_commandchanged",(caddr_t)commandchanged},
    {"uted_qbox_cr",(caddr_t)qbox_cr},
    {"uted_qbox_yes_cb",(caddr_t)qbox_yes_cb},
    {"uted_qbox_no_cb",(caddr_t)qbox_no_cb},
    {"uted_qbox_cancel_cb",(caddr_t)qbox_cancel_cb}
  };

  static int	reglist_num = (sizeof reglist / sizeof reglist[0]);

  /*
   * Now start the module creation
   */

  sts = dcli_translate_filename( uid_filename, uid_filename);
  if ( EVEN(sts)) {
    printf( "** pwr_exe is not defined\n");
    exit(0);
  }

  /* set initialization values in context */

  /* Save the context structure in the widget */
  XtSetArg (args[0], XmNuserData, (unsigned int) this);

  /*
   * Create a new widget
   * Open the UID files (the output of the UIL compiler) in the hierarchy
   * Register the items DRM needs to bind for us.
   * Create a new widget
   * Close the hierarchy
   * Compile the additional button translations and augment and add actions
   */ 
  sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_MrmH);
  if (sts != MrmSUCCESS) printf("can't open hierarchy\n");

  reglist[0].value = (caddr_t) this;

  MrmRegisterNames(reglist, reglist_num);

  if (icon == 0)
    sts = MrmFetchBitmapLiteral(s_MrmH,"icon", 
	      XtScreen(parent_wid), XtDisplay(parent_wid),
	      &icon, &icon_w, &icon_h);

  i=0;
  XtSetArg(args[i],XmNiconName, wu_iconname);  i++;
  XtSetArg(args[i],XmNiconPixmap, icon);  i++;
  XtSetArg(args[i],XmNtitle, name);  i++;
  
  /* SG 11.02.91 Save the id of the top in the context */ 
  parent_wid = XtCreatePopupShell("utilities", 
			       topLevelShellGtkWidgetClass, parent_wid, args, i);

  /* the positioning of a top level can only be define after the creation
      of the widget . So i do it know: 
     SG 24.02.91 use the parameters received x and y 
  */
  i=0;
  XtSetArg(args[i],XmNx,100);i++;
  XtSetArg(args[i],XmNy,100);i++;
  XtSetArg(args[i],XtNallowShellResize,TRUE), i++;
  XtSetValues( parent_wid, args, i);

  /* now that we have a top level we can get the main window */
  sts = MrmFetchGtkWidgetOverride(s_MrmH, "uted_window", parent_wid ,
		name, args, 1,
		&widgets.uted_window, &dclass);
  if (sts != MrmSUCCESS) printf("can't fetch utedit widget\n");

  XtManageChild( widgets.uted_window);

  /* SG 09.02.91 a top level should always be realized ! */
  XtPopup( parent_wid, XtGrabNone );

  /* Ask MRM to fetch the question box */
  i=0;
  if (MrmFetchGtkWidgetOverride(s_MrmH,
			"uted_qbox", 
	     	        widgets.uted_window,
			0,
			args , i,
			&widgets.questionbox, &dclass) != MrmSUCCESS) {
    printf("can't fetch uted_qbox widget\n");
  }

  MrmCloseHierarchy(s_MrmH);

  reset_qual();

  batch_sts = UTED_BATCH_CURRSESS;
  XtSetArg(args[0],XmNsensitive, 0);
  XtSetValues( widgets.timelabel,args,1);
  XtUnmanageChild( widgets.timevalue);
  XtUnmanageChild( widgets.command_window);
  enable_entries( wu_editmode);


  if (MwmDeleteWind == 0)
     MwmDeleteWind = XInternAtom(XtDisplay(parent_wid), "WM_DELETE_WINDOW", FALSE);

  if (MwmDeleteWind != 0)
  {
    XtVaSetValues( parent_wid, XmNdeleteResponse, XmDO_NOTHING, NULL);
    XmAddWMProtocolCallback( parent_wid, MwmDeleteWind, 
       (XtCallbackProc) activate_quit, this);
  }
#endif
  *status = FOE__SUCCESS;
}
示例#20
0
static void aggregate_layer_add_menu_items ( VikAggregateLayer *val, GtkMenu *menu, gpointer vlp )
{
  // Data to pass on in menu functions
  static menu_array_values values;
  values[MA_VAL] = val;
  values[MA_VLP] = vlp;

  GtkWidget *item = gtk_menu_item_new();
  gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
  gtk_widget_show ( item );

  GtkWidget *vis_submenu = gtk_menu_new ();
  item = gtk_menu_item_new_with_mnemonic ( _("_Visibility") );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), vis_submenu );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Show All") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_child_visible_on), values );
  gtk_menu_shell_append (GTK_MENU_SHELL (vis_submenu), item);
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Hide All") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_child_visible_off), values );
  gtk_menu_shell_append (GTK_MENU_SHELL (vis_submenu), item);
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Toggle") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_child_visible_toggle), values );
  gtk_menu_shell_append (GTK_MENU_SHELL (vis_submenu), item);
  gtk_widget_show ( item );

  GtkWidget *submenu_sort = gtk_menu_new ();
  item = gtk_image_menu_item_new_with_mnemonic ( _("_Sort") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU) );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu_sort );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Name _Ascending") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_sort_a2z), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(submenu_sort), item );
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Name _Descending") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_SORT_DESCENDING, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_sort_z2a), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(submenu_sort), item );
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Date Ascending") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_sort_timestamp_ascend), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(submenu_sort), item );
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Date Descending") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_SORT_DESCENDING, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_sort_timestamp_descend), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(submenu_sort), item );
  gtk_widget_show ( item );

  item = gtk_menu_item_new_with_mnemonic ( _("_Statistics") );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_analyse), values );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Track _List...") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_track_list_dialog), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Waypoint List...") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_waypoint_list_dialog), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
  gtk_widget_show ( item );

  GtkWidget *search_submenu = gtk_menu_new ();
  item = gtk_image_menu_item_new_with_mnemonic ( _("Searc_h") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU) );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), search_submenu );

  item = gtk_menu_item_new_with_mnemonic ( _("By _Date...") );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_search_date), values );
  gtk_menu_shell_append ( GTK_MENU_SHELL(search_submenu), item );
  gtk_widget_set_tooltip_text (item, _("Find the first item with a specified date"));
  gtk_widget_show ( item );
}
示例#21
0
static void _context_menu_document(GHtml * ghtml, GtkWidget * menu)
{
	GtkWidget * menuitem;
	GtkWidget * image;

	/* back */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_BACK, NULL);
	if(!ghtml_can_go_back(ghtml->widget))
		gtk_widget_set_sensitive(menuitem, FALSE);
	else
		g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
					surfer_go_back), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* forward */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_FORWARD,
			NULL);
	if(!ghtml_can_go_forward(ghtml->widget))
		gtk_widget_set_sensitive(menuitem, FALSE);
	else
		g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
					surfer_go_forward), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* refresh */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_REFRESH, NULL);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_refresh), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* save page */
	menuitem = gtk_image_menu_item_new_with_mnemonic(
			_("_Save page as..."));
	image = gtk_image_new_from_stock(GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_save_dialog), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* print */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, NULL);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(surfer_print),
			ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* select all */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_SELECT_ALL,
			NULL);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_select_all), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* view source */
	menuitem = gtk_image_menu_item_new_with_mnemonic(_("View so_urce"));
	image = gtk_image_new_from_icon_name("surfer-view-html-source",
			GTK_ICON_SIZE_MENU);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_view_source), ghtml->surfer);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
#ifdef WITH_INSPECTOR
	/* inspect */
	menuitem = gtk_image_menu_item_new_with_mnemonic(
			_("_Inspect this page"));
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				_on_inspect_page), ghtml);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
#endif
}
示例#22
0
static void
gimp_action_set_proxy (GimpAction *action,
                       GtkWidget  *proxy)
{
  if (! GTK_IS_IMAGE_MENU_ITEM (proxy))
    return;

  if (action->color)
    {
      GtkWidget *area;

      area = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));

      if (GIMP_IS_COLOR_AREA (area))
        {
          gimp_color_area_set_color (GIMP_COLOR_AREA (area), action->color);
        }
      else
        {
          gint width, height;

          area = gimp_color_area_new (action->color,
                                      GIMP_COLOR_AREA_SMALL_CHECKS, 0);
          gimp_color_area_set_draw_border (GIMP_COLOR_AREA (area), TRUE);

          gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (proxy),
                                             GTK_ICON_SIZE_MENU,
                                             &width, &height);

          gtk_widget_set_size_request (area, width, height);
          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), area);
          gtk_widget_show (area);
        }
    }
  else if (action->viewable)
    {
      GtkWidget *view;

      view = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));

      if (GIMP_IS_VIEW (view) &&
          g_type_is_a (G_TYPE_FROM_INSTANCE (action->viewable),
                       GIMP_VIEW (view)->renderer->viewable_type))
        {
          gimp_view_set_viewable (GIMP_VIEW (view), action->viewable);
        }
      else
        {
          GtkIconSize size;
          gint        width, height;
          gint        border_width;

          if (GIMP_IS_IMAGEFILE (action->viewable))
            {
              size         = GTK_ICON_SIZE_LARGE_TOOLBAR;
              border_width = 0;
            }
          else
            {
              size         = GTK_ICON_SIZE_MENU;
              border_width = 1;
            }

          gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (proxy),
                                             size, &width, &height);

          view = gimp_view_new_full (action->context, action->viewable,
                                     width, height, border_width,
                                     FALSE, FALSE, FALSE);
          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), view);
          gtk_widget_show (view);
        }
    }
  else
    {
      GtkWidget *image;

      image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));

      if (GIMP_IS_VIEW (image) || GIMP_IS_COLOR_AREA (image))
        {
          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL);
          g_object_notify (G_OBJECT (action), "stock-id");
        }
    }

  {
    GtkWidget *child = gtk_bin_get_child (GTK_BIN (proxy));

    if (GTK_IS_LABEL (child))
      {
        GtkLabel *label = GTK_LABEL (child);

        gtk_label_set_ellipsize (label, action->ellipsize);
        gtk_label_set_max_width_chars (label, action->max_width_chars);
      }
  }
}
示例#23
0
GtkWidget *
mate_panel_applet_create_menu (AppletInfo *info)
{
	GtkWidget   *menu;
	GtkWidget   *menuitem;
	GList       *l;
	PanelWidget *panel_widget;
	gboolean     added_anything = FALSE;

	panel_widget = mate_panel_applet_get_panel_widget (info);

	menu = g_object_ref_sink (gtk_menu_new ());

	/* connect the show & deactivate signal, so that we can "disallow" and
	 * "re-allow" autohide when the menu is shown/deactivated.
	 */
	g_signal_connect (menu, "show",
			  G_CALLBACK (applet_menu_show), info);
	g_signal_connect (menu, "deactivate",
			  G_CALLBACK (applet_menu_deactivate), info);

	for (l = info->user_menu; l; l = l->next) {
		AppletUserMenu *user_menu = l->data;

		if (user_menu->is_enabled_func && !user_menu->is_enabled_func ())
			continue;

		add_to_submenus (info, "", user_menu->name, user_menu,
				 menu, info->user_menu);

		added_anything = TRUE;
	}

	if (!panel_lockdown_get_locked_down ()) {
		GtkWidget *image;
		gboolean   locked;
		gboolean   lockable;
		gboolean   movable;
		gboolean   removable;

		lockable = mate_panel_applet_lockable (info);
		movable = mate_panel_applet_can_freely_move (info);
		removable = panel_profile_id_lists_are_writable ();

		locked = panel_widget_get_applet_locked (panel_widget, info->widget);

		if (added_anything) {
			menuitem = gtk_separator_menu_item_new ();
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
			gtk_widget_show (menuitem);
		}

		menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Panel"));
		image = gtk_image_new_from_stock (GTK_STOCK_REMOVE,
						  GTK_ICON_SIZE_MENU);
		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
					       image);
		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (applet_remove_callback), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, (!locked || lockable) && removable);

		menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (move_applet_callback), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, !locked && movable);

		g_assert (info->move_item == NULL);

		info->move_item = menuitem;
		g_object_add_weak_pointer (G_OBJECT (menuitem),
					   (gpointer *) &info->move_item);

		menuitem = gtk_separator_menu_item_new ();
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_show (menuitem);

		menuitem = gtk_check_menu_item_new_with_mnemonic (_("Loc_k To Panel"));
		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
						locked);
		g_signal_connect (menuitem, "toggled",
				  G_CALLBACK (mate_panel_applet_lock), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, lockable);

		added_anything = TRUE;
	}

	if ( ! added_anything) {
		g_object_unref (menu);
		return NULL;
	}

	return menu;
}
示例#24
0
NodelistGtk::NodelistGtk( void *nodelist_parent_ctx,
			  GtkWidget *nodelist_parent_wid,
			  const char *nodelist_name, int nodelist_mode, 
			  int nodelist_view_node_descr, int msgw_pop, 
			  pwr_tStatus *status) :
  Nodelist( nodelist_parent_ctx, nodelist_name, nodelist_mode, 
	    nodelist_view_node_descr, status), 
  parent_wid(nodelist_parent_wid), clock_cursor(0), add_india_widget(0)
{
  pwr_tStatus sts;

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
			   "default-height", 300,
			   "default-width", 850,
			   "title", nodelist_name,
			   NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close), 
				 gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
  gtk_widget_add_accelerator( file_close, "activate", accel_g,
			      'w', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *file_add_node = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Add Node"));
  g_signal_connect(file_add_node, "activate", G_CALLBACK(activate_add_node), this);

  GtkWidget *file_modify_node = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Modify Node"));
  g_signal_connect(file_modify_node, "activate", G_CALLBACK(activate_modify_node), this);

  GtkWidget *file_remove_node = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Remove Node"));
  g_signal_connect(file_remove_node, "activate", G_CALLBACK(activate_remove_node), this);

  pwr_tFileName fname;
  GtkWidget *file_open_xtt = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Open Runtime _Navigator"));
  dcli_translate_filename( fname, "$pwr_exe/xtt_navigator.png");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_open_xtt), gtk_image_new_from_file( fname));
  g_signal_connect(file_open_xtt, "activate", G_CALLBACK(activate_open_xtt), this);

  GtkWidget *file_open_opplace = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Open Operatorplace"));
  dcli_translate_filename( fname, "$pwr_exe/xtt_op.png");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_open_opplace), 
				 gtk_image_new_from_file( fname));
  g_signal_connect(file_open_opplace, "activate", G_CALLBACK(activate_open_opplace), this);

  GtkWidget *file_open_rtmon = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Open Runtime _Monitor"));
  dcli_translate_filename( fname, "$pwr_exe/xtt_rtmon.png");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_open_rtmon), gtk_image_new_from_file( fname));
  g_signal_connect(file_open_rtmon, "activate", G_CALLBACK(activate_open_rtmon), this);

  GtkWidget *file_save = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Save Configuration"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_save), 
				 gtk_image_new_from_stock( "gtk-save", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_save, "activate", G_CALLBACK(activate_save), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_save);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_add_node);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_modify_node);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_remove_node);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_open_xtt);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_open_opplace);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_open_rtmon);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // View menu
  GtkWidget *view_show_events = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Show _Events"));
  g_signal_connect(view_show_events, "activate", G_CALLBACK(activate_show_events), this);

  GtkWidget *view_pop_events = gtk_check_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Pop Events"));
  g_signal_connect(view_pop_events, "activate", G_CALLBACK(activate_pop_events), this);

  // Submenu Remote GUI
  GSList *rg_group = NULL;
  GtkWidget *view_gui_gtk = gtk_radio_menu_item_new_with_mnemonic( rg_group, "_GTK");
  rg_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_gui_gtk));
  g_signal_connect( view_gui_gtk, "activate", 
		    G_CALLBACK(activate_gui_gtk), this);

  GtkWidget *view_gui_motif = gtk_radio_menu_item_new_with_mnemonic( rg_group, "_Motif");
  rg_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_gui_motif));
  g_signal_connect( view_gui_motif, "activate", 
		    G_CALLBACK(activate_gui_motif), this);


  GtkWidget *view_gui = gtk_menu_item_new_with_mnemonic( "_Remote GUI");
  GtkMenu *view_gui_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_gui_menu), view_gui_gtk);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_gui_menu), view_gui_motif);

  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_gui),
			    GTK_WIDGET(view_gui_menu));


  // Submenu Mode
  GSList *mode_group = NULL;
  GtkWidget *view_mode_systemstatus = gtk_radio_menu_item_new_with_mnemonic( mode_group, "_SystemStatus");
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_mode_systemstatus));
  g_signal_connect( view_mode_systemstatus, "activate", 
		    G_CALLBACK(activate_mode_systemstatus), this);

  GtkWidget *view_mode_userstatus1 = gtk_radio_menu_item_new_with_mnemonic( mode_group, "UserStatus_1");
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_mode_userstatus1));
  g_signal_connect( view_mode_userstatus1, "activate", 
		    G_CALLBACK(activate_mode_userstatus1), this);

  GtkWidget *view_mode_userstatus2 = gtk_radio_menu_item_new_with_mnemonic( mode_group, "UserStatus_2");
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_mode_userstatus2));
  g_signal_connect( view_mode_userstatus2, "activate", 
		    G_CALLBACK(activate_mode_userstatus2), this);

  GtkWidget *view_mode_userstatus3 = gtk_radio_menu_item_new_with_mnemonic( mode_group, "UserStatus_3");
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_mode_userstatus3));
  g_signal_connect( view_mode_userstatus3, "activate", 
		    G_CALLBACK(activate_mode_userstatus3), this);

  GtkWidget *view_mode_userstatus4 = gtk_radio_menu_item_new_with_mnemonic( mode_group, "UserStatus_4");
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_mode_userstatus4));
  g_signal_connect( view_mode_userstatus4, "activate", 
		    G_CALLBACK(activate_mode_userstatus4), this);

  GtkWidget *view_mode_userstatus5 = gtk_radio_menu_item_new_with_mnemonic( mode_group, "UserStatus_5");
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_mode_userstatus5));
  g_signal_connect( view_mode_userstatus5, "activate", 
		    G_CALLBACK(activate_mode_userstatus5), this);


  GtkWidget *view_mode = gtk_menu_item_new_with_mnemonic( "_Mode");
  GtkMenu *view_mode_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_mode_menu), view_mode_systemstatus);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_mode_menu), view_mode_userstatus1);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_mode_menu), view_mode_userstatus2);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_mode_menu), view_mode_userstatus3);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_mode_menu), view_mode_userstatus4);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_mode_menu), view_mode_userstatus5);

  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_mode),
			    GTK_WIDGET(view_mode_menu));


  GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in), 
				 gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out), 
				 gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset), 
				 gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_show_events);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_pop_events);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_gui);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_mode);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));


  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator( help_help, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  msg_window = new MsgWindowGtk( this, toplevel, "Status Events", &sts);
  msg_window->find_wnav_cb = find_node_cb;
  msg_window->msg( 'I', "Status Montitor started");
  
  nodelistnav = new NodelistNavGtk( this, vbox, msg_window, 0, mode, view_node_descr,
				    msgw_pop, &nodelistnav_widget);

  // Toolbar
  GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget *tools_save = gtk_button_new();
  gtk_container_add( GTK_CONTAINER(tools_save), 
	  gtk_image_new_from_stock( "gtk-save", GTK_ICON_SIZE_SMALL_TOOLBAR));
  g_signal_connect(tools_save, "clicked", G_CALLBACK(activate_save), this);
  g_object_set( tools_save, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_save, CoWowGtk::translate_utf8("Save configuration"), "");

  GtkWidget *tools_add_node = gtk_button_new();
  gtk_container_add( GTK_CONTAINER(tools_add_node), 
	  gtk_image_new_from_stock( "gtk-add", GTK_ICON_SIZE_SMALL_TOOLBAR));
  g_signal_connect(tools_add_node, "clicked", G_CALLBACK(activate_add_node), this);
  g_object_set( tools_add_node, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_add_node,CoWowGtk::translate_utf8("Add node"), "");

  GtkWidget *tools_remove_node = gtk_button_new();
  gtk_container_add( GTK_CONTAINER(tools_remove_node), 
	  gtk_image_new_from_stock( "gtk-remove", GTK_ICON_SIZE_SMALL_TOOLBAR));
  g_signal_connect(tools_remove_node, "clicked", G_CALLBACK(activate_remove_node), this);
  g_object_set( tools_remove_node, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_remove_node,CoWowGtk::translate_utf8("Remove node"), "");

  GtkWidget *tools_xtt = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_navigator.png");
  gtk_container_add( GTK_CONTAINER(tools_xtt), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_xtt, "clicked", G_CALLBACK(activate_open_xtt), this);
  g_object_set( tools_xtt, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_xtt,CoWowGtk::translate_utf8("Start Runtime Navigator on selected node"), "");

  GtkWidget *tools_op = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_op.png");
  gtk_container_add( GTK_CONTAINER(tools_op), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_op, "clicked", G_CALLBACK(activate_open_opplace), this);
  g_object_set( tools_op, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_op,CoWowGtk::translate_utf8("Start Operatorplace on selected node"), "");

  GtkWidget *tools_rtmon = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_rtmon.png");
  gtk_container_add( GTK_CONTAINER(tools_rtmon), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_rtmon, "clicked", G_CALLBACK(activate_open_rtmon), this);
  g_object_set( tools_rtmon, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_rtmon,CoWowGtk::translate_utf8("Start Runtime Monitor on selected node"), "");

  GtkWidget *tools_zoom_in = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_in), gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(activate_zoom_in), this);
  g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_in,CoWowGtk::translate_utf8("Zoom in"), "");

  GtkWidget *tools_zoom_out = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_out), gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(activate_zoom_out), this);
  g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_out,CoWowGtk::translate_utf8("Zoom out"), "");

  GtkWidget *tools_zoom_reset = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_reset), gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoom_reset), this);
  g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_reset,CoWowGtk::translate_utf8("Zoom reset"), "");

  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(nodelistnav_widget), TRUE, TRUE, 0);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all( toplevel);

  wow = new CoWowGtk( toplevel);

  *status = 1;
}
示例#25
0
GtkWidget *
panel_context_menu_create (PanelWidget *panel)
{
	GtkWidget *retval;
	GtkWidget *menuitem;
	GtkWidget *image;

	if (panel->master_widget) {
		gpointer    *pointer;
		AppletInfo  *info;

		pointer = g_object_get_data (G_OBJECT (panel->master_widget),
					     "applet_info");

		g_assert (pointer != NULL);
		info = (AppletInfo *) pointer;

		if (info->menu == NULL) {
			info->menu = mate_panel_applet_create_menu (info);
		}

		return info->menu;
	}

	retval = create_empty_menu ();
	gtk_widget_set_name (retval, "mate-panel-context-menu");

	if (!panel_lockdown_get_locked_down ())
		panel_context_menu_build_edition (panel, retval);

	menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Help"));
	image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
	gtk_widget_show (menuitem);
	gtk_menu_shell_append (GTK_MENU_SHELL (retval), menuitem);
	g_signal_connect (menuitem, "activate",
			  G_CALLBACK (panel_context_menu_show_help), NULL);

	menuitem = gtk_image_menu_item_new_with_mnemonic (_("A_bout Panels"));
	image = gtk_image_new_from_stock (GTK_STOCK_ABOUT,
					  GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
	gtk_widget_show (menuitem);
	gtk_menu_shell_append (GTK_MENU_SHELL (retval), menuitem);
	g_signal_connect (menuitem, "activate",
			  G_CALLBACK (panel_context_menu_show_about_dialog),
			  NULL);
	
	//FIXME: can we get rid of this? (needed by menu_get_panel())
	g_object_set_data (G_OBJECT (retval), "menu_panel", panel);

/* Set up theme and transparency support */
#if GTK_CHECK_VERSION (3, 0, 0) 
	GtkWidget *toplevel = gtk_widget_get_toplevel (retval);
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
	GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
	GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); 
/* Set menu and it's toplevel window to follow panel theme */
	GtkStyleContext *context;
	context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
	gtk_style_context_add_class(context,"gnome-panel-menu-bar");
	gtk_style_context_add_class(context,"mate-panel-menu-bar");
#endif

	return retval;
}
示例#26
0
static void
saa_main_window_init (SaaMainWindow * w) {
	GtkWidget * vbox_win;

	// Barre de menu ----------------------------------------------------------
	GtkWidget *menubar;
	GtkWidget *image;

	GtkWidget *mit_fichier;
	GtkWidget *mit_fichier_menu;
		GtkWidget *it_charger_xml;
		GtkWidget *it_enregistrer_xml;

		GtkWidget *mit_exporter;
		GtkWidget *mit_exporter_menu;
			GtkWidget *it_exporter;
			GtkWidget *it_exporter_rb;

		GtkWidget *it_sep_fichier;
		GtkWidget *it_quitter;

	GtkWidget *mit_aide;
	GtkWidget *mit_aide_menu;
		GtkWidget *it_a_propos;


	GtkWidget *hbox_win;
	GtkWidget *vbox_prop;

	// Onglets ----------------------------------------------------------------
	GtkWidget *notebook;

	GtkWidget *label_page1;
	GtkWidget *page1;

	GtkWidget *f_uniform;
	GtkWidget *lbl_uniform;

	GtkWidget *f_traitement;
	GtkWidget *lbl_traitement;

	GtkWidget *label_page2;
	GtkWidget *page2;

	GtkWidget *sw;

	GtkWidget *label_page3;
	GtkWidget *page3;

	// Barre d'état -----------------------------------------------------------
	GtkWidget *hbox_status;
	GtkWidget *statusbar;
	GtkWidget *progressbar;

	GtkAccelGroup *accel_group;

	int i;
	const gchar* const * dirs = g_get_system_data_dirs();
	gchar * path;

	// TODO init_files();
	saa_init_files();

	g_set_application_name (PACKAGE_NAME);

	w->icon = NULL;
	for(i=0; dirs[i] && !w->icon; i++) {
		path = g_build_filename(dirs[i], "images", "gsolaar-logo.png", NULL);
		if(g_file_test(path, G_FILE_TEST_EXISTS)) {
			w->icon = gdk_pixbuf_new_from_file(path, NULL);
			gtk_window_set_default_icon (w->icon);
		}
		g_free(path);
	}
	w->visuel = saa_visuel_creer();

	accel_group = gtk_accel_group_new ();

	gtk_window_set_title (GTK_WINDOW (w), "GSolaar");

	vbox_win = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_win);
	gtk_container_add (GTK_CONTAINER (w), vbox_win);

	menubar = gtk_menu_bar_new ();
	gtk_widget_show (menubar);
	gtk_box_pack_start (GTK_BOX (vbox_win), menubar, FALSE, FALSE, 0);

	mit_fichier = gtk_menu_item_new_with_mnemonic(_("_File"));
	gtk_widget_show (mit_fichier);
	gtk_container_add (GTK_CONTAINER (menubar), mit_fichier);

	mit_fichier_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (mit_fichier), mit_fichier_menu);

	// Chargement -------------------------------------------------------------
	it_charger_xml = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, accel_group);
	gtk_widget_show (it_charger_xml);
	gtk_container_add (GTK_CONTAINER (mit_fichier_menu), it_charger_xml);

	// Sauvegarde -------------------------------------------------------------
	it_enregistrer_xml = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, accel_group);
	gtk_widget_show (it_enregistrer_xml);
	gtk_container_add (GTK_CONTAINER (mit_fichier_menu), it_enregistrer_xml);

	// Patron -----------------------------------------------------------------
	mit_exporter = gtk_image_menu_item_new_with_mnemonic(_("_Export"));
	gtk_widget_show(mit_exporter);
	gtk_container_add (GTK_CONTAINER (mit_fichier_menu), mit_exporter);

	image = gtk_image_new_from_stock (GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU);
	gtk_widget_show (image);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mit_exporter), image);

	mit_exporter_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (mit_exporter), mit_exporter_menu);

	it_exporter = gtk_image_menu_item_new_with_label (_("Pattern ..."));
	gtk_widget_show (it_exporter);
	gtk_container_add (GTK_CONTAINER (mit_exporter_menu), it_exporter);

	it_exporter_rb = gtk_image_menu_item_new_with_label (_("Ruby script for SketchUp ..."));
	gtk_widget_show (it_exporter_rb);
	gtk_container_add (GTK_CONTAINER (mit_exporter_menu), it_exporter_rb);

	//-------------------------------------------------------------------------
	it_sep_fichier = gtk_menu_item_new ();
	gtk_widget_show (it_sep_fichier);
	gtk_container_add (GTK_CONTAINER (mit_fichier_menu), it_sep_fichier);
	gtk_widget_set_sensitive (it_sep_fichier, FALSE);

	it_quitter = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, accel_group);
	gtk_widget_show (it_quitter);
	gtk_container_add (GTK_CONTAINER (mit_fichier_menu), it_quitter);

	mit_aide = gtk_menu_item_new_with_mnemonic ("_?");
	gtk_widget_show (mit_aide);
	gtk_container_add (GTK_CONTAINER (menubar), mit_aide);

	mit_aide_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (mit_aide), mit_aide_menu);

	it_a_propos = gtk_image_menu_item_new_from_stock ( GTK_STOCK_ABOUT, accel_group);
	gtk_widget_show (it_a_propos);
	gtk_container_add (GTK_CONTAINER (mit_aide_menu), it_a_propos);

	//-------------------------------------------------------------------------
	hbox_win = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox_win);
	gtk_box_pack_start (GTK_BOX (vbox_win), hbox_win, TRUE, TRUE, 0);

	vbox_prop = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_prop);
	gtk_box_pack_start (GTK_BOX (hbox_win), vbox_prop, TRUE, TRUE, 0);
	gtk_widget_set_size_request (vbox_prop, 500, 400);

	// Drawing Area
	w->area = saa_drawing_area_new_with_visuel (w->visuel);
	gtk_widget_show (w->area);
	gtk_box_pack_start (GTK_BOX (vbox_prop), w->area, TRUE, TRUE, 0);
	gtk_widget_set_size_request (w->area, 600, 400);

	notebook = gtk_notebook_new();
	gtk_widget_show(notebook);
	gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
	gtk_box_pack_start (GTK_BOX (hbox_win), notebook, FALSE, FALSE, 0);

	label_page1 = gtk_label_new (_("Polyhedron"));
	gtk_widget_show (label_page1);

	page1 = gtk_vbox_new (FALSE, 5);
	gtk_widget_show (page1);
	gtk_container_set_border_width (GTK_CONTAINER (page1), 5);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page1, label_page1);

	f_uniform = gtk_frame_new (NULL);
	gtk_widget_show (f_uniform);
	gtk_box_pack_start (GTK_BOX (page1), f_uniform, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (f_uniform), 5);
	gtk_frame_set_label_align (GTK_FRAME (f_uniform), 0.5, 0.5);

	lbl_uniform = gtk_label_new (_("Uniform polyhedra"));
	gtk_widget_show (lbl_uniform);
	gtk_frame_set_label_widget (GTK_FRAME (f_uniform), lbl_uniform);
	gtk_label_set_justify (GTK_LABEL (lbl_uniform), GTK_JUSTIFY_LEFT);

	// Solid manager
	w->manager = saa_solid_manager_new_with_visuel(w->visuel);
	gtk_widget_show(w->manager);
	gtk_container_add (GTK_CONTAINER (f_uniform), w->manager);

	f_traitement = gtk_frame_new (NULL);
	gtk_widget_show (f_traitement);
	gtk_box_pack_start (GTK_BOX (page1), f_traitement, TRUE, TRUE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (f_traitement), 5);
	gtk_frame_set_label_align (GTK_FRAME (f_traitement), 0.5, 0.5);

	lbl_traitement = gtk_label_new (_("Treatment"));
	gtk_widget_show (lbl_traitement);
	gtk_frame_set_label_widget (GTK_FRAME (f_traitement), lbl_traitement);
	gtk_label_set_justify (GTK_LABEL (lbl_traitement), GTK_JUSTIFY_LEFT);

	// Solid Handler
	w->handler = saa_solid_handler_new_with_visuel(w->visuel);
	gtk_widget_show(w->handler);
	gtk_container_add (GTK_CONTAINER (f_traitement), w->handler);

	label_page2 = gtk_label_new (_("Navigation"));
	gtk_widget_show (label_page2);

	page2 = gtk_vbox_new (FALSE, 5);
	gtk_widget_show (page2);
	gtk_container_set_border_width (GTK_CONTAINER (page2), 5);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page2, label_page2);

    sw = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show(sw);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start (GTK_BOX (page2), sw, TRUE, TRUE, 0);

    // Treeview navigator
	w->explorer = saa_tree_view_new_with_visuel(w->visuel);
	gtk_widget_show(w->explorer);
	gtk_container_add (GTK_CONTAINER (sw), w->explorer);

	// TODO a deplacer dans window realize
	saa_tree_view_update(SAA_TREE_VIEW(w->explorer));

	label_page3 = gtk_label_new (_("Display"));
	gtk_widget_show (label_page3);

	page3 = gtk_vbox_new (FALSE, 5);
	gtk_widget_show (page3);
	gtk_container_set_border_width (GTK_CONTAINER (page3), 5);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page3, label_page3);

	// Solid display
	w->display = saa_solid_display_new_with_visuel(w->visuel);
	gtk_widget_show (w->display);
	gtk_box_pack_start(GTK_BOX(page3), w->display, TRUE, TRUE, 0);


	hbox_status = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox_status);
	gtk_box_pack_start (GTK_BOX (vbox_win), hbox_status, FALSE, FALSE, 0);

	statusbar = gtk_statusbar_new ();
	gtk_widget_show (statusbar);
	gtk_box_pack_start (GTK_BOX (hbox_status), statusbar, TRUE, TRUE, 0);

	progressbar = gtk_progress_bar_new ();
	gtk_widget_show (progressbar);
	gtk_box_pack_start (GTK_BOX (hbox_status), progressbar, FALSE, FALSE, 0);

	g_signal_connect_swapped ((gpointer)w->manager, "solid-changed",
			G_CALLBACK (saa_tree_view_update),
			w->explorer);
	g_signal_connect_swapped ((gpointer)w->manager, "solid-changed",
			G_CALLBACK (gtk_widget_queue_draw),
			w->area);

	g_signal_connect_swapped ((gpointer)w->display, "solid-changed",
			G_CALLBACK (gtk_widget_queue_draw),
			w->area);

	g_signal_connect_swapped ((gpointer)w->handler, "solid-changed",
			G_CALLBACK (saa_tree_view_update),
			w->explorer);
	g_signal_connect_swapped ((gpointer)w->handler, "solid-changed",
			G_CALLBACK (gtk_widget_queue_draw),
			w->area);

	g_signal_connect_swapped ((gpointer)w->area, "vertex-selected",
			G_CALLBACK (saa_tree_view_select_vertex),
			w->explorer);
	g_signal_connect_swapped ((gpointer)w->area, "edge-selected",
			G_CALLBACK (saa_tree_view_select_edge),
			w->explorer);
	g_signal_connect_swapped ((gpointer)w->area, "wing-selected",
			G_CALLBACK (saa_tree_view_select_wing),
			w->explorer);

	g_signal_connect_swapped ((gpointer)w->explorer, "vertex-selected",
			G_CALLBACK (saa_drawing_area_select_vertex),
			w->area);
	g_signal_connect_swapped ((gpointer)w->explorer, "edge-selected",
			G_CALLBACK (saa_drawing_area_select_edge),
			w->area);
	g_signal_connect_swapped ((gpointer)w->explorer, "wing-selected",
			G_CALLBACK (saa_drawing_area_select_wing),
			w->area);

	g_signal_connect_swapped((gpointer)it_charger_xml, "activate",
			G_CALLBACK (saa_main_window_charger_xml_clicked),
			w);
	g_signal_connect_swapped((gpointer)it_enregistrer_xml, "activate",
			G_CALLBACK (saa_main_window_sauver_xml_activate),
			w);
	g_signal_connect_swapped((gpointer)it_exporter, "activate",
			G_CALLBACK (saa_main_window_exporter_activate),
			w);
	g_signal_connect_swapped((gpointer)it_exporter_rb, "activate",
			G_CALLBACK (saa_main_window_exporter_rb_activate),
			w);

	g_signal_connect_swapped ((gpointer)it_quitter, "activate",
			G_CALLBACK (saa_main_window_quitter_activate),
			w);
	g_signal_connect (G_OBJECT(w), "destroy",
			G_CALLBACK (saa_main_window_quitter_activate),
			NULL);

	g_signal_connect_swapped ((gpointer)it_a_propos, "activate",
			G_CALLBACK (saa_main_window_a_propos_activate),
			w);

	gtk_window_add_accel_group (GTK_WINDOW (w), accel_group);
}
示例#27
0
static void
notebook_popup_menu_show (NemoWindowPane *pane,
			  GdkEventButton *event)
{
	GtkWidget *popup;
	GtkWidget *item;
	GtkWidget *image;
	int button, event_time;
	gboolean can_move_left, can_move_right;
	NemoNotebook *notebook;

	notebook = NEMO_NOTEBOOK (pane->notebook);

	can_move_left = nemo_notebook_can_reorder_current_child_relative (notebook, -1);
	can_move_right = nemo_notebook_can_reorder_current_child_relative (notebook, 1);

	popup = gtk_menu_new();

	item = gtk_menu_item_new_with_mnemonic (_("_New Tab"));
	g_signal_connect (item, "activate",
			  G_CALLBACK (notebook_popup_menu_new_tab_cb),
			  pane);
	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
			       item);

	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
			       gtk_separator_menu_item_new ());

	item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left"));
	g_signal_connect (item, "activate",
			  G_CALLBACK (notebook_popup_menu_move_left_cb),
			  pane);
	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
			       item);
	gtk_widget_set_sensitive (item, can_move_left);

	item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Right"));
	g_signal_connect (item, "activate",
			  G_CALLBACK (notebook_popup_menu_move_right_cb),
			  pane);
	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
			       item);
	gtk_widget_set_sensitive (item, can_move_right);

	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
			       gtk_separator_menu_item_new ());

	item = gtk_image_menu_item_new_with_mnemonic (_("_Close Tab"));
	image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
	g_signal_connect (item, "activate",
			  G_CALLBACK (notebook_popup_menu_close_cb), pane);
	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
			       item);

	gtk_widget_show_all (popup);

	if (event) {
		button = event->button;
		event_time = event->time;
	} else {
		button = 0;
		event_time = gtk_get_current_event_time ();
	}

	/* TODO is this correct? */
	gtk_menu_attach_to_widget (GTK_MENU (popup),
				   pane->notebook,
				   NULL);

	gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
			button, event_time);
}
static void
thunar_chooser_button_pressed (ThunarChooserButton *chooser_button,
                               GtkWidget           *button)
{
  ThunarVfsMimeApplication *default_application;
  ThunarVfsMimeInfo        *info;
  ThunarIconFactory        *icon_factory;
  GtkIconTheme             *icon_theme;
  const gchar              *icon_name;
  GdkPixbuf                *icon;
  GtkWidget                *image;
  GtkWidget                *item;
  GtkWidget                *menu;
  GList                    *applications;
  GList                    *lp;
  gint                      icon_size;

  _thunar_return_if_fail (THUNAR_IS_CHOOSER_BUTTON (chooser_button));
  _thunar_return_if_fail (chooser_button->button == button);
  _thunar_return_if_fail (GTK_IS_BUTTON (button));

  /* verify that we have a valid file */
  if (G_UNLIKELY (chooser_button->file == NULL))
    return;

  /* determine the mime info for the file */
  info = thunar_file_get_mime_info (chooser_button->file);

  /* determine the default application */
  default_application = thunar_vfs_mime_database_get_default_application (chooser_button->database, info);
  if (G_UNLIKELY (default_application == NULL))
    {
      /* no default application, just popup the application chooser */
      thunar_chooser_button_activate_other (chooser_button);
      return;
    }

  /* determine all applications that claim to be able to handle the file */
  applications = thunar_vfs_mime_database_get_applications (chooser_button->database, info);

  /* make sure the default application comes first */
  lp = g_list_find (applications, default_application);
  if (G_LIKELY (lp != NULL))
    {
      applications = g_list_delete_link (applications, lp);
      g_object_unref (G_OBJECT (default_application));
    }
  applications = g_list_prepend (applications, default_application);

  /* allocate a new popup menu */
  menu = gtk_menu_new ();

  /* determine the icon size for menus */
  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_size, &icon_size);

  /* determine the icon factory for our screen */
  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (button));
  icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);

  /* add the other possible applications */
  for (lp = applications; lp != NULL; lp = lp->next)
    {
      item = gtk_image_menu_item_new_with_label (thunar_vfs_mime_handler_get_name (lp->data));
      g_object_set_data_full (G_OBJECT (item), I_("thunar-vfs-mime-application"), lp->data, g_object_unref);
      g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_chooser_button_activate), chooser_button);
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
      gtk_widget_show (item);

      /* setup the icon for the application */
      icon_name = thunar_vfs_mime_handler_lookup_icon_name (lp->data, icon_theme);
      icon = thunar_icon_factory_load_icon (icon_factory, icon_name, icon_size, NULL, FALSE);
      image = gtk_image_new_from_pixbuf (icon);
      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
      gtk_widget_show (image);
      if (G_LIKELY (icon != NULL))
        g_object_unref (icon);
    }

  /* cleanup */
  g_object_unref (G_OBJECT (icon_factory));

  /* append a separator */
  item = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show (item);

  /* release the applications list */
  g_list_free (applications);

  /* add the "Other Application..." choice */
  item = gtk_image_menu_item_new_with_mnemonic (_("_Other Application..."));
  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_chooser_button_activate_other), chooser_button);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show (item);

  /* make sure the menu has atleast the same width as the chooser */
  if (menu->allocation.width < button->allocation.width)
    gtk_widget_set_size_request (menu, button->allocation.width, -1);

  /* run the menu on the button's screen (takes over the floating reference of menu) */
  thunar_gtk_menu_run (GTK_MENU (menu), button, menu_position, button, 0, gtk_get_current_event_time ());

  /* yeppa, that's a requirement */
  gtk_button_released (GTK_BUTTON (button));
}
示例#29
0
/*
 * Windows Main
 * Twitter TimeLine Cntent
 * 
 */
int windows_main(int argc, char **argv){
	
	gtk_init (&argc, &argv);

	char *configFile = NULL;
	GError *error = NULL;
	GtkWidget *window,
	*table,
	*scroll,
	*icon_menu,
	*table_into,
	//*tweet,
	//*avatar,
	*scrolled_window,
	*menu_bar,
	*layout,
	*toolbar,
	*statusbar,
	*statusbar_char,
	*new_button,
	*text,
	*file_menu_obj,
	*file_menu_root,
	*file_menu_items,
	*aiuto_menu_obj,
	*aiuto_menu_root,
	*aiuto_menu_items;
	GtkTextBuffer *buffer;

	asprintf(&configFile, "%s%s", g_get_home_dir(), "/.twc/config/user.twc");

	/* Set all window options (color, size, position, logo, icon, etc) */
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW(window), 315, 650);
	gtk_widget_set_size_request (window, 315, 400);
	gtk_window_set_title (GTK_WINDOW(window), "TwitCrusader");
	gtk_container_set_border_width (GTK_CONTAINER (window), 0);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_icon_from_file (GTK_WINDOW(window), ICON_FAVICON, &error);

	/* CALLBACK: exit event */
	g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);

	/* GTK Widget: Menu */
	file_menu_obj = gtk_menu_new();
	aiuto_menu_obj = gtk_menu_new();

	/* SuBMenu File
	 * Fix Icons Linux
	 * gconftool-2 --type boolean --set /desktop/gnome/interface/buttons_have_icons true
	 * gconftool-2 --type boolean --set /desktop/gnome/interface/menus_have_icons true
	 *  */
	file_menu_items = gtk_image_menu_item_new_with_label("Nuovo Utente");
	icon_menu = gtk_image_new_from_file(ICON_ADDUSER);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (file_menu_items), icon_menu);
	g_signal_connect (G_OBJECT (file_menu_items), "activate", G_CALLBACK (windows_adduser), NULL);
	gtk_menu_append(GTK_MENU (file_menu_obj), file_menu_items);

	file_menu_items = gtk_image_menu_item_new_with_label("Opzioni");
	icon_menu = gtk_image_new_from_file(ICON_SETTINGS);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (file_menu_items), icon_menu);
	g_signal_connect (G_OBJECT (file_menu_items), "activate", G_CALLBACK (windows_setting), NULL);
	gtk_menu_append(GTK_MENU (file_menu_obj), file_menu_items);

	file_menu_items = gtk_image_menu_item_new_with_label("Esci");
	icon_menu = gtk_image_new_from_file(ICON_CLOSE);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (file_menu_items), icon_menu);
	g_signal_connect (G_OBJECT (file_menu_items), "activate", G_CALLBACK (gtk_main_quit), NULL);
	gtk_menu_append(GTK_MENU (file_menu_obj), file_menu_items);

	file_menu_root = gtk_menu_item_new_with_label("File");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM (file_menu_root), file_menu_obj);

	/* SubMenu: Help */
	aiuto_menu_items = gtk_image_menu_item_new_with_label("Updates");
	icon_menu = gtk_image_new_from_file(ICON_UPGRADE);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (aiuto_menu_items), icon_menu);
	g_signal_connect (G_OBJECT (aiuto_menu_items), "activate", G_CALLBACK (windows_upgrade), NULL);
	gtk_menu_append(GTK_MENU (aiuto_menu_obj), aiuto_menu_items);
	
	aiuto_menu_items = gtk_image_menu_item_new_with_label("Informazioni");
	icon_menu = gtk_image_new_from_file(ICON_STAR);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (aiuto_menu_items), icon_menu);
	g_signal_connect (G_OBJECT (aiuto_menu_items), "activate", G_CALLBACK (windows_about), NULL);
	gtk_menu_append(GTK_MENU (aiuto_menu_obj), aiuto_menu_items);


	aiuto_menu_root = gtk_menu_item_new_with_label("Aiuto");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM (aiuto_menu_root), aiuto_menu_obj);

	/* Set Layout Position */
	layout = gtk_vbox_new(0, 1);
	gtk_container_add(GTK_CONTAINER(window), layout);
	menu_bar = gtk_menu_bar_new();
	gtk_box_pack_start(GTK_BOX(layout), menu_bar, FALSE, FALSE, 0);
	gtk_menu_bar_append(GTK_MENU_BAR (menu_bar), file_menu_root);
	gtk_menu_bar_append(GTK_MENU_BAR (menu_bar), aiuto_menu_root);

	/* Status Bar */
	statusbar = gtk_statusbar_new ();
	gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR(statusbar), TRUE);
	gtk_statusbar_push (GTK_STATUSBAR(statusbar), 0, "TwitCrusader...");
	gtk_box_pack_end (GTK_BOX (layout), statusbar, FALSE, FALSE, 0);

	/* GTK Widget: Twitter Menu */
	toolbar = gtk_toolbar_new ();
	gtk_box_pack_end (GTK_BOX (layout), toolbar, FALSE, FALSE, 0);
	gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
	gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar));

	/* Twitter Menu: Buttons */
	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_HOME);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_UPDATE);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_MENTION);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_DM);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_FAVORITES);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_LINK);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	new_button = gtk_button_new();
	icon_menu = gtk_image_new_from_file(ICON_PHOTO);
	gtk_button_set_image(GTK_BUTTON(new_button),icon_menu);
	gtk_container_add (GTK_CONTAINER (toolbar), new_button);

	/* Status Bar: Twitter 140char */
	statusbar_char = gtk_statusbar_new ();
	gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR(statusbar_char), FALSE);
	gtk_statusbar_push (GTK_STATUSBAR(statusbar_char), 0, "140");
	gtk_box_pack_end (GTK_BOX (layout), statusbar_char, FALSE, FALSE, 0);

	/* Table Content Tweet/Mentions */
	table = gtk_table_new (9, 3, TRUE);
	gtk_container_add(GTK_CONTAINER(layout), table);

	/* Scrolled */
	table_into = gtk_table_new (1, 3, TRUE);
	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
	gtk_table_attach (GTK_TABLE (table), scrolled_window, 0, 3, 0, 8, GTK_FILL | GTK_EXPAND,GTK_FILL | GTK_EXPAND, 0, 0);
	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), table_into);
	/*for ( rows = 0; rows < 40; rows = rows + 4 ) {
       for ( cols = 0; cols < 3; cols++ ) {
            avatar = gtk_image_new_from_file ("");
		   	tweet = gtk_label_new ("");
		   	gtk_label_set_justify (GTK_LABEL(tweet),GTK_JUSTIFY_LEFT);
		   	gtk_label_set_line_wrap_mode (GTK_LABEL(tweet), GTK_WRAP_WORD_CHAR);
           gtk_table_attach (GTK_TABLE (table_into ), tweet, 0, 1,rows, rows + 4, GTK_FILL | GTK_EXPAND,GTK_FILL, 0, 0);
            gtk_table_attach (GTK_TABLE (table_into ), tweet, 1, 3,rows, rows + 1, GTK_FILL | GTK_EXPAND,GTK_FILL, 0, 0);
            tweet = gtk_label_new ("");
            gtk_table_attach (GTK_TABLE (table_into ), tweet, 1, 3,rows + 1, rows + 4, GTK_FILL | GTK_EXPAND,GTK_FILL, 0, 0);
       }
	}*/

	// TextArea + Scrollbar
	scroll = gtk_scrolled_window_new(NULL,NULL);
	gtk_table_attach (GTK_TABLE (table), scroll, 0, 3,8, 9, GTK_FILL | GTK_EXPAND,GTK_FILL | GTK_EXPAND, 0, 0);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
	text = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text), TRUE);
	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(text), GTK_WRAP_WORD_CHAR);
	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
	gtk_text_buffer_set_text (buffer, "", -1);
	g_signal_connect(buffer, "changed", G_CALLBACK(update_statusbar), statusbar_char);
	g_signal_connect(text, "key-press-event", G_CALLBACK(send_tweet_gtk), buffer);
	gtk_container_add(GTK_CONTAINER(scroll), text);

	// Widget Show
	gtk_widget_show_all (window);
	
	//Exist Config File?
	if(readUserFile()==1) windows_adduser();

	//Show GTK Main
	gtk_main ();


	return 0;
}
static GtkWidget *
build_suggestion_menu (PlumaAutomaticSpellChecker *spell, const gchar *word) 
{
	GtkWidget *topmenu, *menu;
	GtkWidget *mi;
	GSList *suggestions;
	GSList *list;
	gchar *label_text;
	
	topmenu = menu = gtk_menu_new();

	suggestions = pluma_spell_checker_get_suggestions (spell->spell_checker, word, -1);

	list = suggestions;

	if (suggestions == NULL) 
	{		
		/* no suggestions.  put something in the menu anyway... */
		GtkWidget *label;
		/* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions for the current misspelled word */
		label = gtk_label_new (_("(no suggested words)"));
		
		mi = gtk_menu_item_new ();
		gtk_widget_set_sensitive (mi, FALSE);
		gtk_container_add (GTK_CONTAINER(mi), label);
		gtk_widget_show_all (mi);
		gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
	} 
	else 
	{
		gint count = 0;
		
		/* build a set of menus with suggestions. */
		while (suggestions != NULL) 
		{
			GtkWidget *label;

			if (count == 10) 
			{
				/* Separator */
				mi = gtk_menu_item_new ();
				gtk_widget_show (mi);
				gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
	
				mi = gtk_menu_item_new_with_mnemonic (_("_More..."));
				gtk_widget_show (mi);
				gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);

				menu = gtk_menu_new ();
				gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
				count = 0;
			}
			
			label_text = g_strdup_printf ("<b>%s</b>", (gchar*) suggestions->data);
			
			label = gtk_label_new (label_text);
			gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
			gtk_label_set_xalign (GTK_LABEL (label), 0.0);

			mi = gtk_menu_item_new ();
			gtk_container_add (GTK_CONTAINER(mi), label);
			
			gtk_widget_show_all (mi);
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);

			g_object_set_qdata_full (G_OBJECT (mi), 
				 suggestion_id, 
				 g_strdup (suggestions->data), 
				 (GDestroyNotify)g_free);

			g_free (label_text);
			g_signal_connect (mi,
					  "activate",
					  G_CALLBACK (replace_word),
					  spell);

			count++;

			suggestions = g_slist_next (suggestions);
		}
	}

	/* free the suggestion list */
	suggestions = list;

	while (list)
	{
		g_free (list->data);
		list = g_slist_next (list);
	}

	g_slist_free (suggestions);

	/* Separator */
	mi = gtk_menu_item_new ();
	gtk_widget_show (mi);
	gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);

	/* Ignore all */
	mi = gtk_image_menu_item_new_with_mnemonic (_("_Ignore All"));
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
				       gtk_image_new_from_icon_name ("go-bottom", 
					       			     GTK_ICON_SIZE_MENU));
	
	g_signal_connect (mi,
			  "activate",
			  G_CALLBACK(ignore_all),
			  spell);

	gtk_widget_show_all (mi);

	gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);

	/* + Add to Dictionary */
	mi = gtk_image_menu_item_new_with_mnemonic (_("_Add"));
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
				       gtk_image_new_from_icon_name ("list-add", 
					       			     GTK_ICON_SIZE_MENU));

	g_signal_connect (mi,
			  "activate",
			  G_CALLBACK (add_to_dictionary),
			  spell);

	gtk_widget_show_all (mi);
	
	gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);

	return topmenu;
}