From 19eea41c74154855cb68ee3a1fb41e2ec136b764 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Wed, 3 Mar 2010 10:36:43 +0000 Subject: clean up the 'express' mode hooks for UI Managers and start to extend them to plugins - use a simple one-off boolean on the UI Manager instead of exhaustively trying to propagate this information everywhere. --- e-util/e-plugin-ui.c | 5 +- e-util/e-util.c | 122 +++++++++++++++++++++++++++------------ e-util/e-util.h | 9 ++- mail/e-mail-browser.c | 7 ++- modules/mail/e-mail-shell-view.c | 6 +- shell/e-shell-view.c | 6 +- shell/e-shell-window-actions.c | 6 +- shell/e-shell-window-private.c | 32 +++++----- ui/evolution-shell.ui | 2 +- 9 files changed, 123 insertions(+), 72 deletions(-) diff --git a/e-util/e-plugin-ui.c b/e-util/e-plugin-ui.c index c3b5b0df20..3ca8703d5a 100644 --- a/e-util/e-plugin-ui.c +++ b/e-util/e-plugin-ui.c @@ -16,6 +16,7 @@ */ #include "e-plugin-ui.h" +#include "e-util.h" #include @@ -238,8 +239,8 @@ 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 = gtk_ui_manager_add_ui_from_string ( - ui_manager, ui_definition, -1, &error); + merge_id = e_load_ui_manager_definition_from_string ( + ui_manager, ui_definition, &error); if (error != NULL) { g_warning ("%s", error->message); diff --git a/e-util/e-util.c b/e-util/e-util.c index 16f665171b..f86ee1bff4 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -310,24 +310,103 @@ e_load_ui_builder_definition (GtkBuilder *builder, } } + +void +e_load_ui_manager_set_express (GtkUIManager *ui_manager, + gboolean express) +{ + fprintf (stderr, "set express on %p to %d\n", ui_manager, 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")); + fprintf (stderr, "get express on %p to %d\n", ui_manager, 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], " ... - */ - if (g_file_get_contents (filename, &buffer, NULL, &error)) { - int i; - gchar *filtered, **lines; - gboolean include = TRUE; - - lines = g_strsplit (buffer, "\n", -1); - for (i = 0; lines[i]; i++) { - char *p; - if ((p = strstr (lines[i], " + -- cgit v1.2.3