app/widgets/Makefile.am app/widgets/widgets-types.h new files implementing

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

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpdocked.[ch]: new files implementing
	GimpDockedInterface, a GTypeInterface which must be implemented by
	all widgets which want to be packed into a GimpDockable. Has
	virtual functions similar to the ones GimpDockable had.

	* app/widgets/gimpdockable.[ch]: removed all virtual functions and
	all function pointers from the instance struct (also the ones just
	added in the commit below). Make sure only widgets implementing
	the GimpDockedIface are added and simply call the child's
	GimpDocked functions where we used to call our own virtual
	functions and function pointers.

	* app/widgets/gimpcoloreditor.c
	* app/widgets/gimpcontainereditor.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainerview.c
	* app/widgets/gimpeditor.c
	* app/widgets/gimpimageeditor.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimpsessioninfo.c
	* app/widgets/gimptooloptionseditor.c
	* app/display/gimpnavigationview.c: implement GimpDockedIface.

	* app/gui/dialogs-constructors.c: removed all that get_preview_func(),
	set_context_func() etc. cruft since that's done by GimpDockedIface.
	It's really a file of constructors now.

	* app/gui/dialogs-menu.c: changed accordingly.

	* app/widgets/gimpimagedock.c: forgotten in the commit below.
This commit is contained in:
Michael Natterer 2003-10-10 21:24:12 +00:00 committed by Michael Natterer
parent 0ca8e5ef02
commit 99746e1d6c
22 changed files with 1229 additions and 1291 deletions

View file

@ -1,3 +1,38 @@
2003-10-10 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpdocked.[ch]: new files implementing
GimpDockedInterface, a GTypeInterface which must be implemented by
all widgets which want to be packed into a GimpDockable. Has
virtual functions similar to the ones GimpDockable had.
* app/widgets/gimpdockable.[ch]: removed all virtual functions and
all function pointers from the instance struct (also the ones just
added in the commit below). Make sure only widgets implementing
the GimpDockedIface are added and simply call the child's
GimpDocked functions where we used to call our own virtual
functions and function pointers.
* app/widgets/gimpcoloreditor.c
* app/widgets/gimpcontainereditor.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainerview.c
* app/widgets/gimpeditor.c
* app/widgets/gimpimageeditor.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimpsessioninfo.c
* app/widgets/gimptooloptionseditor.c
* app/display/gimpnavigationview.c: implement GimpDockedIface.
* app/gui/dialogs-constructors.c: removed all that get_preview_func(),
set_context_func() etc. cruft since that's done by GimpDockedIface.
It's really a file of constructors now.
* app/gui/dialogs-menu.c: changed accordingly.
* app/widgets/gimpimagedock.c: forgotten in the commit below.
2003-10-10 Michael Natterer <mitch@gimp.org>
Cleaned up session management and changed the format of sessionrc

View file

