Example #1
0
void _HYPlatformWindow::_SetMenuBar(void)
{
    _HYWindow* theParent = (_HYWindow*)this;
    if (windowMB && menu_items == nil)
    {

        GtkAccelGroup * accel_group = gtk_accel_group_new();
        menu_items = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<HY_WINDOW>",accel_group);
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_window_menu_file) / sizeof (hyphy_window_menu_file[0]), hyphy_window_menu_file, theParent);
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_window_menu_edit) / sizeof (hyphy_window_menu_edit[0]), hyphy_window_menu_edit, theParent);
        gtk_window_add_accel_group (GTK_WINDOW (theWindow), accel_group);
        windowMB   = gtk_item_factory_get_widget (menu_items, "<HY_WINDOW>");
        gtk_widget_show (windowMB);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Undo"),  FALSE);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Copy"),  FALSE);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Cut"),  FALSE);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Paste"),  FALSE);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Clear"),  FALSE);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Select All"),  FALSE);

    }
    else if (menu_items)
    {
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/File/Save"),  theParent->IsSaveEnabled());
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/File/Print"), theParent->IsPrintEnabled());
    }
}
Example #2
0
void _HYModelWindow::_SetMenuBar(void)
{
    if (menu_items && !gtk_item_factory_get_item(menu_items,"<HY_WINDOW>/Model")) {
        gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Save");
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_parameter_model_window_menu) / sizeof (hyphy_parameter_model_window_menu[0]),
                                       hyphy_parameter_model_window_menu, this);

        GtkMenu * fileMenu = GTK_MENU (gtk_item_factory_get_widget (menu_items, "<HY_WINDOW>/File"));
        gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/Save"), 0);

        for (long k=0; k<rateOptions.lLength; k++) {
            _String *thisItem = (_String*)rateOptions (k),
                     chopped,
                     type = "<CheckItem>";

            GtkItemFactoryEntry aProcEntry = {NULL,NULL,(GtkItemFactoryCallback)hyphy_menu_item_callback,HY_MDL_WIN32_MENU_BASE+100+k,type.sData};
            chopped = _String("/Model/Rate variation/")&*thisItem;
            aProcEntry.path = chopped.sData;

            gtk_item_factory_create_items (menu_items,  1, &aProcEntry, this);
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget_by_action(menu_items,HY_MDL_WIN32_MENU_BASE+100+rateChoice)),
                                       true);

        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Copy"),  true);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Select All"),  true);
    }
}
void _HYConsoleWindow::_SetMenuBar(void)
{
    if (menu_items && !gtk_item_factory_get_item(menu_items,"<HY_WINDOW>/Analysis")) {
        gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Open");
        gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Close");
        gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Switch to console");
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_console_window_menu_file) / sizeof (hyphy_console_window_menu_file[0]), hyphy_console_window_menu_file, this);

        GtkMenu * fileMenu = GTK_MENU (gtk_item_factory_get_widget (menu_items, "<HY_WINDOW>/File"));
        gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/New"), 0);
        gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/Open"), 1);
        gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/sep1"), 2);

        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Clear"),  true);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Select All"),  true);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,21),  false);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,22),  false);
        gtk_widget_set_sensitive(gtk_item_factory_get_item (menu_items,"<HY_WINDOW>/Analysis/Results"),  false);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,30),  false);

        for (long counter=0; counter<availablePostProcessors.countitems(); counter++) {
            _String * postItem = (_String*)(*(_List*)availablePostProcessors(counter))(0);
            if (!postItem->Equal (&menuSeparator)) {
                postItem = (_String*)(*(_List*)availablePostProcessors(counter))(1);
                _String tryFileName (*postItem);
                FILE    * tryFile   = doFileOpen (tryFileName.getStr(), "r");
                if (tryFile) {
                    fclose(tryFile);
                } else {
                    availablePostProcessors.Delete(counter);
                    counter--;
                }
            }
        }
        if (availablePostProcessors.lLength) {
            long sepCount = 0;
            for (long counter=0; counter<availablePostProcessors.countitems(); counter++) {
                _String * postItem = (_String*)(*(_List*)availablePostProcessors(counter))(0),
                          chopped  = _String("/Analysis/Results/")&*postItem;

                if (postItem->Equal (&menuSeparator)) {
                    GtkItemFactoryEntry aProcEntry = {NULL,NULL,NULL,0,"<Separator>"};
                    chopped = chopped & sepCount++;
                    aProcEntry.path = chopped.sData;
                    gtk_item_factory_create_items (menu_items,  1, &aProcEntry, this);
                } else {
                    GtkItemFactoryEntry aProcEntry = {NULL,NULL,hyphy_menu_item_callback,1000+counter,"<Item>"};
                    aProcEntry.path = chopped.sData;
                    gtk_item_factory_create_items (menu_items,  1, &aProcEntry, this);
                }
            }

        }
    }
}
Example #4
0
void get_main_menu(GtkWidget * window, GtkWidget ** menubar) {
    GtkItemFactory *item_factory;
    GtkAccelGroup *accel_group;
    gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);

    accel_group = gtk_accel_group_new();

    /* This function initializes the item factory.
       Param 1: The type of menu - can be GTK_TYPE_MENU_BAR, GTK_TYPE_MENU,
       or GTK_TYPE_OPTION_MENU.
       Param 2: The path of the menu.
       Param 3: A pointer to a gtk_accel_group.  The item factory sets up
       the accelerator table while generating menus.
     */

    item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
                                        accel_group);

    /* This function generates the menu items. Pass the item factory,
       the number of items in the array, the array itself, and any
       callback data for the the menu items. */
    gtk_item_factory_create_items(item_factory, nmenu_items, menu_items,
                                  NULL);

    /* Attach the new accelerator group to the window. */
    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

    if (menubar)
        /* Finally, return the actual menu bar created by the item factory. */
        *menubar = gtk_item_factory_get_widget(item_factory, "<main>");
}
Example #5
0
void itemfact(int argc, char* argv[])
{
    GtkWidget* window;
    GtkWidget* box;
    GtkWidget* menubar;
    GtkAccelGroup* accel_group;
    GtkItemFactory* item_factory;
    gint n=15;

    gtk_init(&argc, &argv);
    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), txt("Ìí¼Ó²Ëµ¥µÄ¿ì½Ý·½·¨"));
    g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
    accel_group=gtk_accel_group_new();
    box=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window), box);
    gtk_widget_show(box);
    item_factory=gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
    gtk_item_factory_create_items(item_factory, n, menu_items, NULL);
    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
    menubar=gtk_item_factory_get_widget(item_factory, "<main>");
    gtk_box_pack_start(GTK_BOX(box), menubar, FALSE, FALSE, 0);
    gtk_widget_show(menubar);
    gtk_widget_show(window);
    gtk_main();
}
/* Returns a menubar widget made from the above menu */
static void create_menubar_menu()
{
	GtkItemFactory *item_factory;
	GtkAccelGroup *accel_group;

	/* Make an accelerator group (shortcut keys) */
	accel_group = gtk_accel_group_new ();

	/* Make an ItemFactory (that makes a menubar) */
	item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
									   accel_group);

	/* This function generates the menu items. Pass the item factory,
	 the number of items in the array, the array itself, and any
	 callback data for the the menu items. */
	gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);

	/* Attach the new accelerator group to the window. */
	gtk_window_add_accel_group (GTK_WINDOW (bdk_window.fenster), accel_group);

	/* Finally, return the actual menu bar created by the item factory. */
	bdk_window.menubar = gtk_item_factory_get_widget (item_factory, "<main>");

	gtk_box_pack_start (GTK_BOX (bdk_window.main_vbox), bdk_window.menubar, FALSE, TRUE, 0);
}
Example #7
0
File: menu.c Project: Goon83/SALB
/* gui_menu_setup(window)
 *
 * Creates the menubar and attaches accelerators to the window passed in.
 *
 * Returns pointer to menu bar widget.
 */
