app/gui/dialogs-constructors.[ch] app/gui/dialogs.c made the tool options

2002-03-10  Michael Natterer  <mitch@gimp.org>

	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs.c
	* app/gui/tool-options-dialog.[ch]: made the tool options dialog
	dockable. Create a fancy tab for it which looks like the old
	dialog header.

	* app/gui/gui.c
	* app/gui/menus.c
	* app/gui/toolbox.c: changed accordingly.

	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimperasertool.c: moved the tool toggling widgets to
	the top.

	* app/tools/paint_options.c: show the paint mode menu for all
	paint tools but set it insensitive where it makes no sense.
	Reduces flickering and makes the tools' similarity more obvious.

	* app/widgets/gimpdataeditor.c: fixed segfault in
	gimp_data_editor_set_data() (data may be NULL), don't pass NULL to
	gtk_entry_set_text(), make the name entry insensitive if data ==
	NULL.

	* app/widgets/gimpdialogfactory.c: fixed longstanding bug which
	made newly created docks steal the first session entry with a NULL
	widget instead of the first _dock_ session entry with a NULL
	widget. Added even more debugging output. Cleanup.

	* app/widgets/gimpdockbook.c: made the tab/menu widget code more
	general to cover the tool options tab.
This commit is contained in:
Michael Natterer 2002-03-10 15:05:58 +00:00 committed by Michael Natterer
parent 218e11fde3
commit 8b8442e9f4
23 changed files with 847 additions and 633 deletions

View File

@ -1,3 +1,37 @@
2002-03-10 Michael Natterer <mitch@gimp.org>
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs.c
* app/gui/tool-options-dialog.[ch]: made the tool options dialog
dockable. Create a fancy tab for it which looks like the old
dialog header.
* app/gui/gui.c
* app/gui/menus.c
* app/gui/toolbox.c: changed accordingly.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcroptool.c
* app/tools/gimperasertool.c: moved the tool toggling widgets to
the top.
* app/tools/paint_options.c: show the paint mode menu for all
paint tools but set it insensitive where it makes no sense.
Reduces flickering and makes the tools' similarity more obvious.
* app/widgets/gimpdataeditor.c: fixed segfault in
gimp_data_editor_set_data() (data may be NULL), don't pass NULL to
gtk_entry_set_text(), make the name entry insensitive if data ==
NULL.
* app/widgets/gimpdialogfactory.c: fixed longstanding bug which
made newly created docks steal the first session entry with a NULL
widget instead of the first _dock_ session entry with a NULL
widget. Added even more debugging output. Cleanup.
* app/widgets/gimpdockbook.c: made the tab/menu widget code more
general to cover the tool options tab.
2002-03-09 Sven Neumann <sven@gimp.org>
* Made 1.3.4 release.

View File

@ -115,6 +115,9 @@ static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_tool_options_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
@ -144,7 +147,9 @@ static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpColormapDialog *ipal);
/* public functions */
/**********************/
/* toplevel dialogs */
/**********************/
GtkWidget *
dialogs_toolbox_get (GimpDialogFactory *factory,
@ -154,14 +159,6 @@ dialogs_toolbox_get (GimpDialogFactory *factory,
return toolbox_create (context->gimp);
}
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return tool_options_dialog_create (context->gimp);
}
GtkWidget *
dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context,
@ -282,7 +279,9 @@ dialogs_about_get (GimpDialogFactory *factory,
}
/***********/
/* docks */
/***********/
GtkWidget *
dialogs_dock_new (GimpDialogFactory *factory,
@ -293,7 +292,52 @@ dialogs_dock_new (GimpDialogFactory *factory,
}
/* list views */
/***************/
/* dockables */
/***************/
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
if (view)
return NULL;
view = tool_options_dialog_create (context->gimp);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
return dialogs_dockable_new (view,
"Tool Options", "Tool Options",
dialogs_tool_options_tab_func,
NULL);
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
if (view)
return NULL;
view = error_console_create (context->gimp);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
return dialogs_dockable_new (view,
"Error Console", "Errors",
NULL,
NULL);
}
/***** list views *****/
GtkWidget *
dialogs_image_list_view_new (GimpDialogFactory *factory,
@ -439,7 +483,7 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
}
/* grid views */
/***** grid views *****/
GtkWidget *
dialogs_image_grid_view_new (GimpDialogFactory *factory,
@ -585,7 +629,7 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
}
/* image related dialogs */
/***** image related dialogs *****/
GtkWidget *
dialogs_layer_list_view_new (GimpDialogFactory *factory,
@ -774,7 +818,30 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
}
/* editors */
/***** misc dockables *****/
GtkWidget *
dialogs_document_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_document_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->documents,
context,
preview_size,
5, 3,
gimp_item_factory_from_path ("<Documents>"));
return dialogs_dockable_new (view,
"Document History", "History",
NULL,
dialogs_set_editor_context_func);
}
/***** editors *****/
/* the brush editor */
@ -857,53 +924,6 @@ dialogs_edit_palette_func (GimpData *data)
}
/* misc dockables */
GtkWidget *
dialogs_document_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_document_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->documents,
context,
preview_size,
5, 3,
gimp_item_factory_from_path ("<Documents>"));
return dialogs_dockable_new (view,
"Document History", "History",
NULL,
dialogs_set_editor_context_func);
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
GtkWidget *dockable;
if (view)
return NULL;
view = error_console_create (context->gimp);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
dockable = dialogs_dockable_new (view,
"Error Console", "Errors",
NULL,
NULL);
return dockable;
}
/* private functions */
static void
@ -1041,7 +1061,7 @@ dialogs_tool_tab_func (GimpDockable *dockable,
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_tool (context)),
size, size, 1,
MIN (size, 22), MIN (size, 22), 1,
FALSE, FALSE, FALSE);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
@ -1052,6 +1072,70 @@ dialogs_tool_tab_func (GimpDockable *dockable,
return preview;
}
static void
dialogs_tool_options_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
GtkLabel *label)
{
gchar *text;
text = g_strdup_printf (_("%s Options"), tool_info->blurb);
gtk_label_set_text (label, text);
g_free (text);
gimp_help_set_help_data (GTK_WIDGET (label)->parent->parent,
tool_info->help,
tool_info->help_data);
}
static GtkWidget *
dialogs_tool_options_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size)
{
GimpContext *context;
GimpToolInfo *tool_info;
GtkWidget *hbox;
GtkWidget *preview;
GtkWidget *label;
gchar *text;
context = dockbook->dock->context;
tool_info = gimp_context_get_tool (context);
hbox = gtk_hbox_new (FALSE, 2);
preview = gimp_preview_new_full (GIMP_VIEWABLE (tool_info),
MIN (size, 22), MIN (size, 22), 0,
FALSE, FALSE, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
G_CALLBACK (gimp_preview_set_viewable),
G_OBJECT (preview),
G_CONNECT_SWAPPED);
text = g_strdup_printf (_("%s Options"), tool_info->blurb);
label = gtk_label_new (text);
g_free (text);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
G_CALLBACK (dialogs_tool_options_tool_changed),
G_OBJECT (label),
0);
return hbox;
}
static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)

View File

@ -25,9 +25,6 @@
GtkWidget * dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
@ -69,6 +66,13 @@ GtkWidget * dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
@ -148,9 +152,5 @@ GtkWidget * dialogs_palette_editor_get (GimpDialogFactory *factory,
gint preview_size);
void dialogs_edit_palette_func (GimpData *data);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
#endif /* __DIALOGS_CONSTRUCTORS_H__ */

View File