@ -18,11 +18,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
@ -33,7 +30,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
#include "vectors/gimpvectors.h"
@ -55,14 +51,10 @@
#include "widgets/gimpitemtreeview.h"
#include "widgets/gimpdevicestatus.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocumentview.h"
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h"
@ -94,52 +86,15 @@
/* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id);
static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer data);
static GtkWidget * dialogs_tool_options_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer data);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_color_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_image_item_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_image_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context);
static GimpItemFactory * dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id,
GimpDockableGetPreviewFunc get_preview_func,
gpointer get_preview_data,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func);
static void dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view);
static void dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable);
/**********************/
@ -259,10 +214,7 @@ dialogs_tool_options_get (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Tool Options"), NULL,
GIMP_STOCK_TOOL_OPTIONS,
GIMP_HELP_TOOL_OPTIONS_DIALOG,
dialogs_tool_options_preview_func, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_TOOL_OPTIONS_DIALOG);
}
GtkWidget *
@ -282,9 +234,7 @@ dialogs_device_status_get (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Devices"), _("Device Status"),
GIMP_STOCK_DEVICE_STATUS,
GIMP_HELP_DEVICE_STATUS_DIALOG,
NULL, NULL,
NULL, NULL);
GIMP_HELP_DEVICE_STATUS_DIALOG);
}
GtkWidget *
@ -304,10 +254,7 @@ dialogs_error_console_get (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Errors"), _("Error Console"),
GIMP_STOCK_WARNING,
GIMP_HELP_ERRORS_DIALOG,
NULL, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_ERRORS_DIALOG);
}
@ -329,10 +276,7 @@ dialogs_image_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Images"), NULL,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_IMAGE_DIALOG);
}
GtkWidget *
@ -353,10 +297,7 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Brushes"), NULL,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BRUSH_DIALOG);
}
GtkWidget *
@ -376,10 +317,7 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Patterns"), NULL,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PATTERN_DIALOG);
}
GtkWidget *
@ -399,10 +337,7 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Gradients"), NULL,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_GRADIENT_DIALOG);
}
GtkWidget *
@ -422,10 +357,7 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Palettes"), NULL,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PALETTE_DIALOG);
}
GtkWidget *
@ -443,10 +375,7 @@ dialogs_font_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Fonts"), NULL,
GTK_STOCK_SELECT_FONT,
GIMP_HELP_FONT_DIALOG,
dialogs_viewable_preview_func, "font",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_FONT_DIALOG);
}
GtkWidget *
@ -464,10 +393,7 @@ dialogs_tool_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Tools"), NULL,
GTK_STOCK_MISSING_IMAGE,
GIMP_HELP_TOOL_DIALOG,
dialogs_viewable_preview_func, "tool",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_TOOL_DIALOG);
}
GtkWidget *
@ -486,10 +412,7 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Buffers"), NULL,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BUFFER_DIALOG);
}
GtkWidget *
@ -509,10 +432,7 @@ dialogs_document_list_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("History"), _("Document History"),
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_DOCUMENT_DIALOG);
}
GtkWidget *
@ -538,10 +458,7 @@ dialogs_template_list_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Templates"), NULL,
GIMP_STOCK_TEMPLATE,
GIMP_HELP_TEMPLATE_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_TEMPLATE_DIALOG);
}
@ -563,10 +480,7 @@ dialogs_image_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Images"), NULL,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_IMAGE_DIALOG);
}
GtkWidget *
@ -587,10 +501,7 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Brushes"), NULL,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BRUSH_DIALOG);
}
GtkWidget *
@ -610,10 +521,7 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Patterns"), NULL,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PATTERN_DIALOG);
}
GtkWidget *
@ -633,10 +541,7 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Gradients"), NULL,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_GRADIENT_DIALOG);
}
GtkWidget *
@ -656,10 +561,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Palettes"), NULL,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PALETTE_DIALOG);
}
GtkWidget *
@ -677,10 +579,7 @@ dialogs_font_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Fonts"), NULL,
GTK_STOCK_SELECT_FONT,
GIMP_HELP_FONT_DIALOG,
dialogs_viewable_preview_func, "font",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_FONT_DIALOG);
}
GtkWidget *
@ -698,10 +597,7 @@ dialogs_tool_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Tools"), NULL,
GTK_STOCK_MISSING_IMAGE,
GIMP_HELP_TOOL_DIALOG,
dialogs_viewable_preview_func, "tool",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_TOOL_DIALOG);
}
GtkWidget *
@ -720,10 +616,7 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Buffers"), NULL,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BUFFER_DIALOG);
}
GtkWidget *
@ -743,10 +636,7 @@ dialogs_document_grid_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("History"), _("Document History"),
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_DOCUMENT_DIALOG);
}
@ -757,18 +647,15 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
if (preview_size < 1)
preview_size = context->gimp->config->layer_preview_size;
view =
gimp_item_tree_view_new (preview_size, 2,
gimage,
gimp_context_get_image (context),
GIMP_TYPE_LAYER,
"active_layer_changed",
(GimpEditItemFunc) layers_edit_layer_query,
@ -779,10 +666,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Layers"), NULL,
GIMP_STOCK_LAYERS,
GIMP_HELP_LAYER_DIALOG,
NULL, NULL,
dialogs_set_image_item_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_LAYER_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -794,18 +678,15 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
if (preview_size < 1)
preview_size = context->gimp->config->layer_preview_size;
view =
gimp_item_tree_view_new (preview_size, 1,
gimage,
gimp_context_get_image (context),
GIMP_TYPE_CHANNEL,
"active_channel_changed",
(GimpEditItemFunc) channels_edit_channel_query,
@ -816,10 +697,7 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Channels"), NULL,
GIMP_STOCK_CHANNELS,
GIMP_HELP_CHANNEL_DIALOG,
NULL, NULL,
dialogs_set_image_item_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_CHANNEL_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -831,19 +709,16 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GimpVectorsTreeView *vectors_view;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
if (preview_size < 1)
preview_size = context->gimp->config->layer_preview_size;
view =
gimp_item_tree_view_new (preview_size, 1,
gimage,
gimp_context_get_image (context),
GIMP_TYPE_VECTORS,
"active_vectors_changed",
(GimpEditItemFunc) vectors_edit_vectors_query,
@ -859,10 +734,7 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Paths"), NULL,
GIMP_STOCK_PATHS,
GIMP_HELP_PATH_DIALOG,
NULL, NULL,
dialogs_set_image_item_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PATH_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -874,21 +746,16 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
view = gimp_colormap_editor_new (gimage, factory->menu_factory);
view = gimp_colormap_editor_new (gimp_context_get_image (context),
factory->menu_factory);
dockable = dialogs_dockable_new (view,
_("Colormap"), _("Indexed Palette"),
GIMP_STOCK_INDEXED_PALETTE,
GIMP_HELP_INDEXED_PALETTE_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_INDEXED_PALETTE_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -904,14 +771,11 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GimpSelectionEditor *selection_editor;
GtkWidget *view;
GtkWidget *dockable;
GimpSelectionEditor *selection_editor;
gimage = gimp_context_get_image (context);
view = gimp_selection_editor_new (gimage);
view = gimp_selection_editor_new (gimp_context_get_image (context));
selection_editor = GIMP_SELECTION_EDITOR (view);
@ -921,10 +785,7 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Selection"), _("Selection Editor"),
GIMP_STOCK_TOOL_RECT_SELECT,
GIMP_HELP_SELECTION_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
NULL);
GIMP_HELP_SELECTION_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -936,21 +797,15 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
view = gimp_undo_editor_new (gimage);
view = gimp_undo_editor_new (gimp_context_get_image (context));
dockable = dialogs_dockable_new (view,
_("Undo"), _("Undo History"),
GIMP_STOCK_UNDO_HISTORY,
GIMP_HELP_UNDO_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
NULL);
GIMP_HELP_UNDO_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -980,10 +835,7 @@ dialogs_navigation_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Navigation"), _("Display Navigation"),
GIMP_STOCK_NAVIGATION,
GIMP_HELP_NAVIGATION_DIALOG,
NULL, NULL,
dialogs_set_navigation_context_func,
NULL);
GIMP_HELP_NAVIGATION_DIALOG);
}
@ -1001,10 +853,7 @@ dialogs_color_editor_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("FG/BG"), _("FG/BG Color"),
GIMP_STOCK_DEFAULT_COLORS,
GIMP_HELP_COLOR_DIALOG,
NULL, NULL,
dialogs_set_color_editor_context_func,
NULL);
GIMP_HELP_COLOR_DIALOG);
}
@ -1024,9 +873,7 @@ dialogs_brush_editor_get (GimpDialogFactory *factory,
return dialogs_dockable_new (GTK_WIDGET (brush_editor),
_("Brush Editor"), NULL,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_EDITOR_DIALOG,
NULL, NULL,
NULL, NULL);
GIMP_HELP_BRUSH_EDITOR_DIALOG);
}
void
@ -1055,10 +902,7 @@ dialogs_gradient_editor_get (GimpDialogFactory *factory,
return dialogs_dockable_new (GTK_WIDGET (gradient_editor),
_("Gradient Editor"), NULL,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_EDITOR_DIALOG,
NULL, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_GRADIENT_EDITOR_DIALOG);
}
void
@ -1087,10 +931,7 @@ dialogs_palette_editor_get (GimpDialogFactory *factory,
return dialogs_dockable_new (GTK_WIDGET (palette_editor),
_("Palette Editor"), NULL,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_EDITOR_DIALOG,
NULL, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_PALETTE_EDITOR_DIALOG);
}
void
@ -1106,14 +947,28 @@ dialogs_edit_palette_func (GimpData *data)
/* private functions */
static GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id)
{
GtkWidget *dockable;
dockable = gimp_dockable_new (name, blurb, stock_id, help_id);
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
return dockable;
}
static void
dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable)
{
GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage)
{
@ -1130,275 +985,3 @@ dialogs_indexed_palette_selected (GimpColormapEditor *editor,
gimp_context_set_foreground (dockable->context, &color);
}
}
static GtkWidget *
dialogs_viewable_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer preview_data)
{
GtkWidget *preview;
gint width;
gint height;
const gchar *prop_name;
gboolean is_tool;
gtk_icon_size_lookup (size, &width, &height);
prop_name = (const gchar *) preview_data;
is_tool = (strcmp (prop_name, "tool") == 0);
preview = gimp_prop_preview_new (G_OBJECT (context), prop_name, height);
GIMP_PREVIEW (preview)->renderer->size = -1;
gimp_preview_renderer_set_size_full (GIMP_PREVIEW (preview)->renderer,
width, height,
is_tool ? 0 : 1);
return preview;
}
static void
dialogs_tool_options_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
GtkLabel *label)
{
GtkImage *image;
if ((image = g_object_get_data (G_OBJECT (label), "tool-icon")))
{
const gchar *stock_id;
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
gtk_image_set_from_stock (image, stock_id, image->icon_size);
}
gtk_label_set_text (label, tool_info->blurb);
gimp_help_set_help_data (GTK_WIDGET (label)->parent->parent,
tool_info->help, tool_info->help_id);
}
static GtkWidget *
dialogs_tool_options_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer preview_data)
{
GimpToolInfo *tool_info;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
gint width;
gint height;
const gchar *stock_id;
gtk_icon_size_lookup (size, &width, &height);
tool_info = gimp_context_get_tool (context);
hbox = gtk_hbox_new (FALSE, 2);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
image = gtk_image_new_from_stock (stock_id, size);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = gtk_label_new (tool_info->blurb);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_set_data (G_OBJECT (label), "tool-icon", image);
g_signal_connect_object (context, "tool_changed",
G_CALLBACK (dialogs_tool_options_tool_changed),
label,
0);
return hbox;
}
static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
if (view)
gimp_container_view_set_context (view, context);
}
static void
dialogs_set_color_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
if (GIMP_IS_COLOR_EDITOR (widget))
gimp_color_editor_set_context (GIMP_COLOR_EDITOR (widget), context);
}
static void
dialogs_set_image_item_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpImage *gimage = NULL;
if (! GIMP_IS_CONTAINER_VIEW (widget))
return;
if (dockable->context)
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_item_view_image_changed,
widget);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_item_view_image_changed),
widget);
gimage = gimp_context_get_image (context);
}
dialogs_image_item_view_image_changed (context, gimage,
GIMP_CONTAINER_VIEW (widget));
}
static void
dialogs_set_image_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpImage *gimage = NULL;
if (! GIMP_IS_IMAGE_EDITOR (widget))
return;
if (dockable->context)
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_editor_image_changed,
widget);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_editor_image_changed),
widget);
gimage = gimp_context_get_image (context);
}
dialogs_image_editor_image_changed (context, gimage,
GIMP_IMAGE_EDITOR (widget));
}
static void
dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpDisplay *gdisp = NULL;
if (! GIMP_IS_NAVIGATION_VIEW (widget))
return;
if (dockable->context)
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_navigation_display_changed,
widget);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (dialogs_navigation_display_changed),
widget);
gdisp = gimp_context_get_display (context);
}
dialogs_navigation_display_changed (context, gdisp,
GIMP_NAVIGATION_VIEW (widget));
}
static GimpItemFactory *
dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpEditor *editor = NULL;
if (GIMP_IS_EDITOR (widget))
{
editor = GIMP_EDITOR (widget);
}
else if (GIMP_IS_CONTAINER_EDITOR (widget))
{
editor = GIMP_EDITOR (GIMP_CONTAINER_EDITOR (widget)->view);
}
if (editor)
{
if (item_factory_data)
*item_factory_data = editor->item_factory_data;
return editor->item_factory;
}
return NULL;
}
static GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id,
GimpDockableGetPreviewFunc get_preview_func,
gpointer get_preview_data,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func)
{
GtkWidget *dockable;
dockable = gimp_dockable_new (name, blurb, stock_id, help_id,
get_preview_func,
get_preview_data,
set_context_func,
get_menu_func);
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
return dockable;
}
static void
dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_item_tree_view_set_image (GIMP_ITEM_TREE_VIEW (view), gimage);
}
static void
dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor)
{
gimp_image_editor_set_image (editor, gimage);
}
static void
dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}

View file

