shell: Use G_DEFINE_TYPE_WITH_PRIVATE() and friends

This commit is contained in:
Florian Müllner 2015-09-24 18:56:13 +02:00
parent ffe4eaf00d
commit e25502aeb2
10 changed files with 33 additions and 58 deletions

View File

@ -45,7 +45,7 @@ struct _ShellAppSystemPrivate {
static void shell_app_system_finalize (GObject *object); static void shell_app_system_finalize (GObject *object);
G_DEFINE_TYPE(ShellAppSystem, shell_app_system, G_TYPE_OBJECT); G_DEFINE_TYPE_WITH_PRIVATE (ShellAppSystem, shell_app_system, G_TYPE_OBJECT);
static void shell_app_system_class_init(ShellAppSystemClass *klass) static void shell_app_system_class_init(ShellAppSystemClass *klass)
{ {
@ -67,8 +67,6 @@ static void shell_app_system_class_init(ShellAppSystemClass *klass)
G_STRUCT_OFFSET (ShellAppSystemClass, installed_changed), G_STRUCT_OFFSET (ShellAppSystemClass, installed_changed),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
g_type_class_add_private (gobject_class, sizeof (ShellAppSystemPrivate));
} }
static void static void
@ -147,9 +145,7 @@ shell_app_system_init (ShellAppSystem *self)
ShellAppSystemPrivate *priv; ShellAppSystemPrivate *priv;
GAppInfoMonitor *monitor; GAppInfoMonitor *monitor;
self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (self, self->priv = priv = shell_app_system_get_instance_private (self);
SHELL_TYPE_APP_SYSTEM,
ShellAppSystemPrivate);
priv->running_apps = g_hash_table_new_full (NULL, NULL, (GDestroyNotify) g_object_unref, NULL); priv->running_apps = g_hash_table_new_full (NULL, NULL, (GDestroyNotify) g_object_unref, NULL);
priv->id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal, priv->id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,

View File

@ -23,8 +23,6 @@
* - Actor is mapped [actor and all parents visible, actor in stage] * - Actor is mapped [actor and all parents visible, actor in stage]
*/ */
G_DEFINE_TYPE (ShellEmbeddedWindow, shell_embedded_window, GTK_TYPE_WINDOW);
enum { enum {
PROP_0 PROP_0
}; };
@ -35,6 +33,10 @@ struct _ShellEmbeddedWindowPrivate {
GdkRectangle position; GdkRectangle position;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellEmbeddedWindow,
shell_embedded_window,
GTK_TYPE_WINDOW);
/* /*
* The normal gtk_window_show() starts all of the complicated asynchronous * The normal gtk_window_show() starts all of the complicated asynchronous
* window resizing code running; we don't want or need any of that. * window resizing code running; we don't want or need any of that.
@ -134,8 +136,6 @@ shell_embedded_window_class_init (ShellEmbeddedWindowClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
g_type_class_add_private (klass, sizeof (ShellEmbeddedWindowPrivate));
object_class->constructor = shell_embedded_window_constructor; object_class->constructor = shell_embedded_window_constructor;
widget_class->show = shell_embedded_window_show; widget_class->show = shell_embedded_window_show;
@ -148,8 +148,7 @@ shell_embedded_window_class_init (ShellEmbeddedWindowClass *klass)
static void static void
shell_embedded_window_init (ShellEmbeddedWindow *window) shell_embedded_window_init (ShellEmbeddedWindow *window)
{ {
window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, SHELL_TYPE_EMBEDDED_WINDOW, window->priv = shell_embedded_window_get_instance_private (window);
ShellEmbeddedWindowPrivate);
} }
/* /*

View File

@ -23,16 +23,17 @@
static void shell_generic_container_iface_init (ClutterContainerIface *iface); static void shell_generic_container_iface_init (ClutterContainerIface *iface);
G_DEFINE_TYPE_WITH_CODE(ShellGenericContainer,
shell_generic_container,
ST_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
shell_generic_container_iface_init));
struct _ShellGenericContainerPrivate { struct _ShellGenericContainerPrivate {
GHashTable *skip_paint; GHashTable *skip_paint;
}; };
G_DEFINE_TYPE_WITH_CODE(ShellGenericContainer,
shell_generic_container,
ST_TYPE_WIDGET,
G_ADD_PRIVATE (ShellGenericContainer)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
shell_generic_container_iface_init));
/* Signals */ /* Signals */
enum enum
{ {
@ -385,8 +386,6 @@ shell_generic_container_class_init (ShellGenericContainerClass *klass)
0, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 2, CLUTTER_TYPE_ACTOR_BOX, CLUTTER_TYPE_ALLOCATION_FLAGS); G_TYPE_NONE, 2, CLUTTER_TYPE_ACTOR_BOX, CLUTTER_TYPE_ALLOCATION_FLAGS);
g_type_class_add_private (gobject_class, sizeof (ShellGenericContainerPrivate));
} }
static void static void
@ -407,8 +406,7 @@ shell_generic_container_iface_init (ClutterContainerIface *iface)
static void static void
shell_generic_container_init (ShellGenericContainer *area) shell_generic_container_init (ShellGenericContainer *area)
{ {
area->priv = G_TYPE_INSTANCE_GET_PRIVATE (area, SHELL_TYPE_GENERIC_CONTAINER, area->priv = shell_generic_container_get_instance_private (area);
ShellGenericContainerPrivate);
area->priv->skip_paint = g_hash_table_new (NULL, NULL); area->priv->skip_paint = g_hash_table_new (NULL, NULL);
} }

