Exemplo n.º 1
0
GtkWidget *
gconf_editor_application_create_editor_window (int type)
{
	GtkWidget *window;
	GConfEditorWindow *gconfwindow;

	window = g_object_new (GCONF_TYPE_EDITOR_WINDOW, "editor-type", type, NULL);

	gconfwindow = GCONF_EDITOR_WINDOW (window);

	if (gconfwindow->client == NULL) {
		gconf_editor_application_window_destroyed (window);
		return NULL;
	}

	gconf_tree_model_set_client (GCONF_TREE_MODEL (gconfwindow->tree_model), gconfwindow->client);
	gconf_list_model_set_client (GCONF_LIST_MODEL (gconfwindow->list_model), gconfwindow->client);

	if (!gconf_util_can_edit_defaults ())
		gtk_action_set_sensitive (gtk_ui_manager_get_action (gconfwindow->ui_manager, "/GConfEditorMenu/FileMenu/NewDefaultsWindow"),
					  FALSE);

	if (!gconf_util_can_edit_mandatory ())
		gtk_action_set_sensitive (gtk_ui_manager_get_action (gconfwindow->ui_manager, "/GConfEditorMenu/FileMenu/NewMandatoryWindow"),
					  FALSE);
	
	g_signal_connect (window, "destroy",
			  G_CALLBACK (gconf_editor_application_window_destroyed), NULL);
	
	editor_windows = g_slist_prepend (editor_windows, window);

	gconf_editor_window_expand_first (gconfwindow);

	return window;
}
Exemplo n.º 2
0
GtkWidget*
search_box_new (AnjutaDocman *docman)
{
	SearchBox* search_box;
	AnjutaUI *ui;

	search_box = SEARCH_BOX (g_object_new (SEARCH_TYPE_BOX, "homogeneous",
											FALSE, NULL));

	g_signal_connect (G_OBJECT (docman), "document-changed",
					  G_CALLBACK (on_document_changed), search_box);

	search_box->priv->status = anjuta_shell_get_status (docman->shell, NULL);
	
	ui = anjuta_shell_get_ui (docman->shell, NULL);
	search_box->priv->popup_menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui),
											"/SearchboxPopup");
	g_assert (search_box->priv->popup_menu != NULL && GTK_IS_MENU (search_box->priv->popup_menu));

	search_box->priv->case_action = 
		gtk_ui_manager_get_action (GTK_UI_MANAGER (ui),
		                           "/SearchboxPopup/CaseCheck");

	search_box->priv->highlight_action =
		gtk_ui_manager_get_action (GTK_UI_MANAGER (ui),
		                           "/SearchboxPopup/HighlightAll");
	search_box->priv->regex_action = 
		gtk_ui_manager_get_action (GTK_UI_MANAGER (ui),
		                           "/SearchboxPopup/RegexSearch");

	g_signal_connect (search_box->priv->popup_menu, "deactivate",
					  G_CALLBACK (gtk_widget_hide), NULL);

	return GTK_WIDGET (search_box);
}
Exemplo n.º 3
0
/**
 * Update the view menu in the menu bar
 *
 * \param account_number	The account used to update the menu
 *
 * \return FALSE
 * */
gboolean gsb_menu_update_view_menu ( gint account_number )
{
    gchar * item_name = NULL;
    gchar *tmpstr;

    devel_debug_int (account_number);

    block_menu_cb = TRUE;

    /* update the showing of reconciled transactions */
    tmpstr = "/menubar/ViewMenu/ShowReconciled";
    gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (
                        gtk_ui_manager_get_action ( ui_manager, tmpstr) ),
				        gsb_data_account_get_r ( account_number ) );

    tmpstr = "/menubar/ViewMenu/ShowTransactionForm";
    gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (
                        gtk_ui_manager_get_action ( ui_manager, tmpstr) ),
				        gsb_form_is_visible ( ) );

    /* update the showing of archived transactions */
    tmpstr = "/menubar/ViewMenu/ShowArchived";
    gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (
                        gtk_ui_manager_get_action ( ui_manager, tmpstr) ),
				        gsb_data_account_get_l ( account_number ) );

    /* update the number of line showed */
    switch ( gsb_data_account_get_nb_rows (account_number))
    {
	default:
	case 1 :
	    item_name = "/menubar/ViewMenu/ShowOneLine";
	    break;
	case 2 :
	    item_name = "/menubar/ViewMenu/ShowTwoLines";
	    break;
	case 3 :
	    item_name = "/menubar/ViewMenu/ShowThreeLines";
	    break;
	case 4 :
	    item_name = "/menubar/ViewMenu/ShowFourLines";
	    break;
    }

    gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (
                        gtk_ui_manager_get_action ( ui_manager, item_name ) ),
				        TRUE );
    block_menu_cb = FALSE;

    return FALSE;
}
Exemplo n.º 4
0
int
clip_GTK_UIMANAGERGETACTION(ClipMachine * ClipMachineMemory)
{
   C_object *cmanager = _fetch_co_arg(ClipMachineMemory);

   gchar    *path = _clip_parc(ClipMachineMemory, 2);

   GtkAction *action;

   C_object *caction;

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cmanager, GTK_IS_UI_MANAGER(cmanager->object));
   CHECKARG(2, CHARACTER_type_of_ClipVarType);

   action = gtk_ui_manager_get_action(GTK_UI_MANAGER(cmanager->object), path);

   if (action)
    {
       caction = _list_get_cobject(ClipMachineMemory, action);
       if (!caction)
	  caction = _register_object(ClipMachineMemory, action, GTK_TYPE_ACTION, NULL, NULL);
       if (caction)
	  _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &caction->obj);
    }
   return 0;
 err:
   return 1;
}
Exemplo n.º 5
0
//==============================================================================
// PRIVATE METHODS							       =
//==============================================================================
static void merge_ui_def(GebrGuiHelpEditWindow * window, gboolean revert_visible)
{
    GtkActionGroup * action_group;
    GtkUIManager * ui_manager;
    GtkAction * action;
    GError * error = NULL;
    gchar * path;

    ui_manager = gebr_gui_help_edit_window_get_ui_manager(window);

    action_group = gtk_action_group_new("DebrHelpEditGroup");
    gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions(action_group, action_entries, n_action_entries, window);
    action = gtk_action_group_get_action(action_group, "JumpToMenu");
    g_object_set(action, "hide-if-empty", FALSE, NULL);
    action = gtk_action_group_get_action(action_group, "RevertAction");
    gtk_action_set_sensitive(action, revert_visible);

    gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
    gtk_ui_manager_add_ui_from_string(ui_manager, ui_def, -1, &error);
    g_object_unref(action_group);

    path = g_strconcat (gebr_gui_help_edit_window_get_tool_bar_mark (window),
                        "/PreviewAction",
                        NULL);
    action = gtk_ui_manager_get_action (ui_manager, path);
    g_signal_connect (action, "toggled", G_CALLBACK (on_preview_toggled), window);
    g_free (path);

    if (error != NULL) {
        g_warning("%s\n", error->message);
        g_clear_error(&error);
    }
}
Exemplo n.º 6
0
GtkAction *
pragha_application_get_menu_action (PraghaApplication *pragha, const gchar *path)
{
	GtkUIManager *ui_manager = pragha_application_get_menu_ui_manager (pragha);

	return gtk_ui_manager_get_action (ui_manager, path);
}
Exemplo n.º 7
0
/**
 * Toggle blank mode FIXME bitfields!!!
 *
 */
