aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-12-03 22:14:51 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-12-03 22:14:51 +0000
commit0ab4079b28220f4051f8d0935a976e550514ad7f (patch)
tree7693892f4b07f9f222b76d91f641da41f0239d69
parent3fded4665bfe9764faaeb657de791b0c553f6258 (diff)
downloadayatana-ido-0ab4079b28220f4051f8d0935a976e550514ad7f.tar.gz
ayatana-ido-0ab4079b28220f4051f8d0935a976e550514ad7f.tar.bz2
ayatana-ido-0ab4079b28220f4051f8d0935a976e550514ad7f.zip
Avoid deprecated g_type_class_add_private.
-rw-r--r--src/idobasicmenuitem.c33
-rw-r--r--src/idobasicmenuitem.h2
-rw-r--r--src/idocalendarmenuitem.c116
-rw-r--r--src/idocalendarmenuitem.h3
-rw-r--r--src/idodetaillabel.c42
-rw-r--r--src/idodetaillabel.h2
-rw-r--r--src/idoentrymenuitem.c61
-rw-r--r--src/idoentrymenuitem.h3
-rw-r--r--src/idolocationmenuitem.c34
-rw-r--r--src/idolocationmenuitem.h2
-rw-r--r--src/idomessagedialog.c26
-rw-r--r--src/idorange.c20
-rw-r--r--src/idorange.h2
-rw-r--r--src/idoscalemenuitem.c75
-rw-r--r--src/idoscalemenuitem.h3
-rw-r--r--src/idoswitchmenuitem.c33
-rw-r--r--src/idoswitchmenuitem.h3
-rw-r--r--src/idotimeline.c100
-rw-r--r--src/idotimestampmenuitem.c65
-rw-r--r--src/idotimestampmenuitem.h2
-rw-r--r--src/idousermenuitem.c63
-rw-r--r--src/idousermenuitem.h2
22 files changed, 356 insertions, 336 deletions
diff --git a/src/idobasicmenuitem.c b/src/idobasicmenuitem.c
index 382a150..cf57e7c 100644
--- a/src/idobasicmenuitem.c
+++ b/src/idobasicmenuitem.c
@@ -37,8 +37,7 @@ enum
static GParamSpec *properties[PROP_LAST];
-struct _IdoBasicMenuItemPrivate
-{
+typedef struct {
GIcon * icon;
char * text;
char * secondary_text;
@@ -46,11 +45,9 @@ struct _IdoBasicMenuItemPrivate
GtkWidget * image;
GtkWidget * label;
GtkWidget * secondary_label;
-};
-
-typedef IdoBasicMenuItemPrivate priv_t;
+} IdoBasicMenuItemPrivate;
-G_DEFINE_TYPE (IdoBasicMenuItem, ido_basic_menu_item, GTK_TYPE_MENU_ITEM);
+G_DEFINE_TYPE_WITH_PRIVATE (IdoBasicMenuItem, ido_basic_menu_item, GTK_TYPE_MENU_ITEM);
/***
**** GObject Virtual Functions
@@ -63,7 +60,7 @@ my_get_property (GObject * o,
GParamSpec * pspec)
{
IdoBasicMenuItem * self = IDO_BASIC_MENU_ITEM (o);
- priv_t * p = self->priv;
+ IdoBasicMenuItemPrivate * p = ido_basic_menu_item_get_instance_private(self);
switch (property_id)
{
@@ -117,7 +114,7 @@ static void
my_dispose (GObject * object)
{
IdoBasicMenuItem * self = IDO_BASIC_MENU_ITEM (object);
- priv_t * p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
g_clear_object (&p->icon);
@@ -128,7 +125,7 @@ static void
my_finalize (GObject * object)
{
IdoBasicMenuItem * self = IDO_BASIC_MENU_ITEM (object);
- priv_t * p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
g_free (p->text);
g_free (p->secondary_text);
@@ -139,7 +136,7 @@ my_finalize (GObject * object)
static void
ido_basic_menu_item_update_image (IdoBasicMenuItem *self)
{
- IdoBasicMenuItemPrivate * p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
gtk_image_clear (GTK_IMAGE (p->image));
@@ -191,8 +188,6 @@ ido_basic_menu_item_class_init (IdoBasicMenuItemClass *klass)
GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- g_type_class_add_private (klass, sizeof (IdoBasicMenuItemPrivate));
-
gobject_class->get_property = my_get_property;
gobject_class->set_property = my_set_property;
gobject_class->dispose = my_dispose;
@@ -228,15 +223,11 @@ ido_basic_menu_item_class_init (IdoBasicMenuItemClass *klass)
static void
ido_basic_menu_item_init (IdoBasicMenuItem *self)
{
- priv_t * p;
+
GtkWidget * w;
GtkGrid * grid;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- IDO_TYPE_BASIC_MENU_ITEM,
- IdoBasicMenuItemPrivate);
-
- p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
p->image = gtk_image_new ();
gtk_misc_set_alignment(GTK_MISC(p->image), 0.0, 0.0);
@@ -287,7 +278,7 @@ ido_basic_menu_item_new (void)
void
ido_basic_menu_item_set_icon (IdoBasicMenuItem * self, GIcon * icon)
{
- IdoBasicMenuItemPrivate * p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
if (p->icon != icon)
{
@@ -314,7 +305,7 @@ ido_basic_menu_item_set_icon_from_file (IdoBasicMenuItem * self, const char * fi
void
ido_basic_menu_item_set_text (IdoBasicMenuItem * self, const char * text)
{
- IdoBasicMenuItemPrivate * p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
if (g_strcmp0 (p->text, text))
{
@@ -331,7 +322,7 @@ ido_basic_menu_item_set_text (IdoBasicMenuItem * self, const char * text)
void
ido_basic_menu_item_set_secondary_text (IdoBasicMenuItem * self, const char * secondary_text)
{
- IdoBasicMenuItemPrivate * p = self->priv;
+ IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self);
if (g_strcmp0 (p->secondary_text, secondary_text))
{
diff --git a/src/idobasicmenuitem.h b/src/idobasicmenuitem.h
index 6a4b83a..38ae830 100644
--- a/src/idobasicmenuitem.h
+++ b/src/idobasicmenuitem.h
@@ -30,7 +30,6 @@ G_BEGIN_DECLS
typedef struct _IdoBasicMenuItem IdoBasicMenuItem;
typedef struct _IdoBasicMenuItemClass IdoBasicMenuItemClass;
-typedef struct _IdoBasicMenuItemPrivate IdoBasicMenuItemPrivate;
struct _IdoBasicMenuItemClass
{
@@ -44,7 +43,6 @@ struct _IdoBasicMenuItem
{
/*< private >*/
GtkMenuItem parent;
- IdoBasicMenuItemPrivate * priv;
};
diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c
index 557d898..f3881bc 100644
--- a/src/idocalendarmenuitem.c
+++ b/src/idocalendarmenuitem.c
@@ -51,17 +51,14 @@ static void calendar_day_selected_double_click_cb (GtkWidget *widg
gpointer user_data);
static void calendar_day_selected_cb (GtkWidget *widget,
gpointer user_data);
-struct _IdoCalendarMenuItemPrivate
-{
+typedef struct {
GtkWidget *box;
GtkWidget *calendar;
GtkWidget *parent;
gboolean selected;
-};
-
-G_DEFINE_TYPE (IdoCalendarMenuItem, ido_calendar_menu_item, GTK_TYPE_MENU_ITEM)
+} IdoCalendarMenuItemPrivate;
-#define IDO_CALENDAR_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_CALENDAR_MENU_ITEM, IdoCalendarMenuItemPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (IdoCalendarMenuItem, ido_calendar_menu_item, GTK_TYPE_MENU_ITEM)
static void
ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass)
@@ -84,8 +81,6 @@ ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass)
menu_item_class->hide_on_activate = TRUE;
- g_type_class_add_private (gobject_class, sizeof (IdoCalendarMenuItemPrivate));
-
g_signal_new("month-changed", G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
@@ -104,9 +99,7 @@ ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass)
static void
ido_calendar_menu_item_init (IdoCalendarMenuItem *item)
{
- IdoCalendarMenuItemPrivate *priv;
-
- priv = item->priv = IDO_CALENDAR_MENU_ITEM_GET_PRIVATE (item);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(item);
/* Will be disposed automatically */
priv->calendar = g_object_new (gtk_calendar_get_type (),
@@ -136,7 +129,7 @@ static void
ido_calendar_menu_item_finalize (GObject *object)
{
IdoCalendarMenuItem *item = IDO_CALENDAR_MENU_ITEM (object);
- IdoCalendarMenuItemPrivate *priv = IDO_CALENDAR_MENU_ITEM_GET_PRIVATE (item);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(item);
if (G_IS_OBJECT (priv->calendar))
{
@@ -183,13 +176,14 @@ ido_calendar_menu_item_key_press (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
{
- IdoCalendarMenuItem *menuitem = (IdoCalendarMenuItem *)data;
+ IdoCalendarMenuItem *menuitem = IDO_CALENDAR_MENU_ITEM (data);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
g_return_val_if_fail (IDO_IS_CALENDAR_MENU_ITEM (menuitem), FALSE);
- if (menuitem->priv->selected)
+ if (priv->selected)
{
- GtkWidget *calendar = menuitem->priv->calendar;
+ GtkWidget *calendar = priv->calendar;
gtk_widget_event (calendar,
((GdkEvent *)(void*)(event)));
@@ -215,7 +209,10 @@ static gboolean
ido_calendar_menu_item_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar;
+ IdoCalendarMenuItem *menuitem = IDO_CALENDAR_MENU_ITEM (widget);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ GtkWidget *calendar = priv->calendar;
if (event->button == 1) {
if (gtk_widget_get_window (calendar) != NULL) {
@@ -265,7 +262,10 @@ static gboolean
ido_calendar_menu_item_button_release (GtkWidget *widget,
GdkEventButton *event)
{
- GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar;
+ IdoCalendarMenuItem *menuitem = IDO_CALENDAR_MENU_ITEM (widget);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ GtkWidget *calendar = priv->calendar;
GTK_WIDGET_GET_CLASS(calendar)->button_release_event(GTK_WIDGET(calendar), event);
return TRUE;
@@ -274,17 +274,23 @@ ido_calendar_menu_item_button_release (GtkWidget *widget,
static void
ido_calendar_menu_item_select (GtkMenuItem *item)
{
- IDO_CALENDAR_MENU_ITEM (item)->priv->selected = TRUE;
+ IdoCalendarMenuItem *menuitem = IDO_CALENDAR_MENU_ITEM (item);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ priv->selected = TRUE;
- ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), TRUE);
+ ido_calendar_menu_item_send_focus_change (GTK_WIDGET (priv->calendar), TRUE);
}
static void
ido_calendar_menu_item_deselect (GtkMenuItem *item)
{
- IDO_CALENDAR_MENU_ITEM (item)->priv->selected = FALSE;
+ IdoCalendarMenuItem *menuitem = IDO_CALENDAR_MENU_ITEM (item);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
- ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), FALSE);
+ priv->selected = FALSE;
+
+ ido_calendar_menu_item_send_focus_change (GTK_WIDGET (priv->calendar), FALSE);
}
static void
@@ -296,25 +302,27 @@ calendar_realized_cb (GtkWidget *widget,
gdk_window_raise (gtk_widget_get_window (widget));
}
- item->priv->parent = gtk_widget_get_parent (GTK_WIDGET (item));
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(item);
+
+ priv->parent = gtk_widget_get_parent (GTK_WIDGET (item));
- g_object_add_weak_pointer (G_OBJECT (item->priv->parent),
- (gpointer*) &item->priv->parent);
+ g_object_add_weak_pointer (G_OBJECT (priv->parent),
+ (gpointer*) &priv->parent);
- g_signal_connect (item->priv->parent,
+ g_signal_connect (priv->parent,
"key-press-event",
G_CALLBACK (ido_calendar_menu_item_key_press),
item);
- g_signal_connect (item->priv->calendar,
+ g_signal_connect (priv->calendar,
"month-changed",
G_CALLBACK (calendar_month_changed_cb),
item);
- g_signal_connect (item->priv->calendar,
+ g_signal_connect (priv->calendar,
"day-selected",
G_CALLBACK (calendar_day_selected_cb),
item);
- g_signal_connect (item->priv->calendar,
+ g_signal_connect (priv->calendar,
"day-selected-double-click",
G_CALLBACK (calendar_day_selected_double_click_cb),
item);
@@ -327,7 +335,10 @@ calendar_move_focus_cb (GtkWidget *widget,
GtkDirectionType direction,
IdoCalendarMenuItem *item)
{
- ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), FALSE);
+ IdoCalendarMenuItem *menuitem = IDO_CALENDAR_MENU_ITEM (widget);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ ido_calendar_menu_item_send_focus_change (GTK_WIDGET (priv->calendar), FALSE);
g_signal_emit_by_name (item,
"move-focus",
@@ -386,7 +397,9 @@ ido_calendar_menu_item_get_calendar (IdoCalendarMenuItem *menuitem)
{
g_return_val_if_fail (IDO_IS_CALENDAR_MENU_ITEM (menuitem), NULL);
- return menuitem->priv->calendar;
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ return priv->calendar;
}
/**
@@ -402,8 +415,10 @@ gboolean
ido_calendar_menu_item_mark_day (IdoCalendarMenuItem *menuitem, guint day)
{
g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE);
-
- gtk_calendar_mark_day(GTK_CALENDAR (menuitem->priv->calendar), day);
+
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ gtk_calendar_mark_day(GTK_CALENDAR (priv->calendar), day);
return TRUE;
}
@@ -420,8 +435,10 @@ gboolean
ido_calendar_menu_item_unmark_day (IdoCalendarMenuItem *menuitem, guint day)
{
g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE);
-
- gtk_calendar_unmark_day(GTK_CALENDAR (menuitem->priv->calendar), day);
+
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ gtk_calendar_unmark_day(GTK_CALENDAR (priv->calendar), day);
return TRUE;
}
@@ -435,8 +452,10 @@ void
ido_calendar_menu_item_clear_marks (IdoCalendarMenuItem *menuitem)
{
g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem));
-
- gtk_calendar_clear_marks(GTK_CALENDAR (menuitem->priv->calendar));
+
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ gtk_calendar_clear_marks(GTK_CALENDAR (priv->calendar));
}
/**
@@ -450,8 +469,10 @@ void
ido_calendar_menu_item_set_display_options (IdoCalendarMenuItem *menuitem, GtkCalendarDisplayOptions flags)
{
g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem));
-
- gtk_calendar_set_display_options (GTK_CALENDAR (menuitem->priv->calendar), flags);
+
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ gtk_calendar_set_display_options (GTK_CALENDAR (priv->calendar), flags);
}
/**
@@ -466,8 +487,10 @@ GtkCalendarDisplayOptions
ido_calendar_menu_item_get_display_options (IdoCalendarMenuItem *menuitem)
{
g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), 0);
-
- return gtk_calendar_get_display_options (GTK_CALENDAR (menuitem->priv->calendar));
+
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ return gtk_calendar_get_display_options (GTK_CALENDAR (priv->calendar));
}
/**
@@ -484,9 +507,12 @@ ido_calendar_menu_item_get_date (IdoCalendarMenuItem *menuitem,
guint *year,
guint *month,
guint *day) {
-
+
g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem));
- gtk_calendar_get_date (GTK_CALENDAR (menuitem->priv->calendar), year, month, day);
+
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
+ gtk_calendar_get_date (GTK_CALENDAR (priv->calendar), year, month, day);
}
/**
@@ -510,13 +536,15 @@ ido_calendar_menu_item_set_date (IdoCalendarMenuItem *menuitem,
g_return_val_if_fail (IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE);
+ IdoCalendarMenuItemPrivate *priv = ido_calendar_menu_item_get_instance_private(menuitem);
+
ido_calendar_menu_item_get_date (menuitem, &old_y, &old_m, &old_d);
if ((old_y != year) || (old_m != month))
- gtk_calendar_select_month (GTK_CALENDAR (menuitem->priv->calendar), month, year);
+ gtk_calendar_select_month (GTK_CALENDAR (priv->calendar), month, year);
if (old_d != day)
- gtk_calendar_select_day (GTK_CALENDAR (menuitem->priv->calendar), day);
+ gtk_calendar_select_day (GTK_CALENDAR (priv->calendar), day);
return TRUE;
}
diff --git a/src/idocalendarmenuitem.h b/src/idocalendarmenuitem.h
index 5cd913e..8c1528d 100644
--- a/src/idocalendarmenuitem.h
+++ b/src/idocalendarmenuitem.h
@@ -39,13 +39,10 @@ G_BEGIN_DECLS
typedef struct _IdoCalendarMenuItem IdoCalendarMenuItem;
typedef struct _IdoCalendarMenuItemClass IdoCalendarMenuItemClass;
-typedef struct _IdoCalendarMenuItemPrivate IdoCalendarMenuItemPrivate;
struct _IdoCalendarMenuItem
{
GtkMenuItem parent_instance;
-
- IdoCalendarMenuItemPrivate *priv;
};
struct _IdoCalendarMenuItemClass
diff --git a/src/idodetaillabel.c b/src/idodetaillabel.c
index b36b222..c502f92 100644
--- a/src/idodetaillabel.c
+++ b/src/idodetaillabel.c
@@ -21,14 +21,11 @@
#include <math.h>
-G_DEFINE_TYPE (IdoDetailLabel, ido_detail_label, GTK_TYPE_WIDGET)
-
-struct _IdoDetailLabelPrivate
-{
+typedef struct {
gchar *text;
PangoLayout *layout;
gboolean draw_lozenge;
-};
+} IdoDetailLabelPrivate;
enum
{
@@ -39,6 +36,8 @@ enum
static GParamSpec *properties[NUM_PROPERTIES];
+G_DEFINE_TYPE_WITH_PRIVATE (IdoDetailLabel, ido_detail_label, GTK_TYPE_WIDGET)
+
static void
ido_detail_label_get_property (GObject *object,
guint property_id,
@@ -46,11 +45,12 @@ ido_detail_label_get_property (GObject *object,
GParamSpec *pspec)
{
IdoDetailLabel *self = IDO_DETAIL_LABEL (object);
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(self);
switch (property_id)
{
case PROP_TEXT:
- g_value_set_string (value, self->priv->text);
+ g_value_set_string (value, priv->text);
break;
default:
@@ -81,7 +81,7 @@ ido_detail_label_set_property (GObject *object,
static void
ido_detail_label_finalize (GObject *object)
{
- IdoDetailLabelPrivate *priv = IDO_DETAIL_LABEL (object)->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(IDO_DETAIL_LABEL (object));
g_free (priv->text);
@@ -91,7 +91,7 @@ ido_detail_label_finalize (GObject *object)
static void
ido_detail_label_dispose (GObject *object)
{
- IdoDetailLabelPrivate *priv = IDO_DETAIL_LABEL (object)->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(IDO_DETAIL_LABEL (object));
g_clear_object (&priv->layout);
@@ -101,7 +101,7 @@ ido_detail_label_dispose (GObject *object)
static void
ido_detail_label_ensure_layout (IdoDetailLabel *label)
{
- IdoDetailLabelPrivate *priv = label->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(label);
if (priv->layout == NULL)
{
@@ -156,7 +156,8 @@ gtk_widget_get_font_metrics (GtkWidget *widget,
static gint
ido_detail_label_get_minimum_text_width (IdoDetailLabel *label)
{
- IdoDetailLabelPrivate *priv = label->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(label);
+
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width;
@@ -176,7 +177,8 @@ ido_detail_label_draw (GtkWidget *widget,
cairo_t *cr)
{
IdoDetailLabel *label = IDO_DETAIL_LABEL (widget);
- IdoDetailLabelPrivate *priv = IDO_DETAIL_LABEL (widget)->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(label);
+
PangoRectangle extents;
GtkAllocation allocation;
double x, w, h, radius;
@@ -224,7 +226,8 @@ ido_detail_label_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
- IdoDetailLabelPrivate *priv = IDO_DETAIL_LABEL (widget)->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(IDO_DETAIL_LABEL (widget));
+
PangoRectangle extents;
double radius;
@@ -244,7 +247,7 @@ ido_detail_label_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
- IdoDetailLabelPrivate *priv = IDO_DETAIL_LABEL (widget)->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(IDO_DETAIL_LABEL (widget));
PangoContext *context;
PangoFontMetrics *metrics;
PangoRectangle extents;
@@ -277,8 +280,6 @@ ido_detail_label_class_init (IdoDetailLabelClass *klass)
widget_class->get_preferred_width = ido_detail_label_get_preferred_width;
widget_class->get_preferred_height = ido_detail_label_get_preferred_height;
- g_type_class_add_private (klass, sizeof (IdoDetailLabelPrivate));
-
properties[PROP_TEXT] = g_param_spec_string ("text",
"Text",
"The text of the label",
@@ -292,10 +293,6 @@ ido_detail_label_class_init (IdoDetailLabelClass *klass)
static void
ido_detail_label_init (IdoDetailLabel *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- IDO_TYPE_DETAIL_LABEL,
- IdoDetailLabelPrivate);
-
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
}
@@ -311,7 +308,10 @@ const gchar *
ido_detail_label_get_text (IdoDetailLabel *label)
{
g_return_val_if_fail (IDO_IS_DETAIL_LABEL (label), NULL);
- return label->priv->text;
+
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(label);
+
+ return priv->text;
}
/* collapse_whitespace:
@@ -362,7 +362,7 @@ ido_detail_label_set_text_impl (IdoDetailLabel *label,
const gchar *text,
gboolean draw_lozenge)
{
- IdoDetailLabelPrivate * priv = label->priv;
+ IdoDetailLabelPrivate *priv = ido_detail_label_get_instance_private(label);
g_clear_object (&priv->layout);
g_free (priv->text);
diff --git a/src/idodetaillabel.h b/src/idodetaillabel.h
index 1995fee..6b6f57a 100644
--- a/src/idodetaillabel.h
+++ b/src/idodetaillabel.h
@@ -31,12 +31,10 @@
typedef struct _IdoDetailLabel IdoDetailLabel;
typedef struct _IdoDetailLabelClass IdoDetailLabelClass;
-typedef struct _IdoDetailLabelPrivate IdoDetailLabelPrivate;
struct _IdoDetailLabel
{
GtkWidget parent;
- IdoDetailLabelPrivate *priv;
};
struct _IdoDetailLabelClass
diff --git a/src/idoentrymenuitem.c b/src/idoentrymenuitem.c
index 5b5a3fb..d2948df 100644
--- a/src/idoentrymenuitem.c
+++ b/src/idoentrymenuitem.c
@@ -27,6 +27,7 @@
#include "idoentrymenuitem.h"
#include "config.h"
+static void ido_entry_menu_item_finalize (GObject *item);
static void ido_entry_menu_item_select (GtkMenuItem *item);
static void ido_entry_menu_item_deselect (GtkMenuItem *item);
static gboolean ido_entry_menu_item_button_release (GtkWidget *widget,
@@ -44,16 +45,13 @@ static void entry_move_focus_cb (GtkWidget *widget,
GtkDirectionType direction,
IdoEntryMenuItem *item);
-struct _IdoEntryMenuItemPrivate
-{
+typedef struct {
GtkWidget *box;
GtkWidget *entry;
gboolean selected;
-};
-
-G_DEFINE_TYPE (IdoEntryMenuItem, ido_entry_menu_item, GTK_TYPE_MENU_ITEM)
+} IdoEntryMenuItemPrivate;
-#define IDO_ENTRY_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_ENTRY_MENU_ITEM, IdoEntryMenuItemPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (IdoEntryMenuItem, ido_entry_menu_item, GTK_TYPE_MENU_ITEM)
static void
ido_entry_menu_item_class_init (IdoEntryMenuItemClass *klass)
@@ -66,6 +64,8 @@ ido_entry_menu_item_class_init (IdoEntryMenuItemClass *klass)
widget_class = GTK_WIDGET_CLASS (klass);
menu_item_class = GTK_MENU_ITEM_CLASS (klass);
+ gobject_class->finalize = ido_entry_menu_item_finalize;
+
widget_class->button_release_event = ido_entry_menu_item_button_release;
widget_class->button_press_event = ido_entry_menu_item_button_press;
@@ -73,8 +73,6 @@ ido_entry_menu_item_class_init (IdoEntryMenuItemClass *klass)
menu_item_class->deselect = ido_entry_menu_item_deselect;
menu_item_class->hide_on_activate = TRUE;
-
- g_type_class_add_private (gobject_class, sizeof (IdoEntryMenuItemPrivate));
}
static void
@@ -88,7 +86,7 @@ ido_entry_menu_item_init (IdoEntryMenuItem *item)
border.top = 2;
border.bottom = 2;
- priv = item->priv = IDO_ENTRY_MENU_ITEM_GET_PRIVATE (item);
+ priv = ido_entry_menu_item_get_instance_private(item);
priv->entry = g_object_new (gtk_entry_get_type (),
"inner-border", &border,
@@ -135,12 +133,13 @@ ido_entry_menu_item_key_press (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
{
- IdoEntryMenuItem *menuitem = (IdoEntryMenuItem *)data;
+ IdoEntryMenuItem *menuitem = IDO_ENTRY_MENU_ITEM(data);
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(menuitem);
- if (menuitem->priv->selected &&
+ if (priv->selected &&
is_key_press_valid (menuitem, event->keyval))
{
- GtkWidget *entry = menuitem->priv->entry;
+ GtkWidget *entry = priv->entry;
gtk_widget_event (entry,
((GdkEvent *)(void*)(event)));
@@ -179,7 +178,10 @@ static gboolean
ido_entry_menu_item_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- GtkWidget *entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry;
+ IdoEntryMenuItem *menuitem = IDO_ENTRY_MENU_ITEM(widget);
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(menuitem);
+
+ GtkWidget *entry = priv->entry;
if (event->button == 1)
{
@@ -206,7 +208,10 @@ static gboolean
ido_entry_menu_item_button_release (GtkWidget *widget,
GdkEventButton *event)
{
- GtkWidget *entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry;
+ IdoEntryMenuItem *menuitem = IDO_ENTRY_MENU_ITEM(widget);
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(menuitem);
+
+ GtkWidget *entry = priv->entry;
gtk_widget_event (entry,
((GdkEvent *)(void*)(event)));
@@ -217,17 +222,23 @@ ido_entry_menu_item_button_release (GtkWidget *widget,
static void
ido_entry_menu_item_select (GtkMenuItem *item)
{
- IDO_ENTRY_MENU_ITEM (item)->priv->selected = TRUE;
+ IdoEntryMenuItem *menuitem = IDO_ENTRY_MENU_ITEM(item);
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(menuitem);
+
+ priv->selected = TRUE;
- ido_entry_menu_item_send_focus_change (GTK_WIDGET (IDO_ENTRY_MENU_ITEM (item)->priv->entry), TRUE);
+ ido_entry_menu_item_send_focus_change (GTK_WIDGET (priv->entry), TRUE);
}
static void
ido_entry_menu_item_deselect (GtkMenuItem *item)
{
- IDO_ENTRY_MENU_ITEM (item)->priv->selected = FALSE;
+ IdoEntryMenuItem *menuitem = IDO_ENTRY_MENU_ITEM(item);
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(menuitem);
- ido_entry_menu_item_send_focus_change (GTK_WIDGET (IDO_ENTRY_MENU_ITEM (item)->priv->entry), FALSE);
+ priv->selected = FALSE;
+
+ ido_entry_menu_item_send_focus_change (GTK_WIDGET (priv->entry), FALSE);
}
@@ -253,7 +264,9 @@ entry_move_focus_cb (GtkWidget *widget,
GtkDirectionType direction,
IdoEntryMenuItem *item)
{
- ido_entry_menu_item_send_focus_change (GTK_WIDGET (IDO_ENTRY_MENU_ITEM (item)->priv->entry), FALSE);
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(item);
+
+ ido_entry_menu_item_send_focus_change (GTK_WIDGET (priv->entry), FALSE);
g_signal_emit_by_name (item,
"move-focus",
@@ -286,5 +299,13 @@ ido_entry_menu_item_get_entry (IdoEntryMenuItem *menuitem)
{
g_return_val_if_fail (IDO_IS_ENTRY_MENU_ITEM (menuitem), NULL);
- return menuitem->priv->entry;
+ IdoEntryMenuItemPrivate *priv = ido_entry_menu_item_get_instance_private(menuitem);
+
+ return priv->entry;
+}
+
+static void
+ido_entry_menu_item_finalize (GObject *gobject)
+{
+ /* no-op */
}
diff --git a/src/idoentrymenuitem.h b/src/idoentrymenuitem.h
index 417e774..7c5da79 100644
--- a/src/idoentrymenuitem.h
+++ b/src/idoentrymenuitem.h
@@ -39,13 +39,10 @@ G_BEGIN_DECLS
typedef struct _IdoEntryMenuItem IdoEntryMenuItem;
typedef struct _IdoEntryMenuItemClass IdoEntryMenuItemClass;
-typedef struct _IdoEntryMenuItemPrivate IdoEntryMenuItemPrivate;
struct _IdoEntryMenuItem
{
GtkMenuItem parent_instance;
-
- IdoEntryMenuItemPrivate *priv;
};
struct _IdoEntryMenuItemClass
diff --git a/src/idolocationmenuitem.c b/src/idolocationmenuitem.c
index 335422a..eb6b38b 100644
--- a/src/idolocationmenuitem.c
+++ b/src/idolocationmenuitem.c
@@ -37,16 +37,13 @@ enum
static GParamSpec *properties[PROP_LAST];
-struct _IdoLocationMenuItemPrivate
-{
+typedef struct {
char * timezone;
guint timestamp_timer;
-};
+} IdoLocationMenuItemPrivate;
-typedef IdoLocationMenuItemPrivate priv_t;
-
-G_DEFINE_TYPE (IdoLocationMenuItem, ido_location_menu_item, IDO_TYPE_TIME_STAMP_MENU_ITEM);
+G_DEFINE_TYPE_WITH_PRIVATE (IdoLocationMenuItem, ido_location_menu_item, IDO_TYPE_TIME_STAMP_MENU_ITEM);
/***
**** Timestamp Label
@@ -58,7 +55,9 @@ update_timestamp (IdoLocationMenuItem * self)
GTimeZone * tz;
GDateTime * date_time;
- tz = g_time_zone_new (self->priv->timezone);
+ IdoLocationMenuItemPrivate * priv = ido_location_menu_item_get_instance_private(self);
+
+ tz = g_time_zone_new (priv->timezone);
if (tz == NULL)
tz = g_time_zone_new_local ();
date_time = g_date_time_new_now (tz);
@@ -73,7 +72,7 @@ update_timestamp (IdoLocationMenuItem * self)
static void
stop_timestamp_timer (IdoLocationMenuItem * self)
{
- priv_t * p = self->priv;
+ IdoLocationMenuItemPrivate * p = ido_location_menu_item_get_instance_private(self);
if (p->timestamp_timer != 0)
{
@@ -130,6 +129,7 @@ restart_timestamp_timer (IdoLocationMenuItem * self)
const char * fmt = ido_time_stamp_menu_item_get_format (IDO_TIME_STAMP_MENU_ITEM (self));
gboolean timestamp_shows_seconds;
int interval_sec;
+ IdoLocationMenuItemPrivate * priv = ido_location_menu_item_get_instance_private(self);
stop_timestamp_timer (self);
@@ -142,7 +142,7 @@ restart_timestamp_timer (IdoLocationMenuItem * self)
else
interval_sec = calculate_seconds_until_next_minute();
- self->priv->timestamp_timer = g_timeout_add_seconds (interval_sec,
+ priv->timestamp_timer = g_timeout_add_seconds (interval_sec,
on_timestamp_timer,
self);
}
@@ -158,7 +158,7 @@ my_get_property (GObject * o,
GParamSpec * pspec)
{
IdoLocationMenuItem * self = IDO_LOCATION_MENU_ITEM (o);
- priv_t * p = self->priv;
+ IdoLocationMenuItemPrivate * p = ido_location_menu_item_get_instance_private(self);
switch (property_id)
{
@@ -204,8 +204,9 @@ static void
my_finalize (GObject * object)
{
IdoLocationMenuItem * self = IDO_LOCATION_MENU_ITEM (object);
+ IdoLocationMenuItemPrivate * priv = ido_location_menu_item_get_instance_private(self);
- g_free (self->priv->timezone);
+ g_free (priv->timezone);
G_OBJECT_CLASS (ido_location_menu_item_parent_class)->finalize (object);
}
@@ -219,8 +220,6 @@ ido_location_menu_item_class_init (IdoLocationMenuItemClass *klass)
{
GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (IdoLocationMenuItemPrivate));
-
gobject_class->get_property = my_get_property;
gobject_class->set_property = my_set_property;
gobject_class->dispose = my_dispose;
@@ -239,10 +238,6 @@ ido_location_menu_item_class_init (IdoLocationMenuItemClass *klass)
static void
ido_location_menu_item_init (IdoLocationMenuItem *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- IDO_LOCATION_MENU_ITEM_TYPE,
- IdoLocationMenuItemPrivate);
-
/* Update the timer whenever the format string changes
because it determines whether we update once per second or per minute */
g_signal_connect (self, "notify::format",
@@ -271,10 +266,11 @@ void
ido_location_menu_item_set_timezone (IdoLocationMenuItem * self,
const char * timezone)
{
- priv_t * p;
+ IdoLocationMenuItemPrivate * p;
g_return_if_fail (IDO_IS_LOCATION_MENU_ITEM (self));
- p = self->priv;
+
+ p = ido_location_menu_item_get_instance_private(self);
g_free (p->timezone);
p->timezone = g_strdup (timezone);
diff --git a/src/idolocationmenuitem.h b/src/idolocationmenuitem.h
index 2ae231f..5d1c660 100644
--- a/src/idolocationmenuitem.h
+++ b/src/idolocationmenuitem.h
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
typedef struct _IdoLocationMenuItem IdoLocationMenuItem;
typedef struct _IdoLocationMenuItemClass IdoLocationMenuItemClass;
-typedef struct _IdoLocationMenuItemPrivate IdoLocationMenuItemPrivate;
struct _IdoLocationMenuItemClass
{
@@ -48,7 +47,6 @@ struct _IdoLocationMenuItem
{
/*< private >*/
IdoTimeStampMenuItem parent;
- IdoLocationMenuItemPrivate * priv;
};
diff --git a/src/idomessagedialog.c b/src/idomessagedialog.c
index 5b73950..ef5f148 100644
--- a/src/idomessagedialog.c
+++ b/src/idomessagedialog.c
@@ -34,22 +34,18 @@
#include "idotimeline.h"
#include "config.h"
-#define IDO_MESSAGE_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_MESSAGE_DIALOG, IdoMessageDialogPrivate))
-
static GtkWidget *ido_message_dialog_get_secondary_label (IdoMessageDialog *dialog);
static GtkWidget *ido_message_dialog_get_primary_label (IdoMessageDialog *dialog);
-typedef struct _IdoMessageDialogPrivate IdoMessageDialogPrivate;
-typedef struct _IdoMessageDialogMorphContext IdoMessageDialogMorphContext;
-
-struct _IdoMessageDialogPrivate
-{
+typedef struct {
GtkWidget *action_area;
GtkWidget *primary_label;
GtkWidget *secondary_label;
gboolean expanded;
-};
+} IdoMessageDialogPrivate;
+
+typedef struct _IdoMessageDialogMorphContext IdoMessageDialogMorphContext;
struct _IdoMessageDialogMorphContext
{
@@ -60,13 +56,13 @@ struct _IdoMessageDialogMorphContext
GtkRequisition end;
};
-G_DEFINE_TYPE (IdoMessageDialog, ido_message_dialog, GTK_TYPE_MESSAGE_DIALOG)
+G_DEFINE_TYPE_WITH_PRIVATE (IdoMessageDialog, ido_message_dialog, GTK_TYPE_MESSAGE_DIALOG)
static void
ido_message_dialog_map (GtkWidget *widget)
{
IdoMessageDialog *dialog = IDO_MESSAGE_DIALOG (widget);
- IdoMessageDialogPrivate *priv = IDO_MESSAGE_DIALOG_GET_PRIVATE (dialog);
+ IdoMessageDialogPrivate *priv = ido_message_dialog_get_instance_private (dialog);
GTK_WIDGET_CLASS (ido_message_dialog_parent_class)->map (widget);
@@ -145,7 +141,7 @@ timeline_finished_cb (IdoTimeline *timeline,
gpointer user_data)
{
IdoMessageDialogMorphContext *context = user_data;
- IdoMessageDialogPrivate *priv = IDO_MESSAGE_DIALOG_GET_PRIVATE (context->widget);
+ IdoMessageDialogPrivate *priv = ido_message_dialog_get_instance_private (IDO_MESSAGE_DIALOG (context->widget));
gtk_widget_show (priv->action_area);
gtk_widget_show (priv->secondary_label);
@@ -158,7 +154,7 @@ ido_message_dialog_focus_in_event (GtkWidget *widget,
GdkEventFocus *event)
{
IdoMessageDialog *dialog = IDO_MESSAGE_DIALOG (widget);
- IdoMessageDialogPrivate *priv = IDO_MESSAGE_DIALOG_GET_PRIVATE (dialog);
+ IdoMessageDialogPrivate *priv = ido_message_dialog_get_instance_private (dialog);
if (!priv->expanded)
{
@@ -203,7 +199,9 @@ ido_message_dialog_focus_in_event (GtkWidget *widget,
static void
ido_message_dialog_constructed (GObject *object)
{
- IdoMessageDialogPrivate *priv = IDO_MESSAGE_DIALOG_GET_PRIVATE (object);
+
+ IdoMessageDialog *dialog = IDO_MESSAGE_DIALOG (object);
+ IdoMessageDialogPrivate *priv = ido_message_dialog_get_instance_private (dialog);
GtkWidget *vbox;
GtkWidget *event_box;
@@ -231,8 +229,6 @@ ido_message_dialog_class_init (IdoMessageDialogClass *class)
widget_class->map = ido_message_dialog_map;
widget_class->focus_in_event = ido_message_dialog_focus_in_event;
-
- g_type_class_add_private (object_class, sizeof (IdoMessageDialogPrivate));
}
static void
diff --git a/src/idorange.c b/src/idorange.c
index acdfa5d..634b223 100644
--- a/src/idorange.c
+++ b/src/idorange.c
@@ -27,10 +27,9 @@
#include "idotypebuiltins.h"
#include "config.h"
-struct _IdoRangePrivate
-{
+typedef struct {
IdoRangeStyle style;
-};
+} IdoRangePrivate;
static void ido_range_constructed (GObject *object);
static void ido_range_set_property (GObject *object,
@@ -42,9 +41,7 @@ static void ido_range_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-#define IDO_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_RANGE, IdoRangePrivate))
-
-G_DEFINE_TYPE (IdoRange, ido_range, GTK_TYPE_SCALE)
+G_DEFINE_TYPE_WITH_PRIVATE (IdoRange, ido_range, GTK_TYPE_SCALE)
enum {
PROP_0,
@@ -87,8 +84,6 @@ ido_range_class_init (IdoRangeClass *class)
G_MAXINT,
8,
G_PARAM_READABLE));
-
- g_type_class_add_private (class, sizeof (IdoRangePrivate));
}
static void
@@ -97,7 +92,8 @@ ido_range_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- IdoRangePrivate *priv = IDO_RANGE (object)->priv;
+ IdoRange *range = IDO_RANGE (object);
+ IdoRangePrivate *priv = ido_range_get_instance_private (range);
switch (prop_id)
{
@@ -117,7 +113,8 @@ ido_range_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- IdoRangePrivate *priv = IDO_RANGE (object)->priv;
+ IdoRange *range = IDO_RANGE (object);
+ IdoRangePrivate *priv = ido_range_get_instance_private (range);
switch (prop_id)
{
@@ -135,6 +132,7 @@ static void
ido_range_constructed (GObject *object)
{
IdoRange *range = IDO_RANGE (object);
+
IdoRangeStyle style;
char buf[1024];
@@ -163,7 +161,7 @@ ido_range_constructed (GObject *object)
static void
ido_range_init (IdoRange *range)
{
- range->priv = IDO_RANGE_GET_PRIVATE (range);
+ /* no-op */
}
/**
diff --git a/src/idorange.h b/src/idorange.h
index 7c2e79b..beef43f 100644
--- a/src/idorange.h
+++ b/src/idorange.h
@@ -44,13 +44,11 @@ typedef enum
} IdoRangeStyle;
typedef struct _IdoRange IdoRange;
-typedef struct _IdoRangePrivate IdoRangePrivate;
typedef struct _IdoRangeClass IdoRangeClass;
struct _IdoRange
{
GtkScale parent_instance;
- IdoRangePrivate *priv;
};
struct _IdoRangeClass
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c
index de9884f..9f5f29c 100644
--- a/src/idoscalemenuitem.c
+++ b/src/idoscalemenuitem.c
@@ -64,7 +64,7 @@ static void update_packing (IdoScaleMenuItem
static void default_primary_clicked_handler (IdoScaleMenuItem *self);
static void default_secondary_clicked_handler (IdoScaleMenuItem *self);
-struct _IdoScaleMenuItemPrivate {
+typedef struct {
GtkWidget *scale;
GtkAdjustment *adjustment;
GtkWidget *primary_image;
@@ -78,7 +78,7 @@ struct _IdoScaleMenuItemPrivate {
IdoRangeStyle range_style;
gboolean ignore_value_changed;
gboolean has_focus;
-};
+} IdoScaleMenuItemPrivate;
enum {
SLIDER_GRABBED,
@@ -99,15 +99,15 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (IdoScaleMenuItem, ido_scale_menu_item, GTK_TYPE_MENU_ITEM)
-
-#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_SCALE_MENU_ITEM, IdoScaleMenuItemPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (IdoScaleMenuItem, ido_scale_menu_item, GTK_TYPE_MENU_ITEM)
static gboolean
ido_scale_menu_item_scroll_event (GtkWidget *menuitem,
GdkEventScroll *event)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
+ IdoScaleMenuItem *item = IDO_SCALE_MENU_ITEM (menuitem);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (item);
+
GtkWidget *scale = priv->scale;
if (priv->reverse_scroll)
@@ -138,7 +138,7 @@ ido_scale_menu_item_scale_value_changed (GtkRange *range,
gpointer user_data)
{
IdoScaleMenuItem *self = user_data;
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (self);
/* The signal is not sent when it was set through
* ido_scale_menu_item_set_value(). */
@@ -151,7 +151,8 @@ static void
ido_scale_menu_item_constructed (GObject *object)
{
IdoScaleMenuItem *self = IDO_SCALE_MENU_ITEM (object);
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (self);
+
GObject *adj = G_OBJECT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0));
IdoRangeStyle range_style;
GtkWidget *hbox;
@@ -322,14 +323,13 @@ ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class)
G_TYPE_NONE,
1, G_TYPE_DOUBLE);
-
- g_type_class_add_private (item_class, sizeof (IdoScaleMenuItemPrivate));
}
static void
update_packing (IdoScaleMenuItem *self, IdoScaleMenuItemStyle style)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (self);
+
GtkBox * box = GTK_BOX (priv->hbox);
GtkContainer *container = GTK_CONTAINER (priv->hbox);
@@ -366,7 +366,7 @@ update_packing (IdoScaleMenuItem *self, IdoScaleMenuItemStyle style)
static void
ido_scale_menu_item_init (IdoScaleMenuItem *self)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (self);
priv->reverse_scroll = TRUE;
@@ -380,7 +380,7 @@ ido_scale_menu_item_set_property (GObject *object,
GParamSpec *pspec)
{
IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (object);
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menu_item);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (menu_item);
switch (prop_id)
{
@@ -413,7 +413,7 @@ ido_scale_menu_item_get_property (GObject *object,
GParamSpec *pspec)
{
IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (object);
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menu_item);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (menu_item);
GtkAdjustment *adjustment;
switch (prop_id)
@@ -442,7 +442,8 @@ ido_scale_menu_item_parent_key_press_event (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (user_data);
+ IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (user_data);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (menu_item);
/* only listen to events when the playback menu item is selected */
if (!priv->has_focus)
@@ -469,7 +470,8 @@ ido_scale_menu_item_parent_key_press_event (GtkWidget *widget,
static void
ido_scale_menu_item_select (GtkMenuItem *item)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (item);
+ IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (item);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (menu_item);
priv->has_focus = TRUE;
gtk_widget_set_state_flags (priv->scale, GTK_STATE_FLAG_FOCUSED, FALSE);
@@ -480,7 +482,8 @@ ido_scale_menu_item_select (GtkMenuItem *item)
static void
ido_scale_menu_item_deselect (GtkMenuItem *item)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (item);
+ IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (item);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (menu_item);
priv->has_focus = FALSE;
gtk_widget_unset_state_flags (priv->scale, GTK_STATE_FLAG_FOCUSED);
@@ -492,7 +495,9 @@ static gboolean
ido_scale_menu_item_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
+ IdoScaleMenuItem *item = IDO_SCALE_MENU_ITEM (menuitem);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (item);
+
GtkAllocation alloc;
gint x, y;
@@ -516,7 +521,8 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem,
GdkEventButton *event)
{
IdoScaleMenuItem *item = IDO_SCALE_MENU_ITEM (menuitem);
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (item);
+
GtkWidget *scale = priv->scale;
GtkAllocation alloc;
gint x, y;
@@ -569,7 +575,9 @@ static gboolean
ido_scale_menu_item_motion_notify_event (GtkWidget *menuitem,
GdkEventMotion *event)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
+ IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (menuitem);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (menu_item);
+
GtkAllocation alloc;
gint x, y;
@@ -596,7 +604,7 @@ static void
menu_hidden (GtkWidget *menu,
IdoScaleMenuItem *scale)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (scale);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (scale);
if (priv->grabbed)
{
@@ -718,7 +726,7 @@ ido_scale_menu_item_get_scale (IdoScaleMenuItem *menuitem)
g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL);
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
return priv->scale;
}
@@ -739,7 +747,7 @@ ido_scale_menu_item_get_style (IdoScaleMenuItem *menuitem)
g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), IDO_SCALE_MENU_ITEM_STYLE_NONE);
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
return priv->style;
}
@@ -760,7 +768,7 @@ ido_scale_menu_item_set_style (IdoScaleMenuItem *menuitem,
g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem));
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
priv->style = style;
@@ -784,7 +792,7 @@ ido_scale_menu_item_get_primary_image (IdoScaleMenuItem *menuitem)
g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL);
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
return priv->primary_image;
}
@@ -806,7 +814,7 @@ ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem)
g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL);
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
return priv->secondary_image;
}
@@ -859,7 +867,7 @@ ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem)
g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL);
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
return gtk_label_get_text (GTK_LABEL (priv->primary_label));
}
@@ -881,7 +889,7 @@ ido_scale_menu_item_get_secondary_label (IdoScaleMenuItem *menuitem)
g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL);
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
return gtk_label_get_text (GTK_LABEL (priv->secondary_label));
}
@@ -903,7 +911,7 @@ ido_scale_menu_item_set_primary_label (IdoScaleMenuItem *menuitem,
g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem));
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
if (priv->primary_label)
{
@@ -928,7 +936,7 @@ ido_scale_menu_item_set_secondary_label (IdoScaleMenuItem *menuitem,
g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem));
- priv = GET_PRIVATE (menuitem);
+ priv = ido_scale_menu_item_get_instance_private (menuitem);
if (priv->secondary_label)
{
@@ -954,7 +962,8 @@ static void
default_primary_clicked_handler (IdoScaleMenuItem * item)
{
g_debug ("%s: setting scale to lower bound", G_STRFUNC);
- IdoScaleMenuItemPrivate * priv = GET_PRIVATE (item);
+ IdoScaleMenuItemPrivate * priv = ido_scale_menu_item_get_instance_private (item);
+
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (priv->scale));
gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
}
@@ -977,7 +986,7 @@ static void
default_secondary_clicked_handler (IdoScaleMenuItem * item)
{
g_debug ("%s: setting scale to upper bound", G_STRFUNC);
- IdoScaleMenuItemPrivate * priv = GET_PRIVATE (item);
+ IdoScaleMenuItemPrivate * priv = ido_scale_menu_item_get_instance_private (item);
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (priv->scale));
gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj));
}
@@ -991,7 +1000,7 @@ static void
ido_scale_menu_item_set_value (IdoScaleMenuItem *item,
gdouble value)
{
- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (item);
+ IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (item);
/* set ignore_value_changed to signify to the scale menu item that it
* should not emit its own value-changed signal, as that should only
diff --git a/src/idoscalemenuitem.h b/src/idoscalemenuitem.h
index 2c32a49..de6968e 100644
--- a/src/idoscalemenuitem.h
+++ b/src/idoscalemenuitem.h
@@ -47,13 +47,10 @@ typedef enum
typedef struct _IdoScaleMenuItem IdoScaleMenuItem;
typedef struct _IdoScaleMenuItemClass IdoScaleMenuItemClass;
-typedef struct _IdoScaleMenuItemPrivate IdoScaleMenuItemPrivate;
struct _IdoScaleMenuItem
{
GtkMenuItem parent_instance;
-
- IdoScaleMenuItemPrivate *priv;
};
struct _IdoScaleMenuItemClass
diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c
index d47392f..bd00e1d 100644
--- a/src/idoswitchmenuitem.c
+++ b/src/idoswitchmenuitem.c
@@ -23,24 +23,25 @@
#include "idoswitchmenuitem.h"
#include "idoactionhelper.h"
+static void ido_switch_menu_finalize (GObject * item);
static gboolean ido_switch_menu_button_release_event (GtkWidget * widget,
GdkEventButton * event);
-struct _IdoSwitchMenuItemPrivate
+typedef struct
{
GtkWidget * box;
GtkWidget * content_area;
GtkWidget * label;
GtkWidget * image;
GtkWidget * switch_w;
-};
+} IdoSwitchMenuItemPrivate;
/***
**** Life Cycle
***/
-G_DEFINE_TYPE (IdoSwitchMenuItem, ido_switch_menu_item, GTK_TYPE_CHECK_MENU_ITEM)
+G_DEFINE_TYPE_WITH_PRIVATE (IdoSwitchMenuItem, ido_switch_menu_item, GTK_TYPE_CHECK_MENU_ITEM)
static void
ido_switch_menu_item_class_init (IdoSwitchMenuItemClass *klass)
@@ -50,7 +51,8 @@ ido_switch_menu_item_class_init (IdoSwitchMenuItemClass *klass)
GtkCheckMenuItemClass * check_class;
gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (gobject_class, sizeof (IdoSwitchMenuItemPrivate));
+
+ gobject_class->finalize = ido_switch_menu_finalize;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->button_release_event = ido_switch_menu_button_release_event;
@@ -62,9 +64,8 @@ ido_switch_menu_item_class_init (IdoSwitchMenuItemClass *klass)
static void
ido_switch_menu_item_init (IdoSwitchMenuItem *item)
{
- IdoSwitchMenuItemPrivate *priv;
+ IdoSwitchMenuItemPrivate *priv = ido_switch_menu_item_get_instance_private(item);
- priv = item->priv = G_TYPE_INSTANCE_GET_PRIVATE (item, IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemPrivate);
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
priv->content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
priv->switch_w = gtk_switch_new ();
@@ -134,6 +135,8 @@ ido_switch_menu_item_get_content_area (IdoSwitchMenuItem * item)
g_return_val_if_fail (IDO_IS_SWITCH_MENU_ITEM(item), NULL);
+ IdoSwitchMenuItemPrivate *priv = ido_switch_menu_item_get_instance_private(item);
+
if (!warned)
{
g_warning ("%s is deprecated. Please don't use it, especially if you're using"
@@ -141,7 +144,7 @@ ido_switch_menu_item_get_content_area (IdoSwitchMenuItem * item)
warned = TRUE;
}
- return GTK_CONTAINER (item->priv->content_area);
+ return GTK_CONTAINER (priv->content_area);
}
/**
@@ -160,7 +163,7 @@ ido_switch_menu_item_set_label (IdoSwitchMenuItem *item,
g_return_if_fail (IDO_IS_SWITCH_MENU_ITEM (item));
g_return_if_fail (label != NULL);
- priv = item->priv;
+ priv = ido_switch_menu_item_get_instance_private(item);
if (priv->label == NULL)
{
@@ -189,7 +192,7 @@ ido_switch_menu_item_set_icon (IdoSwitchMenuItem *item,
g_return_if_fail (IDO_IS_SWITCH_MENU_ITEM (item));
g_return_if_fail (icon == NULL || G_IS_ICON (icon));
- priv = item->priv;
+ priv = ido_switch_menu_item_get_instance_private(item);
if (icon)
{
@@ -213,10 +216,11 @@ ido_source_menu_item_state_changed (IdoActionHelper *helper,
GVariant *state,
gpointer user_data)
{
- IdoSwitchMenuItem *item = user_data;
+ IdoSwitchMenuItem *item = IDO_SWITCH_MENU_ITEM (user_data);
+ IdoSwitchMenuItemPrivate *priv = ido_switch_menu_item_get_instance_private(item);
if (g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
- gtk_switch_set_active (GTK_SWITCH (item->priv->switch_w),
+ gtk_switch_set_active (GTK_SWITCH (priv->switch_w),
g_variant_get_boolean (state));
}
@@ -269,3 +273,10 @@ ido_switch_menu_item_new_from_menu_model (GMenuItem *menuitem,
return item;
}
+
+static void
+ido_switch_menu_finalize (GObject * item)
+{
+ /* no-op */
+}
+
diff --git a/src/idoswitchmenuitem.h b/src/idoswitchmenuitem.h
index 222b473..de218d1 100644
--- a/src/idoswitchmenuitem.h
+++ b/src/idoswitchmenuitem.h
@@ -34,13 +34,10 @@ G_BEGIN_DECLS
typedef struct _IdoSwitchMenuItem IdoSwitchMenuItem;
typedef struct _IdoSwitchMenuItemClass IdoSwitchMenuItemClass;
-typedef struct _IdoSwitchMenuItemPrivate IdoSwitchMenuItemPrivate;
struct _IdoSwitchMenuItem
{
GtkCheckMenuItem parent_instance;
-
- IdoSwitchMenuItemPrivate *priv;
};
struct _IdoSwitchMenuItemClass
diff --git a/src/idotimeline.c b/src/idotimeline.c
index 8eea4b5..4929ba3 100644
--- a/src/idotimeline.c
+++ b/src/idotimeline.c
@@ -25,15 +25,11 @@
#include <gtk/gtk.h>
#include <math.h>
-#define IDO_TIMELINE_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IDO_TYPE_TIMELINE, IdoTimelinePriv))
#define MSECS_PER_SEC 1000
#define FRAME_INTERVAL(nframes) (MSECS_PER_SEC / nframes)
#define DEFAULT_FPS 30
-typedef struct IdoTimelinePriv IdoTimelinePriv;
-
-struct IdoTimelinePriv
-{
+typedef struct {
guint duration;
guint fps;
guint source_id;
@@ -48,7 +44,7 @@ struct IdoTimelinePriv
guint animations_enabled : 1;
guint loop : 1;
guint direction : 1;
-};
+} IdoTimelinePrivate;
enum {
PROP_0,
@@ -81,7 +77,7 @@ static void ido_timeline_get_property (GObject *object,
static void ido_timeline_finalize (GObject *object);
-G_DEFINE_TYPE (IdoTimeline, ido_timeline, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (IdoTimeline, ido_timeline, G_TYPE_OBJECT)
static void
@@ -193,16 +189,12 @@ ido_timeline_class_init (IdoTimelineClass *klass)
g_cclosure_marshal_VOID__DOUBLE,
G_TYPE_NONE, 1,
G_TYPE_DOUBLE);
-
- g_type_class_add_private (klass, sizeof (IdoTimelinePriv));
}
static void
ido_timeline_init (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
-
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ IdoTimelinePrivate *priv = ido_timeline_get_instance_private (timeline);
priv->fps = DEFAULT_FPS;
priv->duration = 0.0;
@@ -251,11 +243,8 @@ ido_timeline_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- IdoTimeline *timeline;
- IdoTimelinePriv *priv;
-
- timeline = IDO_TIMELINE (object);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ IdoTimeline *timeline = IDO_TIMELINE (object);
+ IdoTimelinePrivate *priv = ido_timeline_get_instance_private (timeline);
switch (prop_id)
{
@@ -282,9 +271,8 @@ ido_timeline_get_property (GObject *object,
static void
ido_timeline_finalize (GObject *object)
{
- IdoTimelinePriv *priv;
-
- priv = IDO_TIMELINE_GET_PRIV (object);
+ IdoTimeline *timeline = IDO_TIMELINE (object);
+ IdoTimelinePrivate *priv = ido_timeline_get_instance_private (timeline);
if (priv->source_id)
{
@@ -301,11 +289,10 @@ ido_timeline_finalize (GObject *object)
static gboolean
ido_timeline_run_frame (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
gdouble delta_progress, progress;
guint elapsed_time;
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ IdoTimelinePrivate *priv = ido_timeline_get_instance_private (timeline);
elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
g_timer_start (priv->timer);
@@ -395,12 +382,12 @@ ido_timeline_new_for_screen (guint duration,
void
ido_timeline_start (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
gboolean enable_animations = FALSE;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (!priv->source_id)
{
@@ -446,11 +433,11 @@ ido_timeline_start (IdoTimeline *timeline)
void
ido_timeline_pause (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (priv->source_id)
{
@@ -470,11 +457,11 @@ ido_timeline_pause (IdoTimeline *timeline)
void
ido_timeline_rewind (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (ido_timeline_get_direction(timeline) != IDO_TIMELINE_DIRECTION_FORWARD)
priv->progress = priv->last_progress = 1.;
@@ -502,11 +489,11 @@ ido_timeline_rewind (IdoTimeline *timeline)
gboolean
ido_timeline_is_running (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), FALSE);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
return (priv->source_id != 0);
}
@@ -522,11 +509,12 @@ ido_timeline_is_running (IdoTimeline *timeline)
guint
ido_timeline_get_fps (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), 1);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
+
return priv->fps;
}
@@ -542,12 +530,12 @@ void
ido_timeline_set_fps (IdoTimeline *timeline,
guint fps)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
g_return_if_fail (fps > 0);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
/* Coverity CID: 12650/12651: guard against division by 0. */
priv->fps = fps > 0 ? fps : priv->fps;
@@ -575,11 +563,12 @@ ido_timeline_set_fps (IdoTimeline *timeline,
gboolean
ido_timeline_get_loop (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), FALSE);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
+
return priv->loop;
}
@@ -595,11 +584,11 @@ void
ido_timeline_set_loop (IdoTimeline *timeline,
gboolean loop)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (loop != priv->loop)
{
@@ -619,11 +608,11 @@ void
ido_timeline_set_duration (IdoTimeline *timeline,
guint duration)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (duration != priv->duration)
{
@@ -643,11 +632,11 @@ ido_timeline_set_duration (IdoTimeline *timeline,
guint
ido_timeline_get_duration (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), 0);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
return priv->duration;
}
@@ -663,11 +652,11 @@ void
ido_timeline_set_direction (IdoTimeline *timeline,
IdoTimelineDirection direction)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (direction != priv->direction)
{
@@ -687,11 +676,12 @@ ido_timeline_set_direction (IdoTimeline *timeline,
IdoTimelineDirection
ido_timeline_get_direction (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), IDO_TIMELINE_DIRECTION_FORWARD);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
+
return priv->direction;
}
@@ -706,12 +696,12 @@ void
ido_timeline_set_screen (IdoTimeline *timeline,
GdkScreen *screen)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
g_return_if_fail (GDK_IS_SCREEN (screen));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (priv->screen)
g_object_unref (priv->screen);
@@ -732,11 +722,12 @@ ido_timeline_set_screen (IdoTimeline *timeline,
GdkScreen *
ido_timeline_get_screen (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), NULL);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
+
return priv->screen;
}
@@ -751,11 +742,12 @@ ido_timeline_get_screen (IdoTimeline *timeline)
gdouble
ido_timeline_get_progress (IdoTimeline *timeline)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_val_if_fail (IDO_IS_TIMELINE (timeline), 0.);
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
+
return priv->progress;
}
@@ -769,11 +761,11 @@ ido_timeline_get_progress (IdoTimeline *timeline)
void
ido_timeline_set_progress (IdoTimeline *timeline, gdouble progress)
{
- IdoTimelinePriv *priv;
+ IdoTimelinePrivate *priv;
g_return_if_fail (IDO_IS_TIMELINE (timeline));
- priv = IDO_TIMELINE_GET_PRIV (timeline);
+ priv = ido_timeline_get_instance_private (timeline);
if (priv->source_id)
{
diff --git a/src/idotimestampmenuitem.c b/src/idotimestampmenuitem.c
index 0d33deb..0c9c086 100644
--- a/src/idotimestampmenuitem.c
+++ b/src/idotimestampmenuitem.c
@@ -39,17 +39,14 @@ enum
static GParamSpec *properties[PROP_LAST];
-struct _IdoTimeStampMenuItemPrivate
-{
+typedef struct {
char * format;
GDateTime * date_time;
-};
-
-typedef IdoTimeStampMenuItemPrivate priv_t;
+} IdoTimeStampMenuItemPrivate;
-G_DEFINE_TYPE (IdoTimeStampMenuItem,
- ido_time_stamp_menu_item,
- IDO_TYPE_BASIC_MENU_ITEM);
+G_DEFINE_TYPE_WITH_PRIVATE (IdoTimeStampMenuItem,
+ ido_time_stamp_menu_item,
+ IDO_TYPE_BASIC_MENU_ITEM);
/***
**** GObject Virtual Functions
@@ -62,16 +59,16 @@ my_get_property (GObject * o,
GParamSpec * pspec)
{
IdoTimeStampMenuItem * self = IDO_TIME_STAMP_MENU_ITEM (o);
- priv_t * p = self->priv;
+ IdoTimeStampMenuItemPrivate * priv = ido_time_stamp_menu_item_get_instance_private(self);
switch (property_id)
{
case PROP_FORMAT:
- g_value_set_string (v, p->format);
+ g_value_set_string (v, priv->format);
break;
case PROP_DATE_TIME:
- g_value_set_boxed (v, p->date_time);
+ g_value_set_boxed (v, priv->date_time);
break;
default:
@@ -108,9 +105,9 @@ static void
my_dispose (GObject * object)
{
IdoTimeStampMenuItem * self = IDO_TIME_STAMP_MENU_ITEM (object);
- priv_t * p = self->priv;
+ IdoTimeStampMenuItemPrivate * priv = ido_time_stamp_menu_item_get_instance_private(self);
- g_clear_pointer (&p->date_time, g_date_time_unref);
+ g_clear_pointer (&priv->date_time, g_date_time_unref);
G_OBJECT_CLASS (ido_time_stamp_menu_item_parent_class)->dispose (object);
}
@@ -119,9 +116,9 @@ static void
my_finalize (GObject * object)
{
IdoTimeStampMenuItem * self = IDO_TIME_STAMP_MENU_ITEM (object);
- priv_t * p = self->priv;
+ IdoTimeStampMenuItemPrivate * priv = ido_time_stamp_menu_item_get_instance_private(self);
- g_free (p->format);
+ g_free (priv->format);
G_OBJECT_CLASS (ido_time_stamp_menu_item_parent_class)->finalize (object);
}
@@ -136,8 +133,6 @@ ido_time_stamp_menu_item_class_init (IdoTimeStampMenuItemClass *klass)
GParamFlags prop_flags;
GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (IdoTimeStampMenuItemPrivate));
-
gobject_class->get_property = my_get_property;
gobject_class->set_property = my_set_property;
gobject_class->dispose = my_dispose;
@@ -167,20 +162,18 @@ ido_time_stamp_menu_item_class_init (IdoTimeStampMenuItemClass *klass)
static void
ido_time_stamp_menu_item_init (IdoTimeStampMenuItem *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- IDO_TYPE_TIME_STAMP_MENU_ITEM,
- IdoTimeStampMenuItemPrivate);
-
+ /* no-op */
}
static void
update_timestamp_label (IdoTimeStampMenuItem * self)
{
char * str;
- priv_t * p = self->priv;
- if (p->date_time && p->format)
- str = g_date_time_format (p->date_time, p->format);
+ IdoTimeStampMenuItemPrivate * priv = ido_time_stamp_menu_item_get_instance_private(self);
+
+ if (priv->date_time && priv->format)
+ str = g_date_time_format (priv->date_time, priv->format);
else
str = NULL;
@@ -210,14 +203,15 @@ void
ido_time_stamp_menu_item_set_date_time (IdoTimeStampMenuItem * self,
GDateTime * date_time)
{
- priv_t * p;
+ IdoTimeStampMenuItemPrivate * priv;
g_return_if_fail (IDO_IS_TIME_STAMP_MENU_ITEM (self));
- p = self->priv;
- g_clear_pointer (&p->date_time, g_date_time_unref);
+ priv = ido_time_stamp_menu_item_get_instance_private(self);
+
+ g_clear_pointer (&priv->date_time, g_date_time_unref);
if (date_time != NULL)
- p->date_time = g_date_time_ref (date_time);
+ priv->date_time = g_date_time_ref (date_time);
update_timestamp_label (self);
}
@@ -234,20 +228,25 @@ void
ido_time_stamp_menu_item_set_format (IdoTimeStampMenuItem * self,
const char * strftime_fmt)
{
- priv_t * p;
+ IdoTimeStampMenuItemPrivate * priv;
g_return_if_fail (IDO_IS_TIME_STAMP_MENU_ITEM (self));
- p = self->priv;
- g_free (p->format);
- p->format = g_strdup (strftime_fmt);
+ priv = ido_time_stamp_menu_item_get_instance_private(self);
+
+ g_free (priv->format);
+ priv->format = g_strdup (strftime_fmt);
update_timestamp_label (self);
}
const gchar *
ido_time_stamp_menu_item_get_format (IdoTimeStampMenuItem * self)
{
+ IdoTimeStampMenuItemPrivate * priv;
+
g_return_val_if_fail (IDO_IS_TIME_STAMP_MENU_ITEM (self), NULL);
- return self->priv->format;
+ priv = ido_time_stamp_menu_item_get_instance_private(self);
+
+ return priv->format;
}
diff --git a/src/idotimestampmenuitem.h b/src/idotimestampmenuitem.h
index 5847ba8..b596fad 100644
--- a/src/idotimestampmenuitem.h
+++ b/src/idotimestampmenuitem.h
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
typedef struct _IdoTimeStampMenuItem IdoTimeStampMenuItem;
typedef struct _IdoTimeStampMenuItemClass IdoTimeStampMenuItemClass;
-typedef struct _IdoTimeStampMenuItemPrivate IdoTimeStampMenuItemPrivate;
struct _IdoTimeStampMenuItemClass
{
@@ -49,7 +48,6 @@ struct _IdoTimeStampMenuItem
{
/*< private >*/
IdoBasicMenuItem parent;
- IdoTimeStampMenuItemPrivate * priv;
};
diff --git a/src/idousermenuitem.c b/src/idousermenuitem.c
index 8d8673e..bbb7916 100644
--- a/src/idousermenuitem.c
+++ b/src/idousermenuitem.c
@@ -42,8 +42,7 @@ enum
static GParamSpec *properties[PROP_LAST];
-struct _IdoUserMenuItemPrivate
-{
+typedef struct {
GtkWidget* user_image;
GtkWidget* user_name;
GtkWidget* container;
@@ -52,9 +51,9 @@ struct _IdoUserMenuItemPrivate
gboolean is_current_user;
gchar * label;
GIcon * icon;
-};
+} IdoUserMenuItemPrivate;
-G_DEFINE_TYPE (IdoUserMenuItem, ido_user_menu_item, GTK_TYPE_MENU_ITEM);
+G_DEFINE_TYPE_WITH_PRIVATE (IdoUserMenuItem, ido_user_menu_item, GTK_TYPE_MENU_ITEM);
/* Prototypes */
static gboolean ido_user_menu_item_primitive_draw_cb_gtk_3 (GtkWidget * image,
@@ -72,23 +71,24 @@ my_get_property (GObject * o,
GParamSpec * pspec)
{
IdoUserMenuItem * self = IDO_USER_MENU_ITEM (o);
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
switch (property_id)
{
case PROP_LABEL:
- g_value_set_string (value, self->priv->label);
+ g_value_set_string (value, priv->label);
break;
case PROP_ICON:
- g_value_set_object (value, self->priv->icon);
+ g_value_set_object (value, priv->icon);
break;
case PROP_IS_LOGGED_IN:
- g_value_set_boolean (value, self->priv->is_logged_in);
+ g_value_set_boolean (value, priv->is_logged_in);
break;
case PROP_IS_CURRENT_USER:
- g_value_set_boolean (value, self->priv->is_current_user);
+ g_value_set_boolean (value, priv->is_current_user);
break;
default:
@@ -104,6 +104,7 @@ my_set_property (GObject * o,
GParamSpec * pspec)
{
IdoUserMenuItem * self = IDO_USER_MENU_ITEM (o);
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
switch (property_id)
{
@@ -120,7 +121,7 @@ my_set_property (GObject * o,
break;
case PROP_IS_CURRENT_USER:
- self->priv->is_current_user = g_value_get_boolean (value);
+ priv->is_current_user = g_value_get_boolean (value);
gtk_widget_queue_draw (GTK_WIDGET(self));
break;
@@ -134,8 +135,9 @@ static void
my_dispose (GObject *object)
{
IdoUserMenuItem * self = IDO_USER_MENU_ITEM (object);
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
- g_clear_object (&self->priv->icon);
+ g_clear_object (&priv->icon);
G_OBJECT_CLASS (ido_user_menu_item_parent_class)->dispose (object);
}
@@ -144,8 +146,9 @@ static void
my_finalize (GObject *object)
{
IdoUserMenuItem * self = IDO_USER_MENU_ITEM (object);
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
- g_free (self->priv->label);
+ g_free (priv->label);
G_OBJECT_CLASS (ido_user_menu_item_parent_class)->finalize (object);
}
@@ -156,8 +159,6 @@ ido_user_menu_item_class_init (IdoUserMenuItemClass *klass)
GParamFlags prop_flags;
GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (IdoUserMenuItemPrivate));
-
gobject_class->get_property = my_get_property;
gobject_class->set_property = my_set_property;
gobject_class->dispose = my_dispose;
@@ -197,13 +198,7 @@ ido_user_menu_item_class_init (IdoUserMenuItemClass *klass)
static void
ido_user_menu_item_init (IdoUserMenuItem *self)
{
- IdoUserMenuItemPrivate * priv;
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- IDO_USER_MENU_ITEM_TYPE,
- IdoUserMenuItemPrivate);
-
- priv = self->priv;
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
// Create the UI elements.
priv->user_image = gtk_image_new ();
@@ -260,7 +255,7 @@ ido_user_menu_item_primitive_draw_cb_gtk_3 (GtkWidget * widget,
g_return_val_if_fail(IS_IDO_USER_MENU_ITEM(user_data), FALSE);
- priv = IDO_USER_MENU_ITEM(user_data)->priv;
+ priv = ido_user_menu_item_get_instance_private(IDO_USER_MENU_ITEM(user_data));
/* Draw dot only when user is the current user. */
if (priv->is_current_user)
@@ -303,6 +298,8 @@ ido_user_menu_item_set_icon_from_file_icon (IdoUserMenuItem *self,
gint height;
GdkPixbuf *pixbuf;
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
+
file = g_file_icon_get_file (G_FILE_ICON (icon));
path = g_file_get_path (file);
@@ -316,7 +313,7 @@ ido_user_menu_item_set_icon_from_file_icon (IdoUserMenuItem *self,
if (pixbuf)
{
- gtk_image_set_from_pixbuf (GTK_IMAGE (self->priv->user_image), pixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->user_image), pixbuf);
g_object_unref (pixbuf);
return TRUE;
}
@@ -331,15 +328,15 @@ ido_user_menu_item_set_icon_from_file_icon (IdoUserMenuItem *self,
void
ido_user_menu_item_set_icon (IdoUserMenuItem * self, GIcon * icon)
{
- IdoUserMenuItemPrivate * p = self->priv;
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
- if (p->icon == icon)
+ if (priv->icon == icon)
return;
- g_clear_object (&p->icon);
+ g_clear_object (&priv->icon);
if (icon)
- p->icon = g_object_ref (icon);
+ priv->icon = g_object_ref (icon);
/* Avatars are always loaded from disk. Show the fallback when no icon
* is set, the icon is not a file icon, or the file could not be
@@ -349,7 +346,7 @@ ido_user_menu_item_set_icon (IdoUserMenuItem * self, GIcon * icon)
!G_IS_FILE_ICON (icon) ||
!ido_user_menu_item_set_icon_from_file_icon (self, G_FILE_ICON (icon)))
{
- gtk_image_set_from_icon_name (GTK_IMAGE (p->user_image),
+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->user_image),
FALLBACK_ICON_NAME,
GTK_ICON_SIZE_MENU);
}
@@ -370,20 +367,26 @@ ido_user_menu_item_set_icon_from_file (IdoUserMenuItem * self, const char * file
void
ido_user_menu_item_set_logged_in (IdoUserMenuItem * self, gboolean is_logged_in)
{
- gtk_widget_set_visible (self->priv->tick_icon, is_logged_in);
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
+
+ gtk_widget_set_visible (priv->tick_icon, is_logged_in);
}
void
ido_user_menu_item_set_current_user (IdoUserMenuItem * self, gboolean is_current_user)
{
- self->priv->is_current_user = is_current_user;
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
+
+ priv->is_current_user = is_current_user;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
void
ido_user_menu_item_set_label (IdoUserMenuItem * self, const char * label)
{
- gtk_label_set_label (GTK_LABEL(self->priv->user_name), label);
+ IdoUserMenuItemPrivate * priv = ido_user_menu_item_get_instance_private(self);
+
+ gtk_label_set_label (GTK_LABEL(priv->user_name), label);
}
GtkWidget*
diff --git a/src/idousermenuitem.h b/src/idousermenuitem.h
index d1d5729..093078d 100644
--- a/src/idousermenuitem.h
+++ b/src/idousermenuitem.h
@@ -32,7 +32,6 @@ G_BEGIN_DECLS
typedef struct _IdoUserMenuItem IdoUserMenuItem;
typedef struct _IdoUserMenuItemClass IdoUserMenuItemClass;
-typedef struct _IdoUserMenuItemPrivate IdoUserMenuItemPrivate;
/* property keys */
#define IDO_USER_MENU_ITEM_PROP_LABEL "label"
@@ -49,7 +48,6 @@ struct _IdoUserMenuItem
{
/*< private >*/
GtkMenuItem parent;
- IdoUserMenuItemPrivate * priv;
};
GType ido_user_menu_item_get_type (void) G_GNUC_CONST;