static void theme_changed (GtkSettings *settings, GParamSpec *pspec, GeditApp *app) { GeditAppPrivate *priv; priv = gedit_app_get_instance_private (app); gchar *theme, *lc_theme, *theme_css; g_object_get (settings, "gtk-theme-name", &theme, NULL); lc_theme = g_ascii_strdown (theme, -1); g_free (theme); theme_css = g_strdup_printf ("gedit.%s.css", lc_theme); g_free (lc_theme); if (priv->theme_provider != NULL) { gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (priv->theme_provider)); g_clear_object (&priv->theme_provider); } priv->theme_provider = load_css_from_resource (theme_css, FALSE); g_free (theme_css); }
static void add_css_provider (GApplication *application, gboolean theme) { gs_unref_object GtkCssProvider *provider; provider = gtk_css_provider_new (); if (!load_css_from_resource (application, provider, theme)) return; gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); }
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); }