[Goodies-commits] r6662 - xfce4-dict/trunk/lib
Enrico Troeger
enrico at xfce.org
Sun Feb 8 23:10:40 CET 2009
Author: enrico
Date: 2009-02-08 22:10:40 +0000 (Sun, 08 Feb 2009)
New Revision: 6662
Modified:
xfce4-dict/trunk/lib/searchentry.c
xfce4-dict/trunk/lib/wraplabel.c
Log:
Use the G_DEFINE_TYPE() macro to generate the *_get_type() code.
Modified: xfce4-dict/trunk/lib/searchentry.c
===================================================================
--- xfce4-dict/trunk/lib/searchentry.c 2009-02-08 18:52:27 UTC (rev 6661)
+++ xfce4-dict/trunk/lib/searchentry.c 2009-02-08 22:10:40 UTC (rev 6662)
@@ -28,10 +28,6 @@
#include "sexy-icon-entry.h"
-static void xfd_search_entry_class_init (XfdSearchEntryClass *klass);
-static void xfd_search_entry_init (XfdSearchEntry *self);
-
-
enum
{
ACTIVE_CHANGED,
@@ -41,32 +37,9 @@
static guint signals[LAST_SIGNAL];
-GType xfd_search_entry_get_type(void)
-{
- static GType self_type = 0;
- if (! self_type)
- {
- static const GTypeInfo self_info =
- {
- sizeof(XfdSearchEntryClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)xfd_search_entry_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(XfdSearchEntry),
- 0,
- (GInstanceInitFunc)xfd_search_entry_init,
- NULL /* value_table */
- };
+G_DEFINE_TYPE(XfdSearchEntry, xfd_search_entry, GTK_TYPE_COMBO_BOX_ENTRY)
- self_type = g_type_register_static(GTK_TYPE_COMBO_BOX_ENTRY, "XfdSearchEntry", &self_info, 0);
- }
- return self_type;
-}
-
-
static void xfd_search_entry_class_init(XfdSearchEntryClass *klass)
{
signals[ACTIVE_CHANGED] = g_signal_new("active-changed",
Modified: xfce4-dict/trunk/lib/wraplabel.c
===================================================================
--- xfce4-dict/trunk/lib/wraplabel.c 2009-02-08 18:52:27 UTC (rev 6661)
+++ xfce4-dict/trunk/lib/wraplabel.c 2009-02-08 22:10:40 UTC (rev 6662)
@@ -31,15 +31,10 @@
#include "wraplabel.h"
-/* Local data */
-static GObjectClass *parent_class = NULL;
-
-
#define XFD_WRAP_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
XFD_WRAP_LABEL_TYPE, XfdWrapLabelPrivate))
-
struct _XfdWrapLabelClass
{
GtkLabelClass parent_class;
@@ -56,43 +51,17 @@
} XfdWrapLabelPrivate;
-static void xfd_wrap_label_class_init (XfdWrapLabelClass *klass);
-static void xfd_wrap_label_init (XfdWrapLabel *self);
+G_DEFINE_TYPE(XfdWrapLabel, xfd_wrap_label, GTK_TYPE_LABEL);
+
static void xfd_wrap_label_size_request (GtkWidget *widget, GtkRequisition *req);
static void xfd_wrap_label_size_allocate (GtkWidget *widget, GtkAllocation *alloc);
static void xfd_wrap_label_set_wrap_width (GtkWidget *widget, gsize width);
-GType xfd_wrap_label_get_type()
-{
- static GType type = G_TYPE_INVALID;
-
- if (G_UNLIKELY(type == G_TYPE_INVALID))
- {
- GTypeInfo gwl_info = {
- sizeof (XfdWrapLabelClass),
- NULL, NULL,
- (GClassInitFunc) xfd_wrap_label_class_init,
- NULL,
- NULL,
- sizeof (XfdWrapLabel),
- 3,
- (GInstanceInitFunc) xfd_wrap_label_init,
- NULL
- };
-
- type = g_type_register_static(GTK_TYPE_LABEL, "XfdWrapLabel", &gwl_info, 0);
- }
-
- return type;
-}
-
-
static void xfd_wrap_label_class_init(XfdWrapLabelClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
widget_class->size_request = xfd_wrap_label_size_request;
widget_class->size_allocate = xfd_wrap_label_size_allocate;
@@ -147,7 +116,7 @@
/* Sets the wrap width to the width allocated to us. */
static void xfd_wrap_label_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
{
- (* GTK_WIDGET_CLASS(parent_class)->size_allocate)(widget, alloc);
+ (* GTK_WIDGET_CLASS(xfd_wrap_label_parent_class)->size_allocate)(widget, alloc);
xfd_wrap_label_set_wrap_width(widget, alloc->width);
}
More information about the Goodies-commits
mailing list