View File

@ -16,13 +16,13 @@
#include <cogl/cogl.h> #include <cogl/cogl.h>
#include "shell-glsl-quad.h" #include "shell-glsl-quad.h"
G_DEFINE_TYPE (ShellGLSLQuad, shell_glsl_quad, CLUTTER_TYPE_ACTOR);
struct _ShellGLSLQuadPrivate struct _ShellGLSLQuadPrivate
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellGLSLQuad, shell_glsl_quad, CLUTTER_TYPE_ACTOR);
static gboolean static gboolean
shell_glsl_quad_get_paint_volume (ClutterActor *actor, shell_glsl_quad_get_paint_volume (ClutterActor *actor,
ClutterPaintVolume *volume) ClutterPaintVolume *volume)
@ -116,7 +116,7 @@ shell_glsl_quad_dispose (GObject *gobject)
static void static void
shell_glsl_quad_init (ShellGLSLQuad *quad) shell_glsl_quad_init (ShellGLSLQuad *quad)
{ {
quad->priv = G_TYPE_INSTANCE_GET_PRIVATE (quad, SHELL_TYPE_GLSL_QUAD, ShellGLSLQuadPrivate); quad->priv = shell_glsl_quad_get_instance_private (quad);
} }
static void static void
@ -161,8 +161,6 @@ shell_glsl_quad_class_init (ShellGLSLQuadClass *klass)
actor_class->get_paint_volume = shell_glsl_quad_get_paint_volume; actor_class->get_paint_volume = shell_glsl_quad_get_paint_volume;
actor_class->paint = shell_glsl_quad_paint; actor_class->paint = shell_glsl_quad_paint;
g_type_class_add_private (klass, sizeof (ShellGLSLQuadPrivate));
} }
/** /**

View File

@ -25,7 +25,7 @@ struct _ShellGtkEmbedPrivate
guint window_created_handler; guint window_created_handler;
}; };
G_DEFINE_TYPE (ShellGtkEmbed, shell_gtk_embed, CLUTTER_TYPE_CLONE); G_DEFINE_TYPE_WITH_PRIVATE (ShellGtkEmbed, shell_gtk_embed, CLUTTER_TYPE_CLONE);
static void shell_gtk_embed_set_window (ShellGtkEmbed *embed, static void shell_gtk_embed_set_window (ShellGtkEmbed *embed,
ShellEmbeddedWindow *window); ShellEmbeddedWindow *window);
@ -327,8 +327,6 @@ shell_gtk_embed_class_init (ShellGtkEmbedClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
g_type_class_add_private (klass, sizeof (ShellGtkEmbedPrivate));
object_class->get_property = shell_gtk_embed_get_property; object_class->get_property = shell_gtk_embed_get_property;
object_class->set_property = shell_gtk_embed_set_property; object_class->set_property = shell_gtk_embed_set_property;
object_class->dispose = shell_gtk_embed_dispose; object_class->dispose = shell_gtk_embed_dispose;
@ -351,8 +349,7 @@ shell_gtk_embed_class_init (ShellGtkEmbedClass *klass)
static void static void
shell_gtk_embed_init (ShellGtkEmbed *embed) shell_gtk_embed_init (ShellGtkEmbed *embed)
{ {
embed->priv = G_TYPE_INSTANCE_GET_PRIVATE (embed, SHELL_TYPE_GTK_EMBED, embed->priv = shell_gtk_embed_get_instance_private (embed);
ShellGtkEmbedPrivate);
} }
/* /*

View File

@ -33,7 +33,6 @@
* the GPid array to JS). * the GPid array to JS).
* See https://bugzilla.gnome.org/show_bug.cgi?id=645978 * See https://bugzilla.gnome.org/show_bug.cgi?id=645978
*/ */
G_DEFINE_TYPE (ShellMountOperation, shell_mount_operation, G_TYPE_MOUNT_OPERATION);
enum { enum {
SHOW_PROCESSES_2, SHOW_PROCESSES_2,
@ -48,11 +47,12 @@ struct _ShellMountOperationPrivate {
gchar *message; gchar *message;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellMountOperation, shell_mount_operation, G_TYPE_MOUNT_OPERATION);
static void static void
shell_mount_operation_init (ShellMountOperation *self) shell_mount_operation_init (ShellMountOperation *self)
{ {
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_MOUNT_OPERATION, self->priv = shell_mount_operation_get_instance_private (self);
ShellMountOperationPrivate);
} }
static void static void
@ -135,8 +135,6 @@ shell_mount_operation_class_init (ShellMountOperationClass *klass)
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, 0, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (ShellMountOperationPrivate));
} }
GMountOperation * GMountOperation *