@ -33,8 +33,10 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
@ -54,6 +56,11 @@
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
static void gimp_navigation_view_init (GimpNavigationView *view);
static void gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_navigation_view_destroy (GtkObject *object);
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
@ -103,9 +110,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_navigation_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
@ -119,13 +126,22 @@ gimp_navigation_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_navigation_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_navigation_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
@ -173,6 +189,54 @@ gimp_navigation_view_init (GimpNavigationView *view)
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
}
static void
gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_navigation_view_set_docked_context;
}
static void
gimp_navigation_view_docked_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
if (prev_context)
g_signal_handlers_disconnect_by_func (prev_context,
gimp_navigation_view_docked_context_changed,
view);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (gimp_navigation_view_docked_context_changed),
view);
gdisp = gimp_context_get_display (context);
}
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_destroy (GtkObject *object)
{

View file

@ -33,8 +33,10 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
@ -54,6 +56,11 @@
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
static void gimp_navigation_view_init (GimpNavigationView *view);
static void gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_navigation_view_destroy (GtkObject *object);
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
@ -103,9 +110,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_navigation_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
@ -119,13 +126,22 @@ gimp_navigation_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_navigation_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_navigation_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
@ -173,6 +189,54 @@ gimp_navigation_view_init (GimpNavigationView *view)
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
}
static void
gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_navigation_view_set_docked_context;
}
static void
gimp_navigation_view_docked_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
if (prev_context)
g_signal_handlers_disconnect_by_func (prev_context,
gimp_navigation_view_docked_context_changed,
view);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (gimp_navigation_view_docked_context_changed),
view);
gdisp = gimp_context_get_display (context);
}
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_destroy (GtkObject *object)
{

View file

@ -18,11 +18,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
@ -33,7 +30,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
#include "vectors/gimpvectors.h"
@ -55,14 +51,10 @@
#include "widgets/gimpitemtreeview.h"
#include "widgets/gimpdevicestatus.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocumentview.h"
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h"
@ -94,52 +86,15 @@
/* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id);
static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer data);
static GtkWidget * dialogs_tool_options_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer data);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_color_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_image_item_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_image_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context);
static GimpItemFactory * dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id,
GimpDockableGetPreviewFunc get_preview_func,
gpointer get_preview_data,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func);
static void dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view);
static void dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable);
/**********************/
@ -259,10 +214,7 @@ dialogs_tool_options_get (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Tool Options"), NULL,
GIMP_STOCK_TOOL_OPTIONS,
GIMP_HELP_TOOL_OPTIONS_DIALOG,
dialogs_tool_options_preview_func, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_TOOL_OPTIONS_DIALOG);
}
GtkWidget *
@ -282,9 +234,7 @@ dialogs_device_status_get (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Devices"), _("Device Status"),
GIMP_STOCK_DEVICE_STATUS,
GIMP_HELP_DEVICE_STATUS_DIALOG,
NULL, NULL,
NULL, NULL);
GIMP_HELP_DEVICE_STATUS_DIALOG);
}
GtkWidget *
@ -304,10 +254,7 @@ dialogs_error_console_get (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Errors"), _("Error Console"),
GIMP_STOCK_WARNING,
GIMP_HELP_ERRORS_DIALOG,
NULL, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_ERRORS_DIALOG);
}
@ -329,10 +276,7 @@ dialogs_image_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Images"), NULL,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_IMAGE_DIALOG);
}
GtkWidget *
@ -353,10 +297,7 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Brushes"), NULL,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BRUSH_DIALOG);
}
GtkWidget *
@ -376,10 +317,7 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Patterns"), NULL,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PATTERN_DIALOG);
}
GtkWidget *
@ -399,10 +337,7 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Gradients"), NULL,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_GRADIENT_DIALOG);
}
GtkWidget *
@ -422,10 +357,7 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Palettes"), NULL,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PALETTE_DIALOG);
}
GtkWidget *
@ -443,10 +375,7 @@ dialogs_font_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Fonts"), NULL,
GTK_STOCK_SELECT_FONT,
GIMP_HELP_FONT_DIALOG,
dialogs_viewable_preview_func, "font",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_FONT_DIALOG);
}
GtkWidget *
@ -464,10 +393,7 @@ dialogs_tool_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Tools"), NULL,
GTK_STOCK_MISSING_IMAGE,
GIMP_HELP_TOOL_DIALOG,
dialogs_viewable_preview_func, "tool",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_TOOL_DIALOG);
}
GtkWidget *
@ -486,10 +412,7 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Buffers"), NULL,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BUFFER_DIALOG);
}
GtkWidget *
@ -509,10 +432,7 @@ dialogs_document_list_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("History"), _("Document History"),
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_DOCUMENT_DIALOG);
}
GtkWidget *
@ -538,10 +458,7 @@ dialogs_template_list_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Templates"), NULL,
GIMP_STOCK_TEMPLATE,
GIMP_HELP_TEMPLATE_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_TEMPLATE_DIALOG);
}
@ -563,10 +480,7 @@ dialogs_image_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Images"), NULL,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_IMAGE_DIALOG);
}
GtkWidget *
@ -587,10 +501,7 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Brushes"), NULL,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BRUSH_DIALOG);
}
GtkWidget *
@ -610,10 +521,7 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Patterns"), NULL,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PATTERN_DIALOG);
}
GtkWidget *
@ -633,10 +541,7 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Gradients"), NULL,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_GRADIENT_DIALOG);
}
GtkWidget *
@ -656,10 +561,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Palettes"), NULL,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PALETTE_DIALOG);
}
GtkWidget *
@ -677,10 +579,7 @@ dialogs_font_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Fonts"), NULL,
GTK_STOCK_SELECT_FONT,
GIMP_HELP_FONT_DIALOG,
dialogs_viewable_preview_func, "font",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_FONT_DIALOG);
}
GtkWidget *
@ -698,10 +597,7 @@ dialogs_tool_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Tools"), NULL,
GTK_STOCK_MISSING_IMAGE,
GIMP_HELP_TOOL_DIALOG,
dialogs_viewable_preview_func, "tool",
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_TOOL_DIALOG);
}
GtkWidget *
@ -720,10 +616,7 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Buffers"), NULL,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_BUFFER_DIALOG);
}
GtkWidget *
@ -743,10 +636,7 @@ dialogs_document_grid_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("History"), _("Document History"),
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_DOCUMENT_DIALOG);
}
@ -757,18 +647,15 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
if (preview_size < 1)
preview_size = context->gimp->config->layer_preview_size;
view =
gimp_item_tree_view_new (preview_size, 2,
gimage,
gimp_context_get_image (context),
GIMP_TYPE_LAYER,
"active_layer_changed",
(GimpEditItemFunc) layers_edit_layer_query,
@ -779,10 +666,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Layers"), NULL,
GIMP_STOCK_LAYERS,
GIMP_HELP_LAYER_DIALOG,
NULL, NULL,
dialogs_set_image_item_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_LAYER_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -794,18 +678,15 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
if (preview_size < 1)
preview_size = context->gimp->config->layer_preview_size;
view =
gimp_item_tree_view_new (preview_size, 1,
gimage,
gimp_context_get_image (context),
GIMP_TYPE_CHANNEL,
"active_channel_changed",
(GimpEditItemFunc) channels_edit_channel_query,
@ -816,10 +697,7 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Channels"), NULL,
GIMP_STOCK_CHANNELS,
GIMP_HELP_CHANNEL_DIALOG,
NULL, NULL,
dialogs_set_image_item_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_CHANNEL_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -831,19 +709,16 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GimpVectorsTreeView *vectors_view;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
if (preview_size < 1)
preview_size = context->gimp->config->layer_preview_size;
view =
gimp_item_tree_view_new (preview_size, 1,
gimage,
gimp_context_get_image (context),
GIMP_TYPE_VECTORS,
"active_vectors_changed",
(GimpEditItemFunc) vectors_edit_vectors_query,
@ -859,10 +734,7 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Paths"), NULL,
GIMP_STOCK_PATHS,
GIMP_HELP_PATH_DIALOG,
NULL, NULL,
dialogs_set_image_item_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_PATH_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -874,21 +746,16 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
view = gimp_colormap_editor_new (gimage, factory->menu_factory);
view = gimp_colormap_editor_new (gimp_context_get_image (context),
factory->menu_factory);
dockable = dialogs_dockable_new (view,
_("Colormap"), _("Indexed Palette"),
GIMP_STOCK_INDEXED_PALETTE,
GIMP_HELP_INDEXED_PALETTE_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
dialogs_get_view_menu_func);
GIMP_HELP_INDEXED_PALETTE_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -904,14 +771,11 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GimpSelectionEditor *selection_editor;
GtkWidget *view;
GtkWidget *dockable;
GimpSelectionEditor *selection_editor;
gimage = gimp_context_get_image (context);
view = gimp_selection_editor_new (gimage);
view = gimp_selection_editor_new (gimp_context_get_image (context));
selection_editor = GIMP_SELECTION_EDITOR (view);
@ -921,10 +785,7 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Selection"), _("Selection Editor"),
GIMP_STOCK_TOOL_RECT_SELECT,
GIMP_HELP_SELECTION_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
NULL);
GIMP_HELP_SELECTION_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -936,21 +797,15 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
view = gimp_undo_editor_new (gimage);
view = gimp_undo_editor_new (gimp_context_get_image (context));
dockable = dialogs_dockable_new (view,
_("Undo"), _("Undo History"),
GIMP_STOCK_UNDO_HISTORY,
GIMP_HELP_UNDO_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
NULL);
GIMP_HELP_UNDO_DIALOG);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -980,10 +835,7 @@ dialogs_navigation_view_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("Navigation"), _("Display Navigation"),
GIMP_STOCK_NAVIGATION,
GIMP_HELP_NAVIGATION_DIALOG,
NULL, NULL,
dialogs_set_navigation_context_func,
NULL);
GIMP_HELP_NAVIGATION_DIALOG);
}
@ -1001,10 +853,7 @@ dialogs_color_editor_new (GimpDialogFactory *factory,
return dialogs_dockable_new (view,
_("FG/BG"), _("FG/BG Color"),
GIMP_STOCK_DEFAULT_COLORS,
GIMP_HELP_COLOR_DIALOG,
NULL, NULL,
dialogs_set_color_editor_context_func,
NULL);
GIMP_HELP_COLOR_DIALOG);
}
@ -1024,9 +873,7 @@ dialogs_brush_editor_get (GimpDialogFactory *factory,
return dialogs_dockable_new (GTK_WIDGET (brush_editor),
_("Brush Editor"), NULL,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_EDITOR_DIALOG,
NULL, NULL,
NULL, NULL);
GIMP_HELP_BRUSH_EDITOR_DIALOG);
}
void
@ -1055,10 +902,7 @@ dialogs_gradient_editor_get (GimpDialogFactory *factory,
return dialogs_dockable_new (GTK_WIDGET (gradient_editor),
_("Gradient Editor"), NULL,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_EDITOR_DIALOG,
NULL, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_GRADIENT_EDITOR_DIALOG);
}
void
@ -1087,10 +931,7 @@ dialogs_palette_editor_get (GimpDialogFactory *factory,
return dialogs_dockable_new (GTK_WIDGET (palette_editor),
_("Palette Editor"), NULL,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_EDITOR_DIALOG,
NULL, NULL,
NULL,
dialogs_get_view_menu_func);
GIMP_HELP_PALETTE_EDITOR_DIALOG);
}
void
@ -1106,14 +947,28 @@ dialogs_edit_palette_func (GimpData *data)
/* private functions */
static GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id)
{
GtkWidget *dockable;
dockable = gimp_dockable_new (name, blurb, stock_id, help_id);
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
return dockable;
}
static void
dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable)
{
GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage)
{
@ -1130,275 +985,3 @@ dialogs_indexed_palette_selected (GimpColormapEditor *editor,
gimp_context_set_foreground (dockable->context, &color);
}
}
static GtkWidget *
dialogs_viewable_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer preview_data)
{
GtkWidget *preview;
gint width;
gint height;
const gchar *prop_name;
gboolean is_tool;
gtk_icon_size_lookup (size, &width, &height);
prop_name = (const gchar *) preview_data;
is_tool = (strcmp (prop_name, "tool") == 0);
preview = gimp_prop_preview_new (G_OBJECT (context), prop_name, height);
GIMP_PREVIEW (preview)->renderer->size = -1;
gimp_preview_renderer_set_size_full (GIMP_PREVIEW (preview)->renderer,
width, height,
is_tool ? 0 : 1);
return preview;
}
static void
dialogs_tool_options_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
GtkLabel *label)
{
GtkImage *image;
if ((image = g_object_get_data (G_OBJECT (label), "tool-icon")))
{
const gchar *stock_id;
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
gtk_image_set_from_stock (image, stock_id, image->icon_size);
}
gtk_label_set_text (label, tool_info->blurb);
gimp_help_set_help_data (GTK_WIDGET (label)->parent->parent,
tool_info->help, tool_info->help_id);
}
static GtkWidget *
dialogs_tool_options_preview_func (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer preview_data)
{
GimpToolInfo *tool_info;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
gint width;
gint height;
const gchar *stock_id;
gtk_icon_size_lookup (size, &width, &height);
tool_info = gimp_context_get_tool (context);
hbox = gtk_hbox_new (FALSE, 2);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
image = gtk_image_new_from_stock (stock_id, size);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = gtk_label_new (tool_info->blurb);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_set_data (G_OBJECT (label), "tool-icon", image);
g_signal_connect_object (context, "tool_changed",
G_CALLBACK (dialogs_tool_options_tool_changed),
label,
0);
return hbox;
}
static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
if (view)
gimp_container_view_set_context (view, context);
}
static void
dialogs_set_color_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
if (GIMP_IS_COLOR_EDITOR (widget))
gimp_color_editor_set_context (GIMP_COLOR_EDITOR (widget), context);
}
static void
dialogs_set_image_item_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpImage *gimage = NULL;
if (! GIMP_IS_CONTAINER_VIEW (widget))
return;
if (dockable->context)
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_item_view_image_changed,
widget);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_item_view_image_changed),
widget);
gimage = gimp_context_get_image (context);
}
dialogs_image_item_view_image_changed (context, gimage,
GIMP_CONTAINER_VIEW (widget));
}
static void
dialogs_set_image_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpImage *gimage = NULL;
if (! GIMP_IS_IMAGE_EDITOR (widget))
return;
if (dockable->context)
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_editor_image_changed,
widget);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_editor_image_changed),
widget);
gimage = gimp_context_get_image (context);
}
dialogs_image_editor_image_changed (context, gimage,
GIMP_IMAGE_EDITOR (widget));
}
static void
dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpDisplay *gdisp = NULL;
if (! GIMP_IS_NAVIGATION_VIEW (widget))
return;
if (dockable->context)
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_navigation_display_changed,
widget);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (dialogs_navigation_display_changed),
widget);
gdisp = gimp_context_get_display (context);
}
dialogs_navigation_display_changed (context, gdisp,
GIMP_NAVIGATION_VIEW (widget));
}
static GimpItemFactory *
dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpEditor *editor = NULL;
if (GIMP_IS_EDITOR (widget))
{
editor = GIMP_EDITOR (widget);
}
else if (GIMP_IS_CONTAINER_EDITOR (widget))
{
editor = GIMP_EDITOR (GIMP_CONTAINER_EDITOR (widget)->view);
}
if (editor)
{
if (item_factory_data)
*item_factory_data = editor->item_factory_data;
return editor->item_factory;
}
return NULL;
}
static GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id,
GimpDockableGetPreviewFunc get_preview_func,
gpointer get_preview_data,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func)
{
GtkWidget *dockable;
dockable = gimp_dockable_new (name, blurb, stock_id, help_id,
get_preview_func,
get_preview_data,
set_context_func,
get_menu_func);
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
return dockable;
}
static void
dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_item_tree_view_set_image (GIMP_ITEM_TREE_VIEW (view), gimage);
}
static void
dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor)
{
gimp_image_editor_set_image (editor, gimage);
}
static void
dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}

