aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-04-08 04:00:05 +0800
committerFederico Mena Quintero <federico@novell.com>2010-04-09 06:48:08 +0800
commitfe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba (patch)
treee861afcea191192accfd1b8777f3dcbf53c07f76
parent5b397348258994539b452006e988be78a43a2fae (diff)
downloadgsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.tar
gsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.tar.gz
gsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.tar.bz2
gsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.tar.lz
gsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.tar.xz
gsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.tar.zst
gsoc2013-evolution-fe8eabe6d710b846ab9d2d95dcf60ed3de9e51ba.zip
Utility function to hide widgets when in Express mode
Express mode requires a reduced preferences dialog. Many options in the current preferences dialog are pure, unadulterated crack. So we need an easy way to hide them, to simplify the dialog and reduce its size. Here we add a function that takes a GConf key, reads a list of strings from that key, and hides the widgets whose names are those strings. This gives us an easy way to experiment with what widgets should be hidden in the preferences dialog, without needing to recompile all the time. Signed-off-by: Federico Mena Quintero <federico@novell.com>
-rw-r--r--shell/e-shell-utils.c58
-rw-r--r--shell/e-shell-utils.h4
2 files changed, 62 insertions, 0 deletions
diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c
index 1b80378277..81380d4d0a 100644
--- a/shell/e-shell-utils.c
+++ b/shell/e-shell-utils.c
@@ -346,3 +346,61 @@ e_shell_utils_import_uris (EShell *shell, gchar **uris, gboolean preview)
return g_strv_length (uris);
}
+
+/**
+ * e_shell_hide_widgets_for_express_mode:
+ * @shell: an #EShell
+ * @builder: a #GtkBuilder
+ * @key_with_widget_names: The name of a GConf key; see below.
+ *
+ * If Evolution is running in Express mode (i.e. if the specified @shell is in
+ * Express mode), then this function will first read the specified GConf key.
+ * This key must contain a string list, and each element of that list must be
+ * the name of a widget present in @builder. Those widgets will then get
+ * hidden.
+ *
+ * This can be used to simplify preference dialogs and such in an easy fashion, for use
+ * in Express mode.
+ *
+ * If Evolution is not running in Express mode, this function does nothing.
+ */
+void
+e_shell_hide_widgets_for_express_mode (EShell *shell,
+ GtkBuilder *builder,
+ const char *key_with_widget_names)
+{
+ GConfClient *client;
+ GSList *names;
+ GSList *l;
+
+ g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (GTK_IS_BUILDER (builder));
+ g_return_if_fail (key_with_widget_names != NULL);
+
+ if (!e_shell_get_express_mode (shell))
+ return;
+
+ client = e_shell_get_gconf_client (shell);
+
+ names = gconf_client_get_list (client, key_with_widget_names, GCONF_VALUE_STRING, NULL); /* NULL-GError */
+ if (!names)
+ return;
+
+ for (l = names; l; l = l->next) {
+ const char *name;
+ GObject *object;
+
+ name = l->data;
+ object = gtk_builder_get_object (builder, name);
+ if (!object || !GTK_IS_WIDGET (object)) {
+ g_error ("Object '%s' was not found in the builder file, or it is not a GtkWidget", name);
+ g_assert_not_reached ();
+ }
+
+ gtk_widget_hide (GTK_WIDGET (object));
+ }
+
+ g_slist_foreach (names, (GFunc) g_free, NULL);
+ g_slist_free (names);
+}
+
diff --git a/shell/e-shell-utils.h b/shell/e-shell-utils.h
index 428d49a836..6e8b83c973 100644
--- a/shell/e-shell-utils.h
+++ b/shell/e-shell-utils.h
@@ -50,6 +50,10 @@ guint e_shell_utils_import_uris (EShell *shell,
gchar **uris,
gboolean preview);
+void e_shell_hide_widgets_for_express_mode (EShell *shell,
+ GtkBuilder *builder,
+ const char *key_with_widget_names);
+
G_END_DECLS
#endif /* E_SHELL_UTILS_H */