variant of gimp_config_connect() which allows the connected objects to

2006-01-14  Michael Natterer  <mitch@gimp.org>

	* app/config/gimpconfig-utils.[ch] (gimp_config_connect_full):
	variant of gimp_config_connect() which allows the connected
	objects to have different propertynames.

	* app/widgets/widgets-enums.[ch]: removed enum GimpViewType...

	* app/core/core-enums.[ch]: ...and added it here.

	* app/widgets/gimpviewablebutton.[ch] (gimp_viewable_button_new):
	added "button_preview_size" parameter so the button and popup
	preview sizes can be specified separately.

	* app/widgets/gimptemplateeditor.c: changed accordingly.

	* app/widgets/gimpviewablebox.[ch] (gimp_prop_*_box_new):
	new functions which take additional "view_type_prop" and
	"view_size_prop" parameters and sync the passed context's
	properties with the resp. properties of the viewable button.

	* app/paint/gimppaintoptions.[ch]
	* app/tools/gimpbucketfilloptions.c
	* app/tools/gimpclonetool.c
	* app/tools/gimppaintoptions-gui.c
	* app/tools/gimptextoptions.[ch]: added view-type and view-size
	properties to the options objects and use the new viewable box
	constructors so the selected view types and sizes are persistant
	across sessions. Fixes bug #315443.
This commit is contained in:
Michael Natterer 2006-01-14 00:09:22 +00:00 committed by Michael Natterer
parent 078c3c8c3c
commit 5d8b25a27d
20 changed files with 634 additions and 114 deletions

View File

@ -1,3 +1,33 @@
2006-01-14 Michael Natterer <mitch@gimp.org>
* app/config/gimpconfig-utils.[ch] (gimp_config_connect_full):
variant of gimp_config_connect() which allows the connected
objects to have different propertynames.
* app/widgets/widgets-enums.[ch]: removed enum GimpViewType...
* app/core/core-enums.[ch]: ...and added it here.
* app/widgets/gimpviewablebutton.[ch] (gimp_viewable_button_new):
added "button_preview_size" parameter so the button and popup
preview sizes can be specified separately.
* app/widgets/gimptemplateeditor.c: changed accordingly.
* app/widgets/gimpviewablebox.[ch] (gimp_prop_*_box_new):
new functions which take additional "view_type_prop" and
"view_size_prop" parameters and sync the passed context's
properties with the resp. properties of the viewable button.
* app/paint/gimppaintoptions.[ch]
* app/tools/gimpbucketfilloptions.c
* app/tools/gimpclonetool.c
* app/tools/gimppaintoptions-gui.c
* app/tools/gimptextoptions.[ch]: added view-type and view-size
properties to the options objects and use the new viewable box
constructors so the selected view types and sizes are persistant
across sessions. Fixes bug #315443.
2006-01-14 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpsessioninfo.c (gimp_session_info_restore): always

View File

@ -105,6 +105,101 @@ gimp_config_connect (GObject *a,
g_free (signal_name);
}
static void
gimp_config_connect_full_notify (GObject *src,
GParamSpec *param_spec,
GObject *dest)
{
if (param_spec->flags & G_PARAM_READABLE)
{
gchar *attach_key;
gchar *dest_prop_name;
GParamSpec *dest_spec = NULL;
attach_key = g_strdup_printf ("%p-%s", dest, param_spec->name);
dest_prop_name = g_object_get_data (src, attach_key);
g_free (attach_key);
if (dest_prop_name)
dest_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (dest),
dest_prop_name);
if (dest_spec &&
(dest_spec->value_type == param_spec->value_type) &&
(dest_spec->flags & G_PARAM_WRITABLE) &&
(dest_spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0)
{
GValue value = { 0, };
g_value_init (&value, param_spec->value_type);
g_object_get_property (src, param_spec->name, &value);
g_signal_handlers_block_by_func (dest,
gimp_config_connect_full_notify, src);
g_object_set_property (dest, dest_prop_name, &value);
g_signal_handlers_unblock_by_func (dest,
gimp_config_connect_full_notify, src);
g_value_unset (&value);
}
}
}
/**
* gimp_config_connect_full:
* @a: a #GObject
* @b: another #GObject
* @property_name_a: the name of a property of @a to connect
* @property_name_b: the name of a property of @b to connect
*
* Connects the two object @a and @b in a way that property changes of
* one are propagated to the other. This is a two-way connection.
*
* If @property_name is %NULL the connection is setup for all
* properties. It is not required that @a and @b are of the same type.
* Only changes on properties that exist in both object classes and
* are of the same value_type are propagated.
**/
void
gimp_config_connect_full (GObject *a,
GObject *b,
const gchar *property_name_a,
const gchar *property_name_b)
{
gchar *signal_name;
gchar *attach_key;
g_return_if_fail (a != b);
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
g_return_if_fail (property_name_a != NULL);
g_return_if_fail (property_name_b != NULL);
signal_name = g_strconcat ("notify::", property_name_a, NULL);
attach_key = g_strdup_printf ("%p-%s", b, property_name_a);
g_signal_connect_object (a, signal_name,
G_CALLBACK (gimp_config_connect_full_notify),
b, 0);
g_object_set_data_full (a, attach_key, g_strdup (property_name_b),
(GDestroyNotify) g_free);
g_free (signal_name);
g_free (attach_key);
signal_name = g_strconcat ("notify::", property_name_b, NULL);
attach_key = g_strdup_printf ("%p-%s", a, property_name_b);
g_signal_connect_object (b, signal_name,
G_CALLBACK (gimp_config_connect_full_notify),
a, 0);
g_object_set_data_full (b, attach_key, g_strdup (property_name_a),
(GDestroyNotify) g_free);
g_free (signal_name);
g_free (attach_key);
}
/**
* gimp_config_disconnect:
* @a: a #GObject

View File

@ -23,11 +23,15 @@
#define __APP_GIMP_CONFIG_UTILS_H__
void gimp_config_connect (GObject *a,
GObject *b,
const gchar *property_name);
void gimp_config_disconnect (GObject *a,
GObject *b);
void gimp_config_connect (GObject *a,
GObject *b,
const gchar *property_name);
void gimp_config_connect_full (GObject *a,
GObject *b,
const gchar *property_name_a,
const gchar *property_name_b);
void gimp_config_disconnect (GObject *a,
GObject *b);
#endif /* __APP_GIMP_CONFIG_UTILS_H__ */

View File

@ -544,6 +544,34 @@ gimp_view_size_get_type (void)
return type;
}
GType
gimp_view_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_VIEW_TYPE_LIST, "GIMP_VIEW_TYPE_LIST", "list" },
{ GIMP_VIEW_TYPE_GRID, "GIMP_VIEW_TYPE_GRID", "grid" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_VIEW_TYPE_LIST, N_("View as list"), NULL },
{ GIMP_VIEW_TYPE_GRID, N_("View as grid"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpViewType", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_selection_control_get_type (void)
{

View File

@ -259,6 +259,17 @@ typedef enum /*< pdb-skip >*/
} GimpViewSize;
#define GIMP_TYPE_VIEW_TYPE (gimp_view_type_get_type ())
GType gimp_view_type_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_VIEW_TYPE_LIST, /*< desc="View as list" >*/
GIMP_VIEW_TYPE_GRID /*< desc="View as grid" >*/
} GimpViewType;
#define GIMP_TYPE_SELECTION_CONTROL (gimp_selection_control_get_type ())
GType gimp_selection_control_get_type (void) G_GNUC_CONST;

View File

@ -80,7 +80,14 @@ enum
PROP_GRADIENT_LENGTH,
PROP_GRADIENT_UNIT,
PROP_USE_JITTER,
PROP_JITTER_AMOUNT
PROP_JITTER_AMOUNT,
PROP_BRUSH_VIEW_TYPE,
PROP_BRUSH_VIEW_SIZE,
PROP_PATTERN_VIEW_TYPE,
PROP_PATTERN_VIEW_SIZE,
PROP_GRADIENT_VIEW_TYPE,
PROP_GRADIENT_VIEW_SIZE
};
@ -200,6 +207,42 @@ gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
"gradient-unit", NULL,
TRUE, TRUE, DEFAULT_GRADIENT_UNIT,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BRUSH_VIEW_TYPE,
"brush-view-type", NULL,
GIMP_TYPE_VIEW_TYPE,
GIMP_VIEW_TYPE_GRID,
0);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_BRUSH_VIEW_SIZE,
"brush-view-size", NULL,
GIMP_VIEW_SIZE_TINY,
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
GIMP_VIEW_SIZE_SMALL,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PATTERN_VIEW_TYPE,
"pattern-view-type", NULL,
GIMP_TYPE_VIEW_TYPE,
GIMP_VIEW_TYPE_GRID,
0);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_PATTERN_VIEW_SIZE,
"pattern-view-size", NULL,
GIMP_VIEW_SIZE_TINY,
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
GIMP_VIEW_SIZE_SMALL,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRADIENT_VIEW_TYPE,
"gradient-view-type", NULL,
GIMP_TYPE_VIEW_TYPE,
GIMP_VIEW_TYPE_LIST,
0);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_GRADIENT_VIEW_SIZE,
"gradient-view-size", NULL,
GIMP_VIEW_SIZE_TINY,
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
GIMP_VIEW_SIZE_LARGE,
0);
}
static void
@ -314,6 +357,27 @@ gimp_paint_options_set_property (GObject *object,
gradient_options->gradient_unit = g_value_get_int (value);
break;
case PROP_BRUSH_VIEW_TYPE:
options->brush_view_type = g_value_get_enum (value);
break;
case PROP_BRUSH_VIEW_SIZE:
options->brush_view_size = g_value_get_int (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;
case PROP_GRADIENT_VIEW_TYPE:
options->gradient_view_type = g_value_get_enum (value);
break;
case PROP_GRADIENT_VIEW_SIZE:
options->gradient_view_size = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -405,6 +469,27 @@ gimp_paint_options_get_property (GObject *object,
g_value_set_int (value, gradient_options->gradient_unit);
break;
case PROP_BRUSH_VIEW_TYPE:
g_value_set_enum (value, options->brush_view_type);
break;
case PROP_BRUSH_VIEW_SIZE:
g_value_set_int (value, options->brush_view_size);
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;
case PROP_GRADIENT_VIEW_TYPE:
g_value_set_enum (value, options->gradient_view_type);
break;
case PROP_GRADIENT_VIEW_SIZE:
g_value_set_int (value, options->gradient_view_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;

View File

@ -94,6 +94,13 @@ struct _GimpPaintOptions
GimpFadeOptions *fade_options;
GimpGradientOptions *gradient_options;
GimpJitterOptions *jitter_options;
GimpViewType brush_view_type;
GimpViewSize brush_view_size;
GimpViewType pattern_view_type;
GimpViewSize pattern_view_size;
GimpViewType gradient_view_type;
GimpViewSize gradient_view_size;
};
struct _GimpPaintOptionsClass

View File

@ -218,7 +218,8 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gimp_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"pattern-view-type", "pattern-view-size");
gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox, GIMP_PATTERN_BUCKET_FILL);
/* fill selection */

View File

@ -305,7 +305,8 @@ gimp_clone_options_gui (GimpToolOptions *tool_options)
_("Sample merged"));
gimp_enum_radio_frame_add (GTK_FRAME (frame), button, GIMP_IMAGE_CLONE);
hbox = gimp_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"pattern-view-type", "pattern-view-size");
gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox, GIMP_PATTERN_CLONE);
table = gtk_table_new (1, 2, FALSE);

View File

@ -123,7 +123,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
tool_type != GIMP_TYPE_BLEND_TOOL &&
tool_type != GIMP_TYPE_INK_TOOL)
{
button = gimp_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"brush-view-type", "brush-view-size");
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Brush:"), 0.0, 0.5,
button, 2, FALSE);
@ -132,8 +133,10 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
/* the gradient */
if (tool_type == GIMP_TYPE_BLEND_TOOL)
{
button = gimp_gradient_box_new (NULL, GIMP_CONTEXT (tool_options),
"gradient-reverse", 2);
button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"gradient-view-type",
"gradient-view-size",
"gradient-reverse");
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Gradient:"), 0.0, 0.5,
button, 2, TRUE);
@ -459,8 +462,10 @@ gradient_options_gui (GimpGradientOptions *gradient,
}
/* the gradient view */
button = gimp_gradient_box_new (NULL, GIMP_CONTEXT (config),
"gradient-reverse", 2);
button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (config), 2,
"gradient-view-type",
"gradient-view-size",
"gradient-reverse");
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Gradient:"), 0.0, 0.5,
button, 2, TRUE);

View File

@ -305,7 +305,8 @@ gimp_clone_options_gui (GimpToolOptions *tool_options)
_("Sample merged"));
gimp_enum_radio_frame_add (GTK_FRAME (frame), button, GIMP_IMAGE_CLONE);
hbox = gimp_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"pattern-view-type", "pattern-view-size");
gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox, GIMP_PATTERN_CLONE);
table = gtk_table_new (1, 2, FALSE);

View File

@ -62,7 +62,10 @@ enum
PROP_JUSTIFICATION,
PROP_INDENTATION,
PROP_LINE_SPACING,
PROP_LETTER_SPACING
PROP_LETTER_SPACING,
PROP_FONT_VIEW_TYPE,
PROP_FONT_VIEW_SIZE
};
@ -155,6 +158,18 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
N_("Adjust letter spacing"),
-8192.0, 8192.0, 0.0,
GIMP_CONFIG_PARAM_DEFAULTS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FONT_VIEW_TYPE,
"font-view-type", NULL,
GIMP_TYPE_VIEW_TYPE,
GIMP_VIEW_TYPE_LIST,
0);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_FONT_VIEW_SIZE,
"font-view-size", NULL,
GIMP_VIEW_SIZE_TINY,
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
GIMP_VIEW_SIZE_SMALL,
0);
}
static void
@ -206,6 +221,14 @@ gimp_text_options_get_property (GObject *object,
case PROP_LETTER_SPACING:
g_value_set_double (value, options->letter_spacing);
break;
case PROP_FONT_VIEW_TYPE:
g_value_set_enum (value, options->font_view_type);
break;
case PROP_FONT_VIEW_SIZE:
g_value_set_int (value, options->font_view_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -256,6 +279,14 @@ gimp_text_options_set_property (GObject *object,
case PROP_LETTER_SPACING:
options->letter_spacing = g_value_get_double (value);
break;
case PROP_FONT_VIEW_TYPE:
options->font_view_type = g_value_get_enum (value);
break;
case PROP_FONT_VIEW_SIZE:
options->font_view_size = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -392,7 +423,8 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
hbox = gimp_font_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
hbox = gimp_prop_font_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"font-view-type", "font-view-size");
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Font:"), 0.0, 0.5,
hbox, 2, FALSE);

View File

@ -50,6 +50,9 @@ struct _GimpTextOptions
gdouble line_spacing;
gdouble letter_spacing;
GimpViewType font_view_type;
GimpViewSize font_view_size;
GimpSizeEntry *size_entry;
};

View File

