gimp r27859 - in trunk: . plug-ins/print
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27859 - in trunk: . plug-ins/print
- Date: Tue, 30 Dec 2008 21:36:04 +0000 (UTC)
Author: neo
Date: Tue Dec 30 21:36:04 2008
New Revision: 27859
URL: http://svn.gnome.org/viewvc/gimp?rev=27859&view=rev
Log:
2008-12-30 Sven Neumann <sven gimp org>
* plug-ins/print/print.[ch]
* plug-ins/print/print-draw-page.c
* plug-ins/print/print-page-layout.c
* plug-ins/print/print-settings.c: optionally draw crop-marks.
Modified:
trunk/ChangeLog
trunk/plug-ins/print/print-draw-page.c
trunk/plug-ins/print/print-page-layout.c
trunk/plug-ins/print/print-settings.c
trunk/plug-ins/print/print.c
trunk/plug-ins/print/print.h
Modified: trunk/plug-ins/print/print-draw-page.c
==============================================================================
--- trunk/plug-ins/print/print-draw-page.c (original)
+++ trunk/plug-ins/print/print-draw-page.c Tue Dec 30 21:36:04 2008
@@ -29,7 +29,49 @@
#include "libgimp/stdplugins-intl.h"
-static cairo_surface_t * print_cairo_surface_from_drawable (gint32 drawable_ID);
+static cairo_surface_t * print_surface_from_drawable (gint32 drawable_ID);
+
+static void print_draw_crop_marks (GtkPrintContext *context,
+ gdouble x,
+ gdouble y,
+ gdouble w,
+ gdouble h);
+
+gboolean
+print_draw_page (GtkPrintContext *context,
+ PrintData *data)
+{
+ cairo_t *cr = gtk_print_context_get_cairo_context (context);
+ cairo_surface_t *surface;
+ gint width;
+ gint height;
+ gdouble scale_x;
+ gdouble scale_y;
+
+ surface = print_surface_from_drawable (data->drawable_id);
+
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+
+ scale_x = gtk_print_context_get_dpi_x (context) / data->xres;
+ scale_y = gtk_print_context_get_dpi_y (context) / data->yres;
+
+ cairo_translate (cr, data->offset_x, data->offset_y);
+
+ if (data->draw_crop_marks)
+ print_draw_crop_marks (context,
+ 0, 0, width * scale_x, height * scale_y);
+
+ cairo_scale (cr, scale_x, scale_y);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_fill (cr);
+
+ cairo_surface_destroy (surface);
+
+ return TRUE;
+}
+
static inline void
convert_from_rgb (const guchar *src,
@@ -127,35 +169,8 @@
}
}
-gboolean
-print_draw_page (GtkPrintContext *context,
- PrintData *data)
-{
- cairo_t *cr;
- cairo_surface_t *surface;
-
- cr = gtk_print_context_get_cairo_context (context);
-
- surface = print_cairo_surface_from_drawable (data->drawable_id);
-
- cairo_translate (cr, data->offset_x, data->offset_y);
- cairo_scale (cr,
- gtk_print_context_get_dpi_x (context) / data->xres,
- gtk_print_context_get_dpi_y (context) / data->yres);
-
- cairo_rectangle (cr,
- 0, 0,
- cairo_image_surface_get_width (surface),
- cairo_image_surface_get_height (surface));
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_fill (cr);
- cairo_surface_destroy (surface);
-
- return TRUE;
-}
-
static cairo_surface_t *
-print_cairo_surface_from_drawable (gint32 drawable_ID)
+print_surface_from_drawable (gint32 drawable_ID)
{
GimpDrawable *drawable = gimp_drawable_get (drawable_ID);
GimpPixelRgn region;
@@ -243,3 +258,50 @@
return surface;
}
+static void
+print_draw_crop_marks (GtkPrintContext *context,
+ gdouble x,
+ gdouble y,
+ gdouble w,
+ gdouble h)
+{
+ cairo_t *cr = gtk_print_context_get_cairo_context (context);
+ gdouble len = MIN (gtk_print_context_get_width (context),
+ gtk_print_context_get_height (context)) / 20.0;
+
+ /* upper left */
+
+ cairo_move_to (cr, x - len, y);
+ cairo_line_to (cr, x - len / 5, y);
+
+ cairo_move_to (cr, x, y - len);
+ cairo_line_to (cr, x, y - len / 5);
+
+ /* upper right */
+
+ cairo_move_to (cr, x + w + len / 5, y);
+ cairo_line_to (cr, x + w + len, y);
+
+ cairo_move_to (cr, x + w, y - len);
+ cairo_line_to (cr, x + w, y - len / 5);
+
+ /* lower left */
+
+ cairo_move_to (cr, x - len, y + h);
+ cairo_line_to (cr, x - len / 5, y + h);
+
+ cairo_move_to (cr, x, y + h + len);
+ cairo_line_to (cr, x, y + h + len / 5);
+
+ /* lower right */
+
+ cairo_move_to (cr, x + w + len / 5, y + h);
+ cairo_line_to (cr, x + w + len, y + h);
+
+ cairo_move_to (cr, x + w, y + h + len);
+ cairo_line_to (cr, x + w, y + h + len / 5);
+
+ cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
+ cairo_set_line_width (cr, 2);
+ cairo_stroke (cr);
+}
Modified: trunk/plug-ins/print/print-page-layout.c
==============================================================================
--- trunk/plug-ins/print/print-page-layout.c (original)
+++ trunk/plug-ins/print/print-page-layout.c Tue Dec 30 21:36:04 2008
@@ -89,6 +89,8 @@
static void print_size_info_set_page_setup (PrintSizeInfo *info);
+static void print_draw_crop_marks_toggled (GtkWidget *widget);
+
static PrintSizeInfo info;
@@ -155,6 +157,17 @@
NULL);
gtk_widget_show (button);
+ /* crop marks toggle */
+ button = gtk_check_button_new_with_mnemonic (_("_Draw Crop Marks"));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+ data->draw_crop_marks);
+ gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (print_draw_crop_marks_toggled),
+ NULL);
+ gtk_widget_show (button);
+
/* preview */
frame = gimp_frame_new (_("Preview"));
gtk_box_pack_start (GTK_BOX (main_hbox), frame, TRUE, TRUE, 0);
@@ -715,7 +728,7 @@
static void
print_size_info_use_full_page_toggled (GtkWidget *widget)
{
- gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
info.data->use_full_page = active;
@@ -874,3 +887,12 @@
gimp_size_entry_set_refval_boundaries (info->resolution_entry, 1,
y, GIMP_MAX_RESOLUTION);
}
+
+static void
+print_draw_crop_marks_toggled (GtkWidget *widget)
+{
+ gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+ info.data->draw_crop_marks = active;
+}
+
Modified: trunk/plug-ins/print/print-settings.c
==============================================================================
--- trunk/plug-ins/print/print-settings.c (original)
+++ trunk/plug-ins/print/print-settings.c Tue Dec 30 21:36:04 2008
@@ -98,6 +98,8 @@
"center-mode", data->center);
g_key_file_set_boolean (key_file, "image-setup",
"use-full-page", data->use_full_page);
+ g_key_file_set_boolean (key_file, "image-setup",
+ "crop-marks", data->draw_crop_marks);
print_utils_key_file_save_as_parasite (key_file,
data->image_id,
@@ -223,38 +225,44 @@
if (g_key_file_has_key (key_file, "image-setup", "unit", NULL))
{
- data->unit = g_key_file_get_integer (key_file,
- "image-setup", "unit", NULL);
+ data->unit = g_key_file_get_integer (key_file, "image-setup",
+ "unit", NULL);
}
if (g_key_file_has_key (key_file, "image-setup", "x-resolution", NULL) &&
g_key_file_has_key (key_file, "image-setup", "y-resolution", NULL))
{
- data->xres = g_key_file_get_double (key_file,
- "image-setup", "x-resolution", NULL);
- data->yres = g_key_file_get_double (key_file,
- "image-setup", "y-resolution", NULL);
+ data->xres = g_key_file_get_double (key_file, "image-setup",
+ "x-resolution", NULL);
+ data->yres = g_key_file_get_double (key_file, "image-setup",
+ "y-resolution", NULL);
}
if (g_key_file_has_key (key_file, "image-setup", "x-offset", NULL) &&
g_key_file_has_key (key_file, "image-setup", "y-offset", NULL))
{
- data->offset_x = g_key_file_get_double (key_file,
- "image-setup", "x-offset", NULL);
- data->offset_y = g_key_file_get_double (key_file,
- "image-setup", "y-offset", NULL);
+ data->offset_x = g_key_file_get_double (key_file, "image-setup",
+ "x-offset", NULL);
+ data->offset_y = g_key_file_get_double (key_file, "image-setup",
+ "y-offset", NULL);
}
if (g_key_file_has_key (key_file, "image-setup", "center-mode", NULL))
{
- data->center = g_key_file_get_integer (key_file,
- "image-setup", "center-mode", NULL);
+ data->center = g_key_file_get_integer (key_file, "image-setup",
+ "center-mode", NULL);
}
if (g_key_file_has_key (key_file, "image-setup", "use-full-page", NULL))
{
- data->use_full_page = g_key_file_get_boolean (key_file,
- "image-setup", "use-full-page", NULL);
+ data->use_full_page = g_key_file_get_boolean (key_file, "image-setup",
+ "use-full-page", NULL);
+ }
+
+ if (g_key_file_has_key (key_file, "image-setup", "crop-marks", NULL))
+ {
+ data->draw_crop_marks = g_key_file_get_boolean (key_file, "image-setup",
+ "crop-marks", NULL);
}
gtk_print_operation_set_print_settings (operation, settings);
Modified: trunk/plug-ins/print/print.c
==============================================================================
--- trunk/plug-ins/print/print.c (original)
+++ trunk/plug-ins/print/print.c Tue Dec 30 21:36:04 2008
@@ -103,7 +103,7 @@
"Print the image using the GTK+ Print API.",
"Bill Skaggs, Sven Neumann, Stefan RÃllin",
"Bill Skaggs <weskaggs primate ucdavis edu>",
- "2006, 2007",
+ "2006 - 2008",
N_("_Print..."),
"*",
GIMP_PLUGIN,
@@ -220,15 +220,16 @@
print_page_setup_load (operation, image_ID);
/* fill in the PrintData struct */
- data.image_id = image_ID;
- data.drawable_id = layer;
- data.unit = gimp_get_default_unit ();
- data.image_unit = gimp_image_get_unit (image_ID);
- data.offset_x = 0;
- data.offset_y = 0;
- data.center = CENTER_BOTH;
- data.use_full_page = FALSE;
- data.operation = operation;
+ data.image_id = image_ID;
+ data.drawable_id = layer;
+ data.unit = gimp_get_default_unit ();
+ data.image_unit = gimp_image_get_unit (image_ID);
+ data.offset_x = 0;
+ data.offset_y = 0;
+ data.center = CENTER_BOTH;
+ data.use_full_page = FALSE;
+ data.draw_crop_marks = FALSE;
+ data.operation = operation;
gimp_image_get_resolution (image_ID, &data.xres, &data.yres);
Modified: trunk/plug-ins/print/print.h
==============================================================================
--- trunk/plug-ins/print/print.h (original)
+++ trunk/plug-ins/print/print.h Tue Dec 30 21:36:04 2008
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
typedef enum
{
CENTER_NONE = 0,
@@ -36,6 +37,6 @@
gdouble offset_y;
PrintCenterMode center;
gboolean use_full_page;
+ gboolean draw_crop_marks;
GtkPrintOperation *operation;
} PrintData;
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]