app/widgets/Makefile.am app/widgets/widgets-types.h new GimpEditor

2003-02-20  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpimageeditor.[ch]: new GimpEditor subclass adding
	a GimpImage pointer and a virtual set_image() function.

	* app/widgets/gimpcolormapeditor.[ch]
	* app/widgets/gimpselectioneditor.[ch]
	* app/widgets/gimpundoeditor.[ch]: derive them from GimpImageEditor.
	Removed the public set_image() functions.

	* app/gui/colormap-editor-commands.c
	* app/gui/colormap-editor-menu.c: changed accordingly.

	* app/gui/dialogs-constructors.c: removed lots of code duplication
	and use the uniform GimpImageEditor API. Misc cleanups.
This commit is contained in:
Michael Natterer 2003-02-20 15:40:15 +00:00 committed by Michael Natterer
parent bca2ddaa90
commit 94bdcbcc01
17 changed files with 711 additions and 734 deletions

View File

@ -1,3 +1,21 @@
2003-02-20 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpimageeditor.[ch]: new GimpEditor subclass adding
a GimpImage pointer and a virtual set_image() function.
* app/widgets/gimpcolormapeditor.[ch]
* app/widgets/gimpselectioneditor.[ch]
* app/widgets/gimpundoeditor.[ch]: derive them from GimpImageEditor.
Removed the public set_image() functions.
* app/gui/colormap-editor-commands.c
* app/gui/colormap-editor-menu.c: changed accordingly.
* app/gui/dialogs-constructors.c: removed lots of code duplication
and use the uniform GimpImageEditor API. Misc cleanups.
2003-02-20 Sven Neumann <sven@gimp.org>
* app/core/gimpmarshal.list: reduced to the set of marshallers we

View File

@ -56,8 +56,7 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage)
return;
@ -80,8 +79,7 @@ colormap_editor_edit_color_cmd_callback (GtkWidget *widget,
GimpRGB color;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage)
return;
@ -126,8 +124,7 @@ colormap_editor_color_notebook_callback (ColorNotebook *color_notebook,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
switch (state)
{

View File

@ -56,8 +56,7 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage)
return;
@ -80,8 +79,7 @@ colormap_editor_edit_color_cmd_callback (GtkWidget *widget,
GimpRGB color;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage)
return;
@ -126,8 +124,7 @@ colormap_editor_color_notebook_callback (ColorNotebook *color_notebook,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
switch (state)
{

View File

@ -113,24 +113,20 @@ static GtkWidget * dialogs_stock_text_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_editor_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_path_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_selection_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_undo_history_context_func (GimpDockable *dockable,
static void dialogs_set_image_item_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_path_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 void dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
@ -145,15 +141,9 @@ static void dialogs_image_item_view_image_changed (GimpContext *context
static void dialogs_path_view_image_changed (GimpContext *context,
GimpImage *gimage,
GtkWidget *view);
static void dialogs_indexed_palette_image_changed (GimpContext *context,
static void dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor);
static void dialogs_selection_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpSelectionEditor *editor);
static void dialogs_undo_history_image_changed (GimpContext *context,
GimpImage *gimage,
GimpUndoEditor *editor);
GimpImageEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
@ -739,7 +729,7 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Indexed Palette"), _("Colormap"), NULL,
NULL,
dialogs_set_indexed_palette_context_func);
dialogs_set_image_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -767,7 +757,7 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
_("Selection Editor"), _("Selection"),
GIMP_STOCK_TOOL_RECT_SELECT,
dialogs_stock_text_tab_func,
dialogs_set_selection_editor_context_func);
dialogs_set_image_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -791,7 +781,7 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
_("Undo History"), _("Undo"),
GTK_STOCK_UNDO,
dialogs_stock_text_tab_func,
dialogs_set_undo_history_context_func);
dialogs_set_image_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -964,11 +954,11 @@ dialogs_indexed_palette_selected (GimpColormapEditor *editor,
if (context)
{
GimpImage *gimage;
GimpRGB color;
gint index;
GimpImage *gimage;
GimpRGB color;
gint index;
gimage = gimp_colormap_editor_get_image (editor);
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
index = gimp_colormap_editor_col_index (editor);
gimp_rgba_set_uchar (&color,
@ -1252,29 +1242,29 @@ dialogs_set_image_item_context_func (GimpDockable *dockable,
view = (GimpItemListView *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_item_view_image_changed,
view);
}
if (context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_item_view_image_changed,
view);
}
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_item_view_image_changed),
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_item_view_image_changed),
view);
dialogs_image_item_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_image_item_view_image_changed (NULL, NULL, view);
}
dialogs_image_item_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_image_item_view_image_changed (NULL, NULL, view);
}
}
@ -1287,134 +1277,64 @@ dialogs_set_path_context_func (GimpDockable *dockable,
view = (GtkWidget *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_path_view_image_changed,
view);
}
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_path_view_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_path_view_image_changed),
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_path_view_image_changed),
view);
dialogs_path_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_path_view_image_changed (NULL, NULL, view);
}
dialogs_path_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_path_view_image_changed (NULL, NULL, view);
}
}
static void
dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpColormapEditor *view;
view = (GimpColormapEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_indexed_palette_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_indexed_palette_image_changed),
view);
dialogs_indexed_palette_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_indexed_palette_image_changed (NULL, NULL, view);
}
}
}
static void
dialogs_set_selection_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpSelectionEditor *view;
view = (GimpSelectionEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_selection_editor_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_selection_editor_image_changed),
view);
dialogs_selection_editor_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_selection_editor_image_changed (NULL, NULL, view);
}
}
}
static void
dialogs_set_undo_history_context_func (GimpDockable *dockable,
dialogs_set_image_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpUndoEditor *view;
GimpImageEditor *view;
view = (GimpUndoEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
view = (GimpImageEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_undo_history_image_changed,
view);
}
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_editor_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_undo_history_image_changed),
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_editor_image_changed),
view);
dialogs_undo_history_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_undo_history_image_changed (NULL, NULL, view);
}
dialogs_image_editor_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_image_editor_image_changed (NULL, NULL, view);
}
}
@ -1427,29 +1347,29 @@ dialogs_set_navigation_context_func (GimpDockable *dockable,
view = (GimpNavigationView *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_navigation_display_changed,
view);
}
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_navigation_display_changed,
view);
}
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (dialogs_navigation_display_changed),
view);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (dialogs_navigation_display_changed),
view);
dialogs_navigation_display_changed (context,
gimp_context_get_display (context),
view);
}
else
{
dialogs_navigation_display_changed (NULL, NULL, view);
}
dialogs_navigation_display_changed (context,
gimp_context_get_display (context),
view);
}
else
{
dialogs_navigation_display_changed (NULL, NULL, view);
}
}
@ -1493,27 +1413,11 @@ dialogs_path_view_image_changed (GimpContext *context,
}
static void
dialogs_indexed_palette_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor)
dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor)
{
gimp_colormap_editor_set_image (editor, gimage);
}
static void
dialogs_selection_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpSelectionEditor *editor)
{
gimp_selection_editor_set_image (editor, gimage);
}
static void
dialogs_undo_history_image_changed (GimpContext *context,
GimpImage *gimage,
GimpUndoEditor *editor)
{
gimp_undo_editor_set_image (editor, gimage);
gimp_image_editor_set_image (editor, gimage);
}
static void

