bumped version number to 1.3.9

2002-08-22  Michael Natterer  <mitch@gimp.org>

	* configure.in: bumped version number to 1.3.9

	* app/tools/gimpbycolorselecttool.[ch]: removed the ByColorDialog
	and cleaned up the code.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpselectioneditor.[ch]: added new widget
	GimpSelectionEditor with same same functionality as the old
	ByColorDialog which can be open all the time (independent of the
	active tool).

	* app/widgets/gimppreview.[ch]: added gimp_preview_new_by_type()
	so previews can be created without a viewable.

	* app/widgets/gimppreview-utils.[ch]: changed
	gimp_preview_type_from_viewable() to
	gimp_preview_type_from_viewable_type().

	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs.c
	* app/gui/menus.c: register the new dialog type.
This commit is contained in:
Michael Natterer 2002-08-22 12:49:01 +00:00 committed by Michael Natterer
parent c2523d8d63
commit e62c2c58c7
26 changed files with 1065 additions and 784 deletions

View File

@ -1,3 +1,28 @@
2002-08-22 Michael Natterer <mitch@gimp.org>
* configure.in: bumped version number to 1.3.9
* app/tools/gimpbycolorselecttool.[ch]: removed the ByColorDialog
and cleaned up the code.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpselectioneditor.[ch]: added new widget
GimpSelectionEditor with same same functionality as the old
ByColorDialog which can be open all the time (independent of the
active tool).
* app/widgets/gimppreview.[ch]: added gimp_preview_new_by_type()
so previews can be created without a viewable.
* app/widgets/gimppreview-utils.[ch]: changed
gimp_preview_type_from_viewable() to
gimp_preview_type_from_viewable_type().
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs.c
* app/gui/menus.c: register the new dialog type.
2002-08-22 Michael Natterer <mitch@gimp.org>
* app/undo.c: compress emissions of "mask_changed" and

View File

