Exemplo n.º 1
0
GtkWidget *
menu_create_main (void *accel_group, int bar, int away, int toplevel,
						GtkWidget **menu_widgets)
{
	int i = 0;
	GtkWidget *item;
	GtkWidget *menu = 0;
	GtkWidget *menu_item = 0;
	GtkWidget *menu_bar;
	GtkWidget *usermenu = 0;
	GtkWidget *submenu = 0;
	int close_mask = GDK_CONTROL_MASK;
	int away_mask = GDK_MOD1_MASK;
	char *key_theme = NULL;
	GtkSettings *settings;
	GSList *group = NULL;

	if (bar)
		menu_bar = gtk_menu_bar_new ();
	else
		menu_bar = gtk_menu_new ();

	/* /MENU needs to know this later */
	g_object_set_data (G_OBJECT (menu_bar), "accel", accel_group);

#if GTK_CHECK_VERSION(2,4,0)
	g_signal_connect (G_OBJECT (menu_bar), "can-activate-accel",
							G_CALLBACK (menu_canacaccel), 0);
#endif

	/* set the initial state of toggles */
	mymenu[MENUBAR_OFFSET].state = !prefs.hidemenu;
	mymenu[MENUBAR_OFFSET+1].state = prefs.topicbar;
	mymenu[MENUBAR_OFFSET+2].state = !prefs.hideuserlist;
	mymenu[MENUBAR_OFFSET+3].state = prefs.userlistbuttons;
	mymenu[MENUBAR_OFFSET+4].state = prefs.chanmodebuttons;

	mymenu[METRE_OFFSET].state = 0;
	mymenu[METRE_OFFSET+1].state = 0;
	mymenu[METRE_OFFSET+2].state = 0;
	mymenu[METRE_OFFSET+3].state = 0;
	switch (prefs.lagometer)
	{
	case 0:
		mymenu[METRE_OFFSET].state = 1;
		break;
	case 1:
		mymenu[METRE_OFFSET+1].state = 1;
		break;
	case 2:
		mymenu[METRE_OFFSET+2].state = 1;
		break;
	default:
		mymenu[METRE_OFFSET+3].state = 1;
	}

	/* change Close binding to ctrl-shift-w when using emacs keys */
	settings = gtk_widget_get_settings (menu_bar);
	if (settings)
	{
		g_object_get (settings, "gtk-key-theme-name", &key_theme, NULL);
		if (key_theme)
		{
			if (!strcasecmp (key_theme, "Emacs"))
			{
				close_mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK;
				mymenu[SEARCH_OFFSET].key = 0;
			}
			g_free (key_theme);
		}
	}

	/* Away binding to ctrl-alt-a if the _Help menu conflicts (FR/PT/IT) */
	{
		char *help = _("_Help");
		char *under = strchr (help, '_');
		if (under && (under[1] == 'a' || under[1] == 'A'))
			away_mask = GDK_MOD1_MASK | GDK_CONTROL_MASK;
	}

	if (!toplevel)
	{
		mymenu[DETACH_OFFSET].text = N_("_Detach Tab");
		mymenu[CLOSE_OFFSET].text = N_("_Close Tab");
	}
	else
	{
		mymenu[DETACH_OFFSET].text = N_("_Attach Window");
		mymenu[CLOSE_OFFSET].text = N_("_Close Window");
	}

	while (1)
	{
		item = NULL;
		if (mymenu[i].id == MENU_ID_USERMENU && !prefs.gui_usermenu)
		{
			i++;
			continue;
		}

		switch (mymenu[i].type)
		{
		case M_NEWMENU:
			if (menu)
				gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
			item = menu = gtk_menu_new ();
			if (mymenu[i].id == MENU_ID_USERMENU)
				usermenu = menu;
			menu_item = gtk_menu_item_new_with_mnemonic (_(mymenu[i].text));
			/* record the English name for /menu */
			g_object_set_data (G_OBJECT (menu_item), "name", mymenu[i].text);
			gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_item);
			gtk_widget_show (menu_item);
			break;

		case M_MENUPIX:
			item = create_icon_menu (_(mymenu[i].text), mymenu[i].image, FALSE);
			goto normalitem;

		case M_MENUSTOCK:
			item = create_icon_menu (_(mymenu[i].text), mymenu[i].image, TRUE);
			goto normalitem;

		case M_MENUITEM:
			item = gtk_menu_item_new_with_mnemonic (_(mymenu[i].text));
normalitem:
			if (mymenu[i].key != 0)
				gtk_widget_add_accelerator (item, "activate", accel_group,
										mymenu[i].key,
										mymenu[i].key == GDK_F1 ? 0 :
										mymenu[i].key == GDK_w ? close_mask :
										GDK_CONTROL_MASK,
										GTK_ACCEL_VISIBLE);
			if (mymenu[i].callback)
				g_signal_connect (G_OBJECT (item), "activate",
										G_CALLBACK (mymenu[i].callback), 0);
			if (submenu)
				gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
			else
				gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
			gtk_widget_show (item);
			break;

		case M_MENUTOG:
			item = gtk_check_menu_item_new_with_mnemonic (_(mymenu[i].text));
togitem:
			/* must avoid callback for Radio buttons */
			GTK_CHECK_MENU_ITEM (item)->active = mymenu[i].state;
			/*gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
													 mymenu[i].state);*/
			if (mymenu[i].key != 0)
				gtk_widget_add_accelerator (item, "activate", accel_group,
									mymenu[i].key, mymenu[i].id == MENU_ID_AWAY ?
									away_mask : GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
			if (mymenu[i].callback)
				g_signal_connect (G_OBJECT (item), "toggled",
										G_CALLBACK (mymenu[i].callback), 0);
			if (submenu)
				gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
			else
				gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
			gtk_widget_show (item);
			gtk_widget_set_sensitive (item, mymenu[i].sensitive);
			break;

		case M_MENURADIO:
			item = gtk_radio_menu_item_new_with_mnemonic (group, _(mymenu[i].text));
			group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
			goto togitem;

		case M_SEP:
			item = gtk_menu_item_new ();
			gtk_widget_set_sensitive (item, FALSE);
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
			gtk_widget_show (item);
			break;

		case M_MENUSUB:
			group = NULL;
			submenu = gtk_menu_new ();
			item = create_icon_menu (_(mymenu[i].text), mymenu[i].image, TRUE);
			/* record the English name for /menu */
			g_object_set_data (G_OBJECT (item), "name", mymenu[i].text);
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
			gtk_widget_show (item);
			break;

		/*case M_END:*/ default:
			if (!submenu)
			{
				if (menu)
				{
					gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
					menu_add_plugin_mainmenu_items (menu_bar);
				}
				if (usermenu)
					usermenu_create (usermenu);
				return (menu_bar);
			}
			submenu = NULL;
		}

		/* record this GtkWidget * so it's state might be changed later */
		if (mymenu[i].id != 0 && menu_widgets)
			/* this ends up in sess->gui->menu_item[MENU_ID_XXX] */
			menu_widgets[mymenu[i].id] = item;

		i++;
	}
}
GtkWidget *trg_tree_view_sort_menu(TrgTreeView * tv, const gchar * label)
{
    TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
    GtkWidget *item = gtk_menu_item_new_with_mnemonic(label);
    GtkTreeModel *treeViewModel =
        gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
    GtkTreeSortable *sortableModel =
        GTK_TREE_SORTABLE(gtk_tree_model_filter_get_model
                          (GTK_TREE_MODEL_FILTER(treeViewModel)));
    GtkWidget *menu = gtk_menu_new();
    GtkWidget *b;
    GList *li;
    gint sort;
    GtkSortType sortType;
    GSList *group = NULL;

    gtk_tree_sortable_get_sort_column_id(sortableModel, &sort, &sortType);

    b = gtk_radio_menu_item_new_with_label(group, _("Ascending"));
    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(b),
                                   sortType == GTK_SORT_ASCENDING);
    g_object_set_data(G_OBJECT(b), "sort-type",
                      GINT_TO_POINTER(GTK_SORT_ASCENDING));
    g_signal_connect(b, "toggled",
                     G_CALLBACK(trg_tree_view_sort_menu_type_toggled),
                     sortableModel);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), b);
    group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(b));
    b = gtk_radio_menu_item_new_with_label(group, _("Descending"));
    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(b),
                                   sortType == GTK_SORT_DESCENDING);
    g_object_set_data(G_OBJECT(b), "sort-type",
                      GINT_TO_POINTER(GTK_SORT_DESCENDING));
    g_signal_connect(b, "toggled",
                     G_CALLBACK(trg_tree_view_sort_menu_type_toggled),
                     sortableModel);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), b);

    group = NULL;

    gtk_menu_shell_append(GTK_MENU_SHELL(menu),
                          gtk_separator_menu_item_new());

    for (li = priv->columns; li; li = g_list_next(li)) {
        trg_column_description *desc = (trg_column_description *) li->data;
        if (!(desc->flags & TRG_COLUMN_HIDE_FROM_TOP_MENU)) {
            b = gtk_radio_menu_item_new_with_label(group, desc->header);
            group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(b));

            if (desc->model_column == sort)
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(b),
                                               TRUE);

            g_object_set_data(G_OBJECT(b), GDATA_KEY_COLUMN_DESC, desc);
            g_signal_connect(b, "toggled",
                             G_CALLBACK
                             (trg_tree_view_sort_menu_item_toggled),
                             sortableModel);

            gtk_menu_shell_append(GTK_MENU_SHELL(menu), b);
        }
    }

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);

    return item;
}
Exemplo n.º 3
0
GtkRadioMenuItem* cast_GtkRadioMenuItem(GtkWidget* widget) {
    return GTK_RADIO_MENU_ITEM(widget);
}
Exemplo n.º 4
0
static void gui_get_objects(GtkBuilder *builder)
{
	// Window
	gui.window = GTK_WINDOW(gui_get_object(builder,
		"window"));

	// Menus
	gui.menuitem_file = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_file"));
	gui.menuitem_save_as = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_save_as"));
	gui.menuitem_quit = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_quit"));
	gui.menuitem_edit = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_edit"));
	gui.menuitem_cut = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_cut"));
	gui.menuitem_copy = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_copy"));
	gui.menuitem_paste = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_paste"));
	gui.menuitem_delete = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_delete"));
	gui.menuitem_select_all = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_select_all"));
	gui.menuitem_prefs = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_prefs"));
	gui.menuitem_about = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_about"));
	gui.radiomenuitem_file = GTK_RADIO_MENU_ITEM(gui_get_object(builder,
		"radiomenuitem_file"));
	gui.radiomenuitem_text = GTK_RADIO_MENU_ITEM(gui_get_object(builder,
		"radiomenuitem_text"));
	gui.radiomenuitem_file_list = GTK_RADIO_MENU_ITEM(gui_get_object(builder,
		"radiomenuitem_file_list"));

	// Toolbar
	gui.toolbar = GTK_TOOLBAR(gui_get_object(builder,
		"toolbar"));
	gui.toolbutton_add = GTK_TOOL_BUTTON(gui_get_object(builder,
		"toolbutton_add"));
	gui.toolbutton_remove = GTK_TOOL_BUTTON(gui_get_object(builder,
		"toolbutton_remove"));
	gui.toolbutton_clear = GTK_TOOL_BUTTON(gui_get_object(builder,
		"toolbutton_clear"));

	// Containers
	gui.vbox_single = GTK_VBOX(gui_get_object(builder,
		"vbox_single"));
	gui.vbox_list = GTK_VBOX(gui_get_object(builder,
		"vbox_list"));
	gui.hbox_input = GTK_HBOX(gui_get_object(builder,
		"hbox_input"));
	gui.hbox_output = GTK_HBOX(gui_get_object(builder,
		"hbox_output"));
	gui.vbox_outputlabels = GTK_VBOX(gui_get_object(builder,
		"vbox_outputlabels"));
	gui.vbox_digests_file = GTK_VBOX(gui_get_object(builder,
		"vbox_digests_file"));
	gui.vbox_digests_text = GTK_VBOX(gui_get_object(builder,
		"vbox_digests_text"));

	// Inputs
	gui.entry = GTK_ENTRY(gui_get_object(builder,
		"entry"));
	gui.filechooserbutton = GTK_FILE_CHOOSER_BUTTON(gui_get_object(builder,
		"filechooserbutton"));

	// Labels
	gui.label_text = GTK_LABEL(gui_get_object(builder,
		"label_text"));
	gui.label_file = GTK_LABEL(gui_get_object(builder,
		"label_file"));

	// Tree View
	gui.treeview = GTK_TREE_VIEW(gui_get_object(builder,
		"treeview"));
	gui.treeselection = GTK_TREE_SELECTION(gui_get_object(builder,
		"treeselection"));
	gui.menu_treeview = GTK_MENU(gui_get_object(builder,
		"menu_treeview"));
	gui.menuitem_treeview_add = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_treeview_add"));
	gui.menuitem_treeview_remove = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_treeview_remove"));
	gui.menuitem_treeview_clear = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_treeview_clear"));
	gui.menu_treeview_copy = GTK_MENU(gui_get_object(builder,
		"menu_treeview_copy"));
	gui.menuitem_treeview_copy = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_treeview_copy"));
	gui.menuitem_treeview_show_toolbar = GTK_MENU_ITEM(gui_get_object(builder,
		"menuitem_treeview_show_toolbar"));

	// Buttons
	gui.hseparator_buttons = GTK_HSEPARATOR(gui_get_object(builder,
		"hseparator_buttons"));
	gui.button_hash = GTK_BUTTON(gui_get_object(builder,
		"button_hash"));
	gui.button_stop = GTK_BUTTON(gui_get_object(builder,
		"button_stop"));

	// Progress Bar
	gui.progressbar = GTK_PROGRESS_BAR(gui_get_object(builder,
		"progressbar"));

	// Dialog
	gui.dialog = GTK_DIALOG(gui_get_object(builder,
		"dialog"));
	gui.dialog_table = GTK_TABLE(gui_get_object(builder,
		"dialog_table"));
	gui.dialog_combobox = GTK_COMBO_BOX(gui_get_object(builder,
		"dialog_combobox"));
	gui.dialog_button_close = GTK_BUTTON(gui_get_object(builder,
		"dialog_button_close"));
}
Exemplo n.º 5
0
static void
gtk_radio_menu_item_activate (GtkMenuItem *menu_item)
{
  GtkRadioMenuItem *radio_menu_item = GTK_RADIO_MENU_ITEM (menu_item);
  GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item);
  GtkCheckMenuItem *tmp_menu_item;
  GtkAction        *action;
  GSList *tmp_list;
  gint toggled;

  action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (menu_item));
  if (action && gtk_menu_item_get_submenu (menu_item) == NULL)
    gtk_action_activate (action);

  toggled = FALSE;

  if (check_menu_item->active)
    {
      tmp_menu_item = NULL;
      tmp_list = radio_menu_item->group;

      while (tmp_list)
	{
	  tmp_menu_item = tmp_list->data;
	  tmp_list = tmp_list->next;

	  if (tmp_menu_item->active && (tmp_menu_item != check_menu_item))
	    break;

	  tmp_menu_item = NULL;
	}

      if (tmp_menu_item)
	{
	  toggled = TRUE;
	  check_menu_item->active = !check_menu_item->active;
	}
    }
  else
    {
      toggled = TRUE;
      check_menu_item->active = !check_menu_item->active;

      tmp_list = radio_menu_item->group;
      while (tmp_list)
	{
	  tmp_menu_item = tmp_list->data;
	  tmp_list = tmp_list->next;

	  if (tmp_menu_item->active && (tmp_menu_item != check_menu_item))
	    {
	      gtk_menu_item_activate (GTK_MENU_ITEM (tmp_menu_item));
	      break;
	    }
	}
    }

  if (toggled)
    {
      gtk_check_menu_item_toggled (check_menu_item);
    }

  gtk_widget_queue_draw (GTK_WIDGET (radio_menu_item));
}
Exemplo n.º 6
0
RtTraceGtk::RtTraceGtk( void *tr_parent_ctx, GtkWidget *tr_parent_wid, pwr_tObjid tr_objid,
			pwr_tStatus *status) :
  RtTrace( tr_parent_ctx, tr_objid, status), parent_wid(tr_parent_wid), toplevel(0), nav_shell(0)
{

  const int	window_width = 900;
  const int    	window_height = 800;
  const int    	nav_width = 180;
  pwr_tStatus 	sts;
  pwr_tObjid	window_objid;
  pwr_tClassId	cid;
  char   	title[220];
  pwr_tOName   	hostname;
  pwr_tOName   	plcconnect;
  pwr_tFileName fname;

  sts = gdh_ObjidToName( tr_objid, name, sizeof(name), cdh_mNName); 
  if (EVEN(sts)) {
    *status = sts;
    return;
  }
  strcpy( title, "Trace ");
  strcat( title, name);

  /* Find plcwindow */
  sts = gdh_GetObjectClass( tr_objid, &cid);
  if ( EVEN(sts)) {
    *status = sts;
    return;
  }

  if ( !(cid == pwr_cClass_windowplc ||
         cid == pwr_cClass_windowcond ||
         cid == pwr_cClass_windoworderact ||
         cid == pwr_cClass_windowsubstep )) {
    sts = gdh_GetChild( tr_objid, &window_objid);
    if ( EVEN(sts)) {
      *status = sts;
      return;
    }
  }
  else
    window_objid = tr_objid; 

  sts = gdh_GetObjectClass( window_objid, &cid);
  if ( EVEN(sts)) {
    *status = sts;
    return;
  }

  if ( !(cid == pwr_cClass_windowplc ||
         cid == pwr_cClass_windowcond ||
         cid == pwr_cClass_windoworderact ||
         cid == pwr_cClass_windowsubstep )) {
    *status = 0;
    return;
  }

  sts = get_filename( window_objid, filename, &m_has_host, hostname, 
		      plcconnect);
  if ( EVEN(sts)) {
    *status = sts;
    return;
  }

  /* Create object context */
  objid = window_objid;
  if ( m_has_host) {
    strcpy( m_hostname, hostname);
    strcpy( m_plcconnect, plcconnect);
  }

  char *titleutf8 = g_convert( title, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);

  // Gtk
  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					 "default-height", window_height,
					 "default-width", window_width,
					 "title", titleutf8,
					 NULL);
  g_free( titleutf8);

  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
  // Submenu Print
  GtkWidget *file_print = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Print"));
  g_signal_connect( file_print, "activate", 
		    G_CALLBACK(activate_print), this);

  GtkWidget *file_print_select = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Print _Selected Documents"));
  g_signal_connect( file_print_select, "activate", 
		    G_CALLBACK(activate_printselect), this);

  GtkWidget *file_savetrace = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Save _Trace"));
  g_signal_connect( file_savetrace, "activate", 
		    G_CALLBACK(activate_savetrace), this);

  GtkWidget *file_restoretrace = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Restore Trace"));
  g_signal_connect( file_restoretrace, "activate", 
		    G_CALLBACK(activate_restoretrace), this);

  GtkWidget *file_cleartrace = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("C_lear Trace"));
  g_signal_connect( file_cleartrace, "activate", 
		    G_CALLBACK(activate_cleartrace), 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_print_select);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_savetrace);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_restoretrace);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_cleartrace);
  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));

  // Functions Entry
  GtkWidget *functions_open_object = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Open Object"));
  g_signal_connect( functions_open_object, "activate", 
		    G_CALLBACK(activate_open_object), this);
  gtk_widget_add_accelerator( functions_open_object, "activate", accel_g,
  			      'a', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_open_subwindow = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Open S_ubwindow"));
  g_signal_connect( functions_open_subwindow, "activate", 
		    G_CALLBACK(activate_open_subwindow), this);
  gtk_widget_add_accelerator( functions_open_subwindow, "activate", accel_g,
  			      'l', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Display object in Navigator"));
  g_signal_connect( functions_display_object, "activate", 
		    G_CALLBACK(activate_display_object), this);
  gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
  			      'd', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_show_cross = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Show Crossreferences"));
  g_signal_connect( functions_show_cross, "activate", 
		    G_CALLBACK(activate_show_cross), this);
  gtk_widget_add_accelerator( functions_show_cross, "activate", accel_g,
  			      'r', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_open_classgraph = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Open ObjectGraph"));
  g_signal_connect( functions_open_classgraph, "activate", 
		    G_CALLBACK(activate_open_classgraph), this);
  gtk_widget_add_accelerator( functions_open_classgraph, "activate", accel_g,
  			      'g', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_collect_insert = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Collect Insert"));
  g_signal_connect( functions_collect_insert, "activate", 
		    G_CALLBACK(activate_collect_insert), this);
  gtk_widget_add_accelerator( functions_collect_insert, "activate", accel_g,
  			      'v', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_open_object);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_open_subwindow);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_display_object);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_show_cross);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_open_classgraph);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_collect_insert);

  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 Entry

  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(activate_zoomin), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
  			      'i', GdkModifierType(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(activate_zoomout), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
  			      'o', GdkModifierType(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(activate_zoomreset), this);
  gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
  			      'b', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  // Submenu ScanTime
  GSList *view_sc_group = NULL;
  GtkWidget *view_scantime1 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.50 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime1, "activate", 
		    G_CALLBACK(activate_scantime1), this);

  GtkWidget *view_scantime2 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.20 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime2, "activate", 
		    G_CALLBACK(activate_scantime2), this);

  GtkWidget *view_scantime3 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.10 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime3, "activate", 
		    G_CALLBACK(activate_scantime3), this);

  GtkWidget *view_scantime4 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.05 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime4, "activate", 
		    G_CALLBACK(activate_scantime4), this);

  GtkWidget *view_scantime5 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.02 s");
  g_signal_connect( view_scantime5, "activate", 
		    G_CALLBACK(activate_scantime5), this);

  GtkWidget *view_sc = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_ScanTime"));
  GtkMenu *view_sc_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime1);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime2);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime3);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime4);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime5);

  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_sc),
			    GTK_WIDGET(view_sc_menu));

  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_sc);

  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));

  // Mode entry
  GSList *mode_group = NULL;
  GtkWidget *mode_view = gtk_radio_menu_item_new_with_mnemonic( mode_group, CoWowGtk::translate_utf8("V_iew"));
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(mode_view));
  g_signal_connect( mode_view, "activate", 
		    G_CALLBACK(activate_view), this);

  GtkWidget *mode_trace = gtk_radio_menu_item_new_with_mnemonic( mode_group, CoWowGtk::translate_utf8("_Trace"));
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(mode_trace));
  g_signal_connect( mode_trace, "activate", 
		    G_CALLBACK(activate_trace), this);

  GtkWidget *mode_simulate = gtk_radio_menu_item_new_with_mnemonic( mode_group, CoWowGtk::translate_utf8("_Simulate"));
  gtk_widget_add_accelerator( mode_simulate, "activate", accel_g,
  			      's', GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK), 
  			      GTK_ACCEL_VISIBLE);
  g_signal_connect( mode_simulate, "activate", 
		    G_CALLBACK(activate_simulate), this);

  GtkMenu *mode_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(mode_menu), mode_view);
  gtk_menu_shell_append(GTK_MENU_SHELL(mode_menu), mode_trace);
  gtk_menu_shell_append(GTK_MENU_SHELL(mode_menu), mode_simulate);

  GtkWidget *mode = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Mode"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), mode);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(mode), GTK_WIDGET(mode_menu));

  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("On _Trace"));
  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);

  GtkWidget *help_plcpgm = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("On _PlcPgm"));
  g_signal_connect( help_plcpgm, "activate", 
		    G_CALLBACK(activate_helpplc), this);

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

  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_display_object = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_navigator.png");
  gtk_container_add( GTK_CONTAINER(tools_display_object), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_display_object, "clicked", G_CALLBACK(activate_display_object), this);
  gtk_toolbar_append_widget( tools, tools_display_object, "Display object in Navigator", "");
  
  GtkWidget *tools_show_cross = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_crossref.png");
  gtk_container_add( GTK_CONTAINER(tools_show_cross), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_show_cross, "clicked", G_CALLBACK(activate_show_cross), this);
  gtk_toolbar_append_widget( tools, tools_show_cross, "Show Crossreferences", "");
  
  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_zoomin), this);
  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(activate_zoomout), this);
  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(activate_zoomreset), this);
  gtk_toolbar_append_widget( tools, tools_zoom_reset, "Zoom reset", "");

  // Flow widget
  GtkWidget *flow_scrolled = scrolledflowwidgetgtk_new( init_flow, 
							this, &flow_widget);
  gtk_widget_show_all(flow_widget);

  nav_widget = flownavwidgetgtk_new( flow_widget);

  GtkWidget *paned = gtk_hpaned_new();
  gtk_paned_pack1( GTK_PANED(paned), flow_scrolled, TRUE, TRUE);
  gtk_paned_pack2( GTK_PANED(paned), nav_widget, FALSE, TRUE);

  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), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(paned), TRUE, TRUE, 0);

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

  gtk_paned_set_position( GTK_PANED(paned), window_width - nav_width);