View file

@ -31,6 +31,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpitemfactory.h"
@ -325,8 +326,10 @@ dialogs_menu_update (GtkItemFactory *factory,
else if (tab_style == GIMP_TAB_STYLE_PREVIEW_NAME)
SET_ACTIVE ("/Tab Style/Status & Text", TRUE);
SET_SENSITIVE ("/Tab Style/Current Status", dockable->get_preview_func);
SET_SENSITIVE ("/Tab Style/Status & Text", dockable->get_preview_func);
SET_SENSITIVE ("/Tab Style/Current Status",
GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child)->get_preview);
SET_SENSITIVE ("/Tab Style/Status & Text",
GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child)->get_preview);
SET_VISIBLE ("/View as Grid", view_type != -1);
SET_VISIBLE ("/View as List", view_type != -1);

View file

@ -79,6 +79,8 @@ libappwidgets_a_sources = \
gimpdockable.h \
gimpdockbook.c \
gimpdockbook.h \
gimpdocked.c \
gimpdocked.h \
gimpdocumentview.c \
gimpdocumentview.h \
gimpdrawabletreeview.c \

View file

@ -32,15 +32,21 @@
#include "core/gimpcontext.h"
#include "gimpcoloreditor.h"
#include "gimpdocked.h"
#include "gimp-intl.h"
static void gimp_color_editor_class_init (GimpColorEditorClass *klass);
static void gimp_color_editor_init (GimpColorEditor *editor);
static void gimp_color_editor_class_init (GimpColorEditorClass *klass);
static void gimp_color_editor_init (GimpColorEditor *editor);
static void gimp_color_editor_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_color_editor_destroy (GtkObject *object);
static void gimp_color_editor_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_color_editor_fg_changed (GimpContext *context,
const GimpRGB *rgb,
GimpColorEditor *editor);
@ -68,9 +74,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_color_editor_get_type (void)
{
static GType editor_type = 0;
static GType type = 0;
if (! editor_type)
if (! type)
{
static const GTypeInfo editor_info =
{
@ -84,13 +90,22 @@ gimp_color_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_color_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpColorEditor",
&editor_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpColorEditor",
&editor_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return editor_type;
return type;
}
static void
@ -270,6 +285,12 @@ gimp_color_editor_init (GimpColorEditor *editor)
}
}
static void
gimp_color_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_color_editor_set_docked_context;
}
static void
gimp_color_editor_destroy (GtkObject *object)
{
@ -283,6 +304,14 @@ gimp_color_editor_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_color_editor_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
gimp_color_editor_set_context (GIMP_COLOR_EDITOR (docked), context);
}
/* public functions */