@ -58,6 +58,7 @@
#include "widgets/gimplistitem.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppreview.h"
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptoolbox.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpvectorslistview.h"
@ -129,8 +130,10 @@ 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_indexed_palette_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_selection_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context);
@ -141,18 +144,21 @@ static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func);
static void dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpItemListView *view);
static void dialogs_path_view_image_changed (GimpContext *context,
GimpImage *gimage,
GtkWidget *view);
static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
static void dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpItemListView *view);
static void dialogs_path_view_image_changed (GimpContext *context,
GimpImage *gimage,
GtkWidget *view);
static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor);
static void dialogs_selection_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpSelectionEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
/**********************/
@ -811,6 +817,29 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
return dockable;
}
GtkWidget *
dialogs_selection_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
view = gimp_selection_editor_new (gimage);
dockable = dialogs_dockable_new (view,
_("Selection Editor"), _("Selection"), NULL,
NULL,
dialogs_set_selection_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
return dockable;
}
/***** misc dockables *****/
@ -1337,6 +1366,41 @@ dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
}
}
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 (G_OBJECT (dockable->context),
dialogs_selection_editor_image_changed,
view);
}
if (context)
{
g_signal_connect (G_OBJECT (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_navigation_context_func (GimpDockable *dockable,
GimpContext *context)
@ -1419,6 +1483,14 @@ dialogs_indexed_palette_image_changed (GimpContext *context,
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_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,

View File

@ -123,6 +123,9 @@ GtkWidget * dialogs_path_list_view_new (GimpDialogFactory *factory,
GtkWidget * dialogs_indexed_palette_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_selection_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_document_history_new (GimpDialogFactory *factory,
GimpContext *context,

View File

@ -74,6 +74,7 @@ static const GimpDialogFactoryEntry dock_entries[] =
{ "gimp-vectors-list", dialogs_vectors_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp-path-list", dialogs_path_list_view_new, 32, TRUE, FALSE, FALSE, TRUE },
{ "gimp-indexed-palette", dialogs_indexed_palette_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp-selection-editor", dialogs_selection_editor_new, 0, FALSE, FALSE, FALSE, TRUE },
{ "gimp-document-history", dialogs_document_history_new, 48, FALSE, FALSE, FALSE, TRUE },

View File

@ -58,6 +58,7 @@
#include "widgets/gimplistitem.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppreview.h"
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptoolbox.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpvectorslistview.h"
@ -129,8 +130,10 @@ 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_indexed_palette_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_selection_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_navigation_context_func (GimpDockable *dockable,
GimpContext *context);
@ -141,18 +144,21 @@ static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
GimpDockableGetTabFunc get_tab_func,
GimpDockableSetContextFunc set_context_func);
static void dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpItemListView *view);
static void dialogs_path_view_image_changed (GimpContext *context,
GimpImage *gimage,
GtkWidget *view);
static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
static void dialogs_image_item_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpItemListView *view);
static void dialogs_path_view_image_changed (GimpContext *context,
GimpImage *gimage,
GtkWidget *view);
static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpImage *gimage,
GimpColormapEditor *editor);
static void dialogs_selection_editor_image_changed (GimpContext *context,
GimpImage *gimage,
GimpSelectionEditor *editor);
static void dialogs_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view);
/**********************/
@ -811,6 +817,29 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
return dockable;
}
GtkWidget *
dialogs_selection_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
view = gimp_selection_editor_new (gimage);
dockable = dialogs_dockable_new (view,
_("Selection Editor"), _("Selection"), NULL,
NULL,
dialogs_set_selection_editor_context_func);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
return dockable;
}
/***** misc dockables *****/
@ -1337,6 +1366,41 @@ dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
}
}
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 (G_OBJECT (dockable->context),
dialogs_selection_editor_image_changed,
view);
}
if (context)
{
g_signal_connect (G_OBJECT (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_navigation_context_func (GimpDockable *dockable,
GimpContext *context)
@ -1419,6 +1483,14 @@ dialogs_indexed_palette_image_changed (GimpContext *context,
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_navigation_display_changed (GimpContext *context,
GimpDisplay *gdisp,

View File

@ -123,6 +123,9 @@ GtkWidget * dialogs_path_list_view_new (GimpDialogFactory *factory,
GtkWidget * dialogs_indexed_palette_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_selection_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_document_history_new (GimpDialogFactory *factory,
GimpContext *context,

View File

@ -74,6 +74,7 @@ static const GimpDialogFactoryEntry dock_entries[] =
{ "gimp-vectors-list", dialogs_vectors_list_view_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp-path-list", dialogs_path_list_view_new, 32, TRUE, FALSE, FALSE, TRUE },
{ "gimp-indexed-palette", dialogs_indexed_palette_new, 32, FALSE, FALSE, FALSE, TRUE },
{ "gimp-selection-editor", dialogs_selection_editor_new, 0, FALSE, FALSE, FALSE, TRUE },
{ "gimp-document-history", dialogs_document_history_new, 48, FALSE, FALSE, FALSE, TRUE },

View File

@ -200,6 +200,11 @@ static GimpItemFactoryEntry toolbox_entries[] =
SEPARATOR ("/File/Dialogs/---"),
{ { N_("/File/Dialogs/Selection Editor..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT },
"gimp-selection-editor",
NULL, NULL },
{ { N_("/File/Dialogs/Navigation..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_NAVIGATION },
@ -923,6 +928,11 @@ static GimpItemFactoryEntry image_entries[] =
SEPARATOR ("/Dialogs/---"),
{ { N_("/Dialogs/Selection Editor..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT },
"gimp-selection-editor",
NULL, NULL },
{ { N_("/Dialogs/Navigation..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_NAVIGATION },
@ -1404,6 +1414,8 @@ static GimpItemFactoryEntry dialogs_entries[] =
SEPARATOR ("/Add Tab/---"),
ADD_TAB (N_("/Add Tab/Selection Editor..."), "gimp-selection-editor",
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT),
ADD_TAB (N_("/Add Tab/Navigation..."), "gimp-navigation-view",
"<StockItem>", GIMP_STOCK_NAVIGATION),
ADD_TAB (N_("/Add Tab/Images..."), "gimp-image-list", NULL, NULL),

View File

@ -200,6 +200,11 @@ static GimpItemFactoryEntry toolbox_entries[] =
SEPARATOR ("/File/Dialogs/---"),
{ { N_("/File/Dialogs/Selection Editor..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT },
"gimp-selection-editor",
NULL, NULL },
{ { N_("/File/Dialogs/Navigation..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_NAVIGATION },
@ -923,6 +928,11 @@ static GimpItemFactoryEntry image_entries[] =
SEPARATOR ("/Dialogs/---"),
{ { N_("/Dialogs/Selection Editor..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT },
"gimp-selection-editor",
NULL, NULL },
{ { N_("/Dialogs/Navigation..."), NULL,
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_NAVIGATION },
@ -1404,6 +1414,8 @@ static GimpItemFactoryEntry dialogs_entries[] =
SEPARATOR ("/Add Tab/---"),
ADD_TAB (N_("/Add Tab/Selection Editor..."), "gimp-selection-editor",
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT),
ADD_TAB (N_("/Add Tab/Navigation..."), "gimp-navigation-view",
"<StockItem>", GIMP_STOCK_NAVIGATION),
ADD_TAB (N_("/Add Tab/Images..."), "gimp-image-list", NULL, NULL),

View File

@ -18,140 +18,52 @@
#include "config.h"
#include <stdlib.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "base/pixel-region.h"
#include "base/temp-buf.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-contiguous-region.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpimage-projection.h"
#include "core/gimptoolinfo.h"
#include "file/file-utils.h"
#include "widgets/gimpdnd.h"
#include "display/gimpdisplay.h"
#include "gimpbycolorselecttool.h"
#include "selection_options.h"
#include "tool_manager.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#define PREVIEW_WIDTH 256
#define PREVIEW_HEIGHT 256
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_ENTER_NOTIFY_MASK
typedef struct _ByColorDialog ByColorDialog;
struct _ByColorDialog
{
GtkWidget *shell;
GtkWidget *preview;
GtkWidget *gimage_name;
GimpImage *gimage; /* gimpimage which is currently under examination */
};
/* Local functions */
static void gimp_by_color_select_tool_class_init (GimpByColorSelectToolClass *klass);
static void gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select);
static void gimp_by_color_select_tool_initialize_by_image (GimpImage *gimage);
static void by_color_select_color_drop (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
/* by_color select action functions */
static void by_color_select_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void by_color_select_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void by_color_select_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void by_color_select_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void by_color_select_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void by_color_select_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void by_color_select_mask_changed (GimpImage *gimage);
static ByColorDialog * by_color_select_dialog_new (void);
static void by_color_select_render (ByColorDialog *,
GimpImage *);
static void by_color_select_draw (ByColorDialog *,
GimpImage *);
static gint by_color_select_preview_events (GtkWidget *,
GdkEventButton *,
ByColorDialog *);
static void by_color_select_invert_callback (GtkWidget *,
gpointer );
static void by_color_select_select_all_callback (GtkWidget *,
gpointer );
static void by_color_select_select_none_callback (GtkWidget *,
gpointer );
static void by_color_select_close_callback (GtkWidget *,
gpointer );
static void by_color_select_preview_button_press (ByColorDialog *,
GdkEventButton *);
static void gimp_by_color_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_by_color_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_by_color_select_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_by_color_select_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static GimpSelectionToolClass *parent_class = NULL;
static ByColorDialog *by_color_dialog = NULL;
/* dnd stuff */
static GtkTargetEntry by_color_select_targets[] =
{
GIMP_TARGET_COLOR
};
/* public functions */
@ -199,17 +111,6 @@ gimp_by_color_select_tool_get_type (void)
return tool_type;
}
void
gimp_by_color_select_tool_initialize_by_image (GimpImage *gimage)
{
/* update the preview window */
if (by_color_dialog)
{
by_color_dialog->gimage = gimage;
by_color_select_render (by_color_dialog, gimage);
by_color_select_draw (by_color_dialog, gimage);
}
}
/* private functions */
@ -222,22 +123,18 @@ gimp_by_color_select_tool_class_init (GimpByColorSelectToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
tool_class->initialize = by_color_select_initialize;
tool_class->control = by_color_select_control;
tool_class->button_press = by_color_select_button_press;
tool_class->button_release = by_color_select_button_release;
tool_class->oper_update = by_color_select_oper_update;
tool_class->cursor_update = by_color_select_cursor_update;
tool_class->button_press = gimp_by_color_select_tool_button_press;
tool_class->button_release = gimp_by_color_select_tool_button_release;
tool_class->oper_update = gimp_by_color_select_tool_oper_update;
tool_class->cursor_update = gimp_by_color_select_tool_cursor_update;
}
static void
gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
{
GimpTool *tool;
GimpSelectionTool *select_tool;
GimpTool *tool;
tool = GIMP_TOOL (by_color_select);
select_tool = GIMP_SELECTION_TOOL (by_color_select);
tool = GIMP_TOOL (by_color_select);
gimp_tool_control_set_preserve (tool->control, FALSE);
gimp_tool_control_set_preserve (tool->control, GIMP_RECT_SELECT_TOOL_CURSOR);
@ -247,74 +144,21 @@ gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
}
static void
by_color_select_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp)
{
switch (action)
{
case PAUSE:
break;
case RESUME:
break;
case HALT:
if (by_color_dialog)
by_color_select_close_callback (NULL, (gpointer) by_color_dialog);
break;
default:
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
}
void
by_color_select_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
/* The "by color" dialog */
if (!by_color_dialog)
{
by_color_dialog = by_color_select_dialog_new ();
/* Catch the "mask_changed" signal and attach a handler that does
* stuff with it. Need to do this somewhere with the relevant
* GimpImage in context
*/
g_signal_connect (G_OBJECT (gdisp->gimage), "mask_changed",
G_CALLBACK (by_color_select_mask_changed),
NULL);
}
else
if (!GTK_WIDGET_VISIBLE (by_color_dialog->shell))
gtk_widget_show (by_color_dialog->shell);
gimp_by_color_select_tool_initialize_by_image (gdisp->gimage);
}
static void
by_color_select_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
gimp_by_color_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_color_sel;
GimpDrawTool *draw_tool;
SelectionOptions *sel_options;
draw_tool = GIMP_DRAW_TOOL (tool);
by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool);
sel_options = (SelectionOptions *) tool->tool_info->tool_options;
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
if (! by_color_dialog)
return;
gimp_tool_control_activate (tool->control);
tool->gdisp = gdisp;
@ -331,31 +175,14 @@ by_color_select_button_press (GimpTool *tool,
by_color_sel->x -= off_x;
by_color_sel->y -= off_y;
}
/* Make sure the "by color" select dialog is visible */
if (! GTK_WIDGET_VISIBLE (by_color_dialog->shell))
gtk_widget_show (by_color_dialog->shell);
if (by_color_dialog->gimage != gdisp->gimage)
{
gdk_draw_rectangle
(by_color_dialog->preview->window,
by_color_dialog->preview->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
0, 0,
by_color_dialog->preview->allocation.width,
by_color_dialog->preview->allocation.width);
by_color_dialog->gimage = gdisp->gimage;
}
}
static void
by_color_select_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
gimp_by_color_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_color_sel;
GimpSelectionTool *sel_tool;
@ -398,10 +225,8 @@ by_color_select_button_release (GimpTool *tool,
}
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], col[3]);
g_free (col);
/* select the area */
gimp_image_mask_select_by_color (gdisp->gimage, drawable,
sel_options->sample_merged,
&color,
@ -413,21 +238,16 @@ by_color_select_button_release (GimpTool *tool,
sel_options->feather_radius,
sel_options->feather_radius);
/* show selection on all views */
gimp_image_flush (gdisp->gimage);
/* update the preview window */
by_color_select_render (by_color_dialog, gdisp->gimage);
by_color_select_draw (by_color_dialog, gdisp->gimage);
}
}
}
static void
by_color_select_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
gimp_by_color_select_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpSelectionTool *sel_tool;
SelectionOptions *sel_options;
@ -458,10 +278,10 @@ by_color_select_oper_update (GimpTool *tool,
}
static void
by_color_select_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
gimp_by_color_select_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_col_sel;
SelectionOptions *sel_options;
@ -485,499 +305,3 @@ by_color_select_cursor_update (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
}
void
by_color_select_mask_changed (GimpImage *gimage)
{
if (by_color_dialog)
gimp_by_color_select_tool_initialize_by_image (gimage);
}
/****************************/
/* Select by Color dialog */
/****************************/
static ByColorDialog *
by_color_select_dialog_new (void)
{
ByColorDialog *bcd;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
bcd = g_new (ByColorDialog, 1);
bcd->gimage = NULL;
/* The shell and main vbox */
bcd->shell = gimp_dialog_new (_("By Color Selection"), "by_color_selection",
NULL, NULL,
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
"_delete_event_", by_color_select_close_callback,
bcd, NULL, NULL, TRUE, TRUE,
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (bcd->shell), FALSE);
gtk_widget_hide (GTK_DIALOG (bcd->shell)->action_area);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->vbox), vbox);
gtk_widget_show (vbox);
/* Create the active image label */
bcd->gimage_name = gtk_label_new (_("Inactive"));
gtk_misc_set_alignment (GTK_MISC (bcd->gimage_name), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), bcd->gimage_name, FALSE, FALSE, 0);
gtk_widget_show (bcd->gimage_name);
/* The preview */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
bcd->preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
gtk_preview_size (GTK_PREVIEW (bcd->preview), PREVIEW_WIDTH, PREVIEW_HEIGHT);
gtk_widget_set_events (bcd->preview, PREVIEW_EVENT_MASK);
gtk_container_add (GTK_CONTAINER (frame), bcd->preview);
g_signal_connect (G_OBJECT (bcd->preview), "button_press_event",
G_CALLBACK (by_color_select_preview_events),
bcd);
/* dnd colors to the image window */
gtk_drag_dest_set (bcd->preview,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
by_color_select_targets,
G_N_ELEMENTS (by_color_select_targets),
GDK_ACTION_COPY);
gimp_dnd_color_dest_set (bcd->preview, by_color_select_color_drop, bcd);
gtk_widget_show (bcd->preview);
gtk_widget_show (frame);
frame = gtk_frame_new (_("Selection"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gtk_hbox_new (TRUE, 2);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
button = gtk_button_new_with_label (_("Invert"));
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (by_color_select_invert_callback),
bcd);
button = gtk_button_new_with_label (_("All"));
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (by_color_select_select_all_callback),
bcd);
button = gtk_button_new_with_label (_("None"));
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (by_color_select_select_none_callback),
bcd);
gtk_widget_show (bcd->shell);
return bcd;
}
static void
by_color_select_render (ByColorDialog *bcd,
GimpImage *gimage)
{
GimpChannel *mask;
MaskBuf *scaled_buf = NULL;
guchar *buf;
PixelRegion srcPR, destPR;
guchar *src;
gint subsample;
gint width, height;
gint srcwidth;
gint i;
gint scale;
mask = gimp_image_get_mask (gimage);
if ((gimp_drawable_width (GIMP_DRAWABLE(mask)) > PREVIEW_WIDTH) ||
(gimp_drawable_height (GIMP_DRAWABLE(mask)) > PREVIEW_HEIGHT))
{
if (((float) gimp_drawable_width (GIMP_DRAWABLE (mask)) / (float) PREVIEW_WIDTH) >
((float) gimp_drawable_height (GIMP_DRAWABLE (mask)) / (float) PREVIEW_HEIGHT))
{
width = PREVIEW_WIDTH;
height = ((gimp_drawable_height (GIMP_DRAWABLE (mask)) * PREVIEW_WIDTH) /
gimp_drawable_width (GIMP_DRAWABLE (mask)));
}
else
{
width = ((gimp_drawable_width (GIMP_DRAWABLE (mask)) * PREVIEW_HEIGHT) /
gimp_drawable_height (GIMP_DRAWABLE (mask)));
height = PREVIEW_HEIGHT;
}
scale = TRUE;
}
else
{
width = gimp_drawable_width (GIMP_DRAWABLE (mask));
height = gimp_drawable_height (GIMP_DRAWABLE (mask));
scale = FALSE;
}
if ((width != bcd->preview->requisition.width) ||
(height != bcd->preview->requisition.height))
gtk_preview_size (GTK_PREVIEW (bcd->preview), width, height);
/* clear the image buf */
buf = g_new0 (guchar, bcd->preview->requisition.width);
for (i = 0; i < bcd->preview->requisition.height; i++)
gtk_preview_draw_row (GTK_PREVIEW (bcd->preview), buf,
0, i, bcd->preview->requisition.width);
g_free (buf);
/* if the mask is empty, no need to scale and update again */
if (gimp_image_mask_is_empty (gimage))
return;
if (scale)
{
/* calculate 'acceptable' subsample */
subsample = 1;
while ((width * (subsample + 1) * 2 < gimp_drawable_width (GIMP_DRAWABLE (mask))) &&
(height * (subsample + 1) * 2 < gimp_drawable_height (GIMP_DRAWABLE (mask))))
subsample = subsample + 1;
pixel_region_init (&srcPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (mask)),
gimp_drawable_height (GIMP_DRAWABLE (mask)), FALSE);
scaled_buf = mask_buf_new (width, height);
destPR.bytes = 1;
destPR.x = 0;
destPR.y = 0;
destPR.w = width;
destPR.h = height;
destPR.rowstride = srcPR.bytes * width;
destPR.data = mask_buf_data (scaled_buf);
destPR.tiles = NULL;
subsample_region (&srcPR, &destPR, subsample);
}
else
{
pixel_region_init (&srcPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (mask)),
gimp_drawable_height (GIMP_DRAWABLE (mask)), FALSE);
scaled_buf = mask_buf_new (width, height);
destPR.bytes = 1;
destPR.x = 0;
destPR.y = 0;
destPR.w = width;
destPR.h = height;
destPR.rowstride = srcPR.bytes * width;
destPR.data = mask_buf_data (scaled_buf);
destPR.tiles = NULL;
copy_region (&srcPR, &destPR);
}
src = mask_buf_data (scaled_buf);
srcwidth = scaled_buf->width;
for (i = 0; i < height; i++)
{
gtk_preview_draw_row (GTK_PREVIEW (bcd->preview), src, 0, i, width);
src += srcwidth;
}
mask_buf_free (scaled_buf);
}
static void
by_color_select_draw (ByColorDialog *bcd,
GimpImage *gimage)
{
gchar *basename;
gtk_widget_queue_draw (bcd->preview);
basename = file_utils_uri_to_utf8_basename (gimp_image_get_uri (gimage));
gtk_label_set_text (GTK_LABEL (bcd->gimage_name), basename);
g_free (basename);
}
static gint
by_color_select_preview_events (GtkWidget *widget,
GdkEventButton *bevent,
ByColorDialog *bcd)
{
switch (bevent->type)
{
case GDK_BUTTON_PRESS:
by_color_select_preview_button_press (bcd, bevent);
break;
default:
break;
}
return FALSE;
}
static void
by_color_select_invert_callback (GtkWidget *widget,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
if (!bcd->gimage)
return;
/* check if the image associated to the mask still exists */
if (! gimp_item_get_image (GIMP_ITEM (gimp_image_get_mask (bcd->gimage))))
return;
/* invert the mask */
gimp_image_mask_invert (bcd->gimage);
/* show selection on all views */
gimp_image_flush (bcd->gimage);
/* update the preview window */
by_color_select_render (bcd, bcd->gimage);
by_color_select_draw (bcd, bcd->gimage);
}
static void
by_color_select_select_all_callback (GtkWidget *widget,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
if (!bcd->gimage)
return;
/* check if the image associated to the mask still exists */
if (! gimp_item_get_image (GIMP_ITEM (gimp_image_get_mask (bcd->gimage))))
return;
/* fill the mask */
gimp_image_mask_all (bcd->gimage);
/* show selection on all views */
gimp_image_flush (bcd->gimage);
/* update the preview window */
by_color_select_render (bcd, bcd->gimage);
by_color_select_draw (bcd, bcd->gimage);
}
static void
by_color_select_select_none_callback (GtkWidget *widget,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
if (!bcd->gimage)
return;
/* check if the image associated to the mask still exists */
if (! gimp_item_get_image (GIMP_ITEM (gimp_image_get_mask (bcd->gimage))))
return;
/* reset the mask */
gimp_image_mask_clear (bcd->gimage);
/* show selection on all views */
gimp_image_flush (bcd->gimage);
/* update the preview window */
by_color_select_render (bcd, bcd->gimage);
by_color_select_draw (bcd, bcd->gimage);
}
static void
by_color_select_close_callback (GtkWidget *widget,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
gtk_widget_hide (bcd->shell);
/* if (bcd->gimage && gimp_container_have (image_context,
* GIMP_OBJECT (bcd->gimage)))
* {
* bcd->gimage->by_color_select = FALSE;
* }
* Temporarily commented out. */
bcd->gimage = NULL;
}
static void
by_color_select_preview_button_press (ByColorDialog *bcd,
GdkEventButton *bevent)
{
GimpToolInfo *tool_info;
SelectionOptions *sel_options;
gint x, y;
gboolean replace;
SelectOps operation;
GimpDrawable *drawable;
guchar *col;
GimpRGB color;
if (! bcd->gimage)
return;
tool_info = tool_manager_get_info_by_type (bcd->gimage->gimp,
GIMP_TYPE_BY_COLOR_SELECT_TOOL);
sel_options = (SelectionOptions *) tool_info->tool_options;
drawable = gimp_image_active_drawable (bcd->gimage);
/* check if the gimage associated to the drawable still exists */
if (! gimp_item_get_image (GIMP_ITEM (drawable)))
return;
/* Defaults */
replace = FALSE;
operation = SELECTION_REPLACE;
/* Based on modifiers, and the "by color" dialog's selection mode */
if ((bevent->state & GDK_SHIFT_MASK) &&
!(bevent->state & GDK_CONTROL_MASK))
operation = SELECTION_ADD;
else if ((bevent->state & GDK_CONTROL_MASK) &&
!(bevent->state & GDK_SHIFT_MASK))
operation = SELECTION_SUBTRACT;
else if ((bevent->state & GDK_CONTROL_MASK) &&
(bevent->state & GDK_SHIFT_MASK))
operation = SELECTION_INTERSECT;
else
operation = sel_options->op;
/* Find x, y and modify selection */
/* Get the start color */
if (sel_options->sample_merged)
{
x = bcd->gimage->width * bevent->x / bcd->preview->requisition.width;
y = bcd->gimage->height * bevent->y / bcd->preview->requisition.height;
if (x < 0 || y < 0 || x >= bcd->gimage->width || y >= bcd->gimage->height)
return;
col = gimp_image_projection_get_color_at (bcd->gimage, x, y);
}
else
{
gint offx, offy;
gimp_drawable_offsets (drawable, &offx, &offy);
x = (gimp_drawable_width (drawable) * bevent->x /
bcd->preview->requisition.width - offx);
y = (gimp_drawable_height (drawable) * bevent->y /
bcd->preview->requisition.height - offy);
if (x < 0 || y < 0 ||
x >= gimp_drawable_width (drawable) || y >= gimp_drawable_height (drawable))
return;
col = gimp_drawable_get_color_at (drawable, x, y);
}
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], col[3]);
g_free (col);
gimp_image_mask_select_by_color (bcd->gimage, drawable,
sel_options->sample_merged,
&color,
sel_options->threshold,
sel_options->select_transparent,
operation,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
/* show selection on all views */
gimp_image_flush (bcd->gimage);
/* update the preview window */
by_color_select_render (bcd, bcd->gimage);
by_color_select_draw (bcd, bcd->gimage);
}
static void
by_color_select_color_drop (GtkWidget *widget,
const GimpRGB *color,
gpointer data)
{
GimpToolInfo *tool_info;
SelectionOptions *sel_options;
GimpDrawable *drawable;
ByColorDialog *bcd;
bcd = (ByColorDialog*) data;
tool_info = tool_manager_get_info_by_type (bcd->gimage->gimp,
GIMP_TYPE_BY_COLOR_SELECT_TOOL);
sel_options = (SelectionOptions *) tool_info->tool_options;
drawable = gimp_image_active_drawable (bcd->gimage);
gimp_image_mask_select_by_color (bcd->gimage, drawable,
sel_options->sample_merged,
color,
sel_options->threshold,
sel_options->select_transparent,
sel_options->op,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
/* show selection on all views */
gimp_image_flush (bcd->gimage);
/* update the preview window */
by_color_select_render (bcd, bcd->gimage);
by_color_select_draw (bcd, bcd->gimage);
}

View File

@ -31,9 +31,7 @@
#define GIMP_BY_COLOR_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BY_COLOR_SELECT_TOOL, GimpByColorSelectToolClass))
/* the by color selection structures */
typedef struct _GimpByColorSelectTool GimpByColorSelectTool;
typedef struct _GimpByColorSelectTool GimpByColorSelectTool;
typedef struct _GimpByColorSelectToolClass GimpByColorSelectToolClass;
struct _GimpByColorSelectTool
@ -43,10 +41,9 @@ struct _GimpByColorSelectTool
gint x, y; /* Point from which to execute seed fill */
};
struct _GimpByColorSelectToolClass
{
GimpSelectionToolClass klass;
GimpSelectionToolClass parent_class;
};

View File

@ -131,6 +131,8 @@ libappwidgets_a_sources = \
gimppreview.h \
gimppreview-utils.c \
gimppreview-utils.h \
gimpselectioneditor.c \
gimpselectioneditor.h \
gimptoolbox.c \
gimptoolbox.h \
gimptoolbox-color-area.c \

View File

@ -47,45 +47,46 @@
GType
gimp_preview_type_from_viewable (GimpViewable *viewable)
gimp_preview_type_from_viewable_type (GType viewable_type)
{
GType type = GIMP_TYPE_PREVIEW;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), G_TYPE_NONE);
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE),
G_TYPE_NONE);
if (GIMP_IS_BRUSH (viewable))
if (g_type_is_a (viewable_type, GIMP_TYPE_BRUSH))
{
type = GIMP_TYPE_BRUSH_PREVIEW;
}
else if (GIMP_IS_DRAWABLE (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_DRAWABLE))
{
type = GIMP_TYPE_DRAWABLE_PREVIEW;
}
else if (GIMP_IS_IMAGE (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_IMAGE))
{
type = GIMP_TYPE_IMAGE_PREVIEW;
}
else if (GIMP_IS_PATTERN (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_PATTERN))
{
type = GIMP_TYPE_PATTERN_PREVIEW;
}
else if (GIMP_IS_GRADIENT (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_GRADIENT))
{
type = GIMP_TYPE_GRADIENT_PREVIEW;
}
else if (GIMP_IS_PALETTE (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_PALETTE))
{
type = GIMP_TYPE_PALETTE_PREVIEW;
}
else if (GIMP_IS_BUFFER (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_BUFFER))
{
type = GIMP_TYPE_BUFFER_PREVIEW;
}
else if (GIMP_IS_TOOL_INFO (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_TOOL_INFO))
{
type = GIMP_TYPE_TOOL_INFO_PREVIEW;
}
else if (GIMP_IS_IMAGEFILE (viewable))
else if (g_type_is_a (viewable_type, GIMP_TYPE_IMAGEFILE))
{
type = GIMP_TYPE_IMAGEFILE_PREVIEW;
}

View File

@ -23,7 +23,7 @@
#define __GIMP_PREVIEW_UTILS_H__
GType gimp_preview_type_from_viewable (GimpViewable *viewable);
GType gimp_preview_type_from_viewable_type (GType viewable_type);
#endif /* __GIMP_PREVIEW_UTILS_H__ */

View File

@ -509,12 +509,16 @@ gimp_preview_new (GimpViewable *viewable,
gboolean is_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
@ -535,13 +539,17 @@ gimp_preview_new_full (GimpViewable *viewable,
gboolean show_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0 && width <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (height > 0 && height <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->clickable = clickable;
@ -554,15 +562,44 @@ gimp_preview_new_full (GimpViewable *viewable,
return GTK_WIDGET (preview);
}
GtkWidget *
gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup)
{
GimpPreview *preview;
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->size = size;
preview->border_width = border_width;
return GTK_WIDGET (preview);
}
void
gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (! viewable ||
g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable (viewable)));
if (viewable)
{
GType viewable_type;
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable_type (viewable_type)));
}
if (viewable == preview->viewable)
return;

View File

@ -107,6 +107,11 @@ GtkWidget * gimp_preview_new_full (GimpViewable *viewable,
gboolean clickable,
gboolean show_popup);
GtkWidget * gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup);
void gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable);

View File

@ -509,12 +509,16 @@ gimp_preview_new (GimpViewable *viewable,
gboolean is_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
@ -535,13 +539,17 @@ gimp_preview_new_full (GimpViewable *viewable,
gboolean show_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0 && width <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (height > 0 && height <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->clickable = clickable;
@ -554,15 +562,44 @@ gimp_preview_new_full (GimpViewable *viewable,
return GTK_WIDGET (preview);
}
GtkWidget *
gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup)
{
GimpPreview *preview;
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->size = size;
preview->border_width = border_width;
return GTK_WIDGET (preview);
}
void
gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (! viewable ||
g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable (viewable)));
if (viewable)
{
GType viewable_type;
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable_type (viewable_type)));
}
if (viewable == preview->viewable)
return;

View File

@ -107,6 +107,11 @@ GtkWidget * gimp_preview_new_full (GimpViewable *viewable,
gboolean clickable,
gboolean show_popup);
GtkWidget * gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup);
void gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable);

View File

@ -0,0 +1,521 @@
/* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#ifdef __GNUC__
#warning #include "tools/tools-types.h"
#endif
#include "tools/tools-types.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpimage-projection.h"
#include "core/gimptoolinfo.h"
#include "tools/gimpbycolorselecttool.h"
#include "tools/selection_options.h"
#include "tools/tool_manager.h"
#include "gimpselectioneditor.h"
#include "gimpdnd.h"
#include "gimppreview.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
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_abox_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpSelectionEditor *editor);
static void gimp_selection_editor_invert_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
static void gimp_selection_editor_all_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
static void gimp_selection_editor_none_clicked (GtkWidget *widget,
GimpSelectionEditor *editor);
static gboolean gimp_selection_preview_button_press(GtkWidget *widget,
GdkEventButton *bevent,
GimpSelectionEditor *editor);
static void gimp_selection_editor_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
static void gimp_selection_editor_mask_changed (GimpImage *gimage,
GimpSelectionEditor *editor);
static gboolean gimp_selection_editor_idle_render (GimpSelectionEditor *editor);
static GimpEditorClass *parent_class = NULL;
static GtkTargetEntry selection_editor_targets[] =
{
GIMP_TARGET_COLOR
};
GType
gimp_selection_editor_get_type (void)
{
static GType editor_type = 0;
if (! editor_type)
{
static const GTypeInfo editor_info =
{
sizeof (GimpSelectionEditorClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_selection_editor_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpSelectionEditor),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_selection_editor_init,
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpSelectionEditor",
&editor_info, 0);
}
return editor_type;
}
static void
gimp_selection_editor_class_init (GimpSelectionEditorClass* klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_selection_editor_destroy;
}
static void
gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
{
GtkWidget *frame;
GtkWidget *abox;
selection_editor->gimage = NULL;
selection_editor->idle_render_id = 0;
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);
gtk_widget_show (frame);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (frame), abox);
gtk_widget_show (abox);
gtk_widget_set_size_request (abox,
gimprc.nav_preview_size,
gimprc.nav_preview_size);
g_signal_connect (G_OBJECT (abox), "size_allocate",
G_CALLBACK (gimp_selection_editor_abox_resized),
selection_editor);
selection_editor->preview = gimp_preview_new_by_type (GIMP_TYPE_DRAWABLE,
gimprc.nav_preview_size,
0,
FALSE);
gtk_container_add (GTK_CONTAINER (abox), selection_editor->preview);
gtk_widget_show (selection_editor->preview);
g_signal_connect (G_OBJECT (selection_editor->preview), "button_press_event",
G_CALLBACK (gimp_selection_preview_button_press),
selection_editor);
gtk_drag_dest_set (selection_editor->preview,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
selection_editor_targets,
G_N_ELEMENTS (selection_editor_targets),
GDK_ACTION_COPY);
gimp_dnd_color_dest_set (selection_editor->preview,
gimp_selection_editor_drop_color,
selection_editor);
selection_editor->invert_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GIMP_STOCK_INVERT,
_("Invert Selection"), NULL,
G_CALLBACK (gimp_selection_editor_invert_clicked),
NULL,
selection_editor);
selection_editor->all_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GTK_STOCK_ADD,
_("Select All"), NULL,
G_CALLBACK (gimp_selection_editor_all_clicked),
NULL,
selection_editor);
selection_editor->none_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GTK_STOCK_REMOVE,
_("Select None"), NULL,
G_CALLBACK (gimp_selection_editor_none_clicked),
NULL,
selection_editor);
gtk_widget_set_sensitive (GTK_WIDGET (selection_editor), FALSE);
}
static void
gimp_selection_editor_destroy (GtkObject *object)
{
GimpSelectionEditor *editor;
editor = GIMP_SELECTION_EDITOR (object);
if (editor->gimage)
gimp_selection_editor_set_image (editor, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/* public functions */
#define PREVIEW_WIDTH 256
#define PREVIEW_HEIGHT 256
GtkWidget *
gimp_selection_editor_new (GimpImage *gimage)
{
GimpSelectionEditor *editor;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
editor = g_object_new (GIMP_TYPE_SELECTION_EDITOR, NULL);
gimp_selection_editor_set_image (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->idle_render_id)
{
g_source_remove (editor->idle_render_id);
editor->idle_render_id = 0;
}
if (editor->gimage)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (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 (G_OBJECT (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;
preview = GIMP_PREVIEW (editor->preview);
if (! preview->viewable)
return;
if (preview->width > allocation->width ||
preview->height > allocation->height ||
(preview->width != allocation->width &&
preview->height != allocation->height))
{
gint width;
gint height;
gboolean dummy;
gimp_preview_calc_size (preview,
editor->gimage->width,
editor->gimage->height,
MIN (allocation->width, GIMP_PREVIEW_MAX_SIZE),
MIN (allocation->height, GIMP_PREVIEW_MAX_SIZE),
editor->gimage->xresolution,
editor->gimage->yresolution,
&width,
&height,
&dummy);
if (width > allocation->width)
{
height = height * allocation->width / width;
width = width * allocation->width / width;
}
else if (height > allocation->height)
{
width = width * allocation->height / height;
height = height * allocation->height / height;
}
gimp_preview_set_size_full (preview, width, height, preview->border_width);
}
}
static void
gimp_selection_editor_invert_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
{
if (editor->gimage)
{
gimp_image_mask_invert (editor->gimage);
gimp_image_flush (editor->gimage);
}
}
static void
gimp_selection_editor_all_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
{
if (editor->gimage)
{
gimp_image_mask_all (editor->gimage);
gimp_image_flush (editor->gimage);
}
}
static void
gimp_selection_editor_none_clicked (GtkWidget *widget,
GimpSelectionEditor *editor)
{
if (editor->gimage)
{
gimp_image_mask_clear (editor->gimage);
gimp_image_flush (editor->gimage);
}
}
static gboolean
gimp_selection_preview_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpSelectionEditor *editor)
{
GimpToolInfo *tool_info;
SelectionOptions *sel_options;
GimpDrawable *drawable;
SelectOps operation = SELECTION_REPLACE;
gint x, y;
guchar *col;
GimpRGB color;
if (! editor->gimage)
return TRUE;
tool_info = tool_manager_get_info_by_type (editor->gimage->gimp,
GIMP_TYPE_BY_COLOR_SELECT_TOOL);
sel_options = (SelectionOptions *) tool_info->tool_options;
drawable = gimp_image_active_drawable (editor->gimage);
if (! drawable)
return TRUE;
if (bevent->state & GDK_SHIFT_MASK)
{
if (bevent->state & GDK_CONTROL_MASK)
{
operation = SELECTION_INTERSECT;
}
else
{
operation = SELECTION_ADD;
}
}
else if (bevent->state & GDK_CONTROL_MASK)
{
operation = SELECTION_SUBTRACT;
}
if (sel_options->sample_merged)
{
x = editor->gimage->width * bevent->x / editor->preview->allocation.width;
y = editor->gimage->height * bevent->y / editor->preview->allocation.height;
if (x < 0 || y < 0 ||
x >= editor->gimage->width ||
y >= editor->gimage->height)
return TRUE;
col = gimp_image_projection_get_color_at (editor->gimage, x, y);
}
else
{
gint offx, offy;
gimp_drawable_offsets (drawable, &offx, &offy);
x = (gimp_drawable_width (drawable) * bevent->x /
editor->preview->requisition.width - offx);
y = (gimp_drawable_height (drawable) * bevent->y /
editor->preview->requisition.height - offy);
if (x < 0 || y < 0 ||
x >= gimp_drawable_width (drawable) ||
y >= gimp_drawable_height (drawable))
return TRUE;
col = gimp_drawable_get_color_at (drawable, x, y);
}
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], col[3]);
g_free (col);
gimp_image_mask_select_by_color (editor->gimage, drawable,
sel_options->sample_merged,
&color,
sel_options->threshold,
sel_options->select_transparent,
operation,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
gimp_image_flush (editor->gimage);
return TRUE;
}
static void
gimp_selection_editor_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data)
{
GimpToolInfo *tool_info;
SelectionOptions *sel_options;
GimpDrawable *drawable;
GimpSelectionEditor *editor;
editor = GIMP_SELECTION_EDITOR (data);
if (! editor->gimage)
return;
tool_info = tool_manager_get_info_by_type (editor->gimage->gimp,
GIMP_TYPE_BY_COLOR_SELECT_TOOL);
sel_options = (SelectionOptions *) tool_info->tool_options;
drawable = gimp_image_active_drawable (editor->gimage);
if (! drawable)
return;
gimp_image_mask_select_by_color (editor->gimage, drawable,
sel_options->sample_merged,
color,
sel_options->threshold,
sel_options->select_transparent,
sel_options->op,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
gimp_image_flush (editor->gimage);
}
static void
gimp_selection_editor_mask_changed (GimpImage *gimage,
GimpSelectionEditor *editor)
{
if (editor->idle_render_id)
g_source_remove (editor->idle_render_id);
editor->idle_render_id =
g_idle_add ((GSourceFunc) gimp_selection_editor_idle_render, editor);
}
static gboolean
gimp_selection_editor_idle_render (GimpSelectionEditor *editor)
{
editor->idle_render_id = 0;
gimp_preview_render (GIMP_PREVIEW (editor->preview));
return FALSE;
}

View File

@ -0,0 +1,66 @@
/* 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_SELECTION_EDITOR_H__
#define __GIMP_SELECTION_EDITOR_H__
#include "gimpeditor.h"
#include "gui/gui-types.h" /* temp hack */
#define GIMP_TYPE_SELECTION_EDITOR (gimp_selection_editor_get_type ())
#define GIMP_SELECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SELECTION_EDITOR, GimpSelectionEditor))
#define GIMP_SELECTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SELECTION_EDITOR, GimpSelectionEditorClass))
#define GIMP_IS_SELECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SELECTION_EDITOR))
#define GIMP_IS_SELECTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SELECTION_EDITOR))
#define GIMP_SELECTION_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SELECTION_EDITOR, GimpSelectionEditorClass))
typedef struct _GimpSelectionEditorClass GimpSelectionEditorClass;
struct _GimpSelectionEditor
{
GimpEditor parent_instance;
GimpImage *gimage;
GtkWidget *preview;
GtkWidget *invert_button;
GtkWidget *all_button;
GtkWidget *none_button;
guint idle_render_id;
};
struct _GimpSelectionEditorClass
{
GimpEditorClass 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);
#endif /* __GIMP_SELECTION_EDITOR_H__ */

View File

@ -509,12 +509,16 @@ gimp_preview_new (GimpViewable *viewable,
gboolean is_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
@ -535,13 +539,17 @@ gimp_preview_new_full (GimpViewable *viewable,
gboolean show_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0 && width <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (height > 0 && height <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->clickable = clickable;
@ -554,15 +562,44 @@ gimp_preview_new_full (GimpViewable *viewable,
return GTK_WIDGET (preview);
}
GtkWidget *
gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup)
{
GimpPreview *preview;
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->size = size;
preview->border_width = border_width;
return GTK_WIDGET (preview);
}
void
gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (! viewable ||
g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable (viewable)));
if (viewable)
{
GType viewable_type;
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable_type (viewable_type)));
}
if (viewable == preview->viewable)
return;

View File

@ -107,6 +107,11 @@ GtkWidget * gimp_preview_new_full (GimpViewable *viewable,
gboolean clickable,
gboolean show_popup);
GtkWidget * gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup);
void gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable);

