From b76ad2b84ec44ad9147ed24303db0d40b78b506c Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 8 Feb 2007 22:49:50 +0000 Subject: [PATCH] app/tools/gimprectangleoptions.c moved code around. 2007-02-08 Sven Neumann * app/tools/gimprectangleoptions.c * app/widgets/gimppropwidgets.[ch]: moved code around. svn path=/trunk/; revision=21876 --- ChangeLog | 5 +++ app/tools/gimprectangleoptions.c | 31 ++++++++++++++---- app/widgets/gimppropwidgets.c | 56 ++------------------------------ app/widgets/gimppropwidgets.h | 6 ++-- 4 files changed, 35 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fc91a44e9..9fe7b93d75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-02-08 Sven Neumann + + * app/tools/gimprectangleoptions.c + * app/widgets/gimppropwidgets.[ch]: moved code around. + 2007-02-08 Sven Neumann * app/tools/gimprectangleoptions.c (gimp_rectangle_options_gui): diff --git a/app/tools/gimprectangleoptions.c b/app/tools/gimprectangleoptions.c index 175b5b593c..78a0d990b7 100644 --- a/app/tools/gimprectangleoptions.c +++ b/app/tools/gimprectangleoptions.c @@ -484,6 +484,24 @@ gimp_rectangle_options_get_property (GObject *object, } } +static void +gimp_rectangle_options_notify_aspect (GtkWidget *widget, + GParamSpec *param_spec, + GimpRectangleOptions *options) +{ + GimpRectangleOptionsPrivate *private; + + private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options); + + if (private->fixed_aspect) + { + g_object_set (options, + "width", private->height, + "height", private->width, + NULL); + } +} + GtkWidget * gimp_rectangle_options_gui (GimpToolOptions *tool_options) { @@ -491,13 +509,12 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options) GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_tool_options_gui (tool_options); + GtkWidget *vbox2; GtkWidget *button; GtkWidget *combo; GtkWidget *table; GtkWidget *entry; GtkWidget *hbox; - GtkWidget *label; - GtkWidget *vbox2; GtkWidget *frame; GtkWidget *aspect; GList *children; @@ -585,9 +602,7 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options) entry = gimp_prop_aspect_ratio_new (config, "aspect-numerator", "aspect-denominator", - "fixed-aspect", - "width", - "height"); + "fixed-aspect"); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); gtk_widget_show (entry); @@ -596,11 +611,15 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options) gtk_box_pack_start (GTK_BOX (hbox), aspect, FALSE, FALSE, 0); gtk_widget_show (aspect); - /* hide "square" */ + /* hide "square" */ children = gtk_container_get_children (GTK_CONTAINER (aspect)); gtk_widget_hide (children->data); g_list_free (children); + g_signal_connect (entry, "notify::aspect", + G_CALLBACK (gimp_rectangle_options_notify_aspect), + config); + button = gimp_prop_check_button_new (config, "fixed-aspect", _("Fix")); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); gtk_widget_show (button); diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c index a3aff929cc..26108a35d5 100644 --- a/app/widgets/gimppropwidgets.c +++ b/app/widgets/gimppropwidgets.c @@ -554,17 +554,11 @@ typedef struct const gchar *numerator_property; const gchar *denominator_property; const gchar *fixed_aspect_property; - const gchar *width_property; - const gchar *height_property; } AspectData; static void gimp_prop_ratio_entry_notify (GObject *config, GParamSpec *param_spec, GtkEntry *entry); - -static void gimp_prop_aspect_notify_aspect (GtkWidget *widget, - GParamSpec *param_spec, - AspectData *data); static void gimp_prop_aspect_ratio_changed (GtkWidget *widget, AspectData *data); @@ -574,21 +568,15 @@ static void gimp_prop_aspect_ratio_changed (GtkWidget *widget, * @config: Object to which property is attached. * @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. + * @fixed_aspect_property: Name of boolean property for fixed aspect (or %NULL). * - * 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. + * Return value: a #GimpRatioEntry widget */ 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) + const gchar *fixed_aspect_property) { AspectData *aspect_data; GtkWidget *entry; @@ -606,8 +594,6 @@ gimp_prop_aspect_ratio_new (GObject *config, aspect_data->numerator_property = numerator_property; aspect_data->denominator_property = denominator_property; aspect_data->fixed_aspect_property = fixed_aspect_property; - aspect_data->width_property = width_property; - aspect_data->height_property = height_property; entry = gimp_ratio_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (entry), 7); @@ -618,9 +604,6 @@ gimp_prop_aspect_ratio_new (GObject *config, gimp_ratio_entry_set_fraction (GIMP_RATIO_ENTRY (entry), numerator, denominator); - g_signal_connect (entry, "notify::aspect", - G_CALLBACK (gimp_prop_aspect_notify_aspect), - aspect_data); g_signal_connect (entry, "ratio-changed", G_CALLBACK (gimp_prop_aspect_ratio_changed), aspect_data); @@ -654,39 +637,6 @@ gimp_prop_ratio_entry_notify (GObject *config, gimp_ratio_entry_set_fraction (GIMP_RATIO_ENTRY (entry), num, denom); } -static void -gimp_prop_aspect_notify_aspect (GtkWidget *widget, - GParamSpec *param_spec, - AspectData *data) -{ - gboolean fixed_aspect = FALSE; - - if (data->fixed_aspect_property) - { - g_object_get (data->config, - data->fixed_aspect_property, &fixed_aspect, - NULL); - } - - if (! fixed_aspect) - return; - - if (data->width_property && data->height_property) - { - gdouble height; - gdouble width; - - g_object_get (data->config, - data->width_property, &width, - data->height_property, &height, - NULL); - - g_object_set (data->config, - data->width_property, height, - data->height_property, width, - NULL); - } -} static void gimp_prop_aspect_ratio_changed (GtkWidget *widget, diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h index a83bc44dee..20712ce6a8 100644 --- a/app/widgets/gimppropwidgets.h +++ b/app/widgets/gimppropwidgets.h @@ -58,14 +58,12 @@ GtkWidget * gimp_prop_view_new (GObject *config, gint size); -/* GParamDouble, GParamDouble, GParamBoolean, GParamDouble, GParamDouble */ +/* GParamDouble, GParamDouble, GParamBoolean */ 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); + const gchar *fixed_aspect_property); #endif /* __GIMP_APP_PROP_WIDGETS_H__ */