View file

@ -34,13 +34,15 @@
#include "gimpcontainereditor.h"
#include "gimpcontainergridview.h"
#include "gimpcontainertreeview.h"
#include "gimpdocked.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
#include "gimppreviewrenderer.h"
static void gimp_container_editor_class_init (GimpContainerEditorClass *klass);
static void gimp_container_editor_init (GimpContainerEditor *view);
static void gimp_container_editor_class_init (GimpContainerEditorClass *klass);
static void gimp_container_editor_init (GimpContainerEditor *view);
static void gimp_container_editor_docked_iface_init (GimpDockedIface *docked_iface);
static gboolean gimp_container_editor_select_item (GtkWidget *widget,
GimpViewable *viewable,
@ -57,6 +59,15 @@ static void gimp_container_editor_context_item (GtkWidget *widge
static void gimp_container_editor_real_context_item(GimpContainerEditor *editor,
GimpViewable *viewable);
static GtkWidget * gimp_container_editor_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
static void gimp_container_editor_set_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static GimpItemFactory * gimp_container_editor_get_menu (GimpDocked *docked,
gpointer *item_factory_data);
static GtkVBoxClass *parent_class = NULL;
@ -64,9 +75,9 @@ static GtkVBoxClass *parent_class = NULL;
GType
gimp_container_editor_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
@ -80,13 +91,22 @@ gimp_container_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_container_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_container_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
view_type = g_type_register_static (GTK_TYPE_VBOX,
"GimpContainerEditor",
&view_info, 0);
type = g_type_register_static (GTK_TYPE_VBOX,
"GimpContainerEditor",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
@ -105,6 +125,14 @@ gimp_container_editor_init (GimpContainerEditor *view)
view->view = NULL;
}
static void
gimp_container_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->get_preview = gimp_container_editor_get_preview;
docked_iface->set_context = gimp_container_editor_set_context;
docked_iface->get_menu = gimp_container_editor_get_menu;
}
gboolean
gimp_container_editor_construct (GimpContainerEditor *editor,
GimpViewType view_type,
@ -239,3 +267,35 @@ gimp_container_editor_real_context_item (GimpContainerEditor *editor,
NULL, NULL, NULL);
}
}
static GtkWidget *
gimp_container_editor_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
return gimp_docked_get_preview (GIMP_DOCKED (editor->view),
context, size);
}
static void
gimp_container_editor_set_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
gimp_docked_set_context (GIMP_DOCKED (editor->view),
context, prev_context);
}
static GimpItemFactory *
gimp_container_editor_get_menu (GimpDocked *docked,
gpointer *item_factory_data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
return gimp_docked_get_menu (GIMP_DOCKED (editor->view),
item_factory_data);
}

View file