@ -39,7 +39,6 @@ GimpDialogFactory *global_dock_factory = NULL;
static const GimpDialogFactoryEntry toplevel_entries[] =
{
{ "gimp:toolbox", dialogs_toolbox_get, 32, TRUE, TRUE, TRUE, TRUE },
{ "gimp:tool-options-dialog", dialogs_tool_options_get, 32, TRUE, TRUE, FALSE, TRUE },
{ "gimp:device-status-dialog", dialogs_device_status_get, 32, TRUE, TRUE, FALSE, TRUE },
{ "gimp:brush-select-dialog", dialogs_brush_select_get, 32, TRUE, TRUE, FALSE, TRUE },
{ "gimp:pattern-select-dialog", dialogs_pattern_select_get, 32, TRUE, TRUE, FALSE, TRUE },
@ -55,6 +54,9 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
static const GimpDialogFactoryEntry dock_entries[] =
{
{ "gimp:tool-options", dialogs_tool_options_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:error-console", dialogs_error_console_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:image-list", dialogs_image_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp:brush-list", dialogs_brush_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp:pattern-list", dialogs_pattern_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
@ -81,9 +83,7 @@ static const GimpDialogFactoryEntry dock_entries[] =
{ "gimp:brush-editor", dialogs_brush_editor_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:gradient-editor", dialogs_gradient_editor_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:error-console", dialogs_error_console_get, 0, TRUE, FALSE, FALSE, TRUE }
{ "gimp:palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE }
};

View File

@ -115,6 +115,9 @@ static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_tool_options_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
@ -144,7 +147,9 @@ static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpColormapDialog *ipal);
/* public functions */
/**********************/
/* toplevel dialogs */
/**********************/
GtkWidget *
dialogs_toolbox_get (GimpDialogFactory *factory,
@ -154,14 +159,6 @@ dialogs_toolbox_get (GimpDialogFactory *factory,
return toolbox_create (context->gimp);
}
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return tool_options_dialog_create (context->gimp);
}
GtkWidget *
dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context,
@ -282,7 +279,9 @@ dialogs_about_get (GimpDialogFactory *factory,
}
/***********/
/* docks */
/***********/
GtkWidget *
dialogs_dock_new (GimpDialogFactory *factory,
@ -293,7 +292,52 @@ dialogs_dock_new (GimpDialogFactory *factory,
}
/* list views */
/***************/
/* dockables */
/***************/
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
if (view)
return NULL;
view = tool_options_dialog_create (context->gimp);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
return dialogs_dockable_new (view,
"Tool Options", "Tool Options",
dialogs_tool_options_tab_func,
NULL);
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
if (view)
return NULL;
view = error_console_create (context->gimp);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
return dialogs_dockable_new (view,
"Error Console", "Errors",
NULL,
NULL);
}
/***** list views *****/
GtkWidget *
dialogs_image_list_view_new (GimpDialogFactory *factory,
@ -439,7 +483,7 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
}
/* grid views */
/***** grid views *****/
GtkWidget *
dialogs_image_grid_view_new (GimpDialogFactory *factory,
@ -585,7 +629,7 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
}
/* image related dialogs */
/***** image related dialogs *****/
GtkWidget *
dialogs_layer_list_view_new (GimpDialogFactory *factory,
@ -774,7 +818,30 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
}
/* editors */
/***** misc dockables *****/
GtkWidget *
dialogs_document_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_document_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->documents,
context,
preview_size,
5, 3,
gimp_item_factory_from_path ("<Documents>"));
return dialogs_dockable_new (view,
"Document History", "History",
NULL,
dialogs_set_editor_context_func);
}
/***** editors *****/
/* the brush editor */
@ -857,53 +924,6 @@ dialogs_edit_palette_func (GimpData *data)
}
/* misc dockables */
GtkWidget *
dialogs_document_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_document_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->documents,
context,
preview_size,
5, 3,
gimp_item_factory_from_path ("<Documents>"));
return dialogs_dockable_new (view,
"Document History", "History",
NULL,
dialogs_set_editor_context_func);
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
GtkWidget *dockable;
if (view)
return NULL;
view = error_console_create (context->gimp);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
dockable = dialogs_dockable_new (view,
"Error Console", "Errors",
NULL,
NULL);
return dockable;
}
/* private functions */
static void
@ -1041,7 +1061,7 @@ dialogs_tool_tab_func (GimpDockable *dockable,
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_tool (context)),
size, size, 1,
MIN (size, 22), MIN (size, 22), 1,
FALSE, FALSE, FALSE);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
@ -1052,6 +1072,70 @@ dialogs_tool_tab_func (GimpDockable *dockable,
return preview;
}
static void
dialogs_tool_options_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
GtkLabel *label)
{
gchar *text;
text = g_strdup_printf (_("%s Options"), tool_info->blurb);
gtk_label_set_text (label, text);
g_free (text);
gimp_help_set_help_data (GTK_WIDGET (label)->parent->parent,
tool_info->help,
tool_info->help_data);
}
static GtkWidget *
dialogs_tool_options_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size)
{
GimpContext *context;
GimpToolInfo *tool_info;
GtkWidget *hbox;
GtkWidget *preview;
GtkWidget *label;
gchar *text;
context = dockbook->dock->context;
tool_info = gimp_context_get_tool (context);
hbox = gtk_hbox_new (FALSE, 2);
preview = gimp_preview_new_full (GIMP_VIEWABLE (tool_info),
MIN (size, 22), MIN (size, 22), 0,
FALSE, FALSE, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
G_CALLBACK (gimp_preview_set_viewable),
G_OBJECT (preview),
G_CONNECT_SWAPPED);
text = g_strdup_printf (_("%s Options"), tool_info->blurb);
label = gtk_label_new (text);
g_free (text);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
G_CALLBACK (dialogs_tool_options_tool_changed),
G_OBJECT (label),
0);
return hbox;
}
static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)

View File

@ -25,9 +25,6 @@
GtkWidget * dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
@ -69,6 +66,13 @@ GtkWidget * dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
@ -148,9 +152,5 @@ GtkWidget * dialogs_palette_editor_get (GimpDialogFactory *factory,
gint preview_size);
void dialogs_edit_palette_func (GimpData *data);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
#endif /* __DIALOGS_CONSTRUCTORS_H__ */

View File