View File

@ -56,8 +56,7 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage)
return;
@ -80,8 +79,7 @@ colormap_editor_edit_color_cmd_callback (GtkWidget *widget,
GimpRGB color;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage)
return;
@ -126,8 +124,7 @@ colormap_editor_color_notebook_callback (ColorNotebook *color_notebook,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
switch (state)
{

View File

@ -61,8 +61,7 @@ colormap_editor_menu_update (GtkItemFactory *factory,
gint num_colors = 0;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage)
{

View File

@ -113,24 +113,20 @@ static GtkWidget * dialogs_stock_text_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_editor_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_path_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_selection_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_undo_history_context_func (GimpDockable *dockable,
static void dialogs_set_image_item_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_path_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 void dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
@ -145,15 +141,9 @@ static void dialogs_image_item_view_image_changed (GimpContext *context
static void dialogs_path_view_image_changed (GimpContext *context,
GimpImage *gimage,
GtkWidget *view);
static void dialogs_indexed_palette_image_changed (GimpContext *context,
static void dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor);
static void dialogs_selection_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpSelectionEditor *editor);
static void dialogs_undo_history_image_changed (GimpContext *context,
GimpImage *gimage,
GimpUndoEditor *editor);
GimpImageEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
@ -739,7 +729,7 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
dockable = dialogs_dockable_new (view,
_("Indexed Palette"), _("Colormap"), NULL,
NULL,
dialogs_set_indexed_palette_context_func);
dialogs_set_image_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -767,7 +757,7 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
_("Selection Editor"), _("Selection"),
GIMP_STOCK_TOOL_RECT_SELECT,
dialogs_stock_text_tab_func,
dialogs_set_selection_editor_context_func);
dialogs_set_image_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -791,7 +781,7 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
_("Undo History"), _("Undo"),
GTK_STOCK_UNDO,
dialogs_stock_text_tab_func,
dialogs_set_undo_history_context_func);
dialogs_set_image_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -964,11 +954,11 @@ dialogs_indexed_palette_selected (GimpColormapEditor *editor,
if (context)
{
GimpImage *gimage;
GimpRGB color;
gint index;
GimpImage *gimage;
GimpRGB color;
gint index;
gimage = gimp_colormap_editor_get_image (editor);
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
index = gimp_colormap_editor_col_index (editor);
gimp_rgba_set_uchar (&color,
@ -1252,29 +1242,29 @@ dialogs_set_image_item_context_func (GimpDockable *dockable,
view = (GimpItemListView *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_item_view_image_changed,
view);
}
if (context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_item_view_image_changed,
view);
}
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_item_view_image_changed),
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_item_view_image_changed),
view);
dialogs_image_item_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_image_item_view_image_changed (NULL, NULL, view);
}
dialogs_image_item_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_image_item_view_image_changed (NULL, NULL, view);
}
}
@ -1287,134 +1277,64 @@ dialogs_set_path_context_func (GimpDockable *dockable,
view = (GtkWidget *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_path_view_image_changed,
view);
}
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_path_view_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_path_view_image_changed),
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_path_view_image_changed),
view);
dialogs_path_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_path_view_image_changed (NULL, NULL, view);
}
dialogs_path_view_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_path_view_image_changed (NULL, NULL, view);
}
}
static void
dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpColormapEditor *view;
view = (GimpColormapEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_indexed_palette_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_indexed_palette_image_changed),
view);
dialogs_indexed_palette_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_indexed_palette_image_changed (NULL, NULL, view);
}
}
}
static void
dialogs_set_selection_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpSelectionEditor *view;
view = (GimpSelectionEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_selection_editor_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_selection_editor_image_changed),
view);
dialogs_selection_editor_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_selection_editor_image_changed (NULL, NULL, view);
}
}
}
static void
dialogs_set_undo_history_context_func (GimpDockable *dockable,
dialogs_set_image_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GimpUndoEditor *view;
GimpImageEditor *view;
view = (GimpUndoEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
view = (GimpImageEditor *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_undo_history_image_changed,
view);
}
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_image_editor_image_changed,
view);
}
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_undo_history_image_changed),
view);
if (context)
{
g_signal_connect (context, "image_changed",
G_CALLBACK (dialogs_image_editor_image_changed),
view);
dialogs_undo_history_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_undo_history_image_changed (NULL, NULL, view);
}
dialogs_image_editor_image_changed (context,
gimp_context_get_image (context),
view);
}
else
{
dialogs_image_editor_image_changed (NULL, NULL, view);
}
}
@ -1427,29 +1347,29 @@ dialogs_set_navigation_context_func (GimpDockable *dockable,
view = (GimpNavigationView *) g_object_get_data (G_OBJECT (dockable),
"gimp-dialogs-view");
if (view)
if (! view)
return;
if (dockable->context)
{
if (dockable->context)
{
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_navigation_display_changed,
view);
}
g_signal_handlers_disconnect_by_func (dockable->context,
dialogs_navigation_display_changed,
view);
}
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (dialogs_navigation_display_changed),
view);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (dialogs_navigation_display_changed),
view);
dialogs_navigation_display_changed (context,
gimp_context_get_display (context),
view);
}
else
{
dialogs_navigation_display_changed (NULL, NULL, view);
}
dialogs_navigation_display_changed (context,
gimp_context_get_display (context),
view);
}
else
{
dialogs_navigation_display_changed (NULL, NULL, view);
}
}
@ -1493,27 +1413,11 @@ dialogs_path_view_image_changed (GimpContext *context,
}
static void
dialogs_indexed_palette_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor)
dialogs_image_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpImageEditor *editor)
{
gimp_colormap_editor_set_image (editor, gimage);
}
static void
dialogs_selection_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpSelectionEditor *editor)
{
gimp_selection_editor_set_image (editor, gimage);
}
static void
dialogs_undo_history_image_changed (GimpContext *context,
GimpImage *gimage,
GimpUndoEditor *editor)
{
gimp_undo_editor_set_image (editor, gimage);
gimp_image_editor_set_image (editor, gimage);
}
static void