@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -34,7 +36,10 @@
#include "gimpcontainerview.h"
#include "gimpdnd.h"
#include "gimpdocked.h"
#include "gimppreview.h"
#include "gimppreviewrenderer.h"
#include "gimppropwidgets.h"
enum
@ -46,9 +51,10 @@ enum
};
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
static void gimp_container_view_init (GimpContainerView *view,
GimpContainerViewClass *klass);
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
static void gimp_container_view_init (GimpContainerView *view,
GimpContainerViewClass *klass);
static void gimp_container_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_container_view_destroy (GtkObject *object);
@ -71,6 +77,13 @@ static void gimp_container_view_reorder (GimpContainerView *view,
gint new_index,
GimpContainer *container);
static GtkWidget * gimp_container_view_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
static void gimp_container_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_container_view_context_changed (GimpContext *context,
GimpViewable *viewable,
GimpContainerView *view);
@ -90,9 +103,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_container_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
@ -106,13 +119,22 @@ gimp_container_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_container_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_container_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpContainerView",
&view_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpContainerView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
@ -219,6 +241,13 @@ gimp_container_view_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_container_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->get_preview = gimp_container_view_get_preview;
docked_iface->set_context = gimp_container_view_set_docked_context;
}
void
gimp_container_view_set_container (GimpContainerView *view,
GimpContainer *container)
@ -688,6 +717,41 @@ gimp_container_view_reorder (GimpContainerView *view,
}
}
static void
gimp_container_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
gimp_container_view_set_context (GIMP_CONTAINER_VIEW (docked), context);
}
static GtkWidget *
gimp_container_view_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size)
{
GimpContainerView *view = GIMP_CONTAINER_VIEW (docked);
GtkWidget *preview;
gint width;
gint height;
const gchar *prop_name;
gboolean is_tool;
gtk_icon_size_lookup (size, &width, &height);
prop_name = gimp_context_type_to_prop_name (view->container->children_type);
is_tool = (strcmp (prop_name, "tool") == 0);
preview = gimp_prop_preview_new (G_OBJECT (context), prop_name, height);
GIMP_PREVIEW (preview)->renderer->size = -1;
gimp_preview_renderer_set_size_full (GIMP_PREVIEW (preview)->renderer,
width, height,
is_tool ? 0 : 1);
return preview;
}
static void
gimp_container_view_context_changed (GimpContext *context,
GimpViewable *viewable,

View file

@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdockable.c
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -34,60 +34,50 @@
#include "gimpdock.h"
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpdocked.h"
#include "gimpitemfactory.h"
#include "gimpwidgets-utils.h"
static void gimp_dockable_class_init (GimpDockableClass *klass);
static void gimp_dockable_init (GimpDockable *dockable);
static void gimp_dockable_class_init (GimpDockableClass *klass);
static void gimp_dockable_init (GimpDockable *dockable);
static void gimp_dockable_destroy (GtkObject *object);
static void gimp_dockable_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gimp_dockable_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_dockable_realize (GtkWidget *widget);
static void gimp_dockable_unrealize (GtkWidget *widget);
static void gimp_dockable_map (GtkWidget *widget);
static void gimp_dockable_unmap (GtkWidget *widget);
static void gimp_dockable_destroy (GtkObject *object);
static void gimp_dockable_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gimp_dockable_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_dockable_realize (GtkWidget *widget);
static void gimp_dockable_unrealize (GtkWidget *widget);
static void gimp_dockable_map (GtkWidget *widget);
static void gimp_dockable_unmap (GtkWidget *widget);
static gboolean gimp_dockable_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static void gimp_dockable_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static gboolean gimp_dockable_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static gboolean gimp_dockable_popup_menu (GtkWidget *widget);
static gboolean gimp_dockable_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static void gimp_dockable_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static gboolean gimp_dockable_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static gboolean gimp_dockable_popup_menu (GtkWidget *widget);
static void gimp_dockable_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static GType gimp_dockable_child_type (GtkContainer *container);
static void gimp_dockable_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gimp_dockable_get_title_area (GimpDockable *dockable,
GdkRectangle *area);
static void gimp_dockable_get_title_area (GimpDockable *dockable,
GdkRectangle *area);
static void gimp_dockable_real_set_aux_info (GimpDockable *dockable,
GList *aux_info);
static GList * gimp_dockable_real_get_aux_info (GimpDockable *dockable);
static GtkWidget * gimp_dockable_real_get_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
static void gimp_dockable_real_set_context (GimpDockable *dockable,
GimpContext *context);
static GimpItemFactory * gimp_dockable_real_get_menu (GimpDockable *dockable,
gpointer *item_factory_data);
static gboolean gimp_dockable_menu_button_press (GtkWidget *button,
GdkEventButton *bevent,
GimpDockable *dockable);
static void gimp_dockable_close_clicked (GtkWidget *button,
GimpDockable *dockable);
static gboolean gimp_dockable_show_menu (GimpDockable *dockable);
static gboolean gimp_dockable_menu_button_press (GtkWidget *button,
GdkEventButton *bevent,
GimpDockable *dockable);
static void gimp_dockable_close_clicked (GtkWidget *button,
GimpDockable *dockable);
static gboolean gimp_dockable_show_menu (GimpDockable *dockable);
static GtkBinClass *parent_class = NULL;
@ -152,14 +142,9 @@ gimp_dockable_class_init (GimpDockableClass *klass)
widget_class->expose_event = gimp_dockable_expose_event;
widget_class->popup_menu = gimp_dockable_popup_menu;
container_class->child_type = gimp_dockable_child_type;
container_class->forall = gimp_dockable_forall;
klass->get_aux_info = gimp_dockable_real_get_aux_info;
klass->set_aux_info = gimp_dockable_real_set_aux_info;
klass->get_tab_widget = gimp_dockable_real_get_tab_widget;
klass->set_context = gimp_dockable_real_set_context;
klass->get_menu = gimp_dockable_real_get_menu;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("content_border",
NULL, NULL,
@ -174,19 +159,16 @@ gimp_dockable_init (GimpDockable *dockable)
{
GtkWidget *image;
dockable->name = NULL;
dockable->blurb = NULL;
dockable->stock_id = NULL;
dockable->help_id = NULL;
dockable->tab_style = GIMP_TAB_STYLE_PREVIEW;
dockable->dockbook = NULL;
dockable->context = NULL;
dockable->get_preview_func = NULL;
dockable->get_preview_data = NULL;
dockable->set_context_func = NULL;
dockable->name = NULL;
dockable->blurb = NULL;
dockable->stock_id = NULL;
dockable->help_id = NULL;
dockable->tab_style = GIMP_TAB_STYLE_PREVIEW;
dockable->dockbook = NULL;
dockable->context = NULL;
dockable->title_layout = NULL;
dockable->title_window = NULL;
dockable->title_layout = NULL;
dockable->title_window = NULL;
gtk_widget_push_composite_child ();
dockable->menu_button = gtk_button_new ();
@ -565,6 +547,15 @@ gimp_dockable_popup_menu (GtkWidget *widget)
return gimp_dockable_show_menu (GIMP_DOCKABLE (widget));
}
static GType
gimp_dockable_child_type (GtkContainer *container)
{
if (GTK_BIN (container)->child)
return G_TYPE_NONE;
return GIMP_TYPE_DOCKED;
}
static void
gimp_dockable_forall (GtkContainer *container,
gboolean include_internals,
@ -587,14 +578,10 @@ gimp_dockable_forall (GtkContainer *container,
}
GtkWidget *
gimp_dockable_new (const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id,
GimpDockableGetPreviewFunc get_preview_func,
gpointer get_preview_data,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func)
gimp_dockable_new (const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id)
{
GimpDockable *dockable;
@ -613,29 +600,6 @@ gimp_dockable_new (const gchar *name,
else
dockable->blurb = dockable->name;
dockable->get_preview_func = get_preview_func;
dockable->get_preview_data = get_preview_data;
dockable->set_context_func = set_context_func;
dockable->get_menu_func = get_menu_func;
if (! get_preview_func)
{
switch (dockable->tab_style)
{
case GIMP_TAB_STYLE_PREVIEW:
dockable->tab_style = GIMP_TAB_STYLE_ICON;
break;
case GIMP_TAB_STYLE_PREVIEW_NAME:
dockable->tab_style = GIMP_TAB_STYLE_ICON_BLURB;
break;
case GIMP_TAB_STYLE_PREVIEW_BLURB:
dockable->tab_style = GIMP_TAB_STYLE_ICON_BLURB;
break;
default:
break;
}
}
gimp_help_set_help_data (GTK_WIDGET (dockable), NULL, help_id);
return GTK_WIDGET (dockable);
@ -647,7 +611,9 @@ gimp_dockable_set_aux_info (GimpDockable *dockable,
{
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
GIMP_DOCKABLE_GET_CLASS (dockable)->set_aux_info (dockable, aux_info);
if (GTK_BIN (dockable)->child)
gimp_docked_set_aux_info (GIMP_DOCKED (GTK_BIN (dockable)->child),
aux_info);
}
GList *
@ -655,7 +621,11 @@ gimp_dockable_get_aux_info (GimpDockable *dockable)
{
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
return GIMP_DOCKABLE_GET_CLASS (dockable)->get_aux_info (dockable);
if (GTK_BIN (dockable)->child)
return gimp_docked_get_aux_info (GIMP_DOCKED (GTK_BIN (dockable)->child));
return NULL;
}
GtkWidget *
@ -664,11 +634,81 @@ gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpTabStyle tab_style,
GtkIconSize size)
{
GtkWidget *tab_widget = NULL;
GtkWidget *label = NULL;
GtkWidget *icon = NULL;
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return GIMP_DOCKABLE_GET_CLASS (dockable)->get_tab_widget (dockable, context,
tab_style, size);
switch (tab_style)
{
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_PREVIEW_NAME:
label = gtk_label_new (dockable->name);
break;
case GIMP_TAB_STYLE_BLURB:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
label = gtk_label_new (dockable->blurb);
break;
default:
break;
}
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
case GIMP_TAB_STYLE_PREVIEW:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
if (GTK_BIN (dockable)->child)
icon = gimp_docked_get_preview (GIMP_DOCKED (GTK_BIN (dockable)->child),
context, size);
if (! icon)
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
default:
break;
}
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_PREVIEW:
tab_widget = icon;
break;
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_BLURB:
tab_widget = label;
break;
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
tab_widget = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (tab_widget), icon, FALSE, FALSE, 0);
gtk_widget_show (icon);
gtk_box_pack_start (GTK_BOX (tab_widget), label, FALSE, FALSE, 0);
gtk_widget_show (label);
break;
}
return tab_widget;
}
void
@ -678,8 +718,13 @@ gimp_dockable_set_context (GimpDockable *dockable,
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
if (context != dockable->context)
GIMP_DOCKABLE_GET_CLASS (dockable)->set_context (dockable, context);
if (context != dockable->context && GTK_BIN (dockable)->child)
{
gimp_docked_set_context (GIMP_DOCKED (GTK_BIN (dockable)->child),
context, dockable->context);
}
dockable->context = context;
}
GimpItemFactory *
@ -689,8 +734,11 @@ gimp_dockable_get_menu (GimpDockable *dockable,
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
g_return_val_if_fail (item_factory_data != NULL, NULL);
return GIMP_DOCKABLE_GET_CLASS (dockable)->get_menu (dockable,
item_factory_data);
if (GTK_BIN (dockable)->child)
return gimp_docked_get_menu (GIMP_DOCKED (GTK_BIN (dockable)->child),
item_factory_data);
return NULL;
}
void
@ -742,127 +790,6 @@ gimp_dockable_get_title_area (GimpDockable *dockable,
area->x += 2 * dockable->close_button->allocation.width;
}
static void
gimp_dockable_real_set_aux_info (GimpDockable *dockable,
GList *aux_info)
{
GList *aux;
for (aux = aux_info; aux; aux = g_list_next (aux))
{
gchar *str = (gchar *) aux->data;
g_print ("dockable %s aux_info: %s\n", dockable->name, str);
}
}
static GList *
gimp_dockable_real_get_aux_info (GimpDockable *dockable)
{
GList *aux = NULL;
return aux;
}
static GtkWidget *
gimp_dockable_real_get_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size)
{
GtkWidget *tab_widget = NULL;
GtkWidget *label = NULL;
GtkWidget *icon = NULL;
switch (tab_style)
{
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_PREVIEW_NAME:
label = gtk_label_new (dockable->name);
break;
case GIMP_TAB_STYLE_BLURB:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
label = gtk_label_new (dockable->blurb);
break;
default:
break;
}
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
case GIMP_TAB_STYLE_PREVIEW:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
if (dockable->get_preview_func)
icon = dockable->get_preview_func (dockable, context, size,
dockable->get_preview_data);
else
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
default:
break;
}
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_PREVIEW:
tab_widget = icon;
break;
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_BLURB:
tab_widget = label;
break;
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
tab_widget = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (tab_widget), icon, FALSE, FALSE, 0);
gtk_widget_show (icon);
gtk_box_pack_start (GTK_BOX (tab_widget), label, FALSE, FALSE, 0);
gtk_widget_show (label);
break;
}
return tab_widget;
}
static void
gimp_dockable_real_set_context (GimpDockable *dockable,
GimpContext *context)
{
if (dockable->set_context_func)
dockable->set_context_func (dockable, context);
dockable->context = context;
}
static GimpItemFactory *
gimp_dockable_real_get_menu (GimpDockable *dockable,
gpointer *item_factory_data)
{
if (dockable->get_menu_func)
return dockable->get_menu_func (dockable, item_factory_data);
return NULL;
}
static gboolean
gimp_dockable_menu_button_press (GtkWidget *button,
GdkEventButton *bevent,

View file

@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdockable.h
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,16 +26,6 @@
#include <gtk/gtkbin.h>
typedef GtkWidget * (* GimpDockableGetPreviewFunc) (GimpDockable *dockable,
GimpContext *context,
GtkIconSize size,
gpointer get_preview_data);
typedef void (* GimpDockableSetContextFunc) (GimpDockable *dockable,
GimpContext *context);
typedef GimpItemFactory * (* GimpDockableGetMenuFunc) (GimpDockable *dockable,
gpointer *item_factory_data);
#define GIMP_TYPE_DOCKABLE (gimp_dockable_get_type ())
#define GIMP_DOCKABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DOCKABLE, GimpDockable))
#define GIMP_DOCKABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DOCKABLE, GimpDockableClass))
@ -64,42 +54,20 @@ struct _GimpDockable
GdkWindow *title_window;
GtkWidget *menu_button;
GtkWidget *close_button;
GimpDockableGetPreviewFunc get_preview_func;
gpointer get_preview_data;
GimpDockableSetContextFunc set_context_func;
GimpDockableGetMenuFunc get_menu_func;
};
struct _GimpDockableClass
{
GtkBinClass parent_class;
void (* set_aux_info) (GimpDockable *dockable,
GList *aux_info);
GList * (* get_aux_info) (GimpDockable *dockable);
GtkWidget * (* get_tab_widget) (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
void (* set_context) (GimpDockable *dockable,
GimpContext *context);
GimpItemFactory * (* get_menu) (GimpDockable *dockable,
gpointer *item_factory_data);
};
GType gimp_dockable_get_type (void) G_GNUC_CONST;
GType gimp_dockable_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_dockable_new (const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id,
GimpDockableGetPreviewFunc get_preview_func,
gpointer get_preview_data,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func);
GtkWidget * gimp_dockable_new (const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id);
void gimp_dockable_set_aux_info (GimpDockable *dockable,
GList *aux_info);

149
app/widgets/gimpdocked.c Normal file
View file

@ -0,0 +1,149 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdocked.c
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "gimpdocked.h"
static void gimp_docked_iface_init (GimpDockedIface *docked_iface);
GType
gimp_docked_interface_get_type (void)
{
static GType docked_iface_type = 0;
if (!docked_iface_type)
{
static const GTypeInfo docked_iface_info =
{
sizeof (GimpDockedIface),
(GBaseInitFunc) gimp_docked_iface_init,
(GBaseFinalizeFunc) NULL,
};
docked_iface_type = g_type_register_static (G_TYPE_INTERFACE,
"GimpDockedInterface",
&docked_iface_info,
0);
g_type_interface_add_prerequisite (docked_iface_type, GTK_TYPE_WIDGET);
}
return docked_iface_type;
}
static void
gimp_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_aux_info = NULL;
docked_iface->get_aux_info = NULL;
docked_iface->get_preview = NULL;
docked_iface->set_context = NULL;
docked_iface->get_menu = NULL;
}
void
gimp_docked_set_aux_info (GimpDocked *docked,
GList *aux_info)
{
GimpDockedIface *docked_iface;
g_return_if_fail (GIMP_IS_DOCKED (docked));
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->set_aux_info)
docked_iface->set_aux_info (docked, aux_info);
}
GList *
gimp_docked_get_aux_info (GimpDocked *docked)
{
GimpDockedIface *docked_iface;
g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->get_aux_info)
return docked_iface->get_aux_info (docked);
return NULL;
}
GtkWidget *
gimp_docked_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size)
{
GimpDockedIface *docked_iface;
g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->get_preview)
return docked_iface->get_preview (docked, context, size);
return NULL;
}
void
gimp_docked_set_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpDockedIface *docked_iface;
g_return_if_fail (GIMP_IS_DOCKED (docked));
g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
g_return_if_fail (prev_context == NULL || GIMP_IS_CONTEXT (prev_context));
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->set_context)
docked_iface->set_context (docked, context, prev_context);
}
GimpItemFactory *
gimp_docked_get_menu (GimpDocked *docked,
gpointer *item_factory_data)
{
GimpDockedIface *docked_iface;
g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
g_return_val_if_fail (item_factory_data != NULL, NULL);
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->get_menu)
return docked_iface->get_menu (docked, item_factory_data);
return NULL;
}