GtkWidget *gui_menu_setup(
    GtkWidget * window)
{
    gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);

    GtkItemFactory *item_factory;
    GtkAccelGroup *accel_group;

    accel_group = gtk_accel_group_new();

    item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
                                        accel_group);

    /* This function generates the menu items. Pass the item factory,
       the number of items in the array, the array itself, and any
       callback data for the the menu items. */
    gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL);

    /* Attach the new accelerator group to the window. */
    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

    /* Save the main window widget so we can attach dialogs to it, etc. */
    main_window = window;

    /* Finally, return the actual menu bar created by the item factory. */
    return gtk_item_factory_get_widget(item_factory, "<main>");
}
Example #8
0
_String HandlePullDown (_List& menuOptions, long l, long t,long startPos)
{
    lastPopupMenuSelection = -1;
    lastPopupMenuItemStrings.Clear();
    if (lastPopupFactory) {
        delete lastPopupFactory;
    }

    if (menuOptions.lLength) {
        ListToPopUpMenu (menuOptions);
        GtkWidget *menu;

        int button                  = 0;
        guint32     event_time      = gtk_get_current_event_time ();

        GtkItemFactory * menu_items = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<HY_POPUP>", NULL);
        gtk_item_factory_create_items (menu_items,  menuOptions.lLength, lastPopupFactory, menu);

        menu = gtk_item_factory_get_widget (menu_items, "<HY_POPUP>/Popup");
        g_signal_connect (menu, "selection-done", (GCallback)hyphy_popup_menu_close, menu_items);

        lastPopupMenuSelection = -1;

        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,  button, event_time);
        gtk_main ();
        gtk_widget_destroy (menu);
        g_object_unref(menu_items);
        if (lastPopupMenuSelection>=0) {
            return *(_String*)menuOptions (lastPopupMenuSelection);
        }

    }

    return empty;
}
Example #9
0
static VALUE
ifact_create_items(VALUE self, VALUE ary)
{
    VALUE entry, path, accel, type, func, data, extdata;
    GtkItemFactoryEntry *entries;
    guint i, len, n_menu_entries;

    n_menu_entries = RARRAY_LEN(ary);
    entries = ALLOC_N(GtkItemFactoryEntry, n_menu_entries);

    for (i = 0; i < n_menu_entries; i++) {
        entry = RARRAY_PTR(ary)[i];
        len = RARRAY_LEN(entry);
        Check_Type(entry, T_ARRAY);
        path =  RARRAY_PTR(entry)[0];
        type =  ((len > 1) ? RARRAY_PTR(entry)[1] : Qnil);
        accel = ((len > 2) ? RARRAY_PTR(entry)[2] : Qnil);
        extdata = ((len > 3) ? RARRAY_PTR(entry)[3] : Qnil);
        func =  ((len > 4) ? RARRAY_PTR(entry)[4] : Qnil);
        data =  ((len > 5) ? RARRAY_PTR(entry)[5] : Qnil);

        create_factory_entry(&entries[i], self, path, type, accel, extdata, func, data);
    }

    gtk_item_factory_create_items (_SELF(self), n_menu_entries, entries, NULL);
    g_free(entries);

    return self;
}
Example #10
0
/*
 *  menu_create:
 *     @ Create menu bar widget.
 *
 *  window    : Window widget that attach accel group.
 *  entries   : Menu item entries.
 *  n_entries : Number of menu items.
 *  path      : Root menu path.
 *  data      : User data for menu callback.
 *  Return    : Menubar widget.
 */
