diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-08-24 23:21:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-08-25 02:37:02 +0800 |
commit | ecf3434da05b1f39f793c24b38bfd278e10b5786 (patch) | |
tree | 485ed2399920ecb10dbee2b4db4c437c22574a20 /modules | |
parent | f1d2541c487fbf7433a1b9aad8e8982ef08b85f5 (diff) | |
download | gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.gz gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.bz2 gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.lz gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.xz gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.zst gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.zip |
GObject boilerplate cleanup.
Prefer thread-safe G_DEFINE_TYPE and G_DEFINE_INTERFACE macros over
manual GType registration.
This is just a start... lots more to do.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mail/e-mail-shell-content.c | 22 | ||||
-rw-r--r-- | modules/mail/em-account-prefs.c | 39 | ||||
-rw-r--r-- | modules/mail/em-composer-prefs.c | 39 | ||||
-rw-r--r-- | modules/mail/em-mailer-prefs.c | 62 | ||||
-rw-r--r-- | modules/mail/em-network-prefs.c | 59 |
5 files changed, 49 insertions, 172 deletions
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index 7a410bac55..8dc2619bfa 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -377,18 +377,18 @@ e_mail_shell_content_get_type (void) } static void -mail_shell_content_reader_init (EMailReaderIface *iface) +mail_shell_content_reader_init (EMailReaderInterface *interface) { - iface->get_action_group = mail_shell_content_get_action_group; - iface->get_formatter = mail_shell_content_get_formatter; - iface->get_hide_deleted = mail_shell_content_get_hide_deleted; - iface->get_message_list = mail_shell_content_get_message_list; - iface->get_popup_menu = mail_shell_content_get_popup_menu; - iface->get_shell_backend = mail_shell_content_get_shell_backend; - iface->get_window = mail_shell_content_get_window; - iface->set_folder = mail_shell_content_set_folder; - iface->show_search_bar = mail_shell_content_show_search_bar; - iface->open_selected_mail = mail_shell_content_open_selected_mail; + interface->get_action_group = mail_shell_content_get_action_group; + interface->get_formatter = mail_shell_content_get_formatter; + interface->get_hide_deleted = mail_shell_content_get_hide_deleted; + interface->get_message_list = mail_shell_content_get_message_list; + interface->get_popup_menu = mail_shell_content_get_popup_menu; + interface->get_shell_backend = mail_shell_content_get_shell_backend; + interface->get_window = mail_shell_content_get_window; + interface->set_folder = mail_shell_content_set_folder; + interface->show_search_bar = mail_shell_content_show_search_bar; + interface->open_selected_mail = mail_shell_content_open_selected_mail; } void diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c index 310f18ed7b..7b3b61fa9a 100644 --- a/modules/mail/em-account-prefs.c +++ b/modules/mail/em-account-prefs.c @@ -50,7 +50,10 @@ struct _EMAccountPrefsPrivate { gpointer editor; /* weak pointer */ }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EMAccountPrefs, + em_account_prefs, + E_TYPE_ACCOUNT_MANAGER) static void account_prefs_enable_account_cb (EAccountTreeView *tree_view) @@ -258,16 +261,15 @@ account_prefs_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (em_account_prefs_parent_class)->dispose (object); } static void -account_prefs_class_init (EMAccountPrefsClass *class) +em_account_prefs_class_init (EMAccountPrefsClass *class) { GObjectClass *object_class; EAccountManagerClass *account_manager_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMAccountPrefsPrivate)); object_class = G_OBJECT_CLASS (class); @@ -280,7 +282,7 @@ account_prefs_class_init (EMAccountPrefsClass *class) } static void -account_prefs_init (EMAccountPrefs *prefs) +em_account_prefs_init (EMAccountPrefs *prefs) { EAccountManager *manager; EAccountTreeView *tree_view; @@ -299,33 +301,6 @@ account_prefs_init (EMAccountPrefs *prefs) G_CALLBACK (account_prefs_disable_account_cb), NULL); } -GType -em_account_prefs_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMAccountPrefsClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) account_prefs_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMAccountPrefs), - 0, /* n_preallocs */ - (GInstanceInitFunc) account_prefs_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_ACCOUNT_MANAGER, "EMAccountPrefs", - &type_info, 0); - } - - return type; -} - GtkWidget * em_account_prefs_new (EPreferencesWindow *window) { diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index 5e0b3405c5..7db5238a62 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -55,7 +55,10 @@ #include "em-config.h" #include "em-folder-selection-button.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EMComposerPrefs, + em_composer_prefs, + GTK_TYPE_VBOX) static gboolean transform_color_to_string (const GValue *src_value, @@ -169,49 +172,21 @@ composer_prefs_finalize (GObject *object) g_object_unref (prefs->builder); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (em_composer_prefs_parent_class)->finalize (object); } static void -composer_prefs_class_init (EMComposerPrefsClass *class) +em_composer_prefs_class_init (EMComposerPrefsClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = composer_prefs_finalize; } static void -composer_prefs_init (EMComposerPrefs *prefs) -{ -} - -GType -em_composer_prefs_get_type (void) +em_composer_prefs_init (EMComposerPrefs *prefs) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMComposerPrefsClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_prefs_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMComposerPrefs), - 0, /* n_allocs */ - (GInstanceInitFunc) composer_prefs_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_VBOX, "EMComposerPrefs", &type_info, 0); - } - - return type; } void diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c index 7a6b86da18..751c395223 100644 --- a/modules/mail/em-mailer-prefs.c +++ b/modules/mail/em-mailer-prefs.c @@ -52,12 +52,6 @@ #include "em-config.h" #include "mail-session.h" -static void em_mailer_prefs_class_init (EMMailerPrefsClass *class); -static void em_mailer_prefs_init (EMMailerPrefs *dialog); -static void em_mailer_prefs_finalize (GObject *object); - -static GtkVBoxClass *parent_class = NULL; - enum { HEADER_LIST_NAME_COLUMN, /* displayable name of the header (may be a translation) */ HEADER_LIST_ENABLED_COLUMN, /* is the header enabled? */ @@ -100,36 +94,34 @@ static const struct { { N_("Once per month"), 30 }, }; -GType -em_mailer_prefs_get_type (void) +G_DEFINE_TYPE ( + EMMailerPrefs, + em_mailer_prefs, + GTK_TYPE_VBOX) + +static void +em_mailer_prefs_finalize (GObject *object) { - static GType type = 0; - - if (!type) { - GTypeInfo type_info = { - sizeof (EMMailerPrefsClass), - NULL, NULL, - (GClassInitFunc) em_mailer_prefs_class_init, - NULL, NULL, - sizeof (EMMailerPrefs), - 0, - (GInstanceInitFunc) em_mailer_prefs_init, - }; - - type = g_type_register_static (gtk_vbox_get_type (), "EMMailerPrefs", &type_info, 0); + EMMailerPrefs *prefs = (EMMailerPrefs *) object; + + g_object_unref (prefs->builder); + + if (prefs->labels_change_notify_id) { + gconf_client_notify_remove (prefs->gconf, prefs->labels_change_notify_id); + + prefs->labels_change_notify_id = 0; } - return type; + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (em_mailer_prefs_parent_class)->finalize (object); } static void -em_mailer_prefs_class_init (EMMailerPrefsClass *klass) +em_mailer_prefs_class_init (EMMailerPrefsClass *class) { GObjectClass *object_class; - object_class = (GObjectClass *) klass; - parent_class = g_type_class_ref (gtk_vbox_get_type ()); - + object_class = G_OBJECT_CLASS (class); object_class->finalize = em_mailer_prefs_finalize; } @@ -139,22 +131,6 @@ em_mailer_prefs_init (EMMailerPrefs *preferences) preferences->gconf = mail_config_get_gconf_client (); } -static void -em_mailer_prefs_finalize (GObject *obj) -{ - EMMailerPrefs *prefs = (EMMailerPrefs *) obj; - - g_object_unref (prefs->builder); - - if (prefs->labels_change_notify_id) { - gconf_client_notify_remove (prefs->gconf, prefs->labels_change_notify_id); - - prefs->labels_change_notify_id = 0; - } - - ((GObjectClass *)(parent_class))->finalize (obj); -} - static gboolean mark_seen_timeout_transform (const GValue *src_value, GValue *dst_value, diff --git a/modules/mail/em-network-prefs.c b/modules/mail/em-network-prefs.c index efa9e0a090..247ab242e4 100644 --- a/modules/mail/em-network-prefs.c +++ b/modules/mail/em-network-prefs.c @@ -61,68 +61,19 @@ #define GCONF_E_USE_PROXY_KEY GCONF_E_SHELL_NETWORK_CONFIG_PATH "use_http_proxy" #define GCONF_E_AUTOCONFIG_URL_KEY GCONF_E_SHELL_NETWORK_CONFIG_PATH "autoconfig_url" -static void em_network_prefs_class_init (EMNetworkPrefsClass *class); -static void em_network_prefs_init (EMNetworkPrefs *dialog); -static void em_network_prefs_destroy (GtkObject *obj); -static void em_network_prefs_finalise (GObject *obj); - -static GtkVBoxClass *parent_class = NULL; - -GType -em_network_prefs_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EMNetworkPrefsClass), - NULL, NULL, - (GClassInitFunc) em_network_prefs_class_init, - NULL, NULL, - sizeof (EMNetworkPrefs), - 0, - (GInstanceInitFunc) em_network_prefs_init, - }; - - type = g_type_register_static (gtk_vbox_get_type (), "EMNetworkPrefs", &info, 0); - } - - return type; -} +G_DEFINE_TYPE ( + EMNetworkPrefs, + em_network_prefs, + GTK_TYPE_VBOX) static void -em_network_prefs_class_init (EMNetworkPrefsClass *klass) +em_network_prefs_class_init (EMNetworkPrefsClass *class) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (gtk_vbox_get_type ()); - - object_class->destroy = em_network_prefs_destroy; - gobject_class->finalize = em_network_prefs_finalise; } static void em_network_prefs_init (EMNetworkPrefs *prefs) { - /* do something here */ -} - -static void -em_network_prefs_finalise (GObject *obj) -{ - d(g_print ("Network preferences finalize is called\n")); - - /* do something here */ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -em_network_prefs_destroy (GtkObject *obj) -{ - d(g_print ("Network preferences destroy is called\n")); - - GTK_OBJECT_CLASS (parent_class)->destroy (obj); } static void |