[gnome-photos/wip/foo: 9/10] EogPrintPreview -> PhotosPrintPreview



commit c857cdaef58a7bb25670ee87d2a0afbb0f9c0419
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Mar 26 19:32:11 2013 +0100

    EogPrintPreview -> PhotosPrintPreview

 src/Makefile.am                                    |    4 +-
 src/eog-print-preview.h                            |   90 --------
 ...{eog-print-preview.c => photos-print-preview.c} |  237 ++++++++++----------
 src/photos-print-preview.h                         |  102 +++++++++
 4 files changed, 224 insertions(+), 209 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ff45180..e97890a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,8 +43,6 @@ gnome_photos_SOURCES = \
        eog-metadata-reader-png.h \
        eog-print-image-setup.c \
        eog-print-image-setup.h \
-       eog-print-preview.c \
-       eog-print-preview.h \
        eog-transform.c \
        eog-transform.h \
        eog-uri-converter.c \
@@ -106,6 +104,8 @@ gnome_photos_SOURCES = \
        photos-preview-view.h \
        photos-print-operation.c \
        photos-print-operation.h \
+       photos-print-preview.c \
+       photos-print-preview.h \
        photos-properties-dialog.c \
        photos-properties-dialog.h \
        photos-query.c \
diff --git a/src/eog-print-preview.c b/src/photos-print-preview.c
similarity index 82%
rename from src/eog-print-preview.c
rename to src/photos-print-preview.c
index cedf949..5d97399 100644
--- a/src/eog-print-preview.c
+++ b/src/photos-print-preview.c
@@ -1,13 +1,12 @@
-/* Eye Of GNOME -- Print Preview Widget
- *
- * Copyright (C) 2006-2008 The Free Software Foundation
- *
- * Author: Claudio Saavedra <csaavedra gnome org>
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2006, 2007, 2008 The Free Software Foundation
+ * Copyright © 2013 Red Hat, Inc.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,21 +15,25 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* Based on code from:
+ *   + Eye of GNOME
  */
 
 #include <gtk/gtk.h>
 #include <cairo.h>
 #include <gdk/gdkkeysyms.h>
 
-#include "eog-print-preview.h"
+#include "photos-print-preview.h"
+
 
-#define EOG_PRINT_PREVIEW_GET_PRIVATE(object)                          \
-       (G_TYPE_INSTANCE_GET_PRIVATE ((object), EOG_TYPE_PRINT_PREVIEW, EogPrintPreviewPrivate))
+G_DEFINE_TYPE (PhotosPrintPreview, photos_print_preview, GTK_TYPE_ASPECT_FRAME);
 
-G_DEFINE_TYPE (EogPrintPreview, eog_print_preview, GTK_TYPE_ASPECT_FRAME)
 