GtkWidget *
menubar_create (GtkWidget *window,
                GtkItemFactoryEntry *entries,
                guint n_entries,
                const gchar *path,
                gpointer data)
{
   GtkItemFactory *factory;
   GtkAccelGroup *accel_group;
   GtkWidget *widget;

   accel_group = gtk_accel_group_new ();
   factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, path, accel_group);
#ifdef ENABLE_NLS
   gtk_item_factory_set_translate_func (factory, (GtkTranslateFunc) gettext,
                                        NULL, NULL);
#endif /* ENABLE_NLS */
   gtk_item_factory_create_items (factory, n_entries, entries, data);
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);

   widget = gtk_item_factory_get_widget (factory, path);
   g_signal_connect (G_OBJECT (widget), "destroy",
                     G_CALLBACK (cb_menu_destroy), factory);

   return widget;
}
Example #11
0
void init_app( App *a )
{
    GtkWidget      *menubar;
    GtkItemFactory *item_factory;
    GtkAccelGroup  *accel_group = gtk_accel_group_new();
    signed int     nitems       = sizeof ( menu_items ) / sizeof ( menu_items[0] );

    GtkWidget      *vbox, *hbox;

    // Create the top-level root window
    a->rootwindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    gtk_signal_connect( GTK_OBJECT( a->rootwindow ), "delete_event", gtk_main_quit,
        NULL );

    // A toplevel box to hold things
    vbox = gtk_vbox_new( FALSE, 0 );
    gtk_container_add( GTK_CONTAINER( a->rootwindow ), vbox );

    // Construct the main menu structure
    item_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", accel_group );
    gtk_item_factory_create_items( item_factory, (guint) nitems, menu_items, NULL );
    gtk_window_add_accel_group( GTK_WINDOW( a->rootwindow ), accel_group );
    menubar = gtk_item_factory_get_widget( item_factory, "<main>" );
    gtk_box_pack_start( GTK_BOX( vbox ), menubar, FALSE, FALSE, 0 );
    gtk_widget_show( menubar );

    // Fiddle with boxes to effect an indent from the edges of the root window
    hbox = gtk_hbox_new( FALSE, 0 );
    gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 10 );
    vbox = gtk_vbox_new( FALSE, 10 );
    gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 10 );

    // Add an area to plot into
    a->plotwindow        = gtk_drawing_area_new();
    a->plotwindow_pixmap = NULL;

  #if TO_PIXMAP != 1
    // Turn off double buffering if we are plotting direct to the plotwindow
    // in setup_plot_drawable().
    //
    GTK_WIDGET_UNSET_FLAGS( a->plotwindow, GTK_DOUBLE_BUFFERED );
  #endif

    // By experiment, 3x3 seems to be the smallest size plplot can cope with.
    // Here we utilise the side effect that gtk_widget_set_size_request()
    // effectively sets the minimum size of the widget.
    //
    gtk_widget_set_size_request( a->plotwindow, 3, 3 );
    gtk_box_pack_start( GTK_BOX( vbox ), a->plotwindow, TRUE, TRUE, 0 );

    // Set the initial size of the application
    gtk_window_set_default_size( GTK_WINDOW( a->rootwindow ), APP_INITIAL_WIDTH, APP_INITIAL_HEIGHT );

    g_signal_connect( G_OBJECT( a->plotwindow ), "configure_event",
        G_CALLBACK( ev_plotwindow_conf ), NULL );
    g_signal_connect( G_OBJECT( a->plotwindow ), "expose_event",
        G_CALLBACK( ev_plotwindow_expose ), NULL );

    gtk_widget_show_all( a->rootwindow );
}
void _HYParameterTable::_SetMenuBar(void)
{
	if (menu_items && !gtk_item_factory_get_widget(menu_items,"<HY_WINDOW>/Likelihood"))
	{
		gtk_item_factory_create_items (menu_items,  sizeof (hyphy_parameter_table_window_menu) / sizeof (hyphy_parameter_table_window_menu[0]),
														    hyphy_parameter_table_window_menu, this);
		_UpdateViewMenu();
		gtk_widget_set_sensitive (gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT),undoCommands.lLength);
	}
}
Example #13
0
/*-----------------------------------------------------------------------------------------------------------------*/
void GetMainMenu(GtkWidget*window,GtkWidget **menubar)
{
GtkItemFactory *item_factory;
GtkAccelGroup *accel_group;
gint nmenu_items=sizeof(menu_items)/sizeof(menu_items[0]);

accel_group=gtk_accel_group_new();
item_factory=gtk_item_factory_new(GTK_TYPE_MENU_BAR,"<main>",accel_group);
gtk_item_factory_create_items(item_factory,nmenu_items,menu_items,NULL);
gtk_window_add_accel_group(GTK_WINDOW(window),accel_group);
if (menubar) *menubar=gtk_item_factory_get_widget(item_factory,"<main>");
}
void _HYDistributionChartWindow::_SetMenuBar(void)
{
    if (menu_items && !gtk_item_factory_get_widget(menu_items,"<HY_WINDOW>/Categories")) {
        _HYChartWindow::_SetMenuBar();
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_distro_window_menu) / sizeof (hyphy_distro_window_menu[0]), hyphy_distro_window_menu, this);

        if (distribProcessors.lLength > 0) {
            for (long k=0; k<distribProcessors.lLength; k++) {
                _String *thisItem = (_String*)distribProcessors (k),
                         chopped = thisItem->Cut (thisItem->FindBackwards ('/',0,-1)+1,-1),
                         type = "<Item>";

                GtkItemFactoryEntry aProcEntry = {NULL,NULL,(GtkItemFactoryCallback)hyphy_menu_item_callback,HY_CHARTD_WIN32_MENU_BASE+3+k,type.sData};
                chopped = _String("/Categories/")&chopped;
                aProcEntry.path = chopped.sData;

                gtk_item_factory_create_items (menu_items,  1, &aProcEntry, this);
            }
        }
    }
}
Example #15
0
/* This is just directly from the gtk menubar tutorial. */
static GtkWidget *get_menubar_menu(GtkWidget *window)
{
	GtkItemFactory *item_factory;
	GtkAccelGroup *accel_group;

	accel_group = gtk_accel_group_new();
	item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);

	gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL);
	gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
	return gtk_item_factory_get_widget(item_factory, "<main>");
}
Example #16
0
/* Same again but return an option menu */
GtkWidget *get_option_menu( void )
{
   GtkItemFactory *item_factory;
   GtkWidget *option_menu;
  
   /* Same again, not bothering with the accelerators */
   item_factory = gtk_item_factory_new (GTK_TYPE_OPTION_MENU, "<main>",
                                        NULL);
   gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
   option_menu = gtk_item_factory_get_widget (item_factory, "<main>");

   return option_menu;
}
Example #17
0
PRIVATE GtkWidget *build_popup(Control *c) {
  GtkItemFactory *ifact;
  GtkWidget *result;
  int nitems = sizeof(popup_items) / sizeof(popup_items[0]);

  ifact = gtk_item_factory_new(GTK_TYPE_MENU, "<seqnote-popup>", NULL);

  gtk_item_factory_create_items(ifact, nitems, popup_items, c);
  result = gtk_item_factory_get_widget(ifact, "<seqnote-popup>");

  gtk_signal_connect(GTK_OBJECT(result), "destroy", GTK_SIGNAL_FUNC(kill_popup), ifact);
  return result;
}
void _HYChartWindow::_SetMenuBar(void)
{
    if (menu_items && !gtk_item_factory_get_widget(menu_items,"<HY_WINDOW>/Chart")) {
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_char_window_menu) / sizeof (hyphy_char_window_menu[0]), hyphy_char_window_menu, this);

        GtkMenu *fileMenu = GTK_MENU(gtk_item_factory_get_widget(menu_items,"<HY_WINDOW>/File"));
        gtk_menu_reorder_child(fileMenu,gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_FILE+3),1);
        gtk_menu_reorder_child(fileMenu,gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_FILE+4),2);
        gtk_menu_reorder_child(fileMenu,gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_FILE+5),4);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT+1),true);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT+3),true);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT+5),true);

        /*InsertMenu    (saveMenu,  0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+1, "Save &Chart\tCtrl-S");
        InsertMenu      (saveMenu,  0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+3, "Save &Graphic");
        InsertMenu      (saveMenu,  0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+4, "Save &Table");

        InsertMenu      (printMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+2, "Print &Graphic\tCtrl-P");
        InsertMenu      (printMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+5, "Print &Data");*/



        for (long k=0; k<chartProcessors.lLength; k++) {
            _String *thisItem = (_String*)chartProcessors (k),
                     chopped = thisItem->Cut (thisItem->FindBackwards ('/',0,-1)+1,-1),
                     type = "<Item>";

            GtkItemFactoryEntry aProcEntry = {NULL,NULL,(GtkItemFactoryCallback)hyphy_menu_item_callback,HY_CHART_WIN32_MENU_BASE+5+k,type.sData};
            chopped = _String("/Chart/Data Processing/")&chopped;
            aProcEntry.path = chopped.sData;

            gtk_item_factory_create_items (menu_items,  1, &aProcEntry, this);
        }

        //ModifyMenu     (chartMenu, 0, MF_BYPOSITION|MF_POPUP, (UINT) saveMenu , "&Save");
        //ModifyMenu     (chartMenu, 1, MF_BYPOSITION|MF_POPUP, (UINT) printMenu , "&Print");

    }
}
Example #19
0
GtkWidget *popup_menu_new (void)
{
  GtkItemFactory *ItemFactory;
  GtkWidget *PopUpMenu;
  guint NbMenuEntries;

  NbMenuEntries = sizeof (PopUpMenuEntries) / sizeof (PopUpMenuEntries[0]);
  ItemFactory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup_main>", NULL);
  gtk_item_factory_create_items (ItemFactory, NbMenuEntries,
				 PopUpMenuEntries, NULL);
  PopUpMenu = gtk_item_factory_get_widget (ItemFactory, "<popup_main>");
  return (PopUpMenu);
}
Example #20
0
static void
dock_build ()
{
    GtkWidget *image;
    GtkWidget *eventbox;

    dock = egg_tray_icon_new ("Pornview");
    eventbox = gtk_event_box_new ();
    image = pixbuf_create_pixmap_from_xpm_data (dock_xpm);

    GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW);
    image->requisition.width = 22;
    image->requisition.height = 22;



    gtk_widget_set_events (GTK_WIDGET (eventbox),
			   gtk_widget_get_events (eventbox) |
			   GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);

    gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",
			GTK_SIGNAL_FUNC (cb_dock_clicked), NULL);

    gtk_widget_show (eventbox);

    /*
     * add the status to the plug 
     */
    gtk_object_set_data (GTK_OBJECT (dock), "pixmapg", image);
    gtk_container_add (GTK_CONTAINER (eventbox), image);
    gtk_container_add (GTK_CONTAINER (dock), eventbox);
    gtk_widget_show_all (GTK_WIDGET (dock));

    /*
     * add the popup menu 
     */
    popup_item_factory =
	gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);

