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 /composer | |
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 'composer')
-rw-r--r-- | composer/e-composer-from-header.c | 39 | ||||
-rw-r--r-- | composer/e-composer-header-table.c | 41 | ||||
-rw-r--r-- | composer/e-composer-header.c | 43 | ||||
-rw-r--r-- | composer/e-composer-name-header.c | 42 | ||||
-rw-r--r-- | composer/e-composer-post-header.c | 44 | ||||
-rw-r--r-- | composer/e-composer-text-header.c | 37 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 48 |
7 files changed, 64 insertions, 230 deletions
diff --git a/composer/e-composer-from-header.c b/composer/e-composer-from-header.c index 4dadfa7ac7..856d36a1e8 100644 --- a/composer/e-composer-from-header.c +++ b/composer/e-composer-from-header.c @@ -29,9 +29,13 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static guint signal_ids[LAST_SIGNAL]; +G_DEFINE_TYPE ( + EComposerFromHeader, + e_composer_from_header, + E_TYPE_COMPOSER_HEADER) + static void composer_from_header_changed_cb (EAccountComboBox *combo_box, EComposerFromHeader *header) @@ -47,10 +51,8 @@ composer_from_header_refreshed_cb (EAccountComboBox *combo_box, } static void -composer_from_header_class_init (EComposerFromHeaderClass *class) +e_composer_from_header_class_init (EComposerFromHeaderClass *class) { - parent_class = g_type_class_peek_parent (class); - signal_ids[REFRESHED] = g_signal_new ( "refreshed", G_TYPE_FROM_CLASS (class), @@ -61,7 +63,7 @@ composer_from_header_class_init (EComposerFromHeaderClass *class) } static void -composer_from_header_init (EComposerFromHeader *header) +e_composer_from_header_init (EComposerFromHeader *header) { GtkWidget *widget; @@ -75,33 +77,6 @@ composer_from_header_init (EComposerFromHeader *header) E_COMPOSER_HEADER (header)->input_widget = widget; } -GType -e_composer_from_header_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EComposerFromHeaderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_from_header_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EComposerFromHeader), - 0, /* n_preallocs */ - (GInstanceInitFunc) composer_from_header_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_COMPOSER_HEADER, "EComposerFromHeader", - &type_info, 0); - } - - return type; -} - EComposerHeader * e_composer_from_header_new (const gchar *label) { diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c index 927408222b..d94201d129 100644 --- a/composer/e-composer-header-table.c +++ b/composer/e-composer-header-table.c @@ -72,7 +72,10 @@ struct _EComposerHeaderTablePrivate { EShell *shell; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EComposerHeaderTable, + e_composer_header_table, + GTK_TYPE_TABLE) static void g_value_set_destinations (GValue *value, @@ -532,7 +535,8 @@ composer_header_table_constructor (GType type, gboolean small_screen_mode; /* Chain up to parent's constructor() method. */ - object = G_OBJECT_CLASS (parent_class)->constructor ( + object = G_OBJECT_CLASS ( + e_composer_header_table_parent_class)->constructor ( type, n_construct_properties, construct_properties); priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (object); @@ -830,16 +834,15 @@ composer_header_table_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_composer_header_table_parent_class)->dispose (object); } static void -composer_header_table_class_init (EComposerHeaderTableClass *class) +e_composer_header_table_class_init (EComposerHeaderTableClass *class) { GObjectClass *object_class; GParamSpec *element_spec; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EComposerHeaderTablePrivate)); object_class = G_OBJECT_CLASS (class); @@ -987,7 +990,7 @@ composer_header_table_class_init (EComposerHeaderTableClass *class) } static void -composer_header_table_init (EComposerHeaderTable *table) +e_composer_header_table_init (EComposerHeaderTable *table) { EComposerHeader *header; ENameSelector *name_selector; @@ -1058,32 +1061,6 @@ composer_header_table_init (EComposerHeaderTable *table) } } -GType -e_composer_header_table_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EComposerHeaderTableClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_header_table_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EComposerHeaderTable), - 0, /* n_preallocs */ - (GInstanceInitFunc) composer_header_table_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_TABLE, "EComposerHeaderTable", &type_info, 0); - } - - return type; -} - GtkWidget * e_composer_header_table_new (EShell *shell) { diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c index 0c634175de..76c5d89b14 100644 --- a/composer/e-composer-header.c +++ b/composer/e-composer-header.c @@ -56,9 +56,13 @@ struct _EComposerHeaderPrivate { guint visible : 1; }; -static gpointer parent_class; static guint signal_ids[LAST_SIGNAL]; +G_DEFINE_ABSTRACT_TYPE ( + EComposerHeader, + e_composer_header, + G_TYPE_OBJECT) + static void composer_header_button_clicked_cb (GtkButton *button, EComposerHeader *header) @@ -78,7 +82,8 @@ composer_header_constructor (GType type, GtkWidget *label; /* Chain up to parent's constructor() method. */ - object = G_OBJECT_CLASS (parent_class)->constructor ( + object = G_OBJECT_CLASS ( + e_composer_header_parent_class)->constructor ( type, n_construct_properties, construct_properties); header = E_COMPOSER_HEADER (object); @@ -197,15 +202,14 @@ composer_header_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_composer_header_parent_class)->dispose (object); } static void -composer_header_class_init (EComposerHeaderClass *class) +e_composer_header_class_init (EComposerHeaderClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EComposerHeaderPrivate)); object_class = G_OBJECT_CLASS (class); @@ -276,38 +280,11 @@ composer_header_class_init (EComposerHeaderClass *class) } static void -composer_header_init (EComposerHeader *header) +e_composer_header_init (EComposerHeader *header) { header->priv = E_COMPOSER_HEADER_GET_PRIVATE (header); } -GType -e_composer_header_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EComposerHeaderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_header_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EComposerHeader), - 0, /* n_preallocs */ - (GInstanceInitFunc) composer_header_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EComposerHeader", - &type_info, G_TYPE_FLAG_ABSTRACT); - } - - return type; -} - gchar * e_composer_header_get_label (EComposerHeader *header) { diff --git a/composer/e-composer-name-header.c b/composer/e-composer-name-header.c index 3544ff0f21..919e946152 100644 --- a/composer/e-composer-name-header.c +++ b/composer/e-composer-name-header.c @@ -45,7 +45,10 @@ struct _EComposerNameHeaderPrivate { guint destination_index; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EComposerNameHeader, + e_composer_name_header, + E_TYPE_COMPOSER_HEADER) static gpointer contact_editor_fudge_new (EBook *book, @@ -116,7 +119,8 @@ composer_name_header_constructor (GType type, gchar *label; /* Chain up to parent's constructor() method. */ - object = G_OBJECT_CLASS (parent_class)->constructor ( + object = G_OBJECT_CLASS ( + e_composer_name_header_parent_class)->constructor ( type, n_construct_properties, construct_properties); priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object); @@ -210,7 +214,7 @@ composer_name_header_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_composer_name_header_parent_class)->dispose (object); } static void @@ -230,12 +234,11 @@ composer_name_header_clicked (EComposerHeader *header) } static void -composer_name_header_class_init (EComposerNameHeaderClass *class) +e_composer_name_header_class_init (EComposerNameHeaderClass *class) { GObjectClass *object_class; EComposerHeaderClass *header_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EComposerNameHeaderPrivate)); object_class = G_OBJECT_CLASS (class); @@ -260,38 +263,11 @@ composer_name_header_class_init (EComposerNameHeaderClass *class) } static void -composer_name_header_init (EComposerNameHeader *header) +e_composer_name_header_init (EComposerNameHeader *header) { header->priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header); } -GType -e_composer_name_header_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EComposerNameHeaderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_name_header_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EComposerNameHeader), - 0, /* n_preallocs */ - (GInstanceInitFunc) composer_name_header_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_COMPOSER_HEADER, "EComposerNameHeader", - &type_info, 0); - } - - return type; -} - EComposerHeader * e_composer_name_header_new (const gchar *label, ENameSelector *name_selector) diff --git a/composer/e-composer-post-header.c b/composer/e-composer-post-header.c index 43b2a9d37d..3d79c9ca2c 100644 --- a/composer/e-composer-post-header.c +++ b/composer/e-composer-post-header.c @@ -39,7 +39,10 @@ struct _EComposerPostHeaderPrivate { gboolean custom; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EComposerPostHeader, + e_composer_post_header, + E_TYPE_COMPOSER_TEXT_HEADER) static gchar * composer_post_header_folder_name_to_string (EComposerPostHeader *header, @@ -118,7 +121,8 @@ composer_post_header_constructor (GType type, GObject *object; /* Chain up to parent's constructor() method. */ - object = G_OBJECT_CLASS (parent_class)->constructor ( + object = G_OBJECT_CLASS ( + e_composer_post_header_parent_class)->constructor ( type, n_construct_properties, construct_properties); e_composer_header_set_title_tooltip ( @@ -175,7 +179,7 @@ composer_post_header_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_composer_post_header_parent_class)->dispose (object); } static void @@ -188,7 +192,7 @@ composer_post_header_finalize (GObject *object) g_free (priv->base_url); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_composer_post_header_parent_class)->finalize (object); } static void @@ -212,12 +216,11 @@ composer_post_header_clicked (EComposerHeader *header) } static void -composer_post_header_class_init (EComposerPostHeaderClass *class) +e_composer_post_header_class_init (EComposerPostHeaderClass *class) { GObjectClass *object_class; EComposerHeaderClass *header_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EComposerPostHeaderPrivate)); object_class = G_OBJECT_CLASS (class); @@ -243,38 +246,11 @@ composer_post_header_class_init (EComposerPostHeaderClass *class) } static void -composer_post_header_init (EComposerPostHeader *header) +e_composer_post_header_init (EComposerPostHeader *header) { header->priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header); } -GType -e_composer_post_header_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EComposerPostHeaderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_post_header_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EComposerPostHeader), - 0, /* n_preallocs */ - (GInstanceInitFunc) composer_post_header_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_COMPOSER_TEXT_HEADER, - "EComposerPostHeader", &type_info, 0); - } - - return type; -} - EComposerHeader * e_composer_post_header_new (const gchar *label) { diff --git a/composer/e-composer-text-header.c b/composer/e-composer-text-header.c index efbf141cea..d92901d55e 100644 --- a/composer/e-composer-text-header.c +++ b/composer/e-composer-text-header.c @@ -30,7 +30,10 @@ struct _EComposerTextHeaderPrivate { guint destination_index; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EComposerTextHeader, + e_composer_text_header, + E_TYPE_COMPOSER_HEADER) static void composer_text_header_changed_cb (GtkEntry *entry, @@ -59,13 +62,12 @@ composer_text_header_query_tooltip_cb (GtkEntry *entry, } static void -composer_text_header_class_init (EComposerTextHeaderClass *class) +e_composer_text_header_class_init (EComposerTextHeaderClass *class) { - parent_class = g_type_class_peek_parent (class); } static void -composer_text_header_init (EComposerTextHeader *header) +e_composer_text_header_init (EComposerTextHeader *header) { GtkWidget *widget; @@ -80,33 +82,6 @@ composer_text_header_init (EComposerTextHeader *header) E_COMPOSER_HEADER (header)->input_widget = widget; } -GType -e_composer_text_header_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EComposerTextHeaderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) composer_text_header_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EComposerTextHeader), - 0, /* n_preallocs */ - (GInstanceInitFunc) composer_text_header_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_COMPOSER_HEADER, "EComposerTextHeader", - &type_info, 0); - } - - return type; -} - EComposerHeader * e_composer_text_header_new_label (const gchar *label) { diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 4a6c6b267f..821b063e62 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -86,7 +86,6 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static guint signals[LAST_SIGNAL]; /* local prototypes */ @@ -114,6 +113,11 @@ static void handle_multipart_signed (EMsgComposer *composer, CamelMultipart *multipart, gint depth); +G_DEFINE_TYPE ( + EMsgComposer, + e_msg_composer, + GTKHTML_TYPE_EDITOR) + /** * emcu_part_to_html: * @part: @@ -1823,7 +1827,7 @@ msg_composer_dispose (GObject *object) e_composer_private_dispose (composer); /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_msg_composer_parent_class)->dispose (object); } static void @@ -1835,7 +1839,7 @@ msg_composer_finalize (GObject *object) e_composer_private_finalize (composer); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_msg_composer_parent_class)->finalize (object); } static void @@ -2011,7 +2015,7 @@ msg_composer_destroy (GtkObject *object) shell, msg_composer_prepare_for_quit_cb, composer); /* Chain up to parent's destroy() method. */ - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (e_msg_composer_parent_class)->destroy (object); } static void @@ -2022,7 +2026,7 @@ msg_composer_map (GtkWidget *widget) const gchar *text; /* Chain up to parent's map() method. */ - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (e_msg_composer_parent_class)->map (widget); table = e_msg_composer_get_header_table (E_MSG_COMPOSER (widget)); @@ -2091,7 +2095,8 @@ msg_composer_key_press_event (GtkWidget *widget, } /* Chain up to parent's key_press_event() method. */ - return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); + return GTK_WIDGET_CLASS (e_msg_composer_parent_class)-> + key_press_event (widget, event); } static void @@ -2268,14 +2273,13 @@ msg_composer_object_deleted (GtkhtmlEditor *editor) } static void -msg_composer_class_init (EMsgComposerClass *class) +e_msg_composer_class_init (EMsgComposerClass *class) { GObjectClass *object_class; GtkObjectClass *gtk_object_class; GtkWidgetClass *widget_class; GtkhtmlEditorClass *editor_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMsgComposerPrivate)); object_class = G_OBJECT_CLASS (class); @@ -2351,37 +2355,11 @@ msg_composer_class_init (EMsgComposerClass *class) } static void -msg_composer_init (EMsgComposer *composer) +e_msg_composer_init (EMsgComposer *composer) { composer->priv = E_MSG_COMPOSER_GET_PRIVATE (composer); } -GType -e_msg_composer_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMsgComposerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) msg_composer_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMsgComposer), - 0, /* n_preallocs */ - (GInstanceInitFunc) msg_composer_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTKHTML_TYPE_EDITOR, "EMsgComposer", &type_info, 0); - } - - return type; -} - /* Callbacks. */ /** |