add non-serializable properties pattern-view-type and pattern-view-size

2008-10-25  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpfilloptions.[ch]: add non-serializable properties
	pattern-view-type and pattern-view-size which are used only by the
	new UI below.

	* app/widgets/gimpfilleditor.[ch]: added boolean edit-context
	property. If TRUE, add widgets to edit the context's foreground and
	pattern. Add "edit_context" parameter to gimp_fill_editor_new().

	* app/widgets/gimpstrokeeditor.[ch]: add the same parameter here.

	* app/widgets/gimpwidgets-utils.[ch]: add gimp_enum_radio_box_add()
	which does the same as the existing gimp_enum_radio_frame_add().

	* app/dialogs/stroke-dialog.c: pass FALSE for "edit_context"
	because this dialog takes its foreground and pattern from the user
	context and doesn't need it's own GUI for them.


svn path=/trunk/; revision=27392
This commit is contained in:
Michael Natterer 2008-10-24 22:34:24 +00:00 committed by Michael Natterer
parent 9c299a8f03
commit 90c26cf10e
10 changed files with 147 additions and 26 deletions

View File

@ -1,3 +1,22 @@
2008-10-25 Michael Natterer <mitch@gimp.org>
* app/core/gimpfilloptions.[ch]: add non-serializable properties
pattern-view-type and pattern-view-size which are used only by the
new UI below.
* app/widgets/gimpfilleditor.[ch]: added boolean edit-context
property. If TRUE, add widgets to edit the context's foreground and
pattern. Add "edit_context" parameter to gimp_fill_editor_new().
* app/widgets/gimpstrokeeditor.[ch]: add the same parameter here.
* app/widgets/gimpwidgets-utils.[ch]: add gimp_enum_radio_box_add()
which does the same as the existing gimp_enum_radio_frame_add().
* app/dialogs/stroke-dialog.c: pass FALSE for "edit_context"
because this dialog takes its foreground and pattern from the user
context and doesn't need it's own GUI for them.
2008-10-24 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am

View File