View File

@ -60,7 +60,7 @@ struct _ShellNetworkAgentPrivate {
GHashTable *requests; GHashTable *requests;
}; };
G_DEFINE_TYPE (ShellNetworkAgent, shell_network_agent, NM_TYPE_SECRET_AGENT) G_DEFINE_TYPE_WITH_PRIVATE (ShellNetworkAgent, shell_network_agent, NM_TYPE_SECRET_AGENT)
static const SecretSchema network_agent_schema = { static const SecretSchema network_agent_schema = {
"org.freedesktop.NetworkManager.Connection", "org.freedesktop.NetworkManager.Connection",
@ -114,8 +114,7 @@ shell_network_agent_init (ShellNetworkAgent *agent)
{ {
ShellNetworkAgentPrivate *priv; ShellNetworkAgentPrivate *priv;
priv = agent->priv = G_TYPE_INSTANCE_GET_PRIVATE (agent, SHELL_TYPE_NETWORK_AGENT, ShellNetworkAgentPrivate); priv = agent->priv = shell_network_agent_get_instance_private (agent);
priv->requests = g_hash_table_new_full (g_str_hash, g_str_equal, priv->requests = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, shell_agent_request_free); g_free, shell_agent_request_free);
} }
@ -853,6 +852,4 @@ shell_network_agent_class_init (ShellNetworkAgentClass *klass)
G_TYPE_NONE, G_TYPE_NONE,
1, /* n_params */ 1, /* n_params */
G_TYPE_STRING); G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (ShellNetworkAgentPrivate));
} }

View File