View File

@ -509,12 +509,16 @@ gimp_preview_new (GimpViewable *viewable,
gboolean is_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
@ -535,13 +539,17 @@ gimp_preview_new_full (GimpViewable *viewable,
gboolean show_popup)
{
GimpPreview *preview;
GType viewable_type;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0 && width <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (height > 0 && height <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->clickable = clickable;
@ -554,15 +562,44 @@ gimp_preview_new_full (GimpViewable *viewable,
return GTK_WIDGET (preview);
}
GtkWidget *
gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup)
{
GimpPreview *preview;
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = g_object_new (gimp_preview_type_from_viewable_type (viewable_type),
NULL);
preview->is_popup = is_popup;
preview->size = size;
preview->border_width = border_width;
return GTK_WIDGET (preview);
}
void
gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (! viewable ||
g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable (viewable)));
if (viewable)
{
GType viewable_type;
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview),
gimp_preview_type_from_viewable_type (viewable_type)));
}
if (viewable == preview->viewable)
return;

View File

@ -107,6 +107,11 @@ GtkWidget * gimp_preview_new_full (GimpViewable *viewable,
gboolean clickable,
gboolean show_popup);
GtkWidget * gimp_preview_new_by_type (GType viewable_type,
gint size,
gint border_width,
gboolean is_popup);
void gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable);

View File

@ -60,6 +60,7 @@ typedef struct _GimpDataEditor GimpDataEditor;
typedef struct _GimpBrushEditor GimpBrushEditor;
typedef struct _GimpGradientEditor GimpGradientEditor;
typedef struct _GimpPaletteEditor GimpPaletteEditor;
typedef struct _GimpSelectionEditor GimpSelectionEditor;
typedef struct _GimpContainerView GimpContainerView;
typedef struct _GimpContainerListView GimpContainerListView;

View File

@ -32,7 +32,7 @@ GIMPPRINT_REQUIRED_VERSION=4.2.0
#
GIMP_MAJOR_VERSION=1
GIMP_MINOR_VERSION=3
GIMP_MICRO_VERSION=8
GIMP_MICRO_VERSION=9
GIMP_INTERFACE_AGE=0
GIMP_BINARY_AGE=0
GIMP_VERSION=$GIMP_MAJOR_VERSION.$GIMP_MINOR_VERSION.$GIMP_MICRO_VERSION