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:
Sven Neumann 2006-12-28 21:48:34 +00:00 committed by Sven Neumann
parent 311e21dfa9
commit e0e14e8c48
4 changed files with 73 additions and 53 deletions

View File

@ -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>
* libgimpwidgets/gimpunitmenu.c: use the toplevel widget as the

View File

@ -111,8 +111,6 @@ draw_page_cairo (GtkPrintContext *context,
cairo_translate (cr, x0, y0);
cairo_scale (cr, scale_x, scale_y);
gimp_tile_cache_ntiles (1 + width / gimp_tile_width ());
gimp_pixel_rgn_init (&region, drawable, 0, 0, width, height, FALSE, FALSE);
pixels = g_new (guchar, MIN (height, tile_height) * rowstride);

View File

@ -60,8 +60,7 @@ static void print_size_info_set_resolution (PrintSizeInfo *info,
gdouble yres);
static void print_size_info_set_page_setup (PrintSizeInfo *info,
GtkPageSetup *setup);
static void print_size_info_set_page_setup (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_widget_show (frame);
print_size_info_set_page_setup (&info);
return main_vbox;
}
@ -171,19 +172,15 @@ run_page_setup_dialog (GtkWidget *widget,
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
/*
* the code below is copied from app/dialogs/print-size-dialog.c
* with minimal changes. Bleeah!
*/
static GtkWidget *
print_size_frame (PrintData *data)
{
GtkPageSetup *setup;
GtkWidget *entry;
GtkWidget *height;
GtkWidget *vbox;
@ -251,8 +248,6 @@ print_size_frame (PrintData *data)
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 1,
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), 1, image_height);
@ -262,7 +257,7 @@ print_size_frame (PrintData *data)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
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,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
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);
print_size_info_set_page_setup (&info, setup);
g_signal_connect (info.size_entry, "value-changed",
G_CALLBACK (print_size_info_size_changed),
NULL);
@ -370,19 +363,14 @@ print_size_info_unit_changed (GtkWidget *widget)
w = gimp_size_entry_get_value (entry, 0) * factor;
h = gimp_size_entry_get_value (entry, 1) * factor;
print_size_info_set_page_setup (&info,
gtk_print_operation_get_default_page_setup (data->operation));
print_size_info_set_page_setup (&info);
print_size_info_set_size (&info, w, h);
}
static void
print_size_info_chain_toggled (GtkWidget *widget)
{
PrintData *data = info.data;
print_size_info_set_page_setup (&info,
gtk_print_operation_get_default_page_setup (data->operation));
print_size_info_set_page_setup (&info);
}
static void
@ -451,24 +439,36 @@ print_size_info_set_resolution (PrintSizeInfo *info,
}
static void
print_size_info_set_page_setup (PrintSizeInfo *info,
GtkPageSetup *setup)
print_size_info_set_page_setup (PrintSizeInfo *info)
{
PrintData *data = info->data;
gchar *text;
gdouble page_width;
gdouble page_height;
gdouble x;
gdouble y;
GtkPageSetup *setup;
PrintData *data = info->data;
gchar *format;
gchar *text;
gdouble page_width;
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) *
gimp_unit_get_factor (data->unit));
page_height = (gtk_page_setup_get_page_height (setup, GTK_UNIT_INCH) *
gimp_unit_get_factor (data->unit));
text = g_strdup_printf ("%g x %g %s",
page_width, page_height,
gimp_unit_get_plural (data->unit));
format = g_strdup_printf ("%%.%df x %%.%df %s",
gimp_unit_get_digits (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);
g_free (text);

View File

@ -17,7 +17,7 @@
*/
#define PRINT_SETTINGS_MAJOR_VERSION 0
#define PRINT_SETTINGS_MINOR_VERSION 1
#define PRINT_SETTINGS_MINOR_VERSION 2
#include "config.h"
@ -83,7 +83,14 @@ save_print_settings (PrintData *data)
GKeyFile *key_file;
key_file = print_settings_key_file_from_settings (data);
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);
g_key_file_free (key_file);
@ -127,11 +134,11 @@ print_settings_key_file_from_settings (PrintData *data)
orientation);
}
#if 0
/* other settings */
g_key_file_set_boolean (key_file, "other-settings", "show-header",
data->show_info_header);
g_key_file_set_integer (key_file, "other-settings", "unit",
data->unit);
#endif
return key_file;
}
@ -270,7 +277,6 @@ load_print_settings_from_key_file (PrintData *data,
GKeyFile *key_file)
{
GtkPrintOperation *operation = data->operation;
GtkPageSetup *page_setup;
GtkPrintSettings *settings;
gchar **keys;
gsize n_keys;
@ -300,25 +306,42 @@ load_print_settings_from_key_file (PrintData *data,
g_strfreev (keys);
/* 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))
{
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,
"page-setup", "orientation", NULL);
gtk_page_setup_set_orientation (page_setup, orientation);
gtk_print_settings_set_orientation (settings, 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 */
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);
}
else
#endif
{
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);
return TRUE;