[cheese] Use new G_DEFINE_TYPE_WITH_PRIVATE macro
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Use new G_DEFINE_TYPE_WITH_PRIVATE macro
- Date: Sun, 17 Nov 2013 00:25:19 +0000 (UTC)
commit 3b3105828787f988c0865e4ef4117d0742f6b527
Author: David King <amigadave amigadave com>
Date: Sun Nov 17 00:20:28 2013 +0000
Use new G_DEFINE_TYPE_WITH_PRIVATE macro
libcheese/cheese-avatar-chooser.c | 10 +-
libcheese/cheese-avatar-widget.c | 10 +-
libcheese/cheese-camera-device-monitor.c | 22 +--
libcheese/cheese-camera.c | 16 +-
libcheese/cheese-effect.c | 11 +-
libcheese/cheese-fileutil.c | 11 +-
libcheese/cheese-flash.c | 10 +-
libcheese/cheese-widget.c | 10 +-
libcheese/totem-aspect-frame.c | 50 +++---
libcheese/totem-aspect-frame.h | 3 -
libcheese/um-crop-area.c | 310 +++++++++++++++--------------
libcheese/um-crop-area.h | 1 -
src/thumbview/cheese-thumb-view.c | 35 ++--
src/thumbview/eog-thumb-nav.c | 179 +++++++++--------
src/thumbview/eog-thumb-nav.h | 3 -
15 files changed, 326 insertions(+), 355 deletions(-)
---
diff --git a/libcheese/cheese-avatar-chooser.c b/libcheese/cheese-avatar-chooser.c
index be2fcd7..05e4eef 100644
--- a/libcheese/cheese-avatar-chooser.c
+++ b/libcheese/cheese-avatar-chooser.c
@@ -64,11 +64,7 @@ struct _CheeseAvatarChooserPrivate
static GParamSpec *properties[PROP_LAST];
-#define CHEESE_AVATAR_CHOOSER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_AVATAR_CHOOSER, \
- CheeseAvatarChooserPrivate))
-
-G_DEFINE_TYPE (CheeseAvatarChooser, cheese_avatar_chooser, GTK_TYPE_DIALOG);
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseAvatarChooser, cheese_avatar_chooser, GTK_TYPE_DIALOG);
static void
update_select_button (CheeseAvatarWidget *widget,
@@ -88,7 +84,7 @@ update_select_button (CheeseAvatarWidget *widget,
static void
cheese_avatar_chooser_init (CheeseAvatarChooser *chooser)
{
- CheeseAvatarChooserPrivate *priv = chooser->priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (chooser);
+ CheeseAvatarChooserPrivate *priv = chooser->priv = cheese_avatar_chooser_get_instance_private (chooser);
gtk_dialog_add_buttons (GTK_DIALOG (chooser),
_("_Cancel"),
@@ -151,8 +147,6 @@ cheese_avatar_chooser_class_init (CheeseAvatarChooserClass *klass)
G_PARAM_READABLE);
g_object_class_install_properties (object_class, PROP_LAST, properties);
-
- g_type_class_add_private (klass, sizeof (CheeseAvatarChooserPrivate));
}
/**
diff --git a/libcheese/cheese-avatar-widget.c b/libcheese/cheese-avatar-widget.c
index d101cf3..9f87c17 100644
--- a/libcheese/cheese-avatar-widget.c
+++ b/libcheese/cheese-avatar-widget.c
@@ -70,11 +70,7 @@ struct _CheeseAvatarWidgetPrivate
static GParamSpec *properties[PROP_LAST];
-#define CHEESE_AVATAR_WIDGET_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_AVATAR_WIDGET, \
- CheeseAvatarWidgetPrivate))
-
-G_DEFINE_TYPE (CheeseAvatarWidget, cheese_avatar_widget, GTK_TYPE_BIN);
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseAvatarWidget, cheese_avatar_widget, GTK_TYPE_BIN);
/*
* cheese_widget_photo_taken_cb:
@@ -239,7 +235,7 @@ cheese_avatar_widget_init (CheeseAvatarWidget *widget)
GtkWidget *frame;
GtkWidget *image;
- CheeseAvatarWidgetPrivate *priv = widget->priv = CHEESE_AVATAR_WIDGET_GET_PRIVATE (widget);
+ CheeseAvatarWidgetPrivate *priv = widget->priv = cheese_avatar_widget_get_instance_private (widget);
priv->flash = cheese_flash_new (GTK_WIDGET (widget));
@@ -332,8 +328,6 @@ cheese_avatar_widget_class_init (CheeseAvatarWidgetClass *klass)
G_PARAM_READABLE);
g_object_class_install_properties (object_class, PROP_LAST, properties);
-
- g_type_class_add_private (klass, sizeof (CheeseAvatarWidgetPrivate));
}
/**
diff --git a/libcheese/cheese-camera-device-monitor.c b/libcheese/cheese-camera-device-monitor.c
index 57cf042..4a660db 100644
--- a/libcheese/cheese-camera-device-monitor.c
+++ b/libcheese/cheese-camera-device-monitor.c
@@ -59,17 +59,6 @@
* CheeseCameraDeviceMonitor::removed signal when an event happens.
*/
-G_DEFINE_TYPE (CheeseCameraDeviceMonitor, cheese_camera_device_monitor, G_TYPE_OBJECT)
-
-#define CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
\
-
CHEESE_TYPE_CAMERA_DEVICE_MONITOR, \
-
CheeseCameraDeviceMonitorPrivate))
-
-#define CHEESE_CAMERA_DEVICE_MONITOR_ERROR cheese_camera_device_monitor_error_quark ()
-
-GST_DEBUG_CATEGORY (cheese_device_monitor_cat);
-#define GST_CAT_DEFAULT cheese_device_monitor_cat
-
struct _CheeseCameraDeviceMonitorPrivate
{
#ifdef HAVE_UDEV
@@ -79,6 +68,13 @@ struct _CheeseCameraDeviceMonitorPrivate
#endif /* HAVE_UDEV */
};
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseCameraDeviceMonitor, cheese_camera_device_monitor, G_TYPE_OBJECT)
+
+#define CHEESE_CAMERA_DEVICE_MONITOR_ERROR cheese_camera_device_monitor_error_quark ()
+
+GST_DEBUG_CATEGORY (cheese_device_monitor_cat);
+#define GST_CAT_DEFAULT cheese_device_monitor_cat
+
enum
{
ADDED,
@@ -424,15 +420,13 @@ cheese_camera_device_monitor_class_init (CheeseCameraDeviceMonitorClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
-
- g_type_class_add_private (klass, sizeof (CheeseCameraDeviceMonitorPrivate));
}
static void
cheese_camera_device_monitor_init (CheeseCameraDeviceMonitor *monitor)
{
#ifdef HAVE_UDEV
- CheeseCameraDeviceMonitorPrivate *priv = monitor->priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE
(monitor);
+ CheeseCameraDeviceMonitorPrivate *priv = monitor->priv = cheese_camera_device_monitor_get_instance_private
(monitor);
const gchar *const subsystems[] = {"video4linux", NULL};
priv->client = g_udev_client_new (subsystems);
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index b2ebc65..373d2c7 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -53,12 +53,6 @@
* #CheeseWidget.
*/
-G_DEFINE_TYPE (CheeseCamera, cheese_camera, G_TYPE_OBJECT)
-
-#define CHEESE_CAMERA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_CAMERA,
CheeseCameraPrivate))
-
-#define CHEESE_CAMERA_ERROR cheese_camera_error_quark ()
-
struct _CheeseCameraPrivate
{
GstBus *bus;
@@ -102,6 +96,12 @@ struct _CheeseCameraPrivate
CheeseCameraDeviceMonitor *monitor;
};
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseCamera, cheese_camera, G_TYPE_OBJECT)
+
+#define CHEESE_CAMERA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_CAMERA,
CheeseCameraPrivate))
+
+#define CHEESE_CAMERA_ERROR cheese_camera_error_quark ()
+
enum
{
PROP_0,
@@ -1464,14 +1464,12 @@ cheese_camera_class_init (CheeseCameraClass *klass)
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST, properties);
-
- g_type_class_add_private (klass, sizeof (CheeseCameraPrivate));
}
static void
cheese_camera_init (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = camera->priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv = cheese_camera_get_instance_private (camera);
priv->is_recording = FALSE;
priv->pipeline_is_playing = FALSE;
diff --git a/libcheese/cheese-effect.c b/libcheese/cheese-effect.c
index a6320e6..aa587a6 100644
--- a/libcheese/cheese-effect.c
+++ b/libcheese/cheese-effect.c
@@ -42,11 +42,6 @@ enum
static GParamSpec *properties[PROP_LAST];
-G_DEFINE_TYPE (CheeseEffect, cheese_effect, G_TYPE_OBJECT)
-
-#define CHEESE_EFFECT_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_EFFECT, CheeseEffectPrivate))
-
struct _CheeseEffectPrivate
{
gchar *name;
@@ -54,6 +49,8 @@ struct _CheeseEffectPrivate
GstElement *control_valve;
};
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseEffect, cheese_effect, G_TYPE_OBJECT)
+
static void
cheese_effect_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
@@ -124,8 +121,6 @@ cheese_effect_class_init (CheeseEffectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CheeseEffectPrivate));
-
object_class->get_property = cheese_effect_get_property;
object_class->set_property = cheese_effect_set_property;
object_class->finalize = cheese_effect_finalize;
@@ -252,7 +247,7 @@ cheese_effect_disable_preview (CheeseEffect *effect)
static void
cheese_effect_init (CheeseEffect *self)
{
- self->priv = CHEESE_EFFECT_GET_PRIVATE (self);
+ self->priv = cheese_effect_get_instance_private (self);
}
/**
diff --git a/libcheese/cheese-fileutil.c b/libcheese/cheese-fileutil.c
index 990b6d1..568c716 100644
--- a/libcheese/cheese-fileutil.c
+++ b/libcheese/cheese-fileutil.c
@@ -39,11 +39,6 @@
* for photos and videos.
*/
-G_DEFINE_TYPE (CheeseFileUtil, cheese_fileutil, G_TYPE_OBJECT)
-
-#define CHEESE_FILEUTIL_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_FILEUTIL, CheeseFileUtilPrivate))
-
struct _CheeseFileUtilPrivate
{
gchar *video_path;
@@ -52,6 +47,8 @@ struct _CheeseFileUtilPrivate
gchar *burst_raw_name;
};
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseFileUtil, cheese_fileutil, G_TYPE_OBJECT)
+
static gchar *
cheese_fileutil_get_path_before_224 (CheeseFileUtil *fileutil);
@@ -241,14 +238,12 @@ cheese_fileutil_class_init (CheeseFileUtilClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = cheese_fileutil_finalize;
-
- g_type_class_add_private (klass, sizeof (CheeseFileUtilPrivate));
}
static void
cheese_fileutil_init (CheeseFileUtil *fileutil)
{
- CheeseFileUtilPrivate *priv = fileutil->priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
+ CheeseFileUtilPrivate *priv = fileutil->priv = cheese_fileutil_get_instance_private (fileutil);
GSettings *settings;
diff --git a/libcheese/cheese-flash.c b/libcheese/cheese-flash.c
index 3ea9848..fc34311 100644
--- a/libcheese/cheese-flash.c
+++ b/libcheese/cheese-flash.c
@@ -55,10 +55,6 @@ static const guint FLASH_ANIMATION_RATE = 50;
/* When to consider the flash finished so we can stop fading */
static const gdouble FLASH_LOW_THRESHOLD = 0.01;
-G_DEFINE_TYPE (CheeseFlash, cheese_flash, GTK_TYPE_WINDOW);
-
-#define CHEESE_FLASH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_FLASH,
CheeseFlashPrivate))
-
/*
* CheeseFlashPrivate:
* @parent: the parent #GtkWidget, for choosing on which display to fire the
@@ -76,10 +72,12 @@ struct _CheeseFlashPrivate
guint fade_timeout_tag;
};
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseFlash, cheese_flash, GTK_TYPE_WINDOW)
+
static void
cheese_flash_init (CheeseFlash *self)
{
- CheeseFlashPrivate *priv = self->priv = CHEESE_FLASH_GET_PRIVATE (self);
+ CheeseFlashPrivate *priv = self->priv = cheese_flash_get_instance_private (self);
cairo_region_t *input_region;
GtkWindow *window = GTK_WINDOW (self);
const GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
@@ -156,8 +154,6 @@ cheese_flash_class_init (CheeseFlashClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CheeseFlashPrivate));
-
object_class->set_property = cheese_flash_set_property;
object_class->dispose = cheese_flash_dispose;
object_class->finalize = cheese_flash_finalize;
diff --git a/libcheese/cheese-widget.c b/libcheese/cheese-widget.c
index 5c51640..7ba1a82 100644
--- a/libcheese/cheese-widget.c
+++ b/libcheese/cheese-widget.c
@@ -66,11 +66,7 @@ struct _CheeseWidgetPrivate
GError *error;
};
-#define CHEESE_WIDGET_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_WIDGET, \
- CheeseWidgetPrivate))
-
-G_DEFINE_TYPE (CheeseWidget, cheese_widget, GTK_TYPE_NOTEBOOK);
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseWidget, cheese_widget, GTK_TYPE_NOTEBOOK);
void setup_camera (CheeseWidget *widget);
@@ -193,7 +189,7 @@ cheese_widget_set_problem_page (CheeseWidget *widget,
static void
cheese_widget_init (CheeseWidget *widget)
{
- CheeseWidgetPrivate *priv = widget->priv = CHEESE_WIDGET_GET_PRIVATE (widget);
+ CheeseWidgetPrivate *priv = widget->priv = cheese_widget_get_instance_private (widget);
GtkWidget *box;
ClutterActor *stage, *frame;
ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
@@ -398,8 +394,6 @@ cheese_widget_class_init (CheeseWidgetClass *klass)
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST, properties);
-
- g_type_class_add_private (klass, sizeof (CheeseWidgetPrivate));
}
/**
diff --git a/libcheese/totem-aspect-frame.c b/libcheese/totem-aspect-frame.c
index 7e72e08..98fb4e0 100644
--- a/libcheese/totem-aspect-frame.c
+++ b/libcheese/totem-aspect-frame.c
@@ -26,12 +26,13 @@
#include "totem-aspect-frame.h"
-G_DEFINE_TYPE (TotemAspectFrame, totem_aspect_frame, CLUTTER_TYPE_ACTOR)
+typedef struct
+{
+ guint expand : 1;
+ gdouble rotation;
+} TotemAspectFramePrivate;
-#define ASPECT_FRAME_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- TOTEM_TYPE_ASPECT_FRAME, \
- TotemAspectFramePrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (TotemAspectFrame, totem_aspect_frame, CLUTTER_TYPE_ACTOR)
enum
{
@@ -40,12 +41,6 @@ enum
PROP_EXPAND,
};
-struct _TotemAspectFramePrivate
-{
- guint expand : 1;
- gdouble rotation;
-};
-
static void
totem_aspect_frame_get_property (GObject *object,
@@ -184,7 +179,7 @@ totem_aspect_frame_set_rotation_internal (TotemAspectFrame *frame,
gdouble rotation,
gboolean animate)
{
- TotemAspectFramePrivate *priv = frame->priv;
+ TotemAspectFramePrivate *priv = totem_aspect_frame_get_instance_private (frame);
ClutterActor *actor;
gfloat frame_width, frame_height;
gfloat child_width, child_height;
@@ -243,7 +238,7 @@ totem_aspect_frame_allocate (ClutterActor *actor,
ClutterActorBox child_box;
gfloat aspect, child_aspect, width, height, box_width, box_height;
- TotemAspectFramePrivate *priv = TOTEM_ASPECT_FRAME (actor)->priv;
+ TotemAspectFramePrivate *priv = totem_aspect_frame_get_instance_private (TOTEM_ASPECT_FRAME (actor));
CLUTTER_ACTOR_CLASS (totem_aspect_frame_parent_class)->
allocate (actor, box, flags);
@@ -289,7 +284,7 @@ static void
totem_aspect_frame_paint (ClutterActor *actor)
{
ClutterActor *child;
- TotemAspectFramePrivate *priv = TOTEM_ASPECT_FRAME (actor)->priv;
+ TotemAspectFramePrivate *priv = totem_aspect_frame_get_instance_private (TOTEM_ASPECT_FRAME (actor));
child = clutter_actor_get_child_at_index (actor, 0);
@@ -316,7 +311,7 @@ totem_aspect_frame_pick (ClutterActor *actor,
{
ClutterActorBox box;
ClutterActor *child;
- TotemAspectFramePrivate *priv = TOTEM_ASPECT_FRAME (actor)->priv;
+ TotemAspectFramePrivate *priv = totem_aspect_frame_get_instance_private (TOTEM_ASPECT_FRAME (actor));
clutter_actor_get_allocation_box (actor, &box);
@@ -345,8 +340,6 @@ totem_aspect_frame_class_init (TotemAspectFrameClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
- g_type_class_add_private (klass, sizeof (TotemAspectFramePrivate));
-
object_class->get_property = totem_aspect_frame_get_property;
object_class->set_property = totem_aspect_frame_set_property;
object_class->dispose = totem_aspect_frame_dispose;
@@ -370,7 +363,6 @@ totem_aspect_frame_class_init (TotemAspectFrameClass *klass)
static void
totem_aspect_frame_init (TotemAspectFrame *self)
{
- self->priv = ASPECT_FRAME_PRIVATE (self);
clutter_actor_set_pivot_point (CLUTTER_ACTOR (self), 0.5f, 0.5f);
}
@@ -387,7 +379,7 @@ totem_aspect_frame_set_expand (TotemAspectFrame *frame, gboolean expand)
g_return_if_fail (TOTEM_IS_ASPECT_FRAME (frame));
- priv = frame->priv;
+ priv = totem_aspect_frame_get_instance_private (frame);
if (priv->expand != expand)
{
priv->expand = expand;
@@ -400,8 +392,11 @@ totem_aspect_frame_set_expand (TotemAspectFrame *frame, gboolean expand)
gboolean
totem_aspect_frame_get_expand (TotemAspectFrame *frame)
{
+ TotemAspectFramePrivate *priv;
+
g_return_val_if_fail (TOTEM_IS_ASPECT_FRAME (frame), FALSE);
- return frame->priv->expand;
+ priv = totem_aspect_frame_get_instance_private (frame);
+ return priv->expand;
}
void
@@ -417,34 +412,39 @@ void
totem_aspect_frame_set_rotation (TotemAspectFrame *frame,
gdouble rotation)
{
+ TotemAspectFramePrivate *priv;
+
g_return_if_fail (TOTEM_IS_ASPECT_FRAME (frame));
g_return_if_fail (fmod (rotation, 90.0) == 0.0);
+ priv = totem_aspect_frame_get_instance_private (frame);
rotation = fmod (rotation, 360.0);
/* When animating, make sure that we go in the right direction,
* otherwise we'll spin in the wrong direction going back to 0 from 270 */
- if (rotation == 0.0 && frame->priv->rotation == 270.0)
+ if (rotation == 0.0 && priv->rotation == 270.0)
rotation = 360.0;
- else if (rotation == 90.0 && frame->priv->rotation == 360.0)
+ else if (rotation == 90.0 && priv->rotation == 360.0)
totem_aspect_frame_set_rotation_internal (frame, 0.0, FALSE);
- else if (rotation == 270.0 && fmod (frame->priv->rotation, 360.0) == 0.0)
+ else if (rotation == 270.0 && fmod (priv->rotation, 360.0) == 0.0)
totem_aspect_frame_set_rotation_internal (frame, 360.0, FALSE);
g_debug ("Setting rotation to '%lf'", rotation);
- frame->priv->rotation = rotation;
+ priv->rotation = rotation;
totem_aspect_frame_set_rotation_internal (frame, rotation, TRUE);
}
gdouble
totem_aspect_frame_get_rotation (TotemAspectFrame *frame)
{
+ TotemAspectFramePrivate *priv;
gdouble rotation;
g_return_val_if_fail (TOTEM_IS_ASPECT_FRAME (frame), 0.0);
- rotation = fmod (frame->priv->rotation, 360.0);
+ priv = totem_aspect_frame_get_instance_private (frame);
+ rotation = fmod (priv->rotation, 360.0);
g_debug ("Got rotation %lf", rotation);
return rotation;
diff --git a/libcheese/totem-aspect-frame.h b/libcheese/totem-aspect-frame.h
index 4ed8408..59517f2 100644
--- a/libcheese/totem-aspect-frame.h
+++ b/libcheese/totem-aspect-frame.h
@@ -53,13 +53,10 @@ G_BEGIN_DECLS
typedef struct _TotemAspectFrame TotemAspectFrame;
typedef struct _TotemAspectFrameClass TotemAspectFrameClass;
-typedef struct _TotemAspectFramePrivate TotemAspectFramePrivate;
struct _TotemAspectFrame
{
ClutterActor parent;
-
- TotemAspectFramePrivate *priv;
};
struct _TotemAspectFrameClass
diff --git a/libcheese/um-crop-area.c b/libcheese/um-crop-area.c
index 95118ad..9deda38 100644
--- a/libcheese/um-crop-area.c
+++ b/libcheese/um-crop-area.c
@@ -54,7 +54,7 @@ struct _UmCropAreaPrivate {
gdouble aspect;
};
-G_DEFINE_TYPE (UmCropArea, um_crop_area, GTK_TYPE_DRAWING_AREA);
+G_DEFINE_TYPE_WITH_PRIVATE (UmCropArea, um_crop_area, GTK_TYPE_DRAWING_AREA)
/*
* shift_color_byte:
@@ -126,6 +126,7 @@ shift_colors (GdkPixbuf *pixbuf,
static void
update_pixbufs (UmCropArea *area)
{
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
gint width;
gint height;
GtkAllocation allocation;
@@ -140,13 +141,13 @@ update_pixbufs (UmCropArea *area)
gtk_widget_get_allocation (widget, &allocation);
context = gtk_widget_get_style_context (widget);
- if (area->priv->pixbuf == NULL ||
- gdk_pixbuf_get_width (area->priv->pixbuf) != allocation.width ||
- gdk_pixbuf_get_height (area->priv->pixbuf) != allocation.height) {
- if (area->priv->pixbuf != NULL)
- g_object_unref (area->priv->pixbuf);
- area->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- gdk_pixbuf_get_has_alpha (area->priv->browse_pixbuf),
+ if (priv->pixbuf == NULL ||
+ gdk_pixbuf_get_width (priv->pixbuf) != allocation.width ||
+ gdk_pixbuf_get_height (priv->pixbuf) != allocation.height) {
+ if (priv->pixbuf != NULL)
+ g_object_unref (priv->pixbuf);
+ priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ gdk_pixbuf_get_has_alpha (priv->browse_pixbuf),
8,
allocation.width, allocation.height);
@@ -154,10 +155,10 @@ update_pixbufs (UmCropArea *area)
pixel = (((gint)(color.red * 1.0)) << 16) |
(((gint)(color.green * 1.0)) << 8) |
((gint)(color.blue * 1.0));
- gdk_pixbuf_fill (area->priv->pixbuf, pixel);
+ gdk_pixbuf_fill (priv->pixbuf, pixel);
- width = gdk_pixbuf_get_width (area->priv->browse_pixbuf);
- height = gdk_pixbuf_get_height (area->priv->browse_pixbuf);
+ width = gdk_pixbuf_get_width (priv->browse_pixbuf);
+ height = gdk_pixbuf_get_height (priv->browse_pixbuf);
scale = allocation.height / (gdouble)height;
if (scale * width > allocation.width)
@@ -168,35 +169,35 @@ update_pixbufs (UmCropArea *area)
dest_x = (allocation.width - dest_width) / 2;
dest_y = (allocation.height - dest_height) / 2,
- gdk_pixbuf_scale (area->priv->browse_pixbuf,
- area->priv->pixbuf,
+ gdk_pixbuf_scale (priv->browse_pixbuf,
+ priv->pixbuf,
dest_x, dest_y,
dest_width, dest_height,
dest_x, dest_y,
scale, scale,
GDK_INTERP_BILINEAR);
- if (area->priv->color_shifted)
- g_object_unref (area->priv->color_shifted);
- area->priv->color_shifted = gdk_pixbuf_copy (area->priv->pixbuf);
- shift_colors (area->priv->color_shifted, -32, -32, -32, 0);
+ if (priv->color_shifted)
+ g_object_unref (priv->color_shifted);
+ priv->color_shifted = gdk_pixbuf_copy (priv->pixbuf);
+ shift_colors (priv->color_shifted, -32, -32, -32, 0);
- if (area->priv->scale == 0.0) {
+ if (priv->scale == 0.0) {
gdouble crop_scale;
- crop_scale = MIN (gdk_pixbuf_get_width (area->priv->pixbuf) / area->priv->base_width
* 0.8,
- gdk_pixbuf_get_height (area->priv->pixbuf) /
area->priv->base_height * 0.8);
- area->priv->crop.width = crop_scale * area->priv->base_width / scale;
- area->priv->crop.height = crop_scale * area->priv->base_height / scale;
- area->priv->crop.x = (gdk_pixbuf_get_width (area->priv->browse_pixbuf) -
area->priv->crop.width) / 2;
- area->priv->crop.y = (gdk_pixbuf_get_height (area->priv->browse_pixbuf) -
area->priv->crop.height) / 2;
+ crop_scale = MIN (gdk_pixbuf_get_width (priv->pixbuf) / priv->base_width * 0.8,
+ gdk_pixbuf_get_height (priv->pixbuf) / priv->base_height * 0.8);
+ priv->crop.width = crop_scale * priv->base_width / scale;
+ priv->crop.height = crop_scale * priv->base_height / scale;
+ priv->crop.x = (gdk_pixbuf_get_width (priv->browse_pixbuf) - priv->crop.width) / 2;
+ priv->crop.y = (gdk_pixbuf_get_height (priv->browse_pixbuf) - priv->crop.height) / 2;
}
- area->priv->scale = scale;
- area->priv->image.x = dest_x;
- area->priv->image.y = dest_y;
- area->priv->image.width = dest_width;
- area->priv->image.height = dest_height;
+ priv->scale = scale;
+ priv->image.x = dest_x;
+ priv->image.y = dest_y;
+ priv->image.width = dest_width;
+ priv->image.height = dest_height;
}
}
@@ -211,10 +212,12 @@ static void
crop_to_widget (UmCropArea *area,
GdkRectangle *crop)
{
- crop->x = area->priv->image.x + area->priv->crop.x * area->priv->scale;
- crop->y = area->priv->image.y + area->priv->crop.y * area->priv->scale;
- crop->width = area->priv->crop.width * area->priv->scale;
- crop->height = area->priv->crop.height * area->priv->scale;
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
+
+ crop->x = priv->image.x + priv->crop.x * priv->scale;
+ crop->y = priv->image.y + priv->crop.y * priv->scale;
+ crop->width = priv->crop.width * priv->scale;
+ crop->height = priv->crop.height * priv->scale;
}
/*
@@ -258,31 +261,32 @@ static gboolean
um_crop_area_draw (GtkWidget *widget,
cairo_t *cr)
{
+ UmCropArea *area = UM_CROP_AREA (widget);
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
GdkRectangle crop;
gint width, height;
- UmCropArea *uarea = UM_CROP_AREA (widget);
- if (uarea->priv->browse_pixbuf == NULL)
+ if (priv->browse_pixbuf == NULL)
return FALSE;
- update_pixbufs (uarea);
+ update_pixbufs (area);
- width = gdk_pixbuf_get_width (uarea->priv->pixbuf);
- height = gdk_pixbuf_get_height (uarea->priv->pixbuf);
- crop_to_widget (uarea, &crop);
+ width = gdk_pixbuf_get_width (priv->pixbuf);
+ height = gdk_pixbuf_get_height (priv->pixbuf);
+ crop_to_widget (area, &crop);
- gdk_cairo_set_source_pixbuf (cr, uarea->priv->color_shifted, 0, 0);
+ gdk_cairo_set_source_pixbuf (cr, priv->color_shifted, 0, 0);
cairo_rectangle (cr, 0, 0, width, crop.y);
cairo_rectangle (cr, 0, crop.y, crop.x, crop.height);
cairo_rectangle (cr, crop.x + crop.width, crop.y, width - crop.x - crop.width, crop.height);
cairo_rectangle (cr, 0, crop.y + crop.height, width, height - crop.y - crop.height);
cairo_fill (cr);
- gdk_cairo_set_source_pixbuf (cr, uarea->priv->pixbuf, 0, 0);
+ gdk_cairo_set_source_pixbuf (cr, priv->pixbuf, 0, 0);
cairo_rectangle (cr, crop.x, crop.y, crop.width, crop.height);
cairo_fill (cr);
- if (uarea->priv->active_region != OUTSIDE) {
+ if (priv->active_region != OUTSIDE) {
gint x1, x2, y1, y2;
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_set_line_width (cr, 1.0);
@@ -423,11 +427,12 @@ update_cursor (UmCropArea *area,
gint x,
gint y)
{
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
gint cursor_type;
GdkRectangle crop;
gint region;
- region = area->priv->active_region;
+ region = priv->active_region;
if (region == OUTSIDE) {
crop_to_widget (area, &crop);
region = find_location (&crop, x, y);
@@ -468,11 +473,11 @@ update_cursor (UmCropArea *area,
g_assert_not_reached ();
}
- if (cursor_type != area->priv->current_cursor) {
+ if (cursor_type != priv->current_cursor) {
GdkCursor *cursor = gdk_cursor_new (cursor_type);
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (area)), cursor);
g_object_unref (cursor);
- area->priv->current_cursor = cursor_type;
+ priv->current_cursor = cursor_type;
}
}
@@ -522,6 +527,7 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event)
{
UmCropArea *area = UM_CROP_AREA (widget);
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
gint x, y;
gint delta_x, delta_y;
gint width, height;
@@ -533,7 +539,7 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
gdouble center_x, center_y;
gint min_width, min_height;
- if (area->priv->browse_pixbuf == NULL)
+ if (priv->browse_pixbuf == NULL)
return FALSE;
update_cursor (area, event->x, event->y);
@@ -543,26 +549,26 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
damage.x - 1, damage.y - 1,
damage.width + 2, damage.height + 2);
- pb_width = gdk_pixbuf_get_width (area->priv->browse_pixbuf);
- pb_height = gdk_pixbuf_get_height (area->priv->browse_pixbuf);
+ pb_width = gdk_pixbuf_get_width (priv->browse_pixbuf);
+ pb_height = gdk_pixbuf_get_height (priv->browse_pixbuf);
- x = (event->x - area->priv->image.x) / area->priv->scale;
- y = (event->y - area->priv->image.y) / area->priv->scale;
+ x = (event->x - priv->image.x) / priv->scale;
+ y = (event->y - priv->image.y) / priv->scale;
- delta_x = x - area->priv->last_press_x;
- delta_y = y - area->priv->last_press_y;
- area->priv->last_press_x = x;
- area->priv->last_press_y = y;
+ delta_x = x - priv->last_press_x;
+ delta_y = y - priv->last_press_y;
+ priv->last_press_x = x;
+ priv->last_press_y = y;
- left = area->priv->crop.x;
- right = area->priv->crop.x + area->priv->crop.width - 1;
- top = area->priv->crop.y;
- bottom = area->priv->crop.y + area->priv->crop.height - 1;
+ left = priv->crop.x;
+ right = priv->crop.x + priv->crop.width - 1;
+ top = priv->crop.y;
+ bottom = priv->crop.y + priv->crop.height - 1;
center_x = (left + right) / 2.0;
center_y = (top + bottom) / 2.0;
- switch (area->priv->active_region) {
+ switch (priv->active_region) {
case INSIDE:
width = right - left + 1;
height = bottom - top + 1;
@@ -599,101 +605,101 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
break;
case TOP_LEFT:
- if (area->priv->aspect < 0) {
+ if (priv->aspect < 0) {
top = y;
left = x;
}
else if (y < eval_radial_line (center_x, center_y, left, top, x)) {
top = y;
- new_width = (bottom - top) * area->priv->aspect;
+ new_width = (bottom - top) * priv->aspect;
left = right - new_width;
}
else {
left = x;
- new_height = (right - left) / area->priv->aspect;
+ new_height = (right - left) / priv->aspect;
top = bottom - new_height;
}
break;
case TOP:
top = y;
- if (area->priv->aspect > 0) {
- new_width = (bottom - top) * area->priv->aspect;
+ if (priv->aspect > 0) {
+ new_width = (bottom - top) * priv->aspect;
right = left + new_width;
}
break;
case TOP_RIGHT:
- if (area->priv->aspect < 0) {
+ if (priv->aspect < 0) {
top = y;
right = x;
}
else if (y < eval_radial_line (center_x, center_y, right, top, x)) {
top = y;
- new_width = (bottom - top) * area->priv->aspect;
+ new_width = (bottom - top) * priv->aspect;
right = left + new_width;
}
else {
right = x;
- new_height = (right - left) / area->priv->aspect;
+ new_height = (right - left) / priv->aspect;
top = bottom - new_height;
}
break;
case LEFT:
left = x;
- if (area->priv->aspect > 0) {
- new_height = (right - left) / area->priv->aspect;
+ if (priv->aspect > 0) {
+ new_height = (right - left) / priv->aspect;
bottom = top + new_height;
}
break;
case BOTTOM_LEFT:
- if (area->priv->aspect < 0) {
+ if (priv->aspect < 0) {
bottom = y;
left = x;
}
else if (y < eval_radial_line (center_x, center_y, left, bottom, x)) {
left = x;
- new_height = (right - left) / area->priv->aspect;
+ new_height = (right - left) / priv->aspect;
bottom = top + new_height;
}
else {
bottom = y;
- new_width = (bottom - top) * area->priv->aspect;
+ new_width = (bottom - top) * priv->aspect;
left = right - new_width;
}
break;
case RIGHT:
right = x;
- if (area->priv->aspect > 0) {
- new_height = (right - left) / area->priv->aspect;
+ if (priv->aspect > 0) {
+ new_height = (right - left) / priv->aspect;
bottom = top + new_height;
}
break;
case BOTTOM_RIGHT:
- if (area->priv->aspect < 0) {
+ if (priv->aspect < 0) {
bottom = y;
right = x;
}
else if (y < eval_radial_line (center_x, center_y, right, bottom, x)) {
right = x;
- new_height = (right - left) / area->priv->aspect;
+ new_height = (right - left) / priv->aspect;
bottom = top + new_height;
}
else {
bottom = y;
- new_width = (bottom - top) * area->priv->aspect;
+ new_width = (bottom - top) * priv->aspect;
right = left + new_width;
}
break;
case BOTTOM:
bottom = y;
- if (area->priv->aspect > 0) {
- new_width = (bottom - top) * area->priv->aspect;
+ if (priv->aspect > 0) {
+ new_width = (bottom - top) * priv->aspect;
right= left + new_width;
}
break;
@@ -702,12 +708,12 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
return FALSE;
}
- min_width = area->priv->base_width / area->priv->scale;
- min_height = area->priv->base_height / area->priv->scale;
+ min_width = priv->base_width / priv->scale;
+ min_height = priv->base_height / priv->scale;
width = right - left + 1;
height = bottom - top + 1;
- if (area->priv->aspect < 0) {
+ if (priv->aspect < 0) {
if (left < 0)
left = 0;
if (top < 0)
@@ -720,7 +726,7 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
width = right - left + 1;
height = bottom - top + 1;
- switch (area->priv->active_region) {
+ switch (priv->active_region) {
case LEFT:
case TOP_LEFT:
case BOTTOM_LEFT:
@@ -737,7 +743,7 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
default: ;
}
- switch (area->priv->active_region) {
+ switch (priv->active_region) {
case TOP:
case TOP_LEFT:
case TOP_RIGHT:
@@ -758,17 +764,17 @@ um_crop_area_motion_notify_event (GtkWidget *widget,
if (left < 0 || top < 0 ||
right > pb_width || bottom > pb_height ||
width < min_width || height < min_height) {
- left = area->priv->crop.x;
- right = area->priv->crop.x + area->priv->crop.width - 1;
- top = area->priv->crop.y;
- bottom = area->priv->crop.y + area->priv->crop.height - 1;
+ left = priv->crop.x;
+ right = priv->crop.x + priv->crop.width - 1;
+ top = priv->crop.y;
+ bottom = priv->crop.y + priv->crop.height - 1;
}
}
- area->priv->crop.x = left;
- area->priv->crop.y = top;
- area->priv->crop.width = right - left + 1;
- area->priv->crop.height = bottom - top + 1;
+ priv->crop.x = left;
+ priv->crop.y = top;
+ priv->crop.width = right - left + 1;
+ priv->crop.height = bottom - top + 1;
crop_to_widget (area, &damage);
gtk_widget_queue_draw_area (widget,
@@ -793,16 +799,17 @@ um_crop_area_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
UmCropArea *area = UM_CROP_AREA (widget);
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
GdkRectangle crop;
- if (area->priv->browse_pixbuf == NULL)
+ if (priv->browse_pixbuf == NULL)
return FALSE;
crop_to_widget (area, &crop);
- area->priv->last_press_x = (event->x - area->priv->image.x) / area->priv->scale;
- area->priv->last_press_y = (event->y - area->priv->image.y) / area->priv->scale;
- area->priv->active_region = find_location (&crop, event->x, event->y);
+ priv->last_press_x = (event->x - priv->image.x) / priv->scale;
+ priv->last_press_y = (event->y - priv->image.y) / priv->scale;
+ priv->active_region = find_location (&crop, event->x, event->y);
gtk_widget_queue_draw_area (widget,
crop.x - 1, crop.y - 1,
@@ -826,16 +833,17 @@ um_crop_area_button_release_event (GtkWidget *widget,
GdkEventButton *event)
{
UmCropArea *area = UM_CROP_AREA (widget);
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
GdkRectangle crop;
- if (area->priv->browse_pixbuf == NULL)
+ if (priv->browse_pixbuf == NULL)
return FALSE;
crop_to_widget (area, &crop);
- area->priv->last_press_x = -1;
- area->priv->last_press_y = -1;
- area->priv->active_region = OUTSIDE;
+ priv->last_press_x = -1;
+ priv->last_press_y = -1;
+ priv->active_region = OUTSIDE;
gtk_widget_queue_draw_area (widget,
crop.x - 1, crop.y - 1,
@@ -847,19 +855,19 @@ um_crop_area_button_release_event (GtkWidget *widget,
static void
um_crop_area_finalize (GObject *object)
{
- UmCropArea *area = UM_CROP_AREA (object);
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (UM_CROP_AREA (object));
- if (area->priv->browse_pixbuf) {
- g_object_unref (area->priv->browse_pixbuf);
- area->priv->browse_pixbuf = NULL;
+ if (priv->browse_pixbuf) {
+ g_object_unref (priv->browse_pixbuf);
+ priv->browse_pixbuf = NULL;
}
- if (area->priv->pixbuf) {
- g_object_unref (area->priv->pixbuf);
- area->priv->pixbuf = NULL;
+ if (priv->pixbuf) {
+ g_object_unref (priv->pixbuf);
+ priv->pixbuf = NULL;
}
- if (area->priv->color_shifted) {
- g_object_unref (area->priv->color_shifted);
- area->priv->color_shifted = NULL;
+ if (priv->color_shifted) {
+ g_object_unref (priv->color_shifted);
+ priv->color_shifted = NULL;
}
G_OBJECT_CLASS (um_crop_area_parent_class)->finalize (object);
@@ -876,29 +884,26 @@ um_crop_area_class_init (UmCropAreaClass *klass)
widget_class->button_press_event = um_crop_area_button_press_event;
widget_class->button_release_event = um_crop_area_button_release_event;
widget_class->motion_notify_event = um_crop_area_motion_notify_event;
-
- g_type_class_add_private (klass, sizeof (UmCropAreaPrivate));
}
static void
um_crop_area_init (UmCropArea *area)
{
- area->priv = (G_TYPE_INSTANCE_GET_PRIVATE ((area), UM_TYPE_CROP_AREA,
- UmCropAreaPrivate));
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
gtk_widget_add_events (GTK_WIDGET (area), GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
- area->priv->scale = 0.0;
- area->priv->image.x = 0;
- area->priv->image.y = 0;
- area->priv->image.width = 0;
- area->priv->image.height = 0;
- area->priv->active_region = OUTSIDE;
- area->priv->base_width = 48;
- area->priv->base_height = 48;
- area->priv->aspect = 1;
+ priv->scale = 0.0;
+ priv->image.x = 0;
+ priv->image.y = 0;
+ priv->image.width = 0;
+ priv->image.height = 0;
+ priv->active_region = OUTSIDE;
+ priv->base_width = 48;
+ priv->base_height = 48;
+ priv->aspect = 1;
}
/*
@@ -926,19 +931,20 @@ um_crop_area_new (void)
GdkPixbuf *
um_crop_area_get_picture (UmCropArea *area)
{
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
gint width, height;
- if (area->priv->browse_pixbuf == NULL)
+ if (priv->browse_pixbuf == NULL)
return NULL;
- width = gdk_pixbuf_get_width (area->priv->browse_pixbuf);
- height = gdk_pixbuf_get_height (area->priv->browse_pixbuf);
- width = MIN (area->priv->crop.width, width - area->priv->crop.x);
- height = MIN (area->priv->crop.height, height - area->priv->crop.y);
+ width = gdk_pixbuf_get_width (priv->browse_pixbuf);
+ height = gdk_pixbuf_get_height (priv->browse_pixbuf);
+ width = MIN (priv->crop.width, width - priv->crop.x);
+ height = MIN (priv->crop.height, height - priv->crop.y);
- return gdk_pixbuf_new_subpixbuf (area->priv->browse_pixbuf,
- area->priv->crop.x,
- area->priv->crop.y,
+ return gdk_pixbuf_new_subpixbuf (priv->browse_pixbuf,
+ priv->crop.x,
+ priv->crop.y,
width, height);
}
@@ -954,15 +960,16 @@ void
um_crop_area_set_picture (UmCropArea *area,
GdkPixbuf *pixbuf)
{
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
gint width;
gint height;
- if (area->priv->browse_pixbuf) {
- g_object_unref (area->priv->browse_pixbuf);
- area->priv->browse_pixbuf = NULL;
+ if (priv->browse_pixbuf) {
+ g_object_unref (priv->browse_pixbuf);
+ priv->browse_pixbuf = NULL;
}
if (pixbuf) {
- area->priv->browse_pixbuf = g_object_ref (pixbuf);
+ priv->browse_pixbuf = g_object_ref (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
} else {
@@ -970,16 +977,16 @@ um_crop_area_set_picture (UmCropArea *area,
height = 0;
}
- area->priv->crop.width = 2 * area->priv->base_width;
- area->priv->crop.height = 2 * area->priv->base_height;
- area->priv->crop.x = (width - area->priv->crop.width) / 2;
- area->priv->crop.y = (height - area->priv->crop.height) / 2;
+ priv->crop.width = 2 * priv->base_width;
+ priv->crop.height = 2 * priv->base_height;
+ priv->crop.x = (width - priv->crop.width) / 2;
+ priv->crop.y = (height - priv->crop.height) / 2;
- area->priv->scale = 0.0;
- area->priv->image.x = 0;
- area->priv->image.y = 0;
- area->priv->image.width = 0;
- area->priv->image.height = 0;
+ priv->scale = 0.0;
+ priv->image.x = 0;
+ priv->image.y = 0;
+ priv->image.width = 0;
+ priv->image.height = 0;
gtk_widget_queue_draw (GTK_WIDGET (area));
}
@@ -997,11 +1004,12 @@ um_crop_area_set_min_size (UmCropArea *area,
gint width,
gint height)
{
- area->priv->base_width = width;
- area->priv->base_height = height;
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
+ priv->base_width = width;
+ priv->base_height = height;
- if (area->priv->aspect > 0) {
- area->priv->aspect = area->priv->base_width / (gdouble)area->priv->base_height;
+ if (priv->aspect > 0) {
+ priv->aspect = priv->base_width / (gdouble)priv->base_height;
}
}
@@ -1017,11 +1025,13 @@ void
um_crop_area_set_constrain_aspect (UmCropArea *area,
gboolean constrain)
{
+ UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
+
if (constrain) {
- area->priv->aspect = area->priv->base_width / (gdouble)area->priv->base_height;
+ priv->aspect = priv->base_width / (gdouble)priv->base_height;
}
else {
- area->priv->aspect = -1;
+ priv->aspect = -1;
}
}
diff --git a/libcheese/um-crop-area.h b/libcheese/um-crop-area.h
index b921008..ddd1e97 100644
--- a/libcheese/um-crop-area.h
+++ b/libcheese/um-crop-area.h
@@ -57,7 +57,6 @@ struct _UmCropAreaClass {
struct _UmCropArea {
/*< private >*/
GtkDrawingArea parent_instance;
- UmCropAreaPrivate *priv;
};
GType um_crop_area_get_type (void) G_GNUC_CONST;
diff --git a/src/thumbview/cheese-thumb-view.c b/src/thumbview/cheese-thumb-view.c
index 22bfccc..74d2dbb 100644
--- a/src/thumbview/cheese-thumb-view.c
+++ b/src/thumbview/cheese-thumb-view.c
@@ -38,11 +38,6 @@ const guint THUMB_VIEW_MINIMUM_HEIGHT = 100;
const gchar CHEESE_OLD_VIDEO_NAME_SUFFIX[] = ".ogv";
-#define CHEESE_THUMB_VIEW_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_THUMB_VIEW, CheeseThumbViewPrivate))
-
-G_DEFINE_TYPE (CheeseThumbView, cheese_thumb_view, GTK_TYPE_ICON_VIEW);
-
typedef struct
{
GtkListStore *store;
@@ -57,6 +52,8 @@ typedef struct
GQueue *thumbnails;
} CheeseThumbViewPrivate;
+G_DEFINE_TYPE_WITH_PRIVATE (CheeseThumbView, cheese_thumb_view, GTK_TYPE_ICON_VIEW);
+
enum
{
THUMBNAIL_PIXBUF_COLUMN,
@@ -98,7 +95,7 @@ cheese_thumb_view_idle_append_item (gpointer data)
if (item == NULL) return FALSE;
thumb_view = item->thumb_view;
- priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ priv = cheese_thumb_view_get_instance_private (thumb_view);
GnomeDesktopThumbnailFactory *factory = priv->factory;
@@ -189,7 +186,7 @@ cheese_thumb_view_idle_append_item (gpointer data)
static void
cheese_thumb_view_append_item (CheeseThumbView *thumb_view, GFile *file)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
GtkTreeIter iter;
GtkIconTheme *icon_theme;
@@ -323,7 +320,7 @@ cheese_thumb_view_append_item (CheeseThumbView *thumb_view, GFile *file)
void
cheese_thumb_view_remove_item (CheeseThumbView *thumb_view, GFile *file)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
gchar *filename;
GtkTreeIter iter;
@@ -420,7 +417,7 @@ cheese_thumb_view_monitor_cb (GFileMonitor *file_monitor,
char *photo_name;
GFile *photo_file;
- priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ priv = cheese_thumb_view_get_instance_private (thumb_view);
path_photos = cheese_fileutil_get_photo_path (priv->fileutil);
filename = g_file_get_path (file);
if (!strcmp(path_photos, filename))
@@ -576,7 +573,7 @@ cheese_thumb_view_get_n_selected (CheeseThumbView *thumbview)
static void
cheese_thumb_view_fill (CheeseThumbView *thumb_view)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
GDir *dir_videos, *dir_photos;
const char *path_videos, *path_photos;
@@ -643,7 +640,7 @@ static void
cheese_thumb_view_finalize (GObject *object)
{
CheeseThumbView *thumb_view = CHEESE_THUMB_VIEW (object);
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
g_object_unref (priv->store);
g_object_unref (priv->fileutil);
@@ -662,8 +659,6 @@ cheese_thumb_view_class_init (CheeseThumbViewClass *klass)
object_class->constructed = cheese_thumb_view_constructed;
object_class->finalize = cheese_thumb_view_finalize;
-
- g_type_class_add_private (klass, sizeof (CheeseThumbViewPrivate));
}
static void
@@ -672,7 +667,7 @@ cheese_thumb_view_row_inserted_cb (GtkTreeModel *tree_model,
GtkTreeIter *iter,
CheeseThumbView *thumb_view)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
priv->n_items++;
if (!priv->vertical)
@@ -686,7 +681,7 @@ cheese_thumb_view_row_deleted_cb (GtkTreeModel *tree_model,
GtkTreePath *path,
CheeseThumbView *thumb_view)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
priv->n_items--;
if (priv->n_items == 0)
@@ -700,7 +695,7 @@ cheese_thumb_view_row_deleted_cb (GtkTreeModel *tree_model,
static void
cheese_thumb_view_init (CheeseThumbView *thumb_view)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
priv->video_file_monitor = NULL;
priv->photo_file_monitor = NULL;
@@ -738,7 +733,7 @@ static void
cheese_thumb_view_constructed (GObject *object)
{
CheeseThumbView *thumb_view = CHEESE_THUMB_VIEW (object);
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
gtk_icon_view_set_model (GTK_ICON_VIEW (thumb_view), GTK_TREE_MODEL (priv->store));
@@ -778,7 +773,7 @@ cheese_thumb_view_new ()
void
cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
priv->vertical = vertical;
if (!priv->vertical && priv->n_items)
@@ -790,7 +785,7 @@ cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical)
void
cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumb_view, const char *path_photos)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
if (priv->photo_file_monitor != NULL)
return;
@@ -809,7 +804,7 @@ cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumb_view, cons
void
cheese_thumb_view_start_monitoring_video_path (CheeseThumbView *thumb_view, const char *path_videos)
{
- CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+ CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
if (priv->video_file_monitor != NULL)
return;
diff --git a/src/thumbview/eog-thumb-nav.c b/src/thumbview/eog-thumb-nav.c
index 8cec7f8..22dcd74 100644
--- a/src/thumbview/eog-thumb-nav.c
+++ b/src/thumbview/eog-thumb-nav.c
@@ -33,23 +33,7 @@
#include <string.h>
#include <math.h>
-#define EOG_THUMB_NAV_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), EOG_TYPE_THUMB_NAV, EogThumbNavPrivate))
-
-G_DEFINE_TYPE (EogThumbNav, eog_thumb_nav, GTK_TYPE_BOX);
-
-#define EOG_THUMB_NAV_SCROLL_INC 20
-#define EOG_THUMB_NAV_SCROLL_MOVE 20
-#define EOG_THUMB_NAV_SCROLL_TIMEOUT 20
-
-enum
-{
- PROP_SHOW_BUTTONS = 1,
- PROP_THUMB_VIEW,
- PROP_MODE
-};
-
-struct _EogThumbNavPrivate
+typedef struct
{
gboolean show_buttons;
gboolean vertical;
@@ -67,17 +51,31 @@ struct _EogThumbNavPrivate
GtkAdjustment *hadj;
GtkAdjustment *vadj;
GtkAdjustment *adj;
+} EogThumbNavPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (EogThumbNav, eog_thumb_nav, GTK_TYPE_BOX)
+
+#define EOG_THUMB_NAV_SCROLL_INC 20
+#define EOG_THUMB_NAV_SCROLL_MOVE 20
+#define EOG_THUMB_NAV_SCROLL_TIMEOUT 20
+
+enum
+{
+ PROP_SHOW_BUTTONS = 1,
+ PROP_THUMB_VIEW,
+ PROP_MODE
};
static gboolean
eog_thumb_nav_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
{
EogThumbNav *nav = EOG_THUMB_NAV (user_data);
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
gint inc = EOG_THUMB_NAV_SCROLL_INC * 3;
gdouble value, upper, page_size, delta_x, delta_y;
gboolean smooth;
- nav->priv->adj = nav->priv->vertical ? nav->priv->vadj : nav->priv->hadj;
+ priv->adj =priv->vertical ? priv->vadj : priv->hadj;
switch (event->direction)
{
@@ -107,17 +105,17 @@ eog_thumb_nav_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer u
return FALSE;
}
- value = gtk_adjustment_get_value (nav->priv->adj);
+ value = gtk_adjustment_get_value (priv->adj);
if (inc < 0)
- gtk_adjustment_set_value (nav->priv->adj, MAX (0, value + inc));
+ gtk_adjustment_set_value (priv->adj, MAX (0, value + inc));
else
{
- upper = gtk_adjustment_get_upper (nav->priv->adj);
- page_size = gtk_adjustment_get_page_size (nav->priv->adj);
- gtk_adjustment_set_value (nav->priv->adj, MIN (upper - page_size, value + inc));
+ upper = gtk_adjustment_get_upper (priv->adj);
+ page_size = gtk_adjustment_get_page_size (priv->adj);
+ gtk_adjustment_set_value (priv->adj, MIN (upper - page_size, value + inc));
}
- gtk_adjustment_value_changed (nav->priv->adj);
+ gtk_adjustment_value_changed (priv->adj);
return TRUE;
}
@@ -130,7 +128,7 @@ eog_thumb_nav_vadj_changed (GtkAdjustment *vadj, gpointer user_data)
gdouble value, upper, page_size;
nav = EOG_THUMB_NAV (user_data);
- priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ priv = eog_thumb_nav_get_instance_private (nav);
g_object_get (vadj,
"value", &value,
@@ -152,7 +150,7 @@ eog_thumb_nav_hadj_changed (GtkAdjustment *hadj, gpointer user_data)
gdouble value, upper, page_size;
nav = EOG_THUMB_NAV (user_data);
- priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ priv = eog_thumb_nav_get_instance_private (nav);
ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
g_object_get (hadj,
@@ -173,7 +171,7 @@ eog_thumb_nav_vadj_value_changed (GtkAdjustment *vadj, gpointer user_data)
gdouble value, upper, page_size;
nav = EOG_THUMB_NAV (user_data);
- priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ priv = eog_thumb_nav_get_instance_private (nav);
g_object_get (vadj,
"value", &value,
@@ -196,7 +194,7 @@ eog_thumb_nav_hadj_value_changed (GtkAdjustment *hadj, gpointer user_data)
gdouble value, upper, page_size;
nav = EOG_THUMB_NAV (user_data);
- priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ priv = eog_thumb_nav_get_instance_private (nav);
ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
g_object_get (hadj,
@@ -215,22 +213,23 @@ static gboolean
eog_thumb_nav_scroll_step (gpointer user_data)
{
EogThumbNav *nav = EOG_THUMB_NAV (user_data);
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
gint delta;
gdouble value, upper, page_size;
- if (nav->priv->scroll_pos < 10)
+ if (priv->scroll_pos < 10)
delta = EOG_THUMB_NAV_SCROLL_INC;
- else if (nav->priv->scroll_pos < 20)
+ else if (priv->scroll_pos < 20)
delta = EOG_THUMB_NAV_SCROLL_INC * 2;
- else if (nav->priv->scroll_pos < 30)
+ else if (priv->scroll_pos < 30)
delta = EOG_THUMB_NAV_SCROLL_INC * 2 + 5;
else
delta = EOG_THUMB_NAV_SCROLL_INC * 2 + 12;
- if (!nav->priv->scroll_dir)
+ if (!priv->scroll_dir)
delta *= -1;
- g_object_get (nav->priv->adj,
+ g_object_get (priv->adj,
"value", &value,
"upper", &upper,
"page_size", &page_size,
@@ -239,20 +238,20 @@ eog_thumb_nav_scroll_step (gpointer user_data)
if ((gint) (value + (gdouble) delta) >= 0 &&
(gint) (value + (gdouble) delta) <= upper - page_size)
{
- gtk_adjustment_set_value (nav->priv->adj, value + (gdouble) delta);
- nav->priv->scroll_pos++;
- gtk_adjustment_value_changed (nav->priv->adj);
+ gtk_adjustment_set_value (priv->adj, value + (gdouble) delta);
+ priv->scroll_pos++;
+ gtk_adjustment_value_changed (priv->adj);
}
else
{
if (delta > 0)
- gtk_adjustment_set_value (nav->priv->adj, upper - page_size);
+ gtk_adjustment_set_value (priv->adj, upper - page_size);
else
- gtk_adjustment_set_value (nav->priv->adj, 0);
+ gtk_adjustment_set_value (priv->adj, 0);
- nav->priv->scroll_pos = 0;
+ priv->scroll_pos = 0;
- gtk_adjustment_value_changed (nav->priv->adj);
+ gtk_adjustment_value_changed (priv->adj);
return G_SOURCE_REMOVE;
}
@@ -263,22 +262,24 @@ eog_thumb_nav_scroll_step (gpointer user_data)
static void
eog_thumb_nav_button_clicked (GtkButton *button, EogThumbNav *nav)
{
- nav->priv->scroll_pos = 0;
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
+
+ priv->scroll_pos = 0;
- if ((GTK_WIDGET (button) == nav->priv->button_right) ||
- (GTK_WIDGET (button) == nav->priv->button_left))
+ if ((GTK_WIDGET (button) == priv->button_right) ||
+ (GTK_WIDGET (button) == priv->button_left))
{
- nav->priv->scroll_dir = gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR ?
- GTK_WIDGET (button) == nav->priv->button_right :
- GTK_WIDGET (button) == nav->priv->button_left;
+ priv->scroll_dir = gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR ?
+ GTK_WIDGET (button) == priv->button_right :
+ GTK_WIDGET (button) == priv->button_left;
}
else
{
- nav->priv->scroll_dir = (GTK_WIDGET (button) == nav->priv->button_down);
+ priv->scroll_dir = (GTK_WIDGET (button) == priv->button_down);
}
- nav->priv->adj = ((GTK_WIDGET (button) == nav->priv->button_right) ||
- (GTK_WIDGET (button) == nav->priv->button_left)) ? nav->priv->hadj : nav->priv->vadj;
+ priv->adj = ((GTK_WIDGET (button) == priv->button_right) ||
+ (GTK_WIDGET (button) == priv->button_left)) ? priv->hadj : priv->vadj;
eog_thumb_nav_scroll_step (nav);
}
@@ -286,34 +287,38 @@ eog_thumb_nav_button_clicked (GtkButton *button, EogThumbNav *nav)
static void
eog_thumb_nav_start_scroll (GtkButton *button, EogThumbNav *nav)
{
- if ((GTK_WIDGET (button) == nav->priv->button_right) ||
- (GTK_WIDGET (button) == nav->priv->button_left))
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
+
+ if ((GTK_WIDGET (button) == priv->button_right) ||
+ (GTK_WIDGET (button) == priv->button_left))
{
- nav->priv->scroll_dir = gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR ?
- GTK_WIDGET (button) == nav->priv->button_right :
- GTK_WIDGET (button) == nav->priv->button_left;
+ priv->scroll_dir = gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR ?
+ GTK_WIDGET (button) == priv->button_right :
+ GTK_WIDGET (button) == priv->button_left;
}
else
{
- nav->priv->scroll_dir = (GTK_WIDGET (button) == nav->priv->button_down);
+ priv->scroll_dir = (GTK_WIDGET (button) == priv->button_down);
}
- nav->priv->adj = ((GTK_WIDGET (button) == nav->priv->button_right) ||
- (GTK_WIDGET (button) == nav->priv->button_left)) ? nav->priv->hadj : nav->priv->vadj;
+ priv->adj = ((GTK_WIDGET (button) == priv->button_right) ||
+ (GTK_WIDGET (button) == priv->button_left)) ? priv->hadj : priv->vadj;
- nav->priv->scroll_id = g_timeout_add (EOG_THUMB_NAV_SCROLL_TIMEOUT,
- eog_thumb_nav_scroll_step,
- nav);
+ priv->scroll_id = g_timeout_add (EOG_THUMB_NAV_SCROLL_TIMEOUT,
+ eog_thumb_nav_scroll_step,
+ nav);
}
static void
eog_thumb_nav_stop_scroll (GtkButton *button, EogThumbNav *nav)
{
- if (nav->priv->scroll_id > 0)
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
+
+ if (priv->scroll_id > 0)
{
- g_source_remove (nav->priv->scroll_id);
- nav->priv->scroll_id = 0;
- nav->priv->scroll_pos = 0;
+ g_source_remove (priv->scroll_id);
+ priv->scroll_id = 0;
+ priv->scroll_pos = 0;
}
}
@@ -324,6 +329,7 @@ eog_thumb_nav_get_property (GObject *object,
GParamSpec *pspec)
{
EogThumbNav *nav = EOG_THUMB_NAV (object);
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
switch (property_id)
{
@@ -333,7 +339,7 @@ eog_thumb_nav_get_property (GObject *object,
break;
case PROP_THUMB_VIEW:
- g_value_set_object (value, nav->priv->thumbview);
+ g_value_set_object (value, priv->thumbview);
break;
}
}
@@ -345,6 +351,7 @@ eog_thumb_nav_set_property (GObject *object,
GParamSpec *pspec)
{
EogThumbNav *nav = EOG_THUMB_NAV (object);
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
switch (property_id)
{
@@ -354,7 +361,7 @@ eog_thumb_nav_set_property (GObject *object,
break;
case PROP_THUMB_VIEW:
- nav->priv->thumbview =
+ priv->thumbview =
GTK_WIDGET (g_value_get_object (value));
break;
}
@@ -371,7 +378,7 @@ eog_thumb_nav_constructor (GType type,
object = G_OBJECT_CLASS (eog_thumb_nav_parent_class)->constructor
(type, n_construct_properties, construct_params);
- priv = EOG_THUMB_NAV_GET_PRIVATE (object);
+ priv = eog_thumb_nav_get_instance_private (EOG_THUMB_NAV (object));
if (priv->thumbview != NULL)
{
@@ -413,8 +420,6 @@ eog_thumb_nav_class_init (EogThumbNavClass *class)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
-
- g_type_class_add_private (g_object_class, sizeof (EogThumbNavPrivate));
}
static void
@@ -423,9 +428,7 @@ eog_thumb_nav_init (EogThumbNav *nav)
EogThumbNavPrivate *priv;
GtkWidget *arrow;
- nav->priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
-
- priv = nav->priv;
+ priv = eog_thumb_nav_get_instance_private (nav);
priv->show_buttons = TRUE;
priv->vertical = FALSE;
@@ -614,9 +617,11 @@ eog_thumb_nav_new (GtkWidget *thumbview,
gboolean
eog_thumb_nav_get_show_buttons (EogThumbNav *nav)
{
+ EogThumbNavPrivate *priv;
+
g_return_val_if_fail (EOG_IS_THUMB_NAV (nav), FALSE);
- return nav->priv->show_buttons;
+ return priv->show_buttons;
}
/**
@@ -630,21 +635,26 @@ eog_thumb_nav_get_show_buttons (EogThumbNav *nav)
void
eog_thumb_nav_set_show_buttons (EogThumbNav *nav, gboolean show_buttons)
{
+ EogThumbNavPrivate *priv;
+
g_return_if_fail (EOG_IS_THUMB_NAV (nav));
- g_return_if_fail (nav->priv->button_left != NULL);
- g_return_if_fail (nav->priv->button_right != NULL);
- nav->priv->show_buttons = show_buttons;
+ priv = eog_thumb_nav_get_instance_private (nav);
+
+ g_return_if_fail (priv->button_left != NULL);
+ g_return_if_fail (priv->button_right != NULL);
+
+ priv->show_buttons = show_buttons;
if (show_buttons)
{
- gtk_widget_show_all (nav->priv->button_left);
- gtk_widget_show_all (nav->priv->button_right);
+ gtk_widget_show_all (priv->button_left);
+ gtk_widget_show_all (priv->button_right);
}
else
{
- gtk_widget_hide (nav->priv->button_left);
- gtk_widget_hide (nav->priv->button_right);
+ gtk_widget_hide (priv->button_left);
+ gtk_widget_hide (priv->button_right);
}
}
@@ -653,7 +663,7 @@ eog_thumb_nav_set_policy (EogThumbNav *nav,
GtkPolicyType hscrollbar_policy,
GtkPolicyType vscrollbar_policy)
{
- EogThumbNavPrivate *priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
hscrollbar_policy,
@@ -663,7 +673,7 @@ eog_thumb_nav_set_policy (EogThumbNav *nav,
gboolean
eog_thumb_nav_is_vertical (EogThumbNav *nav)
{
- EogThumbNavPrivate *priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ EogThumbNavPrivate *priv = eog_thumb_nav_get_instance_private (nav);
return priv->vertical;
}
@@ -671,9 +681,12 @@ eog_thumb_nav_is_vertical (EogThumbNav *nav)
void
eog_thumb_nav_set_vertical (EogThumbNav *nav, gboolean vertical)
{
- EogThumbNavPrivate *priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+ EogThumbNavPrivate *priv;
g_return_if_fail (EOG_IS_THUMB_NAV (nav));
+
+ priv = eog_thumb_nav_get_instance_private (nav);
+
g_return_if_fail (priv->button_left != NULL);
g_return_if_fail (priv->button_right != NULL);
g_return_if_fail (priv->vbox != NULL);
diff --git a/src/thumbview/eog-thumb-nav.h b/src/thumbview/eog-thumb-nav.h
index a800410..5c37d49 100644
--- a/src/thumbview/eog-thumb-nav.h
+++ b/src/thumbview/eog-thumb-nav.h
@@ -32,7 +32,6 @@ G_BEGIN_DECLS
typedef struct _EogThumbNav EogThumbNav;
typedef struct _EogThumbNavClass EogThumbNavClass;
-typedef struct _EogThumbNavPrivate EogThumbNavPrivate;
#define EOG_TYPE_THUMB_NAV (eog_thumb_nav_get_type ())
#define EOG_THUMB_NAV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EOG_TYPE_THUMB_NAV, EogThumbNav))
@@ -44,8 +43,6 @@ typedef struct _EogThumbNavPrivate EogThumbNavPrivate;
struct _EogThumbNav
{
GtkBox base_instance;
-
- EogThumbNavPrivate *priv;
};
struct _EogThumbNavClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]