[almanah/wip/jtojnar/cleanups] Switch to G_DECLARE_{FINAL, DERIVABLE}_TYPE
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [almanah/wip/jtojnar/cleanups] Switch to G_DECLARE_{FINAL, DERIVABLE}_TYPE
- Date: Fri, 8 Mar 2019 19:49:13 +0000 (UTC)
commit 0a3920e43892b34cea7cfe3ef78d9ae2b6f993aa
Author: Jan Tojnar <jtojnar gmail com>
Date: Fri Mar 8 17:28:35 2019 +0100
Switch to G_DECLARE_{FINAL,DERIVABLE}_TYPE
https://blogs.gnome.org/desrt/2015/01/27/g_declare_finalderivable_type/
src/application.c | 15 ++-
src/application.h | 19 +---
src/date-entry-dialog.c | 14 +--
src/date-entry-dialog.h | 19 +---
src/entry.c | 14 +--
src/entry.h | 20 +---
src/event-factories/calendar.c | 18 ++--
src/event-factories/calendar.h | 21 +---
src/event-factories/e-source-selector.c | 167 ++++++++++++++++++++------------
src/event-factories/e-source-selector.h | 31 +-----
src/event-factory.c | 10 +-
src/event-factory.h | 21 +---
src/event-manager.c | 20 ++--
src/event-manager.h | 21 +---
src/event.c | 1 -
src/event.h | 20 +---
src/events/calendar-appointment.c | 16 +--
src/events/calendar-appointment.h | 20 +---
src/events/calendar-task.c | 16 +--
src/events/calendar-task.h | 20 +---
src/export-operation.c | 14 +--
src/export-operation.h | 21 +---
src/import-export-dialog.c | 29 +++---
src/import-export-dialog.h | 42 +-------
src/import-operation.c | 14 +--
src/import-operation.h | 21 +---
src/main-window.c | 13 ++-
src/main-window.h | 20 +---
src/meson.build | 1 +
src/preferences-dialog.c | 14 +--
src/preferences-dialog.h | 20 +---
src/search-dialog.c | 13 ++-
src/search-dialog.h | 20 +---
src/storage-manager.c | 20 ++--
src/storage-manager.h | 18 +---
src/uri-entry-dialog.c | 14 +--
src/uri-entry-dialog.h | 21 +---
src/widgets/calendar-button.c | 100 +++++++++++--------
src/widgets/calendar-button.h | 20 +---
src/widgets/calendar.c | 13 ++-
src/widgets/calendar.h | 21 +---
src/widgets/eggwrapbox.c | 147 +++++++++++++++++-----------
src/widgets/eggwrapbox.h | 22 +----
src/widgets/entry-tags-area.c | 13 ++-
src/widgets/entry-tags-area.h | 18 +---
src/widgets/hyperlink-tag.c | 13 ++-
src/widgets/hyperlink-tag.h | 21 +---
src/widgets/tag-accessible.c | 11 ++-
src/widgets/tag-accessible.h | 20 +---
src/widgets/tag-entry.c | 13 ++-
src/widgets/tag-entry.h | 18 +---
src/widgets/tag.c | 13 ++-
src/widgets/tag.h | 18 +---
53 files changed, 494 insertions(+), 805 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index 9b0adb8..15c1db5 100644
--- a/src/application.c
+++ b/src/application.c
@@ -57,7 +57,7 @@ static void action_quit_cb (GSimpleAction *action, GVariant *parameter, gpointer
/* Some callbacks */
void almanah_application_style_provider_parsing_error_cb (GtkCssProvider *provider, GtkCssSection *section,
GError *error, gpointer user_data);
-struct _AlmanahApplicationPrivate {
+typedef struct {
gboolean debug;
GSettings *settings;
@@ -68,8 +68,15 @@ struct _AlmanahApplicationPrivate {
GtkPrintSettings *print_settings;
GtkPageSetup *page_setup;
+} AlmanahApplicationPrivate;
+
+struct _AlmanahApplication {
+ GtkApplication parent_instance;
+
+ AlmanahApplicationPrivate *priv;
};
+
enum {
PROP_DEBUG = 1
};
@@ -84,7 +91,7 @@ static GActionEntry app_entries[] = {
{"quit", action_quit_cb, NULL, NULL, NULL },
};
-G_DEFINE_TYPE (AlmanahApplication, almanah_application, GTK_TYPE_APPLICATION)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahApplication, almanah_application, GTK_TYPE_APPLICATION)
static void
almanah_application_class_init (AlmanahApplicationClass *klass)
@@ -93,8 +100,6 @@ almanah_application_class_init (AlmanahApplicationClass *klass)
GApplicationClass *gapplication_class = G_APPLICATION_CLASS (klass);
GtkApplicationClass *gtkapplication_class = GTK_APPLICATION_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahApplicationPrivate));
-
gobject_class->constructed = constructed;
gobject_class->dispose = dispose;
gobject_class->get_property = get_property;
@@ -116,7 +121,7 @@ almanah_application_class_init (AlmanahApplicationClass *klass)
static void
almanah_application_init (AlmanahApplication *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_APPLICATION, AlmanahApplicationPrivate);
+ self->priv = almanah_application_get_instance_private (self);
self->priv->debug = FALSE;
}
diff --git a/src/application.h b/src/application.h
index cec5d09..2591de5 100644
--- a/src/application.h
+++ b/src/application.h
@@ -30,24 +30,7 @@
G_BEGIN_DECLS
#define ALMANAH_TYPE_APPLICATION (almanah_application_get_type ())
-#define ALMANAH_APPLICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_APPLICATION,
AlmanahApplication))
-#define ALMANAH_APPLICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_APPLICATION,
AlmanahApplicationClass))
-#define ALMANAH_IS_APPLICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_APPLICATION))
-#define ALMANAH_IS_APPLICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_APPLICATION))
-#define ALMANAH_APPLICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_APPLICATION,
AlmanahApplicationClass))
-
-typedef struct _AlmanahApplicationPrivate AlmanahApplicationPrivate;
-
-typedef struct {
- GtkApplication parent;
- AlmanahApplicationPrivate *priv;
-} AlmanahApplication;
-
-typedef struct {
- GtkApplicationClass parent;
-} AlmanahApplicationClass;
-
-GType almanah_application_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (AlmanahApplication, almanah_application, ALMANAH, APPLICATION, GtkApplication)
AlmanahApplication *almanah_application_new (void) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
diff --git a/src/date-entry-dialog.c b/src/date-entry-dialog.c
index 72dabbc..17fd9d6 100644
--- a/src/date-entry-dialog.c
+++ b/src/date-entry-dialog.c
@@ -31,26 +31,28 @@ static void almanah_date_entry_dialog_set_property (GObject *object, guint prope
/* GtkBuilder callbacks */
void ded_date_entry_notify_text_cb (GObject *gobject, GParamSpec *pspec, AlmanahDateEntryDialog *self);
-struct _AlmanahDateEntryDialogPrivate {
+typedef struct {
GDate date;
GtkWidget *ok_button;
GtkEntry *date_entry;
+} AlmanahDateEntryDialogPrivate;
+
+struct _AlmanahDateEntryDialog {
+ GtkDialog parent;
+ AlmanahDateEntryDialogPrivate *priv;
};
enum {
PROP_DATE = 1
};
-G_DEFINE_TYPE (AlmanahDateEntryDialog, almanah_date_entry_dialog, GTK_TYPE_DIALOG)
-#define ALMANAH_DATE_ENTRY_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_DATE_ENTRY_DIALOG, AlmanahDateEntryDialogPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahDateEntryDialog, almanah_date_entry_dialog, GTK_TYPE_DIALOG)
static void
almanah_date_entry_dialog_class_init (AlmanahDateEntryDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahDateEntryDialogPrivate));
-
gobject_class->set_property = almanah_date_entry_dialog_set_property;
gobject_class->get_property = almanah_date_entry_dialog_get_property;
@@ -64,7 +66,7 @@ almanah_date_entry_dialog_class_init (AlmanahDateEntryDialogClass *klass)
static void
almanah_date_entry_dialog_init (AlmanahDateEntryDialog *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_DATE_ENTRY_DIALOG,
AlmanahDateEntryDialogPrivate);
+ self->priv = almanah_date_entry_dialog_get_instance_private (self);
g_date_clear (&(self->priv->date), 1);
g_signal_connect (self, "response", G_CALLBACK (gtk_widget_hide), self);
diff --git a/src/date-entry-dialog.h b/src/date-entry-dialog.h
index 918feb8..72ba99b 100644
--- a/src/date-entry-dialog.h
+++ b/src/date-entry-dialog.h
@@ -27,24 +27,7 @@
G_BEGIN_DECLS
#define ALMANAH_TYPE_DATE_ENTRY_DIALOG (almanah_date_entry_dialog_get_type ())
-#define ALMANAH_DATE_ENTRY_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_DATE_ENTRY_DIALOG, AlmanahDateEntryDialog))
-#define ALMANAH_DATE_ENTRY_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_DATE_ENTRY_DIALOG,
AlmanahDateEntryDialogClass))
-#define ALMANAH_IS_DATE_ENTRY_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_DATE_ENTRY_DIALOG))
-#define ALMANAH_IS_DATE_ENTRY_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_DATE_ENTRY_DIALOG))
-#define ALMANAH_DATE_ENTRY_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_DATE_ENTRY_DIALOG, AlmanahDateEntryDialogClass))
-
-typedef struct _AlmanahDateEntryDialogPrivate AlmanahDateEntryDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- AlmanahDateEntryDialogPrivate *priv;
-} AlmanahDateEntryDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} AlmanahDateEntryDialogClass;
-
-GType almanah_date_entry_dialog_get_type (void);
+G_DECLARE_FINAL_TYPE (AlmanahDateEntryDialog, almanah_date_entry_dialog, ALMANAH, DATE_ENTRY_DIALOG,
GtkDialog)
AlmanahDateEntryDialog *almanah_date_entry_dialog_new (void);
gboolean almanah_date_entry_dialog_run (AlmanahDateEntryDialog *self);
diff --git a/src/entry.c b/src/entry.c
index 8a705c9..452a218 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -49,7 +49,7 @@ static guint8 *serialise_entry_xml_2_0 (GtkTextBuffer *register_buffer, GtkTextB
static gboolean deserialise_entry_xml_2_0 (GtkTextBuffer *register_buffer, GtkTextBuffer *content_buffer,
GtkTextIter *iter, const guint8 *data,
gsize length, gboolean create_tags, gpointer user_data, GError
**error);
-struct _AlmanahEntryPrivate {
+typedef struct {
GDate date;
guint8 *data;
gsize length;
@@ -57,6 +57,11 @@ struct _AlmanahEntryPrivate {
gboolean is_empty;
gboolean is_important;
GDate last_edited; /* date the entry was last edited *in the database*; e.g. this isn't updated when
almanah_entry_set_content() is called */
+} AlmanahEntryPrivate;
+
+struct _AlmanahEntry {
+ GObject parent;
+ AlmanahEntryPrivate *priv;
};
enum {
@@ -69,16 +74,13 @@ enum {
PROP_LAST_EDITED_YEAR
};
-G_DEFINE_TYPE (AlmanahEntry, almanah_entry, G_TYPE_OBJECT)
-#define ALMANAH_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ALMANAH_TYPE_ENTRY,
AlmanahEntryPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahEntry, almanah_entry, G_TYPE_OBJECT)
static void
almanah_entry_class_init (AlmanahEntryClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahEntryPrivate));
-
gobject_class->set_property = almanah_entry_set_property;
gobject_class->get_property = almanah_entry_get_property;
gobject_class->finalize = almanah_entry_finalize;
@@ -122,7 +124,7 @@ almanah_entry_class_init (AlmanahEntryClass *klass)
static void
almanah_entry_init (AlmanahEntry *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_ENTRY, AlmanahEntryPrivate);
+ self->priv = almanah_entry_get_instance_private (self);
self->priv->data = NULL;
self->priv->length = 0;
self->priv->version = DATA_FORMAT_UNSET;
diff --git a/src/entry.h b/src/entry.h
index 1245641..391a3a9 100644
--- a/src/entry.h
+++ b/src/entry.h
@@ -41,25 +41,9 @@ typedef enum {
GQuark almanah_entry_error_quark (void) G_GNUC_CONST;
#define ALMANAH_ENTRY_ERROR (almanah_entry_error_quark ())
-#define ALMANAH_TYPE_ENTRY (almanah_entry_get_type ())
-#define ALMANAH_ENTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_ENTRY, AlmanahEntry))
-#define ALMANAH_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_ENTRY, AlmanahEntryClass))
-#define ALMANAH_IS_ENTRY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_ENTRY))
-#define ALMANAH_IS_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_ENTRY))
-#define ALMANAH_ENTRY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_ENTRY,
AlmanahEntryClass))
+#define ALMANAH_TYPE_ENTRY (almanah_entry_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahEntry, almanah_entry, ALMANAH, ENTRY, GObject)
-typedef struct _AlmanahEntryPrivate AlmanahEntryPrivate;
-
-typedef struct {
- GObject parent;
- AlmanahEntryPrivate *priv;
-} AlmanahEntry;
-
-typedef struct {
- GObjectClass parent;
-} AlmanahEntryClass;
-
-GType almanah_entry_get_type (void);
AlmanahEntry *almanah_entry_new (GDate *date);
const guint8 *almanah_entry_get_data (AlmanahEntry *self, gsize *length, guint *version);
diff --git a/src/event-factories/calendar.c b/src/event-factories/calendar.c
index bbfe159..976022a 100644
--- a/src/event-factories/calendar.c
+++ b/src/event-factories/calendar.c
@@ -31,12 +31,16 @@ static void query_events (AlmanahEventFactory *event_factory, GDate *date);
static GSList *get_events (AlmanahEventFactory *event_factory, GDate *date);
static void events_changed_cb (CalendarClient *client, AlmanahCalendarEventFactory *self);
-struct _AlmanahCalendarEventFactoryPrivate {
+typedef struct {
CalendarClient *client;
+} AlmanahCalendarEventFactoryPrivate;
+
+struct _AlmanahCalendarEventFactory {
+ AlmanahEventFactory parent;
+ AlmanahCalendarEventFactoryPrivate *priv;
};
-G_DEFINE_TYPE (AlmanahCalendarEventFactory, almanah_calendar_event_factory, ALMANAH_TYPE_EVENT_FACTORY)
-#define ALMANAH_CALENDAR_EVENT_FACTORY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_CALENDAR_EVENT_FACTORY, AlmanahCalendarEventFactoryPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahCalendarEventFactory, almanah_calendar_event_factory,
ALMANAH_TYPE_EVENT_FACTORY)
static void
almanah_calendar_event_factory_class_init (AlmanahCalendarEventFactoryClass *klass)
@@ -44,8 +48,6 @@ almanah_calendar_event_factory_class_init (AlmanahCalendarEventFactoryClass *kla
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AlmanahEventFactoryClass *event_factory_class = ALMANAH_EVENT_FACTORY_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahCalendarEventFactoryPrivate));
-
gobject_class->dispose = almanah_calendar_event_factory_dispose;
event_factory_class->type_id = ALMANAH_EVENT_FACTORY_CALENDAR;
@@ -56,7 +58,7 @@ almanah_calendar_event_factory_class_init (AlmanahCalendarEventFactoryClass *kla
static void
almanah_calendar_event_factory_init (AlmanahCalendarEventFactory *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_EVENT_FACTORY,
AlmanahCalendarEventFactoryPrivate);
+ self->priv = almanah_calendar_event_factory_get_instance_private (self);
self->priv->client = calendar_client_new ();
g_signal_connect (self->priv->client, "tasks-changed", G_CALLBACK (events_changed_cb), self);
@@ -66,7 +68,7 @@ almanah_calendar_event_factory_init (AlmanahCalendarEventFactory *self)
static void
almanah_calendar_event_factory_dispose (GObject *object)
{
- AlmanahCalendarEventFactoryPrivate *priv = ALMANAH_CALENDAR_EVENT_FACTORY_GET_PRIVATE (object);
+ AlmanahCalendarEventFactoryPrivate *priv = almanah_calendar_event_factory_get_instance_private
(ALMANAH_CALENDAR_EVENT_FACTORY (object));
if (priv->client != NULL)
g_object_unref (priv->client);
@@ -109,7 +111,7 @@ static GSList *
get_events (AlmanahEventFactory *event_factory, GDate *date)
{
GSList *calendar_events, *e, *events = NULL;
- AlmanahCalendarEventFactoryPrivate *priv = ALMANAH_CALENDAR_EVENT_FACTORY_GET_PRIVATE (event_factory);
+ AlmanahCalendarEventFactoryPrivate *priv = almanah_calendar_event_factory_get_instance_private
(ALMANAH_CALENDAR_EVENT_FACTORY (event_factory));
calendar_events = calendar_client_get_events (priv->client, CALENDAR_EVENT_ALL);
diff --git a/src/event-factories/calendar.h b/src/event-factories/calendar.h
index 01beb0d..bfe7d94 100644
--- a/src/event-factories/calendar.h
+++ b/src/event-factories/calendar.h
@@ -27,25 +27,8 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_CALENDAR_EVENT_FACTORY (almanah_calendar_event_factory_get_type ())
-#define ALMANAH_CALENDAR_EVENT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_CALENDAR_EVENT_FACTORY, AlmanahCalendarEventFactory))
-#define ALMANAH_CALENDAR_EVENT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
ALMANAH_TYPE_CALENDAR_EVENT_FACTORY, AlmanahCalendarEventFactoryClass))
-#define ALMANAH_IS_CALENDAR_EVENT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_CALENDAR_EVENT_FACTORY))
-#define ALMANAH_IS_CALENDAR_EVENT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_CALENDAR_EVENT_FACTORY))
-#define ALMANAH_CALENDAR_EVENT_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_CALENDAR_EVENT_FACTORY, AlmanahCalendarEventFactoryClass))
-
-typedef struct _AlmanahCalendarEventFactoryPrivate AlmanahCalendarEventFactoryPrivate;
-
-typedef struct {
- AlmanahEventFactory parent;
- AlmanahCalendarEventFactoryPrivate *priv;
-} AlmanahCalendarEventFactory;
-
-typedef struct {
- AlmanahEventFactoryClass parent;
-} AlmanahCalendarEventFactoryClass;
-
-GType almanah_calendar_event_factory_get_type (void);
+#define ALMANAH_TYPE_CALENDAR_EVENT_FACTORY (almanah_calendar_event_factory_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahCalendarEventFactory, almanah_calendar_event_factory, ALMANAH,
CALENDAR_EVENT_FACTORY, AlmanahEventFactory)
G_END_DECLS
diff --git a/src/event-factories/e-source-selector.c b/src/event-factories/e-source-selector.c
index 0efdb19..b1a985e 100644
--- a/src/event-factories/e-source-selector.c
+++ b/src/event-factories/e-source-selector.c
@@ -28,13 +28,7 @@
#include "e-cell-renderer-color.h"
#include "e-source-selector.h"
-#define E_SOURCE_SELECTOR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SOURCE_SELECTOR, ESourceSelectorPrivate))
-
-typedef struct _AsyncContext AsyncContext;
-
-struct _ESourceSelectorPrivate {
+typedef struct {
ESourceRegistry *registry;
GHashTable *source_index;
gchar *extension_name;
@@ -49,12 +43,12 @@ struct _ESourceSelectorPrivate {
gboolean select_new;
gboolean show_colors;
gboolean show_toggles;
-};
+} ESourceSelectorPrivate;
-struct _AsyncContext {
+typedef struct {
ESourceSelector *selector;
ESource *source;
-};
+} AsyncContext;
enum {
PROP_0,
@@ -86,11 +80,10 @@ enum {
static guint signals[NUM_SIGNALS];
-G_DEFINE_TYPE (ESourceSelector, e_source_selector, GTK_TYPE_TREE_VIEW)
+G_DEFINE_TYPE_WITH_PRIVATE (ESourceSelector, e_source_selector, GTK_TYPE_TREE_VIEW)
/* ESafeToggleRenderer does not emit 'toggled' signal
* on 'activate' when mouse is not over the toggle. */
-
typedef GtkCellRendererToggle ECellRendererSafeToggle;
typedef GtkCellRendererToggleClass ECellRendererSafeToggleClass;
@@ -153,8 +146,9 @@ e_cell_renderer_safe_toggle_new (void)
static void
clear_saved_primary_selection (ESourceSelector *selector)
{
- gtk_tree_row_reference_free (selector->priv->saved_primary_selection);
- selector->priv->saved_primary_selection = NULL;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
+ gtk_tree_row_reference_free (priv->saved_primary_selection);
+ priv->saved_primary_selection = NULL;
}
static void
@@ -211,7 +205,9 @@ source_selector_write_idle_cb (gpointer user_data)
source_selector_write_done_cb,
g_object_ref (async_context->selector));
- pending_writes = async_context->selector->priv->pending_writes;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (async_context->selector);
+
+ pending_writes = priv->pending_writes;
g_hash_table_remove (pending_writes, async_context->source);
return FALSE;
@@ -222,10 +218,11 @@ source_selector_cancel_write (ESourceSelector *selector,
ESource *source)
{
GHashTable *pending_writes;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
/* Cancel any pending writes for this ESource so as not
* to overwrite whatever change we're being notified of. */
- pending_writes = selector->priv->pending_writes;
+ pending_writes = priv->pending_writes;
g_hash_table_remove (pending_writes, source);
}
@@ -242,8 +239,9 @@ source_selector_update_row (ESourceSelector *selector,
const gchar *extension_name;
const gchar *display_name;
gboolean selected;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- source_index = selector->priv->source_index;
+ source_index = priv->source_index;
reference = g_hash_table_lookup (source_index, source);
/* This function runs when ANY ESource in the registry changes.
@@ -314,6 +312,7 @@ static gboolean
source_selector_traverse (GNode *node,
ESourceSelector *selector)
{
+ ESourceSelectorPrivate *priv;
ESource *source;
GHashTable *source_index;
GtkTreeRowReference *reference = NULL;
@@ -325,7 +324,8 @@ source_selector_traverse (GNode *node,
if (G_NODE_IS_ROOT (node))
return FALSE;
- source_index = selector->priv->source_index;
+ priv = e_source_selector_get_instance_private (selector);
+ source_index = priv->source_index;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
@@ -374,6 +374,7 @@ source_selector_save_expanded (GtkTreeView *tree_view,
static void
source_selector_build_model (ESourceSelector *selector)
{
+ ESourceSelectorPrivate *priv;
ESourceRegistry *registry;
GQueue queue = G_QUEUE_INIT;
GHashTable *source_index;
@@ -393,7 +394,8 @@ source_selector_build_model (ESourceSelector *selector)
if (registry == NULL || extension_name == NULL)
return;
- source_index = selector->priv->source_index;
+ priv = e_source_selector_get_instance_private (selector);
+ source_index = priv->source_index;
selected = e_source_selector_ref_primary_selection (selector);
/* Save expanded sources to restore later. */
@@ -457,8 +459,9 @@ source_selector_expand_to_source (ESourceSelector *selector,
GHashTable *source_index;
GtkTreeRowReference *reference;
GtkTreePath *path;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- source_index = selector->priv->source_index;
+ source_index = priv->source_index;
reference = g_hash_table_lookup (source_index, source);
/* If the ESource is not in our tree model then return silently. */
@@ -527,8 +530,9 @@ same_source_name_exists (ESourceSelector *selector,
GHashTable *source_index;
GHashTableIter iter;
gpointer key;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- source_index = selector->priv->source_index;
+ source_index = priv->source_index;
g_hash_table_iter_init (&iter, source_index);
while (g_hash_table_iter_next (&iter, &key, NULL)) {
@@ -553,9 +557,10 @@ selection_func (GtkTreeSelection *selection,
ESource *source;
GtkTreeIter iter;
const gchar *extension_name;
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- if (selector->priv->toggled_last) {
- selector->priv->toggled_last = FALSE;
+ if (priv->toggled_last) {
+ priv->toggled_last = FALSE;
return FALSE;
}
@@ -615,11 +620,13 @@ cell_toggled_callback (GtkCellRendererToggle *renderer,
const gchar *path_string,
ESourceSelector *selector)
{
+ ESourceSelectorPrivate *priv;
ESource *source;
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
+ priv = e_source_selector_get_instance_private (selector);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
path = gtk_tree_path_new_from_string (path_string);
@@ -635,7 +642,7 @@ cell_toggled_callback (GtkCellRendererToggle *renderer,
else
e_source_selector_select_source (selector, source);
- selector->priv->toggled_last = TRUE;
+ priv->toggled_last = TRUE;
gtk_tree_path_free (path);
@@ -654,20 +661,28 @@ static void
source_selector_set_extension_name (ESourceSelector *selector,
const gchar *extension_name)
{
+ ESourceSelectorPrivate *priv;
+
g_return_if_fail (extension_name != NULL);
- g_return_if_fail (selector->priv->extension_name == NULL);
- selector->priv->extension_name = g_strdup (extension_name);
+ priv = e_source_selector_get_instance_private (selector);
+ g_return_if_fail (priv->extension_name == NULL);
+
+ priv->extension_name = g_strdup (extension_name);
}
static void
source_selector_set_registry (ESourceSelector *selector,
ESourceRegistry *registry)
{
+ ESourceSelectorPrivate *priv;
+
g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (selector->priv->registry == NULL);
- selector->priv->registry = g_object_ref (registry);
+ priv = e_source_selector_get_instance_private (selector);
+ g_return_if_fail (priv->registry == NULL);
+
+ priv->registry = g_object_ref (registry);
}
static void
@@ -762,7 +777,7 @@ source_selector_dispose (GObject *object)
{
ESourceSelectorPrivate *priv;
- priv = E_SOURCE_SELECTOR_GET_PRIVATE (object);
+ priv = e_source_selector_get_instance_private (E_SOURCE_SELECTOR (object));
if (priv->registry != NULL) {
g_signal_handlers_disconnect_matched (
@@ -787,7 +802,7 @@ source_selector_finalize (GObject *object)
{
ESourceSelectorPrivate *priv;
- priv = E_SOURCE_SELECTOR_GET_PRIVATE (object);
+ priv = e_source_selector_get_instance_private (E_SOURCE_SELECTOR (object));
g_hash_table_destroy (priv->source_index);
g_hash_table_destroy (priv->pending_writes);
@@ -840,6 +855,7 @@ source_selector_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
ESourceSelector *selector;
+ ESourceSelectorPrivate *priv;
GtkWidgetClass *widget_class;
GtkTreePath *path;
ESource *source = NULL;
@@ -851,7 +867,8 @@ source_selector_button_press_event (GtkWidget *widget,
selector = E_SOURCE_SELECTOR (widget);
- selector->priv->toggled_last = FALSE;
+ priv = e_source_selector_get_instance_private (selector);
+ priv->toggled_last = FALSE;
/* Triple-clicking a source selects it exclusively. */
@@ -1085,7 +1102,7 @@ source_selector_test_collapse_row (GtkTreeView *tree_view,
GtkTreeModel *model;
GtkTreeIter child_iter;
- priv = E_SOURCE_SELECTOR_GET_PRIVATE (tree_view);
+ priv = e_source_selector_get_instance_private (E_SOURCE_SELECTOR (tree_view));
/* Clear this because something else has been clicked on now */
priv->toggled_last = FALSE;
@@ -1121,7 +1138,7 @@ source_selector_row_expanded (GtkTreeView *tree_view,
GtkTreePath *child_path;
GtkTreeIter child_iter;
- priv = E_SOURCE_SELECTOR_GET_PRIVATE (tree_view);
+ priv = e_source_selector_get_instance_private (E_SOURCE_SELECTOR (tree_view));
if (!priv->saved_primary_selection)
return;
@@ -1210,8 +1227,6 @@ e_source_selector_class_init (ESourceSelectorClass *class)
GtkWidgetClass *widget_class;
GtkTreeViewClass *tree_view_class;
- g_type_class_add_private (class, sizeof (ESourceSelectorPrivate));
-
object_class = G_OBJECT_CLASS (class);
object_class->set_property = source_selector_set_property;
object_class->get_property = source_selector_get_property;
@@ -1334,6 +1349,7 @@ e_source_selector_class_init (ESourceSelectorClass *class)
static void
e_source_selector_init (ESourceSelector *selector)
{
+ ESourceSelectorPrivate *priv;
GHashTable *pending_writes;
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
@@ -1347,25 +1363,25 @@ e_source_selector_init (ESourceSelector *selector)
(GDestroyNotify) g_object_unref,
(GDestroyNotify) pending_writes_destroy_source);
- selector->priv = E_SOURCE_SELECTOR_GET_PRIVATE (selector);
+ priv = e_source_selector_get_instance_private (selector);
- selector->priv->pending_writes = pending_writes;
+ priv->pending_writes = pending_writes;
- selector->priv->main_context = g_main_context_get_thread_default ();
- if (selector->priv->main_context != NULL)
- g_main_context_ref (selector->priv->main_context);
+ priv->main_context = g_main_context_get_thread_default ();
+ if (priv->main_context != NULL)
+ g_main_context_ref (priv->main_context);
tree_view = GTK_TREE_VIEW (selector);
gtk_tree_view_set_search_column (tree_view, COLUMN_SOURCE);
gtk_tree_view_set_enable_search (tree_view, TRUE);
- selector->priv->toggled_last = FALSE;
- selector->priv->select_new = FALSE;
- selector->priv->show_colors = TRUE;
- selector->priv->show_toggles = TRUE;
+ priv->toggled_last = FALSE;
+ priv->select_new = FALSE;
+ priv->show_colors = TRUE;
+ priv->show_toggles = TRUE;
- selector->priv->source_index = g_hash_table_new_full (
+ priv->source_index = g_hash_table_new_full (
(GHashFunc) e_source_hash,
(GEqualFunc) e_source_equal,
(GDestroyNotify) g_object_unref,
@@ -1469,8 +1485,9 @@ ESourceRegistry *
e_source_selector_get_registry (ESourceSelector *selector)
{
g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL);
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- return selector->priv->registry;
+ return priv->registry;
}
/**
@@ -1487,8 +1504,9 @@ const gchar *
e_source_selector_get_extension_name (ESourceSelector *selector)
{
g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL);
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- return selector->priv->extension_name;
+ return priv->extension_name;
}
/**
@@ -1505,8 +1523,9 @@ gboolean
e_source_selector_get_show_colors (ESourceSelector *selector)
{
g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE);
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- return selector->priv->show_colors;
+ return priv->show_colors;
}
/**
@@ -1523,11 +1542,12 @@ e_source_selector_set_show_colors (ESourceSelector *selector,
gboolean show_colors)
{
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- if ((show_colors ? 1 : 0) == (selector->priv->show_colors ? 1 : 0))
+ if ((show_colors ? 1 : 0) == (priv->show_colors ? 1 : 0))
return;
- selector->priv->show_colors = show_colors;
+ priv->show_colors = show_colors;
g_object_notify (G_OBJECT (selector), "show-colors");
@@ -1548,8 +1568,9 @@ gboolean
e_source_selector_get_show_toggles (ESourceSelector *selector)
{
g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE);
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- return selector->priv->show_toggles;
+ return priv->show_toggles;
}
/**
@@ -1566,11 +1587,12 @@ e_source_selector_set_show_toggles (ESourceSelector *selector,
gboolean show_toggles)
{
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- if ((show_toggles ? 1 : 0) == (selector->priv->show_toggles ? 1 : 0))
+ if ((show_toggles ? 1 : 0) == (priv->show_toggles ? 1 : 0))
return;
- selector->priv->show_toggles = show_toggles;
+ priv->show_toggles = show_toggles;
g_object_notify (G_OBJECT (selector), "show-toggles");
@@ -1658,8 +1680,9 @@ e_source_selector_set_select_new (ESourceSelector *selector,
gboolean state)
{
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
+ ESourceSelectorPrivate *priv = e_source_selector_get_instance_private (selector);
- selector->priv->select_new = state;
+ priv->select_new = state;
}
/**
@@ -1673,15 +1696,17 @@ void
e_source_selector_select_source (ESourceSelector *selector,
ESource *source)
{
+ ESourceSelectorPrivate *priv;
ESourceSelectorClass *class;
GtkTreeRowReference *reference;
GHashTable *source_index;
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
+ priv = e_source_selector_get_instance_private (selector);
/* Make sure the ESource is in our tree model. */
- source_index = selector->priv->source_index;
+ source_index = priv->source_index;
reference = g_hash_table_lookup (source_index, source);
g_return_if_fail (gtk_tree_row_reference_valid (reference));
@@ -1704,15 +1729,17 @@ void
e_source_selector_unselect_source (ESourceSelector *selector,
ESource *source)
{
+ ESourceSelectorPrivate *priv;
ESourceSelectorClass *class;
GtkTreeRowReference *reference;
GHashTable *source_index;
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
+ priv = e_source_selector_get_instance_private (selector);
/* Make sure the ESource is in our tree model. */
- source_index = selector->priv->source_index;
+ source_index = priv->source_index;
reference = g_hash_table_lookup (source_index, source);
g_return_if_fail (gtk_tree_row_reference_valid (reference));
@@ -1737,6 +1764,7 @@ void
e_source_selector_select_exclusive (ESourceSelector *selector,
ESource *source)
{
+ ESourceSelectorPrivate *priv;
ESourceSelectorClass *class;
GHashTable *source_index;
GHashTableIter iter;
@@ -1745,10 +1773,11 @@ e_source_selector_select_exclusive (ESourceSelector *selector,
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
+ priv = e_source_selector_get_instance_private (selector);
class = E_SOURCE_SELECTOR_GET_CLASS (selector);
g_return_if_fail (class->set_source_selected != NULL);
- source_index = selector->priv->source_index;
+ source_index = priv->source_index;
g_hash_table_iter_init (&iter, source_index);
while (g_hash_table_iter_next (&iter, &key, NULL)) {
@@ -1772,6 +1801,7 @@ gboolean
e_source_selector_source_is_selected (ESourceSelector *selector,
ESource *source)
{
+ ESourceSelectorPrivate *priv;
ESourceSelectorClass *class;
GtkTreeRowReference *reference;
GHashTable *source_index;
@@ -1780,7 +1810,8 @@ e_source_selector_source_is_selected (ESourceSelector *selector,
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
/* Make sure the ESource is in our tree model. */
- source_index = selector->priv->source_index;
+ priv = e_source_selector_get_instance_private (selector);
+ source_index = priv->source_index;
reference = g_hash_table_lookup (source_index, source);
g_return_val_if_fail (gtk_tree_row_reference_valid (reference), FALSE);
@@ -1802,6 +1833,7 @@ e_source_selector_source_is_selected (ESourceSelector *selector,
void
e_source_selector_edit_primary_selection (ESourceSelector *selector)
{
+ ESourceSelectorPrivate *priv;
GtkTreeRowReference *reference;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
@@ -1816,7 +1848,8 @@ e_source_selector_edit_primary_selection (ESourceSelector *selector)
tree_view = GTK_TREE_VIEW (selector);
column = gtk_tree_view_get_column (tree_view, 0);
- reference = selector->priv->saved_primary_selection;
+ priv = e_source_selector_get_instance_private (selector);
+ reference = priv->saved_primary_selection;
selection = gtk_tree_view_get_selection (tree_view);
if (reference != NULL)
@@ -1870,6 +1903,7 @@ e_source_selector_edit_primary_selection (ESourceSelector *selector)
ESource *
e_source_selector_ref_primary_selection (ESourceSelector *selector)
{
+ ESourceSelectorPrivate *priv;
ESource *source;
GtkTreeRowReference *reference;
GtkTreeSelection *selection;
@@ -1885,7 +1919,8 @@ e_source_selector_ref_primary_selection (ESourceSelector *selector)
model = gtk_tree_view_get_model (tree_view);
selection = gtk_tree_view_get_selection (tree_view);
- reference = selector->priv->saved_primary_selection;
+ priv = e_source_selector_get_instance_private (selector);
+ reference = priv->saved_primary_selection;
if (gtk_tree_row_reference_valid (reference)) {
GtkTreePath *path;
@@ -1930,6 +1965,7 @@ void
e_source_selector_set_primary_selection (ESourceSelector *selector,
ESource *source)
{
+ ESourceSelectorPrivate *priv;
GHashTable *source_index;
GtkTreeRowReference *reference;
GtkTreeSelection *selection;
@@ -1944,7 +1980,8 @@ e_source_selector_set_primary_selection (ESourceSelector *selector,
tree_view = GTK_TREE_VIEW (selector);
selection = gtk_tree_view_get_selection (tree_view);
- source_index = selector->priv->source_index;
+ priv = e_source_selector_get_instance_private (selector);
+ source_index = priv->source_index;
reference = g_hash_table_lookup (source_index, source);
/* XXX Maybe we should return a success/fail boolean? */
@@ -1977,7 +2014,7 @@ e_source_selector_set_primary_selection (ESourceSelector *selector,
if (gtk_tree_view_row_expanded (tree_view, parent_path)) {
gtk_tree_selection_select_path (selection, child_path);
} else {
- selector->priv->saved_primary_selection =
+ priv->saved_primary_selection =
gtk_tree_row_reference_copy (reference);
g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0);
g_object_notify (G_OBJECT (selector), "primary-selection");
@@ -2034,6 +2071,7 @@ void
e_source_selector_queue_write (ESourceSelector *selector,
ESource *source)
{
+ ESourceSelectorPrivate *priv;
GSource *idle_source;
GHashTable *pending_writes;
GMainContext *main_context;
@@ -2042,8 +2080,9 @@ e_source_selector_queue_write (ESourceSelector *selector,
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
- main_context = selector->priv->main_context;
- pending_writes = selector->priv->pending_writes;
+ priv = e_source_selector_get_instance_private (selector);
+ main_context = priv->main_context;
+ pending_writes = priv->pending_writes;
idle_source = g_hash_table_lookup (pending_writes, source);
if (idle_source != NULL && !g_source_is_destroyed (idle_source))
diff --git a/src/event-factories/e-source-selector.h b/src/event-factories/e-source-selector.h
index b6d3770..7f3b9d4 100644
--- a/src/event-factories/e-source-selector.h
+++ b/src/event-factories/e-source-selector.h
@@ -27,35 +27,11 @@
#include <gtk/gtk.h>
#include <libedataserver/libedataserver.h>
-/* Standard GObject macros */
-#define E_TYPE_SOURCE_SELECTOR \
- (e_source_selector_get_type ())
-#define E_SOURCE_SELECTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SOURCE_SELECTOR, ESourceSelector))
-#define E_SOURCE_SELECTOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SOURCE_SELECTOR, ESourceSelectorClass))
-#define E_IS_SOURCE_SELECTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SOURCE_SELECTOR))
-#define E_IS_SOURCE_SELECTOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SOURCE_SELECTOR))
-#define E_SOURCE_SELECTOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SOURCE_SELECTOR, ESourceSelectorClass))
-
G_BEGIN_DECLS
-typedef struct _ESourceSelector ESourceSelector;
-typedef struct _ESourceSelectorClass ESourceSelectorClass;
-typedef struct _ESourceSelectorPrivate ESourceSelectorPrivate;
-
-struct _ESourceSelector {
- GtkTreeView parent;
- ESourceSelectorPrivate *priv;
-};
+/* Standard GObject macros */
+#define E_TYPE_SOURCE_SELECTOR (e_source_selector_get_type ())
+G_DECLARE_DERIVABLE_TYPE (ESourceSelector, e_source_selector, E, SOURCE_SELECTOR, GtkTreeView)
struct _ESourceSelectorClass {
GtkTreeViewClass parent_class;
@@ -85,7 +61,6 @@ struct _ESourceSelectorClass {
gpointer padding3;
};
-GType e_source_selector_get_type (void);
GtkWidget * e_source_selector_new (ESourceRegistry *registry,
const gchar *extension_name);
ESourceRegistry *
diff --git a/src/event-factory.c b/src/event-factory.c
index 44a55e4..cc9f62e 100644
--- a/src/event-factory.c
+++ b/src/event-factory.c
@@ -24,9 +24,9 @@
static void almanah_event_factory_get_property (GObject *object, guint property_id, GValue *value,
GParamSpec *pspec);
-struct _AlmanahEventFactoryPrivate {
+typedef struct {
GDate date;
-};
+} AlmanahEventFactoryPrivate;
enum {
PROP_TYPE_ID = 1
@@ -39,16 +39,13 @@ enum {
static guint event_factory_signals[LAST_SIGNAL] = { 0, };
-G_DEFINE_ABSTRACT_TYPE (AlmanahEventFactory, almanah_event_factory, G_TYPE_OBJECT)
-#define ALMANAH_EVENT_FACTORY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_EVENT_FACTORY, AlmanahEventFactoryPrivate))
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (AlmanahEventFactory, almanah_event_factory, G_TYPE_OBJECT)
static void
almanah_event_factory_class_init (AlmanahEventFactoryClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahEventFactoryPrivate));
-
gobject_class->get_property = almanah_event_factory_get_property;
g_object_class_install_property (gobject_class, PROP_TYPE_ID,
@@ -68,7 +65,6 @@ almanah_event_factory_class_init (AlmanahEventFactoryClass *klass)
static void
almanah_event_factory_init (AlmanahEventFactory *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_EVENT_FACTORY,
AlmanahEventFactoryPrivate);
}
static void
diff --git a/src/event-factory.h b/src/event-factory.h
index 7939d01..ba70435 100644
--- a/src/event-factory.h
+++ b/src/event-factory.h
@@ -31,30 +31,17 @@ typedef enum {
ALMANAH_EVENT_FACTORY_CALENDAR
} AlmanahEventFactoryType;
-#define ALMANAH_TYPE_EVENT_FACTORY (almanah_event_factory_get_type ())
-#define ALMANAH_EVENT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_EVENT_FACTORY,
AlmanahEventFactory))
-#define ALMANAH_EVENT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_EVENT_FACTORY,
AlmanahEventFactoryClass))
-#define ALMANAH_IS_EVENT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_EVENT_FACTORY))
-#define ALMANAH_IS_EVENT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_EVENT_FACTORY))
-#define ALMANAH_EVENT_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_EVENT_FACTORY,
AlmanahEventFactoryClass))
+#define ALMANAH_TYPE_EVENT_FACTORY (almanah_event_factory_get_type ())
+G_DECLARE_DERIVABLE_TYPE (AlmanahEventFactory, almanah_event_factory, ALMANAH, EVENT_FACTORY, GObject)
-typedef struct _AlmanahEventFactoryPrivate AlmanahEventFactoryPrivate;
-
-typedef struct {
- GObject parent;
- AlmanahEventFactoryPrivate *priv;
-} AlmanahEventFactory;
-
-typedef struct {
+struct _AlmanahEventFactoryClass {
GObjectClass parent;
AlmanahEventFactoryType type_id;
void (*query_events) (AlmanahEventFactory *event_factory, GDate *date);
GSList *(*get_events) (AlmanahEventFactory *event_factory, GDate *date);
-} AlmanahEventFactoryClass;
-
-GType almanah_event_factory_get_type (void);
+};
AlmanahEventFactoryType almanah_event_factory_get_type_id (AlmanahEventFactory *self);
diff --git a/src/event-manager.c b/src/event-manager.c
index 9f5334c..fb739b4 100644
--- a/src/event-manager.c
+++ b/src/event-manager.c
@@ -43,8 +43,13 @@ const EventFactoryType event_factory_types[] = {
static void almanah_event_manager_dispose (GObject *object);
static void events_updated_cb (AlmanahEventFactory *factory, AlmanahEventManager *self);
-struct _AlmanahEventManagerPrivate {
+typedef struct {
AlmanahEventFactory **factories;
+} AlmanahEventManagerPrivate;
+
+struct _AlmanahEventManager {
+ GObject parent;
+ AlmanahEventManagerPrivate *priv;
};
enum {
@@ -54,16 +59,13 @@ enum {
static guint event_manager_signals[LAST_SIGNAL] = { 0, };
-G_DEFINE_TYPE (AlmanahEventManager, almanah_event_manager, G_TYPE_OBJECT)
-#define ALMANAH_EVENT_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_EVENT_MANAGER, AlmanahEventManagerPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahEventManager, almanah_event_manager, G_TYPE_OBJECT)
static void
almanah_event_manager_class_init (AlmanahEventManagerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahEventManagerPrivate));
-
gobject_class->dispose = almanah_event_manager_dispose;
event_manager_signals[SIGNAL_EVENTS_UPDATED] = g_signal_new ("events-updated",
@@ -79,7 +81,7 @@ almanah_event_manager_init (AlmanahEventManager *self)
{
guint i;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_EVENT_MANAGER,
AlmanahEventManagerPrivate);
+ self->priv = almanah_event_manager_get_instance_private (self);
/* Set up the list of AlmanahEventFactories */
self->priv->factories = g_new (AlmanahEventFactory*, G_N_ELEMENTS (event_factory_types) + 1);
@@ -94,7 +96,7 @@ static void
almanah_event_manager_dispose (GObject *object)
{
guint i = 0;
- AlmanahEventManagerPrivate *priv = ALMANAH_EVENT_MANAGER_GET_PRIVATE (object);
+ AlmanahEventManagerPrivate *priv = almanah_event_manager_get_instance_private (ALMANAH_EVENT_MANAGER
(object));
/* Free the factories */
if (priv->factories != NULL) {
@@ -123,7 +125,7 @@ events_updated_cb (AlmanahEventFactory *factory, AlmanahEventManager *self)
void
almanah_event_manager_query_events (AlmanahEventManager *self, AlmanahEventFactoryType type_id, GDate *date)
{
- AlmanahEventManagerPrivate *priv = ALMANAH_EVENT_MANAGER_GET_PRIVATE (self);
+ AlmanahEventManagerPrivate *priv = almanah_event_manager_get_instance_private (self);
guint i;
g_debug ("almanah_event_manager_query_events called for factory %u and date %u-%u-%u.", type_id,
@@ -147,7 +149,7 @@ almanah_event_manager_query_events (AlmanahEventManager *self, AlmanahEventFacto
GSList *
almanah_event_manager_get_events (AlmanahEventManager *self, AlmanahEventFactoryType type_id, GDate *date)
{
- AlmanahEventManagerPrivate *priv = ALMANAH_EVENT_MANAGER_GET_PRIVATE (self);
+ AlmanahEventManagerPrivate *priv = almanah_event_manager_get_instance_private (self);
GSList *list = NULL, *end = NULL;
guint i;
diff --git a/src/event-manager.h b/src/event-manager.h
index 9980724..018b382 100644
--- a/src/event-manager.h
+++ b/src/event-manager.h
@@ -27,25 +27,8 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_EVENT_MANAGER (almanah_event_manager_get_type ())
-#define ALMANAH_EVENT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_EVENT_MANAGER,
AlmanahEventManager))
-#define ALMANAH_EVENT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_EVENT_MANAGER,
AlmanahEventManagerClass))
-#define ALMANAH_IS_EVENT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_EVENT_MANAGER))
-#define ALMANAH_IS_EVENT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_EVENT_MANAGER))
-#define ALMANAH_EVENT_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_EVENT_MANAGER,
AlmanahEventManagerClass))
-
-typedef struct _AlmanahEventManagerPrivate AlmanahEventManagerPrivate;
-
-typedef struct {
- GObject parent;
- AlmanahEventManagerPrivate *priv;
-} AlmanahEventManager;
-
-typedef struct {
- GObjectClass parent;
-} AlmanahEventManagerClass;
-
-GType almanah_event_manager_get_type (void);
+#define ALMANAH_TYPE_EVENT_MANAGER (almanah_event_manager_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahEventManager, almanah_event_manager, ALMANAH, EVENT_MANAGER, GObject)
AlmanahEventManager *almanah_event_manager_new (void);
diff --git a/src/event.c b/src/event.c
index 42bd22b..8991089 100644
--- a/src/event.c
+++ b/src/event.c
@@ -33,7 +33,6 @@ enum {
};
G_DEFINE_ABSTRACT_TYPE (AlmanahEvent, almanah_event, G_TYPE_OBJECT)
-#define ALMANAH_EVENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ALMANAH_TYPE_EVENT,
AlmanahEventPrivate))
static void
almanah_event_class_init (AlmanahEventClass *klass)
diff --git a/src/event.h b/src/event.h
index 2d2f539..0e89c2c 100644
--- a/src/event.h
+++ b/src/event.h
@@ -26,20 +26,10 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_EVENT (almanah_event_get_type ())
-#define ALMANAH_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_EVENT, AlmanahEvent))
-#define ALMANAH_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_EVENT, AlmanahEventClass))
-#define ALMANAH_IS_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_EVENT))
-#define ALMANAH_IS_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_EVENT))
-#define ALMANAH_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_EVENT,
AlmanahEventClass))
+#define ALMANAH_TYPE_EVENT (almanah_event_get_type ())
+G_DECLARE_DERIVABLE_TYPE (AlmanahEvent, almanah_event, ALMANAH, EVENT, GObject)
-typedef struct _AlmanahEventPrivate AlmanahEventPrivate;
-
-typedef struct {
- GObject parent;
-} AlmanahEvent;
-
-typedef struct {
+struct _AlmanahEventClass {
GObjectClass parent;
const gchar *name;
@@ -49,9 +39,7 @@ typedef struct {
const gchar *(*format_value) (AlmanahEvent *event);
const gchar *(*format_time) (AlmanahEvent *event);
gboolean (*view) (AlmanahEvent *event, GtkWindow *parent_window);
-} AlmanahEventClass;
-
-GType almanah_event_get_type (void);
+};
const gchar *almanah_event_format_value (AlmanahEvent *self);
const gchar *almanah_event_format_time (AlmanahEvent *self);
diff --git a/src/events/calendar-appointment.c b/src/events/calendar-appointment.c
index 2a23dac..a63c51c 100644
--- a/src/events/calendar-appointment.c
+++ b/src/events/calendar-appointment.c
@@ -29,14 +29,18 @@ static const gchar *almanah_calendar_appointment_event_format_value (AlmanahEven
static const gchar *almanah_calendar_appointment_event_format_time (AlmanahEvent *event);
static gboolean almanah_calendar_appointment_event_view (AlmanahEvent *event, GtkWindow *parent_window);
-struct _AlmanahCalendarAppointmentEventPrivate {
+typedef struct {
gchar *summary;
gchar *time;
GTime start_time;
+} AlmanahCalendarAppointmentEventPrivate;
+
+struct _AlmanahCalendarAppointmentEvent {
+ AlmanahEvent parent;
+ AlmanahCalendarAppointmentEventPrivate *priv;
};
-G_DEFINE_TYPE (AlmanahCalendarAppointmentEvent, almanah_calendar_appointment_event, ALMANAH_TYPE_EVENT)
-#define ALMANAH_CALENDAR_APPOINTMENT_EVENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, AlmanahCalendarAppointmentEventPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahCalendarAppointmentEvent, almanah_calendar_appointment_event,
ALMANAH_TYPE_EVENT)
static void
almanah_calendar_appointment_event_class_init (AlmanahCalendarAppointmentEventClass *klass)
@@ -44,8 +48,6 @@ almanah_calendar_appointment_event_class_init (AlmanahCalendarAppointmentEventCl
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AlmanahEventClass *event_class = ALMANAH_EVENT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahCalendarAppointmentEventPrivate));
-
gobject_class->finalize = almanah_calendar_appointment_event_finalize;
event_class->name = _("Calendar Appointment");
@@ -60,13 +62,13 @@ almanah_calendar_appointment_event_class_init (AlmanahCalendarAppointmentEventCl
static void
almanah_calendar_appointment_event_init (AlmanahCalendarAppointmentEvent *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT,
AlmanahCalendarAppointmentEventPrivate);
+ self->priv = almanah_calendar_appointment_event_get_instance_private (self);
}
static void
almanah_calendar_appointment_event_finalize (GObject *object)
{
- AlmanahCalendarAppointmentEventPrivate *priv = ALMANAH_CALENDAR_APPOINTMENT_EVENT_GET_PRIVATE
(object);
+ AlmanahCalendarAppointmentEventPrivate *priv =
almanah_calendar_appointment_event_get_instance_private (ALMANAH_CALENDAR_APPOINTMENT_EVENT (object));
g_free (priv->summary);
g_free (priv->time);
diff --git a/src/events/calendar-appointment.h b/src/events/calendar-appointment.h
index e4aa387..31887c1 100644
--- a/src/events/calendar-appointment.h
+++ b/src/events/calendar-appointment.h
@@ -27,25 +27,9 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT (almanah_calendar_appointment_event_get_type
())
-#define ALMANAH_CALENDAR_APPOINTMENT_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, AlmanahCalendarAppointmentEvent))
-#define ALMANAH_CALENDAR_APPOINTMENT_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, AlmanahCalendarAppointmentEventClass))
-#define ALMANAH_IS_CALENDAR_APPOINTMENT_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT))
-#define ALMANAH_IS_CALENDAR_APPOINTMENT_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT))
-#define ALMANAH_CALENDAR_APPOINTMENT_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, AlmanahCalendarAppointmentEventClass))
+#define ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT (almanah_calendar_appointment_event_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahCalendarAppointmentEvent, almanah_calendar_appointment_event, ALMANAH,
CALENDAR_APPOINTMENT_EVENT, AlmanahEvent)
-typedef struct _AlmanahCalendarAppointmentEventPrivate AlmanahCalendarAppointmentEventPrivate;
-
-typedef struct {
- AlmanahEvent parent;
- AlmanahCalendarAppointmentEventPrivate *priv;
-} AlmanahCalendarAppointmentEvent;
-
-typedef struct {
- AlmanahEventClass parent;
-} AlmanahCalendarAppointmentEventClass;
-
-GType almanah_calendar_appointment_event_get_type (void);
AlmanahCalendarAppointmentEvent *almanah_calendar_appointment_event_new (const gchar *summary, GTime
start_time);
G_END_DECLS
diff --git a/src/events/calendar-task.c b/src/events/calendar-task.c
index ea610ad..7b415e0 100644
--- a/src/events/calendar-task.c
+++ b/src/events/calendar-task.c
@@ -29,14 +29,18 @@ static const gchar *almanah_calendar_task_event_format_value (AlmanahEvent *even
static const gchar *almanah_calendar_task_event_format_time (AlmanahEvent *event);
static gboolean almanah_calendar_task_event_view (AlmanahEvent *event, GtkWindow *parent_window);
-struct _AlmanahCalendarTaskEventPrivate {
+typedef struct {
gchar *uid;
gchar *summary;
gchar *time;
+} AlmanahCalendarTaskEventPrivate;
+
+struct _AlmanahCalendarTaskEvent {
+ AlmanahEvent parent;
+ AlmanahCalendarTaskEventPrivate *priv;
};
-G_DEFINE_TYPE (AlmanahCalendarTaskEvent, almanah_calendar_task_event, ALMANAH_TYPE_EVENT)
-#define ALMANAH_CALENDAR_TASK_EVENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEventPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahCalendarTaskEvent, almanah_calendar_task_event, ALMANAH_TYPE_EVENT)
static void
almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
@@ -44,8 +48,6 @@ almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AlmanahEventClass *event_class = ALMANAH_EVENT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahCalendarTaskEventPrivate));
-
gobject_class->finalize = almanah_calendar_task_event_finalize;
event_class->name = _("Calendar Task");
@@ -60,13 +62,13 @@ almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
static void
almanah_calendar_task_event_init (AlmanahCalendarTaskEvent *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_TASK_EVENT,
AlmanahCalendarTaskEventPrivate);
+ self->priv = almanah_calendar_task_event_get_instance_private (self);
}
static void
almanah_calendar_task_event_finalize (GObject *object)
{
- AlmanahCalendarTaskEventPrivate *priv = ALMANAH_CALENDAR_TASK_EVENT_GET_PRIVATE (object);
+ AlmanahCalendarTaskEventPrivate *priv = almanah_calendar_task_event_get_instance_private
(ALMANAH_CALENDAR_TASK_EVENT (object));
g_free (priv->uid);
g_free (priv->summary);
diff --git a/src/events/calendar-task.h b/src/events/calendar-task.h
index fdea4b1..d06d21b 100644
--- a/src/events/calendar-task.h
+++ b/src/events/calendar-task.h
@@ -27,25 +27,9 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_CALENDAR_TASK_EVENT (almanah_calendar_task_event_get_type ())
-#define ALMANAH_CALENDAR_TASK_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEvent))
-#define ALMANAH_CALENDAR_TASK_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEventClass))
-#define ALMANAH_IS_CALENDAR_TASK_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_CALENDAR_TASK_EVENT))
-#define ALMANAH_IS_CALENDAR_TASK_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_CALENDAR_TASK_EVENT))
-#define ALMANAH_CALENDAR_TASK_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEventClass))
+#define ALMANAH_TYPE_CALENDAR_TASK_EVENT (almanah_calendar_task_event_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahCalendarTaskEvent, almanah_calendar_task_event, ALMANAH, CALENDAR_TASK_EVENT,
AlmanahEvent)
-typedef struct _AlmanahCalendarTaskEventPrivate AlmanahCalendarTaskEventPrivate;
-
-typedef struct {
- AlmanahEvent parent;
- AlmanahCalendarTaskEventPrivate *priv;
-} AlmanahCalendarTaskEvent;
-
-typedef struct {
- AlmanahEventClass parent;
-} AlmanahCalendarTaskEventClass;
-
-GType almanah_calendar_task_event_get_type (void);
AlmanahCalendarTaskEvent *almanah_calendar_task_event_new (const gchar *uid, const gchar *summary, GTime
start_time);
G_END_DECLS
diff --git a/src/export-operation.c b/src/export-operation.c
index f32293e..e9c5a38 100644
--- a/src/export-operation.c
+++ b/src/export-operation.c
@@ -59,26 +59,28 @@ static void get_property (GObject *object, guint property_id, GValue *value, GPa
static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void almanah_export_operation_dispose (GObject *object);
-struct _AlmanahExportOperationPrivate {
+typedef struct {
gint current_mode; /* index into export_modes */
AlmanahStorageManager *storage_manager;
GFile *destination;
+} AlmanahExportOperationPrivate;
+
+struct _AlmanahExportOperation {
+ GObject parent;
+ AlmanahExportOperationPrivate *priv;
};
enum {
PROP_STORAGE_MANAGER = 1,
};
-G_DEFINE_TYPE (AlmanahExportOperation, almanah_export_operation, G_TYPE_OBJECT)
-#define ALMANAH_EXPORT_OPERATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_EXPORT_OPERATION, AlmanahExportOperationPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahExportOperation, almanah_export_operation, G_TYPE_OBJECT)
static void
almanah_export_operation_class_init (AlmanahExportOperationClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahExportOperationPrivate));
-
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
gobject_class->dispose = almanah_export_operation_dispose;
@@ -93,7 +95,7 @@ almanah_export_operation_class_init (AlmanahExportOperationClass *klass)
static void
almanah_export_operation_init (AlmanahExportOperation *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_EXPORT_OPERATION,
AlmanahExportOperationPrivate);
+ self->priv = almanah_export_operation_get_instance_private (self);
self->priv->current_mode = -1; /* no mode selected */
}
diff --git a/src/export-operation.h b/src/export-operation.h
index 07cfd74..68ade38 100644
--- a/src/export-operation.h
+++ b/src/export-operation.h
@@ -31,25 +31,8 @@ typedef guint AlmanahExportOperationType;
typedef void (*AlmanahExportProgressCallback) (const GDate *date, gpointer user_data);
-#define ALMANAH_TYPE_EXPORT_OPERATION (almanah_export_operation_get_type ())
-#define ALMANAH_EXPORT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_EXPORT_OPERATION, AlmanahExportOperation))
-#define ALMANAH_EXPORT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_EXPORT_OPERATION,
AlmanahExportOperationClass))
-#define ALMANAH_IS_EXPORT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_EXPORT_OPERATION))
-#define ALMANAH_IS_EXPORT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_EXPORT_OPERATION))
-#define ALMANAH_EXPORT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_EXPORT_OPERATION, AlmanahExportOperationClass))
-
-typedef struct _AlmanahExportOperationPrivate AlmanahExportOperationPrivate;
-
-typedef struct {
- GObject parent;
- AlmanahExportOperationPrivate *priv;
-} AlmanahExportOperation;
-
-typedef struct {
- GObjectClass parent;
-} AlmanahExportOperationClass;
-
-GType almanah_export_operation_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_EXPORT_OPERATION (almanah_export_operation_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahExportOperation, almanah_export_operation, ALMANAH, EXPORT_OPERATION, GObject)
AlmanahExportOperation *almanah_export_operation_new (AlmanahExportOperationType type_id,
AlmanahStorageManager *source_storage_manager,
GFile *destination) G_GNUC_WARN_UNUSED_RESULT
G_GNUC_MALLOC;
diff --git a/src/import-export-dialog.c b/src/import-export-dialog.c
index 4fa4661..5490f68 100644
--- a/src/import-export-dialog.c
+++ b/src/import-export-dialog.c
@@ -35,7 +35,7 @@ void ied_mode_combo_box_changed_cb (GtkComboBox *combo_box, AlmanahImportExportD
void ied_file_chooser_selection_changed_cb (GtkFileChooser *file_chooser, AlmanahImportExportDialog *self);
void ied_file_chooser_file_activated_cb (GtkFileChooser *file_chooser, AlmanahImportExportDialog *self);
-struct _AlmanahImportExportDialogPrivate {
+typedef struct {
AlmanahStorageManager *storage_manager;
gboolean import; /* TRUE if we're in import mode, FALSE otherwise */
GtkComboBox *mode_combo_box;
@@ -46,15 +46,18 @@ struct _AlmanahImportExportDialogPrivate {
GtkLabel *description_label;
GtkProgressBar *progress_bar;
GCancellable *cancellable; /* non-NULL iff an operation is underway */
+} AlmanahImportExportDialogPrivate;
+
+struct _AlmanahImportExportDialog {
+ GtkDialog parent;
+ AlmanahImportExportDialogPrivate *priv;
};
enum {
PROP_STORAGE_MANAGER = 1,
};
-G_DEFINE_TYPE (AlmanahImportExportDialog, almanah_import_export_dialog, GTK_TYPE_DIALOG)
-#define ALMANAH_IMPORT_EXPORT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_IMPORT_EXPORT_DIALOG,\
- AlmanahImportExportDialogPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahImportExportDialog, almanah_import_export_dialog, GTK_TYPE_DIALOG)
static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
@@ -65,8 +68,6 @@ almanah_import_export_dialog_class_init (AlmanahImportExportDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahImportExportDialogPrivate));
-
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
gobject_class->dispose = almanah_import_export_dialog_dispose;
@@ -82,7 +83,7 @@ almanah_import_export_dialog_class_init (AlmanahImportExportDialogClass *klass)
static void
almanah_import_export_dialog_init (AlmanahImportExportDialog *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_IMPORT_EXPORT_DIALOG,
AlmanahImportExportDialogPrivate);
+ self->priv = almanah_import_export_dialog_get_instance_private (self);
self->priv->current_mode = -1; /* no mode selected */
g_signal_connect (self, "response", G_CALLBACK (response_cb), self);
@@ -419,28 +420,30 @@ void ird_results_tree_view_row_activated_cb (GtkTreeView *tree_view, GtkTreePath
void ird_view_button_clicked_cb (GtkButton *button, AlmanahImportResultsDialog *self);
void ird_view_combo_box_changed_cb (GtkComboBox *combo_box, AlmanahImportResultsDialog *self);
-struct _AlmanahImportResultsDialogPrivate {
+typedef struct {
GtkListStore *results_store;
GtkTreeSelection *results_selection;
GtkTreeModelFilter *filtered_results_store;
GtkComboBox *view_combo_box;
AlmanahImportStatus current_mode;
+} AlmanahImportResultsDialogPrivate;
+
+struct _AlmanahImportResultsDialog {
+ GtkDialog parent;
+ AlmanahImportResultsDialogPrivate *priv;
};
-G_DEFINE_TYPE (AlmanahImportResultsDialog, almanah_import_results_dialog, GTK_TYPE_DIALOG)
-#define ALMANAH_IMPORT_RESULTS_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_IMPORT_RESULTS_DIALOG,\
- AlmanahImportResultsDialogPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahImportResultsDialog, almanah_import_results_dialog, GTK_TYPE_DIALOG)
static void
almanah_import_results_dialog_class_init (AlmanahImportResultsDialogClass *klass)
{
- g_type_class_add_private (klass, sizeof (AlmanahImportResultsDialogPrivate));
}
static void
almanah_import_results_dialog_init (AlmanahImportResultsDialog *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_IMPORT_RESULTS_DIALOG,
AlmanahImportResultsDialogPrivate);
+ self->priv = almanah_import_results_dialog_get_instance_private (self);
g_signal_connect (self, "response", G_CALLBACK (response_cb), self);
g_signal_connect (self, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), self);
diff --git a/src/import-export-dialog.h b/src/import-export-dialog.h
index 8601cc3..5e5adda 100644
--- a/src/import-export-dialog.h
+++ b/src/import-export-dialog.h
@@ -29,47 +29,13 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_IMPORT_EXPORT_DIALOG (almanah_import_export_dialog_get_type ())
-#define ALMANAH_IMPORT_EXPORT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_IMPORT_EXPORT_DIALOG, AlmanahImportExportDialog))
-#define ALMANAH_IMPORT_EXPORT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
ALMANAH_TYPE_IMPORT_EXPORT_DIALOG, AlmanahImportExportDialogClass))
-#define ALMANAH_IS_IMPORT_EXPORT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_IMPORT_EXPORT_DIALOG))
-#define ALMANAH_IS_IMPORT_EXPORT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_IMPORT_EXPORT_DIALOG))
-#define ALMANAH_IMPORT_EXPORT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_IMPORT_EXPORT_DIALOG, AlmanahImportExportDialogClass))
-
-typedef struct _AlmanahImportExportDialogPrivate AlmanahImportExportDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- AlmanahImportExportDialogPrivate *priv;
-} AlmanahImportExportDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} AlmanahImportExportDialogClass;
-
-GType almanah_import_export_dialog_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_IMPORT_EXPORT_DIALOG (almanah_import_export_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahImportExportDialog, almanah_import_export_dialog, ALMANAH,
IMPORT_EXPORT_DIALOG, GtkDialog)
AlmanahImportExportDialog *almanah_import_export_dialog_new (AlmanahStorageManager *storage_manager,
gboolean import) G_GNUC_WARN_UNUSED_RESULT;
-#define ALMANAH_TYPE_IMPORT_RESULTS_DIALOG (almanah_import_results_dialog_get_type ())
-#define ALMANAH_IMPORT_RESULTS_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_IMPORT_RESULTS_DIALOG, AlmanahImportResultsDialog))
-#define ALMANAH_IMPORT_RESULTS_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
ALMANAH_TYPE_IMPORT_RESULTS_DIALOG, AlmanahImportResultsDialogClass))
-#define ALMANAH_IS_IMPORT_RESULTS_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_IMPORT_RESULTS_DIALOG))
-#define ALMANAH_IS_IMPORT_RESULTS_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_IMPORT_RESULTS_DIALOG))
-#define ALMANAH_IMPORT_RESULTS_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_IMPORT_RESULTS_DIALOG, AlmanahImportResultsDialogClass))
-
-typedef struct _AlmanahImportResultsDialogPrivate AlmanahImportResultsDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- AlmanahImportResultsDialogPrivate *priv;
-} AlmanahImportResultsDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} AlmanahImportResultsDialogClass;
-
-GType almanah_import_results_dialog_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_IMPORT_RESULTS_DIALOG (almanah_import_results_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahImportResultsDialog, almanah_import_results_dialog, ALMANAH,
IMPORT_RESULTS_DIALOG, GtkDialog)
AlmanahImportResultsDialog *almanah_import_results_dialog_new (void) G_GNUC_WARN_UNUSED_RESULT;
void almanah_import_results_dialog_add_result (AlmanahImportResultsDialog *self, const GDate *date,
AlmanahImportStatus status, const gchar *message);
diff --git a/src/import-operation.c b/src/import-operation.c
index 70770be..ae5b830 100644
--- a/src/import-operation.c
+++ b/src/import-operation.c
@@ -57,26 +57,28 @@ static void get_property (GObject *object, guint property_id, GValue *value, GPa
static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void almanah_import_operation_dispose (GObject *object);
-struct _AlmanahImportOperationPrivate {
+typedef struct {
gint current_mode; /* index into import_modes */
GFile *source;
AlmanahStorageManager *storage_manager;
+} AlmanahImportOperationPrivate;
+
+struct _AlmanahImportOperation {
+ GObject parent;
+ AlmanahImportOperationPrivate *priv;
};
enum {
PROP_STORAGE_MANAGER = 1,
};
-G_DEFINE_TYPE (AlmanahImportOperation, almanah_import_operation, G_TYPE_OBJECT)
-#define ALMANAH_IMPORT_OPERATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_IMPORT_OPERATION, AlmanahImportOperationPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahImportOperation, almanah_import_operation, G_TYPE_OBJECT)
static void
almanah_import_operation_class_init (AlmanahImportOperationClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahImportOperationPrivate));
-
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
gobject_class->dispose = almanah_import_operation_dispose;
@@ -91,7 +93,7 @@ almanah_import_operation_class_init (AlmanahImportOperationClass *klass)
static void
almanah_import_operation_init (AlmanahImportOperation *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_IMPORT_OPERATION,
AlmanahImportOperationPrivate);
+ self->priv = almanah_import_operation_get_instance_private (self);
self->priv->current_mode = -1; /* no mode selected */
}
diff --git a/src/import-operation.h b/src/import-operation.h
index 6b49207..026969b 100644
--- a/src/import-operation.h
+++ b/src/import-operation.h
@@ -39,25 +39,8 @@ typedef guint AlmanahImportOperationType;
typedef void (*AlmanahImportProgressCallback) (const GDate *date, AlmanahImportStatus status, const gchar
*message, gpointer user_data);
-#define ALMANAH_TYPE_IMPORT_OPERATION (almanah_import_operation_get_type ())
-#define ALMANAH_IMPORT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_IMPORT_OPERATION, AlmanahImportOperation))
-#define ALMANAH_IMPORT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_IMPORT_OPERATION,
AlmanahImportOperationClass))
-#define ALMANAH_IS_IMPORT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_IMPORT_OPERATION))
-#define ALMANAH_IS_IMPORT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_IMPORT_OPERATION))
-#define ALMANAH_IMPORT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_IMPORT_OPERATION, AlmanahImportOperationClass))
-
-typedef struct _AlmanahImportOperationPrivate AlmanahImportOperationPrivate;
-
-typedef struct {
- GObject parent;
- AlmanahImportOperationPrivate *priv;
-} AlmanahImportOperation;
-
-typedef struct {
- GObjectClass parent;
-} AlmanahImportOperationClass;
-
-GType almanah_import_operation_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_IMPORT_OPERATION (almanah_import_operation_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahImportOperation, almanah_import_operation, ALMANAH, IMPORT_OPERATION, GObject)
AlmanahImportOperation *almanah_import_operation_new (AlmanahImportOperationType type_id, GFile *source,
AlmanahStorageManager *dest_storage_manager)
G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
diff --git a/src/main-window.c b/src/main-window.c
index 62b0f2a..0b3262d 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -97,7 +97,7 @@ void mw_calendar_day_selected_cb (AlmanahCalendarButton *calendar, AlmanahMainWi
void mw_calendar_select_date_clicked_cb (AlmanahCalendarButton *calendar, AlmanahMainWindow *main_window);
void mw_desktop_interface_settings_changed (GSettings *settings, const gchar *key, gpointer user_data);
-struct _AlmanahMainWindowPrivate {
+typedef struct {
GtkWidget *header_bar;
GtkSourceView *entry_view;
GtkSourceBuffer *entry_buffer;
@@ -125,10 +125,14 @@ struct _AlmanahMainWindowPrivate {
GSettings *settings;
gulong spell_checking_enabled_changed_id; /* signal handler for
application->settings::changed::spell-checking-enabled */
#endif /* ENABLE_SPELL_CHECKING */
+} AlmanahMainWindowPrivate;
+
+struct _AlmanahMainWindow {
+ GtkApplicationWindow parent;
+ AlmanahMainWindowPrivate *priv;
};
-G_DEFINE_TYPE (AlmanahMainWindow, almanah_main_window, GTK_TYPE_APPLICATION_WINDOW)
-#define ALMANAH_MAIN_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ALMANAH_TYPE_MAIN_WINDOW,
AlmanahMainWindowPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahMainWindow, almanah_main_window, GTK_TYPE_APPLICATION_WINDOW)
static GActionEntry win_entries[] = {
{ "cut", mw_cut_activate_cb },
@@ -151,14 +155,13 @@ static void
almanah_main_window_class_init (AlmanahMainWindowClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahMainWindowPrivate));
gobject_class->dispose = almanah_main_window_dispose;
}
static void
almanah_main_window_init (AlmanahMainWindow *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_MAIN_WINDOW, AlmanahMainWindowPrivate);
+ self->priv = almanah_main_window_get_instance_private (self);
gtk_window_set_title (GTK_WINDOW (self), _("Almanah Diary"));
g_signal_connect (self, "delete-event", G_CALLBACK (mw_delete_event_cb), NULL);
diff --git a/src/main-window.h b/src/main-window.h
index 0cfa43a..782e833 100644
--- a/src/main-window.h
+++ b/src/main-window.h
@@ -28,25 +28,9 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_MAIN_WINDOW (almanah_main_window_get_type ())
-#define ALMANAH_MAIN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_MAIN_WINDOW,
AlmanahMainWindow))
-#define ALMANAH_MAIN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_MAIN_WINDOW,
AlmanahMainWindowClass))
-#define ALMANAH_IS_MAIN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_MAIN_WINDOW))
-#define ALMANAH_IS_MAIN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_MAIN_WINDOW))
-#define ALMANAH_MAIN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_MAIN_WINDOW,
AlmanahMainWindowClass))
+#define ALMANAH_TYPE_MAIN_WINDOW (almanah_main_window_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahMainWindow, almanah_main_window, ALMANAH, MAIN_WINDOW, GtkApplicationWindow)
-typedef struct _AlmanahMainWindowPrivate AlmanahMainWindowPrivate;
-
-typedef struct {
- GtkApplicationWindow parent;
- AlmanahMainWindowPrivate *priv;
-} AlmanahMainWindow;
-
-typedef struct {
- GtkApplicationWindowClass parent;
-} AlmanahMainWindowClass;
-
-GType almanah_main_window_get_type (void);
AlmanahMainWindow *almanah_main_window_new (AlmanahApplication *application) G_GNUC_WARN_UNUSED_RESULT
G_GNUC_MALLOC;
void almanah_main_window_select_date (AlmanahMainWindow *self, GDate *date);
diff --git a/src/meson.build b/src/meson.build
index 8ee6c28..c0236c4 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -69,6 +69,7 @@ inc = include_directories(
almanah = executable(
meson.project_name(),
sources,
+ c_args: ['-Wno-deprecated-declarations'],
dependencies: almanah_deps,
include_directories: inc,
install: true,
diff --git a/src/preferences-dialog.c b/src/preferences-dialog.c
index 6199eeb..c50bdb7 100644
--- a/src/preferences-dialog.c
+++ b/src/preferences-dialog.c
@@ -38,7 +38,7 @@ static void almanah_preferences_dialog_dispose (GObject *object);
static void pd_key_combo_changed_cb (GtkComboBox *combo_box, AlmanahPreferencesDialog *preferences_dialog);
static void pd_new_key_button_clicked_cb (GtkButton *button, AlmanahPreferencesDialog *preferences_dialog);
-struct _AlmanahPreferencesDialogPrivate {
+typedef struct {
GSettings *settings;
CryptUIKeyset *keyset;
CryptUIKeyStore *key_store;
@@ -47,22 +47,24 @@ struct _AlmanahPreferencesDialogPrivate {
guint spell_checking_enabled_id;
GtkCheckButton *spell_checking_enabled_check_button;
#endif /* ENABLE_SPELL_CHECKING */
+} AlmanahPreferencesDialogPrivate;
+
+struct _AlmanahPreferencesDialog {
+ GtkDialog parent;
+ AlmanahPreferencesDialogPrivate *priv;
};
enum {
PROP_SETTINGS = 1,
};
-G_DEFINE_TYPE (AlmanahPreferencesDialog, almanah_preferences_dialog, GTK_TYPE_DIALOG)
-#define ALMANAH_PREFERENCES_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_PREFERENCES_DIALOG, AlmanahPreferencesDialogPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahPreferencesDialog, almanah_preferences_dialog, GTK_TYPE_DIALOG)
static void
almanah_preferences_dialog_class_init (AlmanahPreferencesDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahPreferencesDialogPrivate));
-
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
gobject_class->dispose = almanah_preferences_dialog_dispose;
@@ -77,7 +79,7 @@ almanah_preferences_dialog_class_init (AlmanahPreferencesDialogClass *klass)
static void
almanah_preferences_dialog_init (AlmanahPreferencesDialog *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_PREFERENCES_DIALOG,
AlmanahPreferencesDialogPrivate);
+ self->priv = almanah_preferences_dialog_get_instance_private (self);
gtk_window_set_modal (GTK_WINDOW (self), FALSE);
gtk_window_set_title (GTK_WINDOW (self), _("Preferences"));
diff --git a/src/preferences-dialog.h b/src/preferences-dialog.h
index 865cf54..6713baa 100644
--- a/src/preferences-dialog.h
+++ b/src/preferences-dialog.h
@@ -25,25 +25,9 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_PREFERENCES_DIALOG (almanah_preferences_dialog_get_type ())
-#define ALMANAH_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_PREFERENCES_DIALOG, AlmanahPreferencesDialog))
-#define ALMANAH_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
ALMANAH_TYPE_PREFERENCES_DIALOG, AlmanahPreferencesDialogClass))
-#define ALMANAH_IS_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_PREFERENCES_DIALOG))
-#define ALMANAH_IS_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
ALMANAH_TYPE_PREFERENCES_DIALOG))
-#define ALMANAH_PREFERENCES_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_PREFERENCES_DIALOG, AlmanahPreferencesDialogClass))
+#define ALMANAH_TYPE_PREFERENCES_DIALOG (almanah_preferences_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahPreferencesDialog, almanah_preferences_dialog, ALMANAH, PREFERENCES_DIALOG,
GtkDialog)
-typedef struct _AlmanahPreferencesDialogPrivate AlmanahPreferencesDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- AlmanahPreferencesDialogPrivate *priv;
-} AlmanahPreferencesDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} AlmanahPreferencesDialogClass;
-
-GType almanah_preferences_dialog_get_type (void);
AlmanahPreferencesDialog *almanah_preferences_dialog_new (GSettings *settings) G_GNUC_WARN_UNUSED_RESULT
G_GNUC_MALLOC;
G_END_DECLS
diff --git a/src/search-dialog.c b/src/search-dialog.c
index dbe79c2..899a917 100644
--- a/src/search-dialog.c
+++ b/src/search-dialog.c
@@ -38,7 +38,7 @@ void sd_view_button_clicked_cb (GtkButton *self, AlmanahSearchDialog *search_dia
static void sd_search_progress_cb (AlmanahStorageManager *storage_manager, AlmanahEntry *entry,
AlmanahSearchDialog **search_dialog_weak_pointer);
static void sd_search_ready_cb (AlmanahStorageManager *storage_manager, GAsyncResult *res,
AlmanahSearchDialog **search_dialog_weak_pointer);
-struct _AlmanahSearchDialogPrivate {
+typedef struct {
GtkEntry *sd_search_entry;
GtkWidget *sd_search_button;
GtkWidget *sd_cancel_button;
@@ -48,21 +48,24 @@ struct _AlmanahSearchDialogPrivate {
GtkListStore *sd_results_store;
GtkTreeSelection *sd_results_selection;
GCancellable *sd_cancellable;
+} AlmanahSearchDialogPrivate;
+
+struct _AlmanahSearchDialog {
+ GtkDialog parent;
+ AlmanahSearchDialogPrivate *priv;
};
-G_DEFINE_TYPE (AlmanahSearchDialog, almanah_search_dialog, GTK_TYPE_DIALOG)
-#define ALMANAH_SEARCH_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_SEARCH_DIALOG, AlmanahSearchDialogPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahSearchDialog, almanah_search_dialog, GTK_TYPE_DIALOG)
static void
almanah_search_dialog_class_init (AlmanahSearchDialogClass *klass)
{
- g_type_class_add_private (klass, sizeof (AlmanahSearchDialogPrivate));
}
static void
almanah_search_dialog_init (AlmanahSearchDialog *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_SEARCH_DIALOG,
AlmanahSearchDialogPrivate);
+ self->priv = almanah_search_dialog_get_instance_private (self);
g_signal_connect (self, "response", G_CALLBACK (sd_response_cb), self);
gtk_window_set_modal (GTK_WINDOW (self), FALSE);
diff --git a/src/search-dialog.h b/src/search-dialog.h
index 255ce61..1848270 100644
--- a/src/search-dialog.h
+++ b/src/search-dialog.h
@@ -25,25 +25,9 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_SEARCH_DIALOG (almanah_search_dialog_get_type ())
-#define ALMANAH_SEARCH_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_SEARCH_DIALOG,
AlmanahSearchDialog))
-#define ALMANAH_SEARCH_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_SEARCH_DIALOG,
AlmanahSearchDialogClass))
-#define ALMANAH_IS_SEARCH_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_SEARCH_DIALOG))
-#define ALMANAH_IS_SEARCH_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_SEARCH_DIALOG))
-#define ALMANAH_SEARCH_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_SEARCH_DIALOG,
AlmanahSearchDialogClass))
+#define ALMANAH_TYPE_SEARCH_DIALOG (almanah_search_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahSearchDialog, almanah_search_dialog, ALMANAH, SEARCH_DIALOG, GtkDialog)
-typedef struct _AlmanahSearchDialogPrivate AlmanahSearchDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- AlmanahSearchDialogPrivate *priv;
-} AlmanahSearchDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} AlmanahSearchDialogClass;
-
-GType almanah_search_dialog_get_type (void);
AlmanahSearchDialog *almanah_search_dialog_new (void);
G_END_DECLS
diff --git a/src/storage-manager.c b/src/storage-manager.c
index 887a0f9..cfe71cf 100644
--- a/src/storage-manager.c
+++ b/src/storage-manager.c
@@ -38,10 +38,15 @@ static void almanah_storage_manager_get_property (GObject *object, guint propert
static void almanah_storage_manager_set_property (GObject *object, guint property_id, const GValue *value,
GParamSpec *pspec);
static gboolean simple_query (AlmanahStorageManager *self, const gchar *query, GError **error, ...);
-struct _AlmanahStorageManagerPrivate {
+typedef struct {
gchar *filename;
sqlite3 *connection;
GSettings *settings;
+} AlmanahStorageManagerPrivate;
+
+struct _AlmanahStorageManager {
+ GObject parent;
+ AlmanahStorageManagerPrivate *priv;
};
enum {
@@ -61,8 +66,7 @@ enum {
static guint storage_manager_signals[LAST_SIGNAL] = { 0, };
-G_DEFINE_TYPE (AlmanahStorageManager, almanah_storage_manager, G_TYPE_OBJECT)
-#define ALMANAH_STORAGE_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_STORAGE_MANAGER, AlmanahStorageManagerPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahStorageManager, almanah_storage_manager, G_TYPE_OBJECT)
GQuark
almanah_storage_manager_error_quark (void)
@@ -75,8 +79,6 @@ almanah_storage_manager_class_init (AlmanahStorageManagerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahStorageManagerPrivate));
-
gobject_class->set_property = almanah_storage_manager_set_property;
gobject_class->get_property = almanah_storage_manager_get_property;
gobject_class->finalize = almanah_storage_manager_finalize;
@@ -134,7 +136,7 @@ almanah_storage_manager_class_init (AlmanahStorageManagerClass *klass)
static void
almanah_storage_manager_init (AlmanahStorageManager *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_STORAGE_MANAGER,
AlmanahStorageManagerPrivate);
+ self->priv = almanah_storage_manager_get_instance_private (self);
self->priv->filename = NULL;
}
@@ -165,7 +167,7 @@ almanah_storage_manager_new (const gchar *filename, GSettings *settings)
static void
almanah_storage_manager_finalize (GObject *object)
{
- AlmanahStorageManagerPrivate *priv = ALMANAH_STORAGE_MANAGER (object)->priv;
+ AlmanahStorageManagerPrivate *priv = almanah_storage_manager_get_instance_private
(ALMANAH_STORAGE_MANAGER (object));
g_free (priv->filename);
@@ -176,7 +178,7 @@ almanah_storage_manager_finalize (GObject *object)
static void
almanah_storage_manager_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
- AlmanahStorageManagerPrivate *priv = ALMANAH_STORAGE_MANAGER (object)->priv;
+ AlmanahStorageManagerPrivate *priv = almanah_storage_manager_get_instance_private
(ALMANAH_STORAGE_MANAGER (object));
switch (property_id) {
case PROP_FILENAME:
@@ -195,7 +197,7 @@ almanah_storage_manager_get_property (GObject *object, guint property_id, GValue
static void
almanah_storage_manager_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec
*pspec)
{
- AlmanahStorageManagerPrivate *priv = ALMANAH_STORAGE_MANAGER (object)->priv;
+ AlmanahStorageManagerPrivate *priv = almanah_storage_manager_get_instance_private
(ALMANAH_STORAGE_MANAGER (object));
switch (property_id) {
case PROP_FILENAME:
diff --git a/src/storage-manager.h b/src/storage-manager.h
index 9a2551a..33afdd5 100644
--- a/src/storage-manager.h
+++ b/src/storage-manager.h
@@ -30,22 +30,7 @@ G_BEGIN_DECLS
#define ALMANAH_TYPE_STORAGE_MANAGER (almanah_storage_manager_get_type ())
#define ALMANAH_STORAGE_MANAGER_ERROR (almanah_storage_manager_error_quark ())
-#define ALMANAH_STORAGE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_STORAGE_MANAGER, AlmanahStorageManager))
-#define ALMANAH_STORAGE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_STORAGE_MANAGER,
AlmanahStorageManagerClass))
-#define ALMANAH_IS_STORAGE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_STORAGE_MANAGER))
-#define ALMANAH_IS_STORAGE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_STORAGE_MANAGER))
-#define ALMANAH_STORAGE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_STORAGE_MANAGER, AlmanahStorageManagerClass))
-
-typedef struct _AlmanahStorageManagerPrivate AlmanahStorageManagerPrivate;
-
-typedef struct {
- GObject parent;
- AlmanahStorageManagerPrivate *priv;
-} AlmanahStorageManager;
-
-typedef struct {
- GObjectClass parent;
-} AlmanahStorageManagerClass;
+G_DECLARE_FINAL_TYPE (AlmanahStorageManager, almanah_storage_manager, ALMANAH, STORAGE_MANAGER, GObject)
typedef enum {
ALMANAH_STORAGE_MANAGER_ERROR_UNSUPPORTED,
@@ -67,7 +52,6 @@ typedef struct {
typedef void (*AlmanahStorageManagerSearchCallback) (AlmanahStorageManager *storage_manager, AlmanahEntry
*entry, gpointer user_data);
-GType almanah_storage_manager_get_type (void);
GQuark almanah_storage_manager_error_quark (void);
AlmanahStorageManager *almanah_storage_manager_new (const gchar *filename, GSettings *settings)
G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
diff --git a/src/uri-entry-dialog.c b/src/uri-entry-dialog.c
index a8d6f78..3948463 100644
--- a/src/uri-entry-dialog.c
+++ b/src/uri-entry-dialog.c
@@ -31,26 +31,28 @@ static void almanah_uri_entry_dialog_set_property (GObject *object, guint proper
/* GtkBuilder callbacks */
G_MODULE_EXPORT void ued_uri_entry_notify_text_cb (GObject *gobject, GParamSpec *pspec,
AlmanahUriEntryDialog *self);
-struct _AlmanahUriEntryDialogPrivate {
+typedef struct {
gchar *uri;
GtkWidget *ok_button;
GtkEntry *uri_entry;
+} AlmanahUriEntryDialogPrivate;
+
+struct _AlmanahUriEntryDialog {
+ GtkDialog parent;
+ AlmanahUriEntryDialogPrivate *priv;
};
enum {
PROP_URI = 1
};
-G_DEFINE_TYPE (AlmanahUriEntryDialog, almanah_uri_entry_dialog, GTK_TYPE_DIALOG)
-#define ALMANAH_URI_ENTRY_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
ALMANAH_TYPE_URI_ENTRY_DIALOG, AlmanahUriEntryDialogPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahUriEntryDialog, almanah_uri_entry_dialog, GTK_TYPE_DIALOG)
static void
almanah_uri_entry_dialog_class_init (AlmanahUriEntryDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahUriEntryDialogPrivate));
-
gobject_class->set_property = almanah_uri_entry_dialog_set_property;
gobject_class->get_property = almanah_uri_entry_dialog_get_property;
@@ -64,7 +66,7 @@ almanah_uri_entry_dialog_class_init (AlmanahUriEntryDialogClass *klass)
static void
almanah_uri_entry_dialog_init (AlmanahUriEntryDialog *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_URI_ENTRY_DIALOG,
AlmanahUriEntryDialogPrivate);
+ self->priv = almanah_uri_entry_dialog_get_instance_private (self);
g_signal_connect (self, "response", (GCallback) gtk_widget_hide, self);
gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
diff --git a/src/uri-entry-dialog.h b/src/uri-entry-dialog.h
index c59165b..0cd1216 100644
--- a/src/uri-entry-dialog.h
+++ b/src/uri-entry-dialog.h
@@ -26,25 +26,8 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_URI_ENTRY_DIALOG (almanah_uri_entry_dialog_get_type ())
-#define ALMANAH_URI_ENTRY_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_URI_ENTRY_DIALOG, AlmanahUriEntryDialog))
-#define ALMANAH_URI_ENTRY_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_URI_ENTRY_DIALOG,
AlmanahUriEntryDialogClass))
-#define ALMANAH_IS_URI_ENTRY_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_URI_ENTRY_DIALOG))
-#define ALMANAH_IS_URI_ENTRY_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_URI_ENTRY_DIALOG))
-#define ALMANAH_URI_ENTRY_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_URI_ENTRY_DIALOG, AlmanahUriEntryDialogClass))
-
-typedef struct _AlmanahUriEntryDialogPrivate AlmanahUriEntryDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- AlmanahUriEntryDialogPrivate *priv;
-} AlmanahUriEntryDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} AlmanahUriEntryDialogClass;
-
-GType almanah_uri_entry_dialog_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_URI_ENTRY_DIALOG (almanah_uri_entry_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahUriEntryDialog, almanah_uri_entry_dialog, ALMANAH, URI_ENTRY_DIALOG, GtkDialog)
AlmanahUriEntryDialog *almanah_uri_entry_dialog_new (void) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
gboolean almanah_uri_entry_dialog_run (AlmanahUriEntryDialog *self);
diff --git a/src/widgets/calendar-button.c b/src/widgets/calendar-button.c
index f45d488..803e117 100644
--- a/src/widgets/calendar-button.c
+++ b/src/widgets/calendar-button.c
@@ -45,14 +45,14 @@ enum {
static guint calendar_button_signals[LAST_SIGNAL] = { 0 };
-struct _AlmanahCalendarButtonPrivate {
+typedef struct {
GtkWidget *dock;
guchar user_event;
AlmanahCalendar *calendar;
GtkWidget *today_button;
GtkWidget *select_date_button;
AlmanahStorageManager *storage_manager;
-};
+} AlmanahCalendarButtonPrivate;
static void almanah_calendar_button_get_property (GObject *object, guint property_id, GValue *value,
GParamSpec *pspec);
static void almanah_calendar_button_set_property (GObject *object, guint property_id, const GValue *value,
GParamSpec *pspec);
@@ -70,7 +70,7 @@ static gboolean almanah_calendar_button_select_date_press_cb (GtkWidget *widge
static void dock_position_func (AlmanahCalendarButton *self, gint *x, gint *y);
-G_DEFINE_TYPE (AlmanahCalendarButton, almanah_calendar_button, GTK_TYPE_TOGGLE_BUTTON)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahCalendarButton, almanah_calendar_button, GTK_TYPE_TOGGLE_BUTTON)
static void
almanah_calendar_button_class_init (AlmanahCalendarButtonClass *klass)
@@ -78,8 +78,6 @@ almanah_calendar_button_class_init (AlmanahCalendarButtonClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahCalendarButtonPrivate));
-
gobject_class->get_property = almanah_calendar_button_get_property;
gobject_class->set_property = almanah_calendar_button_set_property;
gobject_class->finalize = almanah_calendar_button_finalize;
@@ -131,8 +129,8 @@ almanah_calendar_button_init (AlmanahCalendarButton *self)
NULL
};
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_BUTTON,
AlmanahCalendarButtonPrivate);
- self->priv->user_event = FIRST_EVENT;
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+ priv->user_event = FIRST_EVENT;
gtk_button_set_focus_on_click (GTK_BUTTON (self), TRUE);
@@ -147,33 +145,33 @@ almanah_calendar_button_init (AlmanahCalendarButton *self)
}
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
- self->priv->dock = GTK_WIDGET (gtk_builder_get_object (builder, "almanah_calendar_window"));
- if (self->priv->dock == NULL) {
+ priv->dock = GTK_WIDGET (gtk_builder_get_object (builder, "almanah_calendar_window"));
+ if (priv->dock == NULL) {
g_warning (_("Can't load calendar window object from UI file"));
g_object_unref (builder);
return;
}
- gtk_popover_set_relative_to (GTK_POPOVER (self->priv->dock), GTK_WIDGET (self));
+ gtk_popover_set_relative_to (GTK_POPOVER (priv->dock), GTK_WIDGET (self));
- g_signal_connect (self->priv->dock, "hide", G_CALLBACK (almanah_calendar_button_dock_closed), self);
+ g_signal_connect (priv->dock, "hide", G_CALLBACK (almanah_calendar_button_dock_closed), self);
/* The calendar widget */
- self->priv->calendar = ALMANAH_CALENDAR (gtk_builder_get_object (builder, "almanah_cw_calendar"));
- g_object_ref (self->priv->calendar);
- g_signal_connect (self->priv->calendar, "day-selected", G_CALLBACK
(almanah_calendar_button_day_selected_cb), self);
- g_signal_connect (self->priv->calendar, "month_changed", G_CALLBACK
(almanah_calendar_button_month_changed_cb), self);
+ priv->calendar = ALMANAH_CALENDAR (gtk_builder_get_object (builder, "almanah_cw_calendar"));
+ g_object_ref (priv->calendar);
+ g_signal_connect (priv->calendar, "day-selected", G_CALLBACK
(almanah_calendar_button_day_selected_cb), self);
+ g_signal_connect (priv->calendar, "month_changed", G_CALLBACK
(almanah_calendar_button_month_changed_cb), self);
/* Today button */
- self->priv->today_button = GTK_WIDGET (gtk_builder_get_object (builder, "almanah_cw_today_button"));
- g_signal_connect (self->priv->today_button, "clicked", G_CALLBACK
(almanah_calendar_button_today_clicked_cb), self);
- g_signal_connect (self->priv->today_button, "button-press-event", G_CALLBACK
(almanah_calendar_button_today_press_cb), self);
+ priv->today_button = GTK_WIDGET (gtk_builder_get_object (builder, "almanah_cw_today_button"));
+ g_signal_connect (priv->today_button, "clicked", G_CALLBACK
(almanah_calendar_button_today_clicked_cb), self);
+ g_signal_connect (priv->today_button, "button-press-event", G_CALLBACK
(almanah_calendar_button_today_press_cb), self);
/* Select a day button */
/* @TODO: No the button press event, instead the 'activate' action funcion (if not, the select day
window dosn't showed... */
- self->priv->select_date_button = GTK_WIDGET (gtk_builder_get_object (builder,
"almanah_cw_select_date_button"));
- g_signal_connect (self->priv->select_date_button, "clicked", G_CALLBACK
(almanah_calendar_button_select_date_clicked_cb), self);
- g_signal_connect (self->priv->select_date_button, "button-press-event", G_CALLBACK
(almanah_calendar_button_select_date_press_cb), self);
+ priv->select_date_button = GTK_WIDGET (gtk_builder_get_object (builder,
"almanah_cw_select_date_button"));
+ g_signal_connect (priv->select_date_button, "clicked", G_CALLBACK
(almanah_calendar_button_select_date_clicked_cb), self);
+ g_signal_connect (priv->select_date_button, "button-press-event", G_CALLBACK
(almanah_calendar_button_select_date_press_cb), self);
g_object_unref (builder);
}
@@ -181,7 +179,7 @@ almanah_calendar_button_init (AlmanahCalendarButton *self)
static void
almanah_calendar_button_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
- AlmanahCalendarButtonPrivate *priv = ALMANAH_CALENDAR_BUTTON (object)->priv;
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private
(ALMANAH_CALENDAR_BUTTON (object));
switch (property_id) {
case PROP_STORAGE_MANAGER:
@@ -211,7 +209,7 @@ almanah_calendar_button_set_property (GObject *object, guint property_id, const
static void
almanah_calendar_button_finalize (GObject *object)
{
- AlmanahCalendarButtonPrivate *priv = ALMANAH_CALENDAR_BUTTON (object)->priv;
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private
(ALMANAH_CALENDAR_BUTTON (object));
g_clear_object (&priv->calendar);
g_clear_object (&priv->storage_manager);
@@ -223,8 +221,10 @@ almanah_calendar_button_finalize (GObject *object)
static void
almanah_calendar_button_dock_closed (GtkWidget *dock, AlmanahCalendarButton *self)
{
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private
(ALMANAH_CALENDAR_BUTTON (self));
+
/* Reset the calendar user event and toggle off the button */
- ALMANAH_CALENDAR_BUTTON (self)->priv->user_event = NONE_EVENT;
+ priv->user_event = NONE_EVENT;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self), FALSE);
}
@@ -232,24 +232,28 @@ static void
almanah_calendar_button_toggled (GtkToggleButton *togglebutton)
{
AlmanahCalendarButton *self;
+ AlmanahCalendarButtonPrivate *priv;
self = ALMANAH_CALENDAR_BUTTON (togglebutton);
+ priv = almanah_calendar_button_get_instance_private (self);
if (gtk_toggle_button_get_active (togglebutton)) {
/* Show the dock */
- gtk_widget_show_all (GTK_WIDGET (self->priv->dock));
+ gtk_widget_show_all (GTK_WIDGET (priv->dock));
}
}
static void
almanah_calendar_button_day_selected_cb (GtkCalendar *calendar, AlmanahCalendarButton *self)
{
- if (self->priv->user_event < DAY_EVENT) {
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ if (priv->user_event < DAY_EVENT) {
/* Only hide the dock window when the user has clicked in a calendar day */
- self->priv->user_event = DAY_EVENT;
- gtk_widget_hide (GTK_WIDGET (self->priv->dock));
+ priv->user_event = DAY_EVENT;
+ gtk_widget_hide (GTK_WIDGET (priv->dock));
}
- self->priv->user_event = NONE_EVENT;
+ priv->user_event = NONE_EVENT;
/* Emmits the signal at the end */
g_signal_emit (self, calendar_button_signals[DAY_SELECTED_SIGNAL], 0);
@@ -258,18 +262,22 @@ almanah_calendar_button_day_selected_cb (GtkCalendar *calendar, AlmanahCalendarB
static void
almanah_calendar_button_month_changed_cb (GtkCalendar *calendar, AlmanahCalendarButton *self)
{
- if (self->priv->user_event != TODAY_EVENT) {
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ if (priv->user_event != TODAY_EVENT) {
/* Save the month changed event just if the user hasn't click the today button
* beacuse the dock window should not hide in this case */
- self->priv->user_event = MONTH_EVENT;
+ priv->user_event = MONTH_EVENT;
}
}
static gboolean
almanah_calendar_button_today_press_cb (GtkWidget *widget, GdkEvent *event, AlmanahCalendarButton *self)
{
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
/* Save this event to not hide the dock window */
- self->priv->user_event = TODAY_EVENT;
+ priv->user_event = TODAY_EVENT;
return FALSE;
}
@@ -285,7 +293,9 @@ almanah_calendar_button_today_clicked_cb (__attribute__ ((unused)) GtkButton *bu
static gboolean
almanah_calendar_button_select_date_press_cb (GtkWidget *widget, GdkEvent *event, AlmanahCalendarButton
*self)
{
- self->priv->user_event = NONE_EVENT;
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ priv->user_event = NONE_EVENT;
return FALSE;
}
@@ -311,12 +321,14 @@ almanah_calendar_button_set_storage_manager (AlmanahCalendarButton *self, Almana
g_return_if_fail (ALMANAH_IS_CALENDAR_BUTTON (self));
g_return_if_fail (ALMANAH_IS_STORAGE_MANAGER (storage_manager));
- g_clear_object (&self->priv->storage_manager);
- self->priv->storage_manager = storage_manager;
- g_object_ref (self->priv->storage_manager);
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ g_clear_object (&priv->storage_manager);
+ priv->storage_manager = storage_manager;
+ g_object_ref (priv->storage_manager);
- if (self->priv->calendar != NULL && ALMANAH_IS_CALENDAR (self->priv->calendar)) {
- almanah_calendar_set_storage_manager (self->priv->calendar, self->priv->storage_manager);
+ if (priv->calendar != NULL && ALMANAH_IS_CALENDAR (priv->calendar)) {
+ almanah_calendar_set_storage_manager (priv->calendar, priv->storage_manager);
}
}
@@ -326,7 +338,9 @@ almanah_calendar_button_select_date (AlmanahCalendarButton *self, GDate *date)
g_return_if_fail (ALMANAH_IS_CALENDAR_BUTTON (self));
g_return_if_fail (date != NULL);
- almanah_calendar_select_date (self->priv->calendar, date);
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ almanah_calendar_select_date (priv->calendar, date);
}
void
@@ -335,7 +349,9 @@ almanah_calendar_button_get_date (AlmanahCalendarButton *self, GDate *date)
g_return_if_fail (ALMANAH_IS_CALENDAR_BUTTON (self));
g_return_if_fail (date != NULL);
- almanah_calendar_get_date (self->priv->calendar, date);
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ almanah_calendar_get_date (priv->calendar, date);
}
void
@@ -343,7 +359,9 @@ almanah_calendar_button_popdown (AlmanahCalendarButton *self)
{
g_return_if_fail (ALMANAH_IS_CALENDAR_BUTTON (self));
- gtk_widget_hide (GTK_WIDGET (self->priv->dock));
+ AlmanahCalendarButtonPrivate *priv = almanah_calendar_button_get_instance_private (self);
+
+ gtk_widget_hide (GTK_WIDGET (priv->dock));
}
void
diff --git a/src/widgets/calendar-button.h b/src/widgets/calendar-button.h
index b92cf9c..3ff2956 100644
--- a/src/widgets/calendar-button.h
+++ b/src/widgets/calendar-button.h
@@ -29,27 +29,15 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_CALENDAR_BUTTON (almanah_calendar_button_get_type ())
-#define ALMANAH_CALENDAR_BUTTON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
ALMANAH_TYPE_CALENDAR_BUTTON, AlmanahCalendarButton))
-#define ALMANAH_CALENDAR_BUTTON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_CALENDAR_BUTTON,
AlmanahCalendarButtonClass))
-#define ALMANAH_IS_CALENDAR_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
ALMANAH_TYPE_CALENDAR_BUTTON))
-#define ALMANAH_IS_CALENDAR_BUTTON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_CALENDAR_BUTTON))
-#define ALMANAH_CALENDAR_BUTTON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
ALMANAH_TYPE_CALENDAR_BUTTON, AlmanahCalendarButtonClass))
+#define ALMANAH_TYPE_CALENDAR_BUTTON (almanah_calendar_button_get_type ())
+G_DECLARE_DERIVABLE_TYPE (AlmanahCalendarButton, almanah_calendar_button, ALMANAH, CALENDAR_BUTTON,
GtkToggleButton)
-typedef struct _AlmanahCalendarButtonPrivate AlmanahCalendarButtonPrivate;
-
-typedef struct {
- GtkToggleButton parent;
- AlmanahCalendarButtonPrivate *priv;
-} AlmanahCalendarButton;
-
-typedef struct {
+struct _AlmanahCalendarButtonClass {
GtkToggleButtonClass parent;
void (* day_selected) (AlmanahCalendarButton *self);
void (* select_date_clicked) (AlmanahCalendarButton *self);
-} AlmanahCalendarButtonClass;
+};
-GType almanah_calendar_button_get_type (void) G_GNUC_CONST;
GtkWidget *almanah_calendar_button_new (AlmanahStorageManager *storage_manager) G_GNUC_MALLOC
G_GNUC_WARN_UNUSED_RESULT;
void almanah_calendar_button_set_storage_manager (AlmanahCalendarButton *self, AlmanahStorageManager
*storage_manager);
void almanah_calendar_button_select_date (AlmanahCalendarButton *self, GDate *date);
diff --git a/src/widgets/calendar.c b/src/widgets/calendar.c
index 1696f36..07dc57a 100644
--- a/src/widgets/calendar.c
+++ b/src/widgets/calendar.c
@@ -32,19 +32,24 @@ static gchar *almanah_calendar_detail_func (GtkCalendar *calendar, guint year, g
static void entry_added_cb (AlmanahStorageManager *storage_manager, AlmanahEntry *entry, AlmanahCalendar
*calendar);
static void entry_removed_cb (AlmanahStorageManager *storage_manager, GDate *date, AlmanahCalendar
*calendar);
-struct _AlmanahCalendarPrivate {
+typedef struct {
AlmanahStorageManager *storage_manager;
gulong entry_added_signal;
gulong entry_removed_signal;
gboolean *important_days;
+} AlmanahCalendarPrivate;
+
+struct _AlmanahCalendar {
+ GtkCalendar parent;
+ AlmanahCalendarPrivate *priv;
};
enum {
PROP_STORAGE_MANAGER = 1,
};
-G_DEFINE_TYPE (AlmanahCalendar, almanah_calendar, GTK_TYPE_CALENDAR)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahCalendar, almanah_calendar, GTK_TYPE_CALENDAR)
static void
almanah_calendar_class_init (AlmanahCalendarClass *klass)
@@ -52,8 +57,6 @@ almanah_calendar_class_init (AlmanahCalendarClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkCalendarClass *calendar_class = GTK_CALENDAR_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahCalendarPrivate));
-
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
gobject_class->dispose = dispose;
@@ -71,7 +74,7 @@ almanah_calendar_class_init (AlmanahCalendarClass *klass)
static void
almanah_calendar_init (AlmanahCalendar *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR, AlmanahCalendarPrivate);
+ self->priv = almanah_calendar_get_instance_private (self);
gtk_calendar_set_detail_func (GTK_CALENDAR (self), almanah_calendar_detail_func, NULL, NULL);
}
diff --git a/src/widgets/calendar.h b/src/widgets/calendar.h
index a281b84..6c98984 100644
--- a/src/widgets/calendar.h
+++ b/src/widgets/calendar.h
@@ -28,25 +28,8 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_CALENDAR (almanah_calendar_get_type ())
-#define ALMANAH_CALENDAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_CALENDAR,
AlmanahCalendar))
-#define ALMANAH_CALENDAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_CALENDAR,
AlmanahCalendarClass))
-#define ALMANAH_IS_CALENDAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_CALENDAR))
-#define ALMANAH_IS_CALENDAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_CALENDAR))
-#define ALMANAH_CALENDAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_CALENDAR,
AlmanahCalendarClass))
-
-typedef struct _AlmanahCalendarPrivate AlmanahCalendarPrivate;
-
-typedef struct {
- GtkCalendar parent;
- AlmanahCalendarPrivate *priv;
-} AlmanahCalendar;
-
-typedef struct {
- GtkCalendarClass parent;
-} AlmanahCalendarClass;
-
-GType almanah_calendar_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_CALENDAR (almanah_calendar_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahCalendar, almanah_calendar, ALMANAH, CALENDAR, GtkCalendar)
GtkWidget *almanah_calendar_new (AlmanahStorageManager *storage_manager) G_GNUC_MALLOC
G_GNUC_WARN_UNUSED_RESULT;
diff --git a/src/widgets/eggwrapbox.c b/src/widgets/eggwrapbox.c
index 11d6964..9f64d4e 100644
--- a/src/widgets/eggwrapbox.c
+++ b/src/widgets/eggwrapbox.c
@@ -67,8 +67,7 @@ enum
CHILD_PROP_PACKING
};
-struct _EggWrapBoxPrivate
-{
+typedef struct {
GtkOrientation orientation;
EggWrapAllocationMode mode;
EggWrapBoxSpreading horizontal_spreading;
@@ -81,7 +80,7 @@ struct _EggWrapBoxPrivate
guint16 natural_line_children;
GList *children;
-};
+} EggWrapBoxPrivate;
struct _EggWrapBoxChild
{
@@ -145,18 +144,25 @@ static void egg_wrap_box_get_preferred_width_for_height (GtkWidget *bo
G_DEFINE_TYPE_WITH_CODE (EggWrapBox, egg_wrap_box, GTK_TYPE_CONTAINER,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL) \
+ G_ADD_PRIVATE (EggWrapBox))
+
+guint16 egg_wrap_box_get_orientation_spreading (EggWrapBox *box) {
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private(box);
-#define ORIENTATION_SPREADING(box) \
- (((EggWrapBox *)(box))->priv->orientation == GTK_ORIENTATION_HORIZONTAL ? \
- ((EggWrapBox *)(box))->priv->horizontal_spreading : \
- ((EggWrapBox *)(box))->priv->vertical_spreading)
+ return priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
+ priv->horizontal_spreading :
+ priv->vertical_spreading;
+}
+
+guint16 egg_wrap_box_get_opposing_orientation_spreading (EggWrapBox *box) {
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private(box);
-#define OPPOSING_ORIENTATION_SPREADING(box) \
- (((EggWrapBox *)(box))->priv->orientation == GTK_ORIENTATION_HORIZONTAL ? \
- ((EggWrapBox *)(box))->priv->vertical_spreading : \
- ((EggWrapBox *)(box))->priv->horizontal_spreading)
+ return priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
+ priv->vertical_spreading :
+ priv->horizontal_spreading;
+}
@@ -318,17 +324,12 @@ egg_wrap_box_class_init (EggWrapBoxClass *class)
P_("The packing options to use for this child"),
EGG_TYPE_WRAP_BOX_PACKING, 0,
GTK_PARAM_READWRITE));
-
- g_type_class_add_private (class, sizeof (EggWrapBoxPrivate));
}
static void
egg_wrap_box_init (EggWrapBox *box)
{
- EggWrapBoxPrivate *priv;
-
- box->priv = priv =
- G_TYPE_INSTANCE_GET_PRIVATE (box, EGG_TYPE_WRAP_BOX, EggWrapBoxPrivate);
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
priv->mode = EGG_WRAP_ALLOCATE_FREE;
@@ -351,7 +352,7 @@ egg_wrap_box_get_property (GObject *object,
GParamSpec *pspec)
{
EggWrapBox *box = EGG_WRAP_BOX (object);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
switch (prop_id)
{
@@ -392,7 +393,7 @@ egg_wrap_box_set_property (GObject *object,
GParamSpec *pspec)
{
EggWrapBox *box = EGG_WRAP_BOX (object);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
switch (prop_id)
{
@@ -436,7 +437,7 @@ egg_wrap_box_set_property (GObject *object,
static gint
get_visible_children (EggWrapBox *box)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list;
gint i = 0;
@@ -488,7 +489,7 @@ get_average_item_size (EggWrapBox *box,
gint *min_size,
gint *nat_size)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list;
gint max_min_size = 0;
gint max_nat_size = 0;
@@ -527,7 +528,7 @@ get_largest_size_for_opposing_orientation (EggWrapBox *box,
gint *min_item_size,
gint *nat_item_size)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list;
gint max_min_size = 0;
gint max_nat_size = 0;
@@ -590,7 +591,7 @@ get_largest_size_for_line_in_opposing_orientation (EggWrapBox *box,
/* Distribute the extra pixels to the first children in the line
* (could be fancier and spread them out more evenly) */
this_item_size = item_sizes[i].minimum_size;
- if (extra_pixels > 0 && ORIENTATION_SPREADING (box) == EGG_WRAP_BOX_SPREAD_EXPAND)
+ if (extra_pixels > 0 && egg_wrap_box_get_orientation_spreading (box) == EGG_WRAP_BOX_SPREAD_EXPAND)
{
this_item_size++;
extra_pixels--;
@@ -636,7 +637,7 @@ get_largest_size_for_free_line_in_opposing_orientation (EggWrapBox *box,
gint *extra_pixels,
GArray **ret_array)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GtkRequestedSize *sizes;
GList *list;
GArray *array;
@@ -719,7 +720,7 @@ get_largest_size_for_free_line_in_opposing_orientation (EggWrapBox *box,
*extra_pixels = size;
/* Cut out any expand space if we're not distributing any */
- if (ORIENTATION_SPREADING (box) != EGG_WRAP_BOX_SPREAD_EXPAND)
+ if (egg_wrap_box_get_orientation_spreading (box) != EGG_WRAP_BOX_SPREAD_EXPAND)
size = 0;
/* Count how many children are going to expand... */
@@ -800,7 +801,7 @@ allocate_child (EggWrapBox *box,
gint item_size,
gint line_size)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GtkAllocation widget_allocation;
GtkAllocation child_allocation;
@@ -833,7 +834,7 @@ gather_aligned_item_requests (EggWrapBox *box,
gint n_children,
GtkRequestedSize *item_sizes)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list;
gint i;
gint extra_items, natural_line_size = 0;
@@ -859,7 +860,7 @@ gather_aligned_item_requests (EggWrapBox *box,
/* Get the index and push it over for the last line when spreading to the end */
position = i % line_length;
- if (ORIENTATION_SPREADING (box) == EGG_WRAP_BOX_SPREAD_END && i >= n_children - extra_items)
+ if (egg_wrap_box_get_orientation_spreading (box) == EGG_WRAP_BOX_SPREAD_END && i >= n_children -
extra_items)
position += line_length - extra_items;
/* Round up the size of every column/row */
@@ -929,7 +930,7 @@ egg_wrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
EggWrapBox *box = EGG_WRAP_BOX (widget);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
gint avail_size, avail_other_size, min_items, item_spacing, line_spacing;
EggWrapBoxSpreading item_spreading;
EggWrapBoxSpreading line_spreading;
@@ -953,8 +954,8 @@ egg_wrap_box_size_allocate (GtkWidget *widget,
line_spacing = priv->horizontal_spacing;
}
- item_spreading = ORIENTATION_SPREADING (box);
- line_spreading = OPPOSING_ORIENTATION_SPREADING (box);
+ item_spreading = egg_wrap_box_get_orientation_spreading (box);
+ line_spreading = egg_wrap_box_get_opposing_orientation_spreading (box);
/*********************************************************
@@ -1428,7 +1429,7 @@ egg_wrap_box_remove (GtkContainer *container,
GtkWidget *widget)
{
EggWrapBox *box = EGG_WRAP_BOX (container);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list;
list = g_list_find_custom (priv->children, widget,
@@ -1456,7 +1457,7 @@ egg_wrap_box_forall (GtkContainer *container,
gpointer callback_data)
{
EggWrapBox *box = EGG_WRAP_BOX (container);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
EggWrapBoxChild *child;
GList *list;
@@ -1485,7 +1486,7 @@ egg_wrap_box_set_child_property (GtkContainer *container,
GParamSpec *pspec)
{
EggWrapBox *box = EGG_WRAP_BOX (container);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
EggWrapBoxChild *child;
GList *list;
@@ -1518,7 +1519,7 @@ egg_wrap_box_get_child_property (GtkContainer *container,
GParamSpec *pspec)
{
EggWrapBox *box = EGG_WRAP_BOX (container);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
EggWrapBoxChild *child;
GList *list;
@@ -1548,7 +1549,7 @@ static GtkSizeRequestMode
egg_wrap_box_get_request_mode (GtkWidget *widget)
{
EggWrapBox *box = EGG_WRAP_BOX (widget);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
return (priv->orientation == GTK_ORIENTATION_HORIZONTAL) ?
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
@@ -1563,7 +1564,7 @@ get_largest_line_length (EggWrapBox *box,
gint *min_size,
gint *nat_size)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list, *l;
gint max_min_size = 0;
gint max_nat_size = 0;
@@ -1626,7 +1627,7 @@ get_largest_aligned_line_length (EggWrapBox *box,
gint *min_size,
gint *nat_size)
{
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
GList *list;
gint max_min_size = 0;
gint max_nat_size = 0;
@@ -1692,7 +1693,7 @@ egg_wrap_box_get_preferred_width (GtkWidget *widget,
gint *natural_size)
{
EggWrapBox *box = EGG_WRAP_BOX (widget);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
gint min_item_width, nat_item_width;
gint min_items, nat_items;
gint min_width, nat_width;
@@ -1783,7 +1784,7 @@ egg_wrap_box_get_preferred_height (GtkWidget *widget,
gint *natural_size)
{
EggWrapBox *box = EGG_WRAP_BOX (widget);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
gint min_item_height, nat_item_height;
gint min_items, nat_items;
gint min_height, nat_height;
@@ -1875,7 +1876,7 @@ egg_wrap_box_get_preferred_height_for_width (GtkWidget *widget,
gint *natural_height)
{
EggWrapBox *box = EGG_WRAP_BOX (widget);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
gint min_item_width, nat_item_width;
gint min_items;
gint min_height, nat_height;
@@ -2051,7 +2052,7 @@ egg_wrap_box_get_preferred_width_for_height (GtkWidget *widget,
gint *natural_width)
{
EggWrapBox *box = EGG_WRAP_BOX (widget);
- EggWrapBoxPrivate *priv = box->priv;
+ EggWrapBoxPrivate *priv = egg_wrap_box_get_instance_private (box);
gint min_item_height, nat_item_height;
gint min_items;
gint min_width, nat_width;
@@ -2266,7 +2267,7 @@ egg_wrap_box_set_allocation_mode (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->mode != mode)
{
@@ -2289,9 +2290,13 @@ egg_wrap_box_set_allocation_mode (EggWrapBox *box,
EggWrapAllocationMode
egg_wrap_box_get_allocation_mode (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->mode;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->mode;
}
@@ -2310,7 +2315,7 @@ egg_wrap_box_set_horizontal_spreading (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->horizontal_spreading != spreading)
{
@@ -2333,9 +2338,13 @@ egg_wrap_box_set_horizontal_spreading (EggWrapBox *box,
EggWrapBoxSpreading
egg_wrap_box_get_horizontal_spreading (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->horizontal_spreading;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->horizontal_spreading;
}
@@ -2354,7 +2363,7 @@ egg_wrap_box_set_vertical_spreading (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->vertical_spreading != spreading)
{
@@ -2377,9 +2386,13 @@ egg_wrap_box_set_vertical_spreading (EggWrapBox *box,
EggWrapBoxSpreading
egg_wrap_box_get_vertical_spreading (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->vertical_spreading;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->vertical_spreading;
}
@@ -2398,7 +2411,7 @@ egg_wrap_box_set_vertical_spacing (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->vertical_spacing != spacing)
{
@@ -2421,9 +2434,13 @@ egg_wrap_box_set_vertical_spacing (EggWrapBox *box,
guint
egg_wrap_box_get_vertical_spacing (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->vertical_spacing;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->vertical_spacing;
}
/**
@@ -2441,7 +2458,7 @@ egg_wrap_box_set_horizontal_spacing (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->horizontal_spacing != spacing)
{
@@ -2464,9 +2481,13 @@ egg_wrap_box_set_horizontal_spacing (EggWrapBox *box,
guint
egg_wrap_box_get_horizontal_spacing (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->horizontal_spacing;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->horizontal_spacing;
}
/**
@@ -2485,7 +2506,7 @@ egg_wrap_box_set_minimum_line_children (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->minimum_line_children != n_children)
{
@@ -2508,9 +2529,13 @@ egg_wrap_box_set_minimum_line_children (EggWrapBox *box,
guint
egg_wrap_box_get_minimum_line_children (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->minimum_line_children;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->minimum_line_children;
}
/**
@@ -2533,7 +2558,7 @@ egg_wrap_box_set_natural_line_children (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
if (priv->natural_line_children != n_children)
{
@@ -2556,9 +2581,13 @@ egg_wrap_box_set_natural_line_children (EggWrapBox *box,
guint
egg_wrap_box_get_natural_line_children (EggWrapBox *box)
{
+ EggWrapBoxPrivate *priv;
+
g_return_val_if_fail (EGG_IS_WRAP_BOX (box), FALSE);
- return box->priv->natural_line_children;
+ priv = egg_wrap_box_get_instance_private (box);
+
+ return priv->natural_line_children;
}
@@ -2585,7 +2614,7 @@ egg_wrap_box_insert_child (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
g_return_if_fail (GTK_IS_WIDGET (widget));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
list = g_list_find_custom (priv->children, widget,
(GCompareFunc)find_child_in_list);
@@ -2620,7 +2649,7 @@ egg_wrap_box_reorder_child (EggWrapBox *box,
g_return_if_fail (EGG_IS_WRAP_BOX (box));
g_return_if_fail (GTK_IS_WIDGET (widget));
- priv = box->priv;
+ priv = egg_wrap_box_get_instance_private (box);
list = g_list_find_custom (priv->children, widget,
(GCompareFunc)find_child_in_list);
diff --git a/src/widgets/eggwrapbox.h b/src/widgets/eggwrapbox.h
index 74b7cda..aa61998 100644
--- a/src/widgets/eggwrapbox.h
+++ b/src/widgets/eggwrapbox.h
@@ -27,16 +27,7 @@ G_BEGIN_DECLS
#define EGG_TYPE_WRAP_BOX (egg_wrap_box_get_type ())
-#define EGG_WRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_WRAP_BOX,
EggWrapBox))
-#define EGG_WRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_WRAP_BOX,
EggWrapBoxClass))
-#define EGG_IS_WRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_WRAP_BOX))
-#define EGG_IS_WRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_WRAP_BOX))
-#define EGG_WRAP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_WRAP_BOX,
EggWrapBoxClass))
-
-typedef struct _EggWrapBox EggWrapBox;
-typedef struct _EggWrapBoxPrivate EggWrapBoxPrivate;
-typedef struct _EggWrapBoxClass EggWrapBoxClass;
-
+G_DECLARE_DERIVABLE_TYPE (EggWrapBox, egg_wrap_box, EGG, WRAP_BOX, GtkContainer)
/**
* EggWrapAllocationMode:
@@ -91,22 +82,11 @@ typedef enum
EGG_WRAP_BOX_V_EXPAND = 1 << 1
} EggWrapBoxPacking;
-
-struct _EggWrapBox
-{
- GtkContainer container;
-
- /*< private >*/
- EggWrapBoxPrivate *priv;
-};
-
struct _EggWrapBoxClass
{
GtkContainerClass parent_class;
};
-GType egg_wrap_box_get_type (void) G_GNUC_CONST;
-
GtkWidget *egg_wrap_box_new (EggWrapAllocationMode mode,
EggWrapBoxSpreading horizontal_spreading,
EggWrapBoxSpreading vertical_spreading,
diff --git a/src/widgets/entry-tags-area.c b/src/widgets/entry-tags-area.c
index 64179e5..0cef498 100644
--- a/src/widgets/entry-tags-area.c
+++ b/src/widgets/entry-tags-area.c
@@ -31,12 +31,17 @@ enum {
PROP_BACK_WIDGET
};
-struct _AlmanahEntryTagsAreaPrivate {
+typedef struct {
AlmanahEntry *entry;
AlmanahStorageManager *storage_manager;
GtkWidget *back_widget;
guint tags_number;
AlmanahTagEntry *tag_entry;
+} AlmanahEntryTagsAreaPrivate;
+
+struct _AlmanahEntryTagsArea {
+ EggWrapBox parent;
+ AlmanahEntryTagsAreaPrivate *priv;
};
static void almanah_entry_tags_area_get_property (GObject *object, guint property_id, GValue *value,
GParamSpec *pspec);
@@ -52,7 +57,7 @@ void tag_entry_activate_cb (GtkEntry *entry, AlmanahEntryTag
void entry_tags_area_remove_foreach_cb (GtkWidget *tag_widget, AlmanahEntryTagsArea *self);
static void tag_remove (AlmanahTag *tag_widget, AlmanahEntryTagsArea *self);
-G_DEFINE_TYPE (AlmanahEntryTagsArea, almanah_entry_tags_area, EGG_TYPE_WRAP_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahEntryTagsArea, almanah_entry_tags_area, EGG_TYPE_WRAP_BOX)
static void
almanah_entry_tags_area_class_init (AlmanahEntryTagsAreaClass *klass)
@@ -60,8 +65,6 @@ almanah_entry_tags_area_class_init (AlmanahEntryTagsAreaClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahEntryTagsAreaPrivate));
-
gobject_class->get_property = almanah_entry_tags_area_get_property;
gobject_class->set_property = almanah_entry_tags_area_set_property;
gobject_class->finalize = almanah_entry_tags_area_finalize;
@@ -90,7 +93,7 @@ almanah_entry_tags_area_class_init (AlmanahEntryTagsAreaClass *klass)
static void
almanah_entry_tags_area_init (AlmanahEntryTagsArea *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_ENTRY_TAGS_AREA,
AlmanahEntryTagsAreaPrivate);
+ self->priv = almanah_entry_tags_area_get_instance_private (self);
/* There is no tags showed right now. */
self->priv->tags_number = 0;
diff --git a/src/widgets/entry-tags-area.h b/src/widgets/entry-tags-area.h
index df8fd0c..af1a617 100644
--- a/src/widgets/entry-tags-area.h
+++ b/src/widgets/entry-tags-area.h
@@ -28,24 +28,8 @@
G_BEGIN_DECLS
#define ALMANAH_TYPE_ENTRY_TAGS_AREA (almanah_entry_tags_area_get_type ())
-#define ALMANAH_ENTRY_TAGS_AREA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_ENTRY_TAGS_AREA,
AlmanahEntryTagsArea))
-#define ALMANAH_ENTRY_TAGS_AREA_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_ENTRY_TAGS_AREA,
AlmanahEntryTagsAreaClass))
-#define ALMANAH_IS_ENTRY_TAGS_AREA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_ENTRY_TAGS_AREA))
-#define ALMANAH_IS_ENTRY_TAGS_AREA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_ENTRY_TAGS_AREA))
-#define ALMANAH_ENTRY_TAGS_AREA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_ENTRY_TAGS_AREA,
AlmanahEntryTagsAreaClass))
+G_DECLARE_FINAL_TYPE (AlmanahEntryTagsArea, almanah_entry_tags_area, ALMANAH, ENTRY_TAGS_AREA, EggWrapBox)
-typedef struct _AlmanahEntryTagsAreaPrivate AlmanahEntryTagsAreaPrivate;
-
-typedef struct {
- EggWrapBox parent;
- AlmanahEntryTagsAreaPrivate *priv;
-} AlmanahEntryTagsArea;
-
-typedef struct {
- EggWrapBoxClass parent;
-} AlmanahEntryTagsAreaClass;
-
-GType almanah_entry_tags_area_get_type (void) G_GNUC_CONST;
void almanah_entry_tags_area_set_entry (AlmanahEntryTagsArea *entry_tags_area, AlmanahEntry *entry);
void almanah_entry_tags_area_set_storage_manager (AlmanahEntryTagsArea *entry_tags_area,
AlmanahStorageManager *storage_manager);
void almanah_entry_tags_area_set_back_widget (AlmanahEntryTagsArea *entry_tags_area, GtkWidget
*back_widget);
diff --git a/src/widgets/hyperlink-tag.c b/src/widgets/hyperlink-tag.c
index 05230bd..72afcbb 100644
--- a/src/widgets/hyperlink-tag.c
+++ b/src/widgets/hyperlink-tag.c
@@ -27,23 +27,26 @@ static void get_property (GObject *object, guint property_id, GValue *value, GPa
static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void finalize (GObject *object);
-struct _AlmanahHyperlinkTagPrivate {
+typedef struct {
gchar *uri;
+} AlmanahHyperlinkTagPrivate;
+
+struct _AlmanahHyperlinkTag {
+ GtkTextTag parent;
+ AlmanahHyperlinkTagPrivate *priv;
};
enum {
PROP_URI = 1
};
-G_DEFINE_TYPE (AlmanahHyperlinkTag, almanah_hyperlink_tag, GTK_TYPE_TEXT_TAG)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahHyperlinkTag, almanah_hyperlink_tag, GTK_TYPE_TEXT_TAG)
static void
almanah_hyperlink_tag_class_init (AlmanahHyperlinkTagClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahHyperlinkTagPrivate));
-
gobject_class->constructed = constructed;
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
@@ -59,7 +62,7 @@ almanah_hyperlink_tag_class_init (AlmanahHyperlinkTagClass *klass)
static void
almanah_hyperlink_tag_init (AlmanahHyperlinkTag *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_HYPERLINK_TAG,
AlmanahHyperlinkTagPrivate);
+ self->priv = almanah_hyperlink_tag_get_instance_private (self);
self->priv->uri = NULL;
}
diff --git a/src/widgets/hyperlink-tag.h b/src/widgets/hyperlink-tag.h
index 1c66e76..d86cf3a 100644
--- a/src/widgets/hyperlink-tag.h
+++ b/src/widgets/hyperlink-tag.h
@@ -26,25 +26,8 @@
G_BEGIN_DECLS
-#define ALMANAH_TYPE_HYPERLINK_TAG (almanah_hyperlink_tag_get_type ())
-#define ALMANAH_HYPERLINK_TAG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_HYPERLINK_TAG,
AlmanahHyperlinkTag))
-#define ALMANAH_HYPERLINK_TAG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_HYPERLINK_TAG,
AlmanahHyperlinkTagClass))
-#define ALMANAH_IS_HYPERLINK_TAG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_HYPERLINK_TAG))
-#define ALMANAH_IS_HYPERLINK_TAG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_HYPERLINK_TAG))
-#define ALMANAH_HYPERLINK_TAG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_HYPERLINK_TAG,
AlmanahHyperlinkTagClass))
-
-typedef struct _AlmanahHyperlinkTagPrivate AlmanahHyperlinkTagPrivate;
-
-typedef struct {
- GtkTextTag parent;
- AlmanahHyperlinkTagPrivate *priv;
-} AlmanahHyperlinkTag;
-
-typedef struct {
- GtkTextTagClass parent;
-} AlmanahHyperlinkTagClass;
-
-GType almanah_hyperlink_tag_get_type (void) G_GNUC_CONST;
+#define ALMANAH_TYPE_HYPERLINK_TAG (almanah_hyperlink_tag_get_type ())
+G_DECLARE_FINAL_TYPE (AlmanahHyperlinkTag, almanah_hyperlink_tag, ALMANAH, HYPERLINK_TAG, GtkTextTag)
AlmanahHyperlinkTag *almanah_hyperlink_tag_new (const gchar *uri) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
diff --git a/src/widgets/tag-accessible.c b/src/widgets/tag-accessible.c
index cda2918..0fa0c15 100644
--- a/src/widgets/tag-accessible.c
+++ b/src/widgets/tag-accessible.c
@@ -22,9 +22,14 @@
#include "tag-accessible.h"
#include "tag.h"
-struct _AlmanahTagAccessiblePrivate
-{
+typedef struct {
gint test;
+} AlmanahTagAccessiblePrivate;
+
+struct _AlmanahTagAccessible {
+ GtkWidgetAccessible parent;
+
+ AlmanahTagAccessiblePrivate *priv;
};
static void almanah_tag_accessible_initialize (AtkObject *obj, gpointer data);
@@ -48,8 +53,6 @@ almanah_tag_accessible_class_init (AlmanahTagAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahTagAccessiblePrivate));
-
class->get_name = almanah_tag_accessible_get_name;
class->initialize = almanah_tag_accessible_initialize;
}
diff --git a/src/widgets/tag-accessible.h b/src/widgets/tag-accessible.h
index 30efc3d..6aa389a 100644
--- a/src/widgets/tag-accessible.h
+++ b/src/widgets/tag-accessible.h
@@ -26,25 +26,7 @@
G_BEGIN_DECLS
#define ALMANAH_TYPE_TAG_ACCESSIBLE (almanah_tag_accessible_get_type ())
-#define ALMANAH_TAG_ACCESSIBLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_TAG_ACCESSIBLE,
AlmanahTagAccessible))
-#define ALMANAH_TAG_ACCESSIBLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_TAG_ACCESSIBLE,
AlmanahTagAccessibleClass))
-#define ALMANAH_IS_TAG_ACCESSIBLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_TAG_ACCESSIBLE))
-#define ALMANAH_IS_TAG_ACCESSIBLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_TAG_ACCESSIBLE))
-#define ALMANAH_TAG_ACCESSIBLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_TAG_ACCESSIBLE,
AlmanahTagAccessibleClass))
-
-typedef struct _AlmanahTagAccessiblePrivate AlmanahTagAccessiblePrivate;
-
-typedef struct {
- GtkWidgetAccessible parent;
-
- AlmanahTagAccessiblePrivate *priv;
-} AlmanahTagAccessible;
-
-typedef struct {
- GtkWidgetAccessibleClass parent;
-} AlmanahTagAccessibleClass;
-
-GType almanah_tag_accessible_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (AlmanahTagAccessible, almanah_tag_accessible, ALMANAH, TAG_ACCESSIBLE,
GtkWidgetAccessible)
G_END_DECLS
diff --git a/src/widgets/tag-entry.c b/src/widgets/tag-entry.c
index a5f1606..93a76a5 100644
--- a/src/widgets/tag-entry.c
+++ b/src/widgets/tag-entry.c
@@ -27,9 +27,14 @@ enum {
PROP_STORAGE_MANAGER = 1
};
-struct _AlmanahTagEntryPrivate {
+typedef struct {
GtkListStore *tags_store;
AlmanahStorageManager *storage_manager;
+} AlmanahTagEntryPrivate;
+
+struct _AlmanahTagEntry {
+ GtkEntry parent;
+ AlmanahTagEntryPrivate *priv;
};
static void almanah_tag_entry_get_property (GObject *object, guint property_id, GValue *value,
GParamSpec *pspec);
@@ -41,7 +46,7 @@ gboolean almanah_tag_entry_focus_out_event (GtkWidget *self, GdkEventFocus
gboolean almanah_tag_entry_focus_in_event (GtkWidget *self, GdkEventFocus *event);
gboolean almanah_tag_entry_match_selected (GtkEntryCompletion *widget, GtkTreeModel *model,
GtkTreeIter *iter, AlmanahTagEntry *self);
-G_DEFINE_TYPE (AlmanahTagEntry, almanah_tag_entry, GTK_TYPE_ENTRY)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahTagEntry, almanah_tag_entry, GTK_TYPE_ENTRY)
static void
almanah_tag_entry_class_init (AlmanahTagEntryClass *klass)
@@ -49,8 +54,6 @@ almanah_tag_entry_class_init (AlmanahTagEntryClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahTagEntryPrivate));
-
gobject_class->get_property = almanah_tag_entry_get_property;
gobject_class->set_property = almanah_tag_entry_set_property;
gobject_class->finalize = almanah_tag_entry_finalize;
@@ -72,7 +75,7 @@ almanah_tag_entry_init (AlmanahTagEntry *self)
GtkEntryCompletion *completion;
AtkObject *self_atk_object;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_TAG_ENTRY, AlmanahTagEntryPrivate);
+ self->priv = almanah_tag_entry_get_instance_private (self);
self->priv->tags_store = gtk_list_store_new (1, G_TYPE_STRING);
completion = gtk_entry_completion_new ();
diff --git a/src/widgets/tag-entry.h b/src/widgets/tag-entry.h
index 7e5bacc..fded166 100644
--- a/src/widgets/tag-entry.h
+++ b/src/widgets/tag-entry.h
@@ -27,24 +27,8 @@
G_BEGIN_DECLS
#define ALMANAH_TYPE_TAG_ENTRY (almanah_tag_entry_get_type ())
-#define ALMANAH_TAG_ENTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_TAG_ENTRY,
AlmanahTagEntry))
-#define ALMANAH_TAG_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_TAG_ENTRY,
AlmanahTagEntryClass))
-#define ALMANAH_IS_TAG_ENTRY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_TAG_ENTRY))
-#define ALMANAH_IS_TAG_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_TAG_ENTRY))
-#define ALMANAH_TAG_ENTRY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_TAG_ENTRY,
AlmanahTagEntryClass))
+G_DECLARE_FINAL_TYPE (AlmanahTagEntry, almanah_tag_entry, ALMANAH, TAG_ENTRY, GtkEntry)
-typedef struct _AlmanahTagEntryPrivate AlmanahTagEntryPrivate;
-
-typedef struct {
- GtkEntry parent;
- AlmanahTagEntryPrivate *priv;
-} AlmanahTagEntry;
-
-typedef struct {
- GtkEntryClass parent;
-} AlmanahTagEntryClass;
-
-GType almanah_tag_entry_get_type (void) G_GNUC_CONST;
void almanah_tag_entry_set_storage_manager (AlmanahTagEntry *tag_entry, AlmanahStorageManager
*storage_manager);
G_END_DECLS
diff --git a/src/widgets/tag.c b/src/widgets/tag.c
index 97b2320..6a61826 100644
--- a/src/widgets/tag.c
+++ b/src/widgets/tag.c
@@ -37,7 +37,7 @@ enum {
PROP_TAG = 1
};
-struct _AlmanahTagPrivate {
+typedef struct {
gchar *tag;
PangoLayout *layout;
@@ -54,6 +54,11 @@ struct _AlmanahTagPrivate {
/* The close button state */
gboolean close_highlighted;
gboolean close_pressed;
+} AlmanahTagPrivate;
+
+struct _AlmanahTag {
+ GtkDrawingArea parent;
+ AlmanahTagPrivate *priv;
};
enum {
@@ -75,7 +80,7 @@ gboolean almanah_tag_button_release_event (GtkWidget *widget, GdkEventButton
gboolean almanah_tag_draw (GtkWidget *widget, cairo_t *cr, gpointer data);
gboolean almanah_tag_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode,
GtkTooltip *tooltip);
-G_DEFINE_TYPE (AlmanahTag, almanah_tag, GTK_TYPE_DRAWING_AREA)
+G_DEFINE_TYPE_WITH_PRIVATE (AlmanahTag, almanah_tag, GTK_TYPE_DRAWING_AREA)
static void
almanah_tag_class_init (AlmanahTagClass *klass)
@@ -83,8 +88,6 @@ almanah_tag_class_init (AlmanahTagClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AlmanahTagPrivate));
-
gobject_class->get_property = almanah_tag_get_property;
gobject_class->set_property = almanah_tag_set_property;
gobject_class->finalize = almanah_tag_finalize;
@@ -114,7 +117,7 @@ almanah_tag_class_init (AlmanahTagClass *klass)
static void
almanah_tag_init (AlmanahTag *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_TAG, AlmanahTagPrivate);
+ self->priv = almanah_tag_get_instance_private (self);
g_signal_connect (G_OBJECT (self), "draw", G_CALLBACK (almanah_tag_draw), NULL);
gtk_widget_add_events (GTK_WIDGET (self),
diff --git a/src/widgets/tag.h b/src/widgets/tag.h
index 3628230..2a7cce2 100644
--- a/src/widgets/tag.h
+++ b/src/widgets/tag.h
@@ -25,24 +25,8 @@
G_BEGIN_DECLS
#define ALMANAH_TYPE_TAG (almanah_tag_get_type ())
-#define ALMANAH_TAG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ALMANAH_TYPE_TAG, AlmanahTag))
-#define ALMANAH_TAG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ALMANAH_TYPE_TAG, AlmanahTagClass))
-#define ALMANAH_IS_TAG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ALMANAH_TYPE_TAG))
-#define ALMANAH_IS_TAG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ALMANAH_TYPE_TAG))
-#define ALMANAH_TAG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ALMANAH_TYPE_TAG, AlmanahTagClass))
+G_DECLARE_FINAL_TYPE (AlmanahTag, almanah_tag, ALMANAH, TAG, GtkDrawingArea)
-typedef struct _AlmanahTagPrivate AlmanahTagPrivate;
-
-typedef struct {
- GtkDrawingArea parent;
- AlmanahTagPrivate *priv;
-} AlmanahTag;
-
-typedef struct {
- GtkDrawingAreaClass parent;
-} AlmanahTagClass;
-
-GType almanah_tag_get_type (void) G_GNUC_CONST;
GtkWidget *almanah_tag_new (const gchar *tag);
const gchar *almanah_tag_get_tag (AlmanahTag *tag_widget);
void almanah_tag_remove (AlmanahTag *tag_widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]