@ -39,7 +39,6 @@ GimpDialogFactory *global_dock_factory = NULL;
static const GimpDialogFactoryEntry toplevel_entries[] =
{
{ "gimp:toolbox", dialogs_toolbox_get, 32, TRUE, TRUE, TRUE, TRUE },
{ "gimp:tool-options-dialog", dialogs_tool_options_get, 32, TRUE, TRUE, FALSE, TRUE },
{ "gimp:device-status-dialog", dialogs_device_status_get, 32, TRUE, TRUE, FALSE, TRUE },
{ "gimp:brush-select-dialog", dialogs_brush_select_get, 32, TRUE, TRUE, FALSE, TRUE },
{ "gimp:pattern-select-dialog", dialogs_pattern_select_get, 32, TRUE, TRUE, FALSE, TRUE },
@ -55,6 +54,9 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
static const GimpDialogFactoryEntry dock_entries[] =
{
{ "gimp:tool-options", dialogs_tool_options_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:error-console", dialogs_error_console_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:image-list", dialogs_image_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp:brush-list", dialogs_brush_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp:pattern-list", dialogs_pattern_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
@ -81,9 +83,7 @@ static const GimpDialogFactoryEntry dock_entries[] =
{ "gimp:brush-editor", dialogs_brush_editor_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:gradient-editor", dialogs_gradient_editor_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE },
{ "gimp:error-console", dialogs_error_console_get, 0, TRUE, FALSE, FALSE, TRUE }
{ "gimp:palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE }
};

View File

@ -57,7 +57,6 @@
#include "palette-select.h"
#include "pattern-select.h"
#include "session.h"
#include "tool-options-dialog.h"
#include "toolbox.h"
#include "gimprc.h"
@ -310,7 +309,6 @@ gui_exit (Gimp *gimp)
gimp_devices_exit (gimp);
/* handle this in the dialog factory: */
tool_options_dialog_free (gimp);
toolbox_free (gimp);
gimp_help_free ();

View File

@ -155,8 +155,8 @@ static GimpItemFactoryEntry toolbox_entries[] =
NULL,
NULL, NULL },
{ { N_("/File/Dialogs/Tool Options..."), "<control><shift>T",
dialogs_create_toplevel_cmd_callback, 0 },
"gimp:tool-options-dialog",
dialogs_create_dockable_cmd_callback, 0 },
"gimp:tool-options",
"file/dialogs/tool_options.html", NULL },
{ { N_("/File/Dialogs/Device Status..."), NULL,
dialogs_create_toplevel_cmd_callback, 0 },
@ -848,8 +848,8 @@ static GimpItemFactoryEntry image_entries[] =
NULL,
NULL, NULL },
{ { N_("/Dialogs/Tool Options..."), NULL,
dialogs_create_toplevel_cmd_callback, 0 },
"gimp:tool-options-dialog",
dialogs_create_dockable_cmd_callback, 0 },
"gimp:tool-options",
"dialogs/tool_options.html", NULL },
{ { N_("/Dialogs/Device Status..."), NULL,
dialogs_create_toplevel_cmd_callback, 0 },

View File

@ -30,12 +30,11 @@
#include "core/gimptoolinfo.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimpeditor.h"
#include "widgets/gimppreview.h"
#include "widgets/gimpwidgets-utils.h"
#include "tools/gimptool.h"
#include "tools/tool_options.h"
#include "tools/tool_manager.h"
#include "tool-options-dialog.h"
@ -44,28 +43,34 @@
/* local function prototypes */
static void tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static GimpViewable * tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_close_callback (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_destroy (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static GimpViewable * tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_save_callback (GtkWidget *widget,
GimpContext *context);
static void tool_options_dialog_restore_callback (GtkWidget *widget,
GimpContext *context);
static void tool_options_dialog_reset_callback (GtkWidget *widget,
GimpContext *context);
/* private variables */
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_label = NULL;
static GtkWidget *options_preview = NULL;
static GtkWidget *options_eventbox = NULL;
static GtkWidget *options_reset_button = NULL;
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_save_button = NULL;
static GtkWidget *options_revert_button = NULL;
static GtkWidget *options_reset_button = NULL;
static GimpToolOptions *visible_tool_options = NULL;
@ -75,17 +80,19 @@ static GimpToolOptions *visible_tool_options = NULL;
GtkWidget *
tool_options_dialog_create (Gimp *gimp)
{
GimpContext *user_context;
GimpToolInfo *tool_info;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *editor;
GtkWidget *scrolled_win;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (options_shell)
return options_shell;
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
user_context = gimp_get_user_context (gimp);
tool_info = gimp_context_get_tool (user_context);
if (! tool_info)
{
@ -93,61 +100,55 @@ tool_options_dialog_create (Gimp *gimp)
G_GNUC_FUNCTION);
}
/* The shell and main vbox */
options_shell =
gimp_dialog_new (_("Tool Options"), "tool_options",
tool_manager_help_func,
"dialogs/tool_options.html",
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
editor = g_object_new (GIMP_TYPE_EDITOR, NULL);
GIMP_STOCK_RESET, tool_options_dialog_reset_callback,
gimp, NULL, &options_reset_button, FALSE, FALSE,
gtk_widget_set_size_request (editor, -1, 200);
GTK_STOCK_CLOSE, tool_options_dialog_close_callback,
NULL, NULL, NULL, TRUE, TRUE,
options_shell = editor;
NULL);
g_signal_connect (G_OBJECT (options_shell), "destroy",
G_CALLBACK (tool_options_dialog_destroy),
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (options_shell), FALSE);
options_save_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_SAVE,
_("Save current settings to disk"),
NULL,
G_CALLBACK (tool_options_dialog_save_callback),
NULL,
user_context);
/* The outer frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options_shell)->vbox), frame);
gtk_widget_show (frame);
options_revert_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_REVERT_TO_SAVED,
_("Restore saved settings"),
NULL,
G_CALLBACK (tool_options_dialog_restore_callback),
NULL,
user_context);
/* The vbox containing the title frame and the options vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
options_reset_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GIMP_STOCK_RESET,
_("Reset"),
NULL,
G_CALLBACK (tool_options_dialog_reset_callback),
NULL,
user_context);
/* The title frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
options_eventbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (frame), options_eventbox);
gtk_widget_show (options_eventbox);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (options_eventbox), hbox);
gtk_widget_show (hbox);
options_preview = gimp_preview_new (GIMP_VIEWABLE (tool_info), 22, 0, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), options_preview, FALSE, FALSE, 0);
gtk_widget_show (options_preview);
options_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), options_label, FALSE, FALSE, 1);
gtk_widget_show (options_label);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (editor), scrolled_win);
gtk_widget_show (scrolled_win);
/* The vbox containing the tool options */
options_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (options_vbox), 2);
gtk_box_pack_start (GTK_BOX (vbox), options_vbox, FALSE, FALSE, 0);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
options_vbox);
gtk_widget_show (options_vbox);
/* dnd stuff */
@ -160,47 +161,44 @@ tool_options_dialog_create (Gimp *gimp)
gimp_dnd_viewable_dest_set (options_shell,
GIMP_TYPE_TOOL_INFO,
tool_options_dialog_drop_tool,
gimp);
user_context);
gimp_gtk_drag_source_set_by_type (options_eventbox,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
GIMP_TYPE_TOOL_INFO,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (options_eventbox,
GIMP_TYPE_TOOL_INFO,
tool_options_dialog_drag_tool,
gimp);
g_signal_connect_object (G_OBJECT (gimp_get_user_context (gimp)),
"tool_changed",
g_signal_connect_object (G_OBJECT (user_context), "tool_changed",
G_CALLBACK (tool_options_dialog_tool_changed),
G_OBJECT (options_shell),
0);
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
tool_options_dialog_tool_changed (gimp_get_user_context (gimp),
tool_options_dialog_tool_changed (user_context,
tool_info,
options_shell);
return options_shell;
}
void
tool_options_dialog_free (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (options_shell)
{
gtk_widget_destroy (options_shell);
options_shell = NULL;
}
return editor;
}
/* private functions */
static void
tool_options_dialog_destroy (GtkWidget *widget,
gpointer data)
{
GList *options;
GList *list;
options = gtk_container_get_children (GTK_CONTAINER (options_vbox));
for (list = options; list; list = g_list_next (list))
{
g_object_ref (G_OBJECT (list->data));
gtk_container_remove (GTK_CONTAINER (options_vbox),
GTK_WIDGET (list->data));
}
g_list_free (options);
options_shell = NULL;
}
static void
tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
@ -227,9 +225,6 @@ tool_options_dialog_tool_changed (GimpContext *context,
visible_tool_options = tool_info->tool_options;
gtk_label_set_text (GTK_LABEL (options_label),
tool_info->blurb);
if (tool_info->tool_options->reset_func)
gtk_widget_set_sensitive (options_reset_button, TRUE);
else
@ -239,14 +234,6 @@ tool_options_dialog_tool_changed (GimpContext *context,
{
gtk_widget_set_sensitive (options_reset_button, FALSE);
}
gimp_preview_set_viewable (GIMP_PREVIEW (options_preview),
GIMP_VIEWABLE (tool_info));
gimp_help_set_help_data (options_label->parent->parent,
tool_info->help,
tool_info->help_data);
}
}
@ -255,59 +242,48 @@ tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
Gimp *gimp;
GimpContext *context;
gimp = GIMP (data);
context = GIMP_CONTEXT (data);
gimp_context_set_tool (gimp_get_user_context (gimp),
GIMP_TOOL_INFO (viewable));
gimp_context_set_tool (context, GIMP_TOOL_INFO (viewable));
}
GimpViewable *
tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data)
{
Gimp *gimp;
GimpContext *context;
gimp = GIMP (data);
context = GIMP_CONTEXT (data);
return (GimpViewable *) gimp_context_get_tool (gimp_get_user_context (gimp));
return (GimpViewable *) gimp_context_get_tool (context);
}
static void
tool_options_dialog_close_callback (GtkWidget *widget,
gpointer data)
tool_options_dialog_save_callback (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *shell;
shell = (GtkWidget *) data;
gtk_widget_hide (shell);
g_print ("Save clicked\n");
}
static void
tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data)
tool_options_dialog_restore_callback (GtkWidget *widget,
GimpContext *context)
{
g_print ("Restore clicked\n");
}
static void
tool_options_dialog_reset_callback (GtkWidget *widget,
GimpContext *context)
{
GimpToolInfo *tool_info;
GimpTool *active_tool;
Gimp *gimp;
gimp = GIMP (data);
active_tool = tool_manager_get_active (gimp);
if (! active_tool)
return;
tool_info = active_tool->tool_info;
tool_info = gimp_context_get_tool (context);
if (! tool_info)
{
g_warning ("%s(): no tool info registered for %s",
G_GNUC_FUNCTION,
g_type_name (G_TYPE_FROM_INSTANCE (active_tool)));
}
return;
if (tool_info->tool_options->reset_func)
tool_info->tool_options->reset_func (tool_info->tool_options);

View File

@ -21,7 +21,6 @@
GtkWidget * tool_options_dialog_create (Gimp *gimp);
void tool_options_dialog_free (Gimp *gimp);
#endif /* __TOOL_OPTIONS_DIALOG_H__ */

View File

@ -417,8 +417,9 @@ toolbox_tool_button_press (GtkWidget *widget,
{
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
gimp_dialog_factory_dialog_new (global_dialog_factory,
"gimp:tool-options-dialog", -1);
gimp_dialog_factory_dialog_raise (global_dock_factory,
"gimp:tool-options",
-1);
}
return FALSE;

View File

@ -155,8 +155,8 @@ static GimpItemFactoryEntry toolbox_entries[] =
NULL,
NULL, NULL },
{ { N_("/File/Dialogs/Tool Options..."), "<control><shift>T",
dialogs_create_toplevel_cmd_callback, 0 },
"gimp:tool-options-dialog",
dialogs_create_dockable_cmd_callback, 0 },
"gimp:tool-options",
"file/dialogs/tool_options.html", NULL },
{ { N_("/File/Dialogs/Device Status..."), NULL,
dialogs_create_toplevel_cmd_callback, 0 },
@ -848,8 +848,8 @@ static GimpItemFactoryEntry image_entries[] =
NULL,
NULL, NULL },
{ { N_("/Dialogs/Tool Options..."), NULL,
dialogs_create_toplevel_cmd_callback, 0 },
"gimp:tool-options-dialog",
dialogs_create_dockable_cmd_callback, 0 },
"gimp:tool-options",
"dialogs/tool_options.html", NULL },
{ { N_("/Dialogs/Device Status..."), NULL,
dialogs_create_toplevel_cmd_callback, 0 },

View File

@ -353,6 +353,29 @@ bucket_options_new (GimpToolInfo *tool_info)
/* the main vbox */
vbox = ((GimpToolOptions *) options)->main_vbox;
/* fill type */
frame = gimp_radio_group_new2 (TRUE, _("Fill Type (<Ctrl>)"),
G_CALLBACK (gimp_radio_button_update),
&options->fill_mode,
GINT_TO_POINTER (options->fill_mode),
_("FG Color Fill"),
GINT_TO_POINTER (FG_BUCKET_FILL),
&options->fill_mode_w[0],
_("BG Color Fill"),
GINT_TO_POINTER (BG_BUCKET_FILL),
&options->fill_mode_w[1],
_("Pattern Fill"),
GINT_TO_POINTER (PATTERN_BUCKET_FILL),
&options->fill_mode_w[2],
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
frame = gtk_frame_new (_("Finding Similar Colors"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
@ -411,29 +434,6 @@ bucket_options_new (GimpToolInfo *tool_info)
G_CALLBACK (gimp_double_adjustment_update),
&options->threshold);
/* fill type */
frame = gimp_radio_group_new2 (TRUE, _("Fill Type (<Ctrl>)"),
G_CALLBACK (gimp_radio_button_update),
&options->fill_mode,
GINT_TO_POINTER (options->fill_mode),
_("FG Color Fill"),
GINT_TO_POINTER (FG_BUCKET_FILL),
&options->fill_mode_w[0],
_("BG Color Fill"),
GINT_TO_POINTER (BG_BUCKET_FILL),
&options->fill_mode_w[1],
_("Pattern Fill"),
GINT_TO_POINTER (PATTERN_BUCKET_FILL),
&options->fill_mode_w[2],
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
bucket_options_reset ((GimpToolOptions *) options);
return (GimpToolOptions *) options;

View File

@ -1346,6 +1346,25 @@ crop_options_new (GimpToolInfo *tool_info)
/* the main vbox */
vbox = options->tool_options.main_vbox;
/* tool toggle */
frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle (<Ctrl>)"),
G_CALLBACK (gimp_radio_button_update),
&options->type,
GINT_TO_POINTER (options->type),
_("Crop"),
GINT_TO_POINTER (CROP_CROP),
&options->type_w[0],
_("Resize"),
GINT_TO_POINTER (RESIZE_CROP),
&options->type_w[1],
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
/* layer toggle */
options->layer_only_w =
gtk_check_button_new_with_label(_("Current Layer only"));
@ -1370,25 +1389,6 @@ crop_options_new (GimpToolInfo *tool_info)
options->allow_enlarge_d);
gtk_widget_show (options->allow_enlarge_w);
/* tool toggle */
frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle (<Ctrl>)"),
G_CALLBACK (gimp_radio_button_update),
&options->type,
GINT_TO_POINTER (options->type),
_("Crop"),
GINT_TO_POINTER (CROP_CROP),
&options->type_w[0],
_("Resize"),
GINT_TO_POINTER (RESIZE_CROP),
&options->type_w[1],
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
return (GimpToolOptions *) options;
}

View File

@ -180,26 +180,28 @@ gimp_eraser_tool_options_new (GimpToolInfo *tool_info)
/* the main vbox */
vbox = ((GimpToolOptions *) options)->main_vbox;
/* the hard toggle */
options->hard_w = gtk_check_button_new_with_label (_("Hard Edge"));
gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (options->hard_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&options->hard);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_widget_show (options->hard_w);
/* the anti_erase toggle */
options->anti_erase_w =
gtk_check_button_new_with_label (_("Anti Erase (<Ctrl>)"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
gtk_widget_show (options->anti_erase_w);
g_signal_connect (G_OBJECT (options->anti_erase_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&options->anti_erase);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
gtk_widget_show (options->anti_erase_w);
/* the hard toggle */
options->hard_w = gtk_check_button_new_with_label (_("Hard Edge"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0);
gtk_widget_show (options->hard_w);
g_signal_connect (G_OBJECT (options->hard_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&options->hard);
return (GimpToolOptions *) options;
}
@ -213,8 +215,8 @@ gimp_eraser_tool_options_reset (GimpToolOptions *tool_options)
paint_options_reset (tool_options);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
}

View File

@ -102,6 +102,7 @@ paint_options_init (GimpPaintOptions *options,
{
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *mode_label;
/* initialize the tool options structure */
tool_options_init ((GimpToolOptions *) options, tool_info);
@ -119,7 +120,9 @@ paint_options_init (GimpPaintOptions *options,
/* the main table */
table = gtk_table_new (2, 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);
/* the opacity scale */
options->opacity_w =
@ -139,33 +142,28 @@ paint_options_init (GimpPaintOptions *options,
options->opacity_w);
/* the paint mode menu */
if (tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL ||
tool_info->tool_type == GIMP_TYPE_BLEND_TOOL ||
tool_info->tool_type == GIMP_TYPE_PENCIL_TOOL ||
tool_info->tool_type == GIMP_TYPE_PAINTBRUSH_TOOL ||
tool_info->tool_type == GIMP_TYPE_AIRBRUSH_TOOL ||
tool_info->tool_type == GIMP_TYPE_CLONE_TOOL ||
tool_info->tool_type == GIMP_TYPE_INK_TOOL)
options->paint_mode_w =
gimp_paint_mode_menu_new (G_CALLBACK (paint_options_paint_mode_update),
options,
TRUE,
gimp_context_get_paint_mode (tool_info->context));
mode_label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Mode:"), 1.0, 0.5,
options->paint_mode_w, 2, TRUE);
g_signal_connect (G_OBJECT (tool_info->context), "paint_mode_changed",
G_CALLBACK (paint_options_paint_mode_changed),
options->paint_mode_w);
if (tool_info->tool_type == GIMP_TYPE_ERASER_TOOL ||
tool_info->tool_type == GIMP_TYPE_CONVOLVE_TOOL ||
tool_info->tool_type == GIMP_TYPE_DODGEBURN_TOOL ||
tool_info->tool_type == GIMP_TYPE_SMUDGE_TOOL)
{
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
options->paint_mode_w =
gimp_paint_mode_menu_new (G_CALLBACK (paint_options_paint_mode_update),
options,
TRUE,
gimp_context_get_paint_mode (tool_info->context));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Mode:"), 1.0, 0.5,
options->paint_mode_w, 2, TRUE);
g_signal_connect (G_OBJECT (tool_info->context), "paint_mode_changed",
G_CALLBACK (paint_options_paint_mode_changed),
options->paint_mode_w);
gtk_widget_set_sensitive (options->paint_mode_w, FALSE);
gtk_widget_set_sensitive (mode_label, FALSE);
}
/* show the main table */
gtk_widget_show (table);
/* a separator after the common paint options which can be global */
if (tool_info->tool_type == GIMP_TYPE_BLEND_TOOL)
{
@ -299,8 +297,7 @@ pressure_options_init (GimpPressureOptions *pressure,
GimpPaintOptions *paint_options,
GType tool_type)
{
GtkWidget *frame = NULL;
GtkWidget *wbox = NULL;
GtkWidget *wbox = NULL;
if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL ||
tool_type == GIMP_TYPE_CLONE_TOOL ||
@ -311,10 +308,11 @@ pressure_options_init (GimpPressureOptions *pressure,
tool_type == GIMP_TYPE_PENCIL_TOOL ||
tool_type == GIMP_TYPE_SMUDGE_TOOL)
{
frame = gtk_frame_new (_("Pressure Sensitivity"));
pressure->frame = gtk_frame_new (_("Pressure Sensitivity"));
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), 6);
gtk_container_add (GTK_CONTAINER (frame), wbox);
gtk_container_add (GTK_CONTAINER (pressure->frame), wbox);
gtk_widget_show (wbox);
}
@ -410,8 +408,6 @@ pressure_options_init (GimpPressureOptions *pressure,
G_CALLBACK (gimp_toggle_button_update),
&pressure->color);
}
pressure->frame = frame;
}
static void
@ -457,7 +453,9 @@ gradient_options_init (GimpGradientOptions *gradient,
if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
{
gradient->frame = gtk_frame_new (_("Gradient Options"));
table = gtk_table_new (3, 3, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (gradient->frame), table);
@ -472,37 +470,42 @@ gradient_options_init (GimpGradientOptions *gradient,
gradient->use_fade_w =
gtk_check_button_new_with_label (_("Fade Out"));
gtk_container_add (GTK_CONTAINER (abox), gradient->use_fade_w);
gtk_widget_show (gradient->use_fade_w);
g_signal_connect (G_OBJECT (gradient->use_fade_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&gradient->use_fade);
gtk_widget_show (gradient->use_fade_w);
/* the fade-out sizeentry */
gradient->fade_out_w =
gtk_adjustment_new (gradient->fade_out_d,
1e-5, 32767.0, 1.0, 50.0, 0.0);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (gradient->fade_out_w),
1.0, 0.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_size_request (spinbutton, 50, -1);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1);
gtk_widget_show (spinbutton);
g_signal_connect (G_OBJECT (gradient->fade_out_w), "value_changed",
G_CALLBACK (gimp_double_adjustment_update),
&gradient->fade_out);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1);
gtk_widget_show (spinbutton);
/* the fade-out unitmenu */
gradient->fade_unit_w =
gimp_unit_menu_new ("%a", gradient->fade_unit_d, TRUE, TRUE, TRUE);
g_signal_connect (G_OBJECT (gradient->fade_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->fade_unit);
g_object_set_data (G_OBJECT (gradient->fade_unit_w), "set_digits",
spinbutton);
gtk_table_attach (GTK_TABLE (table), gradient->fade_unit_w, 2, 3, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (gradient->fade_unit_w);
g_object_set_data (G_OBJECT (gradient->fade_unit_w), "set_digits",
spinbutton);
g_signal_connect (G_OBJECT (gradient->fade_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->fade_unit);
/* automatically set the sensitive state of the fadeout stuff */
gtk_widget_set_sensitive (spinbutton, gradient->use_fade_d);
gtk_widget_set_sensitive (gradient->fade_unit_w, gradient->use_fade_d);
@ -520,10 +523,11 @@ gradient_options_init (GimpGradientOptions *gradient,
gradient->use_gradient_w =
gtk_check_button_new_with_label (_("Gradient"));
gtk_container_add (GTK_CONTAINER (abox), gradient->use_gradient_w);
gtk_widget_show (gradient->use_gradient_w);
g_signal_connect (G_OBJECT (gradient->use_gradient_w), "toggled",
G_CALLBACK (paint_options_gradient_toggle_callback),
paint_options);
gtk_widget_show (gradient->use_gradient_w);
/* the gradient length scale */
gradient->gradient_length_w =
@ -534,24 +538,27 @@ gradient_options_init (GimpGradientOptions *gradient,
1.0, 0.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_size_request (spinbutton, 50, -1);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2);
gtk_widget_show (spinbutton);
g_signal_connect (G_OBJECT (gradient->gradient_length_w), "value_changed",
G_CALLBACK (gimp_double_adjustment_update),
&gradient->gradient_length);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2);
gtk_widget_show (spinbutton);
/* the gradient unitmenu */
gradient->gradient_unit_w =
gimp_unit_menu_new ("%a", gradient->gradient_unit_d, TRUE, TRUE, TRUE);
g_signal_connect (G_OBJECT (gradient->gradient_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->gradient_unit);
g_object_set_data (G_OBJECT (gradient->gradient_unit_w), "set_digits",
spinbutton);
gtk_table_attach (GTK_TABLE (table), gradient->gradient_unit_w, 2, 3, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (gradient->gradient_unit_w);
g_object_set_data (G_OBJECT (gradient->gradient_unit_w), "set_digits",
spinbutton);
g_signal_connect (G_OBJECT (gradient->gradient_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->gradient_unit);
/* the gradient type */
gradient->gradient_type_w =
gimp_option_menu_new2 (FALSE,
@ -561,10 +568,13 @@ gradient_options_init (GimpGradientOptions *gradient,
_("Once Forward"),
GINT_TO_POINTER (ONCE_FORWARD), NULL,
_("Once Backward"),
GINT_TO_POINTER (ONCE_BACKWARDS), NULL,
_("Loop Sawtooth"),
GINT_TO_POINTER (LOOP_SAWTOOTH), NULL,
_("Loop Triangle"),
GINT_TO_POINTER (LOOP_TRIANGLE), NULL,
@ -655,8 +665,10 @@ paint_options_opacity_adjustment_update (GtkAdjustment *adjustment,
g_signal_handlers_block_by_func (G_OBJECT (data),
paint_options_opacity_changed,
adjustment);
gimp_context_set_opacity (GIMP_CONTEXT (data),
adjustment->value / 100);
g_signal_handlers_unblock_by_func (G_OBJECT (data),
paint_options_opacity_changed,
adjustment);
@ -670,7 +682,9 @@ paint_options_opacity_changed (GimpContext *context,
g_signal_handlers_block_by_func (G_OBJECT (data),
paint_options_opacity_adjustment_update,
context);
gtk_adjustment_set_value (GTK_ADJUSTMENT (data), opacity * 100);
g_signal_handlers_unblock_by_func (G_OBJECT (data),
paint_options_opacity_adjustment_update,
context);
@ -683,8 +697,8 @@ paint_options_paint_mode_update (GtkWidget *widget,
GimpLayerModeEffects paint_mode;
GimpPaintOptions *options;
paint_mode = (GimpLayerModeEffects) g_object_get_data (G_OBJECT (widget),
"gimp-item-data");
paint_mode = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
options = (GimpPaintOptions *) data;
@ -704,7 +718,8 @@ paint_options_paint_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
gpointer data)
{
gimp_option_menu_set_history (GTK_OPTION_MENU (data), (gpointer) paint_mode);
gimp_option_menu_set_history (GTK_OPTION_MENU (data),
GINT_TO_POINTER (paint_mode));
}
static void

View File

@ -102,6 +102,7 @@ paint_options_init (GimpPaintOptions *options,
{
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *mode_label;
/* initialize the tool options structure */
tool_options_init ((GimpToolOptions *) options, tool_info);
@ -119,7 +120,9 @@ paint_options_init (GimpPaintOptions *options,
/* the main table */
table = gtk_table_new (2, 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);
/* the opacity scale */
options->opacity_w =
@ -139,33 +142,28 @@ paint_options_init (GimpPaintOptions *options,
options->opacity_w);
/* the paint mode menu */
if (tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL ||
tool_info->tool_type == GIMP_TYPE_BLEND_TOOL ||
tool_info->tool_type == GIMP_TYPE_PENCIL_TOOL ||
tool_info->tool_type == GIMP_TYPE_PAINTBRUSH_TOOL ||
tool_info->tool_type == GIMP_TYPE_AIRBRUSH_TOOL ||
tool_info->tool_type == GIMP_TYPE_CLONE_TOOL ||
tool_info->tool_type == GIMP_TYPE_INK_TOOL)
options->paint_mode_w =
gimp_paint_mode_menu_new (G_CALLBACK (paint_options_paint_mode_update),
options,
TRUE,
gimp_context_get_paint_mode (tool_info->context));
mode_label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Mode:"), 1.0, 0.5,
options->paint_mode_w, 2, TRUE);
g_signal_connect (G_OBJECT (tool_info->context), "paint_mode_changed",
G_CALLBACK (paint_options_paint_mode_changed),
options->paint_mode_w);
if (tool_info->tool_type == GIMP_TYPE_ERASER_TOOL ||
tool_info->tool_type == GIMP_TYPE_CONVOLVE_TOOL ||
tool_info->tool_type == GIMP_TYPE_DODGEBURN_TOOL ||
tool_info->tool_type == GIMP_TYPE_SMUDGE_TOOL)
{
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
options->paint_mode_w =
gimp_paint_mode_menu_new (G_CALLBACK (paint_options_paint_mode_update),
options,
TRUE,
gimp_context_get_paint_mode (tool_info->context));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Mode:"), 1.0, 0.5,
options->paint_mode_w, 2, TRUE);
g_signal_connect (G_OBJECT (tool_info->context), "paint_mode_changed",
G_CALLBACK (paint_options_paint_mode_changed),
options->paint_mode_w);
gtk_widget_set_sensitive (options->paint_mode_w, FALSE);
gtk_widget_set_sensitive (mode_label, FALSE);
}
/* show the main table */
gtk_widget_show (table);
/* a separator after the common paint options which can be global */
if (tool_info->tool_type == GIMP_TYPE_BLEND_TOOL)
{
@ -299,8 +297,7 @@ pressure_options_init (GimpPressureOptions *pressure,
GimpPaintOptions *paint_options,
GType tool_type)
{
GtkWidget *frame = NULL;
GtkWidget *wbox = NULL;
GtkWidget *wbox = NULL;
if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL ||
tool_type == GIMP_TYPE_CLONE_TOOL ||
@ -311,10 +308,11 @@ pressure_options_init (GimpPressureOptions *pressure,
tool_type == GIMP_TYPE_PENCIL_TOOL ||
tool_type == GIMP_TYPE_SMUDGE_TOOL)
{
frame = gtk_frame_new (_("Pressure Sensitivity"));
pressure->frame = gtk_frame_new (_("Pressure Sensitivity"));
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), 6);
gtk_container_add (GTK_CONTAINER (frame), wbox);
gtk_container_add (GTK_CONTAINER (pressure->frame), wbox);
gtk_widget_show (wbox);
}
@ -410,8 +408,6 @@ pressure_options_init (GimpPressureOptions *pressure,
G_CALLBACK (gimp_toggle_button_update),
&pressure->color);
}
pressure->frame = frame;
}
static void
@ -457,7 +453,9 @@ gradient_options_init (GimpGradientOptions *gradient,
if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
{
gradient->frame = gtk_frame_new (_("Gradient Options"));
table = gtk_table_new (3, 3, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (gradient->frame), table);
@ -472,37 +470,42 @@ gradient_options_init (GimpGradientOptions *gradient,
gradient->use_fade_w =
gtk_check_button_new_with_label (_("Fade Out"));
gtk_container_add (GTK_CONTAINER (abox), gradient->use_fade_w);
gtk_widget_show (gradient->use_fade_w);
g_signal_connect (G_OBJECT (gradient->use_fade_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&gradient->use_fade);
gtk_widget_show (gradient->use_fade_w);
/* the fade-out sizeentry */
gradient->fade_out_w =
gtk_adjustment_new (gradient->fade_out_d,
1e-5, 32767.0, 1.0, 50.0, 0.0);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (gradient->fade_out_w),
1.0, 0.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_size_request (spinbutton, 50, -1);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1);
gtk_widget_show (spinbutton);
g_signal_connect (G_OBJECT (gradient->fade_out_w), "value_changed",
G_CALLBACK (gimp_double_adjustment_update),
&gradient->fade_out);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1);
gtk_widget_show (spinbutton);
/* the fade-out unitmenu */
gradient->fade_unit_w =
gimp_unit_menu_new ("%a", gradient->fade_unit_d, TRUE, TRUE, TRUE);
g_signal_connect (G_OBJECT (gradient->fade_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->fade_unit);
g_object_set_data (G_OBJECT (gradient->fade_unit_w), "set_digits",
spinbutton);
gtk_table_attach (GTK_TABLE (table), gradient->fade_unit_w, 2, 3, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (gradient->fade_unit_w);
g_object_set_data (G_OBJECT (gradient->fade_unit_w), "set_digits",
spinbutton);
g_signal_connect (G_OBJECT (gradient->fade_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->fade_unit);
/* automatically set the sensitive state of the fadeout stuff */
gtk_widget_set_sensitive (spinbutton, gradient->use_fade_d);
gtk_widget_set_sensitive (gradient->fade_unit_w, gradient->use_fade_d);
@ -520,10 +523,11 @@ gradient_options_init (GimpGradientOptions *gradient,
gradient->use_gradient_w =
gtk_check_button_new_with_label (_("Gradient"));
gtk_container_add (GTK_CONTAINER (abox), gradient->use_gradient_w);
gtk_widget_show (gradient->use_gradient_w);
g_signal_connect (G_OBJECT (gradient->use_gradient_w), "toggled",
G_CALLBACK (paint_options_gradient_toggle_callback),
paint_options);
gtk_widget_show (gradient->use_gradient_w);
/* the gradient length scale */
gradient->gradient_length_w =
@ -534,24 +538,27 @@ gradient_options_init (GimpGradientOptions *gradient,
1.0, 0.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_size_request (spinbutton, 50, -1);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2);
gtk_widget_show (spinbutton);
g_signal_connect (G_OBJECT (gradient->gradient_length_w), "value_changed",
G_CALLBACK (gimp_double_adjustment_update),
&gradient->gradient_length);
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2);
gtk_widget_show (spinbutton);
/* the gradient unitmenu */
gradient->gradient_unit_w =
gimp_unit_menu_new ("%a", gradient->gradient_unit_d, TRUE, TRUE, TRUE);
g_signal_connect (G_OBJECT (gradient->gradient_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->gradient_unit);
g_object_set_data (G_OBJECT (gradient->gradient_unit_w), "set_digits",
spinbutton);
gtk_table_attach (GTK_TABLE (table), gradient->gradient_unit_w, 2, 3, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (gradient->gradient_unit_w);
g_object_set_data (G_OBJECT (gradient->gradient_unit_w), "set_digits",
spinbutton);
g_signal_connect (G_OBJECT (gradient->gradient_unit_w), "unit_changed",
G_CALLBACK (gimp_unit_menu_update),
&gradient->gradient_unit);
/* the gradient type */
gradient->gradient_type_w =
gimp_option_menu_new2 (FALSE,
@ -561,10 +568,13 @@ gradient_options_init (GimpGradientOptions *gradient,
_("Once Forward"),
GINT_TO_POINTER (ONCE_FORWARD), NULL,
_("Once Backward"),
GINT_TO_POINTER (ONCE_BACKWARDS), NULL,
_("Loop Sawtooth"),
GINT_TO_POINTER (LOOP_SAWTOOTH), NULL,
_("Loop Triangle"),
GINT_TO_POINTER (LOOP_TRIANGLE), NULL,
@ -655,8 +665,10 @@ paint_options_opacity_adjustment_update (GtkAdjustment *adjustment,
g_signal_handlers_block_by_func (G_OBJECT (data),
paint_options_opacity_changed,
adjustment);
gimp_context_set_opacity (GIMP_CONTEXT (data),
adjustment->value / 100);
g_signal_handlers_unblock_by_func (G_OBJECT (data),
paint_options_opacity_changed,
adjustment);
@ -670,7 +682,9 @@ paint_options_opacity_changed (GimpContext *context,
g_signal_handlers_block_by_func (G_OBJECT (data),
paint_options_opacity_adjustment_update,
context);
gtk_adjustment_set_value (GTK_ADJUSTMENT (data), opacity * 100);
g_signal_handlers_unblock_by_func (G_OBJECT (data),
paint_options_opacity_adjustment_update,
context);
@ -683,8 +697,8 @@ paint_options_paint_mode_update (GtkWidget *widget,
GimpLayerModeEffects paint_mode;
GimpPaintOptions *options;
paint_mode = (GimpLayerModeEffects) g_object_get_data (G_OBJECT (widget),
"gimp-item-data");
paint_mode = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
options = (GimpPaintOptions *) data;
@ -704,7 +718,8 @@ paint_options_paint_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
gpointer data)
{
gimp_option_menu_set_history (GTK_OPTION_MENU (data), (gpointer) paint_mode);
gimp_option_menu_set_history (GTK_OPTION_MENU (data),
GINT_TO_POINTER (paint_mode));
}
static void

View File

@ -156,8 +156,6 @@ static void
gimp_data_editor_real_set_data (GimpDataEditor *editor,
GimpData *data)
{
const gchar *name = NULL;
if (editor->data)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (editor->data),
@ -177,10 +175,16 @@ gimp_data_editor_real_set_data (GimpDataEditor *editor,
G_CALLBACK (gimp_data_editor_data_name_changed),
editor);
name = gimp_object_get_name (GIMP_OBJECT (editor->data));
gtk_entry_set_text (GTK_ENTRY (editor->name_entry),
gimp_object_get_name (GIMP_OBJECT (editor->data)));
gtk_widget_set_sensitive (editor->name_entry, TRUE);
}
else
{
gtk_entry_set_text (GTK_ENTRY (editor->name_entry), "");
gtk_widget_set_sensitive (editor->name_entry, FALSE);
}
gtk_entry_set_text (GTK_ENTRY (editor->name_entry), name);
}
gboolean
@ -211,8 +215,8 @@ gimp_data_editor_set_data (GimpDataEditor *editor,
{
g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));
g_return_if_fail (! data || GIMP_IS_DATA (data));
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (data),
editor->data_type));
g_return_if_fail (! data || g_type_is_a (G_TYPE_FROM_INSTANCE (data),
editor->data_type));
if (editor->data != data)
{

View File

@ -632,8 +632,9 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
dialog_factory = g_object_get_data (G_OBJECT (dialog),
"gimp-dialog-factory");
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
if (! dialog_factory)
if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
{
g_warning ("%s(): dialog was not created by a GimpDialogFactory",
G_GNUC_FUNCTION);
@ -647,15 +648,13 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
return;
}
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
if (entry) /* dialog is a toplevel (but not a GimpDock) or a GimpDockable */
{
gboolean toplevel;
toplevel = GTK_WIDGET_TOPLEVEL (dialog);
g_print ("%s: registering %s \"%s\"\n",
g_print ("%s: adding %s \"%s\"\n",
G_GNUC_FUNCTION,
toplevel ? "toplevel" : "dockable",
entry->identifier);
@ -664,24 +663,33 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
{
info = (GimpSessionInfo *) list->data;
if (((info->toplevel_entry == entry) && toplevel) ||
if ((info->toplevel_entry == entry) ||
(info->dockable_entry == entry))
{
if (entry->singleton)
if (info->widget)
{
if (info->widget)
if (entry->singleton)
{
g_warning ("%s(): singleton dialog \"%s\"created twice",
g_warning ("%s(): singleton dialog \"%s\" created twice",
G_GNUC_FUNCTION, entry->identifier);
g_print ("%s: corrupt session info: %p (widget %p)\n",
G_GNUC_FUNCTION,
info, info->widget);
return;
}
}
else if (info->widget)
{
continue;
}
info->widget = dialog;
info->widget = dialog;
g_print ("%s: updating session info %p (widget %p) for %s \"%s\"\n",
G_GNUC_FUNCTION,
info, info->widget,
toplevel ? "toplevel" : "dockable",
entry->identifier);
if (entry->session_managed)
{
@ -698,6 +706,12 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
info->widget = dialog;
g_print ("%s: creating session info %p (widget %p) for %s \"%s\"\n",
G_GNUC_FUNCTION,
info, info->widget,
toplevel ? "toplevel" : "dockable",
entry->identifier);
if (toplevel)
info->toplevel_entry = entry;
else
@ -706,18 +720,25 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
factory->session_infos = g_list_append (factory->session_infos, info);
}
}
else if (GIMP_IS_DOCK (dialog)) /* dialog is a GimpDock */
else /* dialog is a GimpDock */
{
g_print ("%s: registering dock\n", G_GNUC_FUNCTION);
g_print ("%s: adding dock\n", G_GNUC_FUNCTION);
for (list = factory->session_infos; list; list = g_list_next (list))
{
info = (GimpSessionInfo *) list->data;
if (! info->widget) /* take the first empty slot */
/* take the first empty slot */
if (! info->toplevel_entry &&
! info->dockable_entry &&
! info->widget)
{
info->widget = dialog;
g_print ("%s: updating session info %p (widget %p) for dock\n",
G_GNUC_FUNCTION,
info, info->widget);
gimp_dialog_factory_set_window_geometry (info->widget, info);
break;
@ -730,17 +751,13 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
info->widget = dialog;
g_print ("%s: creating session info %p (widget %p) for dock\n",
G_GNUC_FUNCTION,
info, info->widget);
factory->session_infos = g_list_append (factory->session_infos, info);
}
}
else
{
g_warning ("%s(): cannot add dialog which neither has a "
"GimpDialogFactoryEntry attached nor is a GimpDock",
G_GNUC_FUNCTION);
return;
}
factory->open_dialogs = g_list_prepend (factory->open_dialogs, dialog);
@ -753,9 +770,10 @@ void
gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
GtkWidget *dialog)
{
GimpDialogFactory *dialog_factory;
GimpSessionInfo *session_info;
GList *list;
GimpDialogFactory *dialog_factory;
GimpDialogFactoryEntry *entry;
GimpSessionInfo *session_info;
GList *list;
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
g_return_if_fail (GTK_IS_WIDGET (dialog));
@ -768,10 +786,11 @@ gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
factory->open_dialogs = g_list_remove (factory->open_dialogs, dialog);
dialog_factory = g_object_get_data (G_OBJECT (dialog),
dialog_factory = g_object_get_data (G_OBJECT (dialog),
"gimp-dialog-factory");
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
if (! dialog_factory)
if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
{
g_warning ("%s(): dialog was not created by a GimpDialogFactory",
G_GNUC_FUNCTION);
@ -785,12 +804,21 @@ gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
return;
}
g_print ("%s: removing \"%s\"\n",
G_GNUC_FUNCTION,
entry ? entry->identifier : "dock");
for (list = factory->session_infos; list; list = g_list_next (list))
{
session_info = (GimpSessionInfo *) list->data;
if (session_info->widget == dialog)
{
g_print ("%s: clearing session info %p (widget %p) for \"%s\"\n",
G_GNUC_FUNCTION,
session_info, session_info->widget,
entry ? entry->identifier : "dock");
session_info->widget = NULL;
/* don't save session info for empty docks */

View File

@ -35,10 +35,7 @@
#include "gimpdockbook.h"
#include "gimpimagedock.h"
#include "gimpitemfactory.h"
/* EEK, see below */
#include "gimpcontainerview.h"
#include "gimpcontainerview-utils.h"
#include "gimppreview.h"
#define TAB_WIDGET_SIZE 24
@ -232,7 +229,7 @@ gimp_dockbook_add (GimpDockbook *dockbook,
g_return_if_fail (GTK_IS_WIDGET (tab_widget));
if (GTK_IS_LABEL (tab_widget))
if (GTK_WIDGET_NO_WINDOW (tab_widget))
{
GtkWidget *event_box;
@ -278,7 +275,7 @@ gimp_dockbook_add (GimpDockbook *dockbook,
g_return_if_fail (GTK_IS_WIDGET (menu_widget));
if (! GTK_IS_LABEL (menu_widget))
if (GIMP_IS_PREVIEW (menu_widget))
{
GtkWidget *hbox;
GtkWidget *label;
@ -294,7 +291,7 @@ gimp_dockbook_add (GimpDockbook *dockbook,
menu_widget = hbox;
}
else
else if (GTK_IS_LABEL (menu_widget))
{
gtk_widget_destroy (menu_widget);

View File

@ -417,8 +417,9 @@ toolbox_tool_button_press (GtkWidget *widget,
{
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
gimp_dialog_factory_dialog_new (global_dialog_factory,
"gimp:tool-options-dialog", -1);
gimp_dialog_factory_dialog_raise (global_dock_factory,
"gimp:tool-options",
-1);
}
return FALSE;

View File

@ -30,12 +30,11 @@
#include "core/gimptoolinfo.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimpeditor.h"
#include "widgets/gimppreview.h"
#include "widgets/gimpwidgets-utils.h"
#include "tools/gimptool.h"
#include "tools/tool_options.h"
#include "tools/tool_manager.h"
#include "tool-options-dialog.h"
@ -44,28 +43,34 @@
/* local function prototypes */
static void tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static GimpViewable * tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_close_callback (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_destroy (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static GimpViewable * tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_save_callback (GtkWidget *widget,
GimpContext *context);
static void tool_options_dialog_restore_callback (GtkWidget *widget,
GimpContext *context);
static void tool_options_dialog_reset_callback (GtkWidget *widget,
GimpContext *context);
/* private variables */
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_label = NULL;
static GtkWidget *options_preview = NULL;
static GtkWidget *options_eventbox = NULL;
static GtkWidget *options_reset_button = NULL;
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_save_button = NULL;
static GtkWidget *options_revert_button = NULL;
static GtkWidget *options_reset_button = NULL;
static GimpToolOptions *visible_tool_options = NULL;
@ -75,17 +80,19 @@ static GimpToolOptions *visible_tool_options = NULL;
GtkWidget *
tool_options_dialog_create (Gimp *gimp)
{
GimpContext *user_context;
GimpToolInfo *tool_info;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *editor;
GtkWidget *scrolled_win;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (options_shell)
return options_shell;
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
user_context = gimp_get_user_context (gimp);
tool_info = gimp_context_get_tool (user_context);
if (! tool_info)
{
@ -93,61 +100,55 @@ tool_options_dialog_create (Gimp *gimp)
G_GNUC_FUNCTION);
}
/* The shell and main vbox */
options_shell =
gimp_dialog_new (_("Tool Options"), "tool_options",
tool_manager_help_func,
"dialogs/tool_options.html",
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
editor = g_object_new (GIMP_TYPE_EDITOR, NULL);
GIMP_STOCK_RESET, tool_options_dialog_reset_callback,
gimp, NULL, &options_reset_button, FALSE, FALSE,
gtk_widget_set_size_request (editor, -1, 200);
GTK_STOCK_CLOSE, tool_options_dialog_close_callback,
NULL, NULL, NULL, TRUE, TRUE,
options_shell = editor;
NULL);
g_signal_connect (G_OBJECT (options_shell), "destroy",
G_CALLBACK (tool_options_dialog_destroy),
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (options_shell), FALSE);
options_save_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_SAVE,
_("Save current settings to disk"),
NULL,
G_CALLBACK (tool_options_dialog_save_callback),
NULL,
user_context);
/* The outer frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options_shell)->vbox), frame);
gtk_widget_show (frame);
options_revert_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_REVERT_TO_SAVED,
_("Restore saved settings"),
NULL,
G_CALLBACK (tool_options_dialog_restore_callback),
NULL,
user_context);
/* The vbox containing the title frame and the options vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
options_reset_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GIMP_STOCK_RESET,
_("Reset"),
NULL,
G_CALLBACK (tool_options_dialog_reset_callback),
NULL,
user_context);
/* The title frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
options_eventbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (frame), options_eventbox);
gtk_widget_show (options_eventbox);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (options_eventbox), hbox);
gtk_widget_show (hbox);
options_preview = gimp_preview_new (GIMP_VIEWABLE (tool_info), 22, 0, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), options_preview, FALSE, FALSE, 0);
gtk_widget_show (options_preview);
options_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), options_label, FALSE, FALSE, 1);
gtk_widget_show (options_label);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (editor), scrolled_win);
gtk_widget_show (scrolled_win);
/* The vbox containing the tool options */
options_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (options_vbox), 2);
gtk_box_pack_start (GTK_BOX (vbox), options_vbox, FALSE, FALSE, 0);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
options_vbox);
gtk_widget_show (options_vbox);
/* dnd stuff */
@ -160,47 +161,44 @@ tool_options_dialog_create (Gimp *gimp)
gimp_dnd_viewable_dest_set (options_shell,
GIMP_TYPE_TOOL_INFO,
tool_options_dialog_drop_tool,
gimp);
user_context);
gimp_gtk_drag_source_set_by_type (options_eventbox,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
GIMP_TYPE_TOOL_INFO,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (options_eventbox,
GIMP_TYPE_TOOL_INFO,
tool_options_dialog_drag_tool,
gimp);
g_signal_connect_object (G_OBJECT (gimp_get_user_context (gimp)),
"tool_changed",
g_signal_connect_object (G_OBJECT (user_context), "tool_changed",
G_CALLBACK (tool_options_dialog_tool_changed),
G_OBJECT (options_shell),
0);
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
tool_options_dialog_tool_changed (gimp_get_user_context (gimp),
tool_options_dialog_tool_changed (user_context,
tool_info,
options_shell);
return options_shell;
}
void
tool_options_dialog_free (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (options_shell)
{
gtk_widget_destroy (options_shell);
options_shell = NULL;
}
return editor;
}
/* private functions */
static void
tool_options_dialog_destroy (GtkWidget *widget,
gpointer data)
{
GList *options;
GList *list;
options = gtk_container_get_children (GTK_CONTAINER (options_vbox));
for (list = options; list; list = g_list_next (list))
{
g_object_ref (G_OBJECT (list->data));
gtk_container_remove (GTK_CONTAINER (options_vbox),
GTK_WIDGET (list->data));
}
g_list_free (options);
options_shell = NULL;
}
static void
tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
@ -227,9 +225,6 @@ tool_options_dialog_tool_changed (GimpContext *context,
visible_tool_options = tool_info->tool_options;
gtk_label_set_text (GTK_LABEL (options_label),
tool_info->blurb);
if (tool_info->tool_options->reset_func)
gtk_widget_set_sensitive (options_reset_button, TRUE);
else
@ -239,14 +234,6 @@ tool_options_dialog_tool_changed (GimpContext *context,
{
gtk_widget_set_sensitive (options_reset_button, FALSE);
}
gimp_preview_set_viewable (GIMP_PREVIEW (options_preview),
GIMP_VIEWABLE (tool_info));
gimp_help_set_help_data (options_label->parent->parent,
tool_info->help,
tool_info->help_data);
}
}
@ -255,59 +242,48 @@ tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
Gimp *gimp;
GimpContext *context;
gimp = GIMP (data);
context = GIMP_CONTEXT (data);
gimp_context_set_tool (gimp_get_user_context (gimp),
GIMP_TOOL_INFO (viewable));
gimp_context_set_tool (context, GIMP_TOOL_INFO (viewable));
}
GimpViewable *
tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data)
{
Gimp *gimp;
GimpContext *context;
gimp = GIMP (data);
context = GIMP_CONTEXT (data);
return (GimpViewable *) gimp_context_get_tool (gimp_get_user_context (gimp));
return (GimpViewable *) gimp_context_get_tool (context);
}
static void
tool_options_dialog_close_callback (GtkWidget *widget,
gpointer data)
tool_options_dialog_save_callback (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *shell;
shell = (GtkWidget *) data;
gtk_widget_hide (shell);
g_print ("Save clicked\n");
}
static void
tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data)
tool_options_dialog_restore_callback (GtkWidget *widget,
GimpContext *context)
{
g_print ("Restore clicked\n");
}
static void
tool_options_dialog_reset_callback (GtkWidget *widget,
GimpContext *context)
{
GimpToolInfo *tool_info;
GimpTool *active_tool;
Gimp *gimp;
gimp = GIMP (data);
active_tool = tool_manager_get_active (gimp);
if (! active_tool)
return;
tool_info = active_tool->tool_info;
tool_info = gimp_context_get_tool (context);
if (! tool_info)
{
g_warning ("%s(): no tool info registered for %s",
G_GNUC_FUNCTION,
g_type_name (G_TYPE_FROM_INSTANCE (active_tool)));
}
return;
if (tool_info->tool_options->reset_func)
tool_info->tool_options->reset_func (tool_info->tool_options);