@ -6,8 +6,6 @@
#include <telepathy-glib/telepathy-glib.h> #include <telepathy-glib/telepathy-glib.h>
G_DEFINE_TYPE(ShellTpClient, shell_tp_client, TP_TYPE_BASE_CLIENT)
struct _ShellTpClientPrivate struct _ShellTpClientPrivate
{ {
ShellTpClientObserveChannelsImpl observe_impl; ShellTpClientObserveChannelsImpl observe_impl;
@ -23,6 +21,8 @@ struct _ShellTpClientPrivate
GDestroyNotify destroy_handle_channels; GDestroyNotify destroy_handle_channels;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellTpClient, shell_tp_client, TP_TYPE_BASE_CLIENT)
/** /**
* ShellTpClientObserveChannelsImpl: * ShellTpClientObserveChannelsImpl:
* @client: a #ShellTpClient instance * @client: a #ShellTpClient instance
@ -84,8 +84,7 @@ shell_tp_client_init (ShellTpClient *self)
{ {
GHashTable *filter; GHashTable *filter;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_TP_CLIENT, self->priv = shell_tp_client_get_instance_private (self);
ShellTpClientPrivate);
/* We only care about single-user text-based chats */ /* We only care about single-user text-based chats */
filter = tp_asv_new ( filter = tp_asv_new (
@ -198,8 +197,6 @@ shell_tp_client_class_init (ShellTpClientClass *cls)
GObjectClass *object_class = G_OBJECT_CLASS (cls); GObjectClass *object_class = G_OBJECT_CLASS (cls);
TpBaseClientClass *base_clt_cls = TP_BASE_CLIENT_CLASS (cls); TpBaseClientClass *base_clt_cls = TP_BASE_CLIENT_CLASS (cls);
g_type_class_add_private (cls, sizeof (ShellTpClientPrivate));
object_class->dispose = shell_tp_client_dispose; object_class->dispose = shell_tp_client_dispose;
base_clt_cls->observe_channels = observe_channels; base_clt_cls->observe_channels = observe_channels;

View File

@ -25,7 +25,7 @@ struct _ShellTrayIconPrivate
char *title, *wm_class; char *title, *wm_class;
}; };
G_DEFINE_TYPE (ShellTrayIcon, shell_tray_icon, SHELL_TYPE_GTK_EMBED); G_DEFINE_TYPE_WITH_PRIVATE (ShellTrayIcon, shell_tray_icon, SHELL_TYPE_GTK_EMBED);
static void static void
shell_tray_icon_finalize (GObject *object) shell_tray_icon_finalize (GObject *object)
@ -117,8 +117,6 @@ shell_tray_icon_class_init (ShellTrayIconClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (ShellTrayIconPrivate));
object_class->get_property = shell_tray_icon_get_property; object_class->get_property = shell_tray_icon_get_property;
object_class->constructed = shell_tray_icon_constructed; object_class->constructed = shell_tray_icon_constructed;
object_class->finalize = shell_tray_icon_finalize; object_class->finalize = shell_tray_icon_finalize;
@ -149,8 +147,7 @@ shell_tray_icon_class_init (ShellTrayIconClass *klass)
static void static void
shell_tray_icon_init (ShellTrayIcon *icon) shell_tray_icon_init (ShellTrayIcon *icon)
{ {
icon->priv = G_TYPE_INSTANCE_GET_PRIVATE (icon, SHELL_TYPE_TRAY_ICON, icon->priv = shell_tray_icon_get_instance_private (icon);
ShellTrayIconPrivate);
} }
/* /*

View File

@ -43,7 +43,7 @@ enum
LAST_SIGNAL LAST_SIGNAL
}; };
G_DEFINE_TYPE (ShellTrayManager, shell_tray_manager, G_TYPE_OBJECT); G_DEFINE_TYPE_WITH_PRIVATE (ShellTrayManager, shell_tray_manager, G_TYPE_OBJECT);
static guint shell_tray_manager_signals [LAST_SIGNAL] = { 0 }; static guint shell_tray_manager_signals [LAST_SIGNAL] = { 0 };
@ -114,8 +114,8 @@ shell_tray_manager_get_property(GObject *object,
static void static void
shell_tray_manager_init (ShellTrayManager *manager) shell_tray_manager_init (ShellTrayManager *manager)
{ {
manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, SHELL_TYPE_TRAY_MANAGER, manager->priv = shell_tray_manager_get_instance_private (manager);
ShellTrayManagerPrivate);
manager->priv->na_manager = na_tray_manager_new (); manager->priv->na_manager = na_tray_manager_new ();
manager->priv->icons = g_hash_table_new_full (NULL, NULL, manager->priv->icons = g_hash_table_new_full (NULL, NULL,
@ -144,8 +144,6 @@ shell_tray_manager_class_init (ShellTrayManagerClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (ShellTrayManagerPrivate));
gobject_class->finalize = shell_tray_manager_finalize; gobject_class->finalize = shell_tray_manager_finalize;
gobject_class->set_property = shell_tray_manager_set_property; gobject_class->set_property = shell_tray_manager_set_property;
gobject_class->get_property = shell_tray_manager_get_property; gobject_class->get_property = shell_tray_manager_get_property;