From 4fb0b2a5bf4d21b4bfbb0f0884c8bc84753f9e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20S=2E=20O=2E=20Bueno=20Calligaris?= Date: Thu, 1 Mar 2007 12:48:00 +0000 Subject: [PATCH] add callback to resolution changes in the postscipt load dialog to update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2007-03-01 João S. O. Bueno Calligaris * plug-ins/common/postscript.c: add callback to resolution changes in the postscipt load dialog to update the image size in pixels. svn path=/trunk/; revision=22035 --- ChangeLog | 8 +++- plug-ins/common/postscript.c | 71 +++++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 998214c781..ea628e2e30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2007-02-29 Raphaël Quinet +2007-03-01 João S. O. Bueno Calligaris + + * plug-ins/common/postscript.c: add callback to resolution + changes in the postscipt load dialog to update the image size + in pixels. + +2007-03-01 Raphaël Quinet * app/tools/gimpmeasuretool.c (gimp_measure_tool_cursor_update): don't suggest Shift when a new point cannot be added to point 0. diff --git a/plug-ins/common/postscript.c b/plug-ins/common/postscript.c index f2bf7817da..e9933ed723 100644 --- a/plug-ins/common/postscript.c +++ b/plug-ins/common/postscript.c @@ -130,7 +130,7 @@ static char dversio[] = "v1.17 19-Sep-2004"; /* Load info */ typedef struct { - guint resolution; /* resolution (dpi) at which to run ghostscript */ + guint resolution; /* resolution (dpi) at which to run ghostscript */ guint width, height; /* desired size (ghostscript may ignore this) */ gint use_bbox; /* 0: use width/height, 1: try to use BoundingBox */ gchar pages[STR_LENGTH]; /* Pages to load (eg.: 1,3,5-7) */ @@ -150,7 +150,13 @@ static PSLoadVals plvals = 1 /* dont use graphics antialiasing */ }; - +/* Widgets for width and height of postscript image to +* be loaded, so that they can be updated when desired resolution is +* changed +*/ +GtkWidget *ps_width_spinbutton; +GtkWidget *ps_height_spinbutton; + /* Save info */ typedef struct { @@ -267,11 +273,14 @@ static void dither_grey (const guchar *grey, /* Dialog-handling */ -static gint32 count_ps_pages (const gchar *filename); -static gboolean load_dialog (const gchar *filename, - gboolean loadPDF); -static void load_pages_entry_callback (GtkWidget *widget, - gpointer data); +static gint32 count_ps_pages (const gchar *filename); +static gboolean load_dialog (const gchar *filename, + gboolean loadPDF); +static void load_pages_entry_callback (GtkWidget *widget, + gpointer data); + +static gboolean resolution_change_callback (GtkAdjustment *adjustment, + gpointer data); typedef struct { @@ -3099,24 +3108,33 @@ load_dialog (const gchar *filename, gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Resolution:"), 0.0, 0.5, spinbutton, 1, FALSE); + + g_signal_connect (adj, "value-changed", + G_CALLBACK (resolution_change_callback), + &plvals.resolution); + g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_int_adjustment_update), &plvals.resolution); - spinbutton = gimp_spin_button_new (&adj, plvals.width, - 1, GIMP_MAX_IMAGE_SIZE, 1, 10, 0, 1, 0); + + + ps_width_spinbutton = gimp_spin_button_new (&adj, plvals.width, + 1, GIMP_MAX_IMAGE_SIZE, + 1, 10, 0, 1, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("_Width:"), 0.0, 0.5, - spinbutton, 1, FALSE); + ps_width_spinbutton, 1, FALSE); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_int_adjustment_update), &plvals.width); - spinbutton = gimp_spin_button_new (&adj, plvals.height, - 1, GIMP_MAX_IMAGE_SIZE, 1, 10, 0, 1, 0); + ps_height_spinbutton = gimp_spin_button_new (&adj, plvals.height, + 1, GIMP_MAX_IMAGE_SIZE, + 1, 10, 0, 1, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, _("_Height:"), 0.0, 0.5, - spinbutton, 1, FALSE); + ps_height_spinbutton, 1, FALSE); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_int_adjustment_update), &plvals.height); @@ -3496,3 +3514,30 @@ save_unit_toggle_update (GtkWidget *widget, } } } + +static gboolean +resolution_change_callback (GtkAdjustment *adjustment, + gpointer data) +{ + guint *old_resolution = (guint *) data; + gdouble ratio; + + if (*old_resolution) + { + ratio = (gdouble) adjustment->value / *old_resolution; + } + else + { + ratio = 1; + } + gtk_spin_button_set_value (GTK_SPIN_BUTTON (ps_width_spinbutton), + GTK_SPIN_BUTTON (ps_width_spinbutton)-> + adjustment->value * ratio); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (ps_height_spinbutton), + GTK_SPIN_BUTTON (ps_height_spinbutton)-> + adjustment->value * ratio); + + return TRUE; + +}