From d7494c8f160b12e1199b06dcafdc8ff01b24b796 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 4 Mar 2010 15:26:59 -0500 Subject: Shell and UI manager cleanups. Replace the EVO_EXPRESS environment variable with an --express command line option. (Note, this adds a new translatable string for --help.) Add an EUIManager class with an "express-mode" property and custom load functions that use our new "express" preprocessor. This replaces the UI manager functions in e-utils.c. (Also going to see if I can get GTK+ to add an "add_ui_from_string" method to GtkUIManagerClass that we can override. Then we could just call gtk_ui_manager_add_ui_from_string() and the preprocessor would automatically do its thing and chain up.) Add an "express-mode" read-only GObject property to EShell. Add e_shell_configure_ui_manager() to e-shell-utils.c. For now this just creates a one-way property binding: EShell:express-mode -> EUIManager:express-mode Call this immediately after e_ui_manager_new(). (EUIManager can't do this itself because it lives too low in the dependency hierarchy and doesn't know about EShell.) --- calendar/gui/dialogs/comp-editor.c | 3 +- calendar/gui/dialogs/event-editor.c | 4 +- calendar/gui/dialogs/memo-editor.c | 4 +- calendar/gui/dialogs/task-editor.c | 4 +- capplet/settings/mail-account-view.c | 2 +- composer/e-msg-composer.c | 4 +- doc/reference/shell/eshell-sections.txt | 2 + doc/reference/shell/tmpl/e-shell-switcher.sgml | 3 +- doc/reference/shell/tmpl/e-shell-utils.sgml | 9 ++ doc/reference/shell/tmpl/e-shell.sgml | 14 +++ e-util/Makefile.am | 2 + e-util/e-plugin-ui.c | 33 +++---- e-util/e-plugin-ui.h | 12 +-- e-util/e-util.c | 119 ------------------------- e-util/e-util.h | 8 -- mail/e-mail-browser.c | 28 ++++-- mail/em-folder-tree-model.c | 6 +- mail/em-folder-tree.c | 9 +- modules/mail/e-mail-shell-view-private.h | 1 + modules/mail/e-mail-shell-view.c | 3 +- shell/e-shell-utils.c | 25 ++++++ shell/e-shell-utils.h | 4 + shell/e-shell-view.c | 7 +- shell/e-shell-window-actions.c | 13 ++- shell/e-shell-window-private.c | 20 ++--- shell/e-shell-window-private.h | 1 + shell/e-shell-window.c | 15 +--- shell/e-shell-window.h | 1 - shell/e-shell.c | 86 ++++++++++++------ shell/e-shell.h | 2 +- shell/main.c | 21 ++++- widgets/misc/e-attachment-view.c | 3 +- widgets/misc/e-web-view.c | 6 +- 33 files changed, 238 insertions(+), 236 deletions(-) diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index e002f6afd4..15384d829d 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -66,6 +66,7 @@ #include "widgets/misc/e-attachment-paned.h" #include "e-util/e-alert-dialog.h" +#include "e-util/e-ui-manager.h" #define COMP_EDITOR_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -1608,7 +1609,7 @@ comp_editor_init (CompEditor *editor) priv->warned = FALSE; priv->is_group_item = FALSE; - priv->ui_manager = gtk_ui_manager_new (); + priv->ui_manager = e_ui_manager_new (); if (comp_lite) gtk_window_set_default_size ((GtkWindow *) editor, 800, 450); diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 23256adff0..6e8b049bee 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -507,8 +507,8 @@ event_editor_init (EventEditor *ee) gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error); id = "org.gnome.evolution.event-editor"; - e_plugin_ui_register_manager (ui_manager, id, ee); - e_plugin_ui_enable_manager (ui_manager, id); + e_plugin_ui_register_manager (E_UI_MANAGER (ui_manager), id, ee); + e_plugin_ui_enable_manager (E_UI_MANAGER (ui_manager), id); if (error != NULL) { g_critical ("%s: %s", G_STRFUNC, error->message); diff --git a/calendar/gui/dialogs/memo-editor.c b/calendar/gui/dialogs/memo-editor.c index 8e988c00a5..8e2a5619dd 100644 --- a/calendar/gui/dialogs/memo-editor.c +++ b/calendar/gui/dialogs/memo-editor.c @@ -143,8 +143,8 @@ memo_editor_init (MemoEditor *me) gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error); id = "org.gnome.evolution.memo-editor"; - e_plugin_ui_register_manager (ui_manager, id, me); - e_plugin_ui_enable_manager (ui_manager, id); + e_plugin_ui_register_manager (E_UI_MANAGER (ui_manager), id, me); + e_plugin_ui_enable_manager (E_UI_MANAGER (ui_manager), id); if (error != NULL) { g_critical ("%s: %s", G_STRFUNC, error->message); diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index a3d4baec46..c7e0440eda 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -365,8 +365,8 @@ task_editor_init (TaskEditor *te) gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error); id = "org.gnome.evolution.task-editor"; - e_plugin_ui_register_manager (ui_manager, id, te); - e_plugin_ui_enable_manager (ui_manager, id); + e_plugin_ui_register_manager (E_UI_MANAGER (ui_manager), id, te); + e_plugin_ui_enable_manager (E_UI_MANAGER (ui_manager), id); if (error != NULL) { g_critical ("%s: %s", G_STRFUNC, error->message); diff --git a/capplet/settings/mail-account-view.c b/capplet/settings/mail-account-view.c index 9201fcf03f..b63b68b7ad 100644 --- a/capplet/settings/mail-account-view.c +++ b/capplet/settings/mail-account-view.c @@ -662,7 +662,7 @@ mail_account_view_construct (MailAccountView *view) em_account_editor_check (view->edit, mail_account_pages[0].path); view->pages[0]->done = TRUE; - if (e_shell_get_express_mode (NULL)) + if (e_shell_get_express_mode (e_shell_get_default ())) gtk_widget_hide (em_account_editor_get_widget (view->edit, "identity_optional_frame")); } diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index b57bd156a5..86275b4755 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1745,8 +1745,8 @@ msg_composer_constructed (GObject *object) gtkhtml_editor_set_changed (editor, FALSE); id = "org.gnome.evolution.composer"; - e_plugin_ui_register_manager (ui_manager, id, composer); - e_plugin_ui_enable_manager (ui_manager, id); + e_plugin_ui_register_manager (E_UI_MANAGER (ui_manager), id, composer); + e_plugin_ui_enable_manager (E_UI_MANAGER (ui_manager), id); } static void diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index 2ae9b9153a..be5171cb3d 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -15,6 +15,7 @@ e_shell_watch_window e_shell_get_watched_windows e_shell_get_active_window e_shell_send_receive +e_shell_get_express_mode e_shell_get_module_directory e_shell_get_network_available e_shell_set_network_available @@ -238,6 +239,7 @@ EShellTaskbarPrivate
e-shell-utils Shell Utilities +e_shell_configure_ui_manager e_shell_configure_web_view e_shell_run_open_dialog e_shell_run_save_dialog diff --git a/doc/reference/shell/tmpl/e-shell-switcher.sgml b/doc/reference/shell/tmpl/e-shell-switcher.sgml index f656b65988..33a6479c06 100644 --- a/doc/reference/shell/tmpl/e-shell-switcher.sgml +++ b/doc/reference/shell/tmpl/e-shell-switcher.sgml @@ -55,7 +55,8 @@ EShellSwitcher @switcher: -@action: +@switch_action: +@new_window_action: diff --git a/doc/reference/shell/tmpl/e-shell-utils.sgml b/doc/reference/shell/tmpl/e-shell-utils.sgml index 5fb4913f96..a5768cf1f8 100644 --- a/doc/reference/shell/tmpl/e-shell-utils.sgml +++ b/doc/reference/shell/tmpl/e-shell-utils.sgml @@ -17,6 +17,15 @@ Shell Utilities + + + + + +@shell: +@ui_manager: + + diff --git a/doc/reference/shell/tmpl/e-shell.sgml b/doc/reference/shell/tmpl/e-shell.sgml index 394645413c..4d3f9a4e47 100644 --- a/doc/reference/shell/tmpl/e-shell.sgml +++ b/doc/reference/shell/tmpl/e-shell.sgml @@ -94,6 +94,11 @@ EShell @eshell: the object which received the signal. + + + + + @@ -241,6 +246,15 @@ EShell @parent: + + + + + +@shell: +@Returns: + + diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 419468480e..7384333452 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -51,6 +51,7 @@ eutilinclude_HEADERS = \ e-text-event-processor-types.h \ e-text-event-processor.h \ e-timeout-activity.h \ + e-ui-manager.h \ e-util.h \ e-unicode.h \ e-xml-utils.h \ @@ -127,6 +128,7 @@ libeutil_la_SOURCES = \ e-text-event-processor-emacs-like.c \ e-text-event-processor.c \ e-timeout-activity.c \ + e-ui-manager.c \ e-util.c \ e-unicode.c \ e-util-private.h \ diff --git a/e-util/e-plugin-ui.c b/e-util/e-plugin-ui.c index 133455b108..9a9a4f23ed 100644 --- a/e-util/e-plugin-ui.c +++ b/e-util/e-plugin-ui.c @@ -16,7 +16,9 @@ */ #include "e-plugin-ui.h" + #include "e-util.h" +#include "e-ui-manager.h" #include @@ -165,7 +167,7 @@ static gpointer parent_class; static void plugin_ui_hook_unregister_manager (EPluginUIHook *hook, - GtkUIManager *ui_manager) + EUIManager *ui_manager) { GHashTable *registry; @@ -176,7 +178,7 @@ plugin_ui_hook_unregister_manager (EPluginUIHook *hook, static void plugin_ui_hook_register_manager (EPluginUIHook *hook, - GtkUIManager *ui_manager, + EUIManager *ui_manager, const gchar *id, gpointer user_data) { @@ -227,7 +229,7 @@ plugin_ui_hook_register_manager (EPluginUIHook *hook, static guint plugin_ui_hook_merge_ui (EPluginUIHook *hook, - GtkUIManager *ui_manager, + EUIManager *ui_manager, const gchar *id) { GHashTable *hash_table; @@ -239,7 +241,7 @@ plugin_ui_hook_merge_ui (EPluginUIHook *hook, ui_definition = g_hash_table_lookup (hash_table, id); g_return_val_if_fail (ui_definition != NULL, 0); - merge_id = e_load_ui_manager_definition_from_string ( + merge_id = e_ui_manager_add_ui_from_string ( ui_manager, ui_definition, &error); if (error != NULL) { @@ -252,7 +254,7 @@ plugin_ui_hook_merge_ui (EPluginUIHook *hook, static void plugin_ui_enable_manager (EPluginUIHook *hook, - GtkUIManager *ui_manager, + EUIManager *ui_manager, const gchar *id) { GHashTable *hash_table; @@ -300,7 +302,7 @@ plugin_ui_enable_manager (EPluginUIHook *hook, static void plugin_ui_disable_manager (EPluginUIHook *hook, - GtkUIManager *ui_manager, + EUIManager *ui_manager, const gchar *id, gboolean remove) { @@ -336,7 +338,8 @@ plugin_ui_disable_manager (EPluginUIHook *hook, /* Merge ID could be 0 if the plugin is disabled. */ if (merge_id > 0) - gtk_ui_manager_remove_ui (ui_manager, merge_id); + gtk_ui_manager_remove_ui ( + GTK_UI_MANAGER (ui_manager), merge_id); if (remove) g_hash_table_remove (hash_table, id); @@ -358,7 +361,7 @@ plugin_ui_enable_hook (EPluginUIHook *hook) g_hash_table_iter_init (&iter, hash_table); while (g_hash_table_iter_next (&iter, &key, NULL)) { - GtkUIManager *ui_manager = key; + EUIManager *ui_manager = key; plugin_ui_enable_manager (hook, ui_manager, NULL); } } @@ -376,7 +379,7 @@ plugin_ui_disable_hook (EPluginUIHook *hook) g_hash_table_iter_init (&iter, hash_table); while (g_hash_table_iter_next (&iter, &key, NULL)) { - GtkUIManager *ui_manager = key; + EUIManager *ui_manager = key; plugin_ui_disable_manager (hook, ui_manager, NULL, FALSE); } } @@ -546,13 +549,13 @@ e_plugin_ui_hook_get_type (void) } void -e_plugin_ui_register_manager (GtkUIManager *ui_manager, +e_plugin_ui_register_manager (EUIManager *ui_manager, const gchar *id, gpointer user_data) { GSList *plugin_list; - g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager)); + g_return_if_fail (E_IS_UI_MANAGER (ui_manager)); g_return_if_fail (id != NULL); /* Loop over all installed plugins. */ @@ -586,12 +589,12 @@ e_plugin_ui_register_manager (GtkUIManager *ui_manager, } void -e_plugin_ui_enable_manager (GtkUIManager *ui_manager, +e_plugin_ui_enable_manager (EUIManager *ui_manager, const gchar *id) { GSList *plugin_list; - g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager)); + g_return_if_fail (E_IS_UI_MANAGER (ui_manager)); g_return_if_fail (id != NULL); /* Loop over all installed plugins. */ @@ -615,12 +618,12 @@ e_plugin_ui_enable_manager (GtkUIManager *ui_manager, } void -e_plugin_ui_disable_manager (GtkUIManager *ui_manager, +e_plugin_ui_disable_manager (EUIManager *ui_manager, const gchar *id) { GSList *plugin_list; - g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager)); + g_return_if_fail (E_IS_UI_MANAGER (ui_manager)); g_return_if_fail (id != NULL); /* Loop over all installed plugins. */ diff --git a/e-util/e-plugin-ui.h b/e-util/e-plugin-ui.h index c9bddafb64..e0cbb32f2d 100644 --- a/e-util/e-plugin-ui.h +++ b/e-util/e-plugin-ui.h @@ -19,7 +19,9 @@ #define E_PLUGIN_UI_H #include -#include "e-plugin.h" + +#include +#include /* Standard GObject macros */ #define E_TYPE_PLUGIN_UI_HOOK \ @@ -57,17 +59,17 @@ struct _EPluginUIHookClass { /* Plugins with "org.gnome.evolution.ui" hooks should define a * function named e_plugin_ui_init() having this signature. */ -typedef gboolean (*EPluginUIInitFunc) (GtkUIManager *ui_manager, +typedef gboolean (*EPluginUIInitFunc) (EUIManager *ui_manager, gpointer user_data); GType e_plugin_ui_hook_get_type (void); -void e_plugin_ui_register_manager (GtkUIManager *ui_manager, +void e_plugin_ui_register_manager (EUIManager *ui_manager, const gchar *id, gpointer user_data); -void e_plugin_ui_enable_manager (GtkUIManager *ui_manager, +void e_plugin_ui_enable_manager (EUIManager *ui_manager, const gchar *id); -void e_plugin_ui_disable_manager (GtkUIManager *ui_manager, +void e_plugin_ui_disable_manager (EUIManager *ui_manager, const gchar *id); G_END_DECLS diff --git a/e-util/e-util.c b/e-util/e-util.c index 3573952244..cf5c0b0464 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -310,125 +310,6 @@ e_load_ui_builder_definition (GtkBuilder *builder, } } - -void -e_load_ui_manager_set_express (GtkUIManager *ui_manager, - gboolean express) -{ - g_object_set_data (G_OBJECT (ui_manager), - "e-ui-mgr-express", - GUINT_TO_POINTER (express)); -} - -static gboolean -e_load_ui_manager_get_express (GtkUIManager *ui_manager) -{ - gboolean express = GPOINTER_TO_UINT ( - g_object_get_data (G_OBJECT (ui_manager), - "e-ui-mgr-express")); - return express; -} - - -/** - * e_load_ui_manager_definition_from_string: - * @ui_manager: a #GtkUIManager - * @string: the UI XML in NULL terminated string form - * - * Loads a UI definition into @ui_manager from Evolution's UI directory. - * Depending on the mode signalled by the 'express' flag on the UI manager - * a simplified version of the UI may be presented. - * - * Returns: The merge ID for the merged UI. The merge ID can be used to - * unmerge the UI with gtk_ui_manager_remove_ui(). - **/ -guint -e_load_ui_manager_definition_from_string (GtkUIManager *ui_manager, - const gchar *ui_string, - GError **error) -{ - int i; - guint merge_id; - gchar *filtered, **lines; - gboolean is_express, in_conditional = FALSE; - gboolean include = TRUE; - - is_express = e_load_ui_manager_get_express (ui_manager); - - /* - * Very simple line based pre-processing based on comments: - * \n ... \n\n - */ - lines = g_strsplit (ui_string, "\n", -1); - for (i = 0; lines[i]; i++) { - char *p; - if ((p = strstr (lines[i], "