aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2010-02-25 01:41:10 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-03-14 09:49:49 +0800
commit304777ae4cd03026fcee98c0863e9e43f483c97a (patch)
treeeff5e49cd55840db565e11c80d9e8deecfa5bf91 /e-util
parent2166e7f4c73e8cc1f9b7f00027eec9de05961ee2 (diff)
downloadgsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.tar
gsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.tar.gz
gsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.tar.bz2
gsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.tar.lz
gsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.tar.xz
gsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.tar.zst
gsoc2013-evolution-304777ae4cd03026fcee98c0863e9e43f483c97a.zip
Add generic 'express mode' conditionals to the UI XML
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c45
-rw-r--r--e-util/e-util.h3
2 files changed, 42 insertions, 6 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 202c956dc1..16f665171b 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 45d3801453..5d369595bb 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