[gnome-photos] print-operation: Make it a final class
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] print-operation: Make it a final class
- Date: Thu, 14 Apr 2016 07:48:43 +0000 (UTC)
commit 677c4245c45c64f44d01bf5acdb1716ec8b7e2df
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Apr 14 09:14:58 2016 +0200
print-operation: Make it a final class
src/photos-print-operation.c | 67 ++++++++++++++++++++----------------------
src/photos-print-operation.h | 28 +----------------
2 files changed, 34 insertions(+), 61 deletions(-)
---
diff --git a/src/photos-print-operation.c b/src/photos-print-operation.c
index ba4f427..0933900 100644
--- a/src/photos-print-operation.c
+++ b/src/photos-print-operation.c
@@ -35,8 +35,9 @@
#include "photos-utils.h"
-struct _PhotosPrintOperationPrivate
+struct _PhotosPrintOperation
{
+ GtkPrintOperation parent_instance;
GeglNode *node;
GtkUnit unit;
PhotosBaseItem *item;
@@ -45,6 +46,11 @@ struct _PhotosPrintOperationPrivate
gdouble scale_factor;
};
+struct _PhotosPrintOperationClass
+{
+ GtkPrintOperationClass parent_class;
+};
+
enum
{
@@ -54,20 +60,19 @@ enum
};
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosPrintOperation, photos_print_operation, GTK_TYPE_PRINT_OPERATION);
+G_DEFINE_TYPE (PhotosPrintOperation, photos_print_operation, GTK_TYPE_PRINT_OPERATION);
static void
photos_print_operation_custom_widget_apply (GtkPrintOperation *operation, GtkWidget *widget)
{
PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (operation);
- PhotosPrintOperationPrivate *priv = self->priv;
photos_print_setup_get_options (PHOTOS_PRINT_SETUP (widget),
- &priv->left_margin,
- &priv->top_margin,
- &priv->scale_factor,
- &priv->unit);
+ &self->left_margin,
+ &self->top_margin,
+ &self->scale_factor,
+ &self->unit);
}
@@ -79,7 +84,7 @@ photos_print_operation_create_custom_widget (GtkPrintOperation *operation)
GtkWidget *print_setup;
page_setup = gtk_print_operation_get_default_page_setup (GTK_PRINT_OPERATION (self));
- print_setup = photos_print_setup_new (self->priv->node, page_setup);
+ print_setup = photos_print_setup_new (self->node, page_setup);
return print_setup;
}
@@ -88,7 +93,6 @@ static void
photos_print_operation_draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr)
{
PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (operation);
- PhotosPrintOperationPrivate *priv = self->priv;
GeglRectangle bbox;
GdkPixbuf *pixbuf = NULL;
GtkPageSetup *page_setup;
@@ -101,21 +105,21 @@ photos_print_operation_draw_page (GtkPrintOperation *operation, GtkPrintContext
gdouble x0;
gdouble y0;
- scale_factor_n = priv->scale_factor / 100.0;
- bbox = gegl_node_get_bounding_box (priv->node);
+ scale_factor_n = self->scale_factor / 100.0;
+ bbox = gegl_node_get_bounding_box (self->node);
dpi_x = gtk_print_context_get_dpi_x (context);
dpi_y = gtk_print_context_get_dpi_x (context);
- switch (priv->unit)
+ switch (self->unit)
{
case GTK_UNIT_INCH:
- x0 = priv->left_margin * dpi_x;
- y0 = priv->top_margin * dpi_y;
+ x0 = self->left_margin * dpi_x;
+ y0 = self->top_margin * dpi_y;
break;
case GTK_UNIT_MM:
- x0 = priv->left_margin * dpi_x / 25.4;
- y0 = priv->top_margin * dpi_y / 25.4;
+ x0 = self->left_margin * dpi_x / 25.4;
+ y0 = self->top_margin * dpi_y / 25.4;
break;
case GTK_UNIT_NONE:
case GTK_UNIT_POINTS:
@@ -141,7 +145,7 @@ photos_print_operation_draw_page (GtkPrintOperation *operation, GtkPrintContext
cairo_clip (cr);
cairo_scale (cr, scale_factor_n, scale_factor_n);
- pixbuf = photos_utils_create_pixbuf_from_node (priv->node);
+ pixbuf = photos_utils_create_pixbuf_from_node (self->node);
if (pixbuf == NULL)
goto out;
@@ -167,7 +171,6 @@ static void
photos_print_operation_constructed (GObject *object)
{
PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (object);
- PhotosPrintOperationPrivate *priv = self->priv;
GeglRectangle bbox;
GtkPageSetup *page_setup;
gchar *name;
@@ -177,7 +180,7 @@ photos_print_operation_constructed (GObject *object)
page_setup = gtk_page_setup_new ();
gtk_print_operation_set_default_page_setup (GTK_PRINT_OPERATION (self), page_setup);
- bbox = gegl_node_get_bounding_box (priv->node);
+ bbox = gegl_node_get_bounding_box (self->node);
if (bbox.height >= bbox.width)
gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_PORTRAIT);
else
@@ -185,14 +188,14 @@ photos_print_operation_constructed (GObject *object)
g_object_unref (page_setup);
- name = g_strdup (photos_base_item_get_name (priv->item));
+ name = g_strdup (photos_base_item_get_name (self->item));
if (name == NULL || name[0] == '\0')
{
GFile *file;
const gchar *uri;
gchar *basename;
- uri = photos_base_item_get_uri (priv->item);
+ uri = photos_base_item_get_uri (self->item);
file = g_file_new_for_uri (uri);
basename = g_file_get_basename (file);
@@ -214,10 +217,9 @@ static void
photos_print_operation_dispose (GObject *object)
{
PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (object);
- PhotosPrintOperationPrivate *priv = self->priv;
- g_clear_object (&priv->item);
- g_clear_object (&priv->node);
+ g_clear_object (&self->item);
+ g_clear_object (&self->node);
G_OBJECT_CLASS (photos_print_operation_parent_class)->dispose (object);
}
@@ -234,16 +236,15 @@ static void
photos_print_operation_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (object);
- PhotosPrintOperationPrivate *priv = self->priv;
switch (prop_id)
{
case PROP_ITEM:
- priv->item = PHOTOS_BASE_ITEM (g_value_dup_object (value));
+ self->item = PHOTOS_BASE_ITEM (g_value_dup_object (value));
break;
case PROP_NODE:
- priv->node = GEGL_NODE (g_value_dup_object (value));
+ self->node = GEGL_NODE (g_value_dup_object (value));
break;
default:
@@ -256,16 +257,12 @@ photos_print_operation_set_property (GObject *object, guint prop_id, const GValu
static void
photos_print_operation_init (PhotosPrintOperation *self)
{
- PhotosPrintOperationPrivate *priv;
GtkPrintSettings *settings;
- self->priv = photos_print_operation_get_instance_private (self);
- priv = self->priv;
-
- priv->unit = GTK_UNIT_INCH;
- priv->left_margin = 0.0;
- priv->top_margin = 0.0;
- priv->scale_factor = 100.0;
+ self->unit = GTK_UNIT_INCH;
+ self->left_margin = 0.0;
+ self->top_margin = 0.0;
+ self->scale_factor = 100.0;
settings = gtk_print_settings_new ();
gtk_print_operation_set_print_settings (GTK_PRINT_OPERATION (self), settings);
diff --git a/src/photos-print-operation.h b/src/photos-print-operation.h
index 37b7300..6bd643d 100644
--- a/src/photos-print-operation.h
+++ b/src/photos-print-operation.h
@@ -38,36 +38,12 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
PHOTOS_TYPE_PRINT_OPERATION, PhotosPrintOperation))
-#define PHOTOS_PRINT_OPERATION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- PHOTOS_TYPE_PRINT_OPERATION, PhotosPrintOperationClass))
-
#define PHOTOS_IS_PRINT_OPERATION(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
PHOTOS_TYPE_PRINT_OPERATION))
-#define PHOTOS_IS_PRINT_OPERATION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- PHOTOS_TYPE_PRINT_OPERATION))
-
-#define PHOTOS_PRINT_OPERATION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- PHOTOS_TYPE_PRINT_OPERATION, PhotosPrintOperationClass))
-
-typedef struct _PhotosPrintOperation PhotosPrintOperation;
-typedef struct _PhotosPrintOperationClass PhotosPrintOperationClass;
-typedef struct _PhotosPrintOperationPrivate PhotosPrintOperationPrivate;
-
-struct _PhotosPrintOperation
-{
- GtkPrintOperation parent_instance;
- PhotosPrintOperationPrivate *priv;
-};
-
-struct _PhotosPrintOperationClass
-{
- GtkPrintOperationClass parent_class;
-};
+typedef struct _PhotosPrintOperation PhotosPrintOperation;
+typedef struct _PhotosPrintOperationClass PhotosPrintOperationClass;
GType photos_print_operation_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]