#if 0
  // Navigator window
  nav_shell = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					  "default-height", 200,
					  "default-width", 200,
					  "title", "Navigator",
					  NULL);
  g_signal_connect( nav_shell, "delete_event", G_CALLBACK(nav_delete_event), this);

  nav_widget = flownavwidgetgtk_new( flow_widget);
  gtk_container_add( GTK_CONTAINER(nav_shell), nav_widget);
  gtk_widget_show_all( nav_shell);
#endif

  wow = new CoWowGtk( toplevel);
  trace_timerid = wow->timer_new();

  viewsetup();
  flow_Open( flow_ctx, filename);

  gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( mode_trace), TRUE);
  gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( view_scantime1), TRUE);

  //trasetup();
  //trace_start();

#if defined OS_LINUX
  {
    struct stat info;

    if ( stat( filename, &info) != -1)
      version = info.st_ctime;    
  }
#endif

  // Check version
  unsigned int flow_version;
  pwr_tUInt32 window_version;
  pwr_tAName aname;

  flow_GetCtxUserVersion( flow_ctx, &flow_version);

  strcpy( aname, name);
  strcat( aname, ".Version");

  sts = gdh_GetObjectInfo( aname, &window_version, sizeof(window_version));
  if ( EVEN(sts)) return;

  if ( flow_version > window_version)
    wow->DisplayError( "Version mismatch", "Trace file is newer than database version");
  else if ( flow_version < window_version)
    wow->DisplayError( "Version mismatch", "Trace file is older than database version");
}
Exemplo n.º 7
0
static gboolean
tm_popup_context_menu_cb(GtkWidget    * toolbar,
                         gint           x,
                         gint           y,
                         gint           button,
                         toolbar_info * info)
{
    GtkWidget *menu;
#if !GTK_CHECK_VERSION(3, 22, 0)
    int event_time;
#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
    guint i;
    GSList *group = NULL;
    GtkToolbarStyle default_style;
    GdkEvent *event;

    if (info->menu != NULL)
        return FALSE;

    info->menu = menu = gtk_menu_new();
    g_signal_connect(menu, "deactivate",
                     G_CALLBACK(tm_popup_deactivated_cb), info);

    /* ... add menu items ... */
    for (i = 0; i < G_N_ELEMENTS(tm_toolbar_options); i++) {
        GtkWidget *item;

        if (!tm_toolbar_options[i].text)
            continue;

        item =
            gtk_radio_menu_item_new_with_mnemonic(group,
                                                  _(tm_toolbar_options[i].
                                                    text));
        group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));

        if (tm_toolbar_options[i].style == info->model->style)
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
                                           TRUE);

        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        g_object_set_data(G_OBJECT(item), BALSA_TOOLBAR_STYLE,
                          GINT_TO_POINTER(tm_toolbar_options[i].style));
        g_signal_connect(item, "toggled", G_CALLBACK(menu_item_toggled_cb),
                         info);
    }

    default_style = tm_default_style();

    for (i = 0; i < G_N_ELEMENTS(tm_toolbar_options); i++) {

        if (!tm_toolbar_options[i].text)
            continue;

        if (tm_toolbar_options[i].style == default_style) {
            gchar *option_text, *text;
            GtkWidget *item;

            gtk_menu_shell_append(GTK_MENU_SHELL(menu),
                                  gtk_separator_menu_item_new());

            option_text =
                tm_remove_underscore(_(tm_toolbar_options[i].text));
            text =
                g_strdup_printf(_("Use Desktop _Default (%s)"),
                                option_text);
            g_free(option_text);

            item = gtk_radio_menu_item_new_with_mnemonic(group, text);
            g_free(text);

            if (info->model->style == (GtkToolbarStyle) (-1))
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
                                               (item), TRUE);
            gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
            g_object_set_data(G_OBJECT(item), BALSA_TOOLBAR_STYLE,
                              GINT_TO_POINTER(-1));
            g_signal_connect(item, "toggled",
                             G_CALLBACK(menu_item_toggled_cb), info);
        }
    }

    if (gtk_widget_is_sensitive(toolbar)) {
        /* This is a real toolbar, not the template from the
         * toolbar-prefs dialog. */
        GtkWidget *item;

        gtk_menu_shell_append(GTK_MENU_SHELL(menu),
                              gtk_separator_menu_item_new());
        item =
            gtk_menu_item_new_with_mnemonic(_("_Customize Toolbars…"));
        g_signal_connect(item, "activate", G_CALLBACK(customize_dialog_cb),
                         gtk_widget_get_toplevel(toolbar));
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

        /* Pass the model type to the customize widget, so that it can
         * show the appropriate notebook page. */
        g_object_set_data(G_OBJECT(item), BALSA_TOOLBAR_MODEL_TYPE,
                          GINT_TO_POINTER(info->model->type));
    }

    gtk_widget_show_all(menu);
    gtk_menu_attach_to_widget(GTK_MENU(menu), toolbar, NULL);

    event = gtk_get_current_event();