67
app/widgets/gimpdocked.h Normal file
View file

@ -0,0 +1,67 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* gimpdocked.h
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DOCKED_H__
#define __GIMP_DOCKED_H__
#define GIMP_TYPE_DOCKED (gimp_docked_interface_get_type ())
#define GIMP_IS_DOCKED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DOCKED))
#define GIMP_DOCKED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DOCKED, GimpDocked))
#define GIMP_DOCKED_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_DOCKED, GimpDockedIface))
struct _GimpDockedIface
{
GTypeInterface base_iface;
void (* set_aux_info) (GimpDocked *docked,
GList *aux_info);
GList * (* get_aux_info) (GimpDocked *docked);
GtkWidget * (* get_preview) (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
void (* set_context) (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
GimpItemFactory * (* get_menu) (GimpDocked *docked,
gpointer *item_factory_data);
};
GType gimp_docked_interface_get_type (void) G_GNUC_CONST;
void gimp_docked_set_aux_info (GimpDocked *docked,
GList *aux_info);
GList * gimp_docked_get_aux_info (GimpDocked *docked);
GtkWidget * gimp_docked_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
void gimp_docked_set_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
GimpItemFactory * gimp_docked_get_menu (GimpDocked *docked,
gpointer *item_factory_data);
#endif /* __GIMP_DOCKED_H__ */

View file

@ -27,6 +27,7 @@
#include "widgets-types.h"
#include "gimpdocked.h"
#include "gimpeditor.h"
#include "gimpdnd.h"
#include "gimpenummenu.h"
@ -40,11 +41,15 @@
static void gimp_editor_class_init (GimpEditorClass *klass);
static void gimp_editor_init (GimpEditor *editor);
static void gimp_editor_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_editor_destroy (GtkObject *object);
static void gimp_editor_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static GimpItemFactory * gimp_editor_get_menu (GimpDocked *docked,
gpointer *item_factory_data);
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
@ -70,10 +75,19 @@ gimp_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GTK_TYPE_VBOX,
"GimpEditor",
&info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return type;
@ -127,6 +141,12 @@ gimp_editor_init (GimpEditor *editor)
editor->button_box = NULL;
}
static void
gimp_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->get_menu = gimp_editor_get_menu;
}
static void
gimp_editor_destroy (GtkObject *object)
{
@ -191,6 +211,17 @@ gimp_editor_style_set (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
}
static GimpItemFactory *
gimp_editor_get_menu (GimpDocked *docked,
gpointer *item_factory_data)
{
GimpEditor *editor = GIMP_EDITOR (docked);
*item_factory_data = editor->item_factory_data;
return editor->item_factory;
}
GtkWidget *
gimp_editor_new (void)
{

View file

@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -56,6 +58,9 @@ static void gimp_image_dock_style_set (GtkWidget *widget,
static void gimp_image_dock_setup (GimpDock *dock,
const GimpDock *template);
static void gimp_image_dock_set_aux_info (GimpDock *dock,
GList *aux_info);
static GList *gimp_image_dock_get_aux_info (GimpDock *dock);
static void gimp_image_dock_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_image_dock_book_removed (GimpDock *dock,
@ -128,6 +133,8 @@ gimp_image_dock_class_init (GimpImageDockClass *klass)
widget_class->style_set = gimp_image_dock_style_set;
dock_class->setup = gimp_image_dock_setup;
dock_class->set_aux_info = gimp_image_dock_set_aux_info;
dock_class->get_aux_info = gimp_image_dock_get_aux_info;
dock_class->book_added = gimp_image_dock_book_added;
dock_class->book_removed = gimp_image_dock_book_removed;
@ -283,6 +290,56 @@ gimp_image_dock_setup (GimpDock *dock,
}
}
static void
gimp_image_dock_set_aux_info (GimpDock *dock,
GList *aux_info)
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
GList *aux;
gboolean menu_shown = image_dock->show_image_menu;
gboolean auto_follow = image_dock->auto_follow_active;
for (aux = aux_info; aux; aux = g_list_next (aux))
{
gchar *str = (gchar *) aux->data;
if (! strcmp (str, "menu-shown"))
menu_shown = TRUE;
else if (! strcmp (str, "menu-hidden"))
menu_shown = FALSE;
else if (! strcmp (str, "follow-active-image"))
auto_follow = TRUE;
else if (! strcmp (str, "dont-follow-active-image"))
auto_follow = FALSE;
}
if (menu_shown != image_dock->show_image_menu)
gimp_image_dock_set_show_image_menu (image_dock, menu_shown);
if (auto_follow != image_dock->auto_follow_active)
gimp_image_dock_set_auto_follow_active (image_dock, auto_follow);
}
static GList *
gimp_image_dock_get_aux_info (GimpDock *dock)
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
GList *aux = NULL;
aux = g_list_append (aux,
image_dock->show_image_menu ?
g_strdup ("menu-shown") :
g_strdup ("menu-hidden"));
aux = g_list_append (aux,
image_dock->auto_follow_active ?
g_strdup ("follow-active-image") :
g_strdup ("dont-follow-active-image"));
return aux;
}
static void
gimp_image_dock_book_added (GimpDock *dock,
GimpDockbook *dockbook)

View file

@ -22,14 +22,21 @@
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "gimpdocked.h"
#include "gimpimageeditor.h"
static void gimp_image_editor_class_init (GimpImageEditorClass *klass);
static void gimp_image_editor_init (GimpImageEditor *editor);
static void gimp_image_editor_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_image_editor_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_image_editor_destroy (GtkObject *object);
static void gimp_image_editor_real_set_image (GimpImageEditor *editor,
@ -42,9 +49,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_image_editor_get_type (void)
{
static GType editor_type = 0;
static GType type = 0;
if (! editor_type)
if (! type)
{
static const GTypeInfo editor_info =
{
@ -58,13 +65,22 @@ gimp_image_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_image_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_image_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpImageEditor",
&editor_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpImageEditor",
&editor_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return editor_type;
return type;
}
static void
@ -89,6 +105,45 @@ gimp_image_editor_init (GimpImageEditor *editor)
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
static void
gimp_image_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_image_editor_set_docked_context;
}
static void
gimp_image_editor_docked_context_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor)
{
gimp_image_editor_set_image (editor, gimage);
}
static void
gimp_image_editor_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (docked);
GimpImage *gimage = NULL;
if (prev_context)
g_signal_handlers_disconnect_by_func (prev_context,
gimp_image_editor_docked_context_changed,
editor);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (gimp_image_editor_docked_context_changed),
editor);
gimage = gimp_context_get_image (context);
}
gimp_image_editor_set_image (editor, gimage);
}
static void
gimp_image_editor_destroy (GtkObject *object)
{

View file

@ -30,6 +30,7 @@
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimplayer.h"
@ -40,6 +41,7 @@
#include "gimpchanneltreeview.h"
#include "gimpcellrenderertoggle.h"
#include "gimpdnd.h"
#include "gimpdocked.h"
#include "gimpitemtreeview.h"
#include "gimpitemfactory.h"
#include "gimplayertreeview.h"
@ -58,9 +60,14 @@ enum
};
static void gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass);
static void gimp_item_tree_view_init (GimpItemTreeView *view,
GimpItemTreeViewClass *view_class);
static void gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass);
static void gimp_item_tree_view_init (GimpItemTreeView *view,
GimpItemTreeViewClass *view_class);
static void gimp_item_tree_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_item_tree_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static GObject * gimp_item_tree_view_constructor (GType type,
guint n_params,
@ -155,9 +162,9 @@ static GimpContainerTreeViewClass *parent_class = NULL;
GType
gimp_item_tree_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
@ -171,13 +178,22 @@ gimp_item_tree_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_item_tree_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_item_tree_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
view_type = g_type_register_static (GIMP_TYPE_CONTAINER_TREE_VIEW,
"GimpItemTreeView",
&view_info, 0);
type = g_type_register_static (GIMP_TYPE_CONTAINER_TREE_VIEW,
"GimpItemTreeView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
@ -337,6 +353,45 @@ gimp_item_tree_view_init (GimpItemTreeView *view,
view->linked_changed_handler_id = 0;
}
static void
gimp_item_tree_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_item_tree_view_set_docked_context;
}
static void
gimp_item_tree_view_docked_context_changed (GimpContext *context,
GimpImage *gimage,
GimpItemTreeView *view)
{
gimp_item_tree_view_set_image (view, gimage);
}
static void
gimp_item_tree_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (docked);
GimpImage *gimage = NULL;
if (prev_context)
g_signal_handlers_disconnect_by_func (prev_context,
gimp_item_tree_view_docked_context_changed,
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (gimp_item_tree_view_docked_context_changed),
view);
gimage = gimp_context_get_image (context);
}
gimp_item_tree_view_set_image (view, gimage);
}
static GObject *
gimp_item_tree_view_constructor (GType type,
guint n_params,

View file

@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -56,6 +58,9 @@ static void gimp_image_dock_style_set (GtkWidget *widget,
static void gimp_image_dock_setup (GimpDock *dock,
const GimpDock *template);
static void gimp_image_dock_set_aux_info (GimpDock *dock,
GList *aux_info);
static GList *gimp_image_dock_get_aux_info (GimpDock *dock);
static void gimp_image_dock_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_image_dock_book_removed (GimpDock *dock,
@ -128,6 +133,8 @@ gimp_image_dock_class_init (GimpImageDockClass *klass)
widget_class->style_set = gimp_image_dock_style_set;
dock_class->setup = gimp_image_dock_setup;
dock_class->set_aux_info = gimp_image_dock_set_aux_info;
dock_class->get_aux_info = gimp_image_dock_get_aux_info;
dock_class->book_added = gimp_image_dock_book_added;
dock_class->book_removed = gimp_image_dock_book_removed;
@ -283,6 +290,56 @@ gimp_image_dock_setup (GimpDock *dock,
}
}
static void
gimp_image_dock_set_aux_info (GimpDock *dock,
GList *aux_info)
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
GList *aux;
gboolean menu_shown = image_dock->show_image_menu;
gboolean auto_follow = image_dock->auto_follow_active;
for (aux = aux_info; aux; aux = g_list_next (aux))
{
gchar *str = (gchar *) aux->data;
if (! strcmp (str, "menu-shown"))
menu_shown = TRUE;
else if (! strcmp (str, "menu-hidden"))
menu_shown = FALSE;
else if (! strcmp (str, "follow-active-image"))
auto_follow = TRUE;
else if (! strcmp (str, "dont-follow-active-image"))
auto_follow = FALSE;
}
if (menu_shown != image_dock->show_image_menu)
gimp_image_dock_set_show_image_menu (image_dock, menu_shown);
if (auto_follow != image_dock->auto_follow_active)
gimp_image_dock_set_auto_follow_active (image_dock, auto_follow);
}
static GList *
gimp_image_dock_get_aux_info (GimpDock *dock)
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
GList *aux = NULL;
aux = g_list_append (aux,
image_dock->show_image_menu ?
g_strdup ("menu-shown") :
g_strdup ("menu-hidden"));
aux = g_list_append (aux,
image_dock->auto_follow_active ?
g_strdup ("follow-active-image") :
g_strdup ("dont-follow-active-image"));
return aux;
}
static void
gimp_image_dock_book_added (GimpDock *dock,
GimpDockbook *dockbook)