#ifdef ENABLE_NLS
    gtk_item_factory_set_translate_func (popup_item_factory,
					 (GtkTranslateFunc) gettext, NULL,
					 NULL);
#endif

    gtk_item_factory_create_items (popup_item_factory,
				   dock_popupmenu_factory_count,
				   dock_popupmenu_factory, NULL);
    popup_menu = gtk_item_factory_get_widget (popup_item_factory, "<popup>");
}
Example #21
0
static int
create_menu_bar( GtkBox *parent, GtkAccelGroup *accel_group )
{
  GtkWidget *menu_bar;

  menu_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>",
				       accel_group );
  gtk_item_factory_create_items( menu_factory, menu_data_count, menu_data,
				 NULL);
  menu_bar = gtk_item_factory_get_widget( menu_factory, "<main>" );

  gtk_box_pack_start( parent, menu_bar, FALSE, FALSE, 0 );
  
  return 0;
}
GtkWidget *getMenubarMenu(GtkWidget *window){
	GtkAccelGroup	*accel_group;		//accelerator group widget

	//Make an accelerator group (shortcut keys)
	accel_group = gtk_accel_group_new();
	//Make an ItemFactory (that makes a menubar)
	item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
	//Generate the menu item
	gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL);
	//Attach the new accelerator group to the window
	gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

	//Return the actual menu bar created by item factory
	return gtk_item_factory_get_widget(item_factory, "<main>");
}
Example #23
0
void gtkui_create_tab_menu(void)
{
   GtkAccelGroup *accel_group;
   GtkWidget *context;
   GtkItemFactory *if_tabs;

   accel_group = gtk_accel_group_new ();
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);

   /* context menu for notebook */
   if_tabs = gtk_item_factory_new(GTK_TYPE_MENU, "<notebook>", accel_group);
   gtk_item_factory_create_items(if_tabs, 5, tab_menu, NULL);
   context = gtk_item_factory_get_widget(if_tabs, "<notebook>");

   g_signal_connect(G_OBJECT(notebook), "button-press-event", G_CALLBACK(gtkui_context_menu), context);
}
Example #24
0
GtkItemFactory *
planner_task_popup_new (PlannerTaskTree *tree)
{
	GtkItemFactory *item_factory;

	item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>", NULL);
	gtk_item_factory_set_translate_func (item_factory,
					     task_tree_item_factory_trans,
					     NULL, NULL);

	gtk_item_factory_create_items (item_factory,
				       G_N_ELEMENTS (popup_menu_items),
				       popup_menu_items, tree);

	return item_factory;
}
Example #25
0
/* Name is in the form "<panel>" */
GtkItemFactory*
menu_create(GtkItemFactoryEntry *def, int n_entries, const gchar *name, GtkAccelGroup *keys)
{
	if (!keys) {
		keys = gtk_accel_group_new();
		gtk_accel_group_lock(keys);
	}

	GtkItemFactory* item_factory = gtk_item_factory_new(GTK_TYPE_MENU, name, keys);

	GtkItemFactoryEntry* translated = def;//translate_entries(def, n_entries);
	gtk_item_factory_create_items(item_factory, n_entries, translated, NULL);
	//free_translated_entries(translated, n_entries);

	return item_factory;
}
Example #26
0
// Fonction de création du menu
void window_barre_menu()
{
  GtkItemFactory * pItemFactory = NULL;
  GtkAccelGroup * pAccel = NULL;
  gint nb_menu_item = sizeof(menu_item) / sizeof(menu_item[0]);

  if(ptr_window==NULL) return;
	
  pAccel = gtk_accel_group_new();
  pItemFactory = gtk_item_factory_new(GTK_TYPE_MENU_BAR,"<main>",pAccel);
  
  gtk_item_factory_create_items(pItemFactory,nb_menu_item, menu_item,(GtkWidget*) ptr_window->win);
  ptr_window->menu_bar = gtk_item_factory_get_widget(pItemFactory, "<main>");
  gtk_window_add_accel_group(GTK_WINDOW(ptr_window->win), pAccel);
  gtk_widget_show_all(ptr_window->menu_bar);
}
Example #27
0
/* ugly foreigner source from sample */
GtkWidget* MainWindow::get_menubar_menu(GtkWidget *window)
{
  GtkItemFactory *item_factory;
  GtkAccelGroup *accel_group;
  /* Создаём группу акселераторов (shortcut keys) */
  accel_group = gtk_accel_group_new ();
  /* Создаём ItemFactory (строку меню) */
  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
  /* Эта функция генерирует пункты меню. Передает item factory,
     номер пункта в массиве, массив непосредственно, а также любые
     данные обратных вызовов для пунктов меню. */
  gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
  /* Прикрепляем новую группу акселераторов к окну. */
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
  /* Возвращаем фактически созданную производством пунктов (item factory) панель меню. */
  return gtk_item_factory_get_widget (item_factory, "<main>");
}
Example #28
0
static 
void create_toplevel(GtkVi *vi)
{
	GtkWidget *window;
	GtkWidget *box, *menubar;
	GtkWidget *vi_window;
	gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
	GtkItemFactory *factory;
	GtkAccelGroup *accel;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	++n_toplevel;

	box = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window), box);
	gtk_widget_show(box);

	vi_window = gtk_vi_window_new(vi);

	accel = gtk_accel_group_new();
	factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel);
	gtk_item_factory_create_items (factory, nmenu_items, menu_items, (gpointer)vi_window);
	gtk_accel_group_attach(accel, GTK_OBJECT(window));
	menubar = gtk_item_factory_get_widget (factory, "<main>");
	gtk_widget_show(menubar);
	gtk_box_pack_start(GTK_BOX(box), menubar, FALSE, FALSE, 0);

	gtk_accel_group_attach(accel, GTK_OBJECT(vi_window));
	gtk_widget_show(vi_window);

	gtk_signal_connect(GTK_OBJECT(vi_window), "rename",
			   GTK_SIGNAL_FUNC(vi_rename),
			   window);
	gtk_signal_connect(GTK_OBJECT(GTK_VI_WINDOW(vi_window)->vi_screen), "destroy",
			   GTK_SIGNAL_FUNC(vi_destroyed),
			   window);
	gtk_box_pack_start(GTK_BOX(box), vi_window, TRUE, TRUE, 0);

	/*
	gtk_widget_grab_focus(GTK_WIDGET(vi->vi));
	*/

	gtk_widget_show(window);
}
Example #29
0
static GtkWidget *
create_menubar (GtkWindow *window)
{
  GtkItemFactory *item_factory;
  GtkAccelGroup *accel_group=NULL;
  GtkWidget *menubar;
  
  accel_group = gtk_accel_group_new ();
  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
                                       accel_group);
  gtk_item_factory_create_items (item_factory,
				 G_N_ELEMENTS (menu_items),
				 menu_items, NULL);
  
  gtk_window_add_accel_group (window, accel_group);
  menubar = gtk_item_factory_get_widget (item_factory, "<main>");

  return menubar;
}
Example #30
0
/* Same as with get_menubar_menu() but just return a button with a signal to
   call a popup menu */
GtkWidget *get_popup_menu( void )
{
   GtkItemFactory *item_factory;
   GtkWidget *button, *menu;
  
   /* Same as before but don't bother with the accelerators */
   item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>",
                                        NULL);
   gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
   menu = gtk_item_factory_get_widget (item_factory, "<main>");
  
   /* Make a button to activate the popup menu */
   button = gtk_button_new_with_label ("Popup");
   /* Make the menu popup when clicked */
   g_signal_connect (G_OBJECT(button),
                     "event",
                     G_CALLBACK(popup_cb),
                     (gpointer) menu);

   return button;
}