aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-03-05 04:26:59 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-03-14 09:53:17 +0800
commitd7494c8f160b12e1199b06dcafdc8ff01b24b796 (patch)
tree28e4c85c915c770a4e7bfb48ede7f686d18da206 /e-util
parent51cbd483d163138c3b570b01f0921f767ca64a7e (diff)
downloadgsoc2013-evolution-d7494c8f160b12e1199b06dcafdc8ff01b24b796.tar.gz
gsoc2013-evolution-d7494c8f160b12e1199b06dcafdc8ff01b24b796.tar.zst
gsoc2013-evolution-d7494c8f160b12e1199b06dcafdc8ff01b24b796.zip
Shell and UI manager cleanups.
Replace the EVO_EXPRESS environment variable with an --express command line option. (Note, this adds a new translatable string for --help.) Add an EUIManager class with an "express-mode" property and custom load functions that use our new "express" preprocessor. This replaces the UI manager functions in e-utils.c. (Also going to see if I can get GTK+ to add an "add_ui_from_string" method to GtkUIManagerClass that we can override. Then we could just call gtk_ui_manager_add_ui_from_string() and the preprocessor would automatically do its thing and chain up.) Add an "express-mode" read-only GObject property to EShell. Add e_shell_configure_ui_manager() to e-shell-utils.c. For now this just creates a one-way property binding: EShell:express-mode -> EUIManager:express-mode Call this immediately after e_ui_manager_new(). (EUIManager can't do this itself because it lives too low in the dependency hierarchy and doesn't know about EShell.)
Diffstat (limited to 'e-util')
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-plugin-ui.c33
-rw-r--r--e-util/e-plugin-ui.h12
-rw-r--r--e-util/e-util.c119
-rw-r--r--e-util/e-util.h8
5 files changed, 27 insertions, 147 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 419468480e..7384333452 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -51,6 +51,7 @@ eutilinclude_HEADERS = \
e-text-event-processor-types.h \
e-text-event-processor.h \
e-timeout-activity.h \
+ e-ui-manager.h \
e-util.h \
e-unicode.h \
e-xml-utils.h \
@@ -127,6 +128,7 @@ libeutil_la_SOURCES = \
e-text-event-processor-emacs-like.c \
e-text-event-processor.c \
e-timeout-activity.c \
+ e-ui-manager.c \
e-util.c \
e-unicode.c \
e-util-private.h \
diff --git a/e-util/e-plugin-ui.c b/e-util/e-plugin-ui.c
index 133455b108..9a9a4f23ed 100644
--- a/e-util/e-plugin-ui.c
+++ b/e-util/e-plugin-ui.c
@@ -16,7 +16,9 @@
*/
#include "e-plugin-ui.h"
+
#include "e-util.h"
+#include "e-ui-manager.h"
#include <string.h>
@@ -165,7 +167,7 @@ static gpointer parent_class;
static void
plugin_ui_hook_unregister_manager (EPluginUIHook *hook,
- GtkUIManager *ui_manager)
+ EUIManager *ui_manager)
{
GHashTable *registry;
@@ -176,7 +178,7 @@ plugin_ui_hook_unregister_manager (EPluginUIHook *hook,
static void
plugin_ui_hook_register_manager (EPluginUIHook *hook,
- GtkUIManager *ui_manager,
+ EUIManager *ui_manager,
const gchar *id,
gpointer user_data)
{
@@ -227,7 +229,7 @@ plugin_ui_hook_register_manager (EPluginUIHook *hook,
static guint
plugin_ui_hook_merge_ui (EPluginUIHook *hook,
- GtkUIManager *ui_manager,
+ EUIManager *ui_manager,
const gchar *id)
{
GHashTable *hash_table;
@@ -239,7 +241,7 @@ 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 = e_load_ui_manager_definition_from_string (
+ merge_id = e_ui_manager_add_ui_from_string (
ui_manager, ui_definition, &error);
if (error != NULL) {
@@ -252,7 +254,7 @@ plugin_ui_hook_merge_ui (EPluginUIHook *hook,
static void
plugin_ui_enable_manager (EPluginUIHook *hook,
- GtkUIManager *ui_manager,
+ EUIManager *ui_manager,
const gchar *id)
{
GHashTable *hash_table;
@@ -300,7 +302,7 @@ plugin_ui_enable_manager (EPluginUIHook *hook,
static void
plugin_ui_disable_manager (EPluginUIHook *hook,
- GtkUIManager *ui_manager,
+ EUIManager *ui_manager,
const gchar *id,
gboolean remove)
{
@@ -336,7 +338,8 @@ plugin_ui_disable_manager (EPluginUIHook *hook,
/* Merge ID could be 0 if the plugin is disabled. */
if (merge_id > 0)
- gtk_ui_manager_remove_ui (ui_manager, merge_id);
+ gtk_ui_manager_remove_ui (
+ GTK_UI_MANAGER (ui_manager), merge_id);
if (remove)
g_hash_table_remove (hash_table, id);
@@ -358,7 +361,7 @@ plugin_ui_enable_hook (EPluginUIHook *hook)
g_hash_table_iter_init (&iter, hash_table);
while (g_hash_table_iter_next (&iter, &key, NULL)) {
- GtkUIManager *ui_manager = key;
+ EUIManager *ui_manager = key;
plugin_ui_enable_manager (hook, ui_manager, NULL);
}
}
@@ -376,7 +379,7 @@ plugin_ui_disable_hook (EPluginUIHook *hook)
g_hash_table_iter_init (&iter, hash_table);
while (g_hash_table_iter_next (&iter, &key, NULL)) {
- GtkUIManager *ui_manager = key;
+ EUIManager *ui_manager = key;
plugin_ui_disable_manager (hook, ui_manager, NULL, FALSE);
}
}
@@ -546,13 +549,13 @@ e_plugin_ui_hook_get_type (void)
}
void
-e_plugin_ui_register_manager (GtkUIManager *ui_manager,
+e_plugin_ui_register_manager (EUIManager *ui_manager,
const gchar *id,
gpointer user_data)
{
GSList *plugin_list;
- g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager));
+ g_return_if_fail (E_IS_UI_MANAGER (ui_manager));
g_return_if_fail (id != NULL);
/* Loop over all installed plugins. */
@@ -586,12 +589,12 @@ e_plugin_ui_register_manager (GtkUIManager *ui_manager,
}
void
-e_plugin_ui_enable_manager (GtkUIManager *ui_manager,
+e_plugin_ui_enable_manager (EUIManager *ui_manager,
const gchar *id)
{
GSList *plugin_list;
- g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager));
+ g_return_if_fail (E_IS_UI_MANAGER (ui_manager));
g_return_if_fail (id != NULL);
/* Loop over all installed plugins. */
@@ -615,12 +618,12 @@ e_plugin_ui_enable_manager (GtkUIManager *ui_manager,
}
void
-e_plugin_ui_disable_manager (GtkUIManager *ui_manager,
+e_plugin_ui_disable_manager (EUIManager *ui_manager,
const gchar *id)
{
GSList *plugin_list;
- g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager));
+ g_return_if_fail (E_IS_UI_MANAGER (ui_manager));
g_return_if_fail (id != NULL);
/* Loop over all installed plugins. */
diff --git a/e-util/e-plugin-ui.h b/e-util/e-plugin-ui.h
index c9bddafb64..e0cbb32f2d 100644
--- a/e-util/e-plugin-ui.h
+++ b/e-util/e-plugin-ui.h
@@ -19,7 +19,9 @@
#define E_PLUGIN_UI_H
#include <gtk/gtk.h>
-#include "e-plugin.h"
+
+#include <e-util/e-ui-manager.h>
+#include <e-util/e-plugin.h>
/* Standard GObject macros */
#define E_TYPE_PLUGIN_UI_HOOK \
@@ -57,17 +59,17 @@ struct _EPluginUIHookClass {
/* Plugins with "org.gnome.evolution.ui" hooks should define a
* function named e_plugin_ui_init() having this signature. */
-typedef gboolean (*EPluginUIInitFunc) (GtkUIManager *ui_manager,
+typedef gboolean (*EPluginUIInitFunc) (EUIManager *ui_manager,
gpointer user_data);
GType e_plugin_ui_hook_get_type (void);
-void e_plugin_ui_register_manager (GtkUIManager *ui_manager,
+void e_plugin_ui_register_manager (EUIManager *ui_manager,
const gchar *id,
gpointer user_data);
-void e_plugin_ui_enable_manager (GtkUIManager *ui_manager,
+void e_plugin_ui_enable_manager (EUIManager *ui_manager,
const gchar *id);
-void e_plugin_ui_disable_manager (GtkUIManager *ui_manager,
+void e_plugin_ui_disable_manager (EUIManager *ui_manager,
const gchar *id);
G_END_DECLS
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 3573952244..cf5c0b0464 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -310,125 +310,6 @@ e_load_ui_builder_definition (GtkBuilder *builder,
}
}
-
-void
-e_load_ui_manager_set_express (GtkUIManager *ui_manager,
- gboolean 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"));
- 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
- *
- * 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 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)
-{
- gchar *filename;
- 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);
-
- 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);
-
- if (error != NULL) {
- g_error ("%s: %s", basename, error->message);
- g_assert_not_reached ();
- }
-
- return merge_id;
-}
-
/**
* e_action_compare_by_label:
* @action1: a #GtkAction
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 34c02a2507..dfbc6c0746 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -65,14 +65,6 @@ 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);
-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