View file

@ -36,6 +36,7 @@
#include "gimpdock.h"
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpdocked.h"
#include "gimpsessioninfo.h"
@ -541,7 +542,7 @@ gimp_session_info_restore (GimpSessionInfo *info,
if (! dockable)
continue;
if (! GIMP_DOCKABLE (dockable)->get_preview_func)
if (! GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child)->get_preview)
{
switch (dockable_info->tab_style)
{

View file

@ -34,6 +34,7 @@
#include "core/gimptooloptions.h"
#include "gimpdnd.h"
#include "gimpdocked.h"
#include "gimphelp-ids.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
@ -43,11 +44,17 @@
#include "gimp-intl.h"
static void gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass);
static void gimp_tool_options_editor_init (GimpToolOptionsEditor *editor);
static void gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass);
static void gimp_tool_options_editor_init (GimpToolOptionsEditor *editor);
static void gimp_tool_options_editor_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_tool_options_editor_destroy (GtkObject *object);
static GtkWidget *gimp_tool_options_editor_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
static void gimp_tool_options_editor_save_clicked (GtkWidget *widget,
GimpToolOptionsEditor *editor);
static void gimp_tool_options_editor_restore_clicked (GtkWidget *widget,
@ -79,9 +86,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_tool_options_editor_get_type (void)
{
static GType editor_type = 0;
static GType type = 0;
if (! editor_type)
if (! type)
{
static const GTypeInfo editor_info =
{
@ -95,13 +102,22 @@ gimp_tool_options_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_tool_options_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_tool_options_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpToolOptionsEditor",
&editor_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpToolOptionsEditor",
&editor_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return editor_type;
return type;
}
static void
@ -183,6 +199,12 @@ gimp_tool_options_editor_init (GimpToolOptionsEditor *editor)
editor);
}
static void
gimp_tool_options_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->get_preview = gimp_tool_options_editor_get_preview;
}
static void
gimp_tool_options_editor_destroy (GtkObject *object)
{
@ -210,6 +232,66 @@ gimp_tool_options_editor_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_tool_options_preview_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
GtkLabel *label)
{
GtkImage *image;
if ((image = g_object_get_data (G_OBJECT (label), "tool-icon")))
{
const gchar *stock_id;
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
gtk_image_set_from_stock (image, stock_id, image->icon_size);
}
gtk_label_set_text (label, tool_info->blurb);
gimp_help_set_help_data (GTK_WIDGET (label)->parent->parent,
tool_info->help, tool_info->help_id);
}
static GtkWidget *
gimp_tool_options_editor_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size)
{
GimpToolInfo *tool_info;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
gint width;
gint height;
const gchar *stock_id;
gtk_icon_size_lookup (size, &width, &height);
tool_info = gimp_context_get_tool (context);
hbox = gtk_hbox_new (FALSE, 2);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
image = gtk_image_new_from_stock (stock_id, size);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = gtk_label_new (tool_info->blurb);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_set_data (G_OBJECT (label), "tool-icon", image);
g_signal_connect_object (context, "tool_changed",
G_CALLBACK (gimp_tool_options_preview_tool_changed),
label,
0);
return hbox;
}
GtkWidget *
gimp_tool_options_editor_new (Gimp *gimp,
GimpMenuFactory *menu_factory)

View file

@ -98,6 +98,8 @@ typedef struct _GimpToolbox GimpToolbox;
typedef struct _GimpImageDock GimpImageDock;
typedef struct _GimpDockable GimpDockable;
typedef struct _GimpDockbook GimpDockbook;
typedef struct _GimpDocked GimpDocked; /* dummy typedef */
typedef struct _GimpDockedIface GimpDockedIface;
typedef struct _GimpContainerPopup GimpContainerPopup;
typedef struct _GimpViewableButton GimpViewableButton;