#if GTK_CHECK_VERSION(3, 22, 0)
    if (event != NULL && event->type == GDK_BUTTON_PRESS) {
        gtk_menu_popup_at_pointer(GTK_MENU(menu), event);
    } else {
        gtk_menu_popup_at_widget(GTK_MENU(menu),
                                 GTK_WIDGET(toolbar),
                                 GDK_GRAVITY_NORTH,
                                 GDK_GRAVITY_SOUTH,
                                 NULL);
    }
#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
    event_time = gtk_get_current_event_time();

    if (button >= 0)
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button,
                       event_time);
    else
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, tm_popup_position_func,
                       toolbar, button, event_time);
#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */

    if (event != NULL)
        gdk_event_free(event);

    return TRUE;
}
Exemplo n.º 8
0
void dev_select_rescan(GtkAction *action, GtkWindow *parent)
{
	GtkComboBox *dev = g_object_get_data(G_OBJECT(parent), "devcombo");
	g_return_if_fail(dev != NULL);
	GtkListStore *devlist = GTK_LIST_STORE(gtk_combo_box_get_model(dev));
	GtkTreeIter iter;
	struct sr_device *device;
	struct sr_device_instance *sdi;
	gchar *sdevname = NULL;
	GSList *devices, *l;
	GtkUIManager *ui = g_object_get_data(G_OBJECT(parent), "ui_manager");
	GtkWidget *menuitem = gtk_ui_manager_get_widget(ui,
					"/menubar/DevMenu/DevSelectMenu");
	GtkMenuShell *devmenu = GTK_MENU_SHELL(gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem)));
	GSList *radiolist = NULL;

	(void)action;

	/* Make a copy of the selected device's short name for comparison.
	 * We wish to select the same device after the refresh if possible.
	 */
	if (gtk_combo_box_get_active_iter(dev, &iter)) {
		gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 1, &device, -1);
		/* FIXME: Use something other than device->plugin->name */
		sdevname = g_strdup(device->plugin->name);
	}

	/* Destroy the old menu items */
	if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter)) do {
		GtkMenuItem *item;
		gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 2, &item, -1);
		gtk_object_destroy(GTK_OBJECT(item));
	} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter));

	gtk_list_store_clear(devlist);

	/* Scan for new devices and update our list */
	/* TODO: Fix this in libsigrok first. */
	/*sr_device_scan();*/
	devices = sr_device_list();
	for (l = devices; l; l = l->next) {
		device = l->data;
		sdi = GET_DEVICE_INSTANCE(device);
		gchar *name = sdi->model ? sdi->model : sdi->vendor;
		if (!name)
			name = "(unknown)";

		menuitem = gtk_radio_menu_item_new_with_label(radiolist, name);
		gtk_widget_show(GTK_WIDGET(menuitem));
		if (!radiolist)
			radiolist = gtk_radio_menu_item_get_group(
					GTK_RADIO_MENU_ITEM(menuitem));
		g_signal_connect(menuitem, "toggled",
				G_CALLBACK(dev_menuitem_toggled), dev);
		gtk_menu_shell_prepend(devmenu, menuitem);

		gtk_list_store_append(devlist, &iter);
		gtk_list_store_set(devlist, &iter,
				0, name,
				1, device,
				2, menuitem,
				-1);

		if (sdevname && g_str_equal(sdevname, device->plugin->name))
			gtk_combo_box_set_active_iter(dev, &iter);
	}
	if (sdevname)
		g_free(sdevname);

	/* Select a default if nothing selected */
	if (!gtk_combo_box_get_active_iter(dev, &iter)) {
		if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter))
			return;
		/* Skip demo if there's another available */
		GtkTreeIter first = iter;
		if (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter))
			gtk_combo_box_set_active_iter(dev, &iter);
		else
			gtk_combo_box_set_active_iter(dev, &first);
	}
}
Exemplo n.º 9
0
static VALUE
rmitem_get_group(VALUE self)
{
    /* Owened by GTK+ */
    return GSLIST2ARY(gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(RVAL2GOBJ(self))));
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
void
xslt_dialog_create(void) {
	GtkWidget *box, *vbox;
	
	GtkWidget *omenu, *menu, *menuitem;
	GSList *group;
	GtkWidget *label;	

	fromxsl_t *cur_f = froms;
	toxsl_t *cur_to = NULL;

	g_return_if_fail(froms != NULL);

	dialog = gtk_dialog_new_with_buttons(
             _("Export through XSLT"),
             NULL, 0,
             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
             GTK_STOCK_OK, GTK_RESPONSE_OK,
             NULL);
	
	gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);

  
	box = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  
	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
	gtk_container_set_border_width (GTK_CONTAINER (box), 10);

	label = gtk_label_new(_("From:"));

 	omenu = gtk_option_menu_new ();
	menu = gtk_menu_new ();
	group = NULL;
	
	while(cur_f != NULL)
	{
		menuitem = gtk_radio_menu_item_new_with_label (group, cur_f->name);
		g_signal_connect (G_OBJECT (menuitem), "activate",
				  G_CALLBACK (from_activate), cur_f);
		group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
		gtk_menu_append (GTK_MENU (menu), menuitem);
		gtk_widget_show (menuitem);
		cur_f = cur_f->next;
	}
	

	gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
	gtk_widget_show(menu);
	gtk_widget_show(omenu);
	gtk_widget_show(label);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), omenu, FALSE, TRUE, 0);
	
	gtk_widget_show_all(vbox);

	gtk_box_pack_start (GTK_BOX (box), vbox, FALSE, TRUE, 0);
	
	cur_f = froms;

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
	gtk_container_set_border_width (GTK_CONTAINER (box), 10);

	label = gtk_label_new(_("To:"));

 	omenu = gtk_option_menu_new ();
	menu = gtk_menu_new ();
	group = NULL;
	
	while(cur_f != NULL)
	{
		cur_to = cur_f->xsls;
		while(cur_to != NULL)
		{
			menuitem = gtk_radio_menu_item_new_with_label (group, cur_to->name);
			g_signal_connect (G_OBJECT (menuitem), "activate",
					  G_CALLBACK (to_update), cur_to );
			group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
			gtk_menu_append (GTK_MENU (menu), menuitem);
			gtk_widget_show (menuitem);
			cur_to->item = menuitem;
			cur_to = cur_to->next;
		}
		cur_f = cur_f->next;		
	}

	gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
	gtk_widget_show(menu);
	gtk_widget_show(omenu);
	gtk_widget_show(label);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), omenu, FALSE, TRUE, 0);
	
	gtk_widget_show_all(vbox);

	gtk_box_pack_start (GTK_BOX (box), vbox, FALSE, TRUE, 0);
	
	gtk_widget_show_all(box);

	g_signal_connect(G_OBJECT(dialog), "response",
                   G_CALLBACK(xslt_dialog_respond),
                   NULL);
	g_signal_connect(G_OBJECT(dialog), "delete_event",
                   G_CALLBACK(gtk_widget_hide), NULL);


	gtk_widget_show(dialog);	

	cur_f = froms->next;
	while(cur_f != NULL)
	{
		from_deactivate(cur_f);
		cur_f = cur_f->next;
	}

}
Exemplo n.º 12
0
static void
gtk_radio_menu_item_activate (GtkMenuItem *menu_item)
{
  GtkRadioMenuItem *radio_menu_item = GTK_RADIO_MENU_ITEM (menu_item);
  GtkRadioMenuItemPrivate *priv = radio_menu_item->priv;
  GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item);
  GtkCheckMenuItem *tmp_menu_item;
  GtkAction        *action;
  GSList *tmp_list;
  gboolean active;
  gint toggled;

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

  action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (menu_item));
  if (action && gtk_menu_item_get_submenu (menu_item) == NULL)
    gtk_action_activate (action);

  G_GNUC_END_IGNORE_DEPRECATIONS;

  toggled = FALSE;

  active = gtk_check_menu_item_get_active (check_menu_item);
  if (active)
    {
      tmp_menu_item = NULL;
      tmp_list = priv->group;

      while (tmp_list)
	{
	  tmp_menu_item = tmp_list->data;
	  tmp_list = tmp_list->next;

          if (gtk_check_menu_item_get_active (tmp_menu_item) &&
              tmp_menu_item != check_menu_item)
	    break;

	  tmp_menu_item = NULL;
	}

      if (tmp_menu_item)
	{
	  toggled = TRUE;
          _gtk_check_menu_item_set_active (check_menu_item, !active);
	}
    }
  else
    {
      toggled = TRUE;
      _gtk_check_menu_item_set_active (check_menu_item, !active);

      tmp_list = priv->group;
      while (tmp_list)
	{
	  tmp_menu_item = tmp_list->data;
	  tmp_list = tmp_list->next;

          if (gtk_check_menu_item_get_active (tmp_menu_item) &&
              tmp_menu_item != check_menu_item)
	    {
              gtk_menu_item_activate (GTK_MENU_ITEM (tmp_menu_item));
	      break;
	    }
	}
    }

  if (toggled)
    {
      gtk_check_menu_item_toggled (check_menu_item);
    }

  gtk_widget_queue_draw (GTK_WIDGET (radio_menu_item));
}
Exemplo n.º 13
0
void wxMenu::GtkAppend(wxMenuItem* mitem, int pos)
{
    GtkWidget *menuItem;
    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:
            {
                // See if we need to create a new radio group for this item or
                // add it to an existing one.
                wxMenuItem* radioGroupItem = NULL;

                const size_t numItems = GetMenuItemCount();
                const size_t n = pos == -1 ? numItems - 1 : size_t(pos);

                if (n != 0)
                {
                    wxMenuItem* const itemPrev = FindItemByPosition(n - 1);
                    if ( itemPrev->GetKind() == wxITEM_RADIO )
                    {
                        // Appending an item after an existing radio item puts
                        // it into the same radio group.
                        radioGroupItem = itemPrev;
                    }
                }

                if (radioGroupItem == NULL && n != numItems - 1)
                {
                    wxMenuItem* const itemNext = FindItemByPosition(n + 1);
                    if ( itemNext->GetKind() == wxITEM_RADIO )
                    {
                        // Inserting an item before an existing radio item
                        // also puts it into the existing radio group.
                        radioGroupItem = itemNext;
                    }
                }

                GSList* group = NULL;
                if ( radioGroupItem )
                {
                    group = gtk_radio_menu_item_get_group(
                              GTK_RADIO_MENU_ITEM(radioGroupItem->GetMenuItem())
                            );
                }

                menuItem = gtk_radio_menu_item_new_with_label(group, "");
            }
            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);
        }
    }
}
Exemplo n.º 14
0
GuiObject GuiMenu_addItem (GuiObject menu, const wchar_t *title, long flags,
	void (*commandCallback) (GuiObject, XtPointer, XtPointer), const void *closure)
{
	Boolean toggle = flags & (GuiMenu_CHECKBUTTON | GuiMenu_RADIO_FIRST | GuiMenu_RADIO_NEXT | GuiMenu_TOGGLE_ON) ? True : False;
	GuiObject button;
	int accelerator = flags & 127;
	Melder_assert (title != NULL);
	if (toggle) {
		if (flags & (GuiMenu_RADIO_FIRST)) group = NULL;
		if (flags & (GuiMenu_RADIO_FIRST | GuiMenu_RADIO_NEXT)) {
			button = gtk_radio_menu_item_new_with_label (group, Melder_peekWcsToUtf8 (title));
			group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button));
			//Melder_casual ("Created a radio menu item with title %ls, group %ld", title, group);
		} else {
			button = gtk_check_menu_item_new_with_label (Melder_peekWcsToUtf8 (title));
		}
	} else {
		button = gtk_menu_item_new_with_label (Melder_peekWcsToUtf8 (title));
	}
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), button);
	Melder_assert (button != NULL);
	if (flags & GuiMenu_INSENSITIVE)
		GuiObject_setSensitive (button, false);
	if (flags & GuiMenu_TOGGLE_ON)
		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button), TRUE);
	if (accelerator) {
		/*
		 * For printable characters, the Command key is assumed.
		 */
		if (accelerator >= 32)
			flags |= GuiMenu_COMMAND;
		
		static const guint acceleratorKeys [] = { 0,
			GDK_Left, GDK_Right, GDK_Up, GDK_Down, GDK_Pause, GDK_Delete, GDK_Insert, GDK_BackSpace,
			GDK_Tab, GDK_Return, GDK_Home, GDK_End, GDK_Return, GDK_Page_Up, GDK_Page_Down, GDK_Escape,
			GDK_F1, GDK_F2, GDK_F3, GDK_F4, GDK_F5, GDK_F6, GDK_F7, GDK_F8, GDK_F9, GDK_F10, GDK_F11, GDK_F12,
			0, 0, 0 };

		int modifiers = 0;
		if (flags & GuiMenu_COMMAND) modifiers |= GDK_CONTROL_MASK;
		if (flags & GuiMenu_SHIFT)   modifiers |= GDK_SHIFT_MASK;
		if (flags & GuiMenu_OPTION)  modifiers |= GDK_MOD1_MASK;

		guint key;
		if (accelerator < 32) {
			key = acceleratorKeys [accelerator];
		} else {
			// gdk key symbols in the ASCII range are equal to ASCII
			key = accelerator;
		}

		GtkAccelGroup *ag = gtk_menu_get_accel_group (GTK_MENU (menu));

		if (key != 0)
			gtk_widget_add_accelerator (button, toggle ? "toggled" : "activate",
				ag, key, (GdkModifierType)modifiers, GTK_ACCEL_VISIBLE);
	}
	#if mac
		if (flags & GuiMenu_ATTRACTIVE) {
			//Melder_casual ("attractive!");
			SetItemStyle (button -> nat.entry.handle, button -> nat.entry.item, bold);
		}
	#endif
	if (commandCallback != NULL) {
		gulong handlerId = g_signal_connect (G_OBJECT (button),
			toggle ? "toggled" : "activate",
			G_CALLBACK (commandCallback), (gpointer) closure);
		g_object_set_data (G_OBJECT (button), "handlerId", (gpointer) handlerId);
		g_object_set_data (G_OBJECT (button), "commandCallback", (gpointer) commandCallback);
		g_object_set_data (G_OBJECT (button), "commandClosure", (gpointer) closure);
	} else {
		gtk_widget_set_sensitive (button, FALSE);
	}
	gtk_widget_show (button);

	return button;
}
Exemplo n.º 15
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;
}
Exemplo n.º 16
0
void MainWindow::initToolbarAndMenu() {
	XOJ_CHECK_TYPE(MainWindow);

	GtkMenuShell * menubar = GTK_MENU_SHELL(get("menuViewToolbar"));
	g_return_if_fail(menubar != NULL);

	ListIterator<ToolbarData *> it = this->toolbar->getModel()->iterator();
	GtkWidget * item = NULL;
	GtkWidget * selectedItem = NULL;
	ToolbarData * selectedData = NULL;

	Settings * settings = control->getSettings();
	String selectedId = settings->getSelectedToolbar();

	bool predefined = true;
	int menuPos = 0;

	while (it.hasNext()) {
		ToolbarData * d = it.next();
		if (selectedData == NULL) {
			selectedData = d;
			selectedItem = item;
		}

		item = gtk_radio_menu_item_new_with_label(this->toolbarGroup, d->getName().c_str());
		this->toolbarGroup = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));

		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), false);

		MenuSelectToolbarData * data = new MenuSelectToolbarData(this, item, d);

		this->toolbarMenuData = g_list_append(this->toolbarMenuData, data);

		if (selectedId == d->getId()) {
			selectedData = d;
			selectedItem = item;
		}

		g_signal_connect(item, "activate", G_CALLBACK(tbSelectMenuitemActivated), data);

		gtk_widget_show(item);

		if (predefined && !d->isPredefined()) {
			GtkWidget * separator = gtk_separator_menu_item_new();
			gtk_widget_show(separator);
			gtk_menu_shell_insert(menubar, separator, menuPos++);

			predefined = false;
			this->toolbarMenuitems = g_list_append(this->toolbarMenuitems, separator);
		}

		gtk_menu_shell_insert(menubar, item, menuPos++);

		this->toolbarMenuitems = g_list_append(this->toolbarMenuitems, item);
	}

	if (selectedData) {
		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(selectedItem), TRUE);
		this->toolbarIntialized = true;
		toolbarSelected(selectedData);
	}

	this->control->getScheduler()->unblockRerenderZoom();
}
Exemplo n.º 17
0
/*
 * mainline..
 */