void
toggle_blank (GtkAction* action, DenemoScriptParam *param)
{
  GtkAction *mode = gtk_ui_manager_get_action (Denemo.ui_manager, "/MainMenu/ModeMenu/Blank");
  gtk_action_activate (mode);
  displayhelper (Denemo.project);
  score_status(Denemo.project, TRUE);
}
Exemplo n.º 8
0
void save_config_file(void)
{
	FILE *fp;
	gchar *path;
	gint width, height, tabwidth;
	gchar *fontname;
	gboolean wordwrap, linenumbers, autoindent;

	gtk_window_get_size(GTK_WINDOW(pub->mw->window), &width, &height);
	fontname = pango_font_description_to_string(gtk_style_context_get_font(gtk_widget_get_style_context(pub->mw->view), 0));
	wordwrap = gtk_toggle_action_get_active(
		GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(pub->mw->menubar,
			"/M/Options/WordWrap")));
	linenumbers = gtk_toggle_action_get_active(
		GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(pub->mw->menubar,
			"/M/Options/LineNumbers")));
	autoindent = gtk_toggle_action_get_active(
		GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(pub->mw->menubar,
			"/M/Options/AutoIndent")));
	tabwidth = get_current_tab_width();

	path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL);
	if (!g_file_test(path, G_FILE_TEST_IS_DIR))
		g_mkdir_with_parents(path, 0700);
	g_free(path);
	path = g_build_filename(g_get_user_config_dir(),
	    PACKAGE, PACKAGE "rc", NULL);
	fp = fopen(path, "w");
	if (!fp) {
		g_print("%s: can't save config file - %s\n", PACKAGE, path);
		return;
	}
	g_free(path);

	fprintf(fp, "%s\n", PACKAGE_VERSION);
	fprintf(fp, "%d\n", width);
	fprintf(fp, "%d\n", height);
	fprintf(fp, "%s\n", fontname);
	fprintf(fp, "%d\n", wordwrap);
	fprintf(fp, "%d\n", linenumbers);
	fprintf(fp, "%d\n", autoindent);
	fprintf(fp, "%d\n", tabwidth);
	fclose(fp);

	g_free(fontname);
}
Exemplo n.º 9
0
static void
load_started (GtkWidget      *view,
              WebKitWebFrame *frame)
{
  GtkAction *action = gtk_ui_manager_get_action (ui_manager,
                                                 "/ui/help-browser-popup/stop");
  gtk_action_set_sensitive (action, TRUE);
}
Exemplo n.º 10
0
static void
window_clipboard_changed_cb (GiggleClipboard *clipboard,
			     GiggleWindow    *window)
{
	GiggleWindowPriv *priv = GET_PRIV (window);

	if (!priv->ui_manager)
		return;

	gtk_action_set_sensitive (gtk_ui_manager_get_action (priv->ui_manager, CUT_PATH),
			          clipboard && giggle_clipboard_can_cut (clipboard));
	gtk_action_set_sensitive (gtk_ui_manager_get_action (priv->ui_manager, COPY_PATH),
			          clipboard && giggle_clipboard_can_copy (clipboard));
	gtk_action_set_sensitive (gtk_ui_manager_get_action (priv->ui_manager, PASTE_PATH),
			          clipboard && giggle_clipboard_can_paste (clipboard));
	gtk_action_set_sensitive (gtk_ui_manager_get_action (priv->ui_manager, DELETE_PATH),
			          clipboard && giggle_clipboard_can_delete (clipboard));
}
Exemplo n.º 11
0
static void
load_finished (GtkWidget      *view,
               WebKitWebFrame *frame)
{
  GtkAction *action = gtk_ui_manager_get_action (ui_manager,
                                                 "/ui/help-browser-popup/stop");
  gtk_action_set_sensitive (action, FALSE);

  update_actions ();

  select_index (webkit_web_frame_get_uri (frame));
}
Exemplo n.º 12
0
static void
window_history_update_ui (GiggleWindow *window)
{
	GiggleWindowPriv *priv = GET_PRIV (window);
	gboolean          back = FALSE, forward = FALSE;
	GtkAction        *action;

	if (!priv->ui_manager)
		return;

	if (priv->history) {
		back = (NULL != priv->history->prev);
		forward = (NULL != priv->history->next);
	}

	action = gtk_ui_manager_get_action (priv->ui_manager, HISTORY_GO_BACK_PATH);
	gtk_action_set_sensitive (action, back);

	action = gtk_ui_manager_get_action (priv->ui_manager, HISTORY_GO_FORWARD_PATH);
	gtk_action_set_sensitive (action, forward);
}
Exemplo n.º 13
0
void flip (GtkUIManager *ui, const char *path, gboolean s)
{
    if (ui != NULL) {
	GtkAction *a = gtk_ui_manager_get_action(ui, path);

	if (a != NULL) {
	    gtk_action_set_sensitive(a, s);
	} else {
	    fprintf(stderr, I_("Failed to flip state of \"%s\"\n"), path);
	}
    }
}
Exemplo n.º 14
0
static void
cedit_prefs_manager_syntax_hl_enable_changed (GSettings *settings,
					      gchar       *key,
					      gpointer     user_data)
{
	cedit_debug (DEBUG_PREFS);

	if (strcmp (key, GPM_SYNTAX_HL_ENABLE) == 0)
	{
		gboolean enable;
		GList *docs;
		GList *l;
		const GList *windows;

		enable = g_settings_get_boolean (settings, key);

		docs = cedit_app_get_documents (cedit_app_get_default ());
		l = docs;

		while (l != NULL)
		{
#if GTK_CHECK_VERSION (3, 0, 0)
			g_return_if_fail (GTK_SOURCE_IS_BUFFER (l->data));
#else
			g_return_if_fail (GTK_IS_SOURCE_BUFFER (l->data));
#endif

			gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (l->data),
								enable);

			l = l->next;
		}

		g_list_free (docs);

		/* update the sensitivity of the Higlight Mode menu item */
		windows = cedit_app_get_windows (cedit_app_get_default ());
		while (windows != NULL)
		{
			GtkUIManager *ui;
			GtkAction *a;

			ui = cedit_window_get_ui_manager (CEDIT_WINDOW (windows->data));

			a = gtk_ui_manager_get_action (ui,
						       "/MenuBar/ViewMenu/ViewHighlightModeMenu");

			gtk_action_set_sensitive (a, enable);

			windows = g_list_next (windows);
		}
	}
}
Exemplo n.º 15
0
void iconview_menubar_state (gboolean s)
{
    if (s) {
	GtkAction *a = gtk_ui_manager_get_action(mdata->ui, "/menubar/View");

	if (a != NULL && !gtk_action_get_sensitive(a)) {
	    gtk_action_set_sensitive(a, TRUE);
	}
    }

    flip(mdata->ui, "/menubar/View/IconView", s);
}
Exemplo n.º 16
0
static void
anjuta_docman_update_documents_menu_status (AnjutaDocman* docman)
{
	AnjutaDocmanPriv *priv = docman->priv;
	GtkUIManager* ui = GTK_UI_MANAGER (anjuta_shell_get_ui (ANJUTA_PLUGIN (priv->plugin)->shell,
															NULL));
	GtkAction* action;
	gint n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (docman));
	gint current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (docman));
	gchar *action_name;

	action = gtk_ui_manager_get_action (ui,
										"/MenuMain/PlaceHolderDocumentsMenus/Documents/PreviousDocument");
	g_object_set (action, "sensitive", current_page > 0, NULL);
	action = gtk_ui_manager_get_action (ui,
										"/MenuMain/PlaceHolderDocumentsMenus/Documents/NextDocument");
	g_object_set (action, "sensitive", (current_page + 1) < n_pages, NULL);
	action_name = g_strdup_printf ("Tab_%d", current_page);
	action = gtk_action_group_get_action (docman->priv->documents_action_group, action_name);
	g_free (action_name);
	if (action)
		gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
}
Exemplo n.º 17
0
/* TODO: use g_settings_bind instead of manual visibility switching
 * see also cmd_show_hide_bar()
*/
static void
update_ui_visibility (EmerillonWindow *self)
{
  gboolean visible;
  GtkAction *action;

  /* Toolbar. */
  visible = g_settings_get_boolean (self->priv->settings_ui,
      EMERILLON_CONF_UI_TOOLBAR);
  action = gtk_ui_manager_get_action (self->priv->ui_manager,
      "/MainMenu/View/ToolbarToggle");
  g_assert (action != NULL);
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
  g_object_set (G_OBJECT (self->priv->toolbar), "visible", visible, NULL);

  /* Statusbar. */
  visible = g_settings_get_boolean (self->priv->settings_ui,
      EMERILLON_CONF_UI_STATUSBAR);
  action = gtk_ui_manager_get_action (self->priv->ui_manager,
      "/MainMenu/View/StatusbarToggle");
  g_assert (action != NULL);
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
  g_object_set (G_OBJECT (self->priv->statusbar), "visible", visible, NULL);

  /* Sidebar. */
  visible = g_settings_get_boolean (self->priv->settings_ui,
      EMERILLON_CONF_UI_SIDEBAR);
  action = gtk_ui_manager_get_action (self->priv->ui_manager,
      "/MainMenu/View/SidebarToggle");
  g_assert (action != NULL);
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
  if (visible)
      gtk_widget_show (self->priv->sidebar);
  else
      gtk_widget_hide (self->priv->sidebar);
}
Exemplo n.º 18
0
static gboolean
view_key_press (GtkWidget   *widget,
                GdkEventKey *event)
{
  if (event->keyval == GDK_KEY_slash)
    {
      GtkAction *action;

      action = gtk_ui_manager_get_action (ui_manager,
                                          "/ui/help-browser-popup/find");
      gtk_action_activate (action);

      return TRUE;
    }

  return FALSE;
}
Exemplo n.º 19
0
/** Set the visibility of the toolbar */
static void gui_set_toolbar_visible(void)
{
	GSList *list;
	gboolean visible;

	list = gtk_ui_manager_get_toplevels(ui_manager,
					    GTK_UI_MANAGER_TOOLBAR);
	g_assert(g_slist_length(list) == 1);
	visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION
					       (gtk_ui_manager_get_action
						(ui_manager,
						 "ui/MainMenu/SettingsMenu/ShowHideToolbar")));
	if (visible)
		gtk_widget_show(GTK_WIDGET(list->data));
	else
		gtk_widget_hide(GTK_WIDGET(list->data));
	config_set_int("settings/show_toolbar", visible);
	g_slist_free(list);
}
Exemplo n.º 20
0
static void rc_plugin_tag_edit_menu_cb()
{
    GtkTreeIter iter;
    gchar *uri = NULL;
    GtkAction *action;
    action = gtk_ui_manager_get_action(rc_gui_get_ui_manager(),
        "/RCMenuBar/ViewMenu/ViewPlaylist");
    gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), table_id+3);
    if(rc_gui_list2_get_cursor(&iter))
    {
        gtk_tree_model_get(rc_gui_list2_get_model(), &iter,
            PLIST2_URI, &uri, -1);
        if(uri!=NULL)
        {
            rc_plugin_tag_read_uri(uri);
            g_free(uri);
        }
    }
}
Exemplo n.º 21
0
static void
anjuta_app_instance_init (AnjutaApp *app)
{
	gint merge_id;
	GtkWidget *menubar, *about_menu;
	GtkWidget *view_menu, *hbox;
	GtkWidget *main_box;
	GtkWidget *dockbar;
	GtkAction* action;
	GList *plugins_dirs = NULL;
	gchar* style;
	GdkGeometry size_hints = {
    	100, 100, 0, 0, 100, 100, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  	};
	
	DEBUG_PRINT ("%s", "Initializing Anjuta...");
	
	gtk_window_set_geometry_hints (GTK_WINDOW (app), GTK_WIDGET (app),
								   &size_hints, GDK_HINT_RESIZE_INC);
	gtk_window_set_resizable (GTK_WINDOW (app), TRUE);
	
	/*
	 * Main box
	 */
	main_box = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (app), main_box);
	gtk_widget_show (main_box);
	
	app->values = NULL;
	app->widgets = NULL;
	
	/* Status bar */
	app->status = ANJUTA_STATUS (anjuta_status_new ());
	anjuta_status_set_title_window (app->status, GTK_WIDGET (app));
	gtk_widget_show (GTK_WIDGET (app->status));
	gtk_box_pack_end (GTK_BOX (main_box),
					  GTK_WIDGET (app->status), FALSE, TRUE, 0);
	g_object_ref (G_OBJECT (app->status));
	g_object_add_weak_pointer (G_OBJECT (app->status), (gpointer)&app->status);
	
	/* configure dock */
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox);
	app->dock = gdl_dock_new ();
	gtk_widget_show (app->dock);
	gtk_box_pack_end(GTK_BOX (hbox), app->dock, TRUE, TRUE, 0);
	
	dockbar = gdl_dock_bar_new (GDL_DOCK(app->dock));
	gtk_widget_show (dockbar);
	gtk_box_pack_start(GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);
	
	app->layout_manager = gdl_dock_layout_new (GDL_DOCK (app->dock));
	g_signal_connect (app->layout_manager, "notify::dirty",
					  G_CALLBACK (on_layout_dirty_notify), app);
	g_signal_connect (app->layout_manager->master, "notify::locked",
					  G_CALLBACK (on_layout_locked_notify), app);
	
	/* UI engine */
	app->ui = anjuta_ui_new ();
	g_object_add_weak_pointer (G_OBJECT (app->ui), (gpointer)&app->ui);
	/* show tooltips in the statusbar */
	g_signal_connect (app->ui,
			  "connect_proxy",
			  G_CALLBACK (connect_proxy_cb),
			  app);
	g_signal_connect (app->ui,
			  "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb),
			  app);
	
	/* Plugin Manager */
	plugins_dirs = g_list_prepend (plugins_dirs, PACKAGE_PLUGIN_DIR);
	app->plugin_manager = anjuta_plugin_manager_new (G_OBJECT (app),
													 app->status,
													 plugins_dirs);
	app->profile_manager = anjuta_profile_manager_new (app->plugin_manager);
	g_list_free (plugins_dirs);
	
	/* Preferences */
	app->preferences = anjuta_preferences_new (app->plugin_manager);
	g_object_add_weak_pointer (G_OBJECT (app->preferences),
							   (gpointer)&app->preferences);
	
	anjuta_preferences_notify_add_string (app->preferences, "anjuta.gdl.style",
	                                      on_gdl_style_changed, app, NULL);
	style = anjuta_preferences_get (app->preferences, "anjuta.gdl.style");
	
	on_gdl_style_changed (app->preferences, NULL, 
	                      style, app);
	g_free (style);
	
	/* Register actions */
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupFile", _("File"),
										menu_entries_file,
										G_N_ELEMENTS (menu_entries_file),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupEdit", _("Edit"),
										menu_entries_edit,
										G_N_ELEMENTS (menu_entries_edit),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupView", _("View"),
										menu_entries_view,
										G_N_ELEMENTS (menu_entries_view),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_toggle_action_group_entries (app->ui, "ActionGroupToggleView",
										_("View"),
										menu_entries_toggle_view,
										G_N_ELEMENTS (menu_entries_toggle_view),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupHelp", _("Help"),
										menu_entries_help,
										G_N_ELEMENTS (menu_entries_help),
										GETTEXT_PACKAGE, TRUE, app);

	/* Merge UI */
	merge_id = anjuta_ui_merge (app->ui, UI_FILE);
	
	/* Adding accels group */
	gtk_window_add_accel_group (GTK_WINDOW (app), 
								gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (app->ui)));
	
	/* create main menu */
	menubar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (app->ui),
										 "/MenuMain");
	gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);
	
	/* create toolbar */	
	app->toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (app->ui),
										 "/ToolbarMain");
    if (!anjuta_preferences_get_bool (app->preferences, "anjuta.toolbar.visible"))
		gtk_widget_hide (app->toolbar);
	gtk_box_pack_start (GTK_BOX (main_box), app->toolbar, FALSE, FALSE, 0);
	action = gtk_ui_manager_get_action (GTK_UI_MANAGER (app->ui),
										"/MenuMain/MenuView/Toolbar");
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action),
								  anjuta_preferences_get_bool_with_default (app->preferences,
																		   "anjuta.toolbar.visible",
																		   TRUE));
	anjuta_preferences_notify_add_string (app->preferences, "anjuta.toolbar.style",
								   on_toolbar_style_changed, app, NULL);
	style = anjuta_preferences_get (app->preferences, "anjuta.toolbar.style");
	on_toolbar_style_changed (app->preferences, NULL, style, app);
	g_free (style);

	/* Create widgets menu */
	view_menu = 
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(app->ui),
								  "/MenuMain/MenuView");
	app->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));	

	/* Disable unavailible tutorials */
	action = anjuta_ui_get_action(app->ui, "ActionGroupHelp", "ActionHelpTutorial");
	g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
	action = anjuta_ui_get_action(app->ui, "ActionGroupHelp", "ActionHelpAdvancedTutorial");
	g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
	
	/* Create about plugins menu */
	about_menu = 
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(app->ui),
								   "/MenuMain/PlaceHolderHelpMenus/MenuHelp/"
								   "PlaceHolderHelpAbout/AboutPlugins");
	about_create_plugins_submenu (ANJUTA_SHELL (app), about_menu);
	
	/* Add main view */
	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);
						
	/* Connect to session */
	g_signal_connect (G_OBJECT (app), "save_session",
					  G_CALLBACK (on_session_save), app);
	g_signal_connect (G_OBJECT (app), "load_session",
					  G_CALLBACK (on_session_load), app);
	
	/* Loading accels */
	anjuta_ui_load_accels (NULL);

	app->save_count = 0;
}
Exemplo n.º 22
0
void gtkui_create_menu(int live)
{
   GtkAccelGroup *accel_group;
   GtkWidget *vbox, *main_menu;
   GtkActionGroup *menuactions;
   GtkAction *action;
   GError *error = NULL;
   GClosure *closure = NULL;
   gint keyval;
   GdkModifierType mods;
   
   const gchar *menu_structure = 
      "<ui>"
      "  <menubar name='MenuBar'>"
      "     <menu name='StartMenu' action='StartMenuAction'>"
      "        <menuitem name='SniffStart' action='SniffStartAction' />"
      "        <menuitem name='SniffStop' action='SniffStopAction' />"
      "        <separator />"
      "        <menuitem name='Exit' action='ExitAction' />"
      "     </menu>"
      "     <menu name='TargetsMenu' action='TargetsMenuAction'>"
      "        <menuitem name='CurrentTargets' action='CurrentTargetsAction' />"
      "        <menuitem name='SelectTargets' action='SelectTargetsAction' />"
      "        <separator />"
      "        <menuitem name='Protocol' action='ProtocolAction' />"
      "        <menuitem name='ReverseMatching' action='ReverseMatchingAction' />"
      "        <separator />"
      "        <menuitem name='WipeTargets' action='WipeTargetsAction' />"
      "     </menu>"
      "     <menu name='HostsMenu' action='HostsMenuAction'>"
      "        <menuitem name='HostsList' action='HostsListAction' />"
      "        <separator />"
#ifdef WITH_IPV6
      "        <menuitem name='EnableIPv6Scan' action='EnableIPv6ScanAction' />"
#endif
      "        <menuitem name='ScanHosts' action='ScanHostsAction' />"
      "        <menuitem name='LoadHosts' action='LoadHostsAction' />"
      "        <menuitem name='SaveHosts' action='SaveHostsAction' />"
      "     </menu>"
      "     <menu name='ViewMenu' action='ViewMenuAction'>"
      "        <menuitem name='ViewConnections' action='ViewConnectionsAction' />"
      "        <menuitem name='ViewProfiles' action='ViewProfilesAction' />"
      "        <menuitem name='ViewStatistics' action='ViewStatisticsAction' />"
      "        <separator />"
      "        <menuitem name='ResolveIpAddresses' action='ResolveIpAddressesAction' />"
      "        <menuitem name='VisualisationMethod' action='VisualisationMethodAction' />"
      "        <menuitem name='VisualisationRegex' action='VisualisationRegexAction' />"
      "        <separator />"
      "        <menuitem name='SetWifiKey' action='SetWifiKeyAction' />"
      "     </menu>"
      "     <menu name='MitmMenu' action='MitmMenuAction'>"
      "        <menuitem name='ArpPoisoning' action='ArpPoisoningAction' />"
      "        <menuitem name='IcmpRedirect' action='IcmpRedirectAction' />"
      "        <menuitem name='PortStealing' action='PortStealingAction' />"
      "        <menuitem name='DhcpSpoofing' action='DhcpSpoofingAction' />"
#ifdef WITH_IPV6
      "        <menuitem name='NdpPoisoning' action='NdpPoisoningAction' />"
#endif
      "        <separator />"
      "        <menuitem name='StopMitmAttacks' action='StopMitmAttacksAction' />"
      "     </menu>"
      "     <menu name='FiltersMenu' action='FiltersMenuAction'>"
      "        <menuitem name='LoadFilter' action='LoadFilterAction' />"
      "        <menuitem name='StopFilter' action='StopFilterAction' />"
      "     </menu>"
      "     <menu name='LoggingMenu' action='LoggingMenuAction'>"
      "        <menuitem name='LoggingAll' action='LoggingAllAction' />"
      "        <menuitem name='LoggingInfo' action='LoggingInfoAction' />"
      "        <menuitem name='LoggingStop' action='LoggingStopAction' />"
      "        <separator />"
      "        <menuitem name='LogMessages' action='LogMessagesAction' />"
      "        <menuitem name='LogMessagesStop' action='LogMessagesStopAction' />"
      "        <separator />"
      "        <menuitem name='LogCompressed' action='LogCompressedAction' />"
      "     </menu>"
#ifdef HAVE_PLUGINS
      "     <menu name='PluginsMenu' action='PluginsMenuAction'>"
      "        <menuitem name='ManagePlugins' action='ManagePluginsAction' />"
      "        <menuitem name='LoadPlugin' action='LoadPluginAction' />"
      "     </menu>"
#endif
      "     <menu name='HelpMenu' action='HelpMenuAction'>"
#ifndef OS_WINDOWS
      "        <menuitem name='Help' action='HelpAction' />"
#endif
      "        <menuitem name='About' action='AboutDialogAction' />"
      "     </menu>"
      "  </menubar>"
      "</ui>";


   GtkActionEntry start_menu_items[] = {
      /* Start Menu */
      {
         "StartMenuAction", NULL, 
         "_Start", NULL, 
         NULL, NULL
      },

      {
         "SniffStartAction", GTK_STOCK_YES,
         "Start sniffing", "<control><shift>w",
         NULL, G_CALLBACK(gtkui_start_sniffing)
      },

      {
         "SniffStopAction", GTK_STOCK_NO,
         "Stop sniffing", "<control><shift>e",
         NULL, G_CALLBACK(gtkui_stop_sniffing)
      },

      {
         "ExitAction", GTK_STOCK_QUIT,
         "E_xit", "<control>q",
         NULL, G_CALLBACK(gtkui_exit)
      }
   };

   GtkActionEntry targets_menu_items[] = {
      /* Targets Menu */
      {
         "TargetsMenuAction", NULL,
         "_Targets", NULL,
         NULL, NULL
      },

      {
         "CurrentTargetsAction", GTK_STOCK_FIND,
         "Current targets", "<control>t",
         NULL, G_CALLBACK(gtkui_current_targets)
      },

      {
         "SelectTargetsAction", GTK_STOCK_ADD,
         "Select target(s)", "<control><shift>t",
         NULL, G_CALLBACK(gtkui_select_targets)
      },

      {
         "ProtocolAction", GTK_STOCK_JUMP_TO,
         "_Protocol...", "<control>p",
         NULL, G_CALLBACK(gtkui_select_protocol)
      },

      {
         "WipeTargetsAction", GTK_STOCK_CLEAR,
         "_Wipe targets", "<control>W",
         NULL, G_CALLBACK(wipe_targets)
      }
   };

   GtkActionEntry hosts_menu_items[] = {
      /* Hosts Menu */
      {
         "HostsMenuAction", NULL,
         "_Hosts", NULL,
         NULL, NULL
      },

      {
         "HostsListAction", GTK_STOCK_INDEX,
         "_Hosts list", "<control>h",
         NULL, G_CALLBACK(gtkui_host_list)
      },

      {
         "ScanHostsAction", GTK_STOCK_FIND,
         "_Scan for hosts", "<control>s",
         NULL, G_CALLBACK(gtkui_scan)
      },

      {
         "LoadHostsAction", GTK_STOCK_OPEN,
         "Load from file...", "",
         NULL, G_CALLBACK(gtkui_load_hosts)
      },

      {
         "SaveHostsAction", GTK_STOCK_SAVE,
         "Save to file...", "",
         NULL, G_CALLBACK(gtkui_save_hosts)
      }
   };

   GtkActionEntry view_menu_items[] = {
      /* View Menu */
      {
         "ViewMenuAction", NULL,
         "_View", NULL,
         NULL, NULL
      },

      {
         "ViewConnectionsAction", GTK_STOCK_JUSTIFY_FILL,
         "_Connections", "<control><shift>c",
         NULL, G_CALLBACK(gtkui_show_connections)
      },

      {
         "ViewProfilesAction", GTK_STOCK_JUSTIFY_LEFT,
         "Pr_ofiles", "<control>o",
         NULL, G_CALLBACK(gtkui_show_profiles)
      },

      {
         "ViewStatisticsAction", GTK_STOCK_PROPERTIES,
         "_Statistics", NULL,
         NULL, G_CALLBACK(gtkui_show_stats)
      },

      {
         "VisualisationMethodAction", GTK_STOCK_PREFERENCES,
         "_Visualisation method...", "<control><shift>v",
         NULL, G_CALLBACK(gtkui_vis_method)
      },

      {
         "VisualisationRegexAction", GTK_STOCK_FIND,
         "Visualisation _regex...", "<control>R",
         NULL, G_CALLBACK(gtkui_vis_regex)
      },

      {
         "SetWifiKeyAction", GTK_STOCK_FIND,
         "Set the _WiFi key...", NULL,
         NULL, G_CALLBACK(gtkui_wifi_key)
      }
   };

   GtkActionEntry mitm_menu_items[] = {
      /* Mitm Menu */
      {
         "MitmMenuAction", NULL,
         "_Mitm", NULL,
         NULL, NULL
      },

      {
         "ArpPoisoningAction", NULL,
         "ARP poisoning...", NULL,
         NULL, G_CALLBACK(gtkui_arp_poisoning)
      },

      {
         "IcmpRedirectAction", NULL,
         "ICMP redirect...", NULL,
         NULL, G_CALLBACK(gtkui_icmp_redir)
      },

      {
         "PortStealingAction", NULL,
         "Port stealing...", NULL,
         NULL, G_CALLBACK(gtkui_port_stealing)
      },

      {
         "DhcpSpoofingAction", NULL,
         "DHCP spoofing...", NULL,
         NULL, G_CALLBACK(gtkui_dhcp_spoofing)
      },

#ifdef WITH_IPV6
      {
         "NdpPoisoningAction", NULL,
         "NDP poisoning...", NULL,
         NULL, G_CALLBACK(gtkui_ndp_poisoning)
      },
#endif

      { 
         "StopMitmAttacksAction", NULL,
         "Stop mitm attack(s)", NULL,
         NULL, G_CALLBACK(gtkui_mitm_stop)
      }
   };

   GtkActionEntry filters_menu_items[] = {
      /* Filters Menu */
      {
         "FiltersMenuAction", NULL,
         "_Filters", NULL,
         NULL, NULL
      },

      {
         "LoadFilterAction", GTK_STOCK_OPEN,
         "Load a filter...", "<control>f",
         NULL, G_CALLBACK(gtkui_load_filter)
      },

      {
         "StopFilterAction", GTK_STOCK_STOP,
         "Stop _filtering", "<control><shift>f",
         NULL, G_CALLBACK(gtkui_stop_filter)
      }
   };

   GtkActionEntry logging_menu_items[] = {
      /* Logging Menu */
      {
         "LoggingMenuAction", NULL,
         "_Logging", NULL,
         NULL, NULL
      },

      {
         "LoggingAllAction", GTK_STOCK_SAVE,
         "Logging all packets and infos...", "<control><shift>i",
         NULL, G_CALLBACK(gtkui_log_all)
      },

      {
         "LoggingInfoAction", GTK_STOCK_SAVE_AS,
         "Logging only infos...", "<control>i",
         NULL, G_CALLBACK(gtkui_log_info)
      },

      {
         "LoggingStopAction", GTK_STOCK_STOP,
         "Stop logging infos", NULL,
         NULL, G_CALLBACK(gtkui_stop_log)
      },

      {
         "LogMessagesAction", GTK_STOCK_REVERT_TO_SAVED,
         "Log user messages...", "<control>m",
         NULL, G_CALLBACK(gtkui_log_msg)
      },

      {
         "LogMessagesStopAction", GTK_STOCK_STOP,
         "Stop logging messages", NULL,
         NULL, G_CALLBACK(gtkui_stop_msg)
      }
   };

#ifdef HAVE_PLUGINS
   GtkActionEntry plugins_menu_items[] = {
      /* Plugins Menu */
      {
         "PluginsMenuAction", NULL,
         "_Plugins", NULL,
         NULL, NULL
      },

      {
         "ManagePluginsAction", GTK_STOCK_EXECUTE,
         "Manage the plugins", "<control>p",
         NULL, G_CALLBACK(gtkui_plugin_mgmt)
      },

      {
         "LoadPluginAction", GTK_STOCK_OPEN,
         "Load a plugin...", NULL,
         NULL, G_CALLBACK(gtkui_plugin_load)
      }
   };
#endif

   GtkActionEntry help_menu_items[] = {
      /* Help Menu */
      {
         "HelpMenuAction", NULL,
         "_Info", NULL,
         NULL, NULL
      },

#ifndef OS_WINDOWS
      {
         "HelpAction", GTK_STOCK_HELP,
         "Help", "F1",
         NULL, G_CALLBACK(gtkui_help)
      },
#endif
      {
         "AboutDialogAction", GTK_STOCK_ABOUT,
         "About", NULL,
         NULL, G_CALLBACK(gtkui_about)
      }
   };

   GtkToggleActionEntry toggle_items[] = {
      {
         "ReverseMatchingAction", NULL,
         "Reverse matching", NULL,
         NULL, G_CALLBACK(toggle_reverse),
         FALSE
      },

#ifdef WITH_IPV6
      {
         "EnableIPv6ScanAction", NULL,
         "Enable IPv6 scan", NULL,
         NULL, G_CALLBACK(toggle_ip6scan),
         FALSE
      },
#endif

      {
         "ResolveIpAddressesAction", NULL,
         "Resolve IP addresses", NULL,
         NULL, G_CALLBACK(toggle_resolve),
         FALSE
      },

      {
         "LogCompressedAction", NULL,
         "Compressed file", NULL,
         NULL, G_CALLBACK(toggle_compress),
         FALSE
      }
   };

   DEBUG_MSG("gtk_create_menu");

   /* remove old menu, it will be automatically destroyed by gtk_main */
   vbox = gtk_bin_get_child(GTK_BIN (window));
   main_menu = gtk_ui_manager_get_widget(menu_manager, "/MenuBar");
   gtk_widget_hide(main_menu);
   gtk_ui_manager_remove_ui(menu_manager, merge_id);

   menuactions = gtk_action_group_new("MenuActions");
   /* Start Menu */
   gtk_action_group_add_actions(menuactions, start_menu_items, G_N_ELEMENTS(start_menu_items), NULL);
   /* Targets Menu */
   gtk_action_group_add_actions(menuactions, targets_menu_items, G_N_ELEMENTS(targets_menu_items), NULL);
   /* Hosts Menu */
   gtk_action_group_add_actions(menuactions, hosts_menu_items, G_N_ELEMENTS(hosts_menu_items), NULL);
   /* View Menu */
   gtk_action_group_add_actions(menuactions, view_menu_items, G_N_ELEMENTS(view_menu_items), NULL);
   /* MITM Menu */
   gtk_action_group_add_actions(menuactions, mitm_menu_items, G_N_ELEMENTS(mitm_menu_items), NULL);
   /* Filters Menu */
   gtk_action_group_add_actions(menuactions, filters_menu_items, G_N_ELEMENTS(filters_menu_items), NULL);
   /* Logging Menu */
   gtk_action_group_add_actions(menuactions, logging_menu_items, G_N_ELEMENTS(logging_menu_items), NULL);
#ifdef HAVE_PLUGINS
   /* Plugins Menu */
   gtk_action_group_add_actions(menuactions, plugins_menu_items, G_N_ELEMENTS(plugins_menu_items), NULL);
#endif
#ifndef OS_WINDOWS
   /* Help Menu */
   gtk_action_group_add_actions(menuactions, help_menu_items, G_N_ELEMENTS(help_menu_items), NULL);
#endif

   gtk_action_group_add_toggle_actions(menuactions, toggle_items, G_N_ELEMENTS(toggle_items), NULL);

   menu_manager = gtk_ui_manager_new();
   gtk_ui_manager_insert_action_group(menu_manager, menuactions, 0);

   merge_id = gtk_ui_manager_add_ui_from_string(menu_manager, menu_structure, -1, &error);
   if (error) {
      g_message("building menu failed: %s", error->message);
      g_error_free(error);
      error = NULL;
   }

   /* Some hidden accellerators */
   accel_group = gtk_accel_group_new ();
   closure = g_cclosure_new(G_CALLBACK(gtkui_exit), NULL, NULL);
   gtk_accelerator_parse("<control>X", &keyval, &mods);
   gtk_accel_group_connect(accel_group, keyval, mods, 0, closure);
   gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
   gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(menu_manager));

   

   if(GBL_OPTIONS->reversed) {
      GBL_OPTIONS->reversed = 0;
      action = gtk_ui_manager_get_action(menu_manager, "/MenuBar/TargetsMenu/ReverseMatching");
      gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
   }

   if(GBL_OPTIONS->resolve) {
      GBL_OPTIONS->resolve = 0;
      action = gtk_ui_manager_get_action(menu_manager, "/MenuBar/ViewMenu/ResolveIpAddresses");
      gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
   }

   if(GBL_OPTIONS->compress) {
      GBL_OPTIONS->compress = 0;
      action = gtk_ui_manager_get_action(menu_manager, "/MenuBar/LoggingMenu/LogCompressed");
      gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
   }

   /* Some menus doesn't apply if started in offline or bridged sniffing mode */
   if (live == 0 || GBL_SNIFF->type == SM_BRIDGED) {
      gtk_widget_set_visible(gtk_ui_manager_get_widget(menu_manager, "/MenuBar/HostsMenu"), FALSE);
      gtk_widget_set_visible(gtk_ui_manager_get_widget(menu_manager, "/MenuBar/MitmMenu"), FALSE);
   }

