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.) --- 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 ---- 5 files changed, 27 insertions(+), 147 deletions(-) (limited to 'e-util') 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], "