[evolution/express-reduced-preferences: 1/6] Utility function to hide widgets when in Express mode
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/express-reduced-preferences: 1/6] Utility function to hide widgets when in Express mode
- Date: Thu, 8 Apr 2010 00:38:12 +0000 (UTC)
commit 074824ed77b36b146744f87ccf8d63a704358632
Author: Federico Mena Quintero <federico novell com>
Date: Wed Apr 7 15:00:05 2010 -0500
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>
shell/e-shell-utils.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
shell/e-shell-utils.h | 4 +++
2 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c
index 4bc9c48..12283b1 100644
--- a/shell/e-shell-utils.c
+++ b/shell/e-shell-utils.c
@@ -348,3 +348,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 428d49a..6e8b83c 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]