@ -29,13 +29,16 @@
#include "core-types.h"
#include "gimpfilloptions.h"
#include "gimpviewable.h"
enum
{
PROP_0,
PROP_STYLE,
PROP_ANTIALIAS
PROP_ANTIALIAS,
PROP_PATTERN_VIEW_TYPE,
PROP_PATTERN_VIEW_SIZE
};
@ -70,6 +73,23 @@ gimp_fill_options_class_init (GimpFillOptionsClass *klass)
"antialias", NULL,
TRUE,
GIMP_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_PATTERN_VIEW_TYPE,
g_param_spec_enum ("pattern-view-type",
NULL, NULL,
GIMP_TYPE_VIEW_TYPE,
GIMP_VIEW_TYPE_GRID,
G_PARAM_CONSTRUCT |
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PATTERN_VIEW_SIZE,
g_param_spec_int ("pattern-view-size",
NULL, NULL,
GIMP_VIEW_SIZE_TINY,
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
GIMP_VIEW_SIZE_SMALL,
G_PARAM_CONSTRUCT |
GIMP_PARAM_READWRITE));
}
static void
@ -94,6 +114,13 @@ gimp_fill_options_set_property (GObject *object,
options->antialias = g_value_get_boolean (value);
break;
case PROP_PATTERN_VIEW_TYPE:
options->pattern_view_type = g_value_get_enum (value);
break;
case PROP_PATTERN_VIEW_SIZE:
options->pattern_view_size = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -117,6 +144,13 @@ gimp_fill_options_get_property (GObject *object,
g_value_set_boolean (value, options->antialias);
break;
case PROP_PATTERN_VIEW_TYPE:
g_value_set_enum (value, options->pattern_view_type);
break;
case PROP_PATTERN_VIEW_SIZE:
g_value_set_int (value, options->pattern_view_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;

View File

@ -43,6 +43,9 @@ struct _GimpFillOptions
GimpFillStyle style;
gboolean antialias;
GimpViewType pattern_view_type;
GimpViewSize pattern_view_size;
};
struct _GimpFillOptionsClass

View File

@ -181,7 +181,7 @@ stroke_dialog_new (GimpItem *item,
gimp_image_get_resolution (image, &xres, &yres);
stroke_editor = gimp_stroke_editor_new (options, yres);
stroke_editor = gimp_stroke_editor_new (options, yres, FALSE);
gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
gtk_widget_show (stroke_editor);

View File

@ -30,7 +30,11 @@
#include "core/gimpfilloptions.h"
#include "gimpcolorpanel.h"
#include "gimpfilleditor.h"
#include "gimppropwidgets.h"
#include "gimpviewablebox.h"
#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@ -39,7 +43,7 @@ enum
{
PROP_0,
PROP_OPTIONS,
PROP_RESOLUTION
PROP_EDIT_CONTEXT
};
@ -73,10 +77,18 @@ gimp_fill_editor_class_init (GimpFillEditorClass *klass)
object_class->get_property = gimp_fill_editor_get_property;
g_object_class_install_property (object_class, PROP_OPTIONS,
g_param_spec_object ("options", NULL, NULL,
g_param_spec_object ("options",
NULL, NULL,
GIMP_TYPE_FILL_OPTIONS,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_EDIT_CONTEXT,
g_param_spec_boolean ("edit-context",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
@ -106,6 +118,29 @@ gimp_fill_editor_constructor (GType type,
gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
gtk_widget_show (box);
if (editor->edit_context)
{
GtkWidget *color_button;
GtkWidget *pattern_box;
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"foreground",
_("Fill Color"),
-1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
GIMP_FILL_STYLE_SOLID);
pattern_box = gimp_prop_pattern_box_new (NULL,
GIMP_CONTEXT (editor->options), 2,
"pattern-view-type",
"pattern-view-size");
gimp_enum_radio_box_add (GTK_BOX (box), pattern_box,
GIMP_FILL_STYLE_PATTERN);
}
return object;
}
@ -139,6 +174,10 @@ gimp_fill_editor_set_property (GObject *object,
editor->options = g_value_dup_object (value);
break;
case PROP_EDIT_CONTEXT:
editor->edit_context = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -159,6 +198,10 @@ gimp_fill_editor_get_property (GObject *object,
g_value_set_object (value, editor->options);
break;
case PROP_EDIT_CONTEXT:
g_value_set_boolean (value, editor->edit_context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -166,11 +209,13 @@ gimp_fill_editor_get_property (GObject *object,
}
GtkWidget *
gimp_fill_editor_new (GimpFillOptions *options)
gimp_fill_editor_new (GimpFillOptions *options,
gboolean edit_context)
{
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), NULL);
return g_object_new (GIMP_TYPE_FILL_EDITOR,
"options", options,
"options", options,
"edit-context", edit_context ? TRUE : FALSE,
NULL);
}

View File

@ -38,6 +38,7 @@ struct _GimpFillEditor
GtkVBox parent_instance;
GimpFillOptions *options;
gboolean edit_context;
};
struct _GimpFillEditorClass
@ -48,7 +49,8 @@ struct _GimpFillEditorClass
GType gimp_fill_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_fill_editor_new (GimpFillOptions *options);
GtkWidget * gimp_fill_editor_new (GimpFillOptions *options,
gboolean edit_context);
#endif /* __GIMP_FILL_EDITOR_H__ */

View File

@ -330,13 +330,15 @@ gimp_stroke_editor_constructor (GType type,
GtkWidget *
gimp_stroke_editor_new (GimpStrokeOptions *options,
gdouble resolution)
gdouble resolution,
gboolean edit_context)
{
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
return g_object_new (GIMP_TYPE_STROKE_EDITOR,
"options", options,
"resolution", resolution,
"options", options,
"resolution", resolution,
"edit-context", edit_context ? TRUE : FALSE,
NULL);
}

View File

@ -52,7 +52,8 @@ struct _GimpStrokeEditorClass
GType gimp_stroke_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options,
gdouble resolution);
gdouble resolution,
gboolean edit_context);
#endif /* __GIMP_STROKE_EDITOR_H__ */

View File

@ -244,23 +244,18 @@ gimp_table_attach_stock (GtkTable *table,
}
void
gimp_enum_radio_frame_add (GtkFrame *frame,
GtkWidget *widget,
gint enum_value)
gimp_enum_radio_box_add (GtkBox *box,
GtkWidget *widget,
gint enum_value)
{
GtkWidget *vbox;
GList *children;
GList *list;
gint pos;
GList *children;
GList *list;
gint pos;
g_return_if_fail (GTK_IS_FRAME (frame));
g_return_if_fail (GTK_IS_BOX (box));
g_return_if_fail (GTK_IS_WIDGET (widget));
vbox = gtk_bin_get_child (GTK_BIN (frame));
g_return_if_fail (GTK_IS_VBOX (vbox));
children = gtk_container_get_children (GTK_CONTAINER (vbox));
children = gtk_container_get_children (GTK_CONTAINER (box));
for (list = children, pos = 1;
list;
@ -312,8 +307,8 @@ gimp_enum_radio_frame_add (GtkFrame *frame,
gtk_widget_set_sensitive (hbox,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (list->data)));
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (vbox), hbox, pos);
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (box), hbox, pos);
gtk_widget_show (hbox);
break;
@ -323,6 +318,23 @@ gimp_enum_radio_frame_add (GtkFrame *frame,
g_list_free (children);
}
void
gimp_enum_radio_frame_add (GtkFrame *frame,
GtkWidget *widget,
gint enum_value)
{
GtkWidget *vbox;
g_return_if_fail (GTK_IS_FRAME (frame));
g_return_if_fail (GTK_IS_WIDGET (widget));
vbox = gtk_bin_get_child (GTK_BIN (frame));
g_return_if_fail (GTK_IS_VBOX (vbox));
gimp_enum_radio_box_add (GTK_BOX (vbox), widget, enum_value);
}
GtkIconSize
gimp_get_icon_size (GtkWidget *widget,
const gchar *stock_id,

View File

@ -38,6 +38,9 @@ void gimp_table_attach_stock (GtkTable *table,
GtkWidget *widget,
gint colspan,
gboolean left_align);
void gimp_enum_radio_box_add (GtkBox *box,
GtkWidget *widget,
gint enum_value);
void gimp_enum_radio_frame_add (GtkFrame *frame,
GtkWidget *widget,
gint enum_value);