diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-03 23:03:50 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-03-17 20:49:12 +0800 |
commit | 23b89997658a8eb8bd2e1d9d20234a6978880aae (patch) | |
tree | 752c37bbf0b9d7c3bbf36d6a155533525c307f4a | |
parent | 09b7686c4a2a359aa8f747719932ccbf12c3103b (diff) | |
download | gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.tar gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.tar.gz gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.tar.bz2 gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.tar.lz gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.tar.xz gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.tar.zst gsoc2013-evolution-23b89997658a8eb8bd2e1d9d20234a6978880aae.zip |
Remove EBookShellSettings.
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-- | modules/addressbook/Makefile.am | 2 | ||||
-rw-r--r-- | modules/addressbook/autocompletion-config.c | 24 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-backend.c | 3 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-settings.c | 47 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-settings.h | 33 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-sidebar.c | 56 |
6 files changed, 58 insertions, 107 deletions
diff --git a/modules/addressbook/Makefile.am b/modules/addressbook/Makefile.am index 2accc37bef..be923f7193 100644 --- a/modules/addressbook/Makefile.am +++ b/modules/addressbook/Makefile.am @@ -36,8 +36,6 @@ module_addressbook_la_SOURCES = \ e-book-shell-content.h \ e-book-shell-migrate.c \ e-book-shell-migrate.h \ - e-book-shell-settings.c \ - e-book-shell-settings.h \ e-book-shell-sidebar.c \ e-book-shell-sidebar.h \ e-book-shell-view.c \ diff --git a/modules/addressbook/autocompletion-config.c b/modules/addressbook/autocompletion-config.c index 49aca305df..ebccce1ee2 100644 --- a/modules/addressbook/autocompletion-config.c +++ b/modules/addressbook/autocompletion-config.c @@ -65,7 +65,7 @@ add_section (GtkWidget *container, GtkWidget * autocompletion_config_new (EPreferencesWindow *window) { - EShellSettings *shell_settings; + GSettings *settings; ESourceRegistry *registry; GtkWidget *container; GtkWidget *itembox; @@ -74,11 +74,9 @@ autocompletion_config_new (EPreferencesWindow *window) EShell *shell; shell = e_preferences_window_get_shell (window); - - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - registry = e_shell_get_registry (shell); - shell_settings = e_shell_get_shell_settings (shell); + + settings = g_settings_new ("org.gnome.evolution.addressbook"); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_widget_show (vbox); @@ -96,11 +94,10 @@ autocompletion_config_new (EPreferencesWindow *window) widget = gtk_check_button_new_with_mnemonic ( _("_Format address according to standard of its destination country")); - g_object_bind_property ( - shell_settings, "enable-address-formatting", + g_settings_bind ( + settings, "address-formatting", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0); gtk_widget_show (widget); @@ -108,11 +105,10 @@ autocompletion_config_new (EPreferencesWindow *window) widget = gtk_check_button_new_with_mnemonic ( _("Always _show address of the autocompleted contact")); - g_object_bind_property ( - shell_settings, "book-completion-show-address", + g_settings_bind ( + settings, "completion-show-address", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0); gtk_widget_show (widget); @@ -131,5 +127,7 @@ autocompletion_config_new (EPreferencesWindow *window) gtk_container_add (GTK_CONTAINER (container), widget); gtk_widget_show (widget); + g_object_unref (settings); + return vbox; } diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c index 8d309a8395..bfa19826ef 100644 --- a/modules/addressbook/e-book-shell-backend.c +++ b/modules/addressbook/e-book-shell-backend.c @@ -43,7 +43,6 @@ #include "e-book-shell-content.h" #include "e-book-shell-migrate.h" -#include "e-book-shell-settings.h" #include "e-book-shell-view.h" #ifdef ENABLE_SMIME @@ -473,8 +472,6 @@ book_shell_backend_constructed (GObject *object) G_CALLBACK (book_shell_backend_window_added_cb), shell_backend); - e_book_shell_backend_init_settings (shell); - /* Initialize preferences after the main loop starts so * that all EPlugins and EPluginHooks are loaded first. */ g_idle_add ((GSourceFunc) book_shell_backend_init_preferences, shell); diff --git a/modules/addressbook/e-book-shell-settings.c b/modules/addressbook/e-book-shell-settings.c deleted file mode 100644 index 22e40a6485..0000000000 --- a/modules/addressbook/e-book-shell-settings.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * e-book-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) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-book-shell-settings.h" - -#define ADDRESSBOOK_SCHEMA "org.gnome.evolution.addressbook" - -void -e_book_shell_backend_init_settings (EShell *shell) -{ - e_shell_settings_install_property_for_key ( - "book-completion-show-address", - ADDRESSBOOK_SCHEMA, - "completion-show-address"); - - e_shell_settings_install_property_for_key ( - "book-primary-selection", - ADDRESSBOOK_SCHEMA, - "primary-addressbook"); - - e_shell_settings_install_property_for_key ( - "enable-address-formatting", - ADDRESSBOOK_SCHEMA, - "address-formatting"); -} diff --git a/modules/addressbook/e-book-shell-settings.h b/modules/addressbook/e-book-shell-settings.h deleted file mode 100644 index 9e05de41df..0000000000 --- a/modules/addressbook/e-book-shell-settings.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * e-book-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_BOOK_SHELL_SETTINGS_H -#define E_BOOK_SHELL_SETTINGS_H - -#include <shell/e-shell.h> - -G_BEGIN_DECLS - -void e_book_shell_backend_init_settings (EShell *shell); - -G_END_DECLS - -#endif /* E_CAL_SHELL_SETTINGS_H */ diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c index 094e825640..d8b25ee3f4 100644 --- a/modules/addressbook/e-book-shell-sidebar.c +++ b/modules/addressbook/e-book-shell-sidebar.c @@ -52,6 +52,43 @@ G_DEFINE_DYNAMIC_TYPE ( e_book_shell_sidebar, E_TYPE_SHELL_SIDEBAR) +static gboolean +book_shell_sidebar_map_uid_to_source (GValue *value, + GVariant *variant, + gpointer user_data) +{ + ESourceRegistry *registry; + ESource *source; + const gchar *uid; + + registry = E_SOURCE_REGISTRY (user_data); + uid = g_variant_get_string (variant, NULL); + source = e_source_registry_ref_source (registry, uid); + g_value_take_object (value, source); + + return (source != NULL); +} + +static GVariant * +book_shell_sidebar_map_source_to_uid (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + GVariant *variant = NULL; + ESource *source; + + source = g_value_get_object (value); + + if (source != NULL) { + const gchar *uid; + + uid = e_source_get_uid (source); + variant = g_variant_new_string (uid); + } + + return variant; +} + static void book_shell_sidebar_get_property (GObject *object, guint property_id, @@ -93,10 +130,10 @@ book_shell_sidebar_constructed (GObject *object) EShellView *shell_view; EShellBackend *shell_backend; EShellSidebar *shell_sidebar; - EShellSettings *shell_settings; EClientCache *client_cache; GtkContainer *container; GtkWidget *widget; + GSettings *settings; priv = E_BOOK_SHELL_SIDEBAR_GET_PRIVATE (object); @@ -106,9 +143,7 @@ book_shell_sidebar_constructed (GObject *object) shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_backend = e_shell_view_get_shell_backend (shell_view); - shell = e_shell_backend_get_shell (shell_backend); - shell_settings = e_shell_get_shell_settings (shell); container = GTK_CONTAINER (shell_sidebar); @@ -129,15 +164,18 @@ book_shell_sidebar_constructed (GObject *object) priv->selector = g_object_ref (widget); gtk_widget_show (widget); - g_object_bind_property_full ( - shell_settings, "book-primary-selection", + settings = g_settings_new ("org.gnome.evolution.addressbook"); + + g_settings_bind_with_mapping ( + settings, "primary-addressbook", widget, "primary-selection", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - (GBindingTransformFunc) e_binding_transform_uid_to_source, - (GBindingTransformFunc) e_binding_transform_source_to_uid, + G_SETTINGS_BIND_DEFAULT, + book_shell_sidebar_map_uid_to_source, + book_shell_sidebar_map_source_to_uid, e_client_cache_ref_registry (client_cache), (GDestroyNotify) g_object_unref); + + g_object_unref (settings); } static guint32 |