View File

@ -103,6 +103,8 @@ libappwidgets_a_sources = \
gimphistogramview.h \
gimpimagedock.c \
gimpimagedock.h \
gimpimageeditor.c \
gimpimageeditor.h \
gimpimagefilepreview.c \
gimpimagefilepreview.h \
gimpimagepreview.c \

View File

@ -79,6 +79,9 @@ static void gimp_colormap_editor_init (GimpColormapEditor *colormap
static void gimp_colormap_editor_destroy (GtkObject *object);
static void gimp_colormap_editor_unmap (GtkWidget *widget);
static void gimp_colormap_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage);
static void gimp_colormap_editor_draw (GimpColormapEditor *editor);
static void gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
gint col);
@ -119,7 +122,7 @@ static void gimp_colormap_image_colormap_changed (GimpImage *gimage,
static guint editor_signals[LAST_SIGNAL] = { 0 };
static GimpEditorClass *parent_class = NULL;
static GimpImageEditorClass *parent_class = NULL;
static GtkTargetEntry color_palette_target_table[] =
{
@ -147,7 +150,7 @@ gimp_colormap_editor_get_type (void)
(GInstanceInitFunc) gimp_colormap_editor_init,
};
gcd_type = g_type_register_static (GIMP_TYPE_EDITOR,
gcd_type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
"GimpColormapEditor",
&gcd_info, 0);
}
@ -158,11 +161,13 @@ gimp_colormap_editor_get_type (void)
static void
gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GimpImageEditorClass *image_editor_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -175,17 +180,18 @@ gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->destroy = gimp_colormap_editor_destroy;
object_class->destroy = gimp_colormap_editor_destroy;
widget_class->unmap = gimp_colormap_editor_unmap;
widget_class->unmap = gimp_colormap_editor_unmap;
klass->selected = NULL;
image_editor_class->set_image = gimp_colormap_editor_set_image;
klass->selected = NULL;
}
static void
gimp_colormap_editor_init (GimpColormapEditor *colormap_editor)
{
colormap_editor->gimage = NULL;
colormap_editor->col_index = 0;
colormap_editor->dnd_col_index = 0;
colormap_editor->palette = NULL;
@ -233,6 +239,62 @@ gimp_colormap_editor_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
gimp_colormap_editor_set_image (GimpImageEditor *image_editor,
GimpImage *gimage)
{
GimpColormapEditor *editor;
editor = GIMP_COLORMAP_EDITOR (image_editor);
if (image_editor->gimage)
{
g_signal_handlers_disconnect_by_func (image_editor->gimage,
gimp_colormap_image_mode_changed,
editor);
g_signal_handlers_disconnect_by_func (image_editor->gimage,
gimp_colormap_image_colormap_changed,
editor);
if (editor->color_notebook)
color_notebook_hide (editor->color_notebook);
if (! gimage || (gimp_image_base_type (gimage) != GIMP_INDEXED))
{
editor->index_adjustment->upper = 0;
gtk_adjustment_changed (editor->index_adjustment);
if (GTK_WIDGET_MAPPED (GTK_WIDGET (editor)))
gimp_colormap_editor_clear (editor, -1);
}
}
GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, gimage);
editor->col_index = 0;
editor->dnd_col_index = 0;
if (gimage)
{
g_signal_connect (gimage, "mode_changed",
G_CALLBACK (gimp_colormap_image_mode_changed),
editor);
g_signal_connect (gimage, "colormap_changed",
G_CALLBACK (gimp_colormap_image_colormap_changed),
editor);
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
{
gimp_colormap_editor_draw (editor);
editor->index_adjustment->upper = gimage->num_cols - 1;
gtk_adjustment_changed (editor->index_adjustment);
}
}
gimp_colormap_editor_update_entries (editor);
}
/* public functions */
@ -320,7 +382,8 @@ gimp_colormap_editor_new (GimpImage *gimage,
G_CALLBACK (gimp_colormap_hex_entry_focus_out),
editor);
gimp_colormap_editor_set_image (editor, gimage);
if (gimage)
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
return GTK_WIDGET (editor);
}
@ -333,68 +396,6 @@ gimp_colormap_editor_selected (GimpColormapEditor *editor)
g_signal_emit (editor, editor_signals[SELECTED], 0);
}
void
gimp_colormap_editor_set_image (GimpColormapEditor *editor,
GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_COLORMAP_EDITOR (editor));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (editor->gimage)
{
g_signal_handlers_disconnect_by_func (editor->gimage,
gimp_colormap_image_mode_changed,
editor);
g_signal_handlers_disconnect_by_func (editor->gimage,
gimp_colormap_image_colormap_changed,
editor);
if (editor->color_notebook)
color_notebook_hide (editor->color_notebook);
if (! gimage || (gimp_image_base_type (gimage) != GIMP_INDEXED))
{
editor->index_adjustment->upper = 0;
gtk_adjustment_changed (editor->index_adjustment);
if (GTK_WIDGET_MAPPED (GTK_WIDGET (editor)))
gimp_colormap_editor_clear (editor, -1);
}
}
editor->gimage = gimage;
editor->col_index = 0;
editor->dnd_col_index = 0;
if (gimage)
{
g_signal_connect (gimage, "mode_changed",
G_CALLBACK (gimp_colormap_image_mode_changed),
editor);
g_signal_connect (gimage, "colormap_changed",
G_CALLBACK (gimp_colormap_image_colormap_changed),
editor);
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
{
gimp_colormap_editor_draw (editor);
editor->index_adjustment->upper = editor->gimage->num_cols - 1;
gtk_adjustment_changed (editor->index_adjustment);
}
}
gimp_colormap_editor_update_entries (editor);
}
GimpImage *
gimp_colormap_editor_get_image (GimpColormapEditor *editor)
{
g_return_val_if_fail (GIMP_IS_COLORMAP_EDITOR (editor), NULL);
return editor->gimage;
}
gint
gimp_colormap_editor_col_index (GimpColormapEditor *editor)
{
@ -418,7 +419,7 @@ gimp_colormap_editor_draw (GimpColormapEditor *editor)
gint cellsize, ncol, xn, yn, width, height;
GtkWidget *palette;
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
palette = editor->palette;
width = palette->allocation.width;
@ -497,12 +498,11 @@ static void
gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
gint col)
{
guchar *row;
gint cellsize, x, y, k;
g_assert (editor);
g_assert (editor->gimage);
g_assert (col < editor->gimage->num_cols);
GimpImage *gimage;
guchar *row;
gint cellsize, x, y, k;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
cellsize = editor->cellsize;
row = g_new (guchar, cellsize * 3);
@ -526,9 +526,9 @@ gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
= 255 * (cellsize & 1);
for (k = 1; k < cellsize - 1; k++)
{
row[k*3] = editor->gimage->cmap[col * 3];
row[k*3+1] = editor->gimage->cmap[col * 3 + 1];
row[k*3+2] = editor->gimage->cmap[col * 3 + 2];
row[k*3] = gimage->cmap[col * 3];
row[k*3+1] = gimage->cmap[col * 3 + 1];
row[k*3+2] = gimage->cmap[col * 3 + 2];
}
for (k = 1; k < cellsize - 1; k+=2)
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
@ -545,9 +545,9 @@ gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
{
for (k = 0; k < cellsize; k++)
{
row[k*3] = editor->gimage->cmap[col * 3];
row[k*3+1] = editor->gimage->cmap[col * 3 + 1];
row[k*3+2] = editor->gimage->cmap[col * 3 + 2];
row[k*3] = gimage->cmap[col * 3];
row[k*3+1] = gimage->cmap[col * 3 + 1];
row[k*3+2] = gimage->cmap[col * 3 + 2];
}
for (k = 0; k < cellsize; k++)
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
@ -627,8 +627,11 @@ gimp_colormap_editor_clear (GimpColormapEditor *editor,
static void
gimp_colormap_editor_update_entries (GimpColormapEditor *editor)
{
if (! editor->gimage ||
(gimp_image_base_type (editor->gimage) != GIMP_INDEXED))
GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! gimage || (gimp_image_base_type (gimage) != GIMP_INDEXED))
{
gtk_widget_set_sensitive (editor->index_spinbutton, FALSE);
gtk_widget_set_sensitive (editor->color_entry, FALSE);
@ -643,7 +646,7 @@ gimp_colormap_editor_update_entries (GimpColormapEditor *editor)
gtk_adjustment_set_value (editor->index_adjustment, editor->col_index);
col = &editor->gimage->cmap[editor->col_index * 3];
col = &gimage->cmap[editor->col_index * 3];
string = g_strdup_printf ("#%02x%02x%02x", col[0], col[1], col[2]);
gtk_entry_set_text (GTK_ENTRY (editor->color_entry), string);
@ -677,7 +680,11 @@ gimp_colormap_preview_size_allocate (GtkWidget *widget,
GtkAllocation *alloc,
GimpColormapEditor *editor)
{
if (editor->gimage && (gimp_image_base_type (editor->gimage) == GIMP_INDEXED))
GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage && (gimp_image_base_type (gimage) == GIMP_INDEXED))
gimp_colormap_editor_draw (editor);
else
gimp_colormap_editor_clear (editor, -1);
@ -693,7 +700,7 @@ gimp_colormap_preview_button_press (GtkWidget *widget,
guchar r, g, b;
guint col;
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (! (gimage && (gimp_image_base_type (gimage) == GIMP_INDEXED)))
return TRUE;
@ -705,7 +712,7 @@ gimp_colormap_preview_button_press (GtkWidget *widget,
col = (editor->xn * ((gint) bevent->y / editor->cellsize) +
((gint) bevent->x / editor->cellsize));
if (col >= editor->gimage->num_cols)
if (col >= gimage->num_cols)
return TRUE;
r = gimage->cmap[col * 3 + 0];
@ -744,8 +751,7 @@ gimp_colormap_preview_drag_color (GtkWidget *widget,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage && (gimp_image_base_type (gimage) == GIMP_INDEXED))
{
@ -770,17 +776,16 @@ gimp_colormap_preview_drop_color (GtkWidget *widget,
GimpImage *gimage;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = editor->gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if ((gimage && gimp_image_base_type (gimage) == GIMP_INDEXED))
{
if (gimage->num_cols < 256)
{
gimp_rgb_get_uchar (color,
&gimage->cmap[editor->gimage->num_cols * 3],
&gimage->cmap[editor->gimage->num_cols * 3 + 1],
&gimage->cmap[editor->gimage->num_cols * 3 + 2]);
&gimage->cmap[gimage->num_cols * 3],
&gimage->cmap[gimage->num_cols * 3 + 1],
&gimage->cmap[gimage->num_cols * 3 + 2]);
gimage->num_cols++;
gimp_image_colormap_changed (gimage, -1);
@ -792,7 +797,7 @@ static void
gimp_colormap_adjustment_changed (GtkAdjustment *adjustment,
GimpColormapEditor *editor)
{
if (editor->gimage)
if (GIMP_IMAGE_EDITOR (editor)->gimage)
{
gimp_colormap_editor_set_index (editor, (gint) (adjustment->value + 0.5));
@ -804,7 +809,11 @@ static void
gimp_colormap_hex_entry_activate (GtkEntry *entry,
GimpColormapEditor *editor)
{
if (editor->gimage)
GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage)
{
const gchar *s;
gulong i;
@ -813,11 +822,13 @@ gimp_colormap_hex_entry_activate (GtkEntry *entry,
if (sscanf (s, "#%lx", &i))
{
guchar *c = &editor->gimage->cmap[3 * editor->col_index];
guchar *c = &gimage->cmap[3 * editor->col_index];
c[0] = (i & 0xFF0000) >> 16;
c[1] = (i & 0x00FF00) >> 8;
c[2] = (i & 0x0000FF);
gimp_image_colormap_changed (editor->gimage, editor->col_index);
gimp_image_colormap_changed (gimage, editor->col_index);
}
gimp_colormap_editor_update_entries (editor);

View File

@ -20,7 +20,7 @@
#define __GIMP_COLORMAP_EDITOR_H__
#include "gimpeditor.h"
#include "gimpimageeditor.h"
#include "gui/gui-types.h" /* temp hack */
@ -37,12 +37,10 @@ typedef struct _GimpColormapEditorClass GimpColormapEditorClass;
struct _GimpColormapEditor
{
GimpEditor parent_instance;
GimpImageEditor parent_instance;
GimpItemFactory *item_factory;
GimpImage *gimage;
gint col_index;
gint dnd_col_index;
GtkWidget *palette;
@ -57,7 +55,7 @@ struct _GimpColormapEditor
struct _GimpColormapEditorClass
{
GimpEditorClass parent_class;
GimpImageEditorClass parent_class;
void (* selected) (GimpColormapEditor *gcd);
};
@ -69,10 +67,6 @@ GtkWidget * gimp_colormap_editor_new (GimpImage *gimage,
GimpMenuFactory *menu_factory);
void gimp_colormap_editor_selected (GimpColormapEditor *editor);
void gimp_colormap_editor_set_image (GimpColormapEditor *editor,
GimpImage *gimage);
GimpImage * gimp_colormap_editor_get_image (GimpColormapEditor *editor);
gint gimp_colormap_editor_col_index (GimpColormapEditor *editor);

View File

@ -0,0 +1,135 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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/gimpimage.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_destroy (GtkObject *object);
static void gimp_image_editor_real_set_image (GimpImageEditor *editor,
GimpImage *gimage);
static GimpEditorClass *parent_class = NULL;
GType
gimp_image_editor_get_type (void)
{
static GType editor_type = 0;
if (! editor_type)
{
static const GTypeInfo editor_info =
{
sizeof (GimpImageEditorClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_image_editor_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpImageEditor),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_image_editor_init,
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpImageEditor",
&editor_info, 0);
}
return editor_type;
}
static void
gimp_image_editor_class_init (GimpImageEditorClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_image_editor_destroy;
klass->set_image = gimp_image_editor_real_set_image;
}
static void
gimp_image_editor_init (GimpImageEditor *editor)
{
editor->gimage = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
static void
gimp_image_editor_destroy (GtkObject *object)
{
GimpImageEditor *editor;
editor = GIMP_IMAGE_EDITOR (object);
if (editor->gimage)
gimp_image_editor_set_image (editor, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_image_editor_real_set_image (GimpImageEditor *editor,
GimpImage *gimage)
{
if (! editor->gimage && gimage)
{
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
}
else if (editor->gimage && ! gimage)
{
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
editor->gimage = gimage;
}
/* public functions */
void
gimp_image_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE_EDITOR (editor));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (gimage == editor->gimage)
return;
GIMP_IMAGE_EDITOR_GET_CLASS (editor)->set_image (editor, gimage);
}

View File

@ -0,0 +1,59 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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_IMAGE_EDITOR_H__
#define __GIMP_IMAGE_EDITOR_H__
#include "gimpeditor.h"
#define GIMP_TYPE_IMAGE_EDITOR (gimp_image_editor_get_type ())
#define GIMP_IMAGE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_EDITOR, GimpImageEditor))
#define GIMP_IMAGE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_EDITOR, GimpImageEditorClass))
#define GIMP_IS_IMAGE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_EDITOR))
#define GIMP_IS_IMAGE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_EDITOR))
#define GIMP_IMAGE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE_EDITOR, GimpImageEditorClass))
typedef struct _GimpImageEditorClass GimpImageEditorClass;
struct _GimpImageEditor
{
GimpEditor parent_instance;
GimpImage *gimage;
};
struct _GimpImageEditorClass
{
GimpEditorClass parent_class;
/* virtual function */
void (* set_image) (GimpImageEditor *editor,
GimpImage *gimage);
};
GType gimp_image_editor_get_type (void) G_GNUC_CONST;
void gimp_image_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage);
#endif /* __GIMP_IMAGE_EDITOR_H__ */

View File

@ -55,19 +55,20 @@
static void gimp_selection_editor_class_init (GimpSelectionEditorClass *klass);
static void gimp_selection_editor_init (GimpSelectionEditor *selection_editor);
static void gimp_selection_editor_destroy (GtkObject *object);
static void gimp_selection_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage);
static void gimp_selection_editor_abox_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpSelectionEditor *editor);
static void gimp_selection_editor_invert_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
GimpImageEditor *editor);
static void gimp_selection_editor_all_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
GimpImageEditor *editor);
static void gimp_selection_editor_none_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
GimpImageEditor *editor);
static void gimp_selection_editor_save_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
GimpImageEditor *editor);
static gboolean gimp_selection_preview_button_press(GtkWidget *widget,
GdkEventButton *bevent,
@ -80,7 +81,7 @@ static void gimp_selection_editor_mask_changed (GimpImage *gimage,
GimpSelectionEditor *editor);
static GimpEditorClass *parent_class = NULL;
static GimpImageEditorClass *parent_class = NULL;
GType
@ -103,7 +104,7 @@ gimp_selection_editor_get_type (void)
(GInstanceInitFunc) gimp_selection_editor_init,
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
editor_type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
"GimpSelectionEditor",
&editor_info, 0);
}
@ -114,13 +115,13 @@ gimp_selection_editor_get_type (void)
static void
gimp_selection_editor_class_init (GimpSelectionEditorClass* klass)
{
GtkObjectClass *object_class;
GimpImageEditorClass *image_editor_class;
object_class = GTK_OBJECT_CLASS (klass);
image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_selection_editor_destroy;
image_editor_class->set_image = gimp_selection_editor_set_image;
}
static void
@ -131,8 +132,6 @@ gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
/* FIXME: take value from GimpGuiConfig */
GimpPreviewSize nav_preview_size = GIMP_PREVIEW_SIZE_HUGE;
selection_editor->gimage = NULL;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (selection_editor), frame, TRUE, TRUE, 0);
@ -199,16 +198,35 @@ gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
}
static void
gimp_selection_editor_destroy (GtkObject *object)
gimp_selection_editor_set_image (GimpImageEditor *image_editor,
GimpImage *gimage)
{
GimpSelectionEditor *editor;
editor = GIMP_SELECTION_EDITOR (object);
editor = GIMP_SELECTION_EDITOR (image_editor);
if (editor->gimage)
gimp_selection_editor_set_image (editor, NULL);
if (image_editor->gimage)
{
g_signal_handlers_disconnect_by_func (image_editor->gimage,
gimp_selection_editor_mask_changed,
editor);
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, gimage);
if (gimage)
{
g_signal_connect (gimage, "mask_changed",
G_CALLBACK (gimp_selection_editor_mask_changed),
editor);
gimp_preview_set_viewable (GIMP_PREVIEW (editor->preview),
GIMP_VIEWABLE (gimp_image_get_mask (gimage)));
}
else
{
gimp_preview_set_viewable (GIMP_PREVIEW (editor->preview), NULL);
}
}
@ -226,58 +244,22 @@ gimp_selection_editor_new (GimpImage *gimage)
editor = g_object_new (GIMP_TYPE_SELECTION_EDITOR, NULL);
gimp_selection_editor_set_image (editor, gimage);
if (gimage)
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
return GTK_WIDGET (editor);
}
void
gimp_selection_editor_set_image (GimpSelectionEditor *editor,
GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_SELECTION_EDITOR (editor));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (gimage == editor->gimage)
return;
if (editor->gimage)
{
g_signal_handlers_disconnect_by_func (editor->gimage,
gimp_selection_editor_mask_changed,
editor);
}
else if (gimage)
{
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
}
editor->gimage = gimage;
if (gimage)
{
g_signal_connect (gimage, "mask_changed",
G_CALLBACK (gimp_selection_editor_mask_changed),
editor);
gimp_preview_set_viewable (GIMP_PREVIEW (editor->preview),
GIMP_VIEWABLE (gimp_image_get_mask (gimage)));
}
else
{
gimp_preview_set_viewable (GIMP_PREVIEW (editor->preview), NULL);
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
}
static void
gimp_selection_editor_abox_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpSelectionEditor *editor)
{
GimpPreview *preview;
GimpImageEditor *image_editor;
GimpPreview *preview;
preview = GIMP_PREVIEW (editor->preview);
image_editor = GIMP_IMAGE_EDITOR (editor);
preview = GIMP_PREVIEW (editor->preview);
if (! preview->viewable)
return;
@ -292,12 +274,12 @@ gimp_selection_editor_abox_resized (GtkWidget *widget,
gboolean dummy;
gimp_preview_calc_size (preview,
editor->gimage->width,
editor->gimage->height,
image_editor->gimage->width,
image_editor->gimage->height,
MIN (allocation->width, GIMP_PREVIEW_MAX_SIZE),
MIN (allocation->height, GIMP_PREVIEW_MAX_SIZE),
editor->gimage->xresolution,
editor->gimage->yresolution,
image_editor->gimage->xresolution,
image_editor->gimage->yresolution,
&width,
&height,
&dummy);
@ -318,8 +300,8 @@ gimp_selection_editor_abox_resized (GtkWidget *widget,
}
static void
gimp_selection_editor_invert_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
gimp_selection_editor_invert_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
{
@ -329,8 +311,8 @@ gimp_selection_editor_invert_clicked (GtkWidget *widget,
}
static void
gimp_selection_editor_all_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
gimp_selection_editor_all_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
{
@ -340,8 +322,8 @@ gimp_selection_editor_all_clicked (GtkWidget *widget,
}
static void
gimp_selection_editor_none_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
gimp_selection_editor_none_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
{
@ -351,8 +333,8 @@ gimp_selection_editor_none_clicked (GtkWidget *widget,
}
static void
gimp_selection_editor_save_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
gimp_selection_editor_save_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
{
@ -365,6 +347,7 @@ gimp_selection_preview_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpSelectionEditor *editor)
{
GimpImageEditor *image_editor;
GimpToolInfo *tool_info;
GimpSelectionOptions *options;
GimpDrawable *drawable;
@ -373,11 +356,13 @@ gimp_selection_preview_button_press (GtkWidget *widget,
guchar *col;
GimpRGB color;
if (! editor->gimage)
image_editor = GIMP_IMAGE_EDITOR (editor);
if (! image_editor->gimage)
return TRUE;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (editor->gimage->gimp->tool_info_list,
gimp_container_get_child_by_name (image_editor->gimage->gimp->tool_info_list,
"gimp-by-color-select-tool");
if (! tool_info)
@ -385,7 +370,7 @@ gimp_selection_preview_button_press (GtkWidget *widget,
options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
drawable = gimp_image_active_drawable (editor->gimage);
drawable = gimp_image_active_drawable (image_editor->gimage);
if (! drawable)
return TRUE;
@ -408,15 +393,17 @@ gimp_selection_preview_button_press (GtkWidget *widget,
if (options->sample_merged)
{
x = editor->gimage->width * bevent->x / editor->preview->allocation.width;
y = editor->gimage->height * bevent->y / editor->preview->allocation.height;
x = (image_editor->gimage->width * bevent->x /
editor->preview->allocation.width);
y = (image_editor->gimage->height * bevent->y /
editor->preview->allocation.height);
if (x < 0 || y < 0 ||
x >= editor->gimage->width ||
y >= editor->gimage->height)
x >= image_editor->gimage->width ||
y >= image_editor->gimage->height)
return TRUE;
col = gimp_image_projection_get_color_at (editor->gimage, x, y);
col = gimp_image_projection_get_color_at (image_editor->gimage, x, y);
}
else
{
@ -441,7 +428,7 @@ gimp_selection_preview_button_press (GtkWidget *widget,
g_free (col);
gimp_image_mask_select_by_color (editor->gimage, drawable,
gimp_image_mask_select_by_color (image_editor->gimage, drawable,
options->sample_merged,
&color,
options->threshold,
@ -452,7 +439,7 @@ gimp_selection_preview_button_press (GtkWidget *widget,
options->feather_radius,
options->feather_radius);
gimp_image_flush (editor->gimage);
gimp_image_flush (image_editor->gimage);
return TRUE;
}
@ -465,9 +452,9 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
GimpToolInfo *tool_info;
GimpSelectionOptions *options;
GimpDrawable *drawable;
GimpSelectionEditor *editor;
GimpImageEditor *editor;
editor = GIMP_SELECTION_EDITOR (data);
editor = GIMP_IMAGE_EDITOR (data);
if (! editor->gimage)
return;

View File

@ -20,7 +20,7 @@
#define __GIMP_SELECTION_EDITOR_H__
#include "gimpeditor.h"
#include "gimpimageeditor.h"
#define GIMP_TYPE_SELECTION_EDITOR (gimp_selection_editor_get_type ())
@ -35,29 +35,25 @@ typedef struct _GimpSelectionEditorClass GimpSelectionEditorClass;
struct _GimpSelectionEditor
{
GimpEditor parent_instance;
GimpImageEditor parent_instance;
GimpImage *gimage;
GtkWidget *preview;
GtkWidget *preview;
GtkWidget *invert_button;
GtkWidget *all_button;
GtkWidget *none_button;
GtkWidget *save_button;
GtkWidget *invert_button;
GtkWidget *all_button;
GtkWidget *none_button;
GtkWidget *save_button;
};
struct _GimpSelectionEditorClass
{
GimpEditorClass parent_class;
GimpImageEditorClass parent_class;
};
GType gimp_selection_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_selection_editor_new (GimpImage *gimage);
void gimp_selection_editor_set_image (GimpSelectionEditor *editor,
GimpImage *gimage);
GtkWidget * gimp_selection_editor_new (GimpImage *gimage);
#endif /* __GIMP_SELECTION_EDITOR_H__ */

View File

@ -39,12 +39,13 @@
static void gimp_undo_editor_class_init (GimpUndoEditorClass *klass);
static void gimp_undo_editor_init (GimpUndoEditor *undo_editor);
static void gimp_undo_editor_destroy (GtkObject *object);
static void gimp_undo_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage);
static void gimp_undo_editor_undo_clicked (GtkWidget *widget,
GimpUndoEditor *editor);
GimpImageEditor *editor);
static void gimp_undo_editor_redo_clicked (GtkWidget *widget,
GimpUndoEditor *editor);
GimpImageEditor *editor);
static void gimp_undo_editor_undo_event (GimpImage *gimage,
GimpUndoEvent event,
@ -57,7 +58,7 @@ static void gimp_undo_editor_select_item (GimpContainerView *view,
GimpUndoEditor *editor);
static GimpEditorClass *parent_class = NULL;
static GimpImageEditorClass *parent_class = NULL;
GType
@ -80,7 +81,7 @@ gimp_undo_editor_get_type (void)
(GInstanceInitFunc) gimp_undo_editor_init,
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
editor_type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
"GimpUndoEditor",
&editor_info, 0);
}
@ -91,19 +92,18 @@ gimp_undo_editor_get_type (void)
static void
gimp_undo_editor_class_init (GimpUndoEditorClass *klass)
{
GtkObjectClass *object_class;
GimpImageEditorClass *image_editor_class;
object_class = GTK_OBJECT_CLASS (klass);
image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_undo_editor_destroy;
image_editor_class->set_image = gimp_undo_editor_set_image;
}
static void
gimp_undo_editor_init (GimpUndoEditor *undo_editor)
{
undo_editor->gimage = NULL;
undo_editor->container = NULL;
undo_editor->view = gimp_container_list_view_new (NULL,
@ -137,46 +137,14 @@ gimp_undo_editor_init (GimpUndoEditor *undo_editor)
}
static void
gimp_undo_editor_destroy (GtkObject *object)
gimp_undo_editor_set_image (GimpImageEditor *image_editor,
GimpImage *gimage)
{
GimpUndoEditor *editor;
editor = GIMP_UNDO_EDITOR (object);
editor = GIMP_UNDO_EDITOR (image_editor);
if (editor->gimage)
gimp_undo_editor_set_image (editor, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/* public functions */
GtkWidget *
gimp_undo_editor_new (GimpImage *gimage)
{
GimpUndoEditor *editor;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
editor = g_object_new (GIMP_TYPE_UNDO_EDITOR, NULL);
gimp_undo_editor_set_image (editor, gimage);
return GTK_WIDGET (editor);
}
void
gimp_undo_editor_set_image (GimpUndoEditor *editor,
GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_UNDO_EDITOR (editor));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (gimage == editor->gimage)
return;
if (editor->gimage)
if (image_editor->gimage)
{
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (editor->view),
NULL);
@ -186,16 +154,12 @@ gimp_undo_editor_set_image (GimpUndoEditor *editor,
g_object_unref (editor->base_item);
editor->base_item = NULL;
g_signal_handlers_disconnect_by_func (editor->gimage,
g_signal_handlers_disconnect_by_func (image_editor->gimage,
gimp_undo_editor_undo_event,
editor);
}
else if (gimage)
{
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
}
editor->gimage = gimage;
GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, gimage);
if (gimage)
{
@ -272,15 +236,32 @@ gimp_undo_editor_set_image (GimpUndoEditor *editor,
G_CALLBACK (gimp_undo_editor_undo_event),
editor);
}
else
{
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
}
/* public functions */
GtkWidget *
gimp_undo_editor_new (GimpImage *gimage)
{
GimpUndoEditor *editor;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
editor = g_object_new (GIMP_TYPE_UNDO_EDITOR, NULL);
if (gimage)
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
return GTK_WIDGET (editor);
}
/* private functions */
static void
gimp_undo_editor_undo_clicked (GtkWidget *widget,
GimpUndoEditor *editor)
gimp_undo_editor_undo_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
{
@ -290,8 +271,8 @@ gimp_undo_editor_undo_clicked (GtkWidget *widget,
}
static void
gimp_undo_editor_redo_clicked (GtkWidget *widget,
GimpUndoEditor *editor)
gimp_undo_editor_redo_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
{
@ -331,6 +312,7 @@ gimp_undo_editor_undo_event (GimpImage *gimage,
break;
case GIMP_UNDO_EVENT_UNDO:
case GIMP_UNDO_EVENT_REDO:
if (top_undo_item)
{
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (editor->view),
@ -345,14 +327,8 @@ gimp_undo_editor_undo_event (GimpImage *gimage,
}
break;
case GIMP_UNDO_EVENT_REDO:
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (editor->view),
GIMP_VIEWABLE (top_undo_item));
gimp_undo_create_preview (top_undo_item, FALSE);
break;
case GIMP_UNDO_EVENT_UNDO_FREE:
gimp_undo_editor_set_image (editor, NULL);
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), NULL);
break;
}
@ -370,52 +346,56 @@ gimp_undo_editor_select_item (GimpContainerView *view,
gpointer insert_data,
GimpUndoEditor *editor)
{
GimpUndo *top_undo_item;
GimpUndo *top_redo_item;
GimpImage *gimage;
GimpUndo *top_undo_item;
GimpUndo *top_redo_item;
top_undo_item = gimp_undo_stack_peek (editor->gimage->undo_stack);
if (! undo)
return;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
top_undo_item = gimp_undo_stack_peek (gimage->undo_stack);
if (undo == editor->base_item)
{
/* the base_image was selected, pop all available undo items
/* the base_item was selected, pop all available undo items
*/
while (top_undo_item != NULL)
{
gimp_image_undo (editor->gimage);
gimp_image_undo (gimage);
top_undo_item = gimp_undo_stack_peek (editor->gimage->undo_stack);
top_undo_item = gimp_undo_stack_peek (gimage->undo_stack);
}
}
else if (gimp_container_have (editor->gimage->undo_stack->undos,
GIMP_OBJECT (undo)))
else if (gimp_container_have (gimage->undo_stack->undos, GIMP_OBJECT (undo)))
{
/* the selected item is on the undo stack, pop undos until it
* is on the of the undo stack
* is on top of the undo stack
*/
while (top_undo_item != undo)
{
gimp_image_undo (editor->gimage);
gimp_image_undo (gimage);
top_undo_item = gimp_undo_stack_peek (editor->gimage->undo_stack);
top_undo_item = gimp_undo_stack_peek (gimage->undo_stack);
}
}
else if (gimp_container_have (editor->gimage->redo_stack->undos,
GIMP_OBJECT (undo)))
else if (gimp_container_have (gimage->redo_stack->undos, GIMP_OBJECT (undo)))
{
/* the selected item is on the redo stack, pop redos until it
* is on top of the undo stack
*/
while (top_undo_item != undo)
{
gimp_image_redo (editor->gimage);
gimp_image_redo (gimage);
top_undo_item = gimp_undo_stack_peek (editor->gimage->undo_stack);
top_undo_item = gimp_undo_stack_peek (gimage->undo_stack);
}
}
gimp_image_flush (editor->gimage);
gimp_image_flush (gimage);
top_redo_item = gimp_undo_stack_peek (editor->gimage->redo_stack);
top_redo_item = gimp_undo_stack_peek (gimage->redo_stack);
gtk_widget_set_sensitive (editor->undo_button, top_undo_item != NULL);
gtk_widget_set_sensitive (editor->redo_button, top_redo_item != NULL);

View File

@ -20,7 +20,7 @@
#define __GIMP_UNDO_EDITOR_H__
#include "gimpeditor.h"
#include "gimpimageeditor.h"
#define GIMP_TYPE_UNDO_EDITOR (gimp_undo_editor_get_type ())
@ -35,30 +35,26 @@ typedef struct _GimpUndoEditorClass GimpUndoEditorClass;
struct _GimpUndoEditor
{
GimpEditor parent_instance;
GimpImageEditor parent_instance;
GimpImage *gimage;
GimpContainer *container;
GtkWidget *view;
GimpContainer *container;
GtkWidget *view;
GimpUndo *base_item;
GimpUndo *base_item;
GtkWidget *undo_button;
GtkWidget *redo_button;
GtkWidget *undo_button;
GtkWidget *redo_button;
};
struct _GimpUndoEditorClass
{
GimpEditorClass parent_class;
GimpImageEditorClass parent_class;
};
GType gimp_undo_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_undo_editor_new (GimpImage *gimage);
void gimp_undo_editor_set_image (GimpUndoEditor *editor,
GimpImage *gimage);
GtkWidget * gimp_undo_editor_new (GimpImage *gimage);
#endif /* __GIMP_UNDO_EDITOR_H__ */

View File

@ -57,6 +57,7 @@ typedef struct _GimpMenuItem GimpMenuItem;
typedef struct _GimpEnumMenu GimpEnumMenu;
typedef struct _GimpEditor GimpEditor;
typedef struct _GimpImageEditor GimpImageEditor;
typedef struct _GimpColorEditor GimpColorEditor;
typedef struct _GimpColormapEditor GimpColormapEditor;
typedef struct _GimpDataEditor GimpDataEditor;