From aa4b3f8d0adc758f2f5dc9eb5c78e79998c8e0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Tue, 6 Jul 2021 10:25:32 +0200 Subject: [PATCH] M!84 - EPluginManager: Make it a page in the preferences Move the plugins preferences into the preferences window, allows to have one less dialog to look-at to configure evolution. Closes https://gitlab.gnome.org/GNOME/evolution/-/merge_requests/84 --- data/icons/CMakeLists.txt | 1 + ...r_categories_48x48_preferences-plugins.svg | 43 +++++++++ .../plugin-manager/evolution-plugin-manager.c | 95 ++++++------------- 3 files changed, 74 insertions(+), 65 deletions(-) create mode 100644 data/icons/hicolor_categories_48x48_preferences-plugins.svg diff --git a/data/icons/CMakeLists.txt b/data/icons/CMakeLists.txt index f60017b5e2..11007ef08e 100644 --- a/data/icons/CMakeLists.txt +++ b/data/icons/CMakeLists.txt @@ -110,6 +110,7 @@ set(private_icons hicolor_categories_48x48_preferences-composer.png hicolor_categories_48x48_preferences-mail.png hicolor_categories_48x48_preferences-mail-accounts.png + hicolor_categories_48x48_preferences-plugins.svg hicolor_categories_48x48_preferences-system-network-proxy.png hicolor_places_16x16_mail-inbox.png hicolor_places_16x16_mail-outbox.png diff --git a/data/icons/hicolor_categories_48x48_preferences-plugins.svg b/data/icons/hicolor_categories_48x48_preferences-plugins.svg new file mode 100644 index 0000000000..8749118860 --- /dev/null +++ b/data/icons/hicolor_categories_48x48_preferences-plugins.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + diff --git a/src/modules/plugin-manager/evolution-plugin-manager.c b/src/modules/plugin-manager/evolution-plugin-manager.c index bc72074be9..aafb739887 100644 --- a/src/modules/plugin-manager/evolution-plugin-manager.c +++ b/src/modules/plugin-manager/evolution-plugin-manager.c @@ -275,45 +275,27 @@ eppm_enable_toggled (GtkCellRendererToggle *renderer, gtk_tree_path_free (path); } -static void -action_plugin_manager_cb (GtkAction *action, - EExtension *extension) +static GtkWidget * +plugins_page_new (EPreferencesWindow *window) { Manager *m; gint i; - GtkWidget *dialog; - GtkWidget *hbox, *w; + GtkWidget *vbox, *hbox, *w; GtkWidget *overview_page; - GtkWidget *content_area; GtkListStore *store; GtkTreeView *tree_view; GtkTreeSelection *selection; + GtkTreePath *path; GtkCellRenderer *renderer; GSList *plugins, *link; gchar *string; GtkWidget *subvbox; - EExtensible *extensible; m = g_malloc0 (sizeof (*m)); - /* Retrieve the parent EShellWindow. */ - extensible = e_extension_get_extensible (extension); - /* Setup the ui */ - dialog = gtk_dialog_new_with_buttons ( - _("Plugin Manager"), - GTK_WINDOW (extensible), - GTK_DIALOG_DESTROY_WITH_PARENT, - _("_Close"), GTK_RESPONSE_CLOSE, NULL); - - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - - gtk_window_set_default_size (GTK_WINDOW (dialog), 640, 400); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); - gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); string = g_markup_printf_escaped ( "%s", _("Note: Some changes " @@ -327,7 +309,9 @@ action_plugin_manager_cb (GtkAction *action, gtk_widget_show (w); g_free (string); - gtk_box_pack_start (GTK_BOX (content_area), w, FALSE, TRUE, 12); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, TRUE, 0); notebook = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE); @@ -396,6 +380,8 @@ action_plugin_manager_cb (GtkAction *action, COL_PLUGIN_CFG_WIDGET, cfg_widget, -1); } + g_slist_free_full (plugins, g_object_unref); + /* setup the treeview */ tree_view = GTK_TREE_VIEW (gtk_tree_view_new ()); gtk_tree_view_set_reorderable (tree_view, FALSE); @@ -489,25 +475,22 @@ action_plugin_manager_cb (GtkAction *action, gtk_widget_show_all (overview_page); selection = gtk_tree_view_get_selection (tree_view); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect ( + g_signal_connect_data ( selection, "changed", - G_CALLBACK (eppm_selection_changed), m); + G_CALLBACK (eppm_selection_changed), + m, (GClosureNotify) g_free, 0); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); + + path = gtk_tree_path_new_first (); + gtk_tree_selection_select_path (selection, path); + gtk_tree_path_free (path); atk_object_set_name ( gtk_widget_get_accessible ( GTK_WIDGET (tree_view)), _("Plugin")); - gtk_dialog_run (GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); - - g_slist_foreach (plugins, (GFunc) g_object_unref, NULL); - g_slist_free (plugins); - g_object_unref (store); - - g_free (m); + return vbox; } static void @@ -516,42 +499,24 @@ plugin_manager_constructed (GObject *object) EExtensible *extensible; EPluginManager *extension; EShellWindow *shell_window; - GtkActionGroup *action_group; - GtkUIManager *ui_manager; - GtkAction *action; - const gchar *action_name; - const gchar *action_label; - const gchar *action_tooltip; - const gchar *widget_path; - guint merge_id; + EShell *shell; + GtkWidget *preferences_window; extension = E_PLUGIN_MANAGER (object); extensible = e_extension_get_extensible (E_EXTENSION (extension)); shell_window = E_SHELL_WINDOW (extensible); - action_group = E_SHELL_WINDOW_ACTION_GROUP_SHELL (shell_window); - ui_manager = e_shell_window_get_ui_manager (shell_window); - merge_id = gtk_ui_manager_new_merge_id (ui_manager); + shell = e_shell_window_get_shell (shell_window); + preferences_window = e_shell_get_preferences_window (shell); - action_name = "plugin-manager"; - action_label = _("_Plugins"); - action_tooltip = _("Enable and disable plugins"); - widget_path = "/main-menu/edit-menu/administrative-actions"; - - action = gtk_action_new ( - action_name, action_label, action_tooltip, NULL); - - g_signal_connect ( - action, "activate", - G_CALLBACK (action_plugin_manager_cb), extension); - - gtk_action_group_add_action (action_group, action); - - gtk_ui_manager_add_ui ( - ui_manager, merge_id, widget_path, action_name, - action_name, GTK_UI_MANAGER_AUTO, FALSE); - - g_object_unref (action); + e_preferences_window_add_page ( + E_PREFERENCES_WINDOW (preferences_window), + "page-plugins", + "preferences-plugins", + _("Plugins"), + NULL, + (EPreferencesWindowCreatePageFn) plugins_page_new, + 900); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_plugin_manager_parent_class)->constructed (object);