static void gedit_plugins_engine_init (GeditPluginsEngine *engine) { gchar *typelib_dir; GError *error = NULL; gedit_debug (DEBUG_PLUGINS); engine->priv = gedit_plugins_engine_get_instance_private (engine); peas_engine_enable_loader (PEAS_ENGINE (engine), "python3"); engine->priv->plugin_settings = g_settings_new ("org.gnome.gedit.plugins"); /* Require gedit's typelib. */ typelib_dir = g_build_filename (gedit_dirs_get_gedit_lib_dir (), "girepository-1.0", NULL); if (!g_irepository_require_private (g_irepository_get_default (), typelib_dir, "Gedit", "3.0", 0, &error)) { g_warning ("Could not load Gedit repository: %s", error->message); g_error_free (error); error = NULL; } g_free (typelib_dir); /* This should be moved to libpeas */ if (!g_irepository_require (g_irepository_get_default (), "Peas", "1.0", 0, &error)) { g_warning ("Could not load Peas repository: %s", error->message); g_error_free (error); error = NULL; } if (!g_irepository_require (g_irepository_get_default (), "PeasGtk", "1.0", 0, &error)) { g_warning ("Could not load PeasGtk repository: %s", error->message); g_error_free (error); error = NULL; } peas_engine_add_search_path (PEAS_ENGINE (engine), gedit_dirs_get_user_plugins_dir (), gedit_dirs_get_user_plugins_dir ()); peas_engine_add_search_path (PEAS_ENGINE (engine), gedit_dirs_get_gedit_plugins_dir (), gedit_dirs_get_gedit_plugins_data_dir ()); g_settings_bind (engine->priv->plugin_settings, GEDIT_SETTINGS_ACTIVE_PLUGINS, engine, "loaded-plugins", G_SETTINGS_BIND_DEFAULT); }
static void liferea_plugins_engine_init (LifereaPluginsEngine * engine) { gchar *typelib_dir; GError *error = NULL; engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, LIFEREA_TYPE_PLUGINS_ENGINE, LifereaPluginsEnginePrivate); peas_engine_enable_loader (PEAS_ENGINE (engine), "python"); engine->priv->plugin_settings = g_settings_new ("net.sf.liferea.plugins"); /* Require Lifereas's typelib. */ typelib_dir = g_build_filename (PACKAGE_LIB_DIR, "girepository-1.0", NULL); if (!g_irepository_require_private (g_irepository_get_default (), typelib_dir, "Liferea", "3.0", 0, &error)) { g_warning ("Could not load Liferea repository: %s", error->message); g_error_free (error); error = NULL; } g_free (typelib_dir); /* This should be moved to libpeas */ if (!g_irepository_require (g_irepository_get_default (), "Peas", "1.0", 0, &error)) { g_warning ("Could not load Peas repository: %s", error->message); g_error_free (error); error = NULL; } if (!g_irepository_require (g_irepository_get_default (), "PeasGtk", "1.0", 0, &error)) { g_warning ("Could not load PeasGtk repository: %s", error->message); g_error_free (error); error = NULL; } peas_engine_add_search_path (PEAS_ENGINE (engine), g_build_filename (g_get_user_data_dir (), "liferea", "plugins", NULL), g_build_filename (g_get_user_data_dir (), "liferea", "plugins", NULL)); peas_engine_add_search_path (PEAS_ENGINE (engine), g_build_filename (PACKAGE_LIB_DIR, "plugins", NULL), g_build_filename (PACKAGE_DATA_DIR, "plugins", NULL)); g_settings_bind (engine->priv->plugin_settings, "active-plugins", engine, "loaded-plugins", G_SETTINGS_BIND_DEFAULT); }
static PeasExtensionSet * liferea_auth_get_extension_set (void) { if (!extensions) { extensions = peas_extension_set_new (PEAS_ENGINE (liferea_plugins_engine_get_default ()), LIFEREA_AUTH_ACTIVATABLE_TYPE, NULL); g_signal_connect (extensions, "extension-added", G_CALLBACK (on_extension_added), NULL); g_signal_connect (extensions, "extension-removed", G_CALLBACK (on_extension_removed), NULL); peas_extension_set_foreach (extensions, on_extension_added, NULL); } return extensions; }
static void eog_application_init (EogApplication *eog_application) { EogApplicationPrivate *priv; const gchar *dot_dir = eog_util_dot_dir (); eog_session_init (eog_application); eog_application->priv = EOG_APPLICATION_GET_PRIVATE (eog_application); priv = eog_application->priv; priv->toolbars_model = egg_toolbars_model_new (); priv->plugin_engine = eog_plugin_engine_new (); priv->flags = 0; priv->ui_settings = g_settings_new (EOG_CONF_UI); egg_toolbars_model_load_names (priv->toolbars_model, EOG_DATA_DIR "/eog-toolbar.xml"); if (G_LIKELY (dot_dir != NULL)) priv->toolbars_file = g_build_filename (dot_dir, "eog_toolbar.xml", NULL); if (!dot_dir || !egg_toolbars_model_load_toolbars (priv->toolbars_model, priv->toolbars_file)) { egg_toolbars_model_load_toolbars (priv->toolbars_model, EOG_DATA_DIR "/eog-toolbar.xml"); } egg_toolbars_model_set_flags (priv->toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE); eog_application_load_accelerators (); priv->extensions = peas_extension_set_new ( PEAS_ENGINE (priv->plugin_engine), EOG_TYPE_APPLICATION_ACTIVATABLE, "app", EOG_APPLICATION (eog_application), NULL); peas_extension_set_call (priv->extensions, "activate"); g_signal_connect (priv->extensions, "extension-added", G_CALLBACK (on_extension_added), eog_application); g_signal_connect (priv->extensions, "extension-removed", G_CALLBACK (on_extension_removed), eog_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); }
void liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState) { GtkUIManager *ui_manager; GtkAccelGroup *accel_group; GError *error = NULL; gboolean toggle; gchar *id; debug_enter ("liferea_shell_create"); g_object_new (LIFEREA_SHELL_TYPE, NULL); shell->priv->window = GTK_WINDOW (liferea_shell_lookup ("mainwindow")); gtk_window_set_application (GTK_WINDOW (shell->priv->window), app); /* 1.) menu creation */ debug0 (DEBUG_GUI, "Setting up menues"); shell->priv->itemlist = itemlist_create (); /* Prepare some toggle button states */ conf_get_bool_value (REDUCED_FEEDLIST, &toggle); liferea_shell_feedlist_toggle_entries[0].is_active = toggle; ui_manager = gtk_ui_manager_new (); shell->priv->generalActions = gtk_action_group_new ("GeneralActions"); gtk_action_group_set_translation_domain (shell->priv->generalActions, PACKAGE); gtk_action_group_add_actions (shell->priv->generalActions, liferea_shell_action_entries, G_N_ELEMENTS (liferea_shell_action_entries), shell->priv); gtk_action_group_add_toggle_actions (shell->priv->generalActions, liferea_shell_action_toggle_entries, G_N_ELEMENTS (liferea_shell_action_toggle_entries), shell->priv); gtk_action_group_add_radio_actions (shell->priv->generalActions, liferea_shell_view_radio_entries, G_N_ELEMENTS (liferea_shell_view_radio_entries), itemlist_get_view_mode (), (GCallback)on_view_activate, (gpointer)TRUE); gtk_action_group_add_toggle_actions (shell->priv->generalActions, liferea_shell_feedlist_toggle_entries, G_N_ELEMENTS (liferea_shell_feedlist_toggle_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->generalActions, 0); shell->priv->addActions = gtk_action_group_new ("AddActions"); gtk_action_group_set_translation_domain (shell->priv->addActions, PACKAGE); gtk_action_group_add_actions (shell->priv->addActions, liferea_shell_add_action_entries, G_N_ELEMENTS (liferea_shell_add_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->addActions, 0); shell->priv->feedActions = gtk_action_group_new ("FeedActions"); gtk_action_group_set_translation_domain (shell->priv->feedActions, PACKAGE); gtk_action_group_add_actions (shell->priv->feedActions, liferea_shell_feed_action_entries, G_N_ELEMENTS (liferea_shell_feed_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->feedActions, 0); shell->priv->readWriteActions = gtk_action_group_new("ReadWriteActions"); gtk_action_group_set_translation_domain (shell->priv->readWriteActions, PACKAGE); gtk_action_group_add_actions (shell->priv->readWriteActions, liferea_shell_read_write_action_entries, G_N_ELEMENTS (liferea_shell_read_write_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->readWriteActions, 0); shell->priv->itemActions = gtk_action_group_new ("ItemActions"); gtk_action_group_set_translation_domain (shell->priv->itemActions, PACKAGE); gtk_action_group_add_actions (shell->priv->itemActions, liferea_shell_item_action_entries, G_N_ELEMENTS (liferea_shell_item_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->itemActions, 0); accel_group = gtk_ui_manager_get_accel_group (ui_manager); gtk_window_add_accel_group (GTK_WINDOW (shell->priv->window), accel_group); g_object_unref (accel_group); g_signal_connect (gtk_accel_map_get (), "changed", G_CALLBACK (on_accel_change), NULL); if (!gtk_ui_manager_add_ui_from_string (ui_manager, liferea_shell_ui_desc, -1, &error)) g_error ("building menus failed: %s", error->message); shell->priv->menubar = gtk_ui_manager_get_widget (ui_manager, "/MainwindowMenubar"); shell->priv->toolbar = gtk_ui_manager_get_widget (ui_manager, "/maintoolbar"); /* Ensure GTK3 toolbar shadows... */ gtk_style_context_add_class (gtk_widget_get_style_context (shell->priv->toolbar), "primary-toolbar"); /* what a pain, why is there no markup for this option? */ g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/newFeedButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/nextUnreadButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/MarkAsReadButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/UpdateAllButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/SearchButton")), "is_important", TRUE, NULL); /* 2.) setup containers */ debug0 (DEBUG_GUI, "Setting up widget containers"); gtk_box_pack_start (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->toolbar, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->toolbar, 0); gtk_box_pack_start (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->menubar, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->menubar, 0); gtk_widget_show_all(GTK_WIDGET(shell->priv->toolbar)); g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_press_event", G_CALLBACK (on_key_press_event_null_cb), NULL); g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_release_event", G_CALLBACK (on_key_press_event_null_cb), NULL); g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "scroll_event", G_CALLBACK (on_notebook_scroll_event_null_cb), NULL); g_signal_connect (G_OBJECT (shell->priv->window), "delete_event", G_CALLBACK(on_close), shell->priv); g_signal_connect (G_OBJECT (shell->priv->window), "window_state_event", G_CALLBACK(on_window_state_event), shell->priv); g_signal_connect (G_OBJECT (shell->priv->window), "key_press_event", G_CALLBACK(on_key_press_event), shell->priv); /* 3.) setup status bar */ debug0 (DEBUG_GUI, "Setting up status bar"); shell->priv->statusbar = GTK_STATUSBAR (liferea_shell_lookup ("statusbar")); shell->priv->statusbarLocked = FALSE; shell->priv->statusbarLockTimer = 0; shell->priv->statusbar_feedsinfo = gtk_label_new(""); gtk_widget_show(shell->priv->statusbar_feedsinfo); gtk_box_pack_start (GTK_BOX (shell->priv->statusbar), shell->priv->statusbar_feedsinfo, FALSE, FALSE, 5); /* 4.) setup tabs */ debug0 (DEBUG_GUI, "Setting up tabbed browsing"); shell->priv->tabs = browser_tabs_create (GTK_NOTEBOOK (liferea_shell_lookup ("browsertabs"))); /* 5.) setup feed list */ debug0 (DEBUG_GUI, "Setting up feed list"); shell->priv->feedlistView = GTK_TREE_VIEW (liferea_shell_lookup ("feedlist")); feed_list_view_init (shell->priv->feedlistView); /* 6.) setup menu sensivity */ debug0 (DEBUG_GUI, "Initialising menues"); /* On start, no item or feed is selected, so Item menu should be insensitive: */ liferea_shell_update_item_menu (FALSE); /* necessary to prevent selection signals when filling the feed list and setting the 2/3 pane mode view */ gtk_widget_set_sensitive (GTK_WIDGET (shell->priv->feedlistView), FALSE); /* 7.) setup item view */ debug0 (DEBUG_GUI, "Setting up item view"); shell->priv->itemview = itemview_create (GTK_WIDGET (shell->priv->window)); /* 8.) load icons as required */ debug0 (DEBUG_GUI, "Loading icons"); icons_load (); /* 9.) update and restore all menu elements */ liferea_shell_update_toolbar (); liferea_shell_update_history_actions (); liferea_shell_setup_URL_receiver (); liferea_shell_restore_state (overrideWindowState); gtk_widget_set_sensitive (GTK_WIDGET (shell->priv->feedlistView), TRUE); /* 10.) After main window is realized get theme colors and set up feed list and tray icon */ render_init_theme_colors (GTK_WIDGET (shell->priv->window)); shell->priv->feedlist = feedlist_create (); g_signal_connect (shell->priv->feedlist, "new-items", G_CALLBACK (liferea_shell_update_unread_stats), shell->priv->feedlist); /* 11.) Restore latest selection */ // FIXME: Move to feed list code if (conf_get_str_value (LAST_NODE_SELECTED, &id)) { feed_list_view_select (node_from_id (id)); g_free (id); } /* 12. Setup shell plugins */ shell->priv->extensions = peas_extension_set_new (PEAS_ENGINE (liferea_plugins_engine_get_default ()), LIFEREA_TYPE_SHELL_ACTIVATABLE, "shell", shell, NULL); g_signal_connect (shell->priv->extensions, "extension-added", G_CALLBACK (on_extension_added), shell); g_signal_connect (shell->priv->extensions, "extension-removed", G_CALLBACK (on_extension_removed), shell); peas_extension_set_call (shell->priv->extensions, "activate"); /* 14. Rebuild search folders if needed */ if (searchFolderRebuild) vfolder_foreach (vfolder_rebuild); debug_exit ("liferea_shell_create"); }
static void mnb_home_new_widget_dialog_init (MnbHomeNewWidgetDialog *self) { ClutterActor *table, *itemview; MnbHomeNewWidgetDialogItemFactory *factory; MnbHomePluginsEngine *engine; const GList *l; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MNB_TYPE_HOME_NEW_WIDGET_DIALOG, MnbHomeNewWidgetDialogPrivate); /* set up model and view */ self->priv->items = clutter_list_model_new (ITEMS_N_COLUMNS, G_TYPE_STRING, "Module", /* ITEMS_MODULE */ G_TYPE_STRING, "Name", /* ITEMS_NAME */ G_TYPE_STRING, "Icon" /* ITEMS_ICON */); table = mx_table_new (); mx_bin_set_child (MX_BIN (self), table); factory = g_object_new (MNB_TYPE_HOME_NEW_WIDGET_DIALOG_ITEM_FACTORY, NULL); factory->dialog = self; itemview = mx_item_view_new (); mx_table_add_actor (MX_TABLE (table), itemview, 0, 1); mx_item_view_set_model (MX_ITEM_VIEW (itemview), self->priv->items); mx_item_view_set_factory (MX_ITEM_VIEW (itemview), MX_ITEM_FACTORY (factory)); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "module", ITEMS_MODULE); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "label", ITEMS_NAME); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "icon", ITEMS_ICON); clutter_actor_show_all (table); /* find plugins */ /* FIXME: should we monitor for new plugins on the fly? */ engine = mnb_home_plugins_engine_dup (); for (l = peas_engine_get_plugin_list (PEAS_ENGINE (engine)); l != NULL; l = g_list_next (l)) { PeasPluginInfo *info = l->data; char *icon; if (!peas_plugin_info_is_available (info, NULL)) continue; icon = g_build_filename ( peas_plugin_info_get_module_dir (info), peas_plugin_info_get_icon_name (info), NULL); clutter_model_append (self->priv->items, ITEMS_MODULE, peas_plugin_info_get_module_name (info), ITEMS_NAME, peas_plugin_info_get_name (info), ITEMS_ICON, icon, -1); g_free (icon); } /* add actions */ mx_dialog_add_action (MX_DIALOG (self), mx_action_new_full ("cancel", _("Cancel"), G_CALLBACK (home_new_widget_dialog_cancel), self)); g_object_unref (engine); g_object_unref (factory); }