some minor fixes / cleanup.

2001-04-23  Michael Natterer  <mitch@gimp.org>

	* app/gimpcontext.[ch]: some minor fixes / cleanup.

	* app/gimpdata.c: forgot to gtk_object_class_add_signals() in
	class_init().

	* app/gui/dialogs-constructors.[ch]: added a tool_tab_func() so
	the notebook tab shows a tool preview, pass a GimpContext to all
	dialog constructors and added set_context() functions for all
	dockable based dialogs so they can be configured to use the
	context of the destination dock when dragging them around.

	* app/widgets/gimpcontainermenuimpl.c: removed debugging output.

	* app/widgets/gimpdialogfactory.[ch]: add a method to create
	dockables (which gets passed the dock the dockable will be added
	to) so the dockables can be created in the right context.

	* app/widgets/gimpdock.[ch]: added a GimpContext attribute, remove
	the dockbooks explicitely in destroy().

	* app/widgets/gimpdockable.[ch]: dockables now know about their
	set_context_func() and can thus be dragged between different
	contexts.

	* app/widgets/gimpdockbook.c: gimp_dockbook_add(): refuse to add
	dockables to dockbooks which are not part of a dock, set the
	dockable's context after adding it.

	* app/widgets/gimpimagedock.[ch]: image docks now keep a pointer
	to the global image list which is passed to them on construction
	so they don't need to know about the global "image_context"
	variable, added an "Auto" button like in L&C.

	* app/gui/dialogs-commands.c: changed accordingly.
This commit is contained in:
Michael Natterer 2001-04-23 16:58:18 +00:00 committed by Michael Natterer
parent 2c89973c96
commit 714f4b14ea
25 changed files with 1125 additions and 387 deletions

View File

@ -1,3 +1,40 @@
2001-04-23 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: some minor fixes / cleanup.
* app/gimpdata.c: forgot to gtk_object_class_add_signals() in
class_init().
* app/gui/dialogs-constructors.[ch]: added a tool_tab_func() so
the notebook tab shows a tool preview, pass a GimpContext to all
dialog constructors and added set_context() functions for all
dockable based dialogs so they can be configured to use the
context of the destination dock when dragging them around.
* app/widgets/gimpcontainermenuimpl.c: removed debugging output.
* app/widgets/gimpdialogfactory.[ch]: add a method to create
dockables (which gets passed the dock the dockable will be added
to) so the dockables can be created in the right context.
* app/widgets/gimpdock.[ch]: added a GimpContext attribute, remove
the dockbooks explicitely in destroy().
* app/widgets/gimpdockable.[ch]: dockables now know about their
set_context_func() and can thus be dragged between different
contexts.
* app/widgets/gimpdockbook.c: gimp_dockbook_add(): refuse to add
dockables to dockbooks which are not part of a dock, set the
dockable's context after adding it.
* app/widgets/gimpimagedock.[ch]: image docks now keep a pointer
to the global image list which is passed to them on construction
so they don't need to know about the global "image_context"
variable, added an "Auto" button like in L&C.
* app/gui/dialogs-commands.c: changed accordingly.
2001-04-23 Sven Neumann <sven@gimp.org>
Merged Yosh's changes from stable branch:

View File

