From e25502aeb2032c9a2b509b18eefc6466e9d79bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 24 Sep 2015 18:56:13 +0200 Subject: [PATCH] shell: Use G_DEFINE_TYPE_WITH_PRIVATE() and friends --- src/shell-app-system.c | 8 ++------ src/shell-embedded-window.c | 11 +++++------ src/shell-generic-container.c | 18 ++++++++---------- src/shell-glsl-quad.c | 8 +++----- src/shell-gtk-embed.c | 7 ++----- src/shell-mount-operation.c | 8 +++----- src/shell-network-agent.c | 7 ++----- src/shell-tp-client.c | 9 +++------ src/shell-tray-icon.c | 7 ++----- src/shell-tray-manager.c | 8 +++----- 10 files changed, 33 insertions(+), 58 deletions(-) diff --git a/src/shell-app-system.c b/src/shell-app-system.c index 9c3e8659a..a4061cb2f 100644 --- a/src/shell-app-system.c +++ b/src/shell-app-system.c @@ -45,7 +45,7 @@ struct _ShellAppSystemPrivate { 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) { @@ -67,8 +67,6 @@ static void shell_app_system_class_init(ShellAppSystemClass *klass) G_STRUCT_OFFSET (ShellAppSystemClass, installed_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); - - g_type_class_add_private (gobject_class, sizeof (ShellAppSystemPrivate)); } static void @@ -147,9 +145,7 @@ shell_app_system_init (ShellAppSystem *self) ShellAppSystemPrivate *priv; GAppInfoMonitor *monitor; - self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SHELL_TYPE_APP_SYSTEM, - ShellAppSystemPrivate); + self->priv = priv = shell_app_system_get_instance_private (self); 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, diff --git a/src/shell-embedded-window.c b/src/shell-embedded-window.c index a61bfd262..26468f6ae 100644 --- a/src/shell-embedded-window.c +++ b/src/shell-embedded-window.c @@ -23,8 +23,6 @@ * - Actor is mapped [actor and all parents visible, actor in stage] */ -G_DEFINE_TYPE (ShellEmbeddedWindow, shell_embedded_window, GTK_TYPE_WINDOW); - enum { PROP_0 }; @@ -35,6 +33,10 @@ struct _ShellEmbeddedWindowPrivate { 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 * 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); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - g_type_class_add_private (klass, sizeof (ShellEmbeddedWindowPrivate)); - object_class->constructor = shell_embedded_window_constructor; widget_class->show = shell_embedded_window_show; @@ -148,8 +148,7 @@ shell_embedded_window_class_init (ShellEmbeddedWindowClass *klass) static void shell_embedded_window_init (ShellEmbeddedWindow *window) { - window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, SHELL_TYPE_EMBEDDED_WINDOW, - ShellEmbeddedWindowPrivate); + window->priv = shell_embedded_window_get_instance_private (window); } /* diff --git a/src/shell-generic-container.c b/src/shell-generic-container.c index bd3a9bf95..aff6a050e 100644 --- a/src/shell-generic-container.c +++ b/src/shell-generic-container.c @@ -23,16 +23,17 @@ 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 { 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 */ enum { @@ -385,8 +386,6 @@ shell_generic_container_class_init (ShellGenericContainerClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 2, CLUTTER_TYPE_ACTOR_BOX, CLUTTER_TYPE_ALLOCATION_FLAGS); - - g_type_class_add_private (gobject_class, sizeof (ShellGenericContainerPrivate)); } static void @@ -407,8 +406,7 @@ shell_generic_container_iface_init (ClutterContainerIface *iface) static void shell_generic_container_init (ShellGenericContainer *area) { - area->priv = G_TYPE_INSTANCE_GET_PRIVATE (area, SHELL_TYPE_GENERIC_CONTAINER, - ShellGenericContainerPrivate); + area->priv = shell_generic_container_get_instance_private (area); area->priv->skip_paint = g_hash_table_new (NULL, NULL); } diff --git a/src/shell-glsl-quad.c b/src/shell-glsl-quad.c index 21652d1c4..0c021d57f 100644 --- a/src/shell-glsl-quad.c +++ b/src/shell-glsl-quad.c @@ -16,13 +16,13 @@ #include #include "shell-glsl-quad.h" -G_DEFINE_TYPE (ShellGLSLQuad, shell_glsl_quad, CLUTTER_TYPE_ACTOR); - struct _ShellGLSLQuadPrivate { CoglPipeline *pipeline; }; +G_DEFINE_TYPE_WITH_PRIVATE (ShellGLSLQuad, shell_glsl_quad, CLUTTER_TYPE_ACTOR); + static gboolean shell_glsl_quad_get_paint_volume (ClutterActor *actor, ClutterPaintVolume *volume) @@ -116,7 +116,7 @@ shell_glsl_quad_dispose (GObject *gobject) static void 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 @@ -161,8 +161,6 @@ shell_glsl_quad_class_init (ShellGLSLQuadClass *klass) actor_class->get_paint_volume = shell_glsl_quad_get_paint_volume; actor_class->paint = shell_glsl_quad_paint; - - g_type_class_add_private (klass, sizeof (ShellGLSLQuadPrivate)); } /** diff --git a/src/shell-gtk-embed.c b/src/shell-gtk-embed.c index 7a45f0e5b..6b87553e4 100644 --- a/src/shell-gtk-embed.c +++ b/src/shell-gtk-embed.c @@ -25,7 +25,7 @@ struct _ShellGtkEmbedPrivate 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, ShellEmbeddedWindow *window); @@ -327,8 +327,6 @@ shell_gtk_embed_class_init (ShellGtkEmbedClass *klass) GObjectClass *object_class = G_OBJECT_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->set_property = shell_gtk_embed_set_property; object_class->dispose = shell_gtk_embed_dispose; @@ -351,8 +349,7 @@ shell_gtk_embed_class_init (ShellGtkEmbedClass *klass) static void shell_gtk_embed_init (ShellGtkEmbed *embed) { - embed->priv = G_TYPE_INSTANCE_GET_PRIVATE (embed, SHELL_TYPE_GTK_EMBED, - ShellGtkEmbedPrivate); + embed->priv = shell_gtk_embed_get_instance_private (embed); } /* diff --git a/src/shell-mount-operation.c b/src/shell-mount-operation.c index 6e428e93b..e1e3d3903 100644 --- a/src/shell-mount-operation.c +++ b/src/shell-mount-operation.c @@ -33,7 +33,6 @@ * the GPid array to JS). * See https://bugzilla.gnome.org/show_bug.cgi?id=645978 */ -G_DEFINE_TYPE (ShellMountOperation, shell_mount_operation, G_TYPE_MOUNT_OPERATION); enum { SHOW_PROCESSES_2, @@ -48,11 +47,12 @@ struct _ShellMountOperationPrivate { gchar *message; }; +G_DEFINE_TYPE_WITH_PRIVATE (ShellMountOperation, shell_mount_operation, G_TYPE_MOUNT_OPERATION); + static void shell_mount_operation_init (ShellMountOperation *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_MOUNT_OPERATION, - ShellMountOperationPrivate); + self->priv = shell_mount_operation_get_instance_private (self); } static void @@ -135,8 +135,6 @@ shell_mount_operation_class_init (ShellMountOperationClass *klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); - - g_type_class_add_private (klass, sizeof (ShellMountOperationPrivate)); } GMountOperation * diff --git a/src/shell-network-agent.c b/src/shell-network-agent.c index c6f4b79c5..5d991673d 100644 --- a/src/shell-network-agent.c +++ b/src/shell-network-agent.c @@ -60,7 +60,7 @@ struct _ShellNetworkAgentPrivate { 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 = { "org.freedesktop.NetworkManager.Connection", @@ -114,8 +114,7 @@ shell_network_agent_init (ShellNetworkAgent *agent) { 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, g_free, shell_agent_request_free); } @@ -853,6 +852,4 @@ shell_network_agent_class_init (ShellNetworkAgentClass *klass) G_TYPE_NONE, 1, /* n_params */ G_TYPE_STRING); - - g_type_class_add_private (klass, sizeof (ShellNetworkAgentPrivate)); } diff --git a/src/shell-tp-client.c b/src/shell-tp-client.c index a20987d9d..4169d4558 100644 --- a/src/shell-tp-client.c +++ b/src/shell-tp-client.c @@ -6,8 +6,6 @@ #include -G_DEFINE_TYPE(ShellTpClient, shell_tp_client, TP_TYPE_BASE_CLIENT) - struct _ShellTpClientPrivate { ShellTpClientObserveChannelsImpl observe_impl; @@ -23,6 +21,8 @@ struct _ShellTpClientPrivate GDestroyNotify destroy_handle_channels; }; +G_DEFINE_TYPE_WITH_PRIVATE (ShellTpClient, shell_tp_client, TP_TYPE_BASE_CLIENT) + /** * ShellTpClientObserveChannelsImpl: * @client: a #ShellTpClient instance @@ -84,8 +84,7 @@ shell_tp_client_init (ShellTpClient *self) { GHashTable *filter; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_TP_CLIENT, - ShellTpClientPrivate); + self->priv = shell_tp_client_get_instance_private (self); /* We only care about single-user text-based chats */ filter = tp_asv_new ( @@ -198,8 +197,6 @@ shell_tp_client_class_init (ShellTpClientClass *cls) GObjectClass *object_class = G_OBJECT_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; base_clt_cls->observe_channels = observe_channels; diff --git a/src/shell-tray-icon.c b/src/shell-tray-icon.c index 86473c869..a75c3c16d 100644 --- a/src/shell-tray-icon.c +++ b/src/shell-tray-icon.c @@ -25,7 +25,7 @@ struct _ShellTrayIconPrivate 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 shell_tray_icon_finalize (GObject *object) @@ -117,8 +117,6 @@ shell_tray_icon_class_init (ShellTrayIconClass *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->constructed = shell_tray_icon_constructed; object_class->finalize = shell_tray_icon_finalize; @@ -149,8 +147,7 @@ shell_tray_icon_class_init (ShellTrayIconClass *klass) static void shell_tray_icon_init (ShellTrayIcon *icon) { - icon->priv = G_TYPE_INSTANCE_GET_PRIVATE (icon, SHELL_TYPE_TRAY_ICON, - ShellTrayIconPrivate); + icon->priv = shell_tray_icon_get_instance_private (icon); } /* diff --git a/src/shell-tray-manager.c b/src/shell-tray-manager.c index d74ade795..cc2519a02 100644 --- a/src/shell-tray-manager.c +++ b/src/shell-tray-manager.c @@ -43,7 +43,7 @@ enum 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 }; @@ -114,8 +114,8 @@ shell_tray_manager_get_property(GObject *object, static void shell_tray_manager_init (ShellTrayManager *manager) { - manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, SHELL_TYPE_TRAY_MANAGER, - ShellTrayManagerPrivate); + manager->priv = shell_tray_manager_get_instance_private (manager); + manager->priv->na_manager = na_tray_manager_new (); 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); - g_type_class_add_private (klass, sizeof (ShellTrayManagerPrivate)); - gobject_class->finalize = shell_tray_manager_finalize; gobject_class->set_property = shell_tray_manager_set_property; gobject_class->get_property = shell_tray_manager_get_property;