Пример #1
0
Файл: menus.c Проект: GNOME/dia
static void
menus_init(void)
{
  GError *error = NULL;
  gchar  *uifile;

  if (!initialise)
    return;

  initialise = FALSE;
  _setup_global_actions ();

  uifile = build_ui_filename ("ui/toolbox-ui.xml");
  if (!gtk_ui_manager_add_ui_from_file (_ui_manager, uifile, &error)) {
    g_warning ("building menus failed: %s", error->message);
    g_error_free (error);
    error = NULL;
  }
  g_free (uifile);

  /* the display menu */
  display_actions = create_or_ref_display_actions (TRUE);

  display_ui_manager = gtk_ui_manager_new ();
  g_signal_connect (G_OBJECT (display_ui_manager),
                    "connect_proxy",
		    G_CALLBACK (_ui_manager_connect_proxy),
		    NULL);
  gtk_ui_manager_set_add_tearoffs (display_ui_manager, DIA_SHOW_TEAROFFS);
  gtk_ui_manager_insert_action_group (display_ui_manager, display_actions, 0);
  gtk_ui_manager_insert_action_group (display_ui_manager, tool_actions, 0);
  if (!gtk_ui_manager_add_ui_from_string (display_ui_manager, ui_info, -1, &error)) {
    g_warning ("built-in menus failed: %s", error->message);
    g_error_free (error);
    error = NULL;
  }

  uifile = build_ui_filename ("ui/popup-ui.xml");
  /* TODO it would be more elegant if we had only one definition of the
   * menu hierarchy and merge it into a popup somehow. */
  if (!gtk_ui_manager_add_ui_from_file (display_ui_manager, uifile, &error)) {
    g_warning ("building menus failed: %s", error->message);
    g_error_free (error);
    error = NULL;
  }
  g_free (uifile);

  display_accels = gtk_ui_manager_get_accel_group (display_ui_manager);
  display_menubar = gtk_ui_manager_get_widget (display_ui_manager, DISPLAY_MENU);
  g_assert (display_menubar);

  add_plugin_actions (_ui_manager, TOOLBOX_MENU);
  add_plugin_actions (display_ui_manager, DISPLAY_MENU);
  add_plugin_actions (display_ui_manager, INVISIBLE_MENU);

  /* after creating all menu items */
  load_accels ();
}
Пример #2
0
Файл: menus.c Проект: GNOME/dia
void
menus_get_integrated_ui_menubar (GtkWidget     **menubar,
                                 GtkWidget     **toolbar,
			         GtkAccelGroup **accel_group)
{
  GError *error = NULL;
  gchar  *uifile;

  _setup_global_actions ();
  g_return_if_fail (_ui_manager != NULL);

  /* the integrated ui menu */
  display_actions = create_or_ref_display_actions (FALSE);
  g_return_if_fail (tool_actions != NULL);

  /* maybe better to put this into toolbox_actions? */
  gtk_action_group_add_toggle_actions (display_actions, integrated_ui_view_toggle_entries,
				       G_N_ELEMENTS (integrated_ui_view_toggle_entries), NULL);

  /* for stand-alone they are per display */
  gtk_ui_manager_insert_action_group (_ui_manager, display_actions, 0);
  tool_actions = create_or_ref_tool_actions ();
  gtk_ui_manager_insert_action_group (_ui_manager, tool_actions, 0);

  uifile = build_ui_filename ("ui/integrated-ui.xml");
  if (!gtk_ui_manager_add_ui_from_file (_ui_manager, uifile, &error)) {
    g_warning ("building integrated ui menus failed: %s", error->message);
    g_error_free (error);
    error = NULL;
  }
  g_free (uifile);
  if (!gtk_ui_manager_add_ui_from_string (_ui_manager, ui_info, -1, &error)) {
    g_warning ("built-in menus failed: %s", error->message);
    g_error_free (error);
    error = NULL;
  }

  add_plugin_actions (_ui_manager, NULL);
  /* after creating all menu items */
  load_accels ();

  if (menubar)
    *menubar = gtk_ui_manager_get_widget (_ui_manager, INTEGRATED_MENU);
  if (toolbar)
    *toolbar = create_integrated_ui_toolbar ();
  if (accel_group)
    *accel_group = gtk_ui_manager_get_accel_group (_ui_manager);
}
Пример #3
0
int
fe_args (int argc, char *argv[])
{
    GError *error = NULL;
    GOptionContext *context;

    gui.main_window = NULL;

#ifdef ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);
#endif
    context = g_option_context_new (NULL);

    g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
    g_option_context_add_group (context, gtk_get_option_group (FALSE));

    gtk_init (&argc, &argv);

    if (! g_option_context_parse (context, &argc, &argv, &error)) {
        g_printerr (_("Failed to parse arguments: %s\n"), error->message);
        g_error_free (error);
        g_option_context_free (context);
        return 0;
    }

    g_option_context_free (context);

    if (opt_version) {
        g_print ("xchat-gnome %s\n", PACKAGE_VERSION);
        return 0;
    }

    if (opt_cfgdir) {
        xdir_fs = opt_cfgdir;
    }

    load_accels ();

    return -1;
}
Пример #4
0
static void
gedit_app_startup (GApplication *application)
{
	GeditAppPrivate *priv;
	GtkCssProvider *css_provider;
	GtkSourceStyleSchemeManager *manager;
	const gchar *dir;
	gchar *icon_dir;
#ifndef ENABLE_GVFS_METADATA
	const gchar *cache_dir;
	gchar *metadata_filename;
#endif

	priv = gedit_app_get_instance_private (GEDIT_APP (application));

	G_APPLICATION_CLASS (gedit_app_parent_class)->startup (application);

	/* Setup debugging */
	gedit_debug_init ();
	gedit_debug_message (DEBUG_APP, "Startup");

	gedit_debug_message (DEBUG_APP, "Set icon");

	dir = gedit_dirs_get_gedit_data_dir ();
	icon_dir = g_build_filename (dir, "icons", NULL);

	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_dir);
	g_free (icon_dir);

	setup_theme_extensions (GEDIT_APP (application));