#ifdef HAVE_PLUGINS
   if (live == 0)
      gtk_widget_set_visible(gtk_ui_manager_get_widget(menu_manager, "/MenuBar/PluginsMenu"), FALSE);
#endif

   /* get the menu widget and add it to the window */
   main_menu = gtk_ui_manager_get_widget(menu_manager, "/MenuBar");
   gtk_box_pack_start(GTK_BOX(vbox), main_menu, FALSE, FALSE, 0);
   gtk_widget_show(main_menu);
   
}
Exemplo n.º 23
0
static void
anjuta_window_instance_init (AnjutaWindow *win)
{
	GtkWidget *menubar, *about_menu;
	GtkWidget *view_menu, *hbox;
	GtkWidget *main_box;
	GtkWidget *dockbar;
	GtkAction* action;
	GList *plugins_dirs = NULL;
	GdkGeometry size_hints = {
    	100, 100, 0, 0, 100, 100, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  	};

	DEBUG_PRINT ("%s", "Initializing Anjuta...");

	gtk_window_set_geometry_hints (GTK_WINDOW (win), GTK_WIDGET (win),
								   &size_hints, GDK_HINT_RESIZE_INC);
	gtk_window_set_resizable (GTK_WINDOW (win), TRUE);

	/*
	 * Main box
	 */
	main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add (GTK_CONTAINER (win), main_box);
	gtk_widget_show (main_box);

	win->values = NULL;
	win->widgets = NULL;
	win->maximized = FALSE;

	/* Settings */
	win->settings = g_settings_new (PREF_SCHEMA);

	/* Status bar */
	win->status = ANJUTA_STATUS (anjuta_status_new ());
	anjuta_status_set_title_window (win->status, GTK_WIDGET (win));
	gtk_widget_show (GTK_WIDGET (win->status));
	gtk_box_pack_end (GTK_BOX (main_box),
					  GTK_WIDGET (win->status), FALSE, TRUE, 0);
	g_object_ref (G_OBJECT (win->status));
	g_object_add_weak_pointer (G_OBJECT (win->status), (gpointer)&win->status);

	/* configure dock */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_show (hbox);
	win->dock = gdl_dock_new ();
	gtk_widget_show (win->dock);
	gtk_box_pack_end(GTK_BOX (hbox), win->dock, TRUE, TRUE, 0);

	dockbar = gdl_dock_bar_new (G_OBJECT (win->dock));
	gtk_widget_show (dockbar);
	gtk_box_pack_start(GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);

	win->layout_manager = gdl_dock_layout_new (G_OBJECT (win->dock));
	g_signal_connect (win->layout_manager, "notify::dirty",
					  G_CALLBACK (on_layout_dirty_notify), win);
	g_signal_connect (gdl_dock_layout_get_master (win->layout_manager), "notify::locked",
					  G_CALLBACK (on_layout_locked_notify), win);

	/* UI engine */
	win->ui = anjuta_ui_new ();
	g_object_add_weak_pointer (G_OBJECT (win->ui), (gpointer)&win->ui);
	/* show tooltips in the statusbar */
	g_signal_connect (win->ui,
			  "connect_proxy",
			  G_CALLBACK (connect_proxy_cb),
			  win);
	g_signal_connect (win->ui,
			  "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb),
			  win);

	/* Plugin Manager */
	plugins_dirs = g_list_prepend (plugins_dirs, PACKAGE_PLUGIN_DIR);
	win->plugin_manager = anjuta_plugin_manager_new (G_OBJECT (win),
													 win->status,
													 plugins_dirs);
	win->profile_manager = anjuta_profile_manager_new (win->plugin_manager);
	g_list_free (plugins_dirs);

	/* Preferences */
	win->preferences = anjuta_preferences_new (win->plugin_manager, PREF_SCHEMA);
	g_object_add_weak_pointer (G_OBJECT (win->preferences),
							   (gpointer)&win->preferences);

	g_signal_connect (win->settings, "changed::" GDL_STYLE,
	                  G_CALLBACK (on_gdl_style_changed), win);
	on_gdl_style_changed (win->settings, GDL_STYLE, win);

	/* Register actions */
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupFile", _("File"),
										menu_entries_file,
										G_N_ELEMENTS (menu_entries_file),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupEdit", _("Edit"),
										menu_entries_edit,
										G_N_ELEMENTS (menu_entries_edit),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupView", _("View"),
										menu_entries_view,
										G_N_ELEMENTS (menu_entries_view),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_toggle_action_group_entries (win->ui, "ActionGroupToggleView",
										_("View"),
										menu_entries_toggle_view,
										G_N_ELEMENTS (menu_entries_toggle_view),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupHelp", _("Help"),
										menu_entries_help,
										G_N_ELEMENTS (menu_entries_help),
										GETTEXT_PACKAGE, TRUE, win);

	/* Merge UI */
	anjuta_ui_merge (win->ui, UI_FILE);

	/* Adding accels group */
	gtk_window_add_accel_group (GTK_WINDOW (win),
								gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (win->ui)));

	/* create main menu */
	menubar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (win->ui),
										 "/MenuMain");
	gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);

	/* create toolbar */
	win->toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (win->ui),
										 "/ToolbarMain");
    if (!g_settings_get_boolean (win->settings, TOOLBAR_VISIBLE))
		gtk_widget_hide (win->toolbar);
	gtk_style_context_add_class (gtk_widget_get_style_context (win->toolbar),
	                             GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	gtk_toolbar_set_icon_size (GTK_TOOLBAR (win->toolbar),
	                           GTK_ICON_SIZE_MENU);
	gtk_box_pack_start (GTK_BOX (main_box), win->toolbar, FALSE, FALSE, 0);
	action = gtk_ui_manager_get_action (GTK_UI_MANAGER (win->ui),
										"/MenuMain/MenuView/Toolbar");
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action),
								  g_settings_get_boolean (win->settings,
								                          TOOLBAR_VISIBLE));
	g_signal_connect (win->settings, "changed::" TOOLBAR_STYLE,
	                  G_CALLBACK (on_toolbar_style_changed), win);
	on_toolbar_style_changed (win->settings, TOOLBAR_STYLE, win);

	/* Create widgets menu */
	view_menu =
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(win->ui),
								  "/MenuMain/MenuView");
	win->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));

	/* Create about plugins menu */
	about_menu =
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(win->ui),
								   "/MenuMain/PlaceHolderHelpMenus/MenuHelp/"
								   "PlaceHolderHelpAbout/AboutPlugins");
	about_create_plugins_submenu (ANJUTA_SHELL (win), about_menu);

	/* Add main view */
	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);

	/* Connect to session */
	g_signal_connect (G_OBJECT (win), "save_session",
					  G_CALLBACK (on_session_save), win);
	g_signal_connect (G_OBJECT (win), "load_session",
					  G_CALLBACK (on_session_load), win);

	/* Loading accels */
	anjuta_ui_load_accels (NULL);

	win->save_count = 0;
}
Exemplo n.º 24
0
static VALUE
rg_get_action(VALUE self, VALUE path)
{
    return GOBJ2RVAL(gtk_ui_manager_get_action(_SELF(self), RVAL2CSTR(path)));
}
Exemplo n.º 25
0
static void
set_up_tree_view (TotemYouTubePlugin *self, GtkBuilder *builder, guint key)
{
	GtkUIManager *ui_manager;
	GtkActionGroup *action_group;
	GtkAction *action, *menu_item;
	GtkWidget *vscroll, *tree_view;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;

	/* Add the cell renderer. This can't be done with GtkBuilder, because it unavoidably sets the expand parameter to FALSE */
	/* TODO: Depends on bug #453692 */
	renderer = GTK_CELL_RENDERER (totem_cell_renderer_video_new (TRUE));
	column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder,
							       (key == SEARCH_TREE_VIEW) ? "yt_treeview_search_column" : "yt_treeview_related_column"));
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_set_attributes (column, renderer, "thumbnail", 0, "title", 1, NULL);

	/* Give the video lists a handle to Totem and connect their scrollbar signals */
	if (key == SEARCH_TREE_VIEW) {
		tree_view = GTK_WIDGET (gtk_builder_get_object (builder, "yt_treeview_search"));
		vscroll = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "yt_scrolled_window_search")));
		self->list_store[key] = GTK_LIST_STORE (gtk_builder_get_object (builder, "yt_list_store_search"));
		self->tree_view[key] = GTK_TREE_VIEW (tree_view);
		self->progress_bar[key] = GTK_PROGRESS_BAR (gtk_builder_get_object (builder, "yt_progress_bar_search"));
	} else {
		tree_view = GTK_WIDGET (gtk_builder_get_object (builder, "yt_treeview_related"));
		vscroll = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "yt_scrolled_window_related")));
		self->list_store[key] = GTK_LIST_STORE (gtk_builder_get_object (builder, "yt_list_store_related"));
		self->tree_view[key] = GTK_TREE_VIEW (tree_view);
		self->progress_bar[key] = GTK_PROGRESS_BAR (gtk_builder_get_object (builder, "yt_progress_bar_related"));
	}
	g_object_set (tree_view, "totem", self->totem, NULL);
	g_signal_connect (vscroll, "button-press-event", G_CALLBACK (button_press_event_cb), self);
	g_signal_connect (vscroll, "button-release-event", G_CALLBACK (button_release_event_cb), self);

	/* Add the extra popup menu options. This is done here rather than in the UI file, because it's done for multiple treeviews;
	 * if it were done in the UI file, the same action group would be used multiple times, which GTK+ doesn't like. */
	ui_manager = totem_video_list_get_ui_manager (TOTEM_VIDEO_LIST (tree_view));
	action_group = gtk_action_group_new ("youtube-action-group");
	action = gtk_action_new ("open-in-web-browser", _("_Open in Web Browser"), _("Open the video in your web browser"), "gtk-jump-to");
	gtk_action_group_add_action_with_accel (action_group, action, NULL);

	gtk_ui_manager_insert_action_group (ui_manager, action_group, 1);
	gtk_ui_manager_add_ui (ui_manager, gtk_ui_manager_new_merge_id (ui_manager),
			       "/ui/totem-video-list-popup/",
			       "open-in-web-browser",
			       "open-in-web-browser",
			       GTK_UI_MANAGER_MENUITEM,
			       FALSE);

	menu_item = gtk_ui_manager_get_action (ui_manager, "/ui/totem-video-list-popup/open-in-web-browser");
	g_signal_connect (menu_item, "activate", G_CALLBACK (open_in_web_browser_activate_cb), self);

	/* Connect to more scroll events */
	#if GTK_CHECK_VERSION(3, 0, 0)
		self->vadjust[key] = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(tree_view));
	#else
		self->vadjust[key] = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(tree_view));
	#endif

	g_signal_connect (self->vadjust[key], "value-changed", G_CALLBACK (value_changed_cb), self);

	self->cancel_button = GTK_WIDGET (gtk_builder_get_object (builder, "yt_cancel_button"));
}
Exemplo n.º 26
0
void
browser_dialog_open (const gchar *plug_in_binary)
{
  GtkWidget   *window;
  GtkWidget   *main_vbox;
  GtkWidget   *vbox;
  GtkWidget   *toolbar;
  GtkWidget   *paned;
  GtkWidget   *scrolled;
  GtkToolItem *item;
  GtkAction   *action;
  DialogData   data = { 720, 560, 240, TRUE, 1.0 };

  gimp_ui_init (plug_in_binary, TRUE);

  gimp_get_data (GIMP_HELP_BROWSER_DIALOG_DATA, &data);

  /*  the dialog window  */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), _("GIMP Help Browser"));
  gtk_window_set_role (GTK_WINDOW (window), plug_in_binary);

  gtk_window_set_default_size (GTK_WINDOW (window), data.width, data.height);

  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  window_set_icons (window);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  ui_manager = ui_manager_new (window);

  toolbar = gtk_ui_manager_get_widget (ui_manager, "/help-browser-toolbar");
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
  gtk_widget_show (toolbar);

  item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
  gtk_widget_show (GTK_WIDGET (item));

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/forward");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
  g_object_notify (G_OBJECT (action), "tooltip");
  button_next = GTK_WIDGET (item);

  item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
  gtk_widget_show (GTK_WIDGET (item));

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/back");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
  g_object_notify (G_OBJECT (action), "tooltip");
  button_prev = GTK_WIDGET (item);

  item =
    GTK_TOOL_ITEM (gtk_ui_manager_get_widget (ui_manager,
                                              "/help-browser-toolbar/space"));
  gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
  gtk_tool_item_set_expand (item, TRUE);

  /*  the horizontal paned  */
  paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (GTK_BOX (vbox), paned, TRUE, TRUE, 0);
  gtk_widget_show (paned);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_paned_add1 (GTK_PANED (paned), scrolled);
  gtk_paned_set_position (GTK_PANED (paned), data.paned_position);

  sidebar = scrolled;

  if (data.show_index)
    gtk_widget_show (sidebar);

  tree_view = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
  gtk_container_add (GTK_CONTAINER (scrolled), tree_view);
  gtk_widget_show (tree_view);

  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1,
                                               NULL,
                                               gtk_cell_renderer_text_new (),
                                               "text", 1,
                                               NULL);

  g_signal_connect (tree_view, "row-activated",
                    G_CALLBACK (row_activated),
                    NULL);

  /*  HTML view  */
  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_widget_show (main_vbox);
  gtk_paned_pack2 (GTK_PANED (paned), main_vbox, TRUE, TRUE);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  gtk_widget_set_size_request (scrolled, 300, 200);
  gtk_box_pack_start (GTK_BOX (main_vbox), scrolled, TRUE, TRUE, 0);
  gtk_widget_show (scrolled);

  view = webkit_web_view_new ();
  webkit_web_view_set_maintains_back_forward_list (WEBKIT_WEB_VIEW (view),
                                                   TRUE);
  gtk_container_add (GTK_CONTAINER (scrolled), view);
  gtk_widget_show (view);

  g_signal_connect (view, "realize",
                    G_CALLBACK (view_realize),
                    NULL);
  g_signal_connect (view, "unrealize",
                    G_CALLBACK (view_unrealize),
                    NULL);

  g_signal_connect (view, "popup-menu",
                    G_CALLBACK (view_popup_menu),
                    NULL);
  g_signal_connect (view, "button-press-event",
                    G_CALLBACK (view_button_press),
                    NULL);
  g_signal_connect (view, "key-press-event",
                    G_CALLBACK (view_key_press),
                    NULL);

  webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (view), data.zoom);

  g_signal_connect (view, "title-changed",
                    G_CALLBACK (title_changed),
                    window);

  g_signal_connect (view, "load-started",
                    G_CALLBACK (load_started),
                    NULL);
  g_signal_connect (view, "load-finished",
                    G_CALLBACK (load_finished),
                    NULL);

  gtk_widget_grab_focus (view);

  g_signal_connect (window, "unmap",
                    G_CALLBACK (dialog_unmap),
                    paned);

  update_actions ();

  /* Searchbar */
  searchbar = build_searchbar ();
  gtk_box_pack_start (GTK_BOX (main_vbox), searchbar, FALSE, FALSE, 0);
}
Exemplo n.º 27
0
static GtkAction *getAction(GuiEvent id)
{
	const gchar *path = NULL;
	gchar *full_path;
	GtkAction *action;
#ifdef ADMIN_GTK
	frontend_gui_register_action(gtk_ui_manager_get_action
				     (manager,
				      "ui/MainMenu/GameMenu/GameAdmin"),
				     GUI_CONNECT);
#endif

	switch (id) {
	case GUI_CONNECT:
		path = "GameMenu/GameNew";
		break;
	case GUI_DISCONNECT:
		path = "GameMenu/GameLeave";
		break;
	case GUI_CHANGE_NAME:
		path = "GameMenu/PlayerName";
		break;
	case GUI_ROLL:
		path = "ActionsMenu/RollDice";
		break;
	case GUI_TRADE:
		path = "ActionsMenu/Trade";
		break;
	case GUI_UNDO:
		path = "ActionsMenu/Undo";
		break;
	case GUI_FINISH:
		path = "ActionsMenu/Finish";
		break;
	case GUI_ROAD:
		path = "ActionsMenu/BuildRoad";
		break;
	case GUI_SHIP:
		path = "ActionsMenu/BuildShip";
		break;
	case GUI_MOVE_SHIP:
		path = "ActionsMenu/MoveShip";
		break;
	case GUI_BRIDGE:
		path = "ActionsMenu/BuildBridge";
		break;
	case GUI_SETTLEMENT:
		path = "ActionsMenu/BuildSettlement";
		break;
	case GUI_CITY:
		path = "ActionsMenu/BuildCity";
		break;
	case GUI_BUY_DEVELOP:
		path = "ActionsMenu/BuyDevelopment";
		break;
	case GUI_CITY_WALL:
		path = "ActionsMenu/BuildCityWall";
		break;
	default:
		break;
	};

	if (!path)
		return NULL;

	full_path = g_strdup_printf("ui/MainMenu/%s", path);
	action = gtk_ui_manager_get_action(ui_manager, full_path);
	g_free(full_path);
	return action;
}
Exemplo n.º 28
0
static void fm_main_win_init(FmMainWin *self)
{
    GtkWidget *vbox, *menubar, *toolitem, *next_btn, *scroll;
    GtkUIManager* ui;
    GtkActionGroup* act_grp;
    GtkAction* act;
    GtkAccelGroup* accel_grp;

    ++n_wins;

    vbox = gtk_vbox_new(FALSE, 0);

    self->hpaned = gtk_hpaned_new();
    gtk_paned_set_position(GTK_PANED(self->hpaned), 150);

    /* places left pane */
    self->places_view = fm_places_view_new();
    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(scroll), self->places_view);
    gtk_paned_add1(GTK_PANED(self->hpaned), scroll);

    /* folder view */
    self->folder_view = fm_folder_view_new( FM_FV_ICON_VIEW );
    fm_folder_view_set_show_hidden(FM_FOLDER_VIEW(self->folder_view), FALSE);
    fm_folder_view_sort(FM_FOLDER_VIEW(self->folder_view), GTK_SORT_DESCENDING, COL_FILE_NAME);
    fm_folder_view_set_selection_mode(FM_FOLDER_VIEW(self->folder_view), GTK_SELECTION_MULTIPLE);
    g_signal_connect(self->folder_view, "clicked", on_file_clicked, self);
    g_signal_connect(self->folder_view, "status", on_status, self);
    g_signal_connect(self->folder_view, "sel-changed", on_sel_changed, self);

    gtk_paned_add2(GTK_PANED(self->hpaned), self->folder_view);

    /* link places view with folder view. */
    g_signal_connect_swapped(self->places_view, "chdir", G_CALLBACK(fm_main_win_chdir), self);

    /* create menu bar and toolbar */
    ui = gtk_ui_manager_new();
    act_grp = gtk_action_group_new("Main");
    gtk_action_group_add_actions(act_grp, main_win_actions, G_N_ELEMENTS(main_win_actions), self);
    gtk_action_group_add_toggle_actions(act_grp, main_win_toggle_actions, G_N_ELEMENTS(main_win_toggle_actions), self);
    gtk_action_group_add_radio_actions(act_grp, main_win_mode_actions, G_N_ELEMENTS(main_win_mode_actions), FM_FV_ICON_VIEW, on_change_mode, self);
    gtk_action_group_add_radio_actions(act_grp, main_win_sort_type_actions, G_N_ELEMENTS(main_win_sort_type_actions), GTK_SORT_ASCENDING, on_sort_type, self);
    gtk_action_group_add_radio_actions(act_grp, main_win_sort_by_actions, G_N_ELEMENTS(main_win_sort_by_actions), 0, on_sort_by, self);

    accel_grp = gtk_ui_manager_get_accel_group(ui);
    gtk_window_add_accel_group(GTK_WINDOW(self), accel_grp);

    gtk_ui_manager_insert_action_group(ui, act_grp, 0);
    gtk_ui_manager_add_ui_from_string(ui, main_menu_xml, -1, NULL);

    menubar = gtk_ui_manager_get_widget(ui, "/menubar");

    self->toolbar = gtk_ui_manager_get_widget(ui, "/toolbar");
    /* FIXME: should make these optional */
    gtk_toolbar_set_icon_size(GTK_TOOLBAR(self->toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
    gtk_toolbar_set_style(GTK_TOOLBAR(self->toolbar), GTK_TOOLBAR_ICONS);

    /* create 'Next' button manually and add a popup menu to it */
    toolitem = g_object_new(GTK_TYPE_MENU_TOOL_BUTTON, NULL);
    gtk_toolbar_insert(GTK_TOOLBAR(self->toolbar), toolitem, 2);
    gtk_widget_show(GTK_WIDGET(toolitem));
    act = gtk_ui_manager_get_action(ui, "/menubar/GoMenu/Next");
    gtk_activatable_set_related_action(GTK_ACTIVATABLE(toolitem), act);

    /* set up history menu */
    self->nav_history = fm_nav_history_new();
    self->history_menu = gtk_menu_new();
    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolitem), self->history_menu);
    g_signal_connect(toolitem, "show-menu", G_CALLBACK(on_show_history_menu), self);

    self->popup = gtk_ui_manager_get_widget(ui, "/popup");

    gtk_box_pack_start( (GtkBox*)vbox, menubar, FALSE, TRUE, 0 );
    gtk_box_pack_start( (GtkBox*)vbox, self->toolbar, FALSE, TRUE, 0 );

    /* load bookmarks menu */
    load_bookmarks(self, ui);

    /* the location bar */
    self->location = fm_path_entry_new();
    g_signal_connect(self->location, "activate", on_entry_activate, self);
    g_signal_connect(self->folder_view, "loaded", G_CALLBACK(on_view_loaded), (gpointer) self);

    toolitem = gtk_tool_item_new();
    gtk_container_add( GTK_CONTAINER(toolitem), self->location );
    gtk_tool_item_set_expand(GTK_TOOL_ITEM(toolitem), TRUE);
    gtk_toolbar_insert((GtkToolbar*)self->toolbar, toolitem, gtk_toolbar_get_n_items(GTK_TOOLBAR(self->toolbar)) - 1 );

    gtk_box_pack_start( (GtkBox*)vbox, self->hpaned, TRUE, TRUE, 0 );

    /* status bar */
    self->statusbar = gtk_statusbar_new();
    gtk_box_pack_start( (GtkBox*)vbox, self->statusbar, FALSE, TRUE, 0 );
    self->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(self->statusbar), "status");
    self->statusbar_ctx2 = gtk_statusbar_get_context_id(GTK_STATUSBAR(self->statusbar), "status2");

    g_object_unref(act_grp);
    self->ui = ui;

    gtk_container_add( (GtkContainer*)self, vbox );
    gtk_widget_show_all(vbox);

    fm_folder_view_set_show_hidden(FM_FOLDER_VIEW(self->folder_view), FALSE);
    fm_main_win_chdir(self, fm_path_get_home());

    gtk_widget_grab_focus(self->folder_view);
}
Exemplo n.º 29
0
static void
update_actions (void)
{
  GtkAction                *action;
  WebKitWebBackForwardList *back_forward_list;
  WebKitWebFrame           *frame;

  back_forward_list =
    webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));

  /*  update the back button and its menu  */

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/back");
  gtk_action_set_sensitive (action,
                            webkit_web_view_can_go_back (WEBKIT_WEB_VIEW (view)));

  if (back_forward_list)
    {
      const GList *list;

      list = webkit_web_back_forward_list_get_back_list_with_limit (back_forward_list,
                                                                    12);
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_prev),
                                     build_menu (list, TRUE));
    }
  else
    {
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_prev), NULL);
    }

  /*  update the forward button and its menu  */

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/forward");
  gtk_action_set_sensitive (action,
                            webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW (view)));

  if (back_forward_list)
    {
      const GList *list;

      list = webkit_web_back_forward_list_get_forward_list_with_limit (back_forward_list,
                                                                       12);
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_next),
                                     build_menu (list, FALSE));
    }
  else
    {
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_next), NULL);
    }

  /*  update the copy-location action  */
  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/copy-location");

  frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
  gtk_action_set_sensitive (action, webkit_web_frame_get_uri (frame) != NULL);

  /*  update the show-index action  */
  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/show-index");
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
                                gtk_widget_get_visible (sidebar));
}
Exemplo n.º 30
0
GtkWidget *gui_build_interface(void)
{
	GtkWidget *vbox;
	GtkWidget *menubar;
	GtkActionGroup *action_group;
	GtkAccelGroup *accel_group;
	GError *error = NULL;
	gchar *icon_file;

	player_init();

	gmap = guimap_new();

	register_pixmaps();
	app_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	/* The name of the application */
	gtk_window_set_title(GTK_WINDOW(app_window), _("Pioneers"));

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(vbox);
	gtk_container_add(GTK_CONTAINER(app_window), vbox);

	action_group = gtk_action_group_new("MenuActions");
	gtk_action_group_set_translation_domain(action_group, PACKAGE);
	gtk_action_group_add_actions(action_group, entries,
				     G_N_ELEMENTS(entries), app_window);
	gtk_action_group_add_toggle_actions(action_group, toggle_entries,
					    G_N_ELEMENTS(toggle_entries),
					    app_window);

	ui_manager = gtk_ui_manager_new();
	gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);

	accel_group = gtk_ui_manager_get_accel_group(ui_manager);
	gtk_window_add_accel_group(GTK_WINDOW(app_window), accel_group);

	error = NULL;
	if (!gtk_ui_manager_add_ui_from_string
	    (ui_manager, ui_description, -1, &error)) {
		g_message("building menus failed: %s", error->message);
		g_error_free(error);
		return NULL;
	}

	icon_file =
	    g_build_filename(DATADIR, "pixmaps", PIONEERS_ICON_FILE, NULL);
	if (g_file_test(icon_file, G_FILE_TEST_EXISTS)) {
		gtk_window_set_default_icon_from_file(icon_file, NULL);
	} else {
		/* Missing pixmap, main icon file */
		g_warning("Pixmap not found: %s", icon_file);
	}
	g_free(icon_file);

	color_chat_enabled =
	    config_get_int_with_default("settings/color_chat", TRUE);

	color_messages_enabled =
	    config_get_int_with_default("settings/color_messages", TRUE);
	log_set_func_message_color_enable(color_messages_enabled);

	set_color_summary(config_get_int_with_default
			  ("settings/color_summary", TRUE));

	set_silent_mode(config_get_int_with_default
			("settings/silent_mode", FALSE));
	set_announce_player(config_get_int_with_default
			    ("settings/announce_player", TRUE));

	legend_page_enabled =
	    config_get_int_with_default("settings/legend_page", FALSE);

	menubar = gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
	toolbar = gtk_ui_manager_get_widget(ui_manager, "/MainToolbar");
	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), build_main_interface(), TRUE,
			   TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), build_status_bar(), FALSE, FALSE,
			   0);

	gtk_toggle_action_set_active(GTK_TOGGLE_ACTION
				     (gtk_ui_manager_get_action
				      (ui_manager,
				       "ui/MainMenu/SettingsMenu/ShowHideToolbar")),
				     config_get_int_with_default
				     ("settings/show_toolbar", TRUE));

	g_signal_connect(G_OBJECT(app_window), "key_press_event",
			 G_CALLBACK(hotkeys_handler), NULL);

	gtk_widget_show(app_window);

	frontend_gui_register_action(getAction(GUI_CONNECT), GUI_CONNECT);
	frontend_gui_register_action(getAction(GUI_DISCONNECT),
				     GUI_DISCONNECT);