void searchbox(char *title, GtkSignalFunc func)
{
    int i;
    GtkWidget *menu, *menuitem, *optionmenu;
    GSList *group;
    GtkWidget *small_hbox;

    GtkWidget *scrolled_win;
    GtkWidget *vbox1, *hbox, *hbox0;
    GtkWidget *button1, *button2, *button3, *button3a, *button4, *button5, *button6, *button7;
    GtkWidget *label;
    gchar *titles[]={"Matches"};
    GtkWidget *frame1, *frame2, *frameh, *frameh0;
    GtkWidget *table;
    GtkTooltips *tooltips;
    GtkAdjustment *adj;
    GtkWidget *align;

    if(is_active) 
	{
	gdk_window_raise(window->window);
	return;
	}

    is_active=1;
    cleanup=func;
    num_rows=selected_rows=0;

    /* create a new modal window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW (window), title);
    gtk_signal_connect(GTK_OBJECT (window), "delete_event",
                       (GtkSignalFunc) destroy_callback, NULL);

    tooltips=gtk_tooltips_new_2();

    table = gtk_table_new (256, 1, FALSE);
    gtk_widget_show (table);

    vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_container_border_width (GTK_CONTAINER (vbox1), 3);
    gtk_widget_show (vbox1);
    frame1 = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frame1), 3);
    gtk_widget_show(frame1);
    gtk_table_attach (GTK_TABLE (table), frame1, 0, 1, 0, 1,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);

    label=gtk_label_new("Signal Search Expression");
    gtk_widget_show(label);

    gtk_box_pack_start (GTK_BOX (vbox1), label, TRUE, TRUE, 0);

    entry = gtk_entry_new_with_max_length (256);
    gtk_signal_connect(GTK_OBJECT(entry), "activate",
		       GTK_SIGNAL_FUNC(enter_callback),
		       entry);
    gtk_entry_set_text (GTK_ENTRY (entry), searchbox_text);
    gtk_entry_select_region (GTK_ENTRY (entry),
			     0, GTK_ENTRY(entry)->text_length);
    gtk_widget_show (entry);
    gtk_tooltips_set_tip_2(tooltips, entry, 
		"Enter search expression here.  POSIX Wildcards are allowed.  Note that you may also "
		"modify the search criteria by selecting ``[W]Range'', ``[W]Strand'', or ``None'' for suffix "
		"matching.",NULL);

    gtk_box_pack_start (GTK_BOX (vbox1), entry, TRUE, TRUE, 0);

    /* Allocate memory for the data that is used later */
    pdata = calloc_2(1, sizeof(SearchProgressData) );
    pdata->value = pdata->oldvalue = 0.0;
    /* Create a centering alignment object */  
    align = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_widget_show(align);
    /* Create a Adjustment object to hold the range of the
     * progress bar */
    adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, (gfloat)((numfacs>1)?numfacs-1:1), 0, 0, 0);
    pdata->adj = adj;
    /* Create the GtkProgressBar using the adjustment */
    pdata->pbar = gtk_progress_bar_new_with_adjustment (adj);
    /* Set the format of the string that can be displayed in the
     * trough of the progress bar:
     * %p - percentage
     * %v - value
     * %l - lower range value
     * %u - upper range value */
    gtk_progress_set_format_string (GTK_PROGRESS (pdata->pbar), "(%p%%)");
    gtk_progress_set_show_text (GTK_PROGRESS (pdata->pbar), TRUE);
    gtk_widget_show(pdata->pbar);
    gtk_box_pack_start (GTK_BOX (vbox1), pdata->pbar, TRUE, TRUE, 0);

    gtk_container_add (GTK_CONTAINER (frame1), vbox1);


    frame2 = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frame2), 3);
    gtk_widget_show(frame2);

    gtk_table_attach (GTK_TABLE (table), frame2, 0, 1, 1, 254,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);

    clist=gtk_clist_new_with_titles(1,titles);
    gtk_clist_column_titles_passive(GTK_CLIST(clist)); 

    gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_EXTENDED);
    gtk_signal_connect_object (GTK_OBJECT (clist), "select_row",
			       GTK_SIGNAL_FUNC(select_row_callback),
			       NULL);
    gtk_signal_connect_object (GTK_OBJECT (clist), "unselect_row",
			       GTK_SIGNAL_FUNC(unselect_row_callback),
			       NULL);
    gtk_widget_show (clist);

    scrolled_win = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_AUTOMATIC);
    gtk_widget_set_usize( GTK_WIDGET (scrolled_win), -1, 300);
    gtk_widget_show(scrolled_win);

    /* gtk_scrolled_window_add_with_viewport doesn't seen to work right here.. */
    gtk_container_add (GTK_CONTAINER (scrolled_win), clist);

    gtk_container_add (GTK_CONTAINER (frame2), scrolled_win);


    frameh0 = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frameh0), 3);
    gtk_widget_show(frameh0);
    gtk_table_attach (GTK_TABLE (table), frameh0, 0, 1, 254, 255,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);


    hbox0 = gtk_hbox_new (FALSE, 1);
    gtk_widget_show (hbox0);

    button6 = gtk_button_new_with_label (" Select All ");
    gtk_container_border_width (GTK_CONTAINER (button6), 3);
    gtk_signal_connect_object (GTK_OBJECT (button6), "clicked",
			       GTK_SIGNAL_FUNC(select_all_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button6);
    gtk_tooltips_set_tip_2(tooltips, button6, 
		"Highlight all signals listed in the match window.",NULL);

    gtk_box_pack_start (GTK_BOX (hbox0), button6, TRUE, FALSE, 0);



    menu = gtk_menu_new ();
    group=NULL;

    small_hbox = gtk_hbox_new (TRUE, 0);
    gtk_widget_show (small_hbox);
    
    for(i=0;i<5;i++)
        {
        menuitem = gtk_radio_menu_item_new_with_label (group, regex_name[i]);
        group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
        gtk_menu_append (GTK_MENU (menu), menuitem);
        gtk_widget_show (menuitem);
        gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
                                 GTK_SIGNAL_FUNC(regex_clicked),
                                 &regex_mutex[i]);
        regex_mutex[i]=0;
        }
    
        regex_mutex[0]=1;     /* "range" */
    
        optionmenu = gtk_option_menu_new ();
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
        gtk_box_pack_start (GTK_BOX (small_hbox), optionmenu, TRUE, FALSE, 0);
        gtk_widget_show (optionmenu);   
	gtk_tooltips_set_tip_2(tooltips, optionmenu,
		"You may "
		"modify the search criteria by selecting ``Range'', ``Strand'', or ``None'' for suffix "
		"matching.  This optionally matches the string you enter in the search string above with a Verilog "
		"format range (signal[7:0]), a strand (signal.1, signal.0), or with no suffix.  "
		"The ``W'' modifier for ``Range'' and ``Strand'' explicitly matches on word boundaries.  "
		"(addr matches unit.freezeaddr[63:0] for ``Range'' but only unit.addr[63:0] for ``WRange'' since addr has to be on a word boundary.  "
		"Note that when ``None'' "
		"is selected, the search string may be located anywhere in the signal name.",NULL);
    
        gtk_box_pack_start (GTK_BOX (hbox0), small_hbox, FALSE, FALSE, 0);


    button7 = gtk_button_new_with_label (" Unselect All ");
    gtk_container_border_width (GTK_CONTAINER (button7), 3);
    gtk_signal_connect_object (GTK_OBJECT (button7), "clicked",
			       GTK_SIGNAL_FUNC(unselect_all_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button7);
    gtk_tooltips_set_tip_2(tooltips, button7, 
		"Unhighlight all signals listed in the match window.",NULL);
    gtk_box_pack_start (GTK_BOX (hbox0), button7, TRUE, FALSE, 0);

    gtk_container_add (GTK_CONTAINER (frameh0), hbox0);


    frameh = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frameh), 3);
    gtk_widget_show(frameh);
    gtk_table_attach (GTK_TABLE (table), frameh, 0, 1, 255, 256,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);


    hbox = gtk_hbox_new (FALSE, 1);
    gtk_widget_show (hbox);

    button1 = gtk_button_new_with_label ("Append");
    gtk_container_border_width (GTK_CONTAINER (button1), 3);
    gtk_signal_connect_object (GTK_OBJECT (button1), "clicked",
			       GTK_SIGNAL_FUNC(ok_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button1);
    gtk_tooltips_set_tip_2(tooltips, button1, 
		"Add selected signals to end of the display on the main window.",NULL);

    gtk_box_pack_start (GTK_BOX (hbox), button1, TRUE, FALSE, 0);

    button2 = gtk_button_new_with_label (" Insert ");
    gtk_container_border_width (GTK_CONTAINER (button2), 3);
    gtk_signal_connect_object (GTK_OBJECT (button2), "clicked",
			       GTK_SIGNAL_FUNC(insert_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button2);
    gtk_tooltips_set_tip_2(tooltips, button2, 
		"Add selected signals after last highlighted signal on the main window.",NULL);
    gtk_box_pack_start (GTK_BOX (hbox), button2, TRUE, FALSE, 0);

    if(vcd_explicit_zero_subscripts>=0)
	{
	button3 = gtk_button_new_with_label (" Bundle Up ");
    	gtk_container_border_width (GTK_CONTAINER (button3), 3);
    	gtk_signal_connect_object (GTK_OBJECT (button3), "clicked",
			       GTK_SIGNAL_FUNC(bundle_callback_up),
			       GTK_OBJECT (window));
    	gtk_widget_show (button3);
    	gtk_tooltips_set_tip_2(tooltips, button3, 
		"Bundle selected signals into a single bit vector with the topmost selected signal as the LSB and the lowest as the MSB.",NULL);
    	gtk_box_pack_start (GTK_BOX (hbox), button3, TRUE, FALSE, 0);

    	button3a = gtk_button_new_with_label (" Bundle Down ");
    	gtk_container_border_width (GTK_CONTAINER (button3a), 3);
    	gtk_signal_connect_object (GTK_OBJECT (button3a), "clicked",
			       GTK_SIGNAL_FUNC(bundle_callback_down),
			       GTK_OBJECT (window));
    	gtk_widget_show (button3a);
    	gtk_tooltips_set_tip_2(tooltips, button3a, 
		"Bundle selected signals into a single bit vector with the topmost selected signal as the MSB and the lowest as the LSB.",NULL);
	gtk_box_pack_start (GTK_BOX (hbox), button3a, TRUE, FALSE, 0);
	}

    button4 = gtk_button_new_with_label (" Replace ");
    gtk_container_border_width (GTK_CONTAINER (button4), 3);
    gtk_signal_connect_object (GTK_OBJECT (button4), "clicked",
			       GTK_SIGNAL_FUNC(replace_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button4);
    gtk_tooltips_set_tip_2(tooltips, button4, 
		"Replace highlighted signals on the main window with signals selected above.",NULL);
    gtk_box_pack_start (GTK_BOX (hbox), button4, TRUE, FALSE, 0);

    button5 = gtk_button_new_with_label (" Exit ");
    gtk_container_border_width (GTK_CONTAINER (button5), 3);
    gtk_signal_connect_object (GTK_OBJECT (button5), "clicked",
			       GTK_SIGNAL_FUNC(destroy_callback),
			       GTK_OBJECT (window));
    gtk_tooltips_set_tip_2(tooltips, button5, 
		"Do nothing and return to the main window.",NULL);
    gtk_widget_show (button5);
    gtk_box_pack_start (GTK_BOX (hbox), button5, TRUE, FALSE, 0);

    gtk_container_add (GTK_CONTAINER (frameh), hbox);
    gtk_container_add (GTK_CONTAINER (window), table);

    gtk_widget_show(window);

    if(strlen(searchbox_text)) enter_callback(entry,NULL);
}
Exemplo n.º 18
0
static void *gtk_thread(void *arg)
{
	struct gtk_mod *mod = arg;
	GtkMenuShell *app_menu;
	GtkWidget *item;
	GError *err = NULL;
	struct le *le;

	gdk_threads_init();
	gtk_init(0, NULL);

	g_set_application_name("baresip");
	mod->app = g_application_new ("com.creytiv.baresip",
			G_APPLICATION_FLAGS_NONE);

	g_application_register (G_APPLICATION (mod->app), NULL, &err);
	if (err != NULL) {
		warning ("Unable to register GApplication: %s",
				err->message);
		g_error_free (err);
		err = NULL;
	}

#ifdef USE_LIBNOTIFY
	notify_init("baresip");
#endif

	mod->status_icon = gtk_status_icon_new_from_icon_name("call-start");
	gtk_status_icon_set_tooltip_text (mod->status_icon, "baresip");

	g_signal_connect(G_OBJECT(mod->status_icon),
			"button_press_event",
			G_CALLBACK(status_icon_on_button_press), mod);
	gtk_status_icon_set_visible(mod->status_icon, TRUE);

	mod->contacts_inited = false;
	mod->dial_dialog = NULL;
	mod->call_windows = NULL;
	mod->incoming_call_menus = NULL;

	/* App menu */
	mod->app_menu = gtk_menu_new();
	app_menu = GTK_MENU_SHELL(mod->app_menu);

	/* Account submenu */
	mod->accounts_menu = gtk_menu_new();
	mod->accounts_menu_group = NULL;
	item = gtk_menu_item_new_with_mnemonic("_Account");
	gtk_menu_shell_append(app_menu, item);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
			mod->accounts_menu);

	/* Add accounts to submenu */
	for (le = list_head(uag_list()); le; le = le->next) {
		struct ua *ua = le->data;
		accounts_menu_add_item(mod, ua);
	}

	/* Status submenu */
	mod->status_menu = gtk_menu_new();
	item = gtk_menu_item_new_with_mnemonic("_Status");
	gtk_menu_shell_append(GTK_MENU_SHELL(app_menu), item);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), mod->status_menu);

	/* Open */
	item = gtk_radio_menu_item_new_with_label(NULL, "Open");
	g_object_set_data(G_OBJECT(item), "presence",
			GINT_TO_POINTER(PRESENCE_OPEN));
	g_signal_connect(item, "activate",
			G_CALLBACK(menu_on_presence_set), mod);
	gtk_menu_shell_append(GTK_MENU_SHELL(mod->status_menu), item);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);

	/* Closed */
	item = gtk_radio_menu_item_new_with_label_from_widget(
			GTK_RADIO_MENU_ITEM(item), "Closed");
	g_object_set_data(G_OBJECT(item), "presence",
			GINT_TO_POINTER(PRESENCE_CLOSED));
	g_signal_connect(item, "activate",
			G_CALLBACK(menu_on_presence_set), mod);
	gtk_menu_shell_append(GTK_MENU_SHELL(mod->status_menu), item);

	gtk_menu_shell_append(app_menu, gtk_separator_menu_item_new());

	/* Dial */
	item = gtk_menu_item_new_with_mnemonic("_Dial...");
	gtk_menu_shell_append(app_menu, item);
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(menu_on_dial), mod);

	/* Dial contact */
	mod->contacts_menu = gtk_menu_new();
	item = gtk_menu_item_new_with_mnemonic("Dial _contact");
	gtk_menu_shell_append(app_menu, item);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
			mod->contacts_menu);

	gtk_menu_shell_append(app_menu, gtk_separator_menu_item_new());

	/* About */
	item = gtk_menu_item_new_with_mnemonic("A_bout");
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(menu_on_about), mod);
	gtk_menu_shell_append(app_menu, item);

	gtk_menu_shell_append(app_menu, gtk_separator_menu_item_new());

	/* Quit */
	item = gtk_menu_item_new_with_mnemonic("_Quit");
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(menu_on_quit), mod);
	gtk_menu_shell_append(app_menu, item);

	g_action_map_add_action_entries(G_ACTION_MAP(mod->app),
			app_entries, G_N_ELEMENTS(app_entries), mod);

	info("gtk_menu starting\n");

	uag_event_register( ua_event_handler, mod );
	mod->run = true;
	gtk_main();
	mod->run = false;
	uag_event_unregister(ua_event_handler);

	if (mod->dial_dialog) {
		mem_deref(mod->dial_dialog);
		mod->dial_dialog = NULL;
	}

	return NULL;
}
Exemplo n.º 19
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;
    }

  }
}
Exemplo n.º 20
0
static void pama_source_output_widget_source_button_clicked(GtkButton *button, PamaSourceOutputWidget *widget)
{
	PamaSourceOutputWidgetPrivate *priv = PAMA_SOURCE_OUTPUT_WIDGET_GET_PRIVATE(widget);
	GtkWidget *item, *last = NULL;
	GtkWidget *label;
	GSList *sources, *iter;
	PamaPulseSource *source, *current_source;
	PamaPulseSink *monitored_sink;
	gchar *source_name, *hostname;
	gboolean network;
	gchar *text;

	if (!priv->source_menu)
	{
		priv->source_menu = gtk_menu_new();
		g_object_ref_sink(priv->source_menu);
		g_signal_connect(gtk_widget_get_toplevel(priv->source_menu), "hide", G_CALLBACK(pama_source_output_widget_source_menu_hidden), widget);

		sources = g_slist_copy(pama_pulse_context_get_sources(priv->context));
		sources = g_slist_sort(sources, _source_menu_sort_function);

		g_object_get(priv->source_output, "source", &current_source, NULL);

		for (iter = sources; iter; iter = iter->next)
		{
			source = PAMA_PULSE_SOURCE(iter->data);
			g_object_get(source, 
			             "description", &source_name, 
			             "hostname",    &hostname,
			             "network",     &network,
			             NULL);
			monitored_sink = pama_pulse_source_get_monitored_sink(source);
			if (monitored_sink)
			{
				g_free(source_name);
				g_free(hostname);

				g_object_get(monitored_sink, 
		 		            "description", &text,
		 		            "hostname",    &hostname,
		  		            "network",     &network,
				             NULL);

				source_name = g_markup_printf_escaped(_("Monitor of %s"), text);
				g_free(text);
			}

			if (network)
				text = g_markup_printf_escaped("<b>%s</b> (on %s)", source_name, hostname);
			else
				text = g_markup_printf_escaped("<b>%s</b>", source_name);

			label = g_object_new(GTK_TYPE_LABEL,
			                     "label", text,
			                     "use-markup", TRUE,
			                     "xalign", 0.0,
			                     NULL);

			if (last)
				item = gtk_radio_menu_item_new_from_widget(GTK_RADIO_MENU_ITEM(last));
			else
				item = gtk_radio_menu_item_new(NULL);

			gtk_container_add(GTK_CONTAINER(item), label);

			g_object_set(item,
			             "active", (current_source == source),
			             "user-data", source,
			             NULL);
			last = item;
			g_free(source_name);
			g_free(hostname);
			g_free(text);

			g_signal_connect(item, "toggled", G_CALLBACK(pama_source_output_widget_source_menu_item_toggled), widget);
			gtk_menu_shell_append(GTK_MENU_SHELL(priv->source_menu), item);
			gtk_widget_show_all(item);
		}

		g_slist_free(sources);
		g_object_unref(current_source);

		gtk_menu_popup(GTK_MENU(priv->source_menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
	}
}
Exemplo n.º 21
0
GtkWidget*
usejournal_build_menu(const char *defaultjournal, const char *currentjournal,
		GSList *journals, gpointer doc) {
	GtkWidget *menu, *curmenu, *item, *label;
	GSList *group = NULL;
	GSList *l;
	char *journal;
	char *curmenuprefix = NULL;
	char prefix[30];

	curmenu = menu = gtk_menu_new(); 

	item = gtk_radio_menu_item_new_with_label(group, defaultjournal);
	group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(activate_cb), doc);

	if (currentjournal == NULL) 
		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);

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

	for (l = journals; l != NULL; l = l->next) {
		journal = (char*)l->data;

		if (curmenuprefix) {
			/* try to match this item to the prefix. */
			if (sharedprefix(curmenuprefix, journal)) {
				/* match. */
			} else {
				curmenu = menu;
				curmenuprefix = NULL;
			}
		} 
		if (!curmenuprefix && l->next) {
			/* try to see if this begins a new prefix. */
			char *nextjournal = (char*)l->next->data;
			int ofs;
			ofs = sharedprefix(journal, nextjournal);
			if (ofs) {
				/* make a new submenu for these shared-prefix journals. */
				memcpy(prefix, journal, ofs);
				prefix[ofs] = 0;

				item = gtk_menu_item_new();
				label = gtk_label_new(NULL);
				gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
				gtk_label_set_markup(GTK_LABEL(label), prefix);
				gtk_container_add(GTK_CONTAINER(item), label);
				gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
				curmenu = gtk_menu_new();
				curmenuprefix = prefix;
				gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), curmenu);
				gtk_widget_show_all(item);
			}
		}
		item = gtk_radio_menu_item_new_with_label(group, journal);
		if (currentjournal && strcmp(currentjournal, journal) == 0)
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
		g_signal_connect(G_OBJECT(item), "activate",
				G_CALLBACK(activate_cb), doc);
		gtk_widget_show(item);
		gtk_menu_shell_append(GTK_MENU_SHELL(curmenu), item);

		group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));
	}

	return menu;
}
Exemplo n.º 22
0
bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
{
    GtkWidget *menuItem;

    wxString text;
    GtkLabel* label = NULL;

    if ( mitem->IsSeparator() )
    {
        // TODO
        menuItem = gtk_menu_item_new();
    }
    else if (mitem->GetBitmap().IsOk())
    {
        text = mitem->wxMenuItemBase::GetItemLabel();
        const wxBitmap *bitmap = &mitem->GetBitmap();

        // TODO
        wxUnusedVar(bitmap);
        menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
        label = GTK_LABEL( GTK_BIN(menuItem)->child );

        m_prevRadio = NULL;
    }
    else // a normal item
    {
        // text has "_" instead of "&" after mitem->SetItemLabel() so don't use it
        text =  mitem->wxMenuItemBase::GetItemLabel() ;

        switch ( mitem->GetKind() )
        {
            case wxITEM_CHECK:
            {
                menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) );
                label = GTK_LABEL( GTK_BIN(menuItem)->child );
                // set new text
                gtk_label_set_text( label, wxGTK_CONV( text ) );
                m_prevRadio = NULL;
                break;
            }

            case wxITEM_RADIO:
            {
                GSList *group = NULL;
                if ( m_prevRadio == NULL )
                {
                    // start of a new radio group
                    m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
                    label = GTK_LABEL( GTK_BIN(menuItem)->child );
                    // set new text
                    gtk_label_set_text( label, wxGTK_CONV( text ) );
                }
                else // continue the radio group
                {
                    group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
                    m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
                    label = GTK_LABEL( GTK_BIN(menuItem)->child );
                }
                break;
            }

            default:
                wxFAIL_MSG( wxT("unexpected menu item kind") );
                // fall through

            case wxITEM_NORMAL:
            {
                menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
                label = GTK_LABEL( GTK_BIN(menuItem)->child );
                m_prevRadio = NULL;
                break;
            }
        }

    }

    guint accel_key;
    GdkModifierType accel_mods;
    wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*mitem) );

    // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetItemLabel().c_str(), GetGtkHotKey(*mitem).c_str() );
    gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
    if (accel_key != 0)
    {
        gtk_widget_add_accelerator (GTK_WIDGET(menuItem),
                                    "activate",
                                    m_accel,
                                    accel_key,
                                    accel_mods,
                                    GTK_ACCEL_VISIBLE);
    }

    if (pos == -1)
        gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
    else
        gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);

    gtk_widget_show( menuItem );

    if ( !mitem->IsSeparator() )
    {
        wxASSERT_MSG( menuItem, wxT("invalid menuitem") );

        gtk_signal_connect( GTK_OBJECT(menuItem), "select",
                            GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
                            (gpointer)this );

        gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
                            GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
                            (gpointer)this );

        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
        {
            gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
                                GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
                                (gpointer)this );
        }

        guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
        if (accel_key != GDK_VoidSymbol)
        {
            gtk_widget_add_accelerator (menuItem,
                                        "activate_item",
                                        gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
                                        accel_key,
                                        GDK_MOD1_MASK,
                                        GTK_ACCEL_LOCKED);
        }
    }

    mitem->SetMenuItem(menuItem);

    if (ms_locked)
    {
        // This doesn't even exist!
        // gtk_widget_lock_accelerators(mitem->GetMenuItem());
    }

    return true;
}
Exemplo n.º 23
0
void encodings_init(void)
{
	GtkWidget *item, *menu[2], *submenu, *menu_westeuro, *menu_easteuro, *menu_eastasian, *menu_asian,
			  *menu_utf8, *menu_middleeast, *item_westeuro, *item_easteuro, *item_eastasian,
			  *item_asian, *item_utf8, *item_middleeast;
	GCallback cb_func[2];
	GSList *group = NULL;
	gchar *label;
	gint order, group_size;
	guint i, j, k;

	init_encodings();

	if (! pregs_loaded)
	{
		regex_compile(&pregs[0], PATTERN_HTMLMETA);
		regex_compile(&pregs[1], PATTERN_CODING);
		pregs_loaded = TRUE;
	}

	/* create encodings submenu in document menu */
	menu[0] = ui_lookup_widget(main_widgets.window, "set_encoding1_menu");
	menu[1] = ui_lookup_widget(main_widgets.window, "menu_reload_as1_menu");
	cb_func[0] = G_CALLBACK(encodings_radio_item_change_cb);
	cb_func[1] = G_CALLBACK(on_reload_as_activate);

	for (k = 0; k < 2; k++)
	{
		menu_westeuro = gtk_menu_new();
		item_westeuro = gtk_menu_item_new_with_mnemonic(_("_West European"));
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_westeuro), menu_westeuro);
		gtk_container_add(GTK_CONTAINER(menu[k]), item_westeuro);
		gtk_widget_show_all(item_westeuro);

		menu_easteuro = gtk_menu_new();
		item_easteuro = gtk_menu_item_new_with_mnemonic(_("_East European"));
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_easteuro), menu_easteuro);
		gtk_container_add(GTK_CONTAINER(menu[k]), item_easteuro);
		gtk_widget_show_all(item_easteuro);

		menu_eastasian = gtk_menu_new();
		item_eastasian = gtk_menu_item_new_with_mnemonic(_("East _Asian"));
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_eastasian), menu_eastasian);
		gtk_container_add(GTK_CONTAINER(menu[k]), item_eastasian);
		gtk_widget_show_all(item_eastasian);

		menu_asian = gtk_menu_new();
		item_asian = gtk_menu_item_new_with_mnemonic(_("_SE & SW Asian"));
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_asian), menu_asian);
		gtk_container_add(GTK_CONTAINER(menu[k]), item_asian);
		gtk_widget_show_all(item_asian);

		menu_middleeast = gtk_menu_new();
		item_middleeast = gtk_menu_item_new_with_mnemonic(_("_Middle Eastern"));
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_middleeast), menu_middleeast);
		gtk_container_add(GTK_CONTAINER(menu[k]), item_middleeast);
		gtk_widget_show_all(item_middleeast);

		menu_utf8 = gtk_menu_new();
		item_utf8 = gtk_menu_item_new_with_mnemonic(_("_Unicode"));
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item_utf8), menu_utf8);
		gtk_container_add(GTK_CONTAINER(menu[k]), item_utf8);
		gtk_widget_show_all(item_utf8);

		/** TODO can it be optimized? ATM 3782 runs at line "if (encodings[j].group ...)" */
		for (i = 0; i < GEANY_ENCODING_GROUPS_MAX; i++)
		{
			order = 0;
			switch (i)
			{
				case WESTEUROPEAN: submenu = menu_westeuro; group_size = 9; break;
				case EASTEUROPEAN: submenu = menu_easteuro; group_size = 14; break;
				case EASTASIAN: submenu = menu_eastasian; group_size = 14; break;
				case ASIAN: submenu = menu_asian; group_size = 9; break;
				case MIDDLEEASTERN: submenu = menu_middleeast; group_size = 7; break;
				case UNICODE: submenu = menu_utf8; group_size = 8; break;
				default: submenu = menu[k]; group_size = 1;
			}

			while (order < group_size)	/* the biggest group has 13 elements */
			{
				for (j = 0; j < GEANY_ENCODINGS_MAX; j++)
				{
					if (encodings[j].group == i && encodings[j].order == order)
					{
						label = encodings_to_string(&encodings[j]);
						if (k == 0)
						{
							item = gtk_radio_menu_item_new_with_label(group, label);
							group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));
							radio_items[j] = item;
						}
						else
							item = gtk_menu_item_new_with_label(label);
						gtk_widget_show(item);
						gtk_container_add(GTK_CONTAINER(submenu), item);
						g_signal_connect(item, "activate",
										cb_func[k], GINT_TO_POINTER(encodings[j].idx));
						g_free(label);
						break;
					}
				}
				order++;
			}
		}
	}
}