background: Rearrange the GObject boilerplate

... so that it is possible to override virtual functions and change
the order of the object creation and destruction process without having
to write a bunch of prototypes. Having the class_init below the others
helps us do that.

https://bugzilla.gnome.org/show_bug.cgi?id=731713
This commit is contained in:
Debarshi Ray 2014-06-17 11:59:58 +02:00
parent 9475b514bc
commit b950a69f3b
2 changed files with 26 additions and 26 deletions

View file

@ -32,11 +32,6 @@ G_DEFINE_TYPE (BgColorsSource, bg_colors_source, BG_TYPE_SOURCE)
#define COLORS_SOURCE_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_COLORS_SOURCE, BgColorsSourcePrivate))
static void
bg_colors_source_class_init (BgColorsSourceClass *klass)
{
}
struct {
GDesktopBackgroundShading type;
int orientation;
@ -109,6 +104,11 @@ bg_colors_source_init (BgColorsSource *self)
g_object_unref (thumb_factory);
}
static void
bg_colors_source_class_init (BgColorsSourceClass *klass)
{
}
BgColorsSource *
bg_colors_source_new (void)
{

View file

@ -40,27 +40,6 @@ struct _BgWallpapersSourcePrivate
};
static void
bg_wallpapers_source_dispose (GObject *object)
{
BgWallpapersSourcePrivate *priv = BG_WALLPAPERS_SOURCE (object)->priv;
g_clear_object (&priv->thumb_factory);
g_clear_object (&priv->xml);
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->dispose (object);
}
static void
bg_wallpapers_source_class_init (BgWallpapersSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (BgWallpapersSourcePrivate));
object_class->dispose = bg_wallpapers_source_dispose;
}
static void
load_wallpapers (gchar *key,
CcBackgroundItem *item,
@ -131,6 +110,17 @@ load_default_bg (BgWallpapersSource *self)
}
}
static void
bg_wallpapers_source_dispose (GObject *object)
{
BgWallpapersSourcePrivate *priv = BG_WALLPAPERS_SOURCE (object)->priv;
g_clear_object (&priv->thumb_factory);
g_clear_object (&priv->xml);
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->dispose (object);
}
static void
bg_wallpapers_source_init (BgWallpapersSource *self)
{
@ -150,6 +140,16 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
cc_background_xml_load_list_async (priv->xml, NULL, list_load_cb, self);
}
static void
bg_wallpapers_source_class_init (BgWallpapersSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (BgWallpapersSourcePrivate));
object_class->dispose = bg_wallpapers_source_dispose;
}
BgWallpapersSource *
bg_wallpapers_source_new (void)
{