[evolution] Add generic 'express mode' conditionals to the UI XML
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Add generic 'express mode' conditionals to the UI XML
- Date: Sun, 14 Mar 2010 02:09:47 +0000 (UTC)
commit 304777ae4cd03026fcee98c0863e9e43f483c97a
Author: Michael Meeks <michael meeks novell com>
Date: Wed Feb 24 17:41:10 2010 +0000
Add generic 'express mode' conditionals to the UI XML
e-util/e-util.c | 45 +++++++++++++++++++++++++++++++++----
e-util/e-util.h | 3 +-
mail/e-mail-browser.c | 3 +-
modules/mail/e-mail-shell-view.c | 5 +++-
shell/e-shell-view.c | 5 +++-
shell/e-shell-window-actions.c | 7 ++++-
ui/evolution-mail-reader.ui | 4 +++
ui/evolution-shell.ui | 3 ++
8 files changed, 64 insertions(+), 11 deletions(-)
---
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 202c956..16f6651 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -314,28 +314,63 @@ e_load_ui_builder_definition (GtkBuilder *builder,
* 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.
+ * its UI definitions. Depending on the mode signalled by @is_express 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)
+ const gchar *basename,
+ gboolean is_express)
{
gchar *filename;
- guint merge_id;
+ guint merge_id = 0;
GError *error = NULL;
+ gchar *buffer;
g_return_val_if_fail (GTK_IS_UI_MANAGER (ui_manager), 0);
g_return_val_if_fail (basename != NULL, 0);
filename = g_build_filename (EVOLUTION_UIDIR, basename, NULL);
- merge_id = gtk_ui_manager_add_ui_from_file (
- ui_manager, filename, &error);
+
+ /*
+ * 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);
+ }
+
g_free (filename);
if (error != NULL) {
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 45d3801..5d36959 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -66,7 +66,8 @@ GtkActionGroup *e_lookup_action_group (GtkUIManager *ui_manager,
void e_load_ui_builder_definition (GtkBuilder *builder,
const gchar *basename);
guint e_load_ui_manager_definition (GtkUIManager *ui_manager,
- const gchar *basename);
+ const gchar *basename,
+ gboolean express);
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 59c09b6..91dacbb 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -505,7 +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_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);
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index b85d146..d922689 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -177,8 +177,11 @@ 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);
+ ui_manager, basename, express);
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 6135b58..d029627 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -594,8 +594,11 @@ 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);
+ ui_manager, basename, express);
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 d751251..b29a96e 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -1867,13 +1867,16 @@ 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");
+ e_load_ui_manager_definition (ui_manager, "evolution-shell.ui", express);
/* Shell Actions */
action_group = ACTION_GROUP (SHELL);
diff --git a/ui/evolution-mail-reader.ui b/ui/evolution-mail-reader.ui
index dc87cf0..b5aef12 100644
--- a/ui/evolution-mail-reader.ui
+++ b/ui/evolution-mail-reader.ui
@@ -120,15 +120,19 @@
</menu>
</toolitem>
<separator/>
+<!-- if !EXPRESS -->
<toolitem action='mail-print'/>
+<!-- endif -->
<toolitem action='mail-delete'/>
<toolitem action='mail-mark-junk'/>
<toolitem action='mail-mark-notjunk'/>
</placeholder>
<separator/>
<placeholder name='mail-toolbar-navigation'>
+<!-- if !EXPRESS -->
<toolitem action='mail-previous'/>
<toolitem action='mail-next'/>
+<!-- endif -->
</placeholder>
</toolbar>
<popup name='mail-message-popup'>
diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui
index fab9255..eb11673 100644
--- a/ui/evolution-shell.ui
+++ b/ui/evolution-shell.ui
@@ -86,5 +86,8 @@
<toolitem action='send-receive'/>
<separator/>
<placeholder name='toolbar-actions'/>
+<!-- if !EXPRESS -->
+ <toolitem action='preferences'/>
+<!-- endif -->
</toolbar>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]