mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
Compare commits
2 Commits
142b79b728
...
alxsa-keep
Author | SHA1 | Date | |
---|---|---|---|
|
2d70eba248 | ||
|
6223d05391 |
@@ -49,7 +49,8 @@ enum
|
||||
PROP_YRESOLUTION,
|
||||
PROP_RESOLUTION_UNIT,
|
||||
PROP_KEEP_ASPECT,
|
||||
PROP_EDIT_RESOLUTION
|
||||
PROP_EDIT_RESOLUTION,
|
||||
PROP_KEEP_PRINT_SIZE
|
||||
};
|
||||
|
||||
|
||||
@@ -63,6 +64,7 @@ struct _GimpSizeBoxPrivate
|
||||
GimpChainButton *size_chain;
|
||||
GtkWidget *pixel_label;
|
||||
GtkWidget *res_label;
|
||||
GtkWidget *print_size_button;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +83,9 @@ static void gimp_size_box_update_size (GimpSizeBox *box);
|
||||
static void gimp_size_box_update_resolution (GimpSizeBox *box);
|
||||
static void gimp_size_box_chain_toggled (GimpChainButton *button,
|
||||
GimpSizeBox *box);
|
||||
static void gimp_size_box_keep_print_size (GimpSizeBox *box,
|
||||
gboolean resolution,
|
||||
gint resolution_field);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpSizeBox, gimp_size_box, GTK_TYPE_BOX)
|
||||
@@ -152,6 +157,12 @@ gimp_size_box_class_init (GimpSizeBoxClass *klass)
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (object_class, PROP_KEEP_PRINT_SIZE,
|
||||
g_param_spec_boolean ("keep-print-size",
|
||||
_("Keep Print Size"),
|
||||
NULL,
|
||||
TRUE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -212,9 +223,9 @@ gimp_size_box_constructed (GObject *object)
|
||||
box->xresolution,
|
||||
box->yresolution);
|
||||
|
||||
g_signal_connect (priv->size_chain, "toggled",
|
||||
G_CALLBACK (gimp_size_box_chain_toggled),
|
||||
box);
|
||||
g_signal_connect_object (priv->size_chain, "toggled",
|
||||
G_CALLBACK (gimp_size_box_chain_toggled),
|
||||
box, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
||||
gtk_widget_show (entry);
|
||||
@@ -245,7 +256,17 @@ gimp_size_box_constructed (GObject *object)
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
gtk_widget_set_visible (hbox, TRUE);
|
||||
|
||||
priv->print_size_button =
|
||||
gimp_prop_check_button_new (G_OBJECT (box), "keep-print-size", NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), priv->print_size_button, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_widget_set_visible (priv->print_size_button, TRUE);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_set_visible (hbox, TRUE);
|
||||
|
||||
chain_active = ABS (box->xresolution -
|
||||
box->yresolution) < GIMP_MIN_RESOLUTION;
|
||||
@@ -263,7 +284,7 @@ gimp_size_box_constructed (GObject *object)
|
||||
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
||||
gtk_widget_show (entry);
|
||||
gtk_widget_set_visible (entry, TRUE);
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (entry));
|
||||
for (list = children; list; list = g_list_next (list))
|
||||
@@ -285,7 +306,7 @@ gimp_size_box_constructed (GObject *object)
|
||||
-1);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
gtk_widget_set_visible (label, TRUE);
|
||||
|
||||
priv->res_label = label;
|
||||
}
|
||||
@@ -335,18 +356,14 @@ gimp_size_box_set_property (GObject *object,
|
||||
|
||||
case PROP_XRESOLUTION:
|
||||
box->xresolution = g_value_get_double (value);
|
||||
if (priv->size_entry)
|
||||
gimp_size_entry_set_resolution (priv->size_entry, 0,
|
||||
box->xresolution, TRUE);
|
||||
gimp_size_box_update_resolution (box);
|
||||
|
||||
gimp_size_box_keep_print_size (box, box->xresolution, 0);
|
||||
break;
|
||||
|
||||
case PROP_YRESOLUTION:
|
||||
box->yresolution = g_value_get_double (value);
|
||||
if (priv->size_entry)
|
||||
gimp_size_entry_set_resolution (priv->size_entry, 1,
|
||||
box->yresolution, TRUE);
|
||||
gimp_size_box_update_resolution (box);
|
||||
|
||||
gimp_size_box_keep_print_size (box, box->yresolution, 1);
|
||||
break;
|
||||
|
||||
case PROP_RESOLUTION_UNIT:
|
||||
@@ -363,6 +380,10 @@ gimp_size_box_set_property (GObject *object,
|
||||
box->edit_resolution = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_KEEP_PRINT_SIZE:
|
||||
box->keep_print_size = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -405,14 +426,19 @@ gimp_size_box_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_KEEP_ASPECT:
|
||||
g_value_set_boolean (value,
|
||||
gimp_chain_button_get_active (priv->size_chain));
|
||||
if (priv->size_chain)
|
||||
g_value_set_boolean (value,
|
||||
gimp_chain_button_get_active (priv->size_chain));
|
||||
break;
|
||||
|
||||
case PROP_EDIT_RESOLUTION:
|
||||
g_value_set_boolean (value, box->edit_resolution);
|
||||
break;
|
||||
|
||||
case PROP_KEEP_PRINT_SIZE:
|
||||
g_value_set_boolean (value, box->keep_print_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -439,7 +465,7 @@ gimp_size_box_update_resolution (GimpSizeBox *box)
|
||||
{
|
||||
GimpSizeBoxPrivate *priv = GIMP_SIZE_BOX_GET_PRIVATE (box);
|
||||
|
||||
if (priv->size_entry)
|
||||
if (priv->size_entry && ! box->keep_print_size)
|
||||
{
|
||||
gimp_size_entry_set_refval (priv->size_entry, 0, box->width);
|
||||
gimp_size_entry_set_refval (priv->size_entry, 1, box->height);
|
||||
@@ -469,3 +495,37 @@ gimp_size_box_chain_toggled (GimpChainButton *button,
|
||||
"keep-aspect", gimp_chain_button_get_active (button),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_size_box_keep_print_size (GimpSizeBox *box,
|
||||
gboolean resolution,
|
||||
gint resolution_field)
|
||||
{
|
||||
GimpSizeBoxPrivate *priv;
|
||||
gboolean original_aspect;
|
||||
|
||||
g_return_if_fail (GIMP_IS_SIZE_BOX (box));
|
||||
|
||||
priv = GIMP_SIZE_BOX_GET_PRIVATE (box);
|
||||
|
||||
g_object_get (box, "keep-aspect", &original_aspect, NULL);
|
||||
|
||||
if (priv->size_chain)
|
||||
g_signal_handlers_block_by_func (priv->size_chain,
|
||||
gimp_size_box_chain_toggled, box);
|
||||
|
||||
g_object_set (box, "keep-aspect", FALSE, NULL);
|
||||
|
||||
if (priv->size_entry)
|
||||
gimp_size_entry_set_resolution (priv->size_entry,
|
||||
resolution_field,
|
||||
resolution,
|
||||
! box->keep_print_size);
|
||||
gimp_size_box_update_resolution (box);
|
||||
|
||||
g_object_set (box, "keep-aspect", original_aspect, NULL);
|
||||
|
||||
if (priv->size_chain)
|
||||
g_signal_handlers_unblock_by_func (priv->size_chain,
|
||||
gimp_size_box_chain_toggled, box);
|
||||
}
|
||||
|
@@ -45,6 +45,7 @@ struct _GimpSizeBox
|
||||
GimpUnit *resolution_unit;
|
||||
|
||||
gboolean edit_resolution;
|
||||
gboolean keep_print_size;
|
||||
};
|
||||
|
||||
struct _GimpSizeBoxClass
|
||||
|
Reference in New Issue
Block a user