#ifndef ENABLE_GVFS_METADATA
	cache_dir = gedit_dirs_get_user_cache_dir ();
	metadata_filename = g_build_filename (cache_dir, "gedit-metadata.xml", NULL);
	gedit_metadata_manager_init (metadata_filename);
	g_free (metadata_filename);
#endif

	/* Load settings */
	priv->settings = gedit_settings_new ();
	priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
	priv->window_settings = g_settings_new ("org.gnome.gedit.state.window");

	/* initial lockdown state */
	priv->lockdown = gedit_settings_get_lockdown (GEDIT_SETTINGS (priv->settings));

	g_action_map_add_action_entries (G_ACTION_MAP (application),
	                                 app_entries,
	                                 G_N_ELEMENTS (app_entries),
	                                 application);

	/* menus */
	priv->window_menu = gtk_application_get_menubar (GTK_APPLICATION (application));

	if (priv->window_menu == NULL)
	{
		priv->window_menu = get_menu_model (GEDIT_APP (application), "gear-menu");
	}
	else
	{
		g_object_ref (priv->window_menu);
	}

	priv->notebook_menu = get_menu_model (GEDIT_APP (application), "notebook-menu");
	priv->tab_width_menu = get_menu_model (GEDIT_APP (application), "tab-width-menu");
	priv->line_col_menu = get_menu_model (GEDIT_APP (application), "line-col-menu");

	/* Accelerators */
	add_accelerator (GTK_APPLICATION (application), "app.new-window", "<Primary>N");
	add_accelerator (GTK_APPLICATION (application), "app.quit", "<Primary>Q");
	add_accelerator (GTK_APPLICATION (application), "app.help", "F1");

	add_accelerator (GTK_APPLICATION (application), "win.gear-menu", "F10");
	add_accelerator (GTK_APPLICATION (application), "win.open", "<Primary>O");
	add_accelerator (GTK_APPLICATION (application), "win.save", "<Primary>S");
	add_accelerator (GTK_APPLICATION (application), "win.save-as", "<Primary><Shift>S");
	add_accelerator (GTK_APPLICATION (application), "win.save-all", "<Primary><Shift>L");
	add_accelerator (GTK_APPLICATION (application), "win.new-tab", "<Primary>T");
	add_accelerator (GTK_APPLICATION (application), "win.reopen-closed-tab", "<Primary><Shift>T");
	add_accelerator (GTK_APPLICATION (application), "win.close", "<Primary>W");
	add_accelerator (GTK_APPLICATION (application), "win.close-all", "<Primary><Shift>W");
	add_accelerator (GTK_APPLICATION (application), "win.print", "<Primary>P");
	add_accelerator (GTK_APPLICATION (application), "win.find", "<Primary>F");
	add_accelerator (GTK_APPLICATION (application), "win.find-next", "<Primary>G");
	add_accelerator (GTK_APPLICATION (application), "win.find-prev", "<Primary><Shift>G");
	add_accelerator (GTK_APPLICATION (application), "win.replace", "<Primary>H");
	add_accelerator (GTK_APPLICATION (application), "win.clear-highlight", "<Primary><Shift>K");
	add_accelerator (GTK_APPLICATION (application), "win.goto-line", "<Primary>I");
	add_accelerator (GTK_APPLICATION (application), "win.focus-active-view", "Escape");
	add_accelerator (GTK_APPLICATION (application), "win.side-panel", "F9");
	add_accelerator (GTK_APPLICATION (application), "win.bottom-panel", "<Primary>F9");
	add_accelerator (GTK_APPLICATION (application), "win.fullscreen", "F11");
	add_accelerator (GTK_APPLICATION (application), "win.new-tab-group", "<Primary><Alt>N");
	add_accelerator (GTK_APPLICATION (application), "win.previous-tab-group", "<Primary><Shift><Alt>Page_Up");
	add_accelerator (GTK_APPLICATION (application), "win.next-tab-group", "<Primary><Shift><Alt>Page_Down");
	add_accelerator (GTK_APPLICATION (application), "win.previous-document", "<Primary><Alt>Page_Up");
	add_accelerator (GTK_APPLICATION (application), "win.next-document", "<Primary><Alt>Page_Down");

	load_accels ();

	/* Load custom css */
	g_object_unref (load_css_from_resource ("gedit-style.css", TRUE));
	css_provider = load_css_from_resource ("gedit-style-os.css", FALSE);
	g_clear_object (&css_provider);

	/*
	 * We use the default gtksourceview style scheme manager so that plugins
	 * can obtain it easily without a gedit specific api, but we need to
	 * add our search path at startup before the manager is actually used.
	 */
	manager = gtk_source_style_scheme_manager_get_default ();
	gtk_source_style_scheme_manager_append_search_path (manager,
	                                                    gedit_dirs_get_user_styles_dir ());

	priv->engine = gedit_plugins_engine_get_default ();
	priv->extensions = peas_extension_set_new (PEAS_ENGINE (priv->engine),
	                                           GEDIT_TYPE_APP_ACTIVATABLE,
	                                           "app", GEDIT_APP (application),
	                                           NULL);

	g_signal_connect (priv->extensions,
	                  "extension-added",
	                  G_CALLBACK (extension_added),
	                  application);

	g_signal_connect (priv->extensions,
	                  "extension-removed",
	                  G_CALLBACK (extension_removed),
	                  application);

	peas_extension_set_foreach (priv->extensions,
	                            (PeasExtensionSetForeachFunc) extension_added,
	                            application);
}