[evolution/express] clean up the 'express' mode hooks for UI Managers and start to extend them to plugins - use a simple
- From: Michael Meeks <michael src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/express] clean up the 'express' mode hooks for UI Managers and start to extend them to plugins - use a simple
- Date: Wed, 3 Mar 2010 14:05:30 +0000 (UTC)
commit dca270ede637195769783dec009f20d4ebb53aa3
Author: Michael Meeks <michael meeks novell com>
Date: Wed Mar 3 10:36:43 2010 +0000
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.
calendar/gui/dialogs/comp-editor.c | 2 +-
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 +-
10 files changed, 124 insertions(+), 73 deletions(-)
---
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 7e16d89..1b6c3bd 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -1580,7 +1580,7 @@ comp_editor_init (CompEditor *editor)
GtkAction *action;
GtkWidget *container;
GtkWidget *widget;
- GtkWidget *scroll;
+ GtkWidget *scroll = NULL;
GtkWindow *window;
EShell *shell;
gint n_targets;
diff --git a/e-util/e-plugin-ui.c b/e-util/e-plugin-ui.c
index c3b5b0d..3ca8703 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 <string.h>
@@ -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 16f6651..f86ee1b 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:
+ * <!-- if [!]EXPRESS -->\n ... \n<!-- endif -->\n
+ */
+ lines = g_strsplit (ui_string, "\n", -1);
+ for (i = 0; lines[i]; i++) {
+ char *p;
+ if ((p = strstr (lines[i], "<!-- if "))) {
+ gboolean not_express = lines[i][8] == '!';
+ include = is_express ^ not_express;
+/* g_warning ("not express: %d from '%s' include to %d (%d)",
+ not_express, lines[i], include, is_express); */
+ lines[i][0] = '\0';
+ in_conditional = TRUE;
+ } else if ((p = strstr (lines[i], "<!-- endif"))) {
+ lines[i][0] = '\0';
+ include = TRUE;
+ in_conditional = FALSE;
+ }
+/* if (in_conditional)
+ g_warning ("conditional: (%d): '%s'", include, lines[i]); */
+ if (!include)
+ lines[i][0] = '\0';
+ }
+ filtered = g_strjoinv("\n", lines);
+
+ merge_id = gtk_ui_manager_add_ui_from_string (ui_manager, filtered, -1, error);
+
+ g_free (filtered);
+
+ return merge_id;
+}
+
/**
* e_load_ui_manager_definition:
* @ui_manager: a #GtkUIManager
* @basename: basename of the UI definition file
- * @is_express: are we in 'express' mode ?
*
* Loads a UI definition into @ui_manager from Evolution's UI directory.
* Failure here is fatal, since the application can't function without
- * its UI definitions. Depending on the mode signalled by @is_express a
- * simplified version of the UI may be presented.
+ * its UI definitions.
+ * 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 (GtkUIManager *ui_manager,
- const gchar *basename,
- gboolean is_express)
+ const gchar *basename)
{
gchar *filename;
guint merge_id = 0;
@@ -339,37 +418,8 @@ e_load_ui_manager_definition (GtkUIManager *ui_manager,
filename = g_build_filename (EVOLUTION_UIDIR, basename, NULL);
- /*
- * Very simple line based pre-processing based on comments:
- * <!-- if [!]EXPRESS --> ... <!-- endif -->
- */
- 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], "<!-- if "))) {
- gboolean not_express = lines[i][8] == '!';
- lines[i][0] = '\0';
- include = is_express ^ not_express;
- fprintf (stderr, "not exporess: %d from '%s' include to %d\n",
- not_express, lines[i], include);
- } else if ((p = strstr (lines[i], "<!-- endif"))) {
- lines[i][0] = '\0';
- include = TRUE;
- }
- if (!include)
- lines[i][0] = '\0';
- }
- filtered = g_strjoinv("\n", lines);
-
- merge_id = gtk_ui_manager_add_ui_from_string (ui_manager, filtered, -1, &error);
-
- g_free (filtered);
- }
+ if (g_file_get_contents (filename, &buffer, NULL, &error))
+ merge_id = e_load_ui_manager_definition_from_string (ui_manager, buffer, &error);
g_free (filename);
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 5d36959..34c02a2 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -65,9 +65,14 @@ GtkActionGroup *e_lookup_action_group (GtkUIManager *ui_manager,
const gchar *group_name);
void e_load_ui_builder_definition (GtkBuilder *builder,
const gchar *basename);
+void e_load_ui_manager_set_express (GtkUIManager *ui_manager,
+ gboolean express);
guint e_load_ui_manager_definition (GtkUIManager *ui_manager,
- const gchar *basename,
- gboolean express);
+ const gchar *basename);
+guint e_load_ui_manager_definition_from_string
+ (GtkUIManager *ui_manager,
+ const gchar *ui_string,
+ GError **error);
gint e_action_compare_by_label (GtkAction *action1,
GtkAction *action2);
void e_action_group_remove_all_actions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 91dacbb..13934d9 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -505,9 +505,8 @@ mail_browser_constructed (GObject *object)
G_N_ELEMENTS (mail_browser_popup_entries));
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- e_load_ui_manager_definition (ui_manager, E_MAIL_READER_UI_DEFINITION,
- e_shell_get_express_mode (shell));
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
+ e_load_ui_manager_definition (ui_manager, E_MAIL_READER_UI_DEFINITION);
+ e_load_ui_manager_definition_from_string (ui_manager, ui, NULL);
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
e_mail_reader_create_charset_menu (reader, ui_manager, merge_id);
@@ -777,6 +776,8 @@ mail_browser_init (EMailBrowser *browser)
browser->priv = E_MAIL_BROWSER_GET_PRIVATE (browser);
browser->priv->ui_manager = gtk_ui_manager_new ();
+ e_load_ui_manager_set_express (browser->priv->ui_manager,
+ e_shell_get_express_mode (NULL));
browser->priv->action_group = gtk_action_group_new ("mail-browser");
browser->priv->html_display = em_format_html_display_new ();
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index d922689..c72a366 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -177,11 +177,7 @@ mail_shell_view_toggled (EShellView *shell_view)
basename = E_MAIL_READER_UI_DEFINITION;
if (view_is_active && priv->merge_id == 0) {
- gboolean express = e_shell_get_express_mode (
- e_shell_backend_get_shell (
- e_shell_view_get_shell_backend (shell_view)));
- priv->merge_id = e_load_ui_manager_definition (
- ui_manager, basename, express);
+ priv->merge_id = e_load_ui_manager_definition (ui_manager, basename);
e_mail_reader_create_charset_menu (
E_MAIL_READER (priv->mail_shell_content),
ui_manager, priv->merge_id);
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 9b7bb9d..4a96a99 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -524,11 +524,7 @@ shell_view_toggled (EShellView *shell_view)
id = shell_view_class->ui_manager_id;
if (view_is_active && priv->merge_id == 0) {
- gboolean express = e_shell_get_express_mode (
- e_shell_backend_get_shell (
- e_shell_view_get_shell_backend (shell_view)));
- priv->merge_id = e_load_ui_manager_definition (
- ui_manager, basename, express);
+ priv->merge_id = e_load_ui_manager_definition (ui_manager, basename);
e_plugin_ui_enable_manager (ui_manager, id);
} else if (!view_is_active && priv->merge_id != 0) {
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index b29a96e..a07fb1d 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -1867,16 +1867,12 @@ e_shell_window_actions_init (EShellWindow *shell_window)
GtkActionGroup *action_group;
EFocusTracker *focus_tracker;
GtkUIManager *ui_manager;
- gboolean express;
gchar *path;
g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
- express = e_shell_get_express_mode (
- e_shell_window_get_shell (shell_window));
ui_manager = e_shell_window_get_ui_manager (shell_window);
-
- e_load_ui_manager_definition (ui_manager, "evolution-shell.ui", express);
+ e_load_ui_manager_definition (ui_manager, "evolution-shell.ui");
/* Shell Actions */
action_group = ACTION_GROUP (SHELL);
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index d380d25..32d8705 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -220,8 +220,6 @@ e_shell_window_private_init (EShellWindow *shell_window)
EShellWindowPrivate *priv = shell_window->priv;
GHashTable *loaded_views;
GArray *signal_handler_ids;
- GtkAccelGroup *accel_group;
- guint merge_id;
loaded_views = g_hash_table_new_full (
g_str_hash, g_str_equal,
@@ -249,19 +247,8 @@ e_shell_window_private_init (EShellWindow *shell_window)
e_shell_window_add_action_group (shell_window, "lockdown-print-setup");
e_shell_window_add_action_group (shell_window, "lockdown-save-to-disk");
- merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
- priv->custom_rule_merge_id = merge_id;
-
- merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
- priv->gal_view_merge_id = merge_id;
-
gtk_window_set_title (GTK_WINDOW (shell_window), _("Evolution"));
- e_shell_window_actions_init (shell_window);
-
- accel_group = gtk_ui_manager_get_accel_group (priv->ui_manager);
- gtk_window_add_accel_group (GTK_WINDOW (shell_window), accel_group);
-
g_signal_connect_swapped (
priv->ui_manager, "connect-proxy",
G_CALLBACK (shell_window_connect_proxy_cb), shell_window);
@@ -275,6 +262,7 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
EShell *shell;
GConfBridge *bridge;
GtkAction *action;
+ GtkAccelGroup *accel_group;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
GtkBox *box;
@@ -282,6 +270,7 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
GtkWidget *widget;
GtkWindow *window;
GObject *object;
+ guint merge_id;
const gchar *key;
const gchar *id;
@@ -292,6 +281,23 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
e_shell_watch_window (shell, window);
+ e_load_ui_manager_set_express (priv->ui_manager,
+ e_shell_get_express_mode (shell));
+
+ /* Defer actions and menu merging until we have set express mode */
+
+ e_shell_window_actions_init (shell_window);
+
+ accel_group = gtk_ui_manager_get_accel_group (priv->ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (shell_window), accel_group);
+
+ merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
+ priv->custom_rule_merge_id = merge_id;
+
+ merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
+ priv->gal_view_merge_id = merge_id;
+
+
/* Construct window widgets. */
widget = gtk_vbox_new (FALSE, 0);
diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui
index 3b3211a..4fe9de2 100644
--- a/ui/evolution-shell.ui
+++ b/ui/evolution-shell.ui
@@ -92,7 +92,7 @@
<toolitem action='send-receive'/>
<separator/>
<placeholder name='toolbar-actions'/>
-<!-- if !EXPRESS -->
+<!-- if EXPRESS -->
<toolitem action='preferences'/>
<!-- endif -->
</toolbar>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]