mirror of https://github.com/GNOME/gimp.git
removed unused settings, bumped format version. Store resolution and unit
2006-12-28 Sven Neumann <sven@gimp.org> * plug-ins/print/print-settings: removed unused settings, bumped format version. Store resolution and unit in the image parasite. * plug-ins/print/print-page-layout.c: deal gracefully with no default page setup.
This commit is contained in:
parent
311e21dfa9
commit
e0e14e8c48
|
@ -1,3 +1,11 @@
|
||||||
|
2006-12-28 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/print/print-settings: removed unused settings, bumped
|
||||||
|
format version. Store resolution and unit in the image parasite.
|
||||||
|
|
||||||
|
* plug-ins/print/print-page-layout.c: deal gracefully with no
|
||||||
|
default page setup.
|
||||||
|
|
||||||
2006-12-28 Sven Neumann <sven@gimp.org>
|
2006-12-28 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* libgimpwidgets/gimpunitmenu.c: use the toplevel widget as the
|
* libgimpwidgets/gimpunitmenu.c: use the toplevel widget as the
|
||||||
|
|
|
@ -111,8 +111,6 @@ draw_page_cairo (GtkPrintContext *context,
|
||||||
cairo_translate (cr, x0, y0);
|
cairo_translate (cr, x0, y0);
|
||||||
cairo_scale (cr, scale_x, scale_y);
|
cairo_scale (cr, scale_x, scale_y);
|
||||||
|
|
||||||
gimp_tile_cache_ntiles (1 + width / gimp_tile_width ());
|
|
||||||
|
|
||||||
gimp_pixel_rgn_init (®ion, drawable, 0, 0, width, height, FALSE, FALSE);
|
gimp_pixel_rgn_init (®ion, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||||
|
|
||||||
pixels = g_new (guchar, MIN (height, tile_height) * rowstride);
|
pixels = g_new (guchar, MIN (height, tile_height) * rowstride);
|
||||||
|
|
|
@ -60,8 +60,7 @@ static void print_size_info_set_resolution (PrintSizeInfo *info,
|
||||||
gdouble yres);
|
gdouble yres);
|
||||||
|
|
||||||
|
|
||||||
static void print_size_info_set_page_setup (PrintSizeInfo *info,
|
static void print_size_info_set_page_setup (PrintSizeInfo *info);
|
||||||
GtkPageSetup *setup);
|
|
||||||
|
|
||||||
|
|
||||||
static PrintSizeInfo info;
|
static PrintSizeInfo info;
|
||||||
|
@ -141,6 +140,8 @@ print_page_layout_gui (PrintData *data)
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
print_size_info_set_page_setup (&info);
|
||||||
|
|
||||||
return main_vbox;
|
return main_vbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,19 +172,15 @@ run_page_setup_dialog (GtkWidget *widget,
|
||||||
|
|
||||||
gtk_print_operation_set_default_page_setup (operation, page_setup);
|
gtk_print_operation_set_default_page_setup (operation, page_setup);
|
||||||
|
|
||||||
print_size_info_set_page_setup (&info, page_setup);
|
print_size_info_set_page_setup (&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SB_WIDTH 8
|
#define SB_WIDTH 8
|
||||||
|
|
||||||
/*
|
|
||||||
* the code below is copied from app/dialogs/print-size-dialog.c
|
|
||||||
* with minimal changes. Bleeah!
|
|
||||||
*/
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
print_size_frame (PrintData *data)
|
print_size_frame (PrintData *data)
|
||||||
{
|
{
|
||||||
GtkPageSetup *setup;
|
|
||||||
GtkWidget *entry;
|
GtkWidget *entry;
|
||||||
GtkWidget *height;
|
GtkWidget *height;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
|
@ -251,8 +248,6 @@ print_size_frame (PrintData *data)
|
||||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 1,
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 1,
|
||||||
data->yres, FALSE);
|
data->yres, FALSE);
|
||||||
|
|
||||||
setup = gtk_print_operation_get_default_page_setup (data->operation);
|
|
||||||
|
|
||||||
gimp_size_entry_set_value (GIMP_SIZE_ENTRY (entry), 0, image_width);
|
gimp_size_entry_set_value (GIMP_SIZE_ENTRY (entry), 0, image_width);
|
||||||
gimp_size_entry_set_value (GIMP_SIZE_ENTRY (entry), 1, image_height);
|
gimp_size_entry_set_value (GIMP_SIZE_ENTRY (entry), 1, image_height);
|
||||||
|
|
||||||
|
@ -262,7 +257,7 @@ print_size_frame (PrintData *data)
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
entry = gimp_size_entry_new (1, data->unit, _("pixels/%a"),
|
entry = gimp_size_entry_new (1, GIMP_UNIT_INCH, _("pixels/%a"),
|
||||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
||||||
|
@ -307,8 +302,6 @@ print_size_frame (PrintData *data)
|
||||||
|
|
||||||
info.chain = GIMP_CHAIN_BUTTON (chain);
|
info.chain = GIMP_CHAIN_BUTTON (chain);
|
||||||
|
|
||||||
print_size_info_set_page_setup (&info, setup);
|
|
||||||
|
|
||||||
g_signal_connect (info.size_entry, "value-changed",
|
g_signal_connect (info.size_entry, "value-changed",
|
||||||
G_CALLBACK (print_size_info_size_changed),
|
G_CALLBACK (print_size_info_size_changed),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -370,19 +363,14 @@ print_size_info_unit_changed (GtkWidget *widget)
|
||||||
w = gimp_size_entry_get_value (entry, 0) * factor;
|
w = gimp_size_entry_get_value (entry, 0) * factor;
|
||||||
h = gimp_size_entry_get_value (entry, 1) * factor;
|
h = gimp_size_entry_get_value (entry, 1) * factor;
|
||||||
|
|
||||||
print_size_info_set_page_setup (&info,
|
print_size_info_set_page_setup (&info);
|
||||||
gtk_print_operation_get_default_page_setup (data->operation));
|
|
||||||
|
|
||||||
print_size_info_set_size (&info, w, h);
|
print_size_info_set_size (&info, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_size_info_chain_toggled (GtkWidget *widget)
|
print_size_info_chain_toggled (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
PrintData *data = info.data;
|
print_size_info_set_page_setup (&info);
|
||||||
|
|
||||||
print_size_info_set_page_setup (&info,
|
|
||||||
gtk_print_operation_get_default_page_setup (data->operation));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -451,24 +439,36 @@ print_size_info_set_resolution (PrintSizeInfo *info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_size_info_set_page_setup (PrintSizeInfo *info,
|
print_size_info_set_page_setup (PrintSizeInfo *info)
|
||||||
GtkPageSetup *setup)
|
|
||||||
{
|
{
|
||||||
PrintData *data = info->data;
|
GtkPageSetup *setup;
|
||||||
gchar *text;
|
PrintData *data = info->data;
|
||||||
gdouble page_width;
|
gchar *format;
|
||||||
gdouble page_height;
|
gchar *text;
|
||||||
gdouble x;
|
gdouble page_width;
|
||||||
gdouble y;
|
gdouble page_height;
|
||||||
|
gdouble x;
|
||||||
|
gdouble y;
|
||||||
|
|
||||||
|
setup = gtk_print_operation_get_default_page_setup (data->operation);
|
||||||
|
if (! setup)
|
||||||
|
{
|
||||||
|
setup = gtk_page_setup_new ();
|
||||||
|
gtk_print_operation_set_default_page_setup (data->operation, setup);
|
||||||
|
}
|
||||||
|
|
||||||
page_width = (gtk_page_setup_get_page_width (setup, GTK_UNIT_INCH) *
|
page_width = (gtk_page_setup_get_page_width (setup, GTK_UNIT_INCH) *
|
||||||
gimp_unit_get_factor (data->unit));
|
gimp_unit_get_factor (data->unit));
|
||||||
page_height = (gtk_page_setup_get_page_height (setup, GTK_UNIT_INCH) *
|
page_height = (gtk_page_setup_get_page_height (setup, GTK_UNIT_INCH) *
|
||||||
gimp_unit_get_factor (data->unit));
|
gimp_unit_get_factor (data->unit));
|
||||||
|
|
||||||
text = g_strdup_printf ("%g x %g %s",
|
format = g_strdup_printf ("%%.%df x %%.%df %s",
|
||||||
page_width, page_height,
|
gimp_unit_get_digits (data->unit),
|
||||||
gimp_unit_get_plural (data->unit));
|
gimp_unit_get_digits (data->unit),
|
||||||
|
gimp_unit_get_plural (data->unit));
|
||||||
|
text = g_strdup_printf (format, page_width, page_height);
|
||||||
|
g_free (format);
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (info->area_label), text);
|
gtk_label_set_text (GTK_LABEL (info->area_label), text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PRINT_SETTINGS_MAJOR_VERSION 0
|
#define PRINT_SETTINGS_MAJOR_VERSION 0
|
||||||
#define PRINT_SETTINGS_MINOR_VERSION 1
|
#define PRINT_SETTINGS_MINOR_VERSION 2
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -83,7 +83,14 @@ save_print_settings (PrintData *data)
|
||||||
GKeyFile *key_file;
|
GKeyFile *key_file;
|
||||||
|
|
||||||
key_file = print_settings_key_file_from_settings (data);
|
key_file = print_settings_key_file_from_settings (data);
|
||||||
|
|
||||||
save_print_settings_resource_file (key_file);
|
save_print_settings_resource_file (key_file);
|
||||||
|
|
||||||
|
/* image setup */
|
||||||
|
g_key_file_set_integer (key_file, "image-setup", "unit", data->unit);
|
||||||
|
g_key_file_set_double (key_file, "image-setup", "x-resolution", data->xres);
|
||||||
|
g_key_file_set_double (key_file, "image-setup", "y-resolution", data->yres);
|
||||||
|
|
||||||
save_print_settings_as_parasite (key_file, data->image_id);
|
save_print_settings_as_parasite (key_file, data->image_id);
|
||||||
|
|
||||||
g_key_file_free (key_file);
|
g_key_file_free (key_file);
|
||||||
|
@ -127,11 +134,11 @@ print_settings_key_file_from_settings (PrintData *data)
|
||||||
orientation);
|
orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* other settings */
|
/* other settings */
|
||||||
g_key_file_set_boolean (key_file, "other-settings", "show-header",
|
g_key_file_set_boolean (key_file, "other-settings", "show-header",
|
||||||
data->show_info_header);
|
data->show_info_header);
|
||||||
g_key_file_set_integer (key_file, "other-settings", "unit",
|
#endif
|
||||||
data->unit);
|
|
||||||
|
|
||||||
return key_file;
|
return key_file;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +277,6 @@ load_print_settings_from_key_file (PrintData *data,
|
||||||
GKeyFile *key_file)
|
GKeyFile *key_file)
|
||||||
{
|
{
|
||||||
GtkPrintOperation *operation = data->operation;
|
GtkPrintOperation *operation = data->operation;
|
||||||
GtkPageSetup *page_setup;
|
|
||||||
GtkPrintSettings *settings;
|
GtkPrintSettings *settings;
|
||||||
gchar **keys;
|
gchar **keys;
|
||||||
gsize n_keys;
|
gsize n_keys;
|
||||||
|
@ -300,25 +306,42 @@ load_print_settings_from_key_file (PrintData *data,
|
||||||
|
|
||||||
g_strfreev (keys);
|
g_strfreev (keys);
|
||||||
|
|
||||||
|
|
||||||
/* page setup parameters */
|
/* page setup parameters */
|
||||||
page_setup = gtk_print_operation_get_default_page_setup (operation);
|
|
||||||
if (! page_setup)
|
|
||||||
page_setup = gtk_page_setup_new ();
|
|
||||||
|
|
||||||
if (g_key_file_has_key (key_file, "page-setup", "orientation", NULL))
|
if (g_key_file_has_key (key_file, "page-setup", "orientation", NULL))
|
||||||
{
|
{
|
||||||
GtkPageOrientation orientation;
|
GtkPageSetup *page_setup;
|
||||||
|
GtkPageOrientation orientation;
|
||||||
|
|
||||||
|
page_setup = gtk_print_operation_get_default_page_setup (operation);
|
||||||
|
if (! page_setup)
|
||||||
|
page_setup = gtk_page_setup_new ();
|
||||||
|
|
||||||
orientation = g_key_file_get_integer (key_file,
|
orientation = g_key_file_get_integer (key_file,
|
||||||
"page-setup", "orientation", NULL);
|
"page-setup", "orientation", NULL);
|
||||||
gtk_page_setup_set_orientation (page_setup, orientation);
|
gtk_page_setup_set_orientation (page_setup, orientation);
|
||||||
gtk_print_settings_set_orientation (settings, orientation);
|
gtk_print_settings_set_orientation (settings, orientation);
|
||||||
data->orientation = orientation;
|
data->orientation = orientation;
|
||||||
|
|
||||||
|
gtk_print_operation_set_default_page_setup (operation, page_setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_print_operation_set_default_page_setup (operation, page_setup);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* other settings */
|
/* other settings */
|
||||||
if (g_key_file_has_key (key_file, "other-settings", "show-header", NULL))
|
if (g_key_file_has_key (key_file, "other-settings", "show-header", NULL))
|
||||||
{
|
{
|
||||||
|
@ -327,20 +350,11 @@ load_print_settings_from_key_file (PrintData *data,
|
||||||
"show-header", NULL);
|
"show-header", NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
data->show_info_header = FALSE;
|
data->show_info_header = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_key_file_has_key (key_file, "other-settings", "unit", NULL))
|
|
||||||
{
|
|
||||||
data->unit = g_key_file_get_integer (key_file,
|
|
||||||
"other-settings", "unit", NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data->unit = GIMP_UNIT_INCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_print_operation_set_print_settings (operation, settings);
|
gtk_print_operation_set_print_settings (operation, settings);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue