added gimp_context_type_to_prop_name().

2003-04-10  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontext.[ch]: added gimp_context_type_to_prop_name().

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpviewablebutton.[ch]: new widget implementing
	the wheel-scrollable preview button.

	* app/tools/gimptextoptions.c
	* app/tools/paint_options.[ch]: removed the code implementing the
	same and use GimpViewableButton.

	* app/tools/tool_manager.c: added the font to the context
	properties which are remembered per tool. Added an evil hack
	using g_object_set_data() to pass the global_dock_factory to
	tool option GUI constructors.
This commit is contained in:
Michael Natterer 2003-04-10 10:34:56 +00:00 committed by Michael Natterer
parent 6b581cc500
commit 2598142564
13 changed files with 460 additions and 490 deletions

View File

@ -1,3 +1,21 @@
2003-04-10 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontext.[ch]: added gimp_context_type_to_prop_name().
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpviewablebutton.[ch]: new widget implementing
the wheel-scrollable preview button.
* app/tools/gimptextoptions.c
* app/tools/paint_options.[ch]: removed the code implementing the
same and use GimpViewableButton.
* app/tools/tool_manager.c: added the font to the context
properties which are remembered per tool. Added an evil hack
using g_object_set_data() to pass the global_dock_factory to
tool option GUI constructors.
2003-04-09 Sven Neumann <sven@gimp.org>
* app/text/text-enums.[ch]

View File

@ -1563,6 +1563,20 @@ gimp_context_type_to_property (GType type)
return -1;
}
const gchar *
gimp_context_type_to_prop_name (GType type)
{
GimpContextPropType prop;
for (prop = GIMP_CONTEXT_FIRST_PROP; prop <= GIMP_CONTEXT_LAST_PROP; prop++)
{
if (g_type_is_a (type, gimp_context_prop_types[prop]))
return gimp_context_prop_names[prop];
}
return NULL;
}
const gchar *
gimp_context_type_to_signal_name (GType type)
{

View File

@ -220,6 +220,7 @@ void gimp_context_copy_properties (GimpContext *src,
/* manipulate by GType */
GimpContextPropType gimp_context_type_to_property (GType type);
const gchar * gimp_context_type_to_prop_name (GType type);
const gchar * gimp_context_type_to_signal_name (GType type);
GimpObject * gimp_context_get_by_type (GimpContext *context,

View File

@ -28,20 +28,15 @@
#include "config/gimpconfig.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
#include "core/gimpdatafactory.h"
#include "core/gimpgradient.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "paint/gimppaintoptions.h"
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gtkhwrapbox.h"
#include "widgets/gimpviewablebutton.h"
#include "gimpairbrushtool.h"
#include "gimpblendtool.h"
@ -71,36 +66,22 @@ static GtkWidget * gradient_options_gui (GimpGradientOptions *gradient,
GType tool_type,
GtkWidget *incremental_toggle);
static void paint_options_brush_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean paint_options_brush_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
static void paint_options_pattern_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean paint_options_pattern_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
static void paint_options_gradient_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean paint_options_gradient_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
GtkWidget *
gimp_paint_options_gui (GimpToolOptions *tool_options)
{
GimpPaintOptions *options;
GimpContext *context;
GObject *config;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *optionmenu;
GtkWidget *mode_label;
GtkWidget *incremental_toggle = NULL;
gint table_row = 0;
GimpPaintOptions *options;
GimpContext *context;
GObject *config;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *optionmenu;
GtkWidget *mode_label;
GtkWidget *button;
GimpDialogFactory *dialog_factory;
GtkWidget *incremental_toggle = NULL;
gint table_row = 0;
options = GIMP_PAINT_OPTIONS (tool_options);
context = GIMP_CONTEXT (tool_options);
@ -108,6 +89,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
vbox = gimp_tool_options_gui (tool_options);
dialog_factory = g_object_get_data (G_OBJECT (tool_options),
"gimp-tool-options-dialog-factory");
/* the main table */
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
@ -142,71 +126,47 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
tool_options->tool_info->tool_type != GIMP_TYPE_BLEND_TOOL &&
tool_options->tool_info->tool_type != GIMP_TYPE_INK_TOOL)
{
GtkWidget *button;
GtkWidget *preview;
button = gtk_button_new ();
preview = gimp_prop_preview_new (config, "brush", 24);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (context->gimp->brush_factory->container,
context, 24,
dialog_factory,
"gimp-brush-grid",
GIMP_STOCK_TOOL_PAINTBRUSH,
_("Open the brush selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Brush:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (paint_options_brush_clicked),
context);
g_signal_connect (button, "scroll_event",
G_CALLBACK (paint_options_brush_scrolled),
context);
}
/* the pattern preview */
if (tool_options->tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL ||
tool_options->tool_info->tool_type == GIMP_TYPE_CLONE_TOOL)
{
GtkWidget *button;
GtkWidget *preview;
button = gtk_button_new ();
preview = gimp_prop_preview_new (config, "pattern", 24);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (context->gimp->pattern_factory->container,
context, 24,
dialog_factory,
"gimp-pattern-grid",
GIMP_STOCK_TOOL_BUCKET_FILL,
_("Open the pattern selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Pattern:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (paint_options_pattern_clicked),
context);
g_signal_connect (button, "scroll_event",
G_CALLBACK (paint_options_pattern_scrolled),
context);
}
/* the gradient preview */
if (tool_options->tool_info->tool_type == GIMP_TYPE_BLEND_TOOL)
{
GtkWidget *button;
GtkWidget *preview;
button = gtk_button_new ();
preview = gimp_prop_preview_new (config, "gradient", 32);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (context->gimp->gradient_factory->container,
context, 32,
dialog_factory,
"gimp-gradient-list",
GIMP_STOCK_TOOL_BLEND,
_("Open the gradient selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Gradient:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (paint_options_gradient_clicked),
context);
g_signal_connect (button, "scroll_event",
G_CALLBACK (paint_options_gradient_scrolled),
context);
}
/* the "incremental" toggle */
@ -474,135 +434,3 @@ gradient_options_gui (GimpGradientOptions *gradient,
return frame;
}
void
paint_options_container_scrolled (GimpContainer *container,
GimpContext *context,
GType type,
GdkEventScroll *sevent)
{
GimpObject *object;
gint index;
object = gimp_context_get_by_type (context, type);
index = gimp_container_get_child_index (container, object);
if (index != -1)
{
gint n_children;
gint new_index = index;
n_children = gimp_container_num_children (container);
if (sevent->direction == GDK_SCROLL_UP)
{
if (index > 0)
new_index--;
else
new_index = n_children - 1;
}
else if (sevent->direction == GDK_SCROLL_DOWN)
{
if (index == (n_children - 1))
new_index = 0;
else
new_index++;
}
if (new_index != index)
{
object = gimp_container_get_child_by_index (container, new_index);
if (object)
gimp_context_set_by_type (context, type, object);
}
}
}
static void
paint_options_brush_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->brush_factory->container,
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-brush-grid",
GIMP_STOCK_TOOL_PAINTBRUSH,
_("Open the brush selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
paint_options_brush_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->brush_factory->container,
context, GIMP_TYPE_BRUSH, sevent);
return TRUE;
}
static void
paint_options_pattern_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->pattern_factory->container,
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-pattern-grid",
GIMP_STOCK_TOOL_BUCKET_FILL,
_("Open the pattern selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
paint_options_pattern_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->pattern_factory->container,
context, GIMP_TYPE_PATTERN, sevent);
return TRUE;
}
static void
paint_options_gradient_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->gradient_factory->container,
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-gradient-list",
GIMP_STOCK_TOOL_BLEND,
_("Open the gradient selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
paint_options_gradient_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->gradient_factory->container,
context, GIMP_TYPE_GRADIENT, sevent);
return TRUE;
}

View File

@ -26,12 +26,4 @@
GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options);
/* utility function -- will become a widget soon */
void paint_options_container_scrolled (GimpContainer *container,
GimpContext *context,
GType type,
GdkEventScroll *sevent);
#endif /* __PAINT_OPTIONS_H__ */

View File

@ -33,19 +33,16 @@
#include "core/gimpcontainer.h"
#include "core/gimptoolinfo.h"
#include "text/gimpfont.h"
#include "text/gimptext.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpfontselection.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimptexteditor.h"
#include "widgets/gimpviewablebutton.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimptextoptions.h"
#include "paint_options.h"
#include "gimp-intl.h"
@ -72,12 +69,6 @@ static void gimp_text_notify_font (GimpText *text,
GParamSpec *pspec,
GimpContext *context);
static void gimp_text_options_font_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean gimp_text_options_font_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
static GimpToolOptionsClass *parent_class = NULL;
@ -218,46 +209,44 @@ gimp_text_notify_font (GimpText *text,
GtkWidget *
gimp_text_options_gui (GimpToolOptions *tool_options)
{
GimpTextOptions *options;
GObject *config;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *button;
GtkWidget *auto_button;
GtkWidget *preview;
GtkWidget *menu;
GtkWidget *font_selection;
GtkWidget *box;
GtkWidget *spinbutton;
gint digits;
GimpTextOptions *options;
GObject *config;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *button;
GimpDialogFactory *dialog_factory;
GtkWidget *auto_button;
GtkWidget *menu;
GtkWidget *font_selection;
GtkWidget *box;
GtkWidget *spinbutton;
gint digits;
options = GIMP_TEXT_OPTIONS (tool_options);
config = G_OBJECT (options->text);
vbox = gimp_tool_options_gui (tool_options);
dialog_factory = g_object_get_data (G_OBJECT (tool_options),
"gimp-tool-options-dialog-factory");
table = gtk_table_new (10, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
button = gtk_button_new ();
preview = gimp_prop_preview_new (G_OBJECT (options), "font", 24);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (GIMP_CONTEXT (options)->gimp->fonts,
GIMP_CONTEXT (options), 24,
dialog_factory,
"gimp-font-list",
GIMP_STOCK_TOOL_TEXT,
_("Open the font selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Font:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (gimp_text_options_font_clicked),
options);
g_signal_connect (button, "scroll_event",
G_CALLBACK (gimp_text_options_font_scrolled),
options);
font_selection = gimp_prop_font_selection_new (config, "font");
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("_Font:"), 1.0, 0.5,
@ -369,32 +358,4 @@ gimp_text_options_editor_new (GimpTextOptions *options,
editor, 0);
return editor;
}
static void
gimp_text_options_font_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->fonts, context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-font-list",
GTK_STOCK_SELECT_FONT,
_("Open the font selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
gimp_text_options_font_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->fonts,
context, GIMP_TYPE_FONT, sevent);
return TRUE;
}

View File

@ -28,20 +28,15 @@
#include "config/gimpconfig.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
#include "core/gimpdatafactory.h"
#include "core/gimpgradient.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "paint/gimppaintoptions.h"
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gtkhwrapbox.h"
#include "widgets/gimpviewablebutton.h"
#include "gimpairbrushtool.h"
#include "gimpblendtool.h"
@ -71,36 +66,22 @@ static GtkWidget * gradient_options_gui (GimpGradientOptions *gradient,
GType tool_type,
GtkWidget *incremental_toggle);
static void paint_options_brush_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean paint_options_brush_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
static void paint_options_pattern_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean paint_options_pattern_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
static void paint_options_gradient_clicked (GtkWidget *widget,
GimpContext *context);
static gboolean paint_options_gradient_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context);
GtkWidget *
gimp_paint_options_gui (GimpToolOptions *tool_options)
{
GimpPaintOptions *options;
GimpContext *context;
GObject *config;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *optionmenu;
GtkWidget *mode_label;
GtkWidget *incremental_toggle = NULL;
gint table_row = 0;
GimpPaintOptions *options;
GimpContext *context;
GObject *config;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *optionmenu;
GtkWidget *mode_label;
GtkWidget *button;
GimpDialogFactory *dialog_factory;
GtkWidget *incremental_toggle = NULL;
gint table_row = 0;
options = GIMP_PAINT_OPTIONS (tool_options);
context = GIMP_CONTEXT (tool_options);
@ -108,6 +89,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
vbox = gimp_tool_options_gui (tool_options);
dialog_factory = g_object_get_data (G_OBJECT (tool_options),
"gimp-tool-options-dialog-factory");
/* the main table */
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
@ -142,71 +126,47 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
tool_options->tool_info->tool_type != GIMP_TYPE_BLEND_TOOL &&
tool_options->tool_info->tool_type != GIMP_TYPE_INK_TOOL)
{
GtkWidget *button;
GtkWidget *preview;
button = gtk_button_new ();
preview = gimp_prop_preview_new (config, "brush", 24);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (context->gimp->brush_factory->container,
context, 24,
dialog_factory,
"gimp-brush-grid",
GIMP_STOCK_TOOL_PAINTBRUSH,
_("Open the brush selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Brush:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (paint_options_brush_clicked),
context);
g_signal_connect (button, "scroll_event",
G_CALLBACK (paint_options_brush_scrolled),
context);
}
/* the pattern preview */
if (tool_options->tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL ||
tool_options->tool_info->tool_type == GIMP_TYPE_CLONE_TOOL)
{
GtkWidget *button;
GtkWidget *preview;
button = gtk_button_new ();
preview = gimp_prop_preview_new (config, "pattern", 24);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (context->gimp->pattern_factory->container,
context, 24,
dialog_factory,
"gimp-pattern-grid",
GIMP_STOCK_TOOL_BUCKET_FILL,
_("Open the pattern selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Pattern:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (paint_options_pattern_clicked),
context);
g_signal_connect (button, "scroll_event",
G_CALLBACK (paint_options_pattern_scrolled),
context);
}
/* the gradient preview */
if (tool_options->tool_info->tool_type == GIMP_TYPE_BLEND_TOOL)
{
GtkWidget *button;
GtkWidget *preview;
button = gtk_button_new ();
preview = gimp_prop_preview_new (config, "gradient", 32);
gtk_container_add (GTK_CONTAINER (button), preview);
gtk_widget_show (preview);
button = gimp_viewable_button_new (context->gimp->gradient_factory->container,
context, 32,
dialog_factory,
"gimp-gradient-list",
GIMP_STOCK_TOOL_BLEND,
_("Open the gradient selection dialog"));
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Gradient:"), 1.0, 0.5,
button, 2, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (paint_options_gradient_clicked),
context);
g_signal_connect (button, "scroll_event",
G_CALLBACK (paint_options_gradient_scrolled),
context);
}
/* the "incremental" toggle */
@ -474,135 +434,3 @@ gradient_options_gui (GimpGradientOptions *gradient,
return frame;
}
void
paint_options_container_scrolled (GimpContainer *container,
GimpContext *context,
GType type,
GdkEventScroll *sevent)
{
GimpObject *object;
gint index;
object = gimp_context_get_by_type (context, type);
index = gimp_container_get_child_index (container, object);
if (index != -1)
{
gint n_children;
gint new_index = index;
n_children = gimp_container_num_children (container);
if (sevent->direction == GDK_SCROLL_UP)
{
if (index > 0)
new_index--;
else
new_index = n_children - 1;
}
else if (sevent->direction == GDK_SCROLL_DOWN)
{
if (index == (n_children - 1))
new_index = 0;
else
new_index++;
}
if (new_index != index)
{
object = gimp_container_get_child_by_index (container, new_index);
if (object)
gimp_context_set_by_type (context, type, object);
}
}
}
static void
paint_options_brush_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->brush_factory->container,
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-brush-grid",
GIMP_STOCK_TOOL_PAINTBRUSH,
_("Open the brush selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
paint_options_brush_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->brush_factory->container,
context, GIMP_TYPE_BRUSH, sevent);
return TRUE;
}
static void
paint_options_pattern_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->pattern_factory->container,
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-pattern-grid",
GIMP_STOCK_TOOL_BUCKET_FILL,
_("Open the pattern selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
paint_options_pattern_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->pattern_factory->container,
context, GIMP_TYPE_PATTERN, sevent);
return TRUE;
}
static void
paint_options_gradient_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->gradient_factory->container,
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-gradient-list",
GIMP_STOCK_TOOL_BLEND,
_("Open the gradient selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static gboolean
paint_options_gradient_scrolled (GtkWidget *widget,
GdkEventScroll *sevent,
GimpContext *context)
{
paint_options_container_scrolled (context->gimp->gradient_factory->container,
context, GIMP_TYPE_GRADIENT, sevent);
return TRUE;
}

View File

@ -26,12 +26,4 @@
GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options);
/* utility function -- will become a widget soon */
void paint_options_container_scrolled (GimpContainer *container,
GimpContext *context,
GType type,
GdkEventScroll *sevent);
#endif /* __PAINT_OPTIONS_H__ */

View File

@ -35,6 +35,11 @@
#include "display/gimpdisplay.h"
#ifdef __GNUC__
#warning FIXME: #include "gui/dialogs.h"
#endif
#include "gui/dialogs.h"
#include "gimpairbrushtool.h"
#include "gimpclonetool.h"
#include "gimpconvolvetool.h"
@ -58,7 +63,8 @@
GIMP_CONTEXT_PAINT_MODE_MASK | \
GIMP_CONTEXT_BRUSH_MASK | \
GIMP_CONTEXT_PATTERN_MASK | \
GIMP_CONTEXT_GRADIENT_MASK
GIMP_CONTEXT_GRADIENT_MASK | \
GIMP_CONTEXT_FONT_MASK
typedef struct _GimpToolManager GimpToolManager;
@ -205,7 +211,15 @@ tool_manager_restore (Gimp *gimp)
if (options_gui_func)
{
g_object_set_data (G_OBJECT (tool_info->tool_options),
"gimp-tool-options-dialog-factory",
global_dock_factory);
options_gui = options_gui_func (tool_info->tool_options);
g_object_set_data (G_OBJECT (tool_info->tool_options),
"gimp-tool-options-dialog-factory",
NULL);
}
else
{

View File

@ -153,6 +153,8 @@ libappwidgets_a_sources = \
gimpundoeditor.h \
gimpvectorstreeview.c \
gimpvectorstreeview.h \
gimpviewablebutton.c \
gimpviewablebutton.h \
gimpviewabledialog.c \
gimpviewabledialog.h \
gimpwidgets-constructors.c \

View File

@ -0,0 +1,247 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpviewablebutton.c
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpviewable.h"
#include "gimpcontainerpopup.h"
#include "gimpdialogfactory.h"
#include "gimppropwidgets.h"
#include "gimpviewablebutton.h"
#include "gimp-intl.h"
static void gimp_viewable_button_class_init (GimpViewableButtonClass *klass);
static void gimp_viewable_button_init (GimpViewableButton *button);
static void gimp_viewable_button_destroy (GtkObject *object);
static gboolean gimp_viewable_button_scroll_event (GtkWidget *widget,
GdkEventScroll *sevent);
static void gimp_viewable_button_clicked (GtkButton *button);
static GimpButtonClass *parent_class = NULL;
GType
gimp_viewable_button_get_type (void)
{
static GType button_type = 0;
if (!button_type)
{
static const GTypeInfo button_info =
{
sizeof (GimpViewableButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_viewable_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpViewableButton),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_viewable_button_init,
};
button_type = g_type_register_static (GIMP_TYPE_BUTTON,
"GimpViewableButton",
&button_info, 0);
}
return button_type;
}
static void
gimp_viewable_button_class_init (GimpViewableButtonClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
button_class = GTK_BUTTON_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_viewable_button_destroy;
widget_class->scroll_event = gimp_viewable_button_scroll_event;
button_class->clicked = gimp_viewable_button_clicked;
}
static void
gimp_viewable_button_init (GimpViewableButton *button)
{
}
static void
gimp_viewable_button_destroy (GtkObject *object)
{
GimpViewableButton *button;
button = GIMP_VIEWABLE_BUTTON (object);
if (button->dialog_identifier)
{
g_free (button->dialog_identifier);
button->dialog_identifier = NULL;
}
if (button->dialog_stock_id)
{
g_free (button->dialog_stock_id);
button->dialog_stock_id = NULL;
}
if (button->dialog_tooltip)
{
g_free (button->dialog_tooltip);
button->dialog_tooltip = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static gboolean
gimp_viewable_button_scroll_event (GtkWidget *widget,
GdkEventScroll *sevent)
{
GimpViewableButton *button;
GimpObject *object;
gint index;
button = GIMP_VIEWABLE_BUTTON (widget);
object = gimp_context_get_by_type (button->context,
button->container->children_type);
index = gimp_container_get_child_index (button->container, object);
if (index != -1)
{
gint n_children;
gint new_index = index;
n_children = gimp_container_num_children (button->container);
if (sevent->direction == GDK_SCROLL_UP)
{
if (index > 0)
new_index--;
else
new_index = n_children - 1;
}
else if (sevent->direction == GDK_SCROLL_DOWN)
{
if (index == (n_children - 1))
new_index = 0;
else
new_index++;
}
if (new_index != index)
{
object = gimp_container_get_child_by_index (button->container,
new_index);
if (object)
gimp_context_set_by_type (button->context,
button->container->children_type,
object);
}
}
return TRUE;
}
static void
gimp_viewable_button_clicked (GtkButton *button)
{
GimpViewableButton *viewable_button;
GtkWidget *popup;
viewable_button = GIMP_VIEWABLE_BUTTON (button);
popup = gimp_container_popup_new (viewable_button->container,
viewable_button->context,
viewable_button->dialog_factory,
viewable_button->dialog_identifier,
viewable_button->dialog_stock_id,
viewable_button->dialog_tooltip);
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), GTK_WIDGET (button));
}
GtkWidget *
gimp_viewable_button_new (GimpContainer *container,
GimpContext *context,
gint preview_size,
GimpDialogFactory *dialog_factory,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
const gchar *dialog_tooltip)
{
GimpViewableButton *button;
const gchar *prop_name;
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL);
g_return_val_if_fail (dialog_factory == NULL ||
GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
if (dialog_factory)
{
g_return_val_if_fail (dialog_identifier != NULL, NULL);
g_return_val_if_fail (dialog_stock_id != NULL, NULL);
g_return_val_if_fail (dialog_tooltip != NULL, NULL);
}
button = g_object_new (GIMP_TYPE_VIEWABLE_BUTTON, NULL);
button->container = container;
button->context = context;
if (dialog_factory)
{
button->dialog_factory = dialog_factory;
button->dialog_identifier = g_strdup (dialog_identifier);
button->dialog_stock_id = g_strdup (dialog_stock_id);
button->dialog_tooltip = g_strdup (dialog_tooltip);
}
prop_name = gimp_context_type_to_prop_name (container->children_type);
button->preview = gimp_prop_preview_new (G_OBJECT (context), prop_name,
preview_size);
gtk_container_add (GTK_CONTAINER (button), button->preview);
gtk_widget_show (button->preview);
return GTK_WIDGET (button);
}

View File

@ -0,0 +1,72 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpviewablebutton.h
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_VIEWABLE_BUTTON_H__
#define __GIMP_VIEWABLE_BUTTON_H__
#include "libgimpwidgets/gimpbutton.h"
G_BEGIN_DECLS
#define GIMP_TYPE_VIEWABLE_BUTTON (gimp_viewable_button_get_type ())
#define GIMP_VIEWABLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VIEWABLE_BUTTON, GimpViewableButton))
#define GIMP_VIEWABLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VIEWABLE_BUTTON, GimpViewableButtonClass))
#define GIMP_IS_VIEWABLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VIEWABLE_BUTTON))
#define GIMP_IS_VIEWABLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_VIEWABLE_BUTTON))
#define GIMP_VIEWABLE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_VIEWABLE_BUTTON, GimpViewableButtonClass))
typedef struct _GimpViewableButtonClass GimpViewableButtonClass;
struct _GimpViewableButton
{
GimpButton parent_instance;
GimpContainer *container;
GimpContext *context;
GimpDialogFactory *dialog_factory;
gchar *dialog_identifier;
gchar *dialog_stock_id;
gchar *dialog_tooltip;
GtkWidget *preview;
};
struct _GimpViewableButtonClass
{
GimpButtonClass parent_class;
};
GType gimp_viewable_button_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_viewable_button_new (GimpContainer *container,
GimpContext *context,
gint preview_size,
GimpDialogFactory *dialog_factory,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
const gchar *dialog_tooltip);
G_END_DECLS
#endif /* __GIMP_VIEWABLE_BUTTON_H__ */

View File

@ -96,6 +96,7 @@ typedef struct _GimpDockable GimpDockable;
typedef struct _GimpDockbook GimpDockbook;
typedef struct _GimpContainerPopup GimpContainerPopup;
typedef struct _GimpViewableButton GimpViewableButton;
typedef struct _GimpViewableDialog GimpViewableDialog;
typedef struct _GimpFontSelection GimpFontSelection;