[gnome-shell] calendar-server: Modernize GObject usage
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] calendar-server: Modernize GObject usage
- Date: Thu, 15 Oct 2015 21:10:17 +0000 (UTC)
commit a539e6236a39b0a1f0e1ec5a97b57aee7d47f5a7
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Sep 24 18:43:24 2015 +0200
calendar-server: Modernize GObject usage
src/calendar-server/calendar-sources.c | 52 ++++++++------------------------
src/calendar-server/calendar-sources.h | 29 ++----------------
2 files changed, 16 insertions(+), 65 deletions(-)
---
diff --git a/src/calendar-server/calendar-sources.c b/src/calendar-server/calendar-sources.c
index 1d691b2..628f89b 100644
--- a/src/calendar-server/calendar-sources.c
+++ b/src/calendar-server/calendar-sources.c
@@ -41,8 +41,6 @@
#define N_(x) x
#endif
-#define CALENDAR_SOURCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_SOURCES,
CalendarSourcesPrivate))
-
typedef struct _ClientData ClientData;
typedef struct _CalendarSourceData CalendarSourceData;
@@ -66,6 +64,14 @@ struct _CalendarSourceData
guint loaded : 1;
};
+typedef struct _CalendarSourcesPrivate CalendarSourcesPrivate;
+
+struct _CalendarSources
+{
+ GObject parent;
+ CalendarSourcesPrivate *priv;
+};
+
struct _CalendarSourcesPrivate
{
ESourceRegistry *registry;
@@ -77,8 +83,8 @@ struct _CalendarSourcesPrivate
CalendarSourceData task_sources;
};
-static void calendar_sources_class_init (CalendarSourcesClass *klass);
-static void calendar_sources_init (CalendarSources *sources);
+G_DEFINE_TYPE_WITH_PRIVATE (CalendarSources, calendar_sources, G_TYPE_OBJECT)
+
static void calendar_sources_finalize (GObject *object);
static void backend_died_cb (EClient *client, CalendarSourceData *source_data);
@@ -108,34 +114,6 @@ client_data_free (ClientData *data)
g_slice_free (ClientData, data);
}
-GType
-calendar_sources_get_type (void)
-{
- static GType sources_type = 0;
-
- if (!sources_type)
- {
- static const GTypeInfo sources_info =
- {
- sizeof (CalendarSourcesClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) calendar_sources_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (CalendarSources),
- 0, /* n_preallocs */
- (GInstanceInitFunc) calendar_sources_init,
- };
-
- sources_type = g_type_register_static (G_TYPE_OBJECT,
- "CalendarSources",
- &sources_info, 0);
- }
-
- return sources_type;
-}
-
static void
calendar_sources_class_init (CalendarSourcesClass *klass)
{
@@ -145,14 +123,11 @@ calendar_sources_class_init (CalendarSourcesClass *klass)
gobject_class->finalize = calendar_sources_finalize;
- g_type_class_add_private (klass, sizeof (CalendarSourcesPrivate));
-
signals [APPOINTMENT_SOURCES_CHANGED] =
g_signal_new ("appointment-sources-changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CalendarSourcesClass,
- appointment_sources_changed),
+ 0,
NULL,
NULL,
NULL,
@@ -163,8 +138,7 @@ calendar_sources_class_init (CalendarSourcesClass *klass)
g_signal_new ("task-sources-changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CalendarSourcesClass,
- task_sources_changed),
+ 0,
NULL,
NULL,
NULL,
@@ -179,7 +153,7 @@ calendar_sources_init (CalendarSources *sources)
GDBusConnection *session_bus;
GVariant *result;
- sources->priv = CALENDAR_SOURCES_GET_PRIVATE (sources);
+ sources->priv = calendar_sources_get_instance_private (sources);
/* WORKAROUND: the hardcoded timeout for e_source_registry_new_sync()
(and other library calls that eventually call g_dbus_proxy_new[_sync]())
diff --git a/src/calendar-server/calendar-sources.h b/src/calendar-server/calendar-sources.h
index 759f5bd..d11850f 100644
--- a/src/calendar-server/calendar-sources.h
+++ b/src/calendar-server/calendar-sources.h
@@ -28,33 +28,10 @@
G_BEGIN_DECLS
-#define CALENDAR_TYPE_SOURCES (calendar_sources_get_type ())
-#define CALENDAR_SOURCES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CALENDAR_TYPE_SOURCES,
CalendarSources))
-#define CALENDAR_SOURCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CALENDAR_TYPE_SOURCES,
CalendarSourcesClass))
-#define CALENDAR_IS_SOURCES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CALENDAR_TYPE_SOURCES))
-#define CALENDAR_IS_SOURCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CALENDAR_TYPE_SOURCES))
-#define CALENDAR_SOURCES_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), CALENDAR_TYPE_SOURCES,
CalendarSourcesClass))
+#define CALENDAR_TYPE_SOURCES (calendar_sources_get_type ())
+G_DECLARE_FINAL_TYPE (CalendarSources, calendar_sources,
+ CALENDAR, SOURCES, GObject)
-typedef struct _CalendarSources CalendarSources;
-typedef struct _CalendarSourcesClass CalendarSourcesClass;
-typedef struct _CalendarSourcesPrivate CalendarSourcesPrivate;
-
-struct _CalendarSources
-{
- GObject parent;
- CalendarSourcesPrivate *priv;
-};
-
-struct _CalendarSourcesClass
-{
- GObjectClass parent_class;
-
- void (* appointment_sources_changed) (CalendarSources *sources);
- void (* task_sources_changed) (CalendarSources *sources);
-};
-
-
-GType calendar_sources_get_type (void) G_GNUC_CONST;
CalendarSources *calendar_sources_get (void);
GList *calendar_sources_get_appointment_clients (CalendarSources *sources);
GList *calendar_sources_get_task_clients (CalendarSources *sources);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]