app/tools/gimprectangleoptions.c cleaned out some cruft. Still work in
2007-02-08 Sven Neumann <sven@gimp.org> * app/tools/gimprectangleoptions.c * app/widgets/gimppropwidgets.[ch]: cleaned out some cruft. Still work in progress. svn path=/trunk/; revision=21872
This commit is contained in:

committed by
Sven Neumann

parent
2b30f1b488
commit
938b316dae
@ -1,3 +1,9 @@
|
||||
2007-02-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimprectangleoptions.c
|
||||
* app/widgets/gimppropwidgets.[ch]: cleaned out some cruft. Still
|
||||
work in progress.
|
||||
|
||||
2007-02-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpratioentry.c (gimp_ratio_entry_set_fraction):
|
||||
|
@ -489,8 +489,8 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
GimpRectangleOptionsPrivate *private;
|
||||
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||
GtkWidget *button;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *table;
|
||||
@ -599,15 +599,14 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, row, row + 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gimp_prop_aspect_ratio_new (config,
|
||||
"aspect-numerator",
|
||||
"aspect-denominator",
|
||||
"fixed-aspect",
|
||||
"width",
|
||||
"height",
|
||||
3,
|
||||
GTK_TABLE (table),
|
||||
row, 2);
|
||||
entry = gimp_prop_aspect_ratio_new (config,
|
||||
"aspect-numerator",
|
||||
"aspect-denominator",
|
||||
"fixed-aspect",
|
||||
"width",
|
||||
"height");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), entry, 2, 5, row, row + 1);
|
||||
gtk_widget_show (entry);
|
||||
|
||||
button = gimp_prop_check_button_new (config, "fixed-aspect", _("Fix"));
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
|
@ -558,61 +558,39 @@ typedef struct
|
||||
const gchar *height_property;
|
||||
} AspectData;
|
||||
|
||||
static void gimp_prop_ratio_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkEntry *entry);
|
||||
static void gimp_prop_ratio_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkEntry *entry);
|
||||
|
||||
static void gimp_prop_aspect_ratio_flip (GtkWidget *widget,
|
||||
AspectData *data);
|
||||
static void gimp_prop_aspect_ratio_changed (GtkWidget *widget,
|
||||
AspectData *data);
|
||||
|
||||
static void gimp_prop_aspect_ratio_flip (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_prop_aspect_ratio_square (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_prop_aspect_ratio_ratio (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_prop_aspect_ratio_set (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
/**
|
||||
* gimp_prop_aspect_ratio_new:
|
||||
* @config: Object to which property is attached.
|
||||
* @numerator_property: Name of double property controlled by the first entry.
|
||||
* @denominator_property: Name of double property controlled by the second entry.
|
||||
* @fixed_aspect_property: Name of Boolean property specifying whether aspect is fixed.
|
||||
* @width_property: Name of double property specifying width of object.
|
||||
* @height_property: Name of double property controlled by the second entry.
|
||||
* @digits: Number of digits after decimal point to display.
|
||||
* @table: The #GtkTable in which the controls should be inserted.
|
||||
* @row0: The first table row to use.
|
||||
* @col0: The first table column to use.
|
||||
*
|
||||
* Creates a set of widgets for controlling an aspect ratio, and
|
||||
* inserts them into the specified table. The widgets include
|
||||
* two text entries and a ":" label on the top line, for specifying
|
||||
* the aspect ratio, and on the second line, a "flip" button, a "1:1"
|
||||
* button for setting the aspect to square, and a "set" button for
|
||||
* setting the aspect from the existing height and width.
|
||||
* @numerator_property: Name of double property for numerator.
|
||||
* @denominator_property: Name of double property for denominator.
|
||||
* @fixed_aspect_property: Name of boolean property for fixed aspect.
|
||||
* @width_property: Name of double property for width.
|
||||
* @height_property: Name of double property for height.
|
||||
*
|
||||
* The @fixed_aspect_property, @width_property, and @height_property can
|
||||
* be set to #NULL, in which case the controls will not do anything
|
||||
* affecting or depending on these properties.
|
||||
*
|
||||
* Since GIMP 2.4
|
||||
*/
|
||||
void
|
||||
GtkWidget *
|
||||
gimp_prop_aspect_ratio_new (GObject *config,
|
||||
const gchar *numerator_property,
|
||||
const gchar *denominator_property,
|
||||
const char *fixed_aspect_property,
|
||||
const gchar *fixed_aspect_property,
|
||||
const gchar *width_property,
|
||||
const gchar *height_property,
|
||||
gint digits,
|
||||
GtkTable *table,
|
||||
gint row0,
|
||||
gint col0)
|
||||
const gchar *height_property)
|
||||
{
|
||||
AspectData *aspect_data;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
gdouble numerator;
|
||||
gdouble denominator;
|
||||
|
||||
@ -622,7 +600,8 @@ gimp_prop_aspect_ratio_new (GObject *config,
|
||||
NULL);
|
||||
|
||||
aspect_data = g_new0 (AspectData, 1);
|
||||
aspect_data->config = config;
|
||||
|
||||
aspect_data->config = config;
|
||||
aspect_data->numerator_property = numerator_property;
|
||||
aspect_data->denominator_property = denominator_property;
|
||||
aspect_data->fixed_aspect_property = fixed_aspect_property;
|
||||
@ -630,53 +609,26 @@ gimp_prop_aspect_ratio_new (GObject *config,
|
||||
aspect_data->height_property = height_property;
|
||||
|
||||
entry = gimp_ratio_entry_new ();
|
||||
g_object_set_data (G_OBJECT (entry),
|
||||
"gimp-ratio-entry-aspect-data",
|
||||
aspect_data);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (entry), 9);
|
||||
|
||||
g_object_set_data (G_OBJECT (entry),
|
||||
"gimp-ratio-entry-aspect-data", aspect_data);
|
||||
|
||||
gimp_ratio_entry_set_fraction (GIMP_RATIO_ENTRY (entry),
|
||||
numerator, denominator);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), entry,
|
||||
col0, col0 + 3, row0, row0 + 1);
|
||||
|
||||
g_signal_connect (entry, "ratio-changed",
|
||||
G_CALLBACK (gimp_prop_aspect_ratio_ratio),
|
||||
G_CALLBACK (gimp_prop_aspect_ratio_changed),
|
||||
aspect_data);
|
||||
|
||||
connect_notify (config, numerator_property,
|
||||
G_CALLBACK (gimp_prop_ratio_entry_notify),
|
||||
entry);
|
||||
connect_notify (config, denominator_property,
|
||||
G_CALLBACK (gimp_prop_ratio_entry_notify),
|
||||
entry);
|
||||
gtk_widget_show (entry);
|
||||
|
||||
/* flip, 1:1, set buttons */
|
||||
hbox = gtk_hbox_new (TRUE, 0);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox,
|
||||
col0, col0 + 3, row0 + 1, row0 + 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
button = gtk_button_new_from_stock (GIMP_STOCK_FLIP_HORIZONTAL);
|
||||
gtk_button_set_use_stock (GTK_BUTTON (button), TRUE);
|
||||
g_signal_connect (button, "pressed",
|
||||
G_CALLBACK (gimp_prop_aspect_ratio_flip),
|
||||
aspect_data);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label (_("1:1"));
|
||||
g_signal_connect (button, "pressed",
|
||||
G_CALLBACK (gimp_prop_aspect_ratio_square),
|
||||
aspect_data);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label (_("Set"));
|
||||
g_signal_connect (button, "pressed",
|
||||
G_CALLBACK (gimp_prop_aspect_ratio_set),
|
||||
aspect_data);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -686,13 +638,12 @@ gimp_prop_ratio_entry_notify (GObject *config,
|
||||
{
|
||||
AspectData *aspect_data = g_object_get_data (G_OBJECT (entry),
|
||||
"gimp-ratio-entry-aspect-data");
|
||||
|
||||
gdouble num, denom;
|
||||
gdouble num, denom;
|
||||
|
||||
g_return_if_fail (aspect_data != NULL);
|
||||
|
||||
g_object_get (config,
|
||||
aspect_data->numerator_property, &num,
|
||||
aspect_data->numerator_property, &num,
|
||||
aspect_data->denominator_property, &denom,
|
||||
NULL);
|
||||
|
||||
@ -700,122 +651,66 @@ gimp_prop_ratio_entry_notify (GObject *config,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_aspect_ratio_flip (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_prop_aspect_ratio_flip (GtkWidget *widget,
|
||||
AspectData *data)
|
||||
{
|
||||
AspectData *aspect_data = data;
|
||||
gdouble numerator;
|
||||
gdouble denominator;
|
||||
gdouble height;
|
||||
gdouble width;
|
||||
gboolean fixed_aspect = FALSE;
|
||||
gdouble numerator;
|
||||
gdouble denominator;
|
||||
gdouble height;
|
||||
gdouble width;
|
||||
gboolean fixed_aspect = FALSE;
|
||||
|
||||
if (aspect_data->fixed_aspect_property)
|
||||
if (data->fixed_aspect_property)
|
||||
{
|
||||
g_object_get (aspect_data->config,
|
||||
aspect_data->fixed_aspect_property, &fixed_aspect,
|
||||
g_object_get (data->config,
|
||||
data->fixed_aspect_property, &fixed_aspect,
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_object_get (aspect_data->config,
|
||||
aspect_data->numerator_property, &numerator,
|
||||
aspect_data->denominator_property, &denominator,
|
||||
g_object_get (data->config,
|
||||
data->numerator_property, &numerator,
|
||||
data->denominator_property, &denominator,
|
||||
NULL);
|
||||
|
||||
if (fixed_aspect)
|
||||
{
|
||||
if (aspect_data->width_property && aspect_data->height_property)
|
||||
if (data->width_property && data->height_property)
|
||||
{
|
||||
g_object_get (aspect_data->config,
|
||||
aspect_data->width_property, &width,
|
||||
aspect_data->height_property, &height,
|
||||
g_object_get (data->config,
|
||||
data->width_property, &width,
|
||||
data->height_property, &height,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->numerator_property, denominator,
|
||||
aspect_data->denominator_property, numerator,
|
||||
g_object_set (data->config,
|
||||
data->numerator_property, denominator,
|
||||
data->denominator_property, numerator,
|
||||
NULL);
|
||||
|
||||
if (fixed_aspect)
|
||||
{
|
||||
if (aspect_data->width_property && aspect_data->height_property)
|
||||
if (data->width_property && data->height_property)
|
||||
{
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->width_property, height,
|
||||
aspect_data->height_property, width,
|
||||
g_object_set (data->config,
|
||||
data->width_property, height,
|
||||
data->height_property, width,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_aspect_ratio_square (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_prop_aspect_ratio_changed (GtkWidget *widget,
|
||||
AspectData *data)
|
||||
{
|
||||
AspectData *aspect_data = data;
|
||||
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->numerator_property, 1.0,
|
||||
aspect_data->denominator_property, 1.0,
|
||||
aspect_data->fixed_aspect_property, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_aspect_ratio_ratio (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
AspectData *aspect_data = data;
|
||||
gdouble num, denom;
|
||||
|
||||
gimp_ratio_entry_get_fraction (GIMP_RATIO_ENTRY (widget), &num, &denom);
|
||||
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->numerator_property, num,
|
||||
aspect_data->denominator_property, denom,
|
||||
aspect_data->fixed_aspect_property, TRUE,
|
||||
g_object_set (data->config,
|
||||
data->numerator_property, num,
|
||||
data->denominator_property, denom,
|
||||
data->fixed_aspect_property, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_aspect_ratio_set (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
AspectData *aspect_data = data;
|
||||
gdouble height;
|
||||
gdouble width;
|
||||
|
||||
if (aspect_data->width_property && aspect_data->height_property)
|
||||
{
|
||||
g_object_get (aspect_data->config,
|
||||
aspect_data->width_property, &width,
|
||||
aspect_data->height_property, &height,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return;
|
||||
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->numerator_property, width,
|
||||
aspect_data->denominator_property, height,
|
||||
NULL);
|
||||
|
||||
/* just to make sure */
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->width_property, width,
|
||||
aspect_data->height_property, height,
|
||||
NULL);
|
||||
|
||||
if (aspect_data->fixed_aspect_property)
|
||||
{
|
||||
g_object_set (aspect_data->config,
|
||||
aspect_data->fixed_aspect_property, TRUE,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,14 +58,14 @@ GtkWidget * gimp_prop_view_new (GObject *config,
|
||||
gint size);
|
||||
|
||||
|
||||
void gimp_prop_aspect_ratio_new (GObject *config,
|
||||
/* GParamDouble, GParamDouble, GParamBoolean, GParamDouble, GParamDouble */
|
||||
|
||||
GtkWidget * gimp_prop_aspect_ratio_new (GObject *config,
|
||||
const gchar *numerator_property,
|
||||
const gchar *denominator_property,
|
||||
const gchar *fixed_aspect_property,
|
||||
const gchar *width_property,
|
||||
const gchar *height_property,
|
||||
gint digits,
|
||||
GtkTable *table,
|
||||
gint row0,
|
||||
gint col0);
|
||||
const gchar *height_property);
|
||||
|
||||
|
||||
#endif /* __GIMP_APP_PROP_WIDGETS_H__ */
|
||||
|
Reference in New Issue
Block a user