@ -531,6 +531,7 @@ gimp_template_editor_new (GimpTemplate *template,
button = gimp_viewable_button_new (editor->stock_id_container,
editor->stock_id_context,
GIMP_VIEW_TYPE_LIST,
GIMP_VIEW_SIZE_SMALL,
GIMP_VIEW_SIZE_SMALL, 0,
NULL, NULL, NULL, NULL);
gimp_viewable_button_set_view_type (GIMP_VIEWABLE_BUTTON (button),

View File

@ -24,6 +24,8 @@
#include "widgets-types.h"
#include "config/gimpconfig-utils.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
@ -42,20 +44,42 @@
/* local function prototypes */
static GtkWidget * gimp_viewable_box_new (GimpContainer *container,
static GtkWidget * gimp_viewable_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewType button_view_size,
GimpViewSize view_size,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
const gchar *dialog_tooltip);
static GtkWidget * view_props_connect (GtkWidget *box,
GimpContext *context,
const gchar *view_type_prop,
const gchar *view_size_prop);
static void gimp_gradient_box_reverse_notify (GObject *object,
GParamSpec *pspec,
GimpView *view);
/* public functions */
/* brush boxes */
static GtkWidget *
brush_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewSize view_size)
{
if (! container)
container = context->gimp->brush_factory->container;
return gimp_viewable_box_new (container, context, spacing,
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
"gimp-brush-grid|gimp-brush-list",
GIMP_STOCK_BRUSH,
_("Open the brush selection dialog"));
}
GtkWidget *
gimp_brush_box_new (GimpContainer *container,
@ -66,14 +90,52 @@ gimp_brush_box_new (GimpContainer *container,
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return brush_box_new (container, context, spacing,
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_SMALL);
}
GtkWidget *
gimp_prop_brush_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop)
{
GimpViewType view_type;
GimpViewSize view_size;
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_object_get (context,
view_type_prop, &view_type,
view_size_prop, &view_size,
NULL);
return view_props_connect (brush_box_new (container, context, spacing,
view_type, view_size),
context,
view_type_prop, view_size_prop);
}
/* pattern boxes */
static GtkWidget *
pattern_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewSize view_size)
{
if (! container)
container = context->gimp->brush_factory->container;
container = context->gimp->pattern_factory->container;
return gimp_viewable_box_new (container, context, spacing,
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_SMALL,
"gimp-brush-grid|gimp-brush-list",
GIMP_STOCK_BRUSH,
_("Open the brush selection dialog"));
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
"gimp-pattern-grid|gimp-pattern-list",
GIMP_STOCK_PATTERN,
_("Open the pattern selection dialog"));
}
GtkWidget *
@ -85,42 +147,65 @@ gimp_pattern_box_new (GimpContainer *container,
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
if (! container)
container = context->gimp->pattern_factory->container;
return gimp_viewable_box_new (container, context, spacing,
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_SMALL,
"gimp-pattern-grid|gimp-pattern-list",
GIMP_STOCK_PATTERN,
_("Open the pattern selection dialog"));
return pattern_box_new (container, context, spacing,
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_SMALL);
}
GtkWidget *
gimp_gradient_box_new (GimpContainer *container,
GimpContext *context,
const gchar *reverse_prop,
gint spacing)
gimp_prop_pattern_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop)
{
GtkWidget *hbox;
GtkWidget *button;
GimpViewType view_type;
GimpViewSize view_size;
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_object_get (context,
view_type_prop, &view_type,
view_size_prop, &view_size,
NULL);
return view_props_connect (pattern_box_new (container, context, spacing,
view_type, view_size),
context,
view_type_prop, view_size_prop);
}
/* gradient boxes */
GtkWidget *
gradient_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewSize view_size,
const gchar *reverse_prop)
{
GtkWidget *hbox;
GtkWidget *button;
if (! container)
container = context->gimp->gradient_factory->container;
hbox = gtk_hbox_new (FALSE, spacing);
button = gimp_viewable_button_new (container, context,
GIMP_VIEW_TYPE_LIST,
GIMP_VIEW_SIZE_LARGE, 1,
view_type,
GIMP_VIEW_SIZE_LARGE, view_size, 1,
gimp_dialog_factory_from_name ("dock"),
"gimp-gradient-list|gimp-gradient-grid",
GIMP_STOCK_GRADIENT,
_("Open the gradient selection dialog"));
GIMP_VIEWABLE_BUTTON (button)->preview_size = GIMP_VIEW_SIZE_SMALL;
GIMP_VIEWABLE_BUTTON (button)->button_preview_size = GIMP_VIEW_SIZE_SMALL;
g_object_set_data (G_OBJECT (hbox), "viewable-button", button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
@ -151,6 +236,68 @@ gimp_gradient_box_new (GimpContainer *container,
return hbox;
}
GtkWidget *
gimp_gradient_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *reverse_prop)
{
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return gradient_box_new (container, context, spacing,
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_LARGE,
reverse_prop);
}
GtkWidget *
gimp_prop_gradient_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop,
const gchar *reverse_prop)
{
GimpViewType view_type;
GimpViewSize view_size;
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_object_get (context,
view_type_prop, &view_type,
view_size_prop, &view_size,
NULL);
return view_props_connect (gradient_box_new (container, context, spacing,
view_type, view_size,
reverse_prop),
context,
view_type_prop, view_size_prop);
}
/* palette boxes */
static GtkWidget *
palette_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewSize view_size)
{
if (! container)
container = context->gimp->palette_factory->container;
return gimp_viewable_box_new (container, context, spacing,
view_type, GIMP_VIEW_SIZE_MEDIUM, view_size,
"gimp-palette-list|gimp-palette-grid",
GIMP_STOCK_PALETTE,
_("Open the palette selection dialog"));
}
GtkWidget *
gimp_palette_box_new (GimpContainer *container,
GimpContext *context,
@ -160,14 +307,53 @@ gimp_palette_box_new (GimpContainer *container,
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return palette_box_new (container, context, spacing,
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_MEDIUM);
}
GtkWidget *
gimp_prop_palette_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop)
{
GimpViewType view_type;
GimpViewSize view_size;
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_object_get (context,
view_type_prop, &view_type,
view_size_prop, &view_size,
NULL);
return view_props_connect (palette_box_new (container, context, spacing,
view_type, view_size),
context,
view_type_prop, view_size_prop);
}
/* font boxes */
static GtkWidget *
font_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewSize view_size)
{
if (! container)
container = context->gimp->palette_factory->container;
container = context->gimp->fonts;
return gimp_viewable_box_new (container, context, spacing,
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_MEDIUM,
"gimp-palette-list|gimp-palette-grid",
GIMP_STOCK_PALETTE,
_("Open the palette selection dialog"));
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
"gimp-font-list|gimp-font-grid",
GIMP_STOCK_FONT,
_("Open the font selection dialog"));
}
GtkWidget *
@ -179,14 +365,33 @@ gimp_font_box_new (GimpContainer *container,
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
if (! container)
container = context->gimp->fonts;
return font_box_new (container, context, spacing,
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_SMALL);
}
return gimp_viewable_box_new (container, context, spacing,
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_SMALL,
"gimp-font-list|gimp-font-grid",
GIMP_STOCK_FONT,
_("Open the font selection dialog"));
GtkWidget *
gimp_prop_font_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop)
{
GimpViewType view_type;
GimpViewSize view_size;
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_object_get (context,
view_type_prop, &view_type,
view_size_prop, &view_size,
NULL);
return view_props_connect (font_box_new (container, context, spacing,
view_type, view_size),
context,
view_type_prop, view_size_prop);
}
@ -197,6 +402,7 @@ gimp_viewable_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
GimpViewType view_type,
GimpViewType button_view_size,
GimpViewSize view_size,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
@ -209,12 +415,14 @@ gimp_viewable_box_new (GimpContainer *container,
hbox = gtk_hbox_new (FALSE, spacing);
button = gimp_viewable_button_new (container, context,
view_type, view_size, 1,
view_type, button_view_size, view_size, 1,
gimp_dialog_factory_from_name ("dock"),
dialog_identifier,
dialog_stock_id,
dialog_tooltip);
g_object_set_data (G_OBJECT (hbox), "viewable-button", button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
@ -230,6 +438,22 @@ gimp_viewable_box_new (GimpContainer *container,
return hbox;
}
static GtkWidget *
view_props_connect (GtkWidget *box,
GimpContext *context,
const gchar *view_type_prop,
const gchar *view_size_prop)
{
GtkWidget *button = g_object_get_data (G_OBJECT (box), "viewable-button");
gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
view_type_prop, "popup-view-type");
gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
view_size_prop, "popup-preview-size");
return box;
}
static void
gimp_gradient_box_reverse_notify (GObject *object,
GParamSpec *pspec,

View File

@ -20,22 +20,52 @@
#define __GIMP_VIEWABLE_BOX_H__
GtkWidget * gimp_brush_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_pattern_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_gradient_box_new (GimpContainer *container,
GimpContext *context,
const gchar *reverse_prop,
gint scacing);
GtkWidget * gimp_palette_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_font_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_brush_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_prop_brush_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop);
GtkWidget * gimp_pattern_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_prop_pattern_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop);
GtkWidget * gimp_gradient_box_new (GimpContainer *container,
GimpContext *context,
gint scacing,
const gchar *reverse_prop);
GtkWidget * gimp_prop_gradient_box_new (GimpContainer *container,
GimpContext *context,
gint scacing,
const gchar *view_type_prop,
const gchar *view_size_prop,
const gchar *reverse_prop);
GtkWidget * gimp_palette_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_prop_palette_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop);
GtkWidget * gimp_font_box_new (GimpContainer *container,
GimpContext *context,
gint spacing);
GtkWidget * gimp_prop_font_box_new (GimpContainer *container,
GimpContext *context,
gint spacing,
const gchar *view_type_prop,
const gchar *view_size_prop);
#endif /* __GIMP_VIEWABLE_BOX_H__ */