@ -56,7 +56,8 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
{
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_new (dockbook->dock->factory,
dockable = gimp_dialog_factory_dockable_new (dockbook->dock->factory,
dockbook->dock,
GUINT_TO_POINTER (action));
if (dockable)

View File

@ -1,7 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontext.c: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
* gimpcontext.c
* Copyright (C) 1999-2001 Michael Natterer
*
* 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
@ -323,8 +324,8 @@ gimp_context_class_init (GimpContextClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
gimp_context_arg_types[GIMP_CONTEXT_ARG_TOOL] = GIMP_TYPE_TOOL_INFO;
gimp_context_arg_types[GIMP_CONTEXT_ARG_IMAGE] = GIMP_TYPE_IMAGE;
gimp_context_arg_types[GIMP_CONTEXT_ARG_TOOL] = GIMP_TYPE_TOOL_INFO;
gimp_context_arg_types[GIMP_CONTEXT_ARG_BRUSH] = GIMP_TYPE_BRUSH;
gimp_context_arg_types[GIMP_CONTEXT_ARG_PATTERN] = GIMP_TYPE_PATTERN;
gimp_context_arg_types[GIMP_CONTEXT_ARG_GRADIENT] = GIMP_TYPE_GRADIENT;
@ -337,7 +338,7 @@ gimp_context_class_init (GimpContextClass *klass)
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
ARG_DISPLAY);
gtk_object_add_arg_type (gimp_context_arg_names[TOOL_CHANGED],
GTK_TYPE_INT, GTK_ARG_READWRITE,
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
ARG_TOOL);
gtk_object_add_arg_type (gimp_context_arg_names[FOREGROUND_CHANGED],
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
@ -538,8 +539,16 @@ gimp_context_destroy (GtkObject *object)
if (context->parent)
gimp_context_unset_parent (context);
context_list = g_slist_remove (context_list, context);
context->image = NULL;
context->display = NULL;
if (context->tool_info)
{
gtk_object_unref (GTK_OBJECT (context->tool_info));
context->tool_info = NULL;
}
if (context->tool_name)
{
@ -548,7 +557,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->brush)
{
gtk_object_unref (GTK_OBJECT (context->brush));
context->brush = NULL;
}
if (context->brush_name)
{
@ -557,7 +569,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->pattern)
{
gtk_object_unref (GTK_OBJECT (context->pattern));
context->pattern = NULL;
}
if (context->pattern_name)
{
@ -566,7 +581,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->gradient)
{
gtk_object_unref (GTK_OBJECT (context->gradient));
context->gradient = NULL;
}
if (context->gradient_name)
{
@ -575,7 +593,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->palette)
{
gtk_object_unref (GTK_OBJECT (context->palette));
context->palette = NULL;
}
if (context->palette_name)
{
@ -585,8 +606,6 @@ gimp_context_destroy (GtkObject *object)
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
context_list = g_slist_remove (context_list, context);
}
static void
@ -898,7 +917,7 @@ gimp_context_set_parent (GimpContext *context,
context_return_if_fail (context);
g_return_if_fail (!parent || GIMP_IS_CONTEXT (parent));
if (context == parent)
if (context == parent || context->parent == parent)
return;
for (arg = 0; arg < GIMP_CONTEXT_NUM_ARGS; arg++)
@ -1010,7 +1029,7 @@ gimp_context_copy_arg (GimpContext *src,
context_return_if_fail (dest);
g_return_if_fail ((arg >= 0) && (arg < GIMP_CONTEXT_NUM_ARGS));
(* gimp_context_copy_arg_funcs[arg]) (src, dest);
gimp_context_copy_arg_funcs[arg] (src, dest);
}
void
@ -1058,7 +1077,7 @@ gimp_context_type_to_signal_name (GtkType type)
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
{
if (gimp_context_arg_types[i] == type)
if (gtk_type_is_a (type, gimp_context_arg_types[i]))
return gimp_context_signal_names[i];
}
@ -1394,8 +1413,6 @@ gimp_context_real_set_tool (GimpContext *context,
GTK_SIGNAL_FUNC (gimp_context_tool_dirty),
context);
/* FIXME if (tool_info != standard_tool_info) */
if (tool_info != standard_tool_info)
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
}

View File

@ -1,7 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontext.h: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
* gimpcontext.h
* Copyright (C) 1999-2001 Michael Natterer
*
* 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

View File

@ -133,6 +133,8 @@ gimp_data_class_init (GimpDataClass *klass)
gimp_marshal_POINTER__NONE,
GTK_TYPE_POINTER, 0);
gtk_object_class_add_signals (object_class, data_signals, LAST_SIGNAL);
object_class->destroy = gimp_data_destroy;
gimp_object_class->name_changed = gimp_data_name_changed;

View File

@ -94,11 +94,22 @@ static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_data_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_drawable_context_func (GimpDockable *dockable,
GimpContext *context);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func);
static void dialogs_drawable_view_image_changed (GimpContext *context,
GimpImage *gimage,
@ -108,89 +119,103 @@ static void dialogs_drawable_view_image_changed (GimpContext *context,
/* public functions */
GtkWidget *
dialogs_toolbox_get (GimpDialogFactory *factory)
dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context)
{
return toolbox_create ();
}
GtkWidget *
dialogs_lc_get (GimpDialogFactory *factory)
dialogs_lc_get (GimpDialogFactory *factory,
GimpContext *context)
{
GDisplay *gdisp;
gdisp = gimp_context_get_display (factory->context);
gdisp = gimp_context_get_display (context);
return lc_dialog_create (gdisp ? gdisp->gimage : NULL);
}
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory)
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context)
{
return tool_options_dialog_create ();
}
GtkWidget *
dialogs_device_status_get (GimpDialogFactory *factory)
dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context)
{
return device_status_create ();
}
GtkWidget *
dialogs_brush_select_get (GimpDialogFactory *factory)
dialogs_brush_select_get (GimpDialogFactory *factory,
GimpContext *context)
{
return brush_dialog_create ();
}
GtkWidget *
dialogs_pattern_select_get (GimpDialogFactory *factory)
dialogs_pattern_select_get (GimpDialogFactory *factory,
GimpContext *context)
{
return pattern_dialog_create ();
}
GtkWidget *
dialogs_gradient_select_get (GimpDialogFactory *factory)
dialogs_gradient_select_get (GimpDialogFactory *factory,
GimpContext *context)
{
return gradient_dialog_create ();
}
GtkWidget *
dialogs_palette_get (GimpDialogFactory *factory)
dialogs_palette_get (GimpDialogFactory *factory,
GimpContext *context)
{
return palette_dialog_create ();
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory)
dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context)
{
return error_console_create ();
}
GtkWidget *
dialogs_document_index_get (GimpDialogFactory *factory)
dialogs_document_index_get (GimpDialogFactory *factory,
GimpContext *context)
{
return document_index_create ();
}
GtkWidget *
dialogs_preferences_get (GimpDialogFactory *factory)
dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context)
{
return preferences_dialog_create ();
}
GtkWidget *
dialogs_input_devices_get (GimpDialogFactory *factory)
dialogs_input_devices_get (GimpDialogFactory *factory,
GimpContext *context)
{
return input_dialog_create ();
}
GtkWidget *
dialogs_module_browser_get (GimpDialogFactory *factory)
dialogs_module_browser_get (GimpDialogFactory *factory,
GimpContext *context)
{
return module_db_browser_new ();
}
GtkWidget *
dialogs_indexed_palette_get (GimpDialogFactory *factory)
dialogs_indexed_palette_get (GimpDialogFactory *factory,
GimpContext *context)
{
GimpColormapDialog *cmap_dlg;
@ -204,12 +229,13 @@ dialogs_indexed_palette_get (GimpDialogFactory *factory)
}
GtkWidget *
dialogs_undo_history_get (GimpDialogFactory *factory)
dialogs_undo_history_get (GimpDialogFactory *factory,
GimpContext *context)
{
GDisplay *gdisp;
GimpImage *gimage;
gdisp = gimp_context_get_display (factory->context);
gdisp = gimp_context_get_display (context);
if (! gdisp)
return NULL;
@ -223,12 +249,13 @@ dialogs_undo_history_get (GimpDialogFactory *factory)
}
GtkWidget *
dialogs_display_filters_get (GimpDialogFactory *factory)
dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context)
{
#ifdef DISPLAY_FILTERS
GDisplay *gdisp;
gdisp = gimp_context_get_display (factory->context);
gdisp = gimp_context_get_display (context);
if (! gdisp)
gdisp = color_area_gdisp;
@ -243,234 +270,262 @@ dialogs_display_filters_get (GimpDialogFactory *factory)
}
GtkWidget *
dialogs_tips_get (GimpDialogFactory *factory)
dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context)
{
return tips_dialog_create ();
}
GtkWidget *
dialogs_about_get (GimpDialogFactory *factory)
dialogs_about_get (GimpDialogFactory *factory,
GimpContext *context)
{
return about_dialog_create ();
}
GtkWidget *
dialogs_dock_new (GimpDialogFactory *factory)
dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context)
{
return gimp_image_dock_new (factory, image_context);
}
GtkWidget *
dialogs_image_list_view_new (GimpDialogFactory *factory)
dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_list_view_new (image_context,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Image List", "Images",
NULL);
NULL,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_brush_list_view_new (GimpDialogFactory *factory)
dialogs_brush_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_brush_factory,
dialogs_edit_brush_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Brush List", "Brushes",
dialogs_brush_tab_func);
dialogs_brush_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_pattern_list_view_new (GimpDialogFactory *factory)
dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_pattern_factory,
NULL,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Pattern List", "Patterns",
dialogs_pattern_tab_func);
dialogs_pattern_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_gradient_list_view_new (GimpDialogFactory *factory)
dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_gradient_factory,
dialogs_edit_gradient_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Gradient List", "Gradients",
dialogs_gradient_tab_func);
dialogs_gradient_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_palette_list_view_new (GimpDialogFactory *factory)
dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_palette_factory,
dialogs_edit_palette_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Palette List", "Palettes",
dialogs_palette_tab_func);
dialogs_palette_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_tool_list_view_new (GimpDialogFactory *factory)
dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_list_view_new (global_tool_info_list,
factory->context,
context,
22,
5, 3);
return dialogs_dockable_new (view,
"Tool List", "Tools",
NULL);
dialogs_tool_tab_func,
dialogs_set_view_context_func);
}
/* grid views */
GtkWidget *
dialogs_image_grid_view_new (GimpDialogFactory *factory)
dialogs_image_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_grid_view_new (image_context,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Image Grid", "Images",
NULL);
NULL,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_brush_grid_view_new (GimpDialogFactory *factory)
dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_brush_factory,
dialogs_edit_brush_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Brush Grid", "Brushes",
dialogs_brush_tab_func);
dialogs_brush_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_pattern_grid_view_new (GimpDialogFactory *factory)
dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_pattern_factory,
NULL,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Pattern Grid", "Patterns",
dialogs_pattern_tab_func);
dialogs_pattern_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_gradient_grid_view_new (GimpDialogFactory *factory)
dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_gradient_factory,
dialogs_edit_gradient_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Gradient Grid", "Gradients",
dialogs_gradient_tab_func);
dialogs_gradient_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_palette_grid_view_new (GimpDialogFactory *factory)
dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_palette_factory,
dialogs_edit_palette_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Palette Grid", "Palettes",
dialogs_palette_tab_func);
dialogs_palette_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_tool_grid_view_new (GimpDialogFactory *factory)
dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_grid_view_new (global_tool_info_list,
factory->context,
context,
22,
5, 3);
return dialogs_dockable_new (view,
"Tool Grid", "Tools",
NULL);
dialogs_tool_tab_func,
dialogs_set_view_context_func);
}
/* image related dialogs */
GtkWidget *
dialogs_layer_list_view_new (GimpDialogFactory *factory)
dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *view;
gimage = gimp_context_get_image (factory->context);
gimage = gimp_context_get_image (context);
view = gimp_drawable_list_view_new
(gimage,
@ -484,24 +539,20 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory)
(GimpRemoveDrawableFunc) gimp_image_remove_layer,
(GimpCopyDrawableFunc) gimp_layer_copy);
gtk_signal_connect_while_alive
(GTK_OBJECT (factory->context), "image_changed",
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view,
GTK_OBJECT (view));
return dialogs_dockable_new (view,
"Layer List", "Layers",
NULL);
NULL,
dialogs_set_drawable_context_func);
}
GtkWidget *
dialogs_channel_list_view_new (GimpDialogFactory *factory)
dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *view;
gimage = gimp_context_get_image (factory->context);
gimage = gimp_context_get_image (context);
view = gimp_drawable_list_view_new
(gimage,
@ -515,15 +566,10 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory)
(GimpRemoveDrawableFunc) gimp_image_remove_channel,
(GimpCopyDrawableFunc) gimp_channel_copy);
gtk_signal_connect_while_alive
(GTK_OBJECT (factory->context), "image_changed",
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view,
GTK_OBJECT (view));
return dialogs_dockable_new (view,
"Channel List", "Channels",
NULL);
NULL,
dialogs_set_drawable_context_func);
}
@ -610,7 +656,7 @@ dialogs_brush_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
@ -634,7 +680,7 @@ dialogs_pattern_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
@ -658,7 +704,7 @@ dialogs_gradient_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
@ -682,7 +728,7 @@ dialogs_palette_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
@ -698,21 +744,130 @@ dialogs_palette_tab_func (GimpDockable *dockable,
return preview;
}
static GtkWidget *
dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size)
{
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_tool (context)),
size, size, 1,
FALSE, FALSE, FALSE);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"tool_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
return preview;
}
static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpContainerView *view;
view = (GimpContainerView *) gtk_object_get_data (GTK_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
gimp_container_view_set_context (view, context);
}
static void
dialogs_set_data_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) gtk_object_get_data (GTK_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
/* TODO: gimp_data_factory_view_set_context (view, context); */
}
}
static void
dialogs_context_disconnect (GimpContext *context,
GtkWidget *view)
{
gtk_object_set_data (GTK_OBJECT (view), "gimp-dialogs-context", NULL);
}
static void
dialogs_set_drawable_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) gtk_object_get_data (GTK_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
GimpContext *old_context;
old_context = (GimpContext *) gtk_object_get_data (GTK_OBJECT (view),
"gimp-dialogs-context");
if (old_context)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (old_context),
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view);
gtk_signal_disconnect_by_func (GTK_OBJECT (old_context),
GTK_SIGNAL_FUNC (dialogs_context_disconnect),
view);
}
if (context)
{
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view);
gtk_signal_connect (GTK_OBJECT (context), "destroy",
GTK_SIGNAL_FUNC (dialogs_context_disconnect),
view);
gtk_object_set_data (GTK_OBJECT (view), "gimp-dialogs-context",
context);
}
dialogs_drawable_view_image_changed (context,
gimp_context_get_image (context),
view);
}
}
static GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func)
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func)
{
GtkWidget *dockable;
dockable = gimp_dockable_new (name,
short_name,
get_tab_func);
get_tab_func,
set_context_func);
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
gtk_object_set_data (GTK_OBJECT (dockable), "gimp-dialogs-view", widget);
return dockable;
}
@ -723,4 +878,3 @@ dialogs_drawable_view_image_changed (GimpContext *context,
{
gimp_drawable_list_view_set_image (view, gimage);
}

View File

@ -20,43 +20,76 @@
#define __DIALOGS_CONSTRUCTORS_H__
GtkWidget * dialogs_toolbox_get (GimpDialogFactory *factory);
GtkWidget * dialogs_lc_get (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_select_get (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_select_get (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_select_get (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_get (GimpDialogFactory *factory);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory);
GtkWidget * dialogs_document_index_get (GimpDialogFactory *factory);
GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory);
GtkWidget * dialogs_input_devices_get (GimpDialogFactory *factory);
GtkWidget * dialogs_module_browser_get (GimpDialogFactory *factory);
GtkWidget * dialogs_indexed_palette_get (GimpDialogFactory *factory);
GtkWidget * dialogs_undo_history_get (GimpDialogFactory *factory);
GtkWidget * dialogs_display_filters_get (GimpDialogFactory *factory);
GtkWidget * dialogs_tips_get (GimpDialogFactory *factory);
GtkWidget * dialogs_about_get (GimpDialogFactory *factory);
GtkWidget * dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_lc_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_brush_select_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_pattern_select_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_gradient_select_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_palette_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_document_index_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_input_devices_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_module_browser_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_indexed_palette_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_undo_history_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_dock_new (GimpDialogFactory *factory);
GtkWidget * dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_brush_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_image_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_image_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_layer_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_channel_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
void dialogs_edit_brush_func (GimpData *data);
void dialogs_edit_gradient_func (GimpData *data);

View File

@ -1,7 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontext.c: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
* gimpcontext.c
* Copyright (C) 1999-2001 Michael Natterer
*
* 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
@ -323,8 +324,8 @@ gimp_context_class_init (GimpContextClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
gimp_context_arg_types[GIMP_CONTEXT_ARG_TOOL] = GIMP_TYPE_TOOL_INFO;
gimp_context_arg_types[GIMP_CONTEXT_ARG_IMAGE] = GIMP_TYPE_IMAGE;
gimp_context_arg_types[GIMP_CONTEXT_ARG_TOOL] = GIMP_TYPE_TOOL_INFO;
gimp_context_arg_types[GIMP_CONTEXT_ARG_BRUSH] = GIMP_TYPE_BRUSH;
gimp_context_arg_types[GIMP_CONTEXT_ARG_PATTERN] = GIMP_TYPE_PATTERN;
gimp_context_arg_types[GIMP_CONTEXT_ARG_GRADIENT] = GIMP_TYPE_GRADIENT;
@ -337,7 +338,7 @@ gimp_context_class_init (GimpContextClass *klass)
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
ARG_DISPLAY);
gtk_object_add_arg_type (gimp_context_arg_names[TOOL_CHANGED],
GTK_TYPE_INT, GTK_ARG_READWRITE,
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
ARG_TOOL);
gtk_object_add_arg_type (gimp_context_arg_names[FOREGROUND_CHANGED],
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
@ -538,8 +539,16 @@ gimp_context_destroy (GtkObject *object)
if (context->parent)
gimp_context_unset_parent (context);
context_list = g_slist_remove (context_list, context);
context->image = NULL;
context->display = NULL;
if (context->tool_info)
{
gtk_object_unref (GTK_OBJECT (context->tool_info));
context->tool_info = NULL;
}
if (context->tool_name)
{
@ -548,7 +557,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->brush)
{
gtk_object_unref (GTK_OBJECT (context->brush));
context->brush = NULL;
}
if (context->brush_name)
{
@ -557,7 +569,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->pattern)
{
gtk_object_unref (GTK_OBJECT (context->pattern));
context->pattern = NULL;
}
if (context->pattern_name)
{
@ -566,7 +581,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->gradient)
{
gtk_object_unref (GTK_OBJECT (context->gradient));
context->gradient = NULL;
}
if (context->gradient_name)
{
@ -575,7 +593,10 @@ gimp_context_destroy (GtkObject *object)
}
if (context->palette)
{
gtk_object_unref (GTK_OBJECT (context->palette));
context->palette = NULL;
}
if (context->palette_name)
{
@ -585,8 +606,6 @@ gimp_context_destroy (GtkObject *object)
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
context_list = g_slist_remove (context_list, context);
}
static void
@ -898,7 +917,7 @@ gimp_context_set_parent (GimpContext *context,
context_return_if_fail (context);
g_return_if_fail (!parent || GIMP_IS_CONTEXT (parent));
if (context == parent)
if (context == parent || context->parent == parent)
return;
for (arg = 0; arg < GIMP_CONTEXT_NUM_ARGS; arg++)
@ -1010,7 +1029,7 @@ gimp_context_copy_arg (GimpContext *src,
context_return_if_fail (dest);
g_return_if_fail ((arg >= 0) && (arg < GIMP_CONTEXT_NUM_ARGS));
(* gimp_context_copy_arg_funcs[arg]) (src, dest);
gimp_context_copy_arg_funcs[arg] (src, dest);
}
void
@ -1058,7 +1077,7 @@ gimp_context_type_to_signal_name (GtkType type)
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
{
if (gimp_context_arg_types[i] == type)
if (gtk_type_is_a (type, gimp_context_arg_types[i]))
return gimp_context_signal_names[i];
}
@ -1394,8 +1413,6 @@ gimp_context_real_set_tool (GimpContext *context,
GTK_SIGNAL_FUNC (gimp_context_tool_dirty),
context);
/* FIXME if (tool_info != standard_tool_info) */
if (tool_info != standard_tool_info)
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
}

View File

@ -1,7 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontext.h: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
* gimpcontext.h
* Copyright (C) 1999-2001 Michael Natterer
*
* 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

View File

@ -133,6 +133,8 @@ gimp_data_class_init (GimpDataClass *klass)
gimp_marshal_POINTER__NONE,
GTK_TYPE_POINTER, 0);
gtk_object_class_add_signals (object_class, data_signals, LAST_SIGNAL);
object_class->destroy = gimp_data_destroy;
gimp_object_class->name_changed = gimp_data_name_changed;

View File

@ -56,7 +56,8 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
{
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_new (dockbook->dock->factory,
dockable = gimp_dialog_factory_dockable_new (dockbook->dock->factory,
dockbook->dock,
GUINT_TO_POINTER (action));
if (dockable)

View File

@ -94,11 +94,22 @@ static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_data_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_drawable_context_func (GimpDockable *dockable,
GimpContext *context);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func);
static void dialogs_drawable_view_image_changed (GimpContext *context,
GimpImage *gimage,
@ -108,89 +119,103 @@ static void dialogs_drawable_view_image_changed (GimpContext *context,
/* public functions */
GtkWidget *
dialogs_toolbox_get (GimpDialogFactory *factory)
dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context)
{
return toolbox_create ();
}
GtkWidget *
dialogs_lc_get (GimpDialogFactory *factory)
dialogs_lc_get (GimpDialogFactory *factory,
GimpContext *context)
{
GDisplay *gdisp;
gdisp = gimp_context_get_display (factory->context);
gdisp = gimp_context_get_display (context);
return lc_dialog_create (gdisp ? gdisp->gimage : NULL);
}
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory)
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context)
{
return tool_options_dialog_create ();
}
GtkWidget *
dialogs_device_status_get (GimpDialogFactory *factory)
dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context)
{
return device_status_create ();
}
GtkWidget *
dialogs_brush_select_get (GimpDialogFactory *factory)
dialogs_brush_select_get (GimpDialogFactory *factory,
GimpContext *context)
{
return brush_dialog_create ();
}
GtkWidget *
dialogs_pattern_select_get (GimpDialogFactory *factory)
dialogs_pattern_select_get (GimpDialogFactory *factory,
GimpContext *context)
{
return pattern_dialog_create ();
}
GtkWidget *
dialogs_gradient_select_get (GimpDialogFactory *factory)
dialogs_gradient_select_get (GimpDialogFactory *factory,
GimpContext *context)
{
return gradient_dialog_create ();
}
GtkWidget *
dialogs_palette_get (GimpDialogFactory *factory)
dialogs_palette_get (GimpDialogFactory *factory,
GimpContext *context)
{
return palette_dialog_create ();
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory)
dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context)
{
return error_console_create ();
}
GtkWidget *
dialogs_document_index_get (GimpDialogFactory *factory)
dialogs_document_index_get (GimpDialogFactory *factory,
GimpContext *context)
{
return document_index_create ();
}
GtkWidget *
dialogs_preferences_get (GimpDialogFactory *factory)
dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context)
{
return preferences_dialog_create ();
}
GtkWidget *
dialogs_input_devices_get (GimpDialogFactory *factory)
dialogs_input_devices_get (GimpDialogFactory *factory,
GimpContext *context)
{
return input_dialog_create ();
}
GtkWidget *
dialogs_module_browser_get (GimpDialogFactory *factory)
dialogs_module_browser_get (GimpDialogFactory *factory,
GimpContext *context)
{
return module_db_browser_new ();
}
GtkWidget *
dialogs_indexed_palette_get (GimpDialogFactory *factory)
dialogs_indexed_palette_get (GimpDialogFactory *factory,
GimpContext *context)
{
GimpColormapDialog *cmap_dlg;
@ -204,12 +229,13 @@ dialogs_indexed_palette_get (GimpDialogFactory *factory)
}
GtkWidget *
dialogs_undo_history_get (GimpDialogFactory *factory)
dialogs_undo_history_get (GimpDialogFactory *factory,
GimpContext *context)
{
GDisplay *gdisp;
GimpImage *gimage;
gdisp = gimp_context_get_display (factory->context);
gdisp = gimp_context_get_display (context);
if (! gdisp)
return NULL;
@ -223,12 +249,13 @@ dialogs_undo_history_get (GimpDialogFactory *factory)
}
GtkWidget *
dialogs_display_filters_get (GimpDialogFactory *factory)
dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context)
{
#ifdef DISPLAY_FILTERS
GDisplay *gdisp;
gdisp = gimp_context_get_display (factory->context);
gdisp = gimp_context_get_display (context);
if (! gdisp)
gdisp = color_area_gdisp;
@ -243,234 +270,262 @@ dialogs_display_filters_get (GimpDialogFactory *factory)
}
GtkWidget *
dialogs_tips_get (GimpDialogFactory *factory)
dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context)
{
return tips_dialog_create ();
}
GtkWidget *
dialogs_about_get (GimpDialogFactory *factory)
dialogs_about_get (GimpDialogFactory *factory,
GimpContext *context)
{
return about_dialog_create ();
}
GtkWidget *
dialogs_dock_new (GimpDialogFactory *factory)
dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context)
{
return gimp_image_dock_new (factory, image_context);
}
GtkWidget *
dialogs_image_list_view_new (GimpDialogFactory *factory)
dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_list_view_new (image_context,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Image List", "Images",
NULL);
NULL,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_brush_list_view_new (GimpDialogFactory *factory)
dialogs_brush_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_brush_factory,
dialogs_edit_brush_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Brush List", "Brushes",
dialogs_brush_tab_func);
dialogs_brush_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_pattern_list_view_new (GimpDialogFactory *factory)
dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_pattern_factory,
NULL,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Pattern List", "Patterns",
dialogs_pattern_tab_func);
dialogs_pattern_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_gradient_list_view_new (GimpDialogFactory *factory)
dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_gradient_factory,
dialogs_edit_gradient_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Gradient List", "Gradients",
dialogs_gradient_tab_func);
dialogs_gradient_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_palette_list_view_new (GimpDialogFactory *factory)
dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
global_palette_factory,
dialogs_edit_palette_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Palette List", "Palettes",
dialogs_palette_tab_func);
dialogs_palette_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_tool_list_view_new (GimpDialogFactory *factory)
dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_list_view_new (global_tool_info_list,
factory->context,
context,
22,
5, 3);
return dialogs_dockable_new (view,
"Tool List", "Tools",
NULL);
dialogs_tool_tab_func,
dialogs_set_view_context_func);
}
/* grid views */
GtkWidget *
dialogs_image_grid_view_new (GimpDialogFactory *factory)
dialogs_image_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_grid_view_new (image_context,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Image Grid", "Images",
NULL);
NULL,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_brush_grid_view_new (GimpDialogFactory *factory)
dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_brush_factory,
dialogs_edit_brush_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Brush Grid", "Brushes",
dialogs_brush_tab_func);
dialogs_brush_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_pattern_grid_view_new (GimpDialogFactory *factory)
dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_pattern_factory,
NULL,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Pattern Grid", "Patterns",
dialogs_pattern_tab_func);
dialogs_pattern_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_gradient_grid_view_new (GimpDialogFactory *factory)
dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_gradient_factory,
dialogs_edit_gradient_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Gradient Grid", "Gradients",
dialogs_gradient_tab_func);
dialogs_gradient_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_palette_grid_view_new (GimpDialogFactory *factory)
dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
global_palette_factory,
dialogs_edit_palette_func,
factory->context,
context,
32,
5, 3);
return dialogs_dockable_new (view,
"Palette Grid", "Palettes",
dialogs_palette_tab_func);
dialogs_palette_tab_func,
dialogs_set_data_context_func);
}
GtkWidget *
dialogs_tool_grid_view_new (GimpDialogFactory *factory)
dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GtkWidget *view;
view = gimp_container_grid_view_new (global_tool_info_list,
factory->context,
context,
22,
5, 3);
return dialogs_dockable_new (view,
"Tool Grid", "Tools",
NULL);
dialogs_tool_tab_func,
dialogs_set_view_context_func);
}
/* image related dialogs */
GtkWidget *
dialogs_layer_list_view_new (GimpDialogFactory *factory)
dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *view;
gimage = gimp_context_get_image (factory->context);
gimage = gimp_context_get_image (context);
view = gimp_drawable_list_view_new
(gimage,
@ -484,24 +539,20 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory)
(GimpRemoveDrawableFunc) gimp_image_remove_layer,
(GimpCopyDrawableFunc) gimp_layer_copy);
gtk_signal_connect_while_alive
(GTK_OBJECT (factory->context), "image_changed",
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view,
GTK_OBJECT (view));
return dialogs_dockable_new (view,
"Layer List", "Layers",
NULL);
NULL,
dialogs_set_drawable_context_func);
}
GtkWidget *
dialogs_channel_list_view_new (GimpDialogFactory *factory)
dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *view;
gimage = gimp_context_get_image (factory->context);
gimage = gimp_context_get_image (context);
view = gimp_drawable_list_view_new
(gimage,
@ -515,15 +566,10 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory)
(GimpRemoveDrawableFunc) gimp_image_remove_channel,
(GimpCopyDrawableFunc) gimp_channel_copy);
gtk_signal_connect_while_alive
(GTK_OBJECT (factory->context), "image_changed",
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view,
GTK_OBJECT (view));
return dialogs_dockable_new (view,
"Channel List", "Channels",
NULL);
NULL,
dialogs_set_drawable_context_func);
}
@ -610,7 +656,7 @@ dialogs_brush_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
@ -634,7 +680,7 @@ dialogs_pattern_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
@ -658,7 +704,7 @@ dialogs_gradient_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
@ -682,7 +728,7 @@ dialogs_palette_tab_func (GimpDockable *dockable,
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->factory->context;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
@ -698,21 +744,130 @@ dialogs_palette_tab_func (GimpDockable *dockable,
return preview;
}
static GtkWidget *
dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size)
{
GimpContext *context;
GtkWidget *preview;
context = dockbook->dock->context;
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_tool (context)),
size, size, 1,
FALSE, FALSE, FALSE);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"tool_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
return preview;
}
static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpContainerView *view;
view = (GimpContainerView *) gtk_object_get_data (GTK_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
gimp_container_view_set_context (view, context);
}
static void
dialogs_set_data_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) gtk_object_get_data (GTK_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
/* TODO: gimp_data_factory_view_set_context (view, context); */
}
}
static void
dialogs_context_disconnect (GimpContext *context,
GtkWidget *view)
{
gtk_object_set_data (GTK_OBJECT (view), "gimp-dialogs-context", NULL);
}
static void
dialogs_set_drawable_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) gtk_object_get_data (GTK_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
GimpContext *old_context;
old_context = (GimpContext *) gtk_object_get_data (GTK_OBJECT (view),
"gimp-dialogs-context");
if (old_context)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (old_context),
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view);
gtk_signal_disconnect_by_func (GTK_OBJECT (old_context),
GTK_SIGNAL_FUNC (dialogs_context_disconnect),
view);
}
if (context)
{
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
view);
gtk_signal_connect (GTK_OBJECT (context), "destroy",
GTK_SIGNAL_FUNC (dialogs_context_disconnect),
view);
gtk_object_set_data (GTK_OBJECT (view), "gimp-dialogs-context",
context);
}
dialogs_drawable_view_image_changed (context,
gimp_context_get_image (context),
view);
}
}
static GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func)
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func)
{
GtkWidget *dockable;
dockable = gimp_dockable_new (name,
short_name,
get_tab_func);
get_tab_func,
set_context_func);
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
gtk_object_set_data (GTK_OBJECT (dockable), "gimp-dialogs-view", widget);
return dockable;
}
@ -723,4 +878,3 @@ dialogs_drawable_view_image_changed (GimpContext *context,
{
gimp_drawable_list_view_set_image (view, gimage);
}

View File

@ -20,43 +20,76 @@
#define __DIALOGS_CONSTRUCTORS_H__
GtkWidget * dialogs_toolbox_get (GimpDialogFactory *factory);
GtkWidget * dialogs_lc_get (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_select_get (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_select_get (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_select_get (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_get (GimpDialogFactory *factory);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory);
GtkWidget * dialogs_document_index_get (GimpDialogFactory *factory);
GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory);
GtkWidget * dialogs_input_devices_get (GimpDialogFactory *factory);
GtkWidget * dialogs_module_browser_get (GimpDialogFactory *factory);
GtkWidget * dialogs_indexed_palette_get (GimpDialogFactory *factory);
GtkWidget * dialogs_undo_history_get (GimpDialogFactory *factory);
GtkWidget * dialogs_display_filters_get (GimpDialogFactory *factory);
GtkWidget * dialogs_tips_get (GimpDialogFactory *factory);
GtkWidget * dialogs_about_get (GimpDialogFactory *factory);
GtkWidget * dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_lc_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_brush_select_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_pattern_select_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_gradient_select_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_palette_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_document_index_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_input_devices_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_module_browser_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_indexed_palette_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_undo_history_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_dock_new (GimpDialogFactory *factory);
GtkWidget * dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_brush_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_image_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_image_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_layer_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_channel_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
GtkWidget * dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context);
void dialogs_edit_brush_func (GimpData *data);
void dialogs_edit_gradient_func (GimpData *data);

View File

@ -207,8 +207,6 @@ gimp_container_menu_impl_remove_item (GimpContainerMenu *menu,
else
menu_item = NULL;
g_print ("remove %p %p\n", viewable, menu_item);
if (menu_item)
{
if (g_list_length (GTK_MENU_SHELL (menu)->children) == 2)

View File

@ -260,8 +260,9 @@ gimp_dialog_factory_find_session_info (GimpDialogFactory *factory,
return NULL;
}
GtkWidget *
gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
static GtkWidget *
gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
GimpContext *context,
const gchar *identifier)
{
GimpDialogFactoryEntry *entry;
@ -299,7 +300,7 @@ gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
if (! dialog)
{
dialog = entry->new_func (factory);
dialog = entry->new_func (factory, context);
if (dialog)
{
@ -328,6 +329,35 @@ gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
return dialog;
}
GtkWidget *
gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
const gchar *identifier)
{
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
g_return_val_if_fail (identifier != NULL, NULL);
return gimp_dialog_factory_dialog_new_internal (factory,
factory->context,
identifier);
}
GtkWidget *
gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
GimpDock *dock,
const gchar *identifier)
{
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
g_return_val_if_fail (dock != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
g_return_val_if_fail (identifier != NULL, NULL);
return gimp_dialog_factory_dialog_new_internal (factory,
dock->context,
identifier);
}
GtkWidget *
gimp_dialog_factory_dock_new (GimpDialogFactory *factory)
{
@ -337,7 +367,7 @@ gimp_dialog_factory_dock_new (GimpDialogFactory *factory)
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
g_return_val_if_fail (factory->new_dock_func != NULL, NULL);
dock = factory->new_dock_func (factory);
dock = factory->new_dock_func (factory, factory->context);
if (dock)
gimp_dialog_factory_add_toplevel (factory, dock);
@ -642,7 +672,8 @@ gimp_dialog_factories_session_restore_foreach (gchar *name,
identifier = (gchar *) pages->data;
dockable = gimp_dialog_factory_dialog_new (factory,
dockable = gimp_dialog_factory_dockable_new (factory,
dock,
identifier);
if (dockable)

View File

@ -28,7 +28,8 @@
#include "gimpobject.h"
typedef GtkWidget * (* GimpDialogNewFunc) (GimpDialogFactory *factory);
typedef GtkWidget * (* GimpDialogNewFunc) (GimpDialogFactory *factory,
GimpContext *context);
typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
@ -116,6 +117,9 @@ void gimp_dialog_factory_register (GimpDialogFactory *factory,
GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
const gchar *identifier);
GtkWidget * gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
GimpDock *dock,
const gchar *identifier);
GtkWidget * gimp_dialog_factory_dock_new (GimpDialogFactory *factory);
void gimp_dialog_factory_add_toplevel (GimpDialogFactory *factory,

View File

@ -121,6 +121,8 @@ gimp_dock_init (GimpDock *dock)
{
GtkWidget *separator;
dock->context = NULL;
gtk_window_set_policy (GTK_WINDOW (dock), FALSE, TRUE, TRUE);
gtk_widget_set_usize (GTK_WIDGET (dock), GIMP_DOCK_MINIMAL_WIDTH, -1);
@ -144,7 +146,10 @@ gimp_dock_destroy (GtkObject *object)
dock = GIMP_DOCK (object);
g_list_free (dock->dockbooks);
while (dock->dockbooks)
gimp_dock_remove_book (dock, GIMP_DOCKBOOK (dock->dockbooks->data));
gtk_object_unref (GTK_OBJECT (dock->context));
if (GTK_OBJECT_CLASS (parent_class))
GTK_OBJECT_CLASS (parent_class)->destroy (object);

View File

@ -41,6 +41,7 @@ struct _GimpDock
GtkWindow parent_instance;
GimpDialogFactory *factory;
GimpContext *context;
GtkWidget *main_vbox;
GtkWidget *vbox;

View File

@ -28,6 +28,8 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpcontext.h"
static void gimp_dockable_class_init (GimpDockableClass *klass);
static void gimp_dockable_init (GimpDockable *dockable);
@ -82,6 +84,7 @@ gimp_dockable_init (GimpDockable *dockable)
dockable->short_name = NULL;
dockable->dockbook = NULL;
dockable->get_tab_func = NULL;
dockable->set_context_func = NULL;
}
static void
@ -91,6 +94,8 @@ gimp_dockable_destroy (GtkObject *object)
dockable = GIMP_DOCKABLE (object);
gimp_dockable_set_context (dockable, NULL);
g_free (dockable->name);
g_free (dockable->short_name);
@ -101,7 +106,8 @@ gimp_dockable_destroy (GtkObject *object)
GtkWidget *
gimp_dockable_new (const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func)
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func)
{
GimpDockable *dockable;
@ -114,6 +120,7 @@ gimp_dockable_new (const gchar *name,
dockable->short_name = g_strdup (short_name);
dockable->get_tab_func = get_tab_func;
dockable->set_context_func = set_context_func;
return GTK_WIDGET (dockable);
}
@ -138,3 +145,18 @@ gimp_dockable_get_tab_widget (GimpDockable *dockable,
return gtk_label_new (dockable->short_name);
}
void
gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context)
{
g_return_if_fail (dockable != NULL);
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
if (dockable->set_context_func)
{
dockable->set_context_func (dockable, context);
}
}

View File

@ -29,6 +29,8 @@
typedef GtkWidget * (* GimpDockableGetTabFunc) (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
typedef void (* GimpDockableSetContextFunc) (GimpDockable *dockable,
GimpContext *context);
#define GIMP_TYPE_DOCKABLE (gimp_dockable_get_type ())
@ -51,6 +53,7 @@ struct _GimpDockable
GimpDockbook *dockbook;
GimpDockableGetTabFunc get_tab_func;
GimpDockableSetContextFunc set_context_func;
};
struct _GimpDockableClass
@ -62,11 +65,14 @@ struct _GimpDockableClass
GtkType gimp_dockable_get_type (void);
GtkWidget * gimp_dockable_new (const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func);
GtkWidget * gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
void gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context);
#endif /* __GIMP_DOCKABLE_H__ */

View File

@ -197,6 +197,8 @@ gimp_dockbook_add (GimpDockbook *dockbook,
g_return_if_fail (dockbook != NULL);
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dockbook->dock != NULL);
g_return_if_fail (dockable != NULL);
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
@ -314,6 +316,8 @@ gimp_dockbook_add (GimpDockbook *dockbook,
dockbook);
dockable->dockbook = dockbook;
gimp_dockable_set_context (dockable, dockbook->dock->context);
}
void

View File

@ -32,7 +32,12 @@
#include "gimpcontainermenuimpl.h"
#include "gimpdockbook.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "libgimp/gimpintl.h"
static void gimp_image_dock_class_init (GimpImageDockClass *klass);
@ -40,6 +45,15 @@ static void gimp_image_dock_init (GimpImageDock *dock);
static void gimp_image_dock_destroy (GtkObject *object);
static void gimp_image_dock_factory_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock);
static void gimp_image_dock_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock);
static void gimp_image_dock_auto_clicked (GtkWidget *widget,
GimpDock *dock);
static GimpDockClass *parent_class = NULL;
@ -84,16 +98,31 @@ gimp_image_dock_class_init (GimpImageDockClass *klass)
static void
gimp_image_dock_init (GimpImageDock *dock)
{
dock->option_menu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (GIMP_DOCK (dock)->main_vbox), dock->option_menu,
GtkWidget *hbox;
GtkWidget *toggle;
dock->image_container = NULL;
dock->auto_follow_active = TRUE;
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (GIMP_DOCK (dock)->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (GIMP_DOCK (dock)->main_vbox),
dock->option_menu, 0);
gtk_box_reorder_child (GTK_BOX (GIMP_DOCK (dock)->main_vbox), hbox, 0);
gtk_widget_show (hbox);
dock->option_menu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (hbox), dock->option_menu, TRUE, TRUE, 0);
gtk_widget_show (dock->option_menu);
dock->menu = gimp_container_menu_new (NULL, NULL, 24);
gtk_option_menu_set_menu (GTK_OPTION_MENU (dock->option_menu), dock->menu);
gtk_widget_show (dock->menu);
toggle = gtk_toggle_button_new_with_label (_("Auto"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
dock->auto_follow_active);
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
gtk_signal_connect (GTK_OBJECT (toggle), "clicked",
GTK_SIGNAL_FUNC (gimp_image_dock_auto_clicked),
dock);
}
static void
@ -103,6 +132,12 @@ gimp_image_dock_destroy (GtkObject *object)
dock = GIMP_IMAGE_DOCK (object);
/* remove the image menu and the auto button manually here because
* of weird cross-connections with GimpDock's context
*/
gtk_container_remove (GTK_CONTAINER (GIMP_DOCK (dock)->main_vbox),
dock->option_menu->parent);
if (GTK_OBJECT_CLASS (parent_class))
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -117,27 +152,95 @@ gimp_image_dock_new (GimpDialogFactory *factory,
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
g_return_val_if_fail (image_container != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CONTAINER (image_container), NULL);
image_dock = gtk_type_new (GIMP_TYPE_IMAGE_DOCK);
dock = GIMP_DOCK (image_dock);
image_dock->image_container = image_container;
dock->factory = factory;
dock->context = gimp_context_new ("Dock Context", factory->context);
gimp_context_define_args (dock->context,
GIMP_CONTEXT_ALL_ARGS_MASK &
~(GIMP_CONTEXT_IMAGE_MASK |
GIMP_CONTEXT_DISPLAY_MASK),
FALSE);
gimp_context_set_parent (dock->context, factory->context);
gtk_signal_connect_while_alive
(GTK_OBJECT (factory->context), "image_changed",
GTK_SIGNAL_FUNC (gimp_image_dock_factory_image_changed),
dock,
GTK_OBJECT (dock));
gtk_signal_connect_while_alive
(GTK_OBJECT (dock->context), "image_changed",
GTK_SIGNAL_FUNC (gimp_image_dock_image_changed),
dock,
GTK_OBJECT (dock));
image_dock->menu = gimp_container_menu_new (image_container,
factory->context, 24);
dock->context, 24);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_dock->option_menu),
image_dock->menu);
gtk_widget_show (image_dock->menu);
/* set the container _after_ adding it to the option menu so it
* has a parent and can set the active item correctly
*/
/*
gimp_container_menu_set_container (GIMP_CONTAINER_MENU (image_dock->menu),
image_container);
gimp_container_menu_set_context (GIMP_CONTAINER_MENU (image_dock->menu),
factory->context);
*/
return GTK_WIDGET (image_dock);
}
static void
gimp_image_dock_factory_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock)
{
GimpImageDock *image_dock;
image_dock = GIMP_IMAGE_DOCK (dock);
if (gimage && image_dock->auto_follow_active)
{
gimp_context_set_image (dock->context, gimage);
}
}
static void
gimp_image_dock_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock)
{
GimpImageDock *image_dock;
image_dock = GIMP_IMAGE_DOCK (dock);
if (! gimage && image_dock->image_container->num_children)
{
gimage = GIMP_IMAGE (gimp_container_get_child_by_index (image_dock->image_container, 0));
gimp_context_set_image (dock->context, gimage);
}
}
static void
gimp_image_dock_auto_clicked (GtkWidget *widget,
GimpDock *dock)
{
GimpImageDock *image_dock;
image_dock = GIMP_IMAGE_DOCK (dock);
gimp_toggle_button_update (widget, &image_dock->auto_follow_active);
if (image_dock->auto_follow_active)
{
GimpImage *gimage;
gimage = gimp_context_get_image (dock->factory->context);
if (gimage)
gimp_context_set_image (dock->context, gimage);
}
}