#ifdef ADMIN_GTK
	/** @todo RC 2005-05-26 Admin interface: Not tested */
	frontend_gui_register_action(gtk_ui_manager_get_action
				     (manager,
				      "ui/MainMenu/GameMenu/GameAdmin"),
				     GUI_ADMIN);
#endif
	frontend_gui_register_action(getAction(GUI_CHANGE_NAME),
				     GUI_CHANGE_NAME);
	frontend_gui_register_action(getAction(GUI_ROLL), GUI_ROLL);
	frontend_gui_register_action(getAction(GUI_TRADE), GUI_TRADE);
	frontend_gui_register_action(getAction(GUI_UNDO), GUI_UNDO);
	frontend_gui_register_action(getAction(GUI_FINISH), GUI_FINISH);
	frontend_gui_register_action(getAction(GUI_ROAD), GUI_ROAD);
	frontend_gui_register_action(getAction(GUI_SHIP), GUI_SHIP);
	frontend_gui_register_action(getAction(GUI_MOVE_SHIP),
				     GUI_MOVE_SHIP);
	frontend_gui_register_action(getAction(GUI_BRIDGE), GUI_BRIDGE);
	frontend_gui_register_action(getAction(GUI_SETTLEMENT),
				     GUI_SETTLEMENT);
	frontend_gui_register_action(getAction(GUI_CITY), GUI_CITY);
	frontend_gui_register_action(getAction(GUI_BUY_DEVELOP),
				     GUI_BUY_DEVELOP);
	frontend_gui_register_action(getAction(GUI_CITY_WALL),
				     GUI_CITY_WALL);
#if 0
	frontend_gui_register_destroy(gtk_ui_manager_get_action
				      (manager, "GameQuit"), GUI_QUIT);
#endif

	gui_toolbar_show_button("BuildShip", FALSE);
	gui_toolbar_show_button("MoveShip", FALSE);
	gui_toolbar_show_button("BuildBridge", FALSE);

	gui_toolbar_show_accelerators(config_get_int_with_default
				      ("settings/toolbar_show_accelerators",
				       TRUE));

	gtk_ui_manager_ensure_update(ui_manager);
	gtk_widget_show(app_window);
	g_signal_connect(G_OBJECT(app_window), "delete_event",
			 G_CALLBACK(quit_cb), NULL);

	return app_window;
}