View File

@ -107,7 +107,7 @@ gimp_viewable_button_init (GimpViewableButton *button)
button->popup_view_type = GIMP_VIEW_TYPE_LIST;
button->popup_preview_size = GIMP_VIEW_SIZE_SMALL;
button->preview_size = GIMP_VIEW_SIZE_SMALL;
button->button_preview_size = GIMP_VIEW_SIZE_SMALL;
button->preview_border_width = 1;
}
@ -240,7 +240,7 @@ gimp_viewable_button_clicked (GtkButton *button)
popup = gimp_container_popup_new (viewable_button->container,
viewable_button->context,
viewable_button->popup_view_type,
viewable_button->preview_size,
viewable_button->button_preview_size,
viewable_button->popup_preview_size,
viewable_button->preview_border_width,
viewable_button->dialog_factory,
@ -275,6 +275,7 @@ GtkWidget *
gimp_viewable_button_new (GimpContainer *container,
GimpContext *context,
GimpViewType view_type,
gint button_preview_size,
gint preview_size,
gint preview_border_width,
GimpDialogFactory *dialog_factory,
@ -309,8 +310,7 @@ gimp_viewable_button_new (GimpContainer *container,
button->container = container;
button->context = context;
button->popup_preview_size = preview_size;
button->preview_size = preview_size;
button->button_preview_size = button_preview_size;
button->preview_border_width = preview_border_width;
if (dialog_factory)
@ -324,7 +324,7 @@ gimp_viewable_button_new (GimpContainer *container,
prop_name = gimp_context_type_to_prop_name (container->children_type);
button->preview = gimp_prop_preview_new (G_OBJECT (context), prop_name,
button->preview_size);
button->button_preview_size);
gtk_container_add (GTK_CONTAINER (button), button->preview);
gtk_widget_show (button->preview);

View File

@ -46,7 +46,7 @@ struct _GimpViewableButton
GimpViewType popup_view_type;
gint popup_preview_size;
gint preview_size;
gint button_preview_size;
gint preview_border_width;
GimpDialogFactory *dialog_factory;
@ -68,6 +68,7 @@ GType gimp_viewable_button_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_viewable_button_new (GimpContainer *container,
GimpContext *context,
GimpViewType view_type,
gint button_preview_size,
gint preview_size,
gint preview_border_width,
GimpDialogFactory *dialog_factory,

View File

@ -280,34 +280,6 @@ gimp_tab_style_get_type (void)
return type;
}
GType
gimp_view_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_VIEW_TYPE_LIST, "GIMP_VIEW_TYPE_LIST", "list" },
{ GIMP_VIEW_TYPE_GRID, "GIMP_VIEW_TYPE_GRID", "grid" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_VIEW_TYPE_LIST, N_("View as list"), NULL },
{ GIMP_VIEW_TYPE_GRID, N_("View as grid"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpViewType", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_window_hint_get_type (void)
{

View File

@ -133,17 +133,6 @@ typedef enum
} GimpTabStyle;
#define GIMP_TYPE_VIEW_TYPE (gimp_view_type_get_type ())
GType gimp_view_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_VIEW_TYPE_LIST, /*< desc="View as list" >*/
GIMP_VIEW_TYPE_GRID /*< desc="View as grid" >*/
} GimpViewType;
#define GIMP_TYPE_WINDOW_HINT (gimp_window_hint_get_type ())
GType gimp_window_hint_get_type (void) G_GNUC_CONST;