-struct _EogPrintPreviewPrivate {
+struct _PhotosPrintPreviewPrivate {
        GtkWidget *area;
        GdkPixbuf *image;
        GdkPixbuf *image_scaled;
@@ -95,20 +98,20 @@ enum {
        PROP_PAGE_BOTTOM_MARGIN
 };
 
-static void eog_print_preview_draw (EogPrintPreview *preview, cairo_t *cr);
-static void eog_print_preview_finalize (GObject *object);
-static void update_relative_sizes (EogPrintPreview *preview);
-static void create_surface (EogPrintPreview *preview);
-static void create_image_scaled (EogPrintPreview *preview);
-static gboolean create_surface_when_idle (EogPrintPreview *preview);
+static void photos_print_preview_draw (PhotosPrintPreview *preview, cairo_t *cr);
+static void photos_print_preview_finalize (GObject *object);
+static void update_relative_sizes (PhotosPrintPreview *preview);
+static void create_surface (PhotosPrintPreview *preview);
+static void create_image_scaled (PhotosPrintPreview *preview);
+static gboolean create_surface_when_idle (PhotosPrintPreview *preview);
 
 static void
-eog_print_preview_get_property (GObject    *object,
+photos_print_preview_get_property (GObject    *object,
                                guint       prop_id,
                                GValue     *value,
                                GParamSpec *pspec)
 {
-       EogPrintPreviewPrivate *priv = EOG_PRINT_PREVIEW (object)->priv;
+       PhotosPrintPreviewPrivate *priv = PHOTOS_PRINT_PREVIEW (object)->priv;
 
        switch (prop_id) {
        case PROP_IMAGE:
@@ -147,12 +150,12 @@ eog_print_preview_get_property (GObject    *object,
 }
 
 static void
-eog_print_preview_set_property (GObject      *object,
+photos_print_preview_set_property (GObject      *object,
                                guint         prop_id,
                                const GValue *value,
                                GParamSpec   *pspec)
 {
-       EogPrintPreviewPrivate *priv = EOG_PRINT_PREVIEW (object)->priv;
+       PhotosPrintPreviewPrivate *priv = PHOTOS_PRINT_PREVIEW (object)->priv;
        gboolean paper_size_changed = FALSE;
 
        switch (prop_id) {
@@ -209,23 +212,23 @@ eog_print_preview_set_property (GObject      *object,
                              NULL);
        }
 
-       update_relative_sizes (EOG_PRINT_PREVIEW (object));
+       update_relative_sizes (PHOTOS_PRINT_PREVIEW (object));
        gtk_widget_queue_draw (priv->area);
 }
 
 static void
-eog_print_preview_class_init (EogPrintPreviewClass *klass)
+photos_print_preview_class_init (PhotosPrintPreviewClass *klass)
 {
        GObjectClass *gobject_class;
 
        gobject_class = (GObjectClass*) klass;
 
-       gobject_class->get_property = eog_print_preview_get_property;
-       gobject_class->set_property = eog_print_preview_set_property;
-       gobject_class->finalize     = eog_print_preview_finalize;
+       gobject_class->get_property = photos_print_preview_get_property;
+       gobject_class->set_property = photos_print_preview_set_property;
+       gobject_class->finalize     = photos_print_preview_finalize;
 
 /**
- * EogPrintPreview:image:
+ * PhotosPrintPreview:image:
  *
  * The "image" property defines the image that is previewed
  * in the widget.
@@ -239,7 +242,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:image-x-align:
+ * PhotosPrintPreview:image-x-align:
  *
  * The "image-x-align" property defines the horizontal alignment
  * of the image in the widget.
@@ -255,7 +258,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:image-y-align:
+ * PhotosPrintPreview:image-y-align:
  *
  * The "image-y-align" property defines the horizontal alignment
  * of the image in the widget.
@@ -271,7 +274,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:image-scale:
+ * PhotosPrintPreview:image-scale:
  *
  * The "image-scale" property defines the scaling of the image
  * that the user wants for the printing.
@@ -287,7 +290,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:paper-width:
+ * PhotosPrintPreview:paper-width:
  *
  * The width of the previewed paper, in inches.
  */
@@ -302,7 +305,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                             G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:paper-height:
+ * PhotosPrintPreview:paper-height:
  *
  * The height of the previewed paper, in inches.
  */
@@ -317,7 +320,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:page-left-margin:
+ * PhotosPrintPreview:page-left-margin:
  *
  * The size of the page's left margin, in inches.
  */
@@ -332,7 +335,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                             G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:page-right-margin:
+ * PhotosPrintPreview:page-right-margin:
  *
  * The size of the page's right margin, in inches.
  */
@@ -346,7 +349,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              0.25,
                                                              G_PARAM_READWRITE));
 /**
- * EogPrintPreview:page-top-margin:
+ * PhotosPrintPreview:page-top-margin:
  *
  * The size of the page's top margin, in inches.
  */
@@ -361,7 +364,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview:page-bottom-margin:
+ * PhotosPrintPreview:page-bottom-margin:
  *
  * The size of the page's bottom margin, in inches.
  */
@@ -376,10 +379,10 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                                                              G_PARAM_READWRITE));
 
 /**
- * EogPrintPreview::image-moved:
+ * PhotosPrintPreview::image-moved:
  * @preview: the object which received the signal
  *
- * The #EogPrintPreview::image-moved signal is emitted when the position
+ * The #PhotosPrintPreview::image-moved signal is emitted when the position
  * of the image is changed.
  */
        preview_signals [SIGNAL_IMAGE_MOVED] =
@@ -390,7 +393,7 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                              0, NULL);
 
 /**
- * EogPrintPreview::image-scaled:
+ * PhotosPrintPreview::image-scaled:
  * @preview: the object which received the signal
  *
  * The ::image-scaled signal is emmited when the scale of the image is changed.
@@ -402,15 +405,15 @@ eog_print_preview_class_init (EogPrintPreviewClass *klass)
                              g_cclosure_marshal_VOID__VOID, G_TYPE_NONE,
                              0, NULL);
 
-       g_type_class_add_private (klass, sizeof (EogPrintPreviewPrivate));
+       g_type_class_add_private (klass, sizeof (PhotosPrintPreviewPrivate));
 }
 
 static void
-eog_print_preview_finalize (GObject *object)
+photos_print_preview_finalize (GObject *object)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
 
-       priv = EOG_PRINT_PREVIEW (object)->priv;
+       priv = PHOTOS_PRINT_PREVIEW (object)->priv;
 
        if (priv->image) {
                g_object_unref (priv->image);
@@ -427,16 +430,16 @@ eog_print_preview_finalize (GObject *object)
                priv->surface = NULL;
        }
 
-       G_OBJECT_CLASS (eog_print_preview_parent_class)->finalize (object);
+       G_OBJECT_CLASS (photos_print_preview_parent_class)->finalize (object);
 }
 
 static void
-eog_print_preview_init (EogPrintPreview *preview)
+photos_print_preview_init (PhotosPrintPreview *preview)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        gfloat ratio;
 
-       priv = preview->priv = EOG_PRINT_PREVIEW_GET_PRIVATE (preview);
+       priv = preview->priv = PHOTOS_PRINT_PREVIEW_GET_PRIVATE (preview);
 
        priv->area = GTK_WIDGET (gtk_drawing_area_new ());
 
@@ -482,22 +485,22 @@ static gboolean draw_cb (GtkDrawingArea *drawing_area, cairo_t *cr, gpointer  us
 static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data);
 
 /**
- * eog_print_preview_new_with_pixbuf:
+ * photos_print_preview_new_with_pixbuf:
  * @pixbuf: a #GdkPixbuf
  *
- * Creates a new #EogPrintPreview widget, and sets the #GdkPixbuf to preview
+ * Creates a new #PhotosPrintPreview widget, and sets the #GdkPixbuf to preview
  * on it.
  *
- * Returns: A new #EogPrintPreview widget.
+ * Returns: A new #PhotosPrintPreview widget.
  **/
 GtkWidget *
-eog_print_preview_new_with_pixbuf (GdkPixbuf *pixbuf)
+photos_print_preview_new_with_pixbuf (GdkPixbuf *pixbuf)
 {
-       EogPrintPreview *preview;
+       PhotosPrintPreview *preview;
 
        g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
 
-       preview = EOG_PRINT_PREVIEW (eog_print_preview_new ());
+       preview = PHOTOS_PRINT_PREVIEW (photos_print_preview_new ());
 
        preview->priv->image = g_object_ref (pixbuf);
 
@@ -507,21 +510,21 @@ eog_print_preview_new_with_pixbuf (GdkPixbuf *pixbuf)
 }
 
 /**
- * eog_print_preview_new:
+ * photos_print_preview_new:
  *
- * Creates a new #EogPrintPreview widget, setting it to the default values,
- * and leaving the page empty. You still need to set the #EogPrintPreview:image
+ * Creates a new #PhotosPrintPreview widget, setting it to the default values,
+ * and leaving the page empty. You still need to set the #PhotosPrintPreview:image
  * property to make it useful.
  *
- * Returns: A new and empty #EogPrintPreview widget.
+ * Returns: A new and empty #PhotosPrintPreview widget.
  **/
 GtkWidget *
-eog_print_preview_new (void)
+photos_print_preview_new (void)
 {
-       EogPrintPreview *preview;
+       PhotosPrintPreview *preview;
        GtkWidget *area;
 
-       preview = g_object_new (EOG_TYPE_PRINT_PREVIEW, NULL);
+       preview = g_object_new (PHOTOS_TYPE_PRINT_PREVIEW, NULL);
 
        area = preview->priv->area;
 
@@ -565,9 +568,9 @@ draw_cb (GtkDrawingArea *drawing_area,
                 cairo_t *cr,
                 gpointer  user_data)
 {
-       update_relative_sizes (EOG_PRINT_PREVIEW (user_data));
+       update_relative_sizes (PHOTOS_PRINT_PREVIEW (user_data));
 
-       eog_print_preview_draw (EOG_PRINT_PREVIEW (user_data), cr);
+       photos_print_preview_draw (PHOTOS_PRINT_PREVIEW (user_data), cr);
 
        if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
                fprintf (stderr, "Cairo is unhappy: %s\n",
@@ -579,7 +582,7 @@ draw_cb (GtkDrawingArea *drawing_area,
 
 /**
  * get_current_image_coordinates:
- * @preview: an #EogPrintPreview
+ * @preview: an #PhotosPrintPreview
  * @x0: A pointer where to store the x coordinate.
  * @y0: A pointer where to store the y coordinate.
  *
@@ -587,10 +590,10 @@ draw_cb (GtkDrawingArea *drawing_area,
  * with the properties of the given @preview widget.
  **/
 static void
-get_current_image_coordinates (EogPrintPreview *preview,
+get_current_image_coordinates (PhotosPrintPreview *preview,
                               gint *x0, gint *y0)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        GtkAllocation allocation;
 
        priv = preview->priv;
@@ -602,7 +605,7 @@ get_current_image_coordinates (EogPrintPreview *preview,
 
 /**
  * press_inside_image_area:
- * @preview: an #EogPrintPreview
+ * @preview: an #PhotosPrintPreview
  * @x: the points x coordinate
  * @y: the points y coordinate
  *
@@ -612,11 +615,11 @@ get_current_image_coordinates (EogPrintPreview *preview,
  * %FALSE otherwise.
  **/
 static gboolean
-press_inside_image_area (EogPrintPreview *preview,
+press_inside_image_area (PhotosPrintPreview *preview,
                         guint x,
                         guint y)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        gint x0, y0;
 
        priv = preview->priv;
@@ -630,19 +633,19 @@ press_inside_image_area (EogPrintPreview *preview,
 }
 
 gboolean
-eog_print_preview_point_in_image_area (EogPrintPreview *preview,
+photos_print_preview_point_in_image_area (PhotosPrintPreview *preview,
                                       guint x,
                                       guint y)
 {
-       g_return_val_if_fail (EOG_IS_PRINT_PREVIEW (preview), FALSE);
+       g_return_val_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview), FALSE);
 
        return press_inside_image_area (preview, x, y);
 }
 
 static void
-create_image_scaled (EogPrintPreview *preview)
+create_image_scaled (PhotosPrintPreview *preview)
 {
-       EogPrintPreviewPrivate *priv = preview->priv;
+       PhotosPrintPreviewPrivate *priv = preview->priv;
 
        if (!priv->image_scaled) {
                gint i_width, i_height;
@@ -669,7 +672,7 @@ create_image_scaled (EogPrintPreview *preview)
 }
 
 static GdkPixbuf *
-create_preview_buffer (EogPrintPreview *preview)
+create_preview_buffer (PhotosPrintPreview *preview)
 {
        GdkPixbuf *pixbuf;
        gint width, height;
@@ -798,9 +801,9 @@ create_surface_from_pixbuf (GdkPixbuf *pixbuf)
 }
 
 static void
-create_surface (EogPrintPreview *preview)
+create_surface (PhotosPrintPreview *preview)
 {
-       EogPrintPreviewPrivate *priv = preview->priv;
+       PhotosPrintPreviewPrivate *priv = preview->priv;
        GdkPixbuf *pixbuf;
 
        if (priv->surface) {
@@ -817,7 +820,7 @@ create_surface (EogPrintPreview *preview)
 }
 
 static gboolean
-create_surface_when_idle (EogPrintPreview *preview)
+create_surface_when_idle (PhotosPrintPreview *preview)
 {
        create_surface (preview);
 
@@ -829,7 +832,7 @@ button_press_event_cb (GtkWidget *widget,
                       GdkEventButton *event,
                       gpointer user_data)
 {
-       EogPrintPreview *preview = EOG_PRINT_PREVIEW (user_data);
+       PhotosPrintPreview *preview = PHOTOS_PRINT_PREVIEW (user_data);
 
        preview->priv->cursorx = event->x;
        preview->priv->cursory = event->y;
@@ -854,7 +857,7 @@ button_release_event_cb (GtkWidget *widget,
                         GdkEventButton *event,
                         gpointer user_data)
 {
-       EogPrintPreview *preview = EOG_PRINT_PREVIEW (user_data);
+       PhotosPrintPreview *preview = PHOTOS_PRINT_PREVIEW (user_data);
 
        switch (event->button) {
        case 1:
@@ -922,7 +925,7 @@ motion_notify_event_cb (GtkWidget      *widget,
                        GdkEventMotion *event,
                        gpointer        user_data)
 {
-       EogPrintPreviewPrivate *priv = EOG_PRINT_PREVIEW (user_data)->priv;
+       PhotosPrintPreviewPrivate *priv = PHOTOS_PRINT_PREVIEW (user_data)->priv;
        gdouble dx, dy;
        GtkAllocation allocation;
 
@@ -950,7 +953,7 @@ motion_notify_event_cb (GtkWidget      *widget,
                        priv->r_dy = 0;
 
                /* we do this to correctly change the property values */
-               g_object_set (EOG_PRINT_PREVIEW (user_data),
+               g_object_set (PHOTOS_PRINT_PREVIEW (user_data),
                              "image-x-align", priv->image_x_align,
                              "image-y-align", priv->image_y_align,
                              NULL);
@@ -962,7 +965,7 @@ motion_notify_event_cb (GtkWidget      *widget,
                               preview_signals
                               [SIGNAL_IMAGE_MOVED], 0);
        } else {
-               if (press_inside_image_area (EOG_PRINT_PREVIEW (user_data), event->x, event->y)) {
+               if (press_inside_image_area (PHOTOS_PRINT_PREVIEW (user_data), event->x, event->y)) {
                        GdkCursor *cursor;
                        cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
                                                             GDK_FLEUR);
@@ -982,9 +985,9 @@ size_allocate_cb (GtkWidget *widget,
                  GtkAllocation *allocation,
                  gpointer user_data)
 {
-       EogPrintPreview *preview;
+       PhotosPrintPreview *preview;
 
-       preview = EOG_PRINT_PREVIEW (user_data);
+       preview = PHOTOS_PRINT_PREVIEW (user_data);
        update_relative_sizes (preview);
 
        preview->priv->flag_create_surface = TRUE;
@@ -998,9 +1001,9 @@ size_allocate_cb (GtkWidget *widget,
 }
 
 static void
-eog_print_preview_draw (EogPrintPreview *preview, cairo_t *cr)
+photos_print_preview_draw (PhotosPrintPreview *preview, cairo_t *cr)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        GtkWidget *area;
        GtkAllocation allocation;
        gint x0, y0;
@@ -1070,9 +1073,9 @@ eog_print_preview_draw (EogPrintPreview *preview, cairo_t *cr)
 }
 
 static void
-update_relative_sizes (EogPrintPreview *preview)
+update_relative_sizes (PhotosPrintPreview *preview)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        GtkAllocation allocation;
        gint i_width, i_height;
 
@@ -1099,8 +1102,8 @@ update_relative_sizes (EogPrintPreview *preview)
 }
 
 /**
- * eog_print_preview_set_page_margins:
- * @preview: a #EogPrintPreview
+ * photos_print_preview_set_page_margins:
+ * @preview: a #PhotosPrintPreview
  * @l_margin: Left margin.
  * @r_margin: Right margin.
  * @t_margin: Top margin.
@@ -1109,13 +1112,13 @@ update_relative_sizes (EogPrintPreview *preview)
  * Manually set the margins, in inches.
  **/
 void
-eog_print_preview_set_page_margins (EogPrintPreview *preview,
+photos_print_preview_set_page_margins (PhotosPrintPreview *preview,
                                    gfloat l_margin,
                                    gfloat r_margin,
                                    gfloat t_margin,
                                    gfloat b_margin)
 {
-       g_return_if_fail (EOG_IS_PRINT_PREVIEW (preview));
+       g_return_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview));
 
        g_object_set (G_OBJECT(preview),
                      "page-left-margin",   l_margin,
@@ -1126,18 +1129,18 @@ eog_print_preview_set_page_margins (EogPrintPreview *preview,
 }
 
 /**
- * eog_print_preview_set_from_page_setup:
- * @preview: a #EogPrintPreview
+ * photos_print_preview_set_from_page_setup:
+ * @preview: a #PhotosPrintPreview
  * @setup: a #GtkPageSetup to set the properties from
  *
  * Sets up the page properties from a #GtkPageSetup. Useful when using the
  * widget with the GtkPrint API.
  **/
 void
-eog_print_preview_set_from_page_setup (EogPrintPreview *preview,
+photos_print_preview_set_from_page_setup (PhotosPrintPreview *preview,
                                       GtkPageSetup *setup)
 {
-       g_return_if_fail (EOG_IS_PRINT_PREVIEW (preview));
+       g_return_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview));
        g_return_if_fail (GTK_IS_PAGE_SETUP (setup));
 
        g_object_set (G_OBJECT (preview),
@@ -1152,8 +1155,8 @@ eog_print_preview_set_from_page_setup (EogPrintPreview *preview,
 }
 
 /**
- * eog_print_preview_get_image_position:
- * @preview: a #EogPrintPreview
+ * photos_print_preview_get_image_position:
+ * @preview: a #PhotosPrintPreview
  * @x: a pointer to a #gdouble, or %NULL to ignore it
  * @y: a pointer to a #gdouble, or %NULL to ignore it
  *
@@ -1161,14 +1164,14 @@ eog_print_preview_set_from_page_setup (EogPrintPreview *preview,
  * (0, 0) position is the intersection between the left and top margins.
  **/
 void
-eog_print_preview_get_image_position (EogPrintPreview *preview,
+photos_print_preview_get_image_position (PhotosPrintPreview *preview,
                                      gdouble *x,
                                      gdouble *y)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        gdouble width, height;
 
-       g_return_if_fail (EOG_IS_PRINT_PREVIEW (preview));
+       g_return_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview));
 
        priv = preview->priv;
 
@@ -1183,8 +1186,8 @@ eog_print_preview_get_image_position (EogPrintPreview *preview,
 }
 
 /**
- * eog_print_preview_set_image_position:
- * @preview: a #EogPrintPreview
+ * photos_print_preview_set_image_position:
+ * @preview: a #PhotosPrintPreview
  * @x: The X coordinate, in inches, or -1 to ignore it.
  * @y: The Y coordinate, in inches, or -1 to ignore it.
  *
@@ -1192,15 +1195,15 @@ eog_print_preview_get_image_position (EogPrintPreview *preview,
  * only want to set the other.
  **/
 void
-eog_print_preview_set_image_position (EogPrintPreview *preview,
+photos_print_preview_set_image_position (PhotosPrintPreview *preview,
                                      gdouble x,
                                      gdouble y)
 {
-       EogPrintPreviewPrivate *priv;
+       PhotosPrintPreviewPrivate *priv;
        gfloat x_align, y_align;
        gdouble width, height;
 
-       g_return_if_fail (EOG_IS_PRINT_PREVIEW (preview));
+       g_return_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview));
 
        priv = preview->priv;
 
@@ -1218,17 +1221,17 @@ eog_print_preview_set_image_position (EogPrintPreview *preview,
 }
 
 /**
- * eog_print_preview_set_scale:
- * @preview: a #EogPrintPreview
+ * photos_print_preview_set_scale:
+ * @preview: a #PhotosPrintPreview
  * @scale: a scale value, between 0 and 1.
  *
  * Sets the scale for the image.
  **/
 void
-eog_print_preview_set_scale (EogPrintPreview *preview,
+photos_print_preview_set_scale (PhotosPrintPreview *preview,
                             gfloat           scale)
 {
-       g_return_if_fail (EOG_IS_PRINT_PREVIEW (preview));
+       g_return_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview));
 
        g_object_set (preview,
                      "image-scale", scale,
@@ -1241,19 +1244,19 @@ eog_print_preview_set_scale (EogPrintPreview *preview,
 }
 
 /**
- * eog_print_preview_get_scale:
- * @preview: A #EogPrintPreview.
+ * photos_print_preview_get_scale:
+ * @preview: A #PhotosPrintPreview.
  *
  * Gets the scale for the image.
  *
  * Returns: The scale for the image.
  **/
 gfloat
-eog_print_preview_get_scale (EogPrintPreview *preview)
+photos_print_preview_get_scale (PhotosPrintPreview *preview)
 {
        gfloat scale;
 
-       g_return_val_if_fail (EOG_IS_PRINT_PREVIEW (preview), 0);
+       g_return_val_if_fail (PHOTOS_IS_PRINT_PREVIEW (preview), 0);
 
        g_object_get (preview,
                      "image-scale", &scale,
diff --git a/src/photos-print-preview.h b/src/photos-print-preview.h
new file mode 100644
index 0000000..1bdbd03
--- /dev/null
+++ b/src/photos-print-preview.h
@@ -0,0 +1,102 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2006, 2007 The Free Software Foundation
+ * Copyright © 2013 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* Based on code from:
+ *   + Eye of GNOME
+ */
+
+#ifndef PHOTOS_PRINT_PREVIEW_H
+#define PHOTOS_PRINT_PREVIEW_H
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_PRINT_PREVIEW (photos_print_preview_get_type ())
+
+#define PHOTOS_PRINT_PREVIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_PRINT_PREVIEW, PhotosPrintPreview))
+
+#define PHOTOS_PRINT_PREVIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   PHOTOS_TYPE_PRINT_PREVIEW, PhotosPrintPreviewClass))
+
+#define PHOTOS_IS_PRINT_PREVIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_PRINT_PREVIEW))
+
+#define PHOTOS_IS_PRINT_PREVIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   PHOTOS_TYPE_PRINT_PREVIEW))
+
+#define PHOTOS_PRINT_PREVIEW_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   PHOTOS_TYPE_PRINT_PREVIEW, PhotosPrintPreviewClass))
+
+typedef struct _PhotosPrintPreview        PhotosPrintPreview;
+typedef struct _PhotosPrintPreviewClass   PhotosPrintPreviewClass;
+typedef struct _PhotosPrintPreviewPrivate PhotosPrintPreviewPrivate;
+
+struct _PhotosPrintPreview
+{
+  GtkAspectFrame parent_instance;
+  PhotosPrintPreviewPrivate *priv;
+};
+
+struct _PhotosPrintPreviewClass
+{
+  GtkAspectFrameClass parent_class;
+};
+
+GType        photos_print_preview_get_type              (void) G_GNUC_CONST;
+
+GtkWidget   *photos_print_preview_new                   (void);
+
+GtkWidget   *photos_print_preview_new_with_pixbuf       (GdkPixbuf *pixbuf);
+
+void         photos_print_preview_set_page_margins      (PhotosPrintPreview *self,
+                                                         gfloat l_margin,
+                                                         gfloat r_margin,
+                                                         gfloat t_margin,
+                                                         gfloat b_margin);
+
+void         photos_print_preview_set_from_page_setup   (PhotosPrintPreview *self,
+                                                         GtkPageSetup *setup);
+
+void         photos_print_preview_get_image_position    (PhotosPrintPreview *self,
+                                                         gdouble *x,
+                                                         gdouble *y);
+
+void         photos_print_preview_set_image_position    (PhotosPrintPreview *self,
+                                                         gdouble x,
+                                                         gdouble y);
+
+gboolean     photos_print_preview_point_in_image_area   (PhotosPrintPreview *self,
+                                                         guint x,
+                                                         guint y);
+
+void         photos_print_preview_set_scale             (PhotosPrintPreview *self,
+                                                         gfloat scale);
+
+gfloat       photos_print_preview_get_scale             (PhotosPrintPreview *self);
+
+G_END_DECLS
+
+#endif /* PHOTOS_PRINT_PREVIEW_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]