View File

@ -39,6 +39,10 @@ struct _GimpImageDock
{
GimpDock parent_instance;
GimpContainer *image_container;
gboolean auto_follow_active;
GtkWidget *option_menu;
GtkWidget *menu;
};

View File

@ -32,7 +32,12 @@
#include "gimpcontainermenuimpl.h"
#include "gimpdockbook.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "libgimp/gimpintl.h"
static void gimp_image_dock_class_init (GimpImageDockClass *klass);
@ -40,6 +45,15 @@ static void gimp_image_dock_init (GimpImageDock *dock);
static void gimp_image_dock_destroy (GtkObject *object);
static void gimp_image_dock_factory_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock);
static void gimp_image_dock_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock);
static void gimp_image_dock_auto_clicked (GtkWidget *widget,
GimpDock *dock);
static GimpDockClass *parent_class = NULL;
@ -84,16 +98,31 @@ gimp_image_dock_class_init (GimpImageDockClass *klass)
static void
gimp_image_dock_init (GimpImageDock *dock)
{
dock->option_menu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (GIMP_DOCK (dock)->main_vbox), dock->option_menu,
GtkWidget *hbox;
GtkWidget *toggle;
dock->image_container = NULL;
dock->auto_follow_active = TRUE;
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (GIMP_DOCK (dock)->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (GIMP_DOCK (dock)->main_vbox),
dock->option_menu, 0);
gtk_box_reorder_child (GTK_BOX (GIMP_DOCK (dock)->main_vbox), hbox, 0);
gtk_widget_show (hbox);
dock->option_menu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (hbox), dock->option_menu, TRUE, TRUE, 0);
gtk_widget_show (dock->option_menu);
dock->menu = gimp_container_menu_new (NULL, NULL, 24);
gtk_option_menu_set_menu (GTK_OPTION_MENU (dock->option_menu), dock->menu);
gtk_widget_show (dock->menu);
toggle = gtk_toggle_button_new_with_label (_("Auto"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
dock->auto_follow_active);
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
gtk_signal_connect (GTK_OBJECT (toggle), "clicked",
GTK_SIGNAL_FUNC (gimp_image_dock_auto_clicked),
dock);
}
static void
@ -103,6 +132,12 @@ gimp_image_dock_destroy (GtkObject *object)
dock = GIMP_IMAGE_DOCK (object);
/* remove the image menu and the auto button manually here because
* of weird cross-connections with GimpDock's context
*/
gtk_container_remove (GTK_CONTAINER (GIMP_DOCK (dock)->main_vbox),
dock->option_menu->parent);
if (GTK_OBJECT_CLASS (parent_class))
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -117,27 +152,95 @@ gimp_image_dock_new (GimpDialogFactory *factory,
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
g_return_val_if_fail (image_container != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CONTAINER (image_container), NULL);
image_dock = gtk_type_new (GIMP_TYPE_IMAGE_DOCK);
dock = GIMP_DOCK (image_dock);
image_dock->image_container = image_container;
dock->factory = factory;
dock->context = gimp_context_new ("Dock Context", factory->context);
gimp_context_define_args (dock->context,
GIMP_CONTEXT_ALL_ARGS_MASK &
~(GIMP_CONTEXT_IMAGE_MASK |
GIMP_CONTEXT_DISPLAY_MASK),
FALSE);
gimp_context_set_parent (dock->context, factory->context);
gtk_signal_connect_while_alive
(GTK_OBJECT (factory->context), "image_changed",
GTK_SIGNAL_FUNC (gimp_image_dock_factory_image_changed),
dock,
GTK_OBJECT (dock));
gtk_signal_connect_while_alive
(GTK_OBJECT (dock->context), "image_changed",
GTK_SIGNAL_FUNC (gimp_image_dock_image_changed),
dock,
GTK_OBJECT (dock));
image_dock->menu = gimp_container_menu_new (image_container,
factory->context, 24);
dock->context, 24);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_dock->option_menu),
image_dock->menu);
gtk_widget_show (image_dock->menu);
/* set the container _after_ adding it to the option menu so it
* has a parent and can set the active item correctly
*/
/*
gimp_container_menu_set_container (GIMP_CONTAINER_MENU (image_dock->menu),
image_container);
gimp_container_menu_set_context (GIMP_CONTAINER_MENU (image_dock->menu),
factory->context);
*/
return GTK_WIDGET (image_dock);
}
static void
gimp_image_dock_factory_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock)
{
GimpImageDock *image_dock;
image_dock = GIMP_IMAGE_DOCK (dock);
if (gimage && image_dock->auto_follow_active)
{
gimp_context_set_image (dock->context, gimage);
}
}
static void
gimp_image_dock_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock)
{
GimpImageDock *image_dock;
image_dock = GIMP_IMAGE_DOCK (dock);
if (! gimage && image_dock->image_container->num_children)
{
gimage = GIMP_IMAGE (gimp_container_get_child_by_index (image_dock->image_container, 0));
gimp_context_set_image (dock->context, gimage);
}
}
static void
gimp_image_dock_auto_clicked (GtkWidget *widget,
GimpDock *dock)
{
GimpImageDock *image_dock;
image_dock = GIMP_IMAGE_DOCK (dock);
gimp_toggle_button_update (widget, &image_dock->auto_follow_active);
if (image_dock->auto_follow_active)
{
GimpImage *gimage;
gimage = gimp_context_get_image (dock->factory->context);
if (gimage)
gimp_context_set_image (dock->context, gimage);
}
}

View File

@ -39,6 +39,10 @@ struct _GimpImageDock
{
GimpDock parent_instance;
GimpContainer *image_container;
gboolean auto_follow_active;
GtkWidget *option_menu;
GtkWidget *menu;
};