diff --git a/src/ui/frames.c b/src/ui/frames.c index ba6c81c13..0ba4d6e5e 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -43,8 +43,6 @@ #define DEFAULT_INNER_BUTTON_BORDER 3 -static void meta_frames_class_init (MetaFramesClass *klass); -static void meta_frames_init (MetaFrames *frames); static void meta_frames_destroy (GtkObject *object); static void meta_frames_finalize (GObject *object); static void meta_frames_style_set (GtkWidget *widget, @@ -108,32 +106,7 @@ static void invalidate_all_caches (MetaFrames *frames); static void invalidate_whole_window (MetaFrames *frames, MetaUIFrame *frame); -static GtkWidgetClass *parent_class = NULL; - -GType -meta_frames_get_type (void) -{ - static GType frames_type = 0; - - if (!frames_type) - { - static const GtkTypeInfo frames_info = - { - "MetaFrames", - sizeof (MetaFrames), - sizeof (MetaFramesClass), - (GtkClassInitFunc) meta_frames_class_init, - (GtkObjectInitFunc) meta_frames_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - frames_type = gtk_type_unique (GTK_TYPE_WINDOW, &frames_info); - } - - return frames_type; -} +G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_WINDOW); static GObject * meta_frames_constructor (GType gtype, @@ -143,7 +116,7 @@ meta_frames_constructor (GType gtype, GObject *object; GObjectClass *gobject_class; - gobject_class = G_OBJECT_CLASS (parent_class); + gobject_class = G_OBJECT_CLASS (meta_frames_parent_class); object = gobject_class->constructor (gtype, n_properties, properties); g_object_set (object, @@ -164,8 +137,6 @@ meta_frames_class_init (MetaFramesClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->constructor = meta_frames_constructor; gobject_class->finalize = meta_frames_finalize; object_class->destroy = meta_frames_destroy; @@ -275,7 +246,7 @@ meta_frames_destroy (GtkObject *object) } g_slist_free (winlist); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (meta_frames_parent_class)->destroy (object); } static void @@ -297,7 +268,7 @@ meta_frames_finalize (GObject *object) g_hash_table_destroy (frames->frames); g_hash_table_destroy (frames->cache); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (meta_frames_parent_class)->finalize (object); } typedef struct @@ -467,7 +438,7 @@ meta_frames_style_set (GtkWidget *widget, g_hash_table_foreach (frames->frames, reattach_style_func, frames); - GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); + GTK_WIDGET_CLASS (meta_frames_parent_class)->style_set (widget, prev_style); } static void @@ -705,15 +676,15 @@ meta_frames_unmanage_window (MetaFrames *frames, static void meta_frames_realize (GtkWidget *widget) { - if (GTK_WIDGET_CLASS (parent_class)->realize) - GTK_WIDGET_CLASS (parent_class)->realize (widget); + if (GTK_WIDGET_CLASS (meta_frames_parent_class)->realize) + GTK_WIDGET_CLASS (meta_frames_parent_class)->realize (widget); } static void meta_frames_unrealize (GtkWidget *widget) { - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + if (GTK_WIDGET_CLASS (meta_frames_parent_class)->unrealize) + GTK_WIDGET_CLASS (meta_frames_parent_class)->unrealize (widget); } static MetaUIFrame* diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c index 565f07ca0..b08c0d6f5 100644 --- a/src/ui/metaaccellabel.c +++ b/src/ui/metaaccellabel.c @@ -39,8 +39,6 @@ #include "gtk-compat.h" -static void meta_accel_label_class_init (MetaAccelLabelClass *klass); -static void meta_accel_label_init (MetaAccelLabel *accel_label); static void meta_accel_label_destroy (GtkObject *object); static void meta_accel_label_finalize (GObject *object); static void meta_accel_label_size_request (GtkWidget *widget, @@ -51,34 +49,7 @@ static gboolean meta_accel_label_expose_event (GtkWidget *widget, static void meta_accel_label_update (MetaAccelLabel *accel_label); static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label); - -static GtkLabelClass *parent_class = NULL; - - -GType -meta_accel_label_get_type (void) -{ - static GType accel_label_type = 0; - - if (!accel_label_type) - { - static const GtkTypeInfo accel_label_info = - { - "MetaAccelLabel", - sizeof (MetaAccelLabel), - sizeof (MetaAccelLabelClass), - (GtkClassInitFunc) meta_accel_label_class_init, - (GtkObjectInitFunc) meta_accel_label_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - accel_label_type = gtk_type_unique (GTK_TYPE_LABEL, &accel_label_info); - } - - return accel_label_type; -} +G_DEFINE_TYPE (MetaAccelLabel, meta_accel_label, GTK_TYPE_LABEL); static void meta_accel_label_class_init (MetaAccelLabelClass *class) @@ -87,8 +58,6 @@ meta_accel_label_class_init (MetaAccelLabelClass *class) GtkObjectClass *object_class = GTK_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = meta_accel_label_finalize; object_class->destroy = meta_accel_label_destroy; @@ -199,7 +168,7 @@ meta_accel_label_destroy (GtkObject *object) accel_label->accel_mods = 0; accel_label->accel_key = 0; - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (meta_accel_label_parent_class)->destroy (object); } static void @@ -209,7 +178,7 @@ meta_accel_label_finalize (GObject *object) g_free (accel_label->accel_string); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (meta_accel_label_parent_class)->finalize (object); } void @@ -246,8 +215,8 @@ meta_accel_label_size_request (GtkWidget *widget, PangoLayout *layout; gint width; - if (GTK_WIDGET_CLASS (parent_class)->size_request) - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->size_request) + GTK_WIDGET_CLASS (meta_accel_label_parent_class)->size_request (widget, requisition); layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string); pango_layout_get_pixel_size (layout, &width, NULL); @@ -291,8 +260,8 @@ meta_accel_label_expose_event (GtkWidget *widget, allocation.width -= ac_width; gtk_widget_set_allocation (widget, &allocation); - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event) + GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event (widget, event); if (direction == GTK_TEXT_DIR_RTL) { @@ -330,8 +299,8 @@ meta_accel_label_expose_event (GtkWidget *widget, } else { - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event) + GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event (widget, event); } } diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c index 77d0abda9..c023ca9eb 100644 --- a/src/ui/preview-widget.c +++ b/src/ui/preview-widget.c @@ -28,8 +28,6 @@ #include #include "preview-widget.h" -static void meta_preview_class_init (MetaPreviewClass *klass); -static void meta_preview_init (MetaPreview *preview); static void meta_preview_size_request (GtkWidget *widget, GtkRequisition *req); static void meta_preview_size_allocate (GtkWidget *widget, @@ -38,32 +36,7 @@ static gboolean meta_preview_expose (GtkWidget *widget, GdkEventExpose *event); static void meta_preview_finalize (GObject *object); -static GtkWidgetClass *parent_class; - -GType -meta_preview_get_type (void) -{ - static GType preview_type = 0; - - if (!preview_type) - { - static const GtkTypeInfo preview_info = - { - "MetaPreview", - sizeof (MetaPreview), - sizeof (MetaPreviewClass), - (GtkClassInitFunc) meta_preview_class_init, - (GtkObjectInitFunc) meta_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - preview_type = gtk_type_unique (GTK_TYPE_BIN, &preview_info); - } - - return preview_type; -} +G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN); static void meta_preview_class_init (MetaPreviewClass *class) @@ -72,7 +45,6 @@ meta_preview_class_init (MetaPreviewClass *class) GtkWidgetClass *widget_class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek (GTK_TYPE_BIN); gobject_class->finalize = meta_preview_finalize; @@ -125,7 +97,7 @@ meta_preview_new (void) { MetaPreview *preview; - preview = gtk_type_new (META_TYPE_PREVIEW); + preview = g_object_new (META_TYPE_PREVIEW, NULL); return GTK_WIDGET (preview); } @@ -140,7 +112,7 @@ meta_preview_finalize (GObject *object) g_free (preview->title); preview->title = NULL; - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (meta_preview_parent_class)->finalize (object); } static void @@ -266,7 +238,7 @@ meta_preview_expose (GtkWidget *widget, } /* draw child */ - return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + return GTK_WIDGET_CLASS (meta_preview_parent_class)->expose_event (widget, event); } static void diff --git a/src/ui/themewidget.c b/src/ui/themewidget.c index 59f91bb99..37cbd5c44 100644 --- a/src/ui/themewidget.c +++ b/src/ui/themewidget.c @@ -26,8 +26,6 @@ #include "gtk-compat.h" -static void meta_area_class_init (MetaAreaClass *klass); -static void meta_area_init (MetaArea *area); static void meta_area_size_request (GtkWidget *widget, GtkRequisition *req); static gint meta_area_expose (GtkWidget *widget, @@ -35,32 +33,7 @@ static gint meta_area_expose (GtkWidget *widget, static void meta_area_finalize (GObject *object); -static GtkMiscClass *parent_class; - -GType -meta_area_get_type (void) -{ - static GType area_type = 0; - - if (!area_type) - { - static const GtkTypeInfo area_info = - { - "MetaArea", - sizeof (MetaArea), - sizeof (MetaAreaClass), - (GtkClassInitFunc) meta_area_class_init, - (GtkObjectInitFunc) meta_area_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - area_type = gtk_type_unique (GTK_TYPE_MISC, &area_info); - } - - return area_type; -} +G_DEFINE_TYPE (MetaArea, meta_area, GTK_TYPE_MISC); static void meta_area_class_init (MetaAreaClass *class) @@ -71,7 +44,6 @@ meta_area_class_init (MetaAreaClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek (gtk_misc_get_type ()); gobject_class->finalize = meta_area_finalize; @@ -90,7 +62,7 @@ meta_area_new (void) { MetaArea *area; - area = gtk_type_new (META_TYPE_AREA); + area = g_object_new (META_TYPE_AREA, NULL); return GTK_WIDGET (area); } @@ -105,7 +77,7 @@ meta_area_finalize (GObject *object) if (area->dnotify) (* area->dnotify) (area->user_data); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (meta_area_parent_class)->finalize (object); } static gint