static void append_global_paths() { // append style path PUSS/styles { GtkSourceStyleSchemeManager* ssm = gtk_source_style_scheme_manager_get_default(); gchar* style_path = g_build_filename(puss_app->module_path, "styles", NULL); gtk_source_style_scheme_manager_append_search_path(ssm, style_path); g_free(style_path); } }
static void add_pluma_styles_path (GtkSourceStyleSchemeManager *mgr) { gchar *dir; dir = get_pluma_styles_path(); if (dir != NULL) { gtk_source_style_scheme_manager_append_search_path (mgr, dir); g_free (dir); } }
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); }
GUIEditor * gui_editor_new (void) { GUIEditor *self; GPtrArray *dirs; const gchar * const *current_search_path; gchar **lang_spec_search_path; self = g_malloc0 (sizeof (GUIEditor)); self->buffer = gtk_source_buffer_new (NULL); self->widget = gtk_source_view_new_with_buffer (self->buffer); self->scroll = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (self->scroll), self->widget); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gui_editor_set_font (self, DEFAULT_EDITOR_FONT); self->hltag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(self->buffer), HIGHLIGHT_TAG, "background", COLOUR_BG_HL, NULL); self->lang_manager = gtk_source_language_manager_new (); self->style_scheme_manager = gtk_source_style_scheme_manager_get_default (); dirs = g_ptr_array_new(); current_search_path = gtk_source_language_manager_get_search_path(self->lang_manager); for (; current_search_path != NULL && *current_search_path != NULL; ++current_search_path) g_ptr_array_add(dirs, g_strdup(*current_search_path)); // look for spec file in our own directory g_ptr_array_add(dirs, g_strdup(PACKAGE_DATA_DIR)); // look for spec file in data directory when running from svn g_ptr_array_add(dirs, g_strdup("data")); // look for spec file in current directory, when running on windows g_ptr_array_add(dirs, g_strdup(".")); g_ptr_array_add(dirs, g_strdup(NULL)); lang_spec_search_path = (gchar **)g_ptr_array_free(dirs, FALSE); gtk_source_language_manager_set_search_path (self->lang_manager, lang_spec_search_path); gtk_source_style_scheme_manager_append_search_path (self->style_scheme_manager, "data"); gtk_source_style_scheme_manager_append_search_path (self->style_scheme_manager, "."); #if GTK_CHECK_VERSION(3, 0, 0) GtkSourceMarkAttributes *mark_attributes = gtk_source_mark_attributes_new (); gtk_source_mark_attributes_set_icon_name (mark_attributes, "gtk-no"); gtk_source_view_set_mark_attributes (GTK_SOURCE_VIEW (self->widget), MARKER_BREAKPOINT, mark_attributes, 0); #else GdkPixbuf *pixbuf; pixbuf = gui_editor_get_stock_icon (GTK_WIDGET(self->widget), GTK_STOCK_NO, GTK_ICON_SIZE_MENU); if (pixbuf) { gtk_source_view_set_mark_category_icon_from_pixbuf (GTK_SOURCE_VIEW (self->widget), MARKER_BREAKPOINT, pixbuf); g_object_unref (pixbuf); } #endif return self; }