diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-10-10 02:27:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-10-10 02:27:41 +0800 |
commit | d181e003cadfc3be2ac8b8ad020b110b94c08356 (patch) | |
tree | 6b90d877658a0002eae036b2cf71e913cb073631 /modules | |
parent | 55d5344510bd2991259d9b202988024b00c957d8 (diff) | |
download | gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.tar gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.tar.gz gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.tar.bz2 gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.tar.lz gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.tar.xz gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.tar.zst gsoc2013-evolution-d181e003cadfc3be2ac8b8ad020b110b94c08356.zip |
EBookConfigNameSelectorEntry: Use G_DEFINE_DYNAMIC_TYPE.
Follow the usual GObject conventions.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/addressbook/e-book-config-name-selector-entry.c | 84 | ||||
-rw-r--r-- | modules/addressbook/e-book-config-name-selector-entry.h | 40 | ||||
-rw-r--r-- | modules/addressbook/evolution-module-addressbook.c | 2 |
3 files changed, 82 insertions, 44 deletions
diff --git a/modules/addressbook/e-book-config-name-selector-entry.c b/modules/addressbook/e-book-config-name-selector-entry.c index 6fa761a136..ac7ccf4fce 100644 --- a/modules/addressbook/e-book-config-name-selector-entry.c +++ b/modules/addressbook/e-book-config-name-selector-entry.c @@ -22,37 +22,36 @@ #include "e-book-config-name-selector-entry.h" -#include <libebackend/libebackend.h> #include <libedataserverui/libedataserverui.h> -typedef struct _EBookConfigNameSelectorEntry EBookConfigNameSelectorEntry; -typedef struct _EBookConfigNameSelectorEntryClass EBookConfigNameSelectorEntryClass; +#define E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY, EBookConfigNameSelectorEntryPrivate)) -struct _EBookConfigNameSelectorEntry { - EExtension parent; +struct _EBookConfigNameSelectorEntryPrivate { GSettings *settings; }; -struct _EBookConfigNameSelectorEntryClass { - EExtensionClass parent_class; -}; - -static gpointer parent_class; +G_DEFINE_DYNAMIC_TYPE ( + EBookConfigNameSelectorEntry, + e_book_config_name_selector_entry, + E_TYPE_EXTENSION) static void book_config_name_selector_entry_dispose (GObject *object) { - EBookConfigNameSelectorEntry *extension; + EBookConfigNameSelectorEntryPrivate *priv; - extension = (EBookConfigNameSelectorEntry *) object; + priv = E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_GET_PRIVATE (object); - if (extension->settings != NULL) { - g_object_unref (extension->settings); - extension->settings = NULL; + if (priv->settings != NULL) { + g_object_unref (priv->settings); + priv->settings = NULL; } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_book_config_name_selector_entry_parent_class)-> + dispose (object); } static void @@ -61,32 +60,32 @@ book_config_name_selector_entry_constructed (GObject *object) EBookConfigNameSelectorEntry *extension; EExtensible *extensible; - extension = (EBookConfigNameSelectorEntry *) object; + extension = E_BOOK_CONFIG_NAME_SELECTOR_ENTRY (object); extensible = e_extension_get_extensible (E_EXTENSION (extension)); - extension->settings = g_settings_new ("org.gnome.evolution.addressbook"); - /* Chain up to parent's consturcted() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_book_config_name_selector_entry_parent_class)-> + constructed (object); g_settings_bind ( - extension->settings, "completion-minimum-query-length", + extension->priv->settings, "completion-minimum-query-length", extensible, "minimum-query-length", G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY); g_settings_bind ( - extension->settings, "completion-show-address", + extension->priv->settings, "completion-show-address", extensible, "show-address", G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY); } static void -book_config_name_selector_entry_class_init (EBookConfigNameSelectorEntryClass *class) +e_book_config_name_selector_entry_class_init (EBookConfigNameSelectorEntryClass *class) { GObjectClass *object_class; EExtensionClass *extension_class; - parent_class = g_type_class_peek_parent (class); + g_type_class_add_private ( + class, sizeof (EBookConfigNameSelectorEntryPrivate)); object_class = G_OBJECT_CLASS (class); object_class->dispose = book_config_name_selector_entry_dispose; @@ -96,23 +95,26 @@ book_config_name_selector_entry_class_init (EBookConfigNameSelectorEntryClass *c extension_class->extensible_type = E_TYPE_NAME_SELECTOR_ENTRY; } +static void +e_book_config_name_selector_entry_class_finalize (EBookConfigNameSelectorEntryClass *class) +{ +} + +static void +e_book_config_name_selector_entry_init (EBookConfigNameSelectorEntry *extension) +{ + extension->priv = + E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_GET_PRIVATE (extension); + extension->priv->settings = + g_settings_new ("org.gnome.evolution.addressbook"); +} + void -e_book_config_name_selector_entry_register_type (GTypeModule *type_module) +e_book_config_name_selector_entry_type_register (GTypeModule *type_module) { - static const GTypeInfo type_info = { - sizeof (EBookConfigNameSelectorEntryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) book_config_name_selector_entry_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EBookConfigNameSelectorEntry), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - NULL /* value_table */ - }; - - g_type_module_register_type ( - type_module, E_TYPE_EXTENSION, - "EBookConfigNameSelectorEntry", &type_info, 0); + /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration + * function, so we have to wrap it with a public function in + * order to register types from a separate compilation unit. */ + e_book_config_name_selector_entry_register_type (type_module); } + diff --git a/modules/addressbook/e-book-config-name-selector-entry.h b/modules/addressbook/e-book-config-name-selector-entry.h index e61bc028db..b326e57371 100644 --- a/modules/addressbook/e-book-config-name-selector-entry.h +++ b/modules/addressbook/e-book-config-name-selector-entry.h @@ -19,12 +19,48 @@ #ifndef E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_H #define E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_H -#include <glib-object.h> +#include <libebackend/libebackend.h> + +/* Standard GObject macros */ +#define E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY \ + (e_book_config_name_selector_entry_get_type ()) +#define E_BOOK_CONFIG_NAME_SELECTOR_ENTRY(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY, EBookConfigNameSelectorEntry)) +#define E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY, EBookConfigNameSelectorEntryClass)) +#define E_IS_BOOK_CONFIG_NAME_SELECTOR_ENTRY(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY)) +#define E_IS_BOOK_CONFIG_NAME_SELECTOR_ENTRY_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY)) +#define E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_BOOK_CONFIG_NAME_SELECTOR_ENTRY, EBookConfigNameSelectorEntryClass)) G_BEGIN_DECLS -void e_book_config_name_selector_entry_register_type (GTypeModule *type_module); +typedef struct _EBookConfigNameSelectorEntry EBookConfigNameSelectorEntry; +typedef struct _EBookConfigNameSelectorEntryClass EBookConfigNameSelectorEntryClass; +typedef struct _EBookConfigNameSelectorEntryPrivate EBookConfigNameSelectorEntryPrivate; + +struct _EBookConfigNameSelectorEntry { + EExtension parent; + EBookConfigNameSelectorEntryPrivate *priv; +}; + +struct _EBookConfigNameSelectorEntryClass { + EExtensionClass parent_class; +}; + +GType e_book_config_name_selector_entry_get_type + (void) G_GNUC_CONST; +void e_book_config_name_selector_entry_type_register + (GTypeModule *type_module); G_END_DECLS #endif /* E_BOOK_CONFIG_NAME_SELECTOR_ENTRY_H */ + diff --git a/modules/addressbook/evolution-module-addressbook.c b/modules/addressbook/evolution-module-addressbook.c index ebfdc07d36..950fdeebf9 100644 --- a/modules/addressbook/evolution-module-addressbook.c +++ b/modules/addressbook/evolution-module-addressbook.c @@ -41,7 +41,7 @@ e_module_load (GTypeModule *type_module) /* Register dynamically loaded types. */ e_book_config_hook_register_type (type_module); - e_book_config_name_selector_entry_register_type (type_module); + e_book_config_name_selector_entry_type_register (type_module); e_book_shell_view_register_type (type_module); e_book_shell_backend_type_register (type_module); |