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-util.c | 122 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 36 deletions(-) (limited to 'e-util/e-util.c') 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], "