tweaked spacing and alignments to make it look more like our other
2005-07-18 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpresolutionentry.c: tweaked spacing and alignments to make it look more like our other widgets. * plug-ins/common/poppler.c: put the resolution entry into a hbox so that it doesn't expand horizontally; removed unused table.
This commit is contained in:

committed by
Sven Neumann

parent
5713d3048b
commit
dca11f2ef4
@ -1,3 +1,11 @@
|
|||||||
|
2005-07-18 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpresolutionentry.c: tweaked spacing and
|
||||||
|
alignments to make it look more like our other widgets.
|
||||||
|
|
||||||
|
* plug-ins/common/poppler.c: put the resolution entry into a hbox
|
||||||
|
so that it doesn't expand horizontally; removed unused table.
|
||||||
|
|
||||||
2005-07-17 Sven Neumann <sven@gimp.org>
|
2005-07-17 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/nlfilt.c
|
* plug-ins/common/nlfilt.c
|
||||||
|
@ -74,16 +74,18 @@ static void gimp_resolution_entry_field_init (GimpResolutionEntry *gre,
|
|||||||
gint spinbutton_width);
|
gint spinbutton_width);
|
||||||
|
|
||||||
|
|
||||||
static void gimp_resolution_entry_field_set_boundaries
|
static void gimp_resolution_entry_field_set_boundaries
|
||||||
(GimpResolutionEntryField *gref,
|
(GimpResolutionEntryField *gref,
|
||||||
gdouble lower,
|
gdouble lower,
|
||||||
gdouble upper);
|
gdouble upper);
|
||||||
|
|
||||||
static void
|
static void gimp_resolution_entry_field_set_value
|
||||||
gimp_resolution_entry_field_set_value (GimpResolutionEntryField *gref,
|
(GimpResolutionEntryField *gref,
|
||||||
gdouble value);
|
gdouble value);
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_resolution_entry_format_label (GimpResolutionEntry *gre,
|
||||||
|
GtkWidget *label,
|
||||||
|
gdouble size);
|
||||||
static guint gimp_resolution_entry_signals[LAST_SIGNAL] = { 0 };
|
static guint gimp_resolution_entry_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
static GtkTableClass *parent_class = NULL;
|
static GtkTableClass *parent_class = NULL;
|
||||||
@ -134,7 +136,7 @@ gimp_resolution_entry_class_init (GimpResolutionEntryClass *klass)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
gimp_resolution_entry_signals[WIDTH_CHANGED] =
|
gimp_resolution_entry_signals[WIDTH_CHANGED] =
|
||||||
g_signal_new ("width-changed",
|
g_signal_new ("width-changed",
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
@ -143,7 +145,7 @@ gimp_resolution_entry_class_init (GimpResolutionEntryClass *klass)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
gimp_resolution_entry_signals[X_CHANGED] =
|
gimp_resolution_entry_signals[X_CHANGED] =
|
||||||
g_signal_new ("x-changed",
|
g_signal_new ("x-changed",
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
@ -184,6 +186,9 @@ gimp_resolution_entry_init (GimpResolutionEntry *gre)
|
|||||||
gre->unitmenu = NULL;
|
gre->unitmenu = NULL;
|
||||||
gre->unit = GIMP_UNIT_INCH;
|
gre->unit = GIMP_UNIT_INCH;
|
||||||
gre->independent = FALSE;
|
gre->independent = FALSE;
|
||||||
|
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (gre), 4);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (gre), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -211,24 +216,24 @@ gimp_resolution_entry_field_init (GimpResolutionEntry *gre,
|
|||||||
gint digits;
|
gint digits;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
|
|
||||||
gref->gre = gre;
|
gref->gre = gre;
|
||||||
gref->corresponding = corresponding;
|
gref->corresponding = corresponding;
|
||||||
gref->changed_signal = gimp_resolution_entry_signals[changed_signal];
|
gref->changed_signal = gimp_resolution_entry_signals[changed_signal];
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
gref->value = initial_val /
|
gref->value = initial_val /
|
||||||
gimp_unit_get_factor (initial_unit) *
|
gimp_unit_get_factor (initial_unit) *
|
||||||
corresponding->value *
|
corresponding->value *
|
||||||
gimp_unit_get_factor (gre->unit);
|
gimp_unit_get_factor (gre->unit);
|
||||||
|
|
||||||
gref->phy_size = initial_val /
|
gref->phy_size = initial_val /
|
||||||
gimp_unit_get_factor (initial_unit);
|
gimp_unit_get_factor (initial_unit);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gref->value = initial_val;
|
gref->value = initial_val;
|
||||||
|
|
||||||
gref->min_value = GIMP_MIN_RESOLUTION;
|
gref->min_value = GIMP_MIN_RESOLUTION;
|
||||||
gref->max_value = GIMP_MAX_RESOLUTION;
|
gref->max_value = GIMP_MAX_RESOLUTION;
|
||||||
gref->adjustment = NULL;
|
gref->adjustment = NULL;
|
||||||
@ -239,16 +244,15 @@ gimp_resolution_entry_field_init (GimpResolutionEntry *gre,
|
|||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
/*
|
gref->label = g_object_new (GTK_TYPE_LABEL,
|
||||||
* warning: not correctly localizable in many gimp supported languages
|
"xalign", 0.0,
|
||||||
* */
|
"yalign", 0.5,
|
||||||
gchar *text = g_strdup_printf (_("%f %s"), gref->phy_size *
|
NULL);
|
||||||
gimp_unit_get_factor (gre->unit),
|
gimp_label_set_attributes (GTK_LABEL (gref->label),
|
||||||
gimp_unit_get_plural (gre->unit));
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||||
|
-1);
|
||||||
gref->label = gtk_label_new (text);
|
|
||||||
|
|
||||||
g_free (text);
|
gimp_resolution_entry_format_label (gre, gref->label, gref->phy_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
digits = size ? 0 : GIMP_RESOLUTION_ENTRY_DIGITS (initial_unit);
|
digits = size ? 0 : GIMP_RESOLUTION_ENTRY_DIGITS (initial_unit);
|
||||||
@ -258,9 +262,9 @@ gimp_resolution_entry_field_init (GimpResolutionEntry *gre,
|
|||||||
gref->min_value,
|
gref->min_value,
|
||||||
gref->max_value,
|
gref->max_value,
|
||||||
1.0, 10.0, 0.0,
|
1.0, 10.0, 0.0,
|
||||||
1.0,
|
1.0,
|
||||||
digits);
|
digits);
|
||||||
|
|
||||||
|
|
||||||
if (spinbutton_width > 0)
|
if (spinbutton_width > 0)
|
||||||
{
|
{
|
||||||
@ -282,9 +286,9 @@ gimp_resolution_entry_field_init (GimpResolutionEntry *gre,
|
|||||||
* @size_unit: Unit used to specify the width and height.
|
* @size_unit: Unit used to specify the width and height.
|
||||||
* @x_label: Optional label for the X resolution entry.
|
* @x_label: Optional label for the X resolution entry.
|
||||||
* @initial_x: The initial X resolution.
|
* @initial_x: The initial X resolution.
|
||||||
* @x_label: Optional label for the Y resolution entry. Ignored if
|
* @y_label: Optional label for the Y resolution entry. Ignored if
|
||||||
* @independent is %FALSE.
|
* @independent is %FALSE.
|
||||||
* @initial_y: The initial Y resolution. Ignored if @independent is
|
* @initial_y: The initial Y resolution. Ignored if @independent is
|
||||||
* %FALSE.
|
* %FALSE.
|
||||||
* @initial_unit: The initial unit.
|
* @initial_unit: The initial unit.
|
||||||
* @independent: Whether the X and Y resolutions can be different values.
|
* @independent: Whether the X and Y resolutions can be different values.
|
||||||
@ -295,7 +299,7 @@ gimp_resolution_entry_field_init (GimpResolutionEntry *gre,
|
|||||||
* The #GimpResolutionEntry is derived from #GtkTable and will have
|
* The #GimpResolutionEntry is derived from #GtkTable and will have
|
||||||
* an empty border of one cell width on each side plus an empty column left
|
* an empty border of one cell width on each side plus an empty column left
|
||||||
* of the #GimpUnitMenu to allow the caller to add labels or other widgets.
|
* of the #GimpUnitMenu to allow the caller to add labels or other widgets.
|
||||||
*
|
*
|
||||||
* A #GimpChainButton is displayed if independent is set to %TRUE.
|
* A #GimpChainButton is displayed if independent is set to %TRUE.
|
||||||
*
|
*
|
||||||
* Returns: A pointer to the new #GimpResolutionEntry widget.
|
* Returns: A pointer to the new #GimpResolutionEntry widget.
|
||||||
@ -327,7 +331,7 @@ gimp_resolution_entry_new (const gchar *width_label,
|
|||||||
independent ? 5 : 4,
|
independent ? 5 : 4,
|
||||||
4);
|
4);
|
||||||
|
|
||||||
gimp_resolution_entry_field_init (gre, &gre->x,
|
gimp_resolution_entry_field_init (gre, &gre->x,
|
||||||
&gre->width,
|
&gre->width,
|
||||||
X_CHANGED,
|
X_CHANGED,
|
||||||
initial_x, initial_unit,
|
initial_x, initial_unit,
|
||||||
@ -337,26 +341,26 @@ gimp_resolution_entry_new (const gchar *width_label,
|
|||||||
gtk_table_attach_defaults (GTK_TABLE (gre), gre->x.spinbutton,
|
gtk_table_attach_defaults (GTK_TABLE (gre), gre->x.spinbutton,
|
||||||
1, 2,
|
1, 2,
|
||||||
3, 4);
|
3, 4);
|
||||||
|
|
||||||
g_signal_connect (gre->x.adjustment, "value-changed",
|
g_signal_connect (gre->x.adjustment, "value-changed",
|
||||||
G_CALLBACK (gimp_resolution_entry_value_callback),
|
G_CALLBACK (gimp_resolution_entry_value_callback),
|
||||||
&gre->x);
|
&gre->x);
|
||||||
|
|
||||||
gtk_widget_show (gre->x.spinbutton);
|
gtk_widget_show (gre->x.spinbutton);
|
||||||
|
|
||||||
if (independent)
|
if (independent)
|
||||||
{
|
{
|
||||||
gre->chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
gre->chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (gre), gre->chainbutton,
|
gtk_table_attach (GTK_TABLE (gre), gre->chainbutton,
|
||||||
2, 3,
|
2, 3,
|
||||||
3, 5,
|
3, 5,
|
||||||
GTK_SHRINK, GTK_SHRINK | GTK_FILL,
|
GTK_SHRINK, GTK_SHRINK | GTK_FILL,
|
||||||
0, 0);
|
0, 0);
|
||||||
|
|
||||||
gtk_widget_show (gre->chainbutton);
|
gtk_widget_show (gre->chainbutton);
|
||||||
|
|
||||||
gimp_resolution_entry_field_init (gre, &gre->y,
|
gimp_resolution_entry_field_init (gre, &gre->y,
|
||||||
&gre->height,
|
&gre->height,
|
||||||
Y_CHANGED,
|
Y_CHANGED,
|
||||||
initial_y, initial_unit,
|
initial_y, initial_unit,
|
||||||
@ -370,15 +374,15 @@ gimp_resolution_entry_new (const gchar *width_label,
|
|||||||
g_signal_connect (gre->y.adjustment, "value-changed",
|
g_signal_connect (gre->y.adjustment, "value-changed",
|
||||||
G_CALLBACK (gimp_resolution_entry_value_callback),
|
G_CALLBACK (gimp_resolution_entry_value_callback),
|
||||||
&gre->y);
|
&gre->y);
|
||||||
|
|
||||||
gtk_widget_show (gre->y.spinbutton);
|
gtk_widget_show (gre->y.spinbutton);
|
||||||
}
|
}
|
||||||
|
|
||||||
gre->unitmenu = gimp_unit_menu_new (_("pixels/%s"), initial_unit,
|
gre->unitmenu = gimp_unit_menu_new (_("pixels/%s"), initial_unit,
|
||||||
FALSE, FALSE,
|
FALSE, FALSE,
|
||||||
TRUE);
|
TRUE);
|
||||||
gtk_table_attach (GTK_TABLE (gre), gre->unitmenu,
|
gtk_table_attach (GTK_TABLE (gre), gre->unitmenu,
|
||||||
3, 4,
|
3, 4,
|
||||||
independent ? 4 : 3, independent ? 5 : 4,
|
independent ? 4 : 3, independent ? 5 : 4,
|
||||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||||
g_signal_connect (gre->unitmenu, "unit-changed",
|
g_signal_connect (gre->unitmenu, "unit-changed",
|
||||||
@ -396,19 +400,19 @@ gimp_resolution_entry_new (const gchar *width_label,
|
|||||||
gtk_table_attach_defaults (GTK_TABLE (gre), gre->width.spinbutton,
|
gtk_table_attach_defaults (GTK_TABLE (gre), gre->width.spinbutton,
|
||||||
1, 2,
|
1, 2,
|
||||||
1, 2);
|
1, 2);
|
||||||
|
|
||||||
gtk_table_attach_defaults (GTK_TABLE (gre), gre->width.label,
|
gtk_table_attach_defaults (GTK_TABLE (gre), gre->width.label,
|
||||||
3, 4,
|
3, 4,
|
||||||
1, 2);
|
1, 2);
|
||||||
|
|
||||||
g_signal_connect (gre->width.adjustment, "value-changed",
|
g_signal_connect (gre->width.adjustment, "value-changed",
|
||||||
G_CALLBACK (gimp_resolution_entry_value_callback),
|
G_CALLBACK (gimp_resolution_entry_value_callback),
|
||||||
&gre->width);
|
&gre->width);
|
||||||
|
|
||||||
gtk_widget_show (gre->width.spinbutton);
|
gtk_widget_show (gre->width.spinbutton);
|
||||||
gtk_widget_show (gre->width.label);
|
gtk_widget_show (gre->width.label);
|
||||||
|
|
||||||
gimp_resolution_entry_field_init (gre, &gre->height,
|
gimp_resolution_entry_field_init (gre, &gre->height,
|
||||||
independent ? &gre->y : &gre->x,
|
independent ? &gre->y : &gre->x,
|
||||||
HEIGHT_CHANGED,
|
HEIGHT_CHANGED,
|
||||||
height, size_unit,
|
height, size_unit,
|
||||||
@ -418,29 +422,29 @@ gimp_resolution_entry_new (const gchar *width_label,
|
|||||||
gtk_table_attach_defaults (GTK_TABLE (gre), gre->height.spinbutton,
|
gtk_table_attach_defaults (GTK_TABLE (gre), gre->height.spinbutton,
|
||||||
1, 2,
|
1, 2,
|
||||||
2, 3);
|
2, 3);
|
||||||
|
|
||||||
gtk_table_attach_defaults (GTK_TABLE (gre), gre->height.label,
|
gtk_table_attach_defaults (GTK_TABLE (gre), gre->height.label,
|
||||||
3, 4,
|
3, 4,
|
||||||
2, 3);
|
2, 3);
|
||||||
|
|
||||||
g_signal_connect (gre->height.adjustment, "value-changed",
|
g_signal_connect (gre->height.adjustment, "value-changed",
|
||||||
G_CALLBACK (gimp_resolution_entry_value_callback),
|
G_CALLBACK (gimp_resolution_entry_value_callback),
|
||||||
&gre->height);
|
&gre->height);
|
||||||
|
|
||||||
gtk_widget_show (gre->height.spinbutton);
|
gtk_widget_show (gre->height.spinbutton);
|
||||||
gtk_widget_show (gre->height.label);
|
gtk_widget_show (gre->height.label);
|
||||||
|
|
||||||
if (width_label)
|
if (width_label)
|
||||||
gimp_resolution_entry_attach_label (gre, width_label, 1, 0, 1.0);
|
gimp_resolution_entry_attach_label (gre, width_label, 1, 0, 0.0);
|
||||||
|
|
||||||
if (height_label)
|
if (height_label)
|
||||||
gimp_resolution_entry_attach_label (gre, height_label, 2, 0, 1.0);
|
gimp_resolution_entry_attach_label (gre, height_label, 2, 0, 0.0);
|
||||||
|
|
||||||
if (x_label)
|
if (x_label)
|
||||||
gimp_resolution_entry_attach_label (gre, x_label, 3, 0, 1.0);
|
gimp_resolution_entry_attach_label (gre, x_label, 3, 0, 0.0);
|
||||||
|
|
||||||
if (independent && y_label)
|
if (independent && y_label)
|
||||||
gimp_resolution_entry_attach_label (gre, y_label, 4, 0, 1.0);
|
gimp_resolution_entry_attach_label (gre, y_label, 4, 0, 0.0);
|
||||||
|
|
||||||
return GTK_WIDGET (gre);
|
return GTK_WIDGET (gre);
|
||||||
}
|
}
|
||||||
@ -480,7 +484,7 @@ gimp_resolution_entry_attach_label (GimpResolutionEntry *gre,
|
|||||||
|
|
||||||
for (list = GTK_TABLE (gre)->children; list; list = g_list_next (list))
|
for (list = GTK_TABLE (gre)->children; list; list = g_list_next (list))
|
||||||
{
|
{
|
||||||
child = (GtkTableChild *) list->data;
|
child = list->data;
|
||||||
|
|
||||||
if (child->left_attach == 1 && child->top_attach == row)
|
if (child->left_attach == 1 && child->top_attach == row)
|
||||||
{
|
{
|
||||||
@ -506,7 +510,7 @@ gimp_resolution_entry_attach_label (GimpResolutionEntry *gre,
|
|||||||
* @lower: The new lower boundary of the value of the field in pixels.
|
* @lower: The new lower boundary of the value of the field in pixels.
|
||||||
* @upper: The new upper boundary of the value of the field in pixels.
|
* @upper: The new upper boundary of the value of the field in pixels.
|
||||||
*
|
*
|
||||||
* Limits the range of possible values which can be entered in the width field
|
* Limits the range of possible values which can be entered in the width field
|
||||||
* of the #GimpResolutionEntry.
|
* of the #GimpResolutionEntry.
|
||||||
*
|
*
|
||||||
* The current value of the field will be clamped to fit in its
|
* The current value of the field will be clamped to fit in its
|
||||||
@ -532,7 +536,7 @@ gimp_resolution_entry_set_width_value_boundaries (GimpResolutionEntry *gre,
|
|||||||
* @lower: The new lower boundary of the value of the field in pixels.
|
* @lower: The new lower boundary of the value of the field in pixels.
|
||||||
* @upper: The new upper boundary of the value of the field in pixels.
|
* @upper: The new upper boundary of the value of the field in pixels.
|
||||||
*
|
*
|
||||||
* Limits the range of possible values which can be entered in the height field
|
* Limits the range of possible values which can be entered in the height field
|
||||||
* of the #GimpResolutionEntry.
|
* of the #GimpResolutionEntry.
|
||||||
*
|
*
|
||||||
* The current value of the field will be clamped to fit in its
|
* The current value of the field will be clamped to fit in its
|
||||||
@ -558,7 +562,7 @@ gimp_resolution_entry_set_height_value_boundaries (GimpResolutionEntry *gre,
|
|||||||
* @lower: The new lower boundary of the value of the field, in the current unit.
|
* @lower: The new lower boundary of the value of the field, in the current unit.
|
||||||
* @upper: The new upper boundary of the value of the field, in the current unit.
|
* @upper: The new upper boundary of the value of the field, in the current unit.
|
||||||
*
|
*
|
||||||
* Limits the range of possible values which can be entered in the x field
|
* Limits the range of possible values which can be entered in the x field
|
||||||
* of the #GimpResolutionEntry.
|
* of the #GimpResolutionEntry.
|
||||||
*
|
*
|
||||||
* The current value of the field will be clamped to fit in its
|
* The current value of the field will be clamped to fit in its
|
||||||
@ -584,7 +588,7 @@ gimp_resolution_entry_set_x_boundaries (GimpResolutionEntry *gre,
|
|||||||
* @lower: The new lower boundary of the value of the field, in the current unit.
|
* @lower: The new lower boundary of the value of the field, in the current unit.
|
||||||
* @upper: The new upper boundary of the value of the field, in the current unit.
|
* @upper: The new upper boundary of the value of the field, in the current unit.
|
||||||
*
|
*
|
||||||
* Limits the range of possible values which can be entered in the y field
|
* Limits the range of possible values which can be entered in the y field
|
||||||
* of the #GimpResolutionEntry.
|
* of the #GimpResolutionEntry.
|
||||||
*
|
*
|
||||||
* The current value of the field will be clamped to fit in its
|
* The current value of the field will be clamped to fit in its
|
||||||
@ -619,7 +623,7 @@ gimp_resolution_entry_field_set_boundaries (GimpResolutionEntryField *gref,
|
|||||||
GTK_ADJUSTMENT (gref->adjustment)->lower = gref->min_value;
|
GTK_ADJUSTMENT (gref->adjustment)->lower = gref->min_value;
|
||||||
GTK_ADJUSTMENT (gref->adjustment)->upper = gref->max_value;
|
GTK_ADJUSTMENT (gref->adjustment)->upper = gref->max_value;
|
||||||
|
|
||||||
if (gref->value > upper || gref->value < lower)
|
if (gref->value > upper || gref->value < lower)
|
||||||
gimp_resolution_entry_field_set_value (gref, gref->value);
|
gimp_resolution_entry_field_set_value (gref, gref->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,7 +642,7 @@ gdouble
|
|||||||
gimp_resolution_entry_get_width (GimpResolutionEntry *gre)
|
gimp_resolution_entry_get_width (GimpResolutionEntry *gre)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
||||||
|
|
||||||
return gre->width.value;
|
return gre->width.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,7 +661,7 @@ gdouble
|
|||||||
gimp_resolution_entry_get_height (GimpResolutionEntry *gre)
|
gimp_resolution_entry_get_height (GimpResolutionEntry *gre)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
||||||
|
|
||||||
return gre->height.value;
|
return gre->height.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,7 +680,7 @@ gdouble
|
|||||||
gimp_resolution_entry_get_x (GimpResolutionEntry *gre)
|
gimp_resolution_entry_get_x (GimpResolutionEntry *gre)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
||||||
|
|
||||||
return gre->x.value;
|
return gre->x.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,7 +699,7 @@ gdouble
|
|||||||
gimp_resolution_entry_get_x_in_dpi (GimpResolutionEntry *gre)
|
gimp_resolution_entry_get_x_in_dpi (GimpResolutionEntry *gre)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
||||||
|
|
||||||
return gre->x.value / gimp_unit_get_factor (gre->unit);
|
return gre->x.value / gimp_unit_get_factor (gre->unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,7 +718,7 @@ gdouble
|
|||||||
gimp_resolution_entry_get_y (GimpResolutionEntry *gre)
|
gimp_resolution_entry_get_y (GimpResolutionEntry *gre)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
||||||
|
|
||||||
return gre->y.value;
|
return gre->y.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +737,7 @@ gdouble
|
|||||||
gimp_resolution_entry_get_y_in_dpi (GimpResolutionEntry *gre)
|
gimp_resolution_entry_get_y_in_dpi (GimpResolutionEntry *gre)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), 0);
|
||||||
|
|
||||||
return gre->y.value / gimp_unit_get_factor (gre->unit);
|
return gre->y.value / gimp_unit_get_factor (gre->unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,7 +753,7 @@ gimp_resolution_entry_update_value (GimpResolutionEntryField *gref,
|
|||||||
|
|
||||||
gref->stop_recursion++;
|
gref->stop_recursion++;
|
||||||
|
|
||||||
if (gref->gre->independent &&
|
if (gref->gre->independent &&
|
||||||
!gref->size &&
|
!gref->size &&
|
||||||
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (gref->gre->chainbutton)))
|
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (gref->gre->chainbutton)))
|
||||||
{
|
{
|
||||||
@ -769,24 +773,24 @@ gimp_resolution_entry_update_value (GimpResolutionEntryField *gref,
|
|||||||
if (gref->gre->independent)
|
if (gref->gre->independent)
|
||||||
gimp_resolution_entry_update_value (gref->corresponding,
|
gimp_resolution_entry_update_value (gref->corresponding,
|
||||||
gref->value *
|
gref->value *
|
||||||
gref->corresponding->phy_size *
|
gref->corresponding->phy_size *
|
||||||
factor);
|
factor);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_resolution_entry_update_value (&gref->gre->width,
|
gimp_resolution_entry_update_value (&gref->gre->width,
|
||||||
gref->value *
|
gref->value *
|
||||||
gref->gre->width.phy_size *
|
gref->gre->width.phy_size *
|
||||||
factor);
|
factor);
|
||||||
|
|
||||||
gimp_resolution_entry_update_value (&gref->gre->height,
|
gimp_resolution_entry_update_value (&gref->gre->height,
|
||||||
gref->value *
|
gref->value *
|
||||||
gref->gre->height.phy_size *
|
gref->gre->height.phy_size *
|
||||||
factor);
|
factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (gref->adjustment), value);
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (gref->adjustment), value);
|
||||||
|
|
||||||
gref->stop_recursion--;
|
gref->stop_recursion--;
|
||||||
|
|
||||||
g_signal_emit (gref->gre, gref->changed_signal, 0);
|
g_signal_emit (gref->gre, gref->changed_signal, 0);
|
||||||
@ -917,8 +921,6 @@ gimp_resolution_entry_update_unit (GimpResolutionEntry *gre,
|
|||||||
{
|
{
|
||||||
GimpUnit old_unit;
|
GimpUnit old_unit;
|
||||||
gint digits;
|
gint digits;
|
||||||
|
|
||||||
gchar *label_text;
|
|
||||||
gdouble factor;
|
gdouble factor;
|
||||||
|
|
||||||
old_unit = gre->unit;
|
old_unit = gre->unit;
|
||||||
@ -926,18 +928,17 @@ gimp_resolution_entry_update_unit (GimpResolutionEntry *gre,
|
|||||||
|
|
||||||
digits = (gimp_unit_get_digits (GIMP_UNIT_INCH) -
|
digits = (gimp_unit_get_digits (GIMP_UNIT_INCH) -
|
||||||
gimp_unit_get_digits (unit));
|
gimp_unit_get_digits (unit));
|
||||||
|
|
||||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gre->x.spinbutton),
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gre->x.spinbutton),
|
||||||
MAX (3 + digits, 3));
|
MAX (3 + digits, 3));
|
||||||
|
|
||||||
|
|
||||||
factor = gimp_unit_get_factor (old_unit) /
|
factor = gimp_unit_get_factor (old_unit) / gimp_unit_get_factor (unit);
|
||||||
gimp_unit_get_factor (unit);
|
|
||||||
|
|
||||||
gre->x.min_value *= factor;
|
gre->x.min_value *= factor;
|
||||||
gre->x.max_value *= factor;
|
gre->x.max_value *= factor;
|
||||||
gre->x.value *= factor;
|
gre->x.value *= factor;
|
||||||
|
|
||||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (gre->x.adjustment),
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (gre->x.adjustment),
|
||||||
gre->x.value);
|
gre->x.value);
|
||||||
|
|
||||||
@ -950,28 +951,17 @@ gimp_resolution_entry_update_unit (GimpResolutionEntry *gre,
|
|||||||
gre->y.min_value *= factor;
|
gre->y.min_value *= factor;
|
||||||
gre->y.max_value *= factor;
|
gre->y.max_value *= factor;
|
||||||
gre->y.value *= factor;
|
gre->y.value *= factor;
|
||||||
|
|
||||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (gre->y.adjustment),
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (gre->y.adjustment),
|
||||||
gre->y.value);
|
gre->y.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
factor = gimp_unit_get_factor (unit);
|
gimp_resolution_entry_format_label (gre,
|
||||||
|
gre->width.label, gre->width.phy_size);
|
||||||
/*
|
gimp_resolution_entry_format_label (gre,
|
||||||
* warning: not correctly localizable in many gimp supported languages
|
gre->height.label, gre->height.phy_size);
|
||||||
*/
|
|
||||||
label_text = g_strdup_printf (_("%f %s"), gre->width.phy_size * factor,
|
|
||||||
gimp_unit_get_plural (unit));
|
|
||||||
gtk_label_set_text (GTK_LABEL (gre->width.label), label_text);
|
|
||||||
g_free (label_text);
|
|
||||||
|
|
||||||
label_text = g_strdup_printf (_("%f %s"), gre->height.phy_size * factor,
|
|
||||||
gimp_unit_get_plural (unit));
|
|
||||||
gtk_label_set_text (GTK_LABEL (gre->height.label), label_text);
|
|
||||||
g_free (label_text);
|
|
||||||
|
|
||||||
|
|
||||||
g_signal_emit (gre, gimp_resolution_entry_signals[UNIT_CHANGED], 0);
|
g_signal_emit (gre, gimp_resolution_entry_signals[UNIT_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,7 +1171,7 @@ gimp_resolution_entry_get_y_help_widget (GimpResolutionEntry *gre)
|
|||||||
* gimp_resolution_entry_update_width:
|
* gimp_resolution_entry_update_width:
|
||||||
* @gre: the #GimpResolutionEntry
|
* @gre: the #GimpResolutionEntry
|
||||||
* @data: a pointer to a gdouble
|
* @data: a pointer to a gdouble
|
||||||
*
|
*
|
||||||
* Convenience function to set a double to the width, suitable
|
* Convenience function to set a double to the width, suitable
|
||||||
* for use as a signal callback.
|
* for use as a signal callback.
|
||||||
*
|
*
|
||||||
@ -1193,7 +1183,7 @@ gimp_resolution_entry_update_width (GimpResolutionEntry *gre,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
gdouble *val;
|
gdouble *val;
|
||||||
|
|
||||||
g_return_if_fail (gre != NULL);
|
g_return_if_fail (gre != NULL);
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
@ -1208,7 +1198,7 @@ gimp_resolution_entry_update_width (GimpResolutionEntry *gre,
|
|||||||
* gimp_resolution_entry_update_height:
|
* gimp_resolution_entry_update_height:
|
||||||
* @gre: the #GimpResolutionEntry
|
* @gre: the #GimpResolutionEntry
|
||||||
* @data: a pointer to a gdouble
|
* @data: a pointer to a gdouble
|
||||||
*
|
*
|
||||||
* Convenience function to set a double to the height, suitable
|
* Convenience function to set a double to the height, suitable
|
||||||
* for use as a signal callback.
|
* for use as a signal callback.
|
||||||
*
|
*
|
||||||
@ -1220,7 +1210,7 @@ gimp_resolution_entry_update_height (GimpResolutionEntry *gre,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
gdouble *val;
|
gdouble *val;
|
||||||
|
|
||||||
g_return_if_fail (gre != NULL);
|
g_return_if_fail (gre != NULL);
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
@ -1235,7 +1225,7 @@ gimp_resolution_entry_update_height (GimpResolutionEntry *gre,
|
|||||||
* gimp_resolution_entry_update_x:
|
* gimp_resolution_entry_update_x:
|
||||||
* @gre: the #GimpResolutionEntry
|
* @gre: the #GimpResolutionEntry
|
||||||
* @data: a pointer to a gdouble
|
* @data: a pointer to a gdouble
|
||||||
*
|
*
|
||||||
* Convenience function to set a double to the X resolution, suitable
|
* Convenience function to set a double to the X resolution, suitable
|
||||||
* for use as a signal callback.
|
* for use as a signal callback.
|
||||||
*
|
*
|
||||||
@ -1247,7 +1237,7 @@ gimp_resolution_entry_update_x (GimpResolutionEntry *gre,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
gdouble *val;
|
gdouble *val;
|
||||||
|
|
||||||
g_return_if_fail (gre != NULL);
|
g_return_if_fail (gre != NULL);
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
@ -1261,7 +1251,7 @@ gimp_resolution_entry_update_x (GimpResolutionEntry *gre,
|
|||||||
* gimp_resolution_entry_update_x_in_dpi:
|
* gimp_resolution_entry_update_x_in_dpi:
|
||||||
* @gre: the #GimpResolutionEntry
|
* @gre: the #GimpResolutionEntry
|
||||||
* @data: a pointer to a gdouble
|
* @data: a pointer to a gdouble
|
||||||
*
|
*
|
||||||
* Convenience function to set a double to the X resolution, suitable
|
* Convenience function to set a double to the X resolution, suitable
|
||||||
* for use as a signal callback.
|
* for use as a signal callback.
|
||||||
*
|
*
|
||||||
@ -1273,7 +1263,7 @@ gimp_resolution_entry_update_x_in_dpi (GimpResolutionEntry *gre,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
gdouble *val;
|
gdouble *val;
|
||||||
|
|
||||||
g_return_if_fail (gre != NULL);
|
g_return_if_fail (gre != NULL);
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
@ -1287,7 +1277,7 @@ gimp_resolution_entry_update_x_in_dpi (GimpResolutionEntry *gre,
|
|||||||
* gimp_resolution_entry_update_y:
|
* gimp_resolution_entry_update_y:
|
||||||
* @gre: the #GimpResolutionEntry
|
* @gre: the #GimpResolutionEntry
|
||||||
* @data: a pointer to a gdouble
|
* @data: a pointer to a gdouble
|
||||||
*
|
*
|
||||||
* Convenience function to set a double to the Y resolution, suitable
|
* Convenience function to set a double to the Y resolution, suitable
|
||||||
* for use as a signal callback.
|
* for use as a signal callback.
|
||||||
*
|
*
|
||||||
@ -1299,7 +1289,7 @@ gimp_resolution_entry_update_y (GimpResolutionEntry *gre,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
gdouble *val;
|
gdouble *val;
|
||||||
|
|
||||||
g_return_if_fail (gre != NULL);
|
g_return_if_fail (gre != NULL);
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
@ -1313,7 +1303,7 @@ gimp_resolution_entry_update_y (GimpResolutionEntry *gre,
|
|||||||
* gimp_resolution_entry_update_y_in_dpi:
|
* gimp_resolution_entry_update_y_in_dpi:
|
||||||
* @gre: the #GimpResolutionEntry
|
* @gre: the #GimpResolutionEntry
|
||||||
* @data: a pointer to a gdouble
|
* @data: a pointer to a gdouble
|
||||||
*
|
*
|
||||||
* Convenience function to set a double to the Y resolution, suitable
|
* Convenience function to set a double to the Y resolution, suitable
|
||||||
* for use as a signal callback.
|
* for use as a signal callback.
|
||||||
*
|
*
|
||||||
@ -1325,7 +1315,7 @@ gimp_resolution_entry_update_y_in_dpi (GimpResolutionEntry *gre,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
gdouble *val;
|
gdouble *val;
|
||||||
|
|
||||||
g_return_if_fail (gre != NULL);
|
g_return_if_fail (gre != NULL);
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre));
|
||||||
@ -1334,3 +1324,19 @@ gimp_resolution_entry_update_y_in_dpi (GimpResolutionEntry *gre,
|
|||||||
|
|
||||||
*val = gimp_resolution_entry_get_y_in_dpi (gre);
|
*val = gimp_resolution_entry_get_y_in_dpi (gre);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_resolution_entry_format_label (GimpResolutionEntry *gre,
|
||||||
|
GtkWidget *label,
|
||||||
|
gdouble size)
|
||||||
|
{
|
||||||
|
gchar *format = g_strdup_printf ("%%.%df %%s",
|
||||||
|
gimp_unit_get_digits (gre->unit));
|
||||||
|
gchar *text = g_strdup_printf (format,
|
||||||
|
size * gimp_unit_get_factor (gre->unit),
|
||||||
|
gimp_unit_get_plural (gre->unit));
|
||||||
|
g_free (format);
|
||||||
|
|
||||||
|
gtk_label_set_text (GTK_LABEL (label), text);
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* The GIMP -- an image manipulation program
|
/* The GIMP -- an image manipulation program
|
||||||
*
|
*
|
||||||
* pdf.c - PDF file loader
|
* poppler.c - PDF file loader
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 Nathan Summers
|
* Copyright (C) 2005 Nathan Summers
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -105,7 +105,7 @@ query (void)
|
|||||||
{ GIMP_PDB_INT32, "n_pages", "Number of pages to load (0 for all)"},
|
{ GIMP_PDB_INT32, "n_pages", "Number of pages to load (0 for all)"},
|
||||||
{ GIMP_PDB_INT32ARRAY,"page", "The pages to load"}
|
{ GIMP_PDB_INT32ARRAY,"page", "The pages to load"}
|
||||||
};
|
};
|
||||||
|
|
||||||
static GimpParamDef load_return_vals[] =
|
static GimpParamDef load_return_vals[] =
|
||||||
{
|
{
|
||||||
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
||||||
@ -174,14 +174,13 @@ run (const gchar *name,
|
|||||||
{
|
{
|
||||||
static GimpParam values[2];
|
static GimpParam values[2];
|
||||||
GimpRunMode run_mode;
|
GimpRunMode run_mode;
|
||||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||||
gint32 image_ID;
|
gint32 image_ID = -1;
|
||||||
|
PopplerDocument *doc = NULL;
|
||||||
PopplerDocument *doc;
|
|
||||||
|
|
||||||
run_mode = param[0].data.d_int32;
|
run_mode = param[0].data.d_int32;
|
||||||
|
|
||||||
INIT_I18N ();
|
INIT_I18N ();
|
||||||
|
|
||||||
*nreturn_vals = 1;
|
*nreturn_vals = 1;
|
||||||
*return_vals = values;
|
*return_vals = values;
|
||||||
@ -195,7 +194,7 @@ run (const gchar *name,
|
|||||||
if (strcmp (name, "file_pdf_load") == 0)
|
if (strcmp (name, "file_pdf_load") == 0)
|
||||||
{
|
{
|
||||||
PdfSelectedPages *pages = g_new (PdfSelectedPages, 1);
|
PdfSelectedPages *pages = g_new (PdfSelectedPages, 1);
|
||||||
|
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
@ -225,7 +224,7 @@ run (const gchar *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
image_ID = load_image (doc, param[1].data.d_string,
|
image_ID = load_image (doc, param[1].data.d_string,
|
||||||
loadvals.resolution,
|
loadvals.resolution,
|
||||||
loadvals.antialias,
|
loadvals.antialias,
|
||||||
pages);
|
pages);
|
||||||
@ -268,14 +267,14 @@ run (const gchar *name,
|
|||||||
|
|
||||||
if (doc)
|
if (doc)
|
||||||
{
|
{
|
||||||
PopplerPage *page = poppler_document_get_page (doc, 0);
|
PopplerPage *page = poppler_document_get_page (doc, 0);
|
||||||
if (page)
|
if (page)
|
||||||
{
|
{
|
||||||
poppler_page_get_size (page, &width, &height);
|
poppler_page_get_size (page, &width, &height);
|
||||||
|
|
||||||
g_object_unref (page);
|
g_object_unref (page);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = get_thumbnail (doc, 0, param[1].data.d_int32);
|
buf = get_thumbnail (doc, 0, param[1].data.d_int32);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,13 +283,13 @@ run (const gchar *name,
|
|||||||
image = gimp_image_new (gdk_pixbuf_get_width (buf),
|
image = gimp_image_new (gdk_pixbuf_get_width (buf),
|
||||||
gdk_pixbuf_get_height (buf),
|
gdk_pixbuf_get_height (buf),
|
||||||
GIMP_RGB);
|
GIMP_RGB);
|
||||||
|
|
||||||
layer_from_pixbuf (image, "thumbnail", 0, buf,
|
layer_from_pixbuf (image, "thumbnail", 0, buf,
|
||||||
0.0, 1.0);
|
0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scale = loadvals.resolution /
|
|
||||||
|
scale = loadvals.resolution /
|
||||||
gimp_unit_get_factor (GIMP_UNIT_POINT);
|
gimp_unit_get_factor (GIMP_UNIT_POINT);
|
||||||
|
|
||||||
width *= scale;
|
width *= scale;
|
||||||
@ -327,14 +326,14 @@ run (const gchar *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PopplerDocument*
|
static PopplerDocument*
|
||||||
open_document (const gchar *filename)
|
open_document (const gchar *filename)
|
||||||
{
|
{
|
||||||
PopplerDocument *doc;
|
PopplerDocument *doc;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
uri = g_filename_to_uri (filename, NULL, &err);
|
uri = g_filename_to_uri (filename, NULL, &err);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
g_message ("Could not convert '%s' to a URI: %s",
|
g_message ("Could not convert '%s' to a URI: %s",
|
||||||
@ -343,7 +342,7 @@ open_document (const gchar *filename)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = poppler_document_new_from_file (uri, NULL, &err);
|
doc = poppler_document_new_from_file (uri, NULL, &err);
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
@ -385,12 +384,12 @@ layer_from_pixbuf (gint32 image,
|
|||||||
|
|
||||||
width = gdk_pixbuf_get_width (buf);
|
width = gdk_pixbuf_get_width (buf);
|
||||||
height = gdk_pixbuf_get_height (buf);
|
height = gdk_pixbuf_get_height (buf);
|
||||||
|
|
||||||
rowstride = gdk_pixbuf_get_rowstride (buf);
|
rowstride = gdk_pixbuf_get_rowstride (buf);
|
||||||
bpp = gdk_pixbuf_get_n_channels (buf);
|
bpp = gdk_pixbuf_get_n_channels (buf);
|
||||||
pixels = gdk_pixbuf_get_pixels (buf);
|
pixels = gdk_pixbuf_get_pixels (buf);
|
||||||
|
|
||||||
layer = gimp_layer_new (image, layer_name,
|
layer = gimp_layer_new (image, layer_name,
|
||||||
width, height,
|
width, height,
|
||||||
GIMP_RGB_IMAGE, 100.0, GIMP_NORMAL_MODE);
|
GIMP_RGB_IMAGE, 100.0, GIMP_NORMAL_MODE);
|
||||||
|
|
||||||
@ -423,14 +422,14 @@ layer_from_pixbuf (gint32 image,
|
|||||||
|
|
||||||
gimp_progress_update (progress_start + progress * progress_scale);
|
gimp_progress_update (progress_start + progress * progress_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_drawable_detach (drawable);
|
gimp_drawable_detach (drawable);
|
||||||
|
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint32
|
static gint32
|
||||||
load_image (PopplerDocument *doc,
|
load_image (PopplerDocument *doc,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
guint32 resolution,
|
guint32 resolution,
|
||||||
gboolean antialias,
|
gboolean antialias,
|
||||||
@ -438,19 +437,19 @@ load_image (PopplerDocument *doc,
|
|||||||
{
|
{
|
||||||
gint32 image = 0;
|
gint32 image = 0;
|
||||||
|
|
||||||
|
|
||||||
double scale;
|
double scale;
|
||||||
|
|
||||||
PopplerPage *page;
|
PopplerPage *page;
|
||||||
gchar *page_label;
|
gchar *page_label;
|
||||||
int i;
|
int i;
|
||||||
double page_width;
|
double page_width;
|
||||||
double page_height;
|
double page_height;
|
||||||
|
|
||||||
GdkPixbuf *buf;
|
GdkPixbuf *buf;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
|
||||||
double doc_progress = 0;
|
double doc_progress = 0;
|
||||||
|
|
||||||
gimp_progress_init (NULL);
|
gimp_progress_init (NULL);
|
||||||
@ -466,14 +465,14 @@ load_image (PopplerDocument *doc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < pages->n_pages; i++)
|
for (i = 0; i < pages->n_pages; i++)
|
||||||
{
|
{
|
||||||
page = poppler_document_get_page (doc, pages->pages[i]);
|
page = poppler_document_get_page (doc, pages->pages[i]);
|
||||||
|
|
||||||
|
|
||||||
poppler_page_get_size (page, &page_width, &page_height);
|
poppler_page_get_size (page, &page_width, &page_height);
|
||||||
width = page_width * scale;
|
width = page_width * scale;
|
||||||
height = page_height * scale;
|
height = page_height * scale;
|
||||||
|
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
image = gimp_image_new (width, height, GIMP_RGB);
|
image = gimp_image_new (width, height, GIMP_RGB);
|
||||||
@ -492,13 +491,13 @@ load_image (PopplerDocument *doc,
|
|||||||
0, 0);
|
0, 0);
|
||||||
|
|
||||||
g_object_get (G_OBJECT (page), "label", &page_label, NULL);
|
g_object_get (G_OBJECT (page), "label", &page_label, NULL);
|
||||||
|
|
||||||
layer_from_pixbuf (image, page_label, i, buf,
|
layer_from_pixbuf (image, page_label, i, buf,
|
||||||
doc_progress, 1.0 / pages->n_pages);
|
doc_progress, 1.0 / pages->n_pages);
|
||||||
|
|
||||||
g_free (page_label);
|
g_free (page_label);
|
||||||
|
|
||||||
|
|
||||||
doc_progress = (double) (i + 1) / pages->n_pages;
|
doc_progress = (double) (i + 1) / pages->n_pages;
|
||||||
gimp_progress_update (doc_progress);
|
gimp_progress_update (doc_progress);
|
||||||
|
|
||||||
@ -520,10 +519,10 @@ get_thumbnail (PopplerDocument *doc,
|
|||||||
|
|
||||||
if (! page)
|
if (! page)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pixbuf = poppler_page_get_thumbnail (page);
|
pixbuf = poppler_page_get_thumbnail (page);
|
||||||
|
|
||||||
if (! pixbuf)
|
if (! pixbuf)
|
||||||
{
|
{
|
||||||
double width, height, scale;
|
double width, height, scale;
|
||||||
|
|
||||||
@ -609,24 +608,24 @@ static gboolean
|
|||||||
load_dialog (PopplerDocument *doc,
|
load_dialog (PopplerDocument *doc,
|
||||||
PdfSelectedPages *pages)
|
PdfSelectedPages *pages)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *title;
|
GtkWidget *title;
|
||||||
GtkWidget *selector;
|
GtkWidget *selector;
|
||||||
GtkWidget *table;
|
GtkWidget *resolution;
|
||||||
GtkWidget *resolution;
|
GtkWidget *toggle;
|
||||||
GtkWidget *toggle;
|
GtkWidget *hbox;
|
||||||
|
|
||||||
ThreadData thread_data;
|
|
||||||
GThread *thread;
|
|
||||||
|
|
||||||
int i;
|
ThreadData thread_data;
|
||||||
int n_pages;
|
GThread *thread;
|
||||||
|
|
||||||
gdouble width;
|
gint i;
|
||||||
gdouble height;
|
gint n_pages;
|
||||||
|
|
||||||
gboolean run;
|
gdouble width;
|
||||||
|
gdouble height;
|
||||||
|
|
||||||
|
gboolean run;
|
||||||
|
|
||||||
gimp_ui_init ("file-pdf-load", FALSE);
|
gimp_ui_init ("file-pdf-load", FALSE);
|
||||||
|
|
||||||
@ -660,7 +659,7 @@ load_dialog (PopplerDocument *doc,
|
|||||||
n_pages = poppler_document_get_n_pages (doc);
|
n_pages = poppler_document_get_n_pages (doc);
|
||||||
gimp_page_selector_set_n_pages (GIMP_PAGE_SELECTOR (selector), n_pages);
|
gimp_page_selector_set_n_pages (GIMP_PAGE_SELECTOR (selector), n_pages);
|
||||||
|
|
||||||
for (i=0; i<n_pages; i++)
|
for (i = 0; i < n_pages; i++)
|
||||||
{
|
{
|
||||||
PopplerPage *page;
|
PopplerPage *page;
|
||||||
gchar *label;
|
gchar *label;
|
||||||
@ -673,48 +672,45 @@ load_dialog (PopplerDocument *doc,
|
|||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
poppler_page_get_size (page, &width, &height);
|
poppler_page_get_size (page, &width, &height);
|
||||||
|
|
||||||
g_object_unref (page);
|
g_object_unref (page);
|
||||||
g_free (label);
|
g_free (label);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show (selector);
|
gtk_widget_show (selector);
|
||||||
|
|
||||||
thread_data.document = doc;
|
thread_data.document = doc;
|
||||||
thread_data.selector = GIMP_PAGE_SELECTOR (selector);
|
thread_data.selector = GIMP_PAGE_SELECTOR (selector);
|
||||||
thread_data.stop_thumbnailing = FALSE;
|
thread_data.stop_thumbnailing = FALSE;
|
||||||
|
|
||||||
thread = g_thread_create (thumbnail_thread, &thread_data, TRUE, NULL);
|
thread = g_thread_create (thumbnail_thread, &thread_data, TRUE, NULL);
|
||||||
|
|
||||||
/* table */
|
|
||||||
table = gtk_table_new (1, 2, FALSE);
|
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (table);
|
|
||||||
|
|
||||||
/* Resolution */
|
/* Resolution */
|
||||||
|
|
||||||
resolution = gimp_resolution_entry_new ("_Width (pixels): ", width,
|
hbox = gtk_hbox_new (FALSE, 0);
|
||||||
"_Height (pixels): ", height,
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
|
resolution = gimp_resolution_entry_new ("_Width (pixels):", width,
|
||||||
|
"_Height (pixels):", height,
|
||||||
GIMP_UNIT_POINT,
|
GIMP_UNIT_POINT,
|
||||||
|
|
||||||
"_Resolution: ", loadvals.resolution,
|
"_Resolution:", loadvals.resolution,
|
||||||
"_Resolution: ", loadvals.resolution,
|
"_Resolution:", loadvals.resolution,
|
||||||
GIMP_UNIT_INCH,
|
GIMP_UNIT_INCH,
|
||||||
|
|
||||||
FALSE,
|
FALSE,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), resolution, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), resolution, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (resolution);
|
gtk_widget_show (resolution);
|
||||||
|
|
||||||
g_signal_connect (resolution, "x-changed",
|
g_signal_connect (resolution, "x-changed",
|
||||||
G_CALLBACK (gimp_resolution_entry_update_x_in_dpi),
|
G_CALLBACK (gimp_resolution_entry_update_x_in_dpi),
|
||||||
&loadvals.resolution);
|
&loadvals.resolution);
|
||||||
|
|
||||||
/* Antialiasing */
|
/* Antialiasing */
|
||||||
toggle = gtk_check_button_new_with_mnemonic("A_ntialiasing");
|
toggle = gtk_check_button_new_with_mnemonic ("A_ntialiasing");
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
||||||
loadvals.antialias);
|
loadvals.antialias);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
||||||
@ -729,8 +725,8 @@ load_dialog (PopplerDocument *doc,
|
|||||||
|
|
||||||
/* run the dialog */
|
/* run the dialog */
|
||||||
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
||||||
|
|
||||||
pages->pages =
|
pages->pages =
|
||||||
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (selector),
|
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (selector),
|
||||||
&pages->n_pages);
|
&pages->n_pages);
|
||||||
|
|
||||||
@ -739,11 +735,11 @@ load_dialog (PopplerDocument *doc,
|
|||||||
{
|
{
|
||||||
gimp_page_selector_select_all (GIMP_PAGE_SELECTOR (selector));
|
gimp_page_selector_select_all (GIMP_PAGE_SELECTOR (selector));
|
||||||
|
|
||||||
pages->pages =
|
pages->pages =
|
||||||
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (selector),
|
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (selector),
|
||||||
&pages->n_pages);
|
&pages->n_pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
thread_data.stop_thumbnailing = TRUE;
|
thread_data.stop_thumbnailing = TRUE;
|
||||||
g_thread_join (thread);
|
g_thread_join (thread);
|
||||||
|
Reference in New Issue
Block a user