diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-12 02:27:39 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-03-17 20:49:12 +0800 |
commit | 7ec9a50ee085ea083e0424dbd7e117573cf4847a (patch) | |
tree | 8cb1579c17393fbddbc2ecd88229381d406be038 | |
parent | 2e87aa81fc94f5d9564421e036adae7b48e7380a (diff) | |
download | gsoc2013-evolution-7ec9a50ee085ea083e0424dbd7e117573cf4847a.tar.gz gsoc2013-evolution-7ec9a50ee085ea083e0424dbd7e117573cf4847a.tar.zst gsoc2013-evolution-7ec9a50ee085ea083e0424dbd7e117573cf4847a.zip |
Remove EShellSettings.
EShellSettings predates GSettings and is no longer necessary.
GSettings allows binding GObject properties to GSettings keys,
with optional mapping functions. That fulfills the purpose of
EShellSettings.
-rw-r--r-- | doc/reference/libeshell/libeshell-docs.sgml | 1 | ||||
-rw-r--r-- | doc/reference/libeshell/libeshell-sections.txt | 31 | ||||
-rw-r--r-- | shell/Makefile.am | 2 | ||||
-rw-r--r-- | shell/e-shell-settings.c | 753 | ||||
-rw-r--r-- | shell/e-shell-settings.h | 109 | ||||
-rw-r--r-- | shell/e-shell.c | 78 | ||||
-rw-r--r-- | shell/e-shell.h | 2 |
7 files changed, 1 insertions, 975 deletions
diff --git a/doc/reference/libeshell/libeshell-docs.sgml b/doc/reference/libeshell/libeshell-docs.sgml index 22bc93fa19..992e0b25b1 100644 --- a/doc/reference/libeshell/libeshell-docs.sgml +++ b/doc/reference/libeshell/libeshell-docs.sgml @@ -20,7 +20,6 @@ <xi:include href="xml/e-shell-sidebar.xml"/> <xi:include href="xml/e-shell-taskbar.xml"/> <xi:include href="xml/e-shell-searchbar.xml"/> - <xi:include href="xml/e-shell-settings.xml"/> <xi:include href="xml/e-shell-switcher.xml"/> <xi:include href="xml/e-shell-utils.xml"/> </chapter> diff --git a/doc/reference/libeshell/libeshell-sections.txt b/doc/reference/libeshell/libeshell-sections.txt index 5734ef3a15..10a42cd719 100644 --- a/doc/reference/libeshell/libeshell-sections.txt +++ b/doc/reference/libeshell/libeshell-sections.txt @@ -9,7 +9,6 @@ e_shell_get_canonical_name e_shell_get_backend_by_name e_shell_get_backend_by_scheme e_shell_get_client_cache -e_shell_get_shell_settings e_shell_get_registry e_shell_create_shell_window e_shell_handle_uris @@ -151,36 +150,6 @@ EShellSearchbarPrivate </SECTION> <SECTION> -<FILE>e-shell-settings</FILE> -<TITLE>EShellSettings</TITLE> -EShellSettings -e_shell_settings_install_property -e_shell_settings_install_property_for_key -e_shell_settings_enable_debug -e_shell_settings_get_boolean -e_shell_settings_set_boolean -e_shell_settings_get_int -e_shell_settings_set_int -e_shell_settings_get_string -e_shell_settings_set_string -e_shell_settings_get_object -e_shell_settings_set_object -e_shell_settings_get_pointer -e_shell_settings_set_pointer -<SUBSECTION Standard> -E_SHELL_SETTINGS -E_IS_SHELL_SETTINGS -E_TYPE_SHELL_SETTINGS -E_SHELL_SETTINGS_CLASS -E_IS_SHELL_SETTINGS_CLASS -E_SHELL_SETTINGS_GET_CLASS -EShellSettingsClass -e_shell_settings_get_type -<SUBSECTION Private> -EShellSettingsPrivate -</SECTION> - -<SECTION> <FILE>e-shell-sidebar</FILE> <TITLE>EShellSidebar</TITLE> EShellSidebar diff --git a/shell/Makefile.am b/shell/Makefile.am index d1d3fdbcec..bd2fe53dbd 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -23,7 +23,6 @@ eshellinclude_HEADERS = \ e-shell-content.h \ e-shell-enumtypes.h \ e-shell-searchbar.h \ - e-shell-settings.h \ e-shell-sidebar.h \ e-shell-switcher.h \ e-shell-taskbar.h \ @@ -69,7 +68,6 @@ libeshell_la_SOURCES = \ e-shell-meego.c \ e-shell-meego.h \ e-shell-searchbar.c \ - e-shell-settings.c \ e-shell-sidebar.c \ e-shell-switcher.c \ e-shell-taskbar.c \ diff --git a/shell/e-shell-settings.c b/shell/e-shell-settings.c deleted file mode 100644 index 3b971b6ab1..0000000000 --- a/shell/e-shell-settings.c +++ /dev/null @@ -1,753 +0,0 @@ -/* - * e-shell-settings.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/** - * SECTION: e-shell-settings - * @short_description: settings management - * @include: shell/e-shell-settings.h - **/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-shell-settings.h" - -#define E_SHELL_SETTINGS_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsPrivate)) - -#define E_SHELL_SETTINGS_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsPrivate)) - -struct _EShellSettingsPrivate { - GArray *value_array; - guint debug : 1; -}; - -static GList *instances; -static guint property_count; -static gpointer parent_class; - -static gboolean -shell_settings_value_equal (const GValue *v1, - const GValue *v2, - gboolean is_debug) -{ - if (!v1 || !v2) - return v1 == v2; - - if (G_VALUE_HOLDS_STRING (v1) && - G_VALUE_HOLDS_STRING (v2)) { - return g_strcmp0 ( - g_value_get_string (v1), - g_value_get_string (v2)) == 0; - } else if (G_VALUE_HOLDS_UCHAR (v1) && - G_VALUE_HOLDS_UCHAR (v2)) { - return g_value_get_uchar (v1) == g_value_get_uchar (v2); - } else if (G_VALUE_HOLDS_CHAR (v1) && - G_VALUE_HOLDS_CHAR (v2)) { - return g_value_get_schar (v1) == g_value_get_schar (v2); - } else if (G_VALUE_HOLDS_INT (v1) && - G_VALUE_HOLDS_INT (v2)) { - return g_value_get_int (v1) == g_value_get_int (v2); - } else if (G_VALUE_HOLDS_UINT (v1) && - G_VALUE_HOLDS_UINT (v2)) { - return g_value_get_uint (v1) == g_value_get_uint (v2); - } else if (G_VALUE_HOLDS_LONG (v1) && - G_VALUE_HOLDS_LONG (v2)) { - return g_value_get_long (v1) == g_value_get_long (v2); - } else if (G_VALUE_HOLDS_ULONG (v1) && - G_VALUE_HOLDS_ULONG (v2)) { - return g_value_get_ulong (v1) == g_value_get_ulong (v2); - } else if (G_VALUE_HOLDS_INT64 (v1) && - G_VALUE_HOLDS_INT64 (v2)) { - return g_value_get_int64 (v1) == g_value_get_int64 (v2); - } else if (G_VALUE_HOLDS_UINT64 (v1) && - G_VALUE_HOLDS_UINT64 (v2)) { - return g_value_get_uint64 (v1) == g_value_get_uint64 (v2); - } else if (G_VALUE_HOLDS_DOUBLE (v1) && - G_VALUE_HOLDS_DOUBLE (v2)) { - return g_value_get_double (v1) == g_value_get_double (v2); - } else if (G_VALUE_HOLDS_BOOLEAN (v1) && - G_VALUE_HOLDS_BOOLEAN (v2)) { - return g_value_get_boolean (v1) == g_value_get_boolean (v2); - } else if (G_VALUE_HOLDS_POINTER (v1) && - G_VALUE_HOLDS_POINTER (v2)) { - return g_value_get_pointer (v1) == g_value_get_pointer (v2); - } - - if (is_debug) - g_debug ( - "%s: Cannot compare '%s' with '%s'", - G_STRFUNC, - G_VALUE_TYPE_NAME (v1), - G_VALUE_TYPE_NAME (v2)); - - return FALSE; -} - -static GParamSpec * -shell_settings_pspec_for_key (const gchar *property_name, - const gchar *schema, - const gchar *key) -{ - GSettings *settings; - GVariant *v; - GParamSpec *pspec; - const gchar *bad_type; - - settings = g_settings_new (schema); - - v = g_settings_get_value (settings, key); - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) { - pspec = g_param_spec_string ( - property_name, NULL, NULL, - g_variant_get_string (v, NULL), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_BYTE)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_byte (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT16)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_int16 (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT16)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_uint16 (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT32)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_int32 (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_uint32 (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT64)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_int64 (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT64)) { - pspec = g_param_spec_int ( - property_name, NULL, NULL, - G_MININT, G_MAXINT, - g_variant_get_uint64 (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_DOUBLE)) { - pspec = g_param_spec_double ( - property_name, NULL, NULL, - -G_MAXDOUBLE, G_MAXDOUBLE, - g_variant_get_double (v), - G_PARAM_READWRITE); - } else if (g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN)) { - pspec = g_param_spec_boolean ( - property_name, NULL, NULL, - g_variant_get_boolean (v), - G_PARAM_READWRITE); - } else { - bad_type = g_variant_get_type_string (v); - goto fail; - } - - g_variant_unref (v); - g_object_unref (settings); - - return pspec; - -fail: - g_error ( - "Unable to create EShellSettings property for " - "GSettings key '%s' of type '%s'", key, bad_type); - g_assert_not_reached (); -} - -static void -shell_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - EShellSettingsPrivate *priv; - GValue *dest_value; - - priv = E_SHELL_SETTINGS_GET_PRIVATE (object); - - dest_value = &g_array_index ( - priv->value_array, GValue, property_id - 1); - - if (shell_settings_value_equal (value, dest_value, priv->debug)) { - if (priv->debug) - g_debug ("Setting '%s' set, but it didn't change", pspec->name); - return; - } - - g_value_copy (value, dest_value); - g_object_notify (object, pspec->name); - - if (priv->debug) { - gchar *contents; - - contents = g_strdup_value_contents (value); - g_debug ( - "Setting '%s' set to '%s' (%s)", - pspec->name, contents, G_VALUE_TYPE_NAME (value)); - g_free (contents); - } -} - -static void -shell_settings_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - EShellSettingsPrivate *priv; - GValue *src_value; - - priv = E_SHELL_SETTINGS_GET_PRIVATE (object); - - src_value = &g_array_index ( - priv->value_array, GValue, property_id - 1); - - g_value_copy (src_value, value); -} - -static void -shell_settings_finalize (GObject *object) -{ - EShellSettingsPrivate *priv; - guint ii; - - priv = E_SHELL_SETTINGS_GET_PRIVATE (object); - - for (ii = 0; ii < priv->value_array->len; ii++) - g_value_unset (&g_array_index (priv->value_array, GValue, ii)); - - g_array_free (priv->value_array, TRUE); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -shell_settings_class_init (EShellSettingsClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (EShellSettingsPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = shell_settings_set_property; - object_class->get_property = shell_settings_get_property; - object_class->finalize = shell_settings_finalize; -} - -static void -shell_settings_init (EShellSettings *shell_settings, - GObjectClass *object_class) -{ - GArray *value_array; - GParamSpec **pspecs; - guint ii; - - instances = g_list_prepend (instances, shell_settings); - - value_array = g_array_new (FALSE, TRUE, sizeof (GValue)); - g_array_set_size (value_array, property_count); - - shell_settings->priv = E_SHELL_SETTINGS_GET_PRIVATE (shell_settings); - shell_settings->priv->value_array = value_array; - - g_object_freeze_notify (G_OBJECT (shell_settings)); - - pspecs = g_object_class_list_properties (object_class, NULL); - for (ii = 0; ii < property_count; ii++) { - GParamSpec *pspec = pspecs[ii]; - GValue *value; - - value = &g_array_index (value_array, GValue, ii); - g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - g_param_value_set_default (pspec, value); - g_object_notify (G_OBJECT (shell_settings), pspec->name); - - /* FIXME Need to bind those properties that have - * associated GSettings keys. */ - } - g_free (pspecs); - - g_object_thaw_notify (G_OBJECT (shell_settings)); -} - -GType -e_shell_settings_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - const GTypeInfo type_info = { - sizeof (EShellSettingsClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) shell_settings_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EShellSettings), - 0, /* n_preallocs */ - (GInstanceInitFunc) shell_settings_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EShellSettings", &type_info, 0); - } - - return type; -} - -/** - * e_shell_settings_install_property: - * @pspec: a #GParamSpec - * - * Installs a new #EShellSettings class property from @pspec. - * This is usually done during initialization of an #EShellBackend - * or other dynamically loaded entity. - **/ -void -e_shell_settings_install_property (GParamSpec *pspec) -{ - static GObjectClass *class = NULL; - GList *iter, *next; - - g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - - if (G_UNLIKELY (class == NULL)) - class = g_type_class_ref (E_TYPE_SHELL_SETTINGS); - - if (g_object_class_find_property (class, pspec->name) != NULL) { - g_warning ( - "Settings property \"%s\" already exists", - pspec->name); - return; - } - - for (iter = instances; iter != NULL; iter = iter->next) - g_object_freeze_notify (iter->data); - - g_object_class_install_property (class, ++property_count, pspec); - - for (iter = instances; iter != NULL; iter = iter->next) { - EShellSettings *shell_settings; - GArray *value_array; - GValue *value; - - shell_settings = E_SHELL_SETTINGS (iter->data); - value_array = shell_settings->priv->value_array; - g_array_set_size (value_array, property_count); - - value = &g_array_index ( - value_array, GValue, property_count - 1); - g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - g_param_value_set_default (pspec, value); - g_object_notify (G_OBJECT (shell_settings), pspec->name); - } - - for (iter = instances; iter != NULL; iter = next) { - next = iter->next; - g_object_thaw_notify (iter->data); - } -} - -/** - * e_shell_settings_install_property_for_key: - * @property_name: the name of the property to install - * @schema: the GSettings schema to use for @key - * @key: the GSettings key to bind the property to - * - * Installs a new #EShellSettings class property by examining the - * GSettings schema for @key to determine the appropriate type and - * default value. This is usually done during initialization of an - * #EShellBackend of other dynamically loaded entity. - * - * After the class property is installed, all #EShellSettings instances - * are bound to @key, causing @property_name and @key to have - * the same value at all times. - **/ -void -e_shell_settings_install_property_for_key (const gchar *property_name, - const gchar *schema, - const gchar *key) -{ - GParamSpec *pspec; - GList *iter, *next; - GSettings *settings; - - g_return_if_fail (property_name != NULL); - g_return_if_fail (schema != NULL); - g_return_if_fail (key != NULL); - - pspec = shell_settings_pspec_for_key (property_name, schema, key); - if (!pspec) - return; - - e_shell_settings_install_property (pspec); - - settings = g_settings_new (schema); - - for (iter = instances; iter != NULL; iter = iter->next) - g_object_freeze_notify (iter->data); - - for (iter = instances; iter != NULL; iter = iter->next) { - EShellSettings *shell_settings; - - shell_settings = E_SHELL_SETTINGS (iter->data); - - g_settings_bind ( - settings, key, G_OBJECT (shell_settings), - property_name, G_SETTINGS_BIND_DEFAULT); - } - - for (iter = instances; iter != NULL; iter = next) { - next = iter->next; - g_object_thaw_notify (iter->data); - } - - g_object_unref (settings); -} - -/** - * e_shell_settings_enable_debug: - * @shell_settings: an #EShellSettings - * - * Print a debug message to standard output when a property value changes. - **/ -void -e_shell_settings_enable_debug (EShellSettings *shell_settings) -{ - g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings)); - - shell_settings->priv->debug = TRUE; -} - -/** - * e_shell_settings_get_boolean: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * - * Return the contents of an #EShellSettings property of type - * #G_TYPE_BOOLEAN. - * - * Returns: boolean contents of @property_name - **/ -gboolean -e_shell_settings_get_boolean (EShellSettings *shell_settings, - const gchar *property_name) -{ - GObject *object; - GValue value = { 0, }; - gboolean v_boolean; - - g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), FALSE); - g_return_val_if_fail (property_name != NULL, FALSE); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_BOOLEAN); - g_object_get_property (object, property_name, &value); - v_boolean = g_value_get_boolean (&value); - g_value_unset (&value); - - return v_boolean; -} - -/** - * e_shell_settings_set_boolean: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * @v_boolean: boolean value to be set - * - * Sets the contents of an #EShellSettings property of type #G_TYPE_BOOLEAN - * to @v_boolean. If @property_name is bound to a GSettings key, the GSettings key - * will also be set to @v_boolean. - **/ -void -e_shell_settings_set_boolean (EShellSettings *shell_settings, - const gchar *property_name, - gboolean v_boolean) -{ - GObject *object; - GValue value = { 0, }; - - g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings)); - g_return_if_fail (property_name != NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, v_boolean); - g_object_set_property (object, property_name, &value); - g_value_unset (&value); -} - -/** - * e_shell_settings_get_int: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * - * Returns the contents of an #EShellSettings property of type - * #G_TYPE_INT. - * - * Returns: integer contents of @property_name - **/ -gint -e_shell_settings_get_int (EShellSettings *shell_settings, - const gchar *property_name) -{ - GObject *object; - GValue value = { 0, }; - gint v_int; - - g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), 0); - g_return_val_if_fail (property_name != NULL, 0); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_INT); - g_object_get_property (object, property_name, &value); - v_int = g_value_get_int (&value); - g_value_unset (&value); - - return v_int; -} - -/** - * e_shell_settings_set_int: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * @v_int: integer value to be set - * - * Sets the contents of an #EShellSettings property of type #G_TYPE_INT - * to @v_int. If @property_name is bound to a GSettings key, the GSettings key - * will also be set to @v_int. - **/ -void -e_shell_settings_set_int (EShellSettings *shell_settings, - const gchar *property_name, - gint v_int) -{ - GObject *object; - GValue value = { 0, }; - - g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings)); - g_return_if_fail (property_name != NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, v_int); - g_object_set_property (object, property_name, &value); - g_value_unset (&value); -} - -/** - * e_shell_settings_get_string: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * - * Returns the contents of an #EShellSettings property of type - * #G_TYPE_STRING. The returned string should be freed using g_free(). - * - * Returns: string contents of @property_name - **/ -gchar * -e_shell_settings_get_string (EShellSettings *shell_settings, - const gchar *property_name) -{ - GObject *object; - GValue value = { 0, }; - gchar *v_string; - - g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL); - g_return_val_if_fail (property_name != NULL, NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_STRING); - g_object_get_property (object, property_name, &value); - v_string = g_value_dup_string (&value); - g_value_unset (&value); - - return v_string; -} - -/** - * e_shell_settings_set_string: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * @v_string: string to be set - * - * Sets the contents of an #EShellSettings property of type #G_TYPE_STRING - * to @v_string. If @property_name is bound to a GSettings key, the GSettings key - * will also be set to @v_string. - **/ -void -e_shell_settings_set_string (EShellSettings *shell_settings, - const gchar *property_name, - const gchar *v_string) -{ - GObject *object; - GValue value = { 0, }; - - g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings)); - g_return_if_fail (property_name != NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, v_string); - g_object_set_property (object, property_name, &value); - g_value_unset (&value); -} - -/** - * e_shell_settings_get_object: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * - * Returns the contents of an #EShellSettings property of type - * #G_TYPE_OBJECT. The caller owns the reference to the returned - * object, and should call g_object_unref() when finished with it. - * - * Returns: a new reference to the object under @property_name - **/ -gpointer -e_shell_settings_get_object (EShellSettings *shell_settings, - const gchar *property_name) -{ - GObject *object; - GValue value = { 0, }; - gpointer v_object; - - g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL); - g_return_val_if_fail (property_name != NULL, NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_OBJECT); - g_object_get_property (object, property_name, &value); - v_object = g_value_dup_object (&value); - g_value_unset (&value); - - return v_object; -} - -/** - * e_shell_settings_set_object: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * @v_object: object to be set - * - * Sets the contents of an #EShellSettings property of type #G_TYPE_OBJECT - * to @v_object. - **/ -void -e_shell_settings_set_object (EShellSettings *shell_settings, - const gchar *property_name, - gpointer v_object) -{ - GObject *object; - GValue value = { 0, }; - - g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings)); - g_return_if_fail (property_name != NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_OBJECT); - g_value_set_object (&value, v_object); - g_object_set_property (object, property_name, &value); - g_value_unset (&value); -} - -/** - * e_shell_settings_get_pointer: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * - * Returns the contents of an #EShellSettings property of type - * #G_TYPE_POINTER. - * - * Returns: pointer contents of @property_name - **/ -gpointer -e_shell_settings_get_pointer (EShellSettings *shell_settings, - const gchar *property_name) -{ - GObject *object; - GValue value = { 0, }; - gpointer v_pointer; - - g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL); - g_return_val_if_fail (property_name != NULL, NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_POINTER); - g_object_get_property (object, property_name, &value); - v_pointer = g_value_get_pointer (&value); - g_value_unset (&value); - - return v_pointer; -} - -/** - * e_shell_settings_set_pointer: - * @shell_settings: an #EShellSettings - * @property_name: an installed property name - * @v_pointer: pointer to be set - * - * Sets the contents of an #EShellSettings property of type #G_TYPE_POINTER - * to @v_pointer. - **/ -void -e_shell_settings_set_pointer (EShellSettings *shell_settings, - const gchar *property_name, - gpointer v_pointer) -{ - GObject *object; - GValue value = { 0, }; - - g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings)); - g_return_if_fail (property_name != NULL); - - object = G_OBJECT (shell_settings); - g_value_init (&value, G_TYPE_POINTER); - g_value_set_pointer (&value, v_pointer); - g_object_set_property (object, property_name, &value); - g_value_unset (&value); -} diff --git a/shell/e-shell-settings.h b/shell/e-shell-settings.h deleted file mode 100644 index 0316a7bb0b..0000000000 --- a/shell/e-shell-settings.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * e-shell-settings.h - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_SHELL_SETTINGS_H -#define E_SHELL_SETTINGS_H - -#include <shell/e-shell-common.h> - -/* Standard GObject macros */ -#define E_TYPE_SHELL_SETTINGS \ - (e_shell_settings_get_type ()) -#define E_SHELL_SETTINGS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_SHELL_SETTINGS, EShellSettings)) -#define E_SHELL_SETTINGS_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_SHELL_SETTINGS, EShellSettingsClass)) -#define E_IS_SHELL_SETTINGS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_SHELL_SETTINGS)) -#define E_IS_SHELL_SETTINGS_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_SHELL_SETTINGS)) -#define E_SHELL_SETTINGS_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsClass)) - -G_BEGIN_DECLS - -typedef struct _EShellSettings EShellSettings; -typedef struct _EShellSettingsClass EShellSettingsClass; -typedef struct _EShellSettingsPrivate EShellSettingsPrivate; - -/** - * EShellSettings: - * - * Contains only private data that should be read and manipulated using the - * functions below. - **/ -struct _EShellSettings { - GObject parent; - EShellSettingsPrivate *priv; -}; - -struct _EShellSettingsClass { - GObjectClass parent_class; -}; - -GType e_shell_settings_get_type (void); -void e_shell_settings_install_property - (GParamSpec *pspec); -void e_shell_settings_install_property_for_key - (const gchar *property_name, - const gchar *schema, - const gchar *key); -void e_shell_settings_enable_debug (EShellSettings *shell_settings); - -/* Getters and setters for common EShellSettings property types. - * These are more convenient than g_object_get() / g_object_set(). - * Add more types as needed. If GObject ever adds similar functions, - * kill these. */ - -gboolean e_shell_settings_get_boolean (EShellSettings *shell_settings, - const gchar *property_name); -void e_shell_settings_set_boolean (EShellSettings *shell_settings, - const gchar *property_name, - gboolean v_boolean); -gint e_shell_settings_get_int (EShellSettings *shell_settings, - const gchar *property_name); -void e_shell_settings_set_int (EShellSettings *shell_settings, - const gchar *property_name, - gint v_int); -gchar * e_shell_settings_get_string (EShellSettings *shell_settings, - const gchar *property_name); -void e_shell_settings_set_string (EShellSettings *shell_settings, - const gchar *property_name, - const gchar *v_string); -gpointer e_shell_settings_get_object (EShellSettings *shell_settings, - const gchar *property_name); -void e_shell_settings_set_object (EShellSettings *shell_settings, - const gchar *property_name, - gpointer v_object); -gpointer e_shell_settings_get_pointer (EShellSettings *shell_settings, - const gchar *property_name); -void e_shell_settings_set_pointer (EShellSettings *shell_settings, - const gchar *property_name, - gpointer v_pointer); - -G_END_DECLS - -#endif /* E_SHELL_SETTINGS_H */ diff --git a/shell/e-shell.c b/shell/e-shell.c index 22ea2702b4..efb3348843 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -47,7 +47,6 @@ struct _EShellPrivate { GQueue alerts; - EShellSettings *settings; ESourceRegistry *registry; EClientCache *client_cache; GtkWidget *preferences_window; @@ -91,8 +90,7 @@ enum { PROP_MODULE_DIRECTORY, PROP_NETWORK_AVAILABLE, PROP_ONLINE, - PROP_REGISTRY, - PROP_SHELL_SETTINGS + PROP_REGISTRY }; enum { @@ -105,14 +103,6 @@ enum { LAST_SIGNAL }; -enum { - DEBUG_KEY_SETTINGS = 1 << 0 -}; - -static GDebugKey debug_keys[] = { - { "settings", DEBUG_KEY_SETTINGS } -}; - static gpointer default_shell; static guint signals[LAST_SIGNAL]; @@ -129,19 +119,6 @@ G_DEFINE_TYPE_WITH_CODE ( E_TYPE_EXTENSIBLE, NULL)) static void -shell_parse_debug_string (EShell *shell) -{ - guint flags; - - flags = g_parse_debug_string ( - g_getenv ("EVOLUTION_DEBUG"), - debug_keys, G_N_ELEMENTS (debug_keys)); - - if (flags & DEBUG_KEY_SETTINGS) - e_shell_settings_enable_debug (shell->priv->settings); -} - -static void shell_alert_response_cb (EShell *shell, gint response_id, EAlert *alert) @@ -685,12 +662,6 @@ shell_get_property (GObject *object, value, e_shell_get_registry ( E_SHELL (object))); return; - - case PROP_SHELL_SETTINGS: - g_value_set_object ( - value, e_shell_get_shell_settings ( - E_SHELL (object))); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -728,11 +699,6 @@ shell_dispose (GObject *object) priv->startup_view = NULL; } - if (priv->settings != NULL) { - g_object_unref (priv->settings); - priv->settings = NULL; - } - if (priv->registry != NULL) { g_object_unref (priv->registry); priv->registry = NULL; @@ -1067,21 +1033,6 @@ e_shell_class_init (EShellClass *class) G_PARAM_READABLE)); /** - * EShell:settings - * - * The #EShellSettings object stores application settings. - **/ - g_object_class_install_property ( - object_class, - PROP_SHELL_SETTINGS, - g_param_spec_object ( - "shell-settings", - "Shell Settings", - "Application-wide settings", - E_TYPE_SHELL_SETTINGS, - G_PARAM_READABLE)); - - /** * EShell::event * @shell: the #EShell which emitted the signal * @event_data: data associated with the event @@ -1244,7 +1195,6 @@ e_shell_init (EShell *shell) g_queue_init (&shell->priv->alerts); - shell->priv->settings = g_object_new (E_TYPE_SHELL_SETTINGS, NULL); shell->priv->preferences_window = e_preferences_window_new (shell); shell->priv->backends_by_name = backends_by_name; shell->priv->backends_by_scheme = backends_by_scheme; @@ -1259,20 +1209,10 @@ e_shell_init (EShell *shell) icon_theme = gtk_icon_theme_get_default (); gtk_icon_theme_append_search_path (icon_theme, EVOLUTION_ICONDIR); - shell_parse_debug_string (shell); - g_signal_connect ( shell, "notify::online", G_CALLBACK (shell_notify_online_cb), NULL); - /* XXX Do this after creating the EShellSettings instance, - * otherwise the GSettings bindings will not get set up. */ - - e_shell_settings_install_property_for_key ( - "start-offline", - "org.gnome.evolution.shell", - "start-offline"); - g_signal_connect_swapped ( G_APPLICATION (shell), "shutdown", G_CALLBACK (shell_sm_quit_cb), shell); @@ -1452,22 +1392,6 @@ e_shell_get_client_cache (EShell *shell) } /** - * e_shell_get_shell_settings: - * @shell: an #EShell - * - * Returns the #EShellSettings instance for @shell. - * - * Returns: the #EShellSettings instance for @shell - **/ -EShellSettings * -e_shell_get_shell_settings (EShell *shell) -{ - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->settings; -} - -/** * e_shell_get_registry: * @shell: an #EShell * diff --git a/shell/e-shell.h b/shell/e-shell.h index bdbbf0942f..94ed735c69 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -28,7 +28,6 @@ #include <shell/e-shell-common.h> #include <shell/e-shell-backend.h> -#include <shell/e-shell-settings.h> /* Standard GObject macros */ #define E_TYPE_SHELL \ @@ -117,7 +116,6 @@ EShellBackend * e_shell_get_backend_by_name (EShell *shell, EShellBackend * e_shell_get_backend_by_scheme (EShell *shell, const gchar *scheme); EClientCache * e_shell_get_client_cache (EShell *shell); -EShellSettings *e_shell_get_shell_settings (EShell *shell); ESourceRegistry * e_shell_get_registry (EShell *shell); GtkWidget * e_shell_create_shell_window (EShell *shell, |