app/apptypes.h app/Makefile.am new widget. The upcoming replacement for

2001-02-27  Michael Natterer  <mitch@gimp.org>

	* app/apptypes.h
	* app/Makefile.am
	* app/gimpdrawablelistview.[ch]: new widget. The upcoming replacement
	for the layers and channels dialogs.

	* app/test_commands.[ch]: put the test dialogs here...

	* app/commands.[ch]: ... and made this one clean again.

	* app/gimpcontainergridview.c
	* app/gimpcontainerlistview.c
	* app/gimpcontainerview.[ch]: some signal handling fine tuning.

	* app/gimpimage.[ch]: emits "active_layer_changed" and
	"active_channel_changed" signals now. The semantics of
	gimage->active_layer and gimage->active_channel have changed a bit.
	We now have either an active layer _or_ and active channel (there
	is no active layer any more if a channel is active).

	* app/channel_ops.c
	* app/floating_sel.c
	* app/gdisplay.c
	* app/layers_dialog.c
	* app/menus.c: changed accordingly.

	* app/tools/gimpcolorpickertool.c: actually assign the draw_class
	vraiable in the class_init function.

	* app/tools/gimpdrawtool.[ch]
	* app/tools/tool.c: removed the _new() functions because these
	objects are abstract superclasses. Did some cleanup.
	Nathan, please configure you editor to _not_ produce any tabs
	in the source code.

	* app/tools/gimppaintbrushtool.[ch]: "blurb" and "help" are tagged
	with _(), not N_(). Put the register function to the header.

	* po/POTFILES.in: made it compile again.
This commit is contained in:
Michael Natterer 2001-02-27 14:14:13 +00:00 committed by Michael Natterer
parent 80a8d5a75f
commit 8e3259d084
76 changed files with 5856 additions and 3149 deletions

View File

@ -1,5 +1,47 @@
2001-02-27 Michael Natterer <mitch@gimp.org>
* app/apptypes.h
* app/Makefile.am
* app/gimpdrawablelistview.[ch]: new widget. The upcoming replacement
for the layers and channels dialogs.
* app/test_commands.[ch]: put the test dialogs here...
* app/commands.[ch]: ... and made this one clean again.
* app/gimpcontainergridview.c
* app/gimpcontainerlistview.c
* app/gimpcontainerview.[ch]: some signal handling fine tuning.
* app/gimpimage.[ch]: emits "active_layer_changed" and
"active_channel_changed" signals now. The semantics of
gimage->active_layer and gimage->active_channel have changed a bit.
We now have either an active layer _or_ and active channel (there
is no active layer any more if a channel is active).
* app/channel_ops.c
* app/floating_sel.c
* app/gdisplay.c
* app/layers_dialog.c
* app/menus.c: changed accordingly.
* app/tools/gimpcolorpickertool.c: actually assign the draw_class
vraiable in the class_init function.
* app/tools/gimpdrawtool.[ch]
* app/tools/tool.c: removed the _new() functions because these
objects are abstract superclasses. Did some cleanup.
Nathan, please configure you editor to _not_ produce any tabs
in the source code.
* app/tools/gimppaintbrushtool.[ch]: "blurb" and "help" are tagged
with _(), not N_(). Put the register function to the header.
* po/POTFILES.in: made it compile again.
2001-02-26 Nathan Summers <rock@gimp.org>
app/tools/gimpdrawtool.c
* app/tools/gimpdrawtool.c
* app/tools/gimpdrawtool.h
* app/tools/gimppainttool.c
* app/tools/gimppainttool.h
@ -79,8 +121,8 @@ app/tools/gimpdrawtool.c
* plug-ins/libgck/gck/Makefile.am: made linking against stable
GIMP installed in the same prefix work again by renaming all our
libraries explicitly to libgimp<foo>-1.3.* (not as part of the
libtool revision but as part of the library name). Removed the
libtool revision to avoid double versioning. This has to be
libtool release but as part of the library name). Removed the
libtool release to avoid double versioning. This has to be
hardcoded in the libraries' Makefile.am ...
* app/Makefile.am
@ -115,7 +157,7 @@ app/tools/gimpdrawtool.c
* plug-ins/sgi/Makefile.am
* plug-ins/webbrowser/Makefile.am
* plug-ins/xjt/Makefile.am: ... while all other Makefiles can simply
link against "libgimp<foo>-$(LT_REVISION).la"
link against "libgimp<foo>-$(LT_RELEASE).la"
2001-02-24 Michael Natterer <mitch@gimp.org>

View File

@ -245,6 +245,8 @@ gimp_SOURCES = \
selection.h \
session.h \
session.c \
test_commands.c \
test_commands.h \
tips_dialog.c \
tips_dialog.h \
toolbox.c \
@ -291,6 +293,8 @@ gimp_SOURCES = \
gimpcontainerview.c \
gimpdatafactoryview.h \
gimpdatafactoryview.c \
gimpdrawablelistview.c \
gimpdrawablelistview.h \
gimpdrawablepreview.c \
gimpdrawablepreview.h \
gimpgradientpreview.h \

View File

@ -52,6 +52,7 @@
#include "floating_sel.h"
#include "gdisplay_ops.h"
#include "gimage_mask.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimphelp.h"
@ -82,17 +83,6 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "gradient_editor.h"
#include "gimpcontainer.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#include "gimpdatafactory.h"
#include "gimpdatafactoryview.h"
#include "gimppreview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1381,575 +1371,6 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
gtk_widget_show (module_browser);
}
/***** Container View Test Dialogs *****/
static void
container_view_scale_callback (GtkAdjustment *adj,
GimpContainerView *view)
{
gimp_container_view_set_preview_size (view, ROUND (adj->value));
}
static void
brushes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_brush_factory->container);
}
static void
patterns_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_pattern_factory->container);
}
static void
gradients_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_gradient_factory->container);
}
static void
palettes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_palette_factory->container);
}
static void
images_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, image_context);
}
/*
static void
null_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, NULL);
}
*/
static void
container_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
static void
data_factory_view_new (GimpViewType view_type,
gchar *title,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
view = gimp_data_factory_view_new (view_type,
factory,
edit_func,
context,
preview_size,
5, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
GIMP_DATA_FACTORY_VIEW (view)->view);
gtk_widget_show (dialog);
}
static void
container_multi_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *preview;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"Images", images_callback,
view, NULL, NULL, FALSE, FALSE,
/*
"NULL", null_callback,
view, NULL, NULL, FALSE, FALSE,
*/
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (brushes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"brush_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (patterns_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (gradients_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"gradient_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (palettes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"palette_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
/*
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_image (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (images_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 64, 4, 4, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
void
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (TRUE, "Image List",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Image Grid",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Brush List",
global_brush_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Pattern List",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Palette List",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Brush Grid",
global_brush_factory,
NULL,
gimp_context_get_user (),
32);
}
void
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Pattern Grid",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Palette Grid",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (TRUE, "Multi List",
global_brush_factory->container,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (FALSE, "Multi Grid",
global_brush_factory->container,
gimp_context_get_user (),
32);
}
static void
layers_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->layers : NULL);
}
static void
channels_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->channels : NULL);
}
static void
drawable_view_new (GimpViewType view_type,
gchar *title,
gboolean channels,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *dialog;
GtkWidget *view;
if (view_type == GIMP_VIEW_TYPE_LIST)
{
view = gimp_container_list_view_new (NULL,
NULL,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (NULL,
NULL,
preview_size,
5, 5);
}
gimage = gimp_context_get_image (context);
if (channels)
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->channels);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (channels_view_image_changed),
view);
}
else
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->layers);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (layers_view_image_changed),
view);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
gtk_widget_show (dialog);
}
void
dialogs_test_layer_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Layer List", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_layer_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Layer Grid", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_channel_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Channel List", TRUE,
gimp_context_get_user ());
}
void
dialogs_test_channel_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Channel Grid", TRUE,
gimp_context_get_user ());
}
/***** Help *****/

View File

@ -20,31 +20,31 @@
#define __COMMANDS_H__
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void select_invert_cmd_callback (GtkWidget *, gpointer);
void select_all_cmd_callback (GtkWidget *, gpointer);
@ -129,37 +129,16 @@ void dialogs_device_status_cmd_callback (GtkWidget *, gpointer);
void dialogs_document_index_cmd_callback (GtkWidget *, gpointer);
void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
void dialogs_module_browser_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_grid_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_grid_cmd_callback (GtkWidget *, gpointer);
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#ifdef DISPLAY_FILTERS
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
#endif /* DISPLAY_FILTERS */
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#endif /* __COMMANDS_H__ */

View File

@ -78,6 +78,8 @@ typedef struct _GimpPalette GimpPalette;
typedef struct _GimpToolInfo GimpToolInfo;
typedef struct _GimpTool GimpTool;
typedef struct _GimpPaintTool GimpPaintTool;
typedef struct _GimpDrawTool GimpDrawTool;
/* widgets */
@ -95,6 +97,7 @@ typedef struct _GimpContainerView GimpContainerView;
typedef struct _GimpContainerListView GimpContainerListView;
typedef struct _GimpContainerGridView GimpContainerGridView;
typedef struct _GimpDataFactoryView GimpDataFactoryView;
typedef struct _GimpDrawableListView GimpDrawableListView;
typedef struct _HistogramWidget HistogramWidget;
@ -111,12 +114,8 @@ typedef struct _BoundSeg BoundSeg;
typedef struct _ColorNotebook ColorNotebook;
typedef struct _GimpDrawTool GimpDrawTool;
typedef struct _GDisplay GDisplay;
typedef struct _GimpContextPreview GimpContextPreview;
typedef struct _GimpHistogram GimpHistogram;
typedef struct _GimpImageNewValues GimpImageNewValues;
@ -133,8 +132,6 @@ typedef gpointer ImageMap;
typedef struct _InfoDialog InfoDialog;
typedef struct _GimpPaintTool GimpPaintTool;
typedef struct _Path Path;
typedef struct _PathPoint PathPoint;
typedef struct _PathList PathList;

View File

@ -575,11 +575,11 @@ duplicate (GimpImage *gimage)
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
ParasiteList *parasites;
PathList *paths;
gint count;

View File

@ -52,6 +52,7 @@
#include "floating_sel.h"
#include "gdisplay_ops.h"
#include "gimage_mask.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimphelp.h"
@ -82,17 +83,6 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "gradient_editor.h"
#include "gimpcontainer.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#include "gimpdatafactory.h"
#include "gimpdatafactoryview.h"
#include "gimppreview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1381,575 +1371,6 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
gtk_widget_show (module_browser);
}
/***** Container View Test Dialogs *****/
static void
container_view_scale_callback (GtkAdjustment *adj,
GimpContainerView *view)
{
gimp_container_view_set_preview_size (view, ROUND (adj->value));
}
static void
brushes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_brush_factory->container);
}
static void
patterns_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_pattern_factory->container);
}
static void
gradients_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_gradient_factory->container);
}
static void
palettes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_palette_factory->container);
}
static void
images_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, image_context);
}
/*
static void
null_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, NULL);
}
*/
static void
container_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
static void
data_factory_view_new (GimpViewType view_type,
gchar *title,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
view = gimp_data_factory_view_new (view_type,
factory,
edit_func,
context,
preview_size,
5, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
GIMP_DATA_FACTORY_VIEW (view)->view);
gtk_widget_show (dialog);
}
static void
container_multi_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *preview;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"Images", images_callback,
view, NULL, NULL, FALSE, FALSE,
/*
"NULL", null_callback,
view, NULL, NULL, FALSE, FALSE,
*/
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (brushes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"brush_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (patterns_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (gradients_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"gradient_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (palettes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"palette_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
/*
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_image (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (images_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 64, 4, 4, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
void
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (TRUE, "Image List",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Image Grid",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Brush List",
global_brush_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Pattern List",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Palette List",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Brush Grid",
global_brush_factory,
NULL,
gimp_context_get_user (),
32);
}
void
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Pattern Grid",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Palette Grid",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (TRUE, "Multi List",
global_brush_factory->container,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (FALSE, "Multi Grid",
global_brush_factory->container,
gimp_context_get_user (),
32);
}
static void
layers_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->layers : NULL);
}
static void
channels_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->channels : NULL);
}
static void
drawable_view_new (GimpViewType view_type,
gchar *title,
gboolean channels,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *dialog;
GtkWidget *view;
if (view_type == GIMP_VIEW_TYPE_LIST)
{
view = gimp_container_list_view_new (NULL,
NULL,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (NULL,
NULL,
preview_size,
5, 5);
}
gimage = gimp_context_get_image (context);
if (channels)
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->channels);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (channels_view_image_changed),
view);
}
else
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->layers);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (layers_view_image_changed),
view);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
gtk_widget_show (dialog);
}
void
dialogs_test_layer_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Layer List", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_layer_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Layer Grid", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_channel_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Channel List", TRUE,
gimp_context_get_user ());
}
void
dialogs_test_channel_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Channel Grid", TRUE,
gimp_context_get_user ());
}
/***** Help *****/

View File

@ -20,31 +20,31 @@
#define __COMMANDS_H__
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void select_invert_cmd_callback (GtkWidget *, gpointer);
void select_all_cmd_callback (GtkWidget *, gpointer);
@ -129,37 +129,16 @@ void dialogs_device_status_cmd_callback (GtkWidget *, gpointer);
void dialogs_document_index_cmd_callback (GtkWidget *, gpointer);
void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
void dialogs_module_browser_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_grid_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_grid_cmd_callback (GtkWidget *, gpointer);
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#ifdef DISPLAY_FILTERS
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
#endif /* DISPLAY_FILTERS */
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#endif /* __COMMANDS_H__ */

View File

@ -575,11 +575,11 @@ duplicate (GimpImage *gimage)
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
ParasiteList *parasites;
PathList *paths;
gint count;

View File

@ -575,11 +575,11 @@ duplicate (GimpImage *gimage)
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
ParasiteList *parasites;
PathList *paths;
gint count;

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -195,6 +195,7 @@ gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
object_class = (GtkObjectClass *) klass;
tool_class = (GimpToolClass *) klass;
draw_class = (GimpDrawToolClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_DRAW_TOOL);

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -166,12 +166,6 @@ floating_sel_reset (GimpLayer *layer)
else if (GIMP_IS_CHANNEL (layer->fs.drawable))
{
gimp_image_set_active_channel (gimage, GIMP_CHANNEL (layer->fs.drawable));
if (gimp_container_num_children (gimage->layers))
{
gimp_image_set_active_layer (gimage,
(GimpLayer *) gimage->layer_stack->data);
}
}
}

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -1958,13 +1958,14 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
if (lp)
{
layer = gimp_image_get_active_layer (gdisp->gimage);
if (layer)
{
lm = gimp_layer_get_mask (layer) ? TRUE : FALSE;
alpha = gimp_layer_has_alpha (layer);
lind = gimp_image_get_layer_index (gdisp->gimage, layer);
}
lind = gimp_image_get_layer_index (gdisp->gimage, layer);
lnum = gimp_container_num_children (gdisp->gimage->layers);
}
}
@ -2038,17 +2039,24 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("Image/Mode/RGB", (base_type != RGB));
SET_SENSITIVE ("Image/Mode/Grayscale", (base_type != GRAY));
SET_SENSITIVE ("Image/Mode/Indexed...", (base_type != INDEXED));
#warning FIXME (set_menu_sensitivity)
#if 0
SET_SENSITIVE ("Image/Histogram...", lp);
#endif
SET_SENSITIVE ("Image/Colors", lp);
#if 0
SET_SENSITIVE ("Image/Colors/Color Balance...", (base_type == RGB));
SET_SENSITIVE ("Image/Colors/Hue-Saturation...", (base_type == RGB));
SET_SENSITIVE ("Image/Colors/Brightness-Contrast...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Threshold...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Levels...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Curves...", (base_type != INDEXED));
#endif
SET_SENSITIVE ("Image/Colors/Desaturate", (base_type == RGB));
#if 0
SET_SENSITIVE ("Image/Colors/Posterize...", (base_type != INDEXED));
#endif
SET_SENSITIVE ("Image/Colors/Invert", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Auto/Equalize", (base_type != INDEXED));

View File

@ -1958,13 +1958,14 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
if (lp)
{
layer = gimp_image_get_active_layer (gdisp->gimage);
if (layer)
{
lm = gimp_layer_get_mask (layer) ? TRUE : FALSE;
alpha = gimp_layer_has_alpha (layer);
lind = gimp_image_get_layer_index (gdisp->gimage, layer);
}
lind = gimp_image_get_layer_index (gdisp->gimage, layer);
lnum = gimp_container_num_children (gdisp->gimage->layers);
}
}
@ -2038,17 +2039,24 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("Image/Mode/RGB", (base_type != RGB));
SET_SENSITIVE ("Image/Mode/Grayscale", (base_type != GRAY));
SET_SENSITIVE ("Image/Mode/Indexed...", (base_type != INDEXED));
#warning FIXME (set_menu_sensitivity)
#if 0
SET_SENSITIVE ("Image/Histogram...", lp);
#endif
SET_SENSITIVE ("Image/Colors", lp);
#if 0
SET_SENSITIVE ("Image/Colors/Color Balance...", (base_type == RGB));
SET_SENSITIVE ("Image/Colors/Hue-Saturation...", (base_type == RGB));
SET_SENSITIVE ("Image/Colors/Brightness-Contrast...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Threshold...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Levels...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Curves...", (base_type != INDEXED));
#endif
SET_SENSITIVE ("Image/Colors/Desaturate", (base_type == RGB));
#if 0
SET_SENSITIVE ("Image/Colors/Posterize...", (base_type != INDEXED));
#endif
SET_SENSITIVE ("Image/Colors/Invert", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Auto/Equalize", (base_type != INDEXED));

View File

@ -166,12 +166,6 @@ floating_sel_reset (GimpLayer *layer)
else if (GIMP_IS_CHANNEL (layer->fs.drawable))
{
gimp_image_set_active_channel (gimage, GIMP_CHANNEL (layer->fs.drawable));
if (gimp_container_num_children (gimage->layers))
{
gimp_image_set_active_layer (gimage,
(GimpLayer *) gimage->layer_stack->data);
}
}
}

View File

@ -1958,13 +1958,14 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
if (lp)
{
layer = gimp_image_get_active_layer (gdisp->gimage);
if (layer)
{
lm = gimp_layer_get_mask (layer) ? TRUE : FALSE;
alpha = gimp_layer_has_alpha (layer);
lind = gimp_image_get_layer_index (gdisp->gimage, layer);
}
lind = gimp_image_get_layer_index (gdisp->gimage, layer);
lnum = gimp_container_num_children (gdisp->gimage->layers);
}
}
@ -2038,17 +2039,24 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("Image/Mode/RGB", (base_type != RGB));
SET_SENSITIVE ("Image/Mode/Grayscale", (base_type != GRAY));
SET_SENSITIVE ("Image/Mode/Indexed...", (base_type != INDEXED));
#warning FIXME (set_menu_sensitivity)
#if 0
SET_SENSITIVE ("Image/Histogram...", lp);
#endif
SET_SENSITIVE ("Image/Colors", lp);
#if 0
SET_SENSITIVE ("Image/Colors/Color Balance...", (base_type == RGB));
SET_SENSITIVE ("Image/Colors/Hue-Saturation...", (base_type == RGB));
SET_SENSITIVE ("Image/Colors/Brightness-Contrast...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Threshold...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Levels...", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Curves...", (base_type != INDEXED));
#endif
SET_SENSITIVE ("Image/Colors/Desaturate", (base_type == RGB));
#if 0
SET_SENSITIVE ("Image/Colors/Posterize...", (base_type != INDEXED));
#endif
SET_SENSITIVE ("Image/Colors/Invert", (base_type != INDEXED));
SET_SENSITIVE ("Image/Colors/Auto/Equalize", (base_type != INDEXED));

View File

@ -54,7 +54,7 @@ static void gimp_container_grid_view_clear_items (GimpContainerView *v
static void gimp_container_grid_view_set_preview_size (GimpContainerView *view);
static void gimp_container_grid_view_item_selected (GtkWidget *widget,
gpointer data);
static void gimp_container_grid_view_item_activate (GtkWidget *widget,
static void gimp_container_grid_view_item_activated (GtkWidget *widget,
gpointer data);
static void gimp_container_grid_view_highlight_item (GimpContainerView *view,
GimpViewable *viewable,
@ -240,7 +240,7 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
view);
gtk_signal_connect (GTK_OBJECT (preview), "double_clicked",
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activate),
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activated),
view);
return (gpointer) preview;
@ -336,20 +336,16 @@ static void
gimp_container_grid_view_item_selected (GtkWidget *widget,
gpointer data)
{
gimp_container_grid_view_highlight_item (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable,
widget);
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
}
static void
gimp_container_grid_view_item_activate (GtkWidget *widget,
gpointer data)
gimp_container_grid_view_item_activated (GtkWidget *widget,
gpointer data)
{
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
}
static void

View File

@ -58,7 +58,7 @@ static void gimp_container_list_view_name_changed (GimpViewable *v
static void gimp_container_list_view_item_selected (GtkWidget *widget,
GtkWidget *child,
gpointer data);
static gint gimp_container_list_view_item_activate (GtkWidget *widget,
static gint gimp_container_list_view_item_activated (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static GimpViewable * gimp_container_list_view_drag_viewable (GtkWidget *widget,
@ -243,7 +243,7 @@ gimp_container_list_view_insert_item (GimpContainerView *view,
GTK_OBJECT (list_view));
gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event",
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activate),
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activated),
list_view);
gimp_gtk_drag_source_set_by_type (list_item,
@ -382,6 +382,10 @@ gimp_container_list_view_select_item (GimpContainerView *view,
gimp_container_list_view_item_selected,
list_view);
}
else
{
gtk_list_unselect_all (GTK_LIST (list_view->gtk_list));
}
}
static void
@ -440,9 +444,9 @@ gimp_container_list_view_item_selected (GtkWidget *widget,
}
static gint
gimp_container_list_view_item_activate (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
gimp_container_list_view_item_activated (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
if (bevent->type == GDK_2BUTTON_PRESS)
{
@ -451,7 +455,7 @@ gimp_container_list_view_item_activate (GtkWidget *widget,
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data), viewable);
gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data), viewable);
}
return FALSE;

View File

@ -427,17 +427,19 @@ gimp_container_view_item_selected (GimpContainerView *view,
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
if (! (view->container && view->context))
return;
if (view->container && view->context)
{
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
gimp_container_view_select_item (view, viewable);
}
void
gimp_container_view_item_activate (GimpContainerView *view,
GimpViewable *viewable)
gimp_container_view_item_activated (GimpContainerView *view,
GimpViewable *viewable)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));

View File

@ -87,7 +87,7 @@ void gimp_container_view_activate_item (GimpContainerView *view,
void gimp_container_view_item_selected (GimpContainerView *view,
GimpViewable *item);
void gimp_container_view_item_activate (GimpContainerView *view,
void gimp_container_view_item_activated (GimpContainerView *view,
GimpViewable *item);

View File

@ -575,11 +575,11 @@ duplicate (GimpImage *gimage)
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
ParasiteList *parasites;
PathList *paths;
gint count;

528
app/gimpdrawablelistview.c Normal file
View File

@ -0,0 +1,528 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "gimpcontainer.h"
#include "gimpdrawable.h"
#include "gimpdrawablelistview.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimprc.h"
#include "gimpviewable.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/delete.xpm"
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
#include "pixmaps/duplicate.xpm"
#include "pixmaps/new.xpm"
#include "pixmaps/pennorm.xpm"
static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass);
static void gimp_drawable_list_view_init (GimpDrawableListView *view);
static void gimp_drawable_list_view_destroy (GtkObject *object);
static void gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view);
static GimpContainerListViewClass *parent_class = NULL;
GtkType
gimp_drawable_list_view_get_type (void)
{
static guint view_type = 0;
if (! view_type)
{
GtkTypeInfo view_info =
{
"GimpDrawableListView",
sizeof (GimpDrawableListView),
sizeof (GimpDrawableListViewClass),
(GtkClassInitFunc) gimp_drawable_list_view_class_init,
(GtkObjectInitFunc) gimp_drawable_list_view_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_LIST_VIEW, &view_info);
}
return view_type;
}
static void
gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
{
GtkObjectClass *object_class;
GimpContainerViewClass *container_view_class;
object_class = (GtkObjectClass *) klass;
container_view_class = (GimpContainerViewClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_LIST_VIEW);
object_class->destroy = gimp_drawable_list_view_destroy;
container_view_class->select_item = gimp_drawable_list_view_select_item;
container_view_class->activate_item = gimp_drawable_list_view_activate_item;
}
static void
gimp_drawable_list_view_init (GimpDrawableListView *view)
{
GtkWidget *pixmap;
view->gimage = NULL;
view->drawable_type = GTK_TYPE_NONE;
view->signal_name = NULL;
gtk_box_set_spacing (GTK_BOX (view), 2);
view->button_box = gtk_hbox_new (TRUE, 2);
gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0);
gtk_widget_show (view->button_box);
/* new */
view->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button,
TRUE, TRUE, 0);
gtk_widget_show (view->new_button);
gimp_help_set_help_data (view->new_button, _("New"), NULL);
gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_new_clicked),
view);
pixmap = gimp_pixmap_new (new_xpm);
gtk_container_add (GTK_CONTAINER (view->new_button), pixmap);
gtk_widget_show (pixmap);
/* raise */
view->raise_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->raise_button,
TRUE, TRUE, 0);
gtk_widget_show (view->raise_button);
gimp_help_set_help_data (view->raise_button, _("Raise"), NULL);
gtk_signal_connect (GTK_OBJECT (view->raise_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_raise_clicked),
view);
pixmap = gimp_pixmap_new (raise_xpm);
gtk_container_add (GTK_CONTAINER (view->raise_button), pixmap);
gtk_widget_show (pixmap);
/* lower */
view->lower_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->lower_button,
TRUE, TRUE, 0);
gtk_widget_show (view->lower_button);
gimp_help_set_help_data (view->lower_button, _("Lower"), NULL);
gtk_signal_connect (GTK_OBJECT (view->lower_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_lower_clicked),
view);
pixmap = gimp_pixmap_new (lower_xpm);
gtk_container_add (GTK_CONTAINER (view->lower_button), pixmap);
gtk_widget_show (pixmap);
/* duplicate */
view->duplicate_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button,
TRUE, TRUE, 0);
gtk_widget_show (view->duplicate_button);
gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL);
gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_duplicate_clicked),
view);
pixmap = gimp_pixmap_new (duplicate_xpm);
gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap);
gtk_widget_show (pixmap);
/* edit */
view->edit_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button,
TRUE, TRUE, 0);
gtk_widget_show (view->edit_button);
gimp_help_set_help_data (view->edit_button, _("Edit"), NULL);
gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_edit_clicked),
view);
pixmap = gimp_pixmap_new (pennorm_xpm);
gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap);
gtk_widget_show (pixmap);
/* delete */
view->delete_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button,
TRUE, TRUE, 0);
gtk_widget_show (view->delete_button);
gimp_help_set_help_data (view->delete_button, _("Delete"), NULL);
gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_delete_clicked),
view);
pixmap = gimp_pixmap_new (delete_xpm);
gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap);
gtk_widget_show (pixmap);
gtk_widget_set_sensitive (view->raise_button, FALSE);
gtk_widget_set_sensitive (view->lower_button, FALSE);
gtk_widget_set_sensitive (view->duplicate_button, FALSE);
gtk_widget_set_sensitive (view->delete_button, FALSE);
}
static void
gimp_drawable_list_view_destroy (GtkObject *object)
{
GimpDrawableListView *view;
view = GIMP_DRAWABLE_LIST_VIEW (object);
g_free (view->signal_name);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (signal_name != NULL, NULL);
g_return_val_if_fail (get_container_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
list_view = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_VIEW);
view = GIMP_CONTAINER_VIEW (list_view);
view->preview_size = preview_size;
list_view->drawable_type = drawable_type;
list_view->signal_name = g_strdup (signal_name);
list_view->get_container_func = get_container_func;
list_view->get_drawable_func = get_drawable_func;
list_view->set_drawable_func = set_drawable_func;
/* drop to "new" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->new_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->new_button),
drawable_type,
gimp_drawable_list_view_new_dropped,
list_view);
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->duplicate_button),
drawable_type,
gimp_drawable_list_view_duplicate_dropped,
list_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->edit_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->edit_button),
drawable_type,
gimp_drawable_list_view_edit_dropped,
list_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->delete_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->delete_button),
drawable_type,
gimp_drawable_list_view_delete_dropped,
list_view);
if (gimage)
gimp_drawable_list_view_set_image (list_view, gimage);
return GTK_WIDGET (list_view);
}
void
gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE_LIST_VIEW (view));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (view->gimage == gimage)
return;
if (view->gimage)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (view->gimage),
gimp_drawable_list_view_drawable_changed,
view);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL);
}
view->gimage = gimage;
if (view->gimage)
{
GimpContainer *container;
container = view->get_container_func (view->gimage);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container);
gtk_signal_connect (GTK_OBJECT (view->gimage), view->signal_name,
GTK_SIGNAL_FUNC (gimp_drawable_list_view_drawable_changed),
view);
}
}
static void
gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view,
item,
insert_data);
g_print ("select item\n");
}
static void
gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item (view,
item,
insert_data);
g_print ("activate item\n");
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("new clicked\n");
}
static void
gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("new dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
}
}
static void
gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("duplicate clicked\n");
}
static void
gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("duplicate dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_duplicate_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("raise clicked\n");
}
static void
gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("lower clicked\n");
}
static void
gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("edit clicked\n");
}
static void
gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("edit dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_edit_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("delete clicked\n");
}
static void
gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("delete dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_delete_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view)
{
GimpDrawable *drawable;
drawable = view->get_drawable_func (gimage);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
(GimpViewable *) drawable);
}

View File

@ -0,0 +1,83 @@
/* 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_DRAWABLE_LIST_VIEW_H__
#define __GIMP_DRAWABLE_LIST_VIEW_H__
#include "gimpcontainerlistview.h"
typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *gimage);
typedef GimpDrawable * (* GimpGetDrawableFunc) (const GimpImage *gimage);
typedef void (* GimpSetDrawableFunc) (GimpImage *gimage,
GimpDrawable *drawable);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
#define GIMP_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListView))
#define GIMP_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListViewClass))
#define GIMP_IS_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW))
#define GIMP_IS_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW))
typedef struct _GimpDrawableListViewClass GimpDrawableListViewClass;
struct _GimpDrawableListView
{
GimpContainerListView parent_instance;
GimpImage *gimage;
GtkType drawable_type;
gchar *signal_name;
GimpGetContainerFunc get_container_func;
GimpGetDrawableFunc get_drawable_func;
GimpSetDrawableFunc set_drawable_func;
GtkWidget *button_box;
GtkWidget *new_button;
GtkWidget *raise_button;
GtkWidget *lower_button;
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
};
struct _GimpDrawableListViewClass
{
GimpContainerListViewClass parent_class;
};
GtkType gimp_drawable_list_view_get_type (void);
GtkWidget * gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);
#endif /* __GIMP_DRAWABLE_LIST_VIEW_H__ */

View File

@ -575,11 +575,11 @@ duplicate (GimpImage *gimage)
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
ParasiteList *parasites;
PathList *paths;
gint count;

View File

@ -152,6 +152,8 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
CLEAN,
DIRTY,
REPAINT,
@ -205,6 +207,24 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_layer_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_CHANNEL_CHANGED] =
gtk_signal_new ("active_channel_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
active_channel_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[CLEAN] =
gtk_signal_new ("clean",
GTK_RUN_FIRST,
@ -2133,6 +2153,24 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
NULL);
}
GimpContainer *
gimp_image_get_layers (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->layers;
}
GimpContainer *
gimp_image_get_channels (const GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->channels;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2327,22 +2365,31 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (! layer)
if (layer)
{
gimage->active_layer = NULL;
return NULL;
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
if (layer != gimage->active_layer)
{
gimage->active_layer = layer;
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
/* Set the active layer */
gimage->active_layer = layer;
gimage->active_channel = NULL;
if (gimage->active_channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
}
}
/* return the layer */
return layer;
@ -2364,14 +2411,21 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (! gimp_container_have (gimage->channels, GIMP_OBJECT (channel)))
channel = (GimpChannel *) gimp_container_get_child_by_index (gimage->channels, 0);
if (! channel)
if (channel != gimage->active_channel)
{
gimage->active_channel = NULL;
return NULL;
}
gimage->active_channel = channel;
/* Set the active channel */
gimage->active_channel = channel;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->active_layer)
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* return the channel */
return channel;
@ -2384,12 +2438,24 @@ gimp_image_unset_active_channel (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* make sure there is an active channel */
if (! (channel = gimage->active_channel))
return NULL;
channel = gimp_image_get_active_channel (gimage);
/* Set the active channel */
gimage->active_channel = NULL;
if (channel)
{
gimage->active_channel = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_CHANNEL_CHANGED]);
if (gimage->layer_stack)
{
GimpLayer *layer;
layer = (GimpLayer *) gimage->layer_stack->data;
gimp_image_set_active_layer (gimage, layer);
}
}
return channel;
}
@ -3125,7 +3191,7 @@ gimp_image_add_layer (GimpImage *gimage,
/* let the layer know about the gimage */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
/* If the layer has a mask, set the mask's gimage and layer */
/* If the layer has a mask, set the mask's gimage */
if (layer->mask)
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer->mask), gimage);
@ -3133,18 +3199,30 @@ gimp_image_add_layer (GimpImage *gimage,
/* add the layer to the list at the specified position */
if (position == -1)
position =
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (gimage->active_layer));
if (position != -1)
{
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer) && position == 0)
position = 1;
GimpLayer *active_layer;
active_layer = gimp_image_get_active_layer (gimage);
if (active_layer)
{
position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (active_layer));
}
else
{
position = 0;
}
}
/* If there is a floating selection (and this isn't it!),
* make sure the insert position is greater than 0
*/
if (position == 0 &&
gimp_image_floating_sel (gimage) &&
(gimage->floating_sel != layer))
{
position = 1;
}
gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position);
@ -3204,9 +3282,16 @@ gimp_image_remove_layer (GimpImage *gimage,
if (layer == gimp_image_get_active_layer (gimage))
{
if (gimage->layer_stack)
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
{
gimp_image_set_active_layer (gimage, gimage->layer_stack->data);
}
else
gimage->active_layer = NULL;
{
gimage->active_layer = NULL;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[ACTIVE_LAYER_CHANGED]);
}
}
/* Send out REMOVED signal from layer */
@ -3524,8 +3609,6 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpDrawable *
gimp_image_active_drawable (const GimpImage *gimage)
{
GimpLayer *layer;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -3538,6 +3621,8 @@ gimp_image_active_drawable (const GimpImage *gimage)
}
else if (gimage->active_layer)
{
GimpLayer *layer;
layer = gimage->active_layer;
if (layer->mask && layer->edit_mask)

View File

@ -142,13 +142,21 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* clean) (GimpImage *gimage);
void (* dirty) (GimpImage *gimage);
void (* repaint) (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2);
void (* resize) (GimpImage *gimage);
void (* restructure) (GimpImage *gimage);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
gint event);
};
@ -283,6 +291,9 @@ void gimp_image_colormap_changed (const GimpImage *image,
/* layer/channel functions */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,

View File

@ -52,6 +52,7 @@
#include "floating_sel.h"
#include "gdisplay_ops.h"
#include "gimage_mask.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimphelp.h"
@ -82,17 +83,6 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "gradient_editor.h"
#include "gimpcontainer.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#include "gimpdatafactory.h"
#include "gimpdatafactoryview.h"
#include "gimppreview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1381,575 +1371,6 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
gtk_widget_show (module_browser);
}
/***** Container View Test Dialogs *****/
static void
container_view_scale_callback (GtkAdjustment *adj,
GimpContainerView *view)
{
gimp_container_view_set_preview_size (view, ROUND (adj->value));
}
static void
brushes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_brush_factory->container);
}
static void
patterns_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_pattern_factory->container);
}
static void
gradients_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_gradient_factory->container);
}
static void
palettes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_palette_factory->container);
}
static void
images_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, image_context);
}
/*
static void
null_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, NULL);
}
*/
static void
container_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
static void
data_factory_view_new (GimpViewType view_type,
gchar *title,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
view = gimp_data_factory_view_new (view_type,
factory,
edit_func,
context,
preview_size,
5, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
GIMP_DATA_FACTORY_VIEW (view)->view);
gtk_widget_show (dialog);
}
static void
container_multi_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *preview;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"Images", images_callback,
view, NULL, NULL, FALSE, FALSE,
/*
"NULL", null_callback,
view, NULL, NULL, FALSE, FALSE,
*/
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (brushes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"brush_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (patterns_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (gradients_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"gradient_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (palettes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"palette_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
/*
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_image (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (images_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 64, 4, 4, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
void
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (TRUE, "Image List",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Image Grid",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Brush List",
global_brush_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Pattern List",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Palette List",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Brush Grid",
global_brush_factory,
NULL,
gimp_context_get_user (),
32);
}
void
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Pattern Grid",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Palette Grid",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (TRUE, "Multi List",
global_brush_factory->container,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (FALSE, "Multi Grid",
global_brush_factory->container,
gimp_context_get_user (),
32);
}
static void
layers_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->layers : NULL);
}
static void
channels_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->channels : NULL);
}
static void
drawable_view_new (GimpViewType view_type,
gchar *title,
gboolean channels,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *dialog;
GtkWidget *view;
if (view_type == GIMP_VIEW_TYPE_LIST)
{
view = gimp_container_list_view_new (NULL,
NULL,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (NULL,
NULL,
preview_size,
5, 5);
}
gimage = gimp_context_get_image (context);
if (channels)
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->channels);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (channels_view_image_changed),
view);
}
else
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->layers);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (layers_view_image_changed),
view);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
gtk_widget_show (dialog);
}
void
dialogs_test_layer_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Layer List", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_layer_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Layer Grid", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_channel_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Channel List", TRUE,
gimp_context_get_user ());
}
void
dialogs_test_channel_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Channel Grid", TRUE,
gimp_context_get_user ());
}
/***** Help *****/

View File

@ -20,31 +20,31 @@
#define __COMMANDS_H__
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void select_invert_cmd_callback (GtkWidget *, gpointer);
void select_all_cmd_callback (GtkWidget *, gpointer);
@ -129,37 +129,16 @@ void dialogs_device_status_cmd_callback (GtkWidget *, gpointer);
void dialogs_document_index_cmd_callback (GtkWidget *, gpointer);
void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
void dialogs_module_browser_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_grid_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_grid_cmd_callback (GtkWidget *, gpointer);
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#ifdef DISPLAY_FILTERS
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
#endif /* DISPLAY_FILTERS */
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#endif /* __COMMANDS_H__ */

View File

@ -52,6 +52,7 @@
#include "floating_sel.h"
#include "gdisplay_ops.h"
#include "gimage_mask.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimphelp.h"
@ -82,17 +83,6 @@
#include "undo.h"
#include "undo_history.h"
/* for the example dialogs */
#include "gradient_editor.h"
#include "gimpcontainer.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#include "gimpdatafactory.h"
#include "gimpdatafactoryview.h"
#include "gimppreview.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
@ -1381,575 +1371,6 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
gtk_widget_show (module_browser);
}
/***** Container View Test Dialogs *****/
static void
container_view_scale_callback (GtkAdjustment *adj,
GimpContainerView *view)
{
gimp_container_view_set_preview_size (view, ROUND (adj->value));
}
static void
brushes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_brush_factory->container);
}
static void
patterns_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_pattern_factory->container);
}
static void
gradients_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_gradient_factory->container);
}
static void
palettes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_palette_factory->container);
}
static void
images_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, image_context);
}
/*
static void
null_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, NULL);
}
*/
static void
container_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
static void
data_factory_view_new (GimpViewType view_type,
gchar *title,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
view = gimp_data_factory_view_new (view_type,
factory,
edit_func,
context,
preview_size,
5, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
GIMP_DATA_FACTORY_VIEW (view)->view);
gtk_widget_show (dialog);
}
static void
container_multi_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *preview;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"Images", images_callback,
view, NULL, NULL, FALSE, FALSE,
/*
"NULL", null_callback,
view, NULL, NULL, FALSE, FALSE,
*/
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (brushes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"brush_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (patterns_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (gradients_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"gradient_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (palettes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"palette_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
/*
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_image (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (images_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 64, 4, 4, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
void
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (TRUE, "Image List",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Image Grid",
image_context,
gimp_context_get_user (),
64);
}
void
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Brush List",
global_brush_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Pattern List",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Palette List",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Brush Grid",
global_brush_factory,
NULL,
gimp_context_get_user (),
32);
}
void
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Pattern Grid",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Palette Grid",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (TRUE, "Multi List",
global_brush_factory->container,
gimp_context_get_user (),
24);
}
void
dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (FALSE, "Multi Grid",
global_brush_factory->container,
gimp_context_get_user (),
32);
}
static void
layers_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->layers : NULL);
}
static void
channels_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpContainerView *view)
{
gimp_container_view_set_container (view, gimage ? gimage->channels : NULL);
}
static void
drawable_view_new (GimpViewType view_type,
gchar *title,
gboolean channels,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *dialog;
GtkWidget *view;
if (view_type == GIMP_VIEW_TYPE_LIST)
{
view = gimp_container_list_view_new (NULL,
NULL,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (NULL,
NULL,
preview_size,
5, 5);
}
gimage = gimp_context_get_image (context);
if (channels)
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->channels);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (channels_view_image_changed),
view);
}
else
{
if (gimage)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view),
gimage->layers);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (layers_view_image_changed),
view);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
/*
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 1)));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
gtk_widget_show (dialog);
}
void
dialogs_test_layer_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Layer List", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_layer_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Layer Grid", FALSE,
gimp_context_get_user ());
}
void
dialogs_test_channel_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_LIST, "Channel List", TRUE,
gimp_context_get_user ());
}
void
dialogs_test_channel_grid_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new (GIMP_VIEW_TYPE_GRID, "Channel Grid", TRUE,
gimp_context_get_user ());
}
/***** Help *****/

View File

@ -20,31 +20,31 @@
#define __COMMANDS_H__
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *, gpointer, guint);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
void file_save_a_copy_as_cmd_callback (GtkWidget *, gpointer);
void file_revert_cmd_callback (GtkWidget *, gpointer);
void file_pref_cmd_callback (GtkWidget *, gpointer);
void file_close_cmd_callback (GtkWidget *, gpointer);
void file_quit_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void edit_undo_cmd_callback (GtkWidget *, gpointer);
void edit_redo_cmd_callback (GtkWidget *, gpointer);
void edit_cut_cmd_callback (GtkWidget *, gpointer);
void edit_copy_cmd_callback (GtkWidget *, gpointer);
void edit_paste_cmd_callback (GtkWidget *, gpointer);
void edit_paste_into_cmd_callback (GtkWidget *, gpointer);
void edit_paste_as_new_cmd_callback (GtkWidget *, gpointer);
void edit_named_cut_cmd_callback (GtkWidget *, gpointer);
void edit_named_copy_cmd_callback (GtkWidget *, gpointer);
void edit_named_paste_cmd_callback (GtkWidget *, gpointer);
void edit_clear_cmd_callback (GtkWidget *, gpointer);
void edit_fill_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void edit_stroke_cmd_callback (GtkWidget *, gpointer);
void select_invert_cmd_callback (GtkWidget *, gpointer);
void select_all_cmd_callback (GtkWidget *, gpointer);
@ -129,37 +129,16 @@ void dialogs_device_status_cmd_callback (GtkWidget *, gpointer);
void dialogs_document_index_cmd_callback (GtkWidget *, gpointer);
void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
void dialogs_module_browser_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_palette_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_list_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_multi_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_layer_grid_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_list_cmd_callback (GtkWidget *, gpointer);
void dialogs_test_channel_grid_cmd_callback (GtkWidget *, gpointer);
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#ifdef DISPLAY_FILTERS
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
#endif /* DISPLAY_FILTERS */
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#endif /* __COMMANDS_H__ */

View File

@ -1191,6 +1191,9 @@ layers_dialog_set_active_layer (GimpLayer *layer)
GtkStateType state;
gint index;
if (! layer)
return;
layer_widget = layer_widget_get_ID (layer);
if (!layersD || !layer_widget)
return;
@ -1225,6 +1228,9 @@ layers_dialog_unset_layer (GimpLayer *layer)
GtkStateType state;
gint index;
if (! layer)
return;
layer_widget = layer_widget_get_ID (layer);
if (!layersD || !layer_widget)
return;

View File

@ -43,6 +43,9 @@
#include "menus.h"
#include "paths_dialog.h"
/* test dialogs */
#include "test_commands.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
@ -157,53 +160,49 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/display_filters/display_filters.html", NULL },
#endif /* DISPLAY_FILTERS */
{ { N_("/File/Test Dialogs/Layer List..."), NULL, dialogs_test_layer_list_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Layer List..."), NULL, test_layer_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Layer Grid..."), NULL, dialogs_test_layer_grid_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, dialogs_test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel Grid..."), NULL, dialogs_test_channel_grid_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Images List...", NULL, dialogs_test_image_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images List...", NULL, test_image_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Images Grid...", NULL, dialogs_test_image_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images Grid...", NULL, test_image_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe List...", NULL, dialogs_test_brush_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe List...", NULL, test_brush_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern List...", NULL, dialogs_test_pattern_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern List...", NULL, test_pattern_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient List...", NULL, dialogs_test_gradient_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient List...", NULL, test_gradient_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette List...", NULL, dialogs_test_palette_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette List...", NULL, test_palette_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, dialogs_test_brush_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, test_brush_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, dialogs_test_pattern_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, test_pattern_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, dialogs_test_gradient_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, test_gradient_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette Grid...", NULL, dialogs_test_palette_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette Grid...", NULL, test_palette_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Multi List...", NULL, dialogs_test_multi_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi List...", NULL, test_multi_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Multi Grid...", NULL, dialogs_test_multi_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi Grid...", NULL, test_multi_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/---", NULL, NULL, 0, "<Separator>" },

582
app/gui/test-commands.c Normal file
View File

@ -0,0 +1,582 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "context_manager.h"
#include "gradient_editor.h"
#include "gimpchannel.h"
#include "gimpcontainer.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#include "gimpcontext.h"
#include "gimpdatafactory.h"
#include "gimpdatafactoryview.h"
#include "gimpdrawablelistview.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimppreview.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp) \
gdisp = gdisplay_active (); \
if (!gdisp) return
/***** Container View Test Dialogs *****/
static void
container_view_scale_callback (GtkAdjustment *adj,
GimpContainerView *view)
{
gimp_container_view_set_preview_size (view, ROUND (adj->value));
}
static void
brushes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_brush_factory->container);
}
static void
patterns_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_pattern_factory->container);
}
static void
gradients_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_gradient_factory->container);
}
static void
palettes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_palette_factory->container);
}
static void
images_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, image_context);
}
/*
static void
null_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, NULL);
}
*/
static void
container_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 0)));
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
static void
data_factory_view_new (GimpViewType view_type,
gchar *title,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
view = gimp_data_factory_view_new (view_type,
factory,
edit_func,
context,
preview_size,
5, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
GIMP_DATA_FACTORY_VIEW (view)->view);
gtk_widget_show (dialog);
}
static void
container_multi_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *preview;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"Images", images_callback,
view, NULL, NULL, FALSE, FALSE,
/*
"NULL", null_callback,
view, NULL, NULL, FALSE, FALSE,
*/
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (brushes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"brush_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (patterns_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (gradients_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"gradient_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (palettes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"palette_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
/*
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_image (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (images_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 64, 4, 4, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
void
test_image_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (TRUE, "Image List",
image_context,
gimp_context_get_user (),
64);
}
void
test_image_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Image Grid",
image_context,
gimp_context_get_user (),
64);
}
void
test_brush_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Brush List",
global_brush_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Pattern List",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_palette_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Palette List",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Brush Grid",
global_brush_factory,
NULL,
gimp_context_get_user (),
32);
}
void
test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Pattern Grid",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_palette_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Palette Grid",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_multi_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (TRUE, "Multi List",
global_brush_factory->container,
gimp_context_get_user (),
24);
}
void
test_multi_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (FALSE, "Multi Grid",
global_brush_factory->container,
gimp_context_get_user (),
32);
}
static void
drawable_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDrawableListView *view)
{
gimp_drawable_list_view_set_image (view, gimage);
}
static void
drawable_view_new (gchar *title,
gboolean channels,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *dialog;
GtkWidget *view;
gimage = gimp_context_get_image (context);
if (channels)
{
view = gimp_drawable_list_view_new (gimage,
GIMP_TYPE_CHANNEL,
"active_channel_changed",
gimp_image_get_channels,
gimp_image_get_active_channel,
gimp_image_set_active_channel);
}
else
{
view = gimp_drawable_list_view_new (gimage,
GIMP_TYPE_LAYER,
"active_layer_changed",
gimp_image_get_layers,
gimp_image_get_active_layer,
gimp_image_set_active_layer);
}
gtk_list_set_selection_mode (GTK_LIST (GIMP_CONTAINER_LIST_VIEW (view)->gtk_list),
GTK_SELECTION_SINGLE);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (drawable_view_image_changed),
view);
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 0)));
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
gtk_widget_show (dialog);
}
void
test_layer_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new ("Layer List", FALSE,
gimp_context_get_user ());
}
void
test_channel_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new ("Channel List", TRUE,
gimp_context_get_user ());
}

45
app/gui/test-commands.h Normal file
View File

@ -0,0 +1,45 @@
/* 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 __TEST_COMMANDS_H__
#define __TEST_COMMANDS_H__
void test_image_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_image_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_brush_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_pattern_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_gradient_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_palette_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_brush_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_pattern_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_gradient_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_palette_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_multi_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_multi_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_layer_list_cmd_callback (GtkWidget *, gpointer);
void test_layer_grid_cmd_callback (GtkWidget *, gpointer);
void test_channel_list_cmd_callback (GtkWidget *, gpointer);
void test_channel_grid_cmd_callback (GtkWidget *, gpointer);
#endif /* __TEST_COMMANDS_H__ */

View File

@ -1191,6 +1191,9 @@ layers_dialog_set_active_layer (GimpLayer *layer)
GtkStateType state;
gint index;
if (! layer)
return;
layer_widget = layer_widget_get_ID (layer);
if (!layersD || !layer_widget)
return;
@ -1225,6 +1228,9 @@ layers_dialog_unset_layer (GimpLayer *layer)
GtkStateType state;
gint index;
if (! layer)
return;
layer_widget = layer_widget_get_ID (layer);
if (!layersD || !layer_widget)
return;

View File

@ -43,6 +43,9 @@
#include "menus.h"
#include "paths_dialog.h"
/* test dialogs */
#include "test_commands.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
@ -157,53 +160,49 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/display_filters/display_filters.html", NULL },
#endif /* DISPLAY_FILTERS */
{ { N_("/File/Test Dialogs/Layer List..."), NULL, dialogs_test_layer_list_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Layer List..."), NULL, test_layer_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Layer Grid..."), NULL, dialogs_test_layer_grid_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, dialogs_test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel Grid..."), NULL, dialogs_test_channel_grid_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Images List...", NULL, dialogs_test_image_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images List...", NULL, test_image_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Images Grid...", NULL, dialogs_test_image_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images Grid...", NULL, test_image_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe List...", NULL, dialogs_test_brush_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe List...", NULL, test_brush_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern List...", NULL, dialogs_test_pattern_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern List...", NULL, test_pattern_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient List...", NULL, dialogs_test_gradient_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient List...", NULL, test_gradient_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette List...", NULL, dialogs_test_palette_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette List...", NULL, test_palette_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, dialogs_test_brush_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, test_brush_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, dialogs_test_pattern_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, test_pattern_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, dialogs_test_gradient_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, test_gradient_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette Grid...", NULL, dialogs_test_palette_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette Grid...", NULL, test_palette_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Multi List...", NULL, dialogs_test_multi_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi List...", NULL, test_multi_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Multi Grid...", NULL, dialogs_test_multi_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi Grid...", NULL, test_multi_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/---", NULL, NULL, 0, "<Separator>" },

View File

@ -43,6 +43,9 @@
#include "menus.h"
#include "paths_dialog.h"
/* test dialogs */
#include "test_commands.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
@ -157,53 +160,49 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/display_filters/display_filters.html", NULL },
#endif /* DISPLAY_FILTERS */
{ { N_("/File/Test Dialogs/Layer List..."), NULL, dialogs_test_layer_list_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Layer List..."), NULL, test_layer_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Layer Grid..."), NULL, dialogs_test_layer_grid_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, dialogs_test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel Grid..."), NULL, dialogs_test_channel_grid_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Images List...", NULL, dialogs_test_image_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images List...", NULL, test_image_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Images Grid...", NULL, dialogs_test_image_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images Grid...", NULL, test_image_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe List...", NULL, dialogs_test_brush_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe List...", NULL, test_brush_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern List...", NULL, dialogs_test_pattern_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern List...", NULL, test_pattern_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient List...", NULL, dialogs_test_gradient_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient List...", NULL, test_gradient_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette List...", NULL, dialogs_test_palette_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette List...", NULL, test_palette_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, dialogs_test_brush_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, test_brush_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, dialogs_test_pattern_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, test_pattern_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, dialogs_test_gradient_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, test_gradient_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette Grid...", NULL, dialogs_test_palette_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette Grid...", NULL, test_palette_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Multi List...", NULL, dialogs_test_multi_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi List...", NULL, test_multi_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Multi Grid...", NULL, dialogs_test_multi_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi Grid...", NULL, test_multi_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/---", NULL, NULL, 0, "<Separator>" },

View File

@ -499,10 +499,11 @@ gimp_paintbrush_tool_register (void)
{
tool_manager_register_tool (GIMP_TYPE_PAINTBRUSH_TOOL,
"gimp:paintbrush_tool",
N_("Paintbrush"),
N_("Paint fuzzy brush strokes"),
_("Paintbrush"),
_("Paint fuzzy brush strokes"),
N_("/Tools/Paint Tools/Paintbrush"), "P",
NULL, "tools/paintbrush.html", (const gchar **) paint_bits);
NULL, "tools/paintbrush.html",
(const gchar **) paint_bits);
}

View File

@ -37,7 +37,7 @@ struct _GimpPaintbrushToolClass
GimpPaintToolClass parent_class;
};
typedef struct _GimpPaintbrushTool GimpPaintbrushTool;
typedef struct _GimpPaintbrushTool GimpPaintbrushTool;
typedef struct _GimpPaintbrushToolClass GimpPaintbrushToolClass;
/* FIXME: this antique code doesn't follow the coding style */
@ -52,6 +52,8 @@ gboolean gimp_paintbrush_tool_non_gui_default (GimpDrawable *,
gint ,
gdouble *);
void gimp_paintbrush_tool_register (void);
GimpTool * gimp_paintbrush_tool_new (void);
GtkType gimp_paintbrush_tool_get_type (void);

582
app/test_commands.c Normal file
View File

@ -0,0 +1,582 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "context_manager.h"
#include "gradient_editor.h"
#include "gimpchannel.h"
#include "gimpcontainer.h"
#include "gimpcontainerlistview.h"
#include "gimpcontainergridview.h"
#include "gimpcontext.h"
#include "gimpdatafactory.h"
#include "gimpdatafactoryview.h"
#include "gimpdrawablelistview.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimppreview.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp) \
gdisp = gdisplay_active (); \
if (!gdisp) return
/***** Container View Test Dialogs *****/
static void
container_view_scale_callback (GtkAdjustment *adj,
GimpContainerView *view)
{
gimp_container_view_set_preview_size (view, ROUND (adj->value));
}
static void
brushes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_brush_factory->container);
}
static void
patterns_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_pattern_factory->container);
}
static void
gradients_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_gradient_factory->container);
}
static void
palettes_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, global_palette_factory->container);
}
static void
images_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, image_context);
}
/*
static void
null_callback (GtkWidget *widget,
GimpContainerView *view)
{
gimp_container_view_set_container (view, NULL);
}
*/
static void
container_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 0)));
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
static void
data_factory_view_new (GimpViewType view_type,
gchar *title,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
view = gimp_data_factory_view_new (view_type,
factory,
edit_func,
context,
preview_size,
5, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 256, 16, 16, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
GIMP_DATA_FACTORY_VIEW (view)->view);
gtk_widget_show (dialog);
}
static void
container_multi_view_new (gboolean list,
gchar *title,
GimpContainer *container,
GimpContext *context,
gint preview_size)
{
GtkWidget *dialog;
GtkWidget *view;
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *preview;
if (list)
{
view = gimp_container_list_view_new (container,
context,
preview_size,
5, 5);
}
else
{
view = gimp_container_grid_view_new (container,
context,
preview_size,
5, 5);
}
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"Images", images_callback,
view, NULL, NULL, FALSE, FALSE,
/*
"NULL", null_callback,
view, NULL, NULL, FALSE, FALSE,
*/
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (brushes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"brush_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (patterns_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (gradients_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"gradient_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (palettes_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"palette_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
/*
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_image (context)),
32, 32, 1,
FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), preview,
FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
GTK_SIGNAL_FUNC (images_callback),
view);
gtk_signal_connect_object_while_alive
(GTK_OBJECT (context),
"pattern_changed",
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
GTK_OBJECT (preview));
*/
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
adjustment = gtk_adjustment_new (preview_size, 16, 64, 4, 4, 0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale,
FALSE, FALSE, 0);
gtk_widget_show (scale);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (container_view_scale_callback),
view);
gtk_widget_show (dialog);
}
void
test_image_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (TRUE, "Image List",
image_context,
gimp_context_get_user (),
64);
}
void
test_image_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_view_new (FALSE, "Image Grid",
image_context,
gimp_context_get_user (),
64);
}
void
test_brush_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Brush List",
global_brush_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Pattern List",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_palette_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Palette List",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Brush Grid",
global_brush_factory,
NULL,
gimp_context_get_user (),
32);
}
void
test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Pattern Grid",
global_pattern_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid",
global_gradient_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_palette_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Palette Grid",
global_palette_factory,
NULL,
gimp_context_get_user (),
24);
}
void
test_multi_container_list_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (TRUE, "Multi List",
global_brush_factory->container,
gimp_context_get_user (),
24);
}
void
test_multi_container_grid_view_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
container_multi_view_new (FALSE, "Multi Grid",
global_brush_factory->container,
gimp_context_get_user (),
32);
}
static void
drawable_view_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDrawableListView *view)
{
gimp_drawable_list_view_set_image (view, gimage);
}
static void
drawable_view_new (gchar *title,
gboolean channels,
GimpContext *context)
{
GimpImage *gimage;
GtkWidget *dialog;
GtkWidget *view;
gimage = gimp_context_get_image (context);
if (channels)
{
view = gimp_drawable_list_view_new (gimage,
GIMP_TYPE_CHANNEL,
"active_channel_changed",
gimp_image_get_channels,
gimp_image_get_active_channel,
gimp_image_set_active_channel);
}
else
{
view = gimp_drawable_list_view_new (gimage,
GIMP_TYPE_LAYER,
"active_layer_changed",
gimp_image_get_layers,
gimp_image_get_active_layer,
gimp_image_set_active_layer);
}
gtk_list_set_selection_mode (GTK_LIST (GIMP_CONTAINER_LIST_VIEW (view)->gtk_list),
GTK_SELECTION_SINGLE);
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
GTK_SIGNAL_FUNC (drawable_view_image_changed),
view);
dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func,
NULL,
GTK_WIN_POS_MOUSE,
FALSE, TRUE, TRUE,
"_delete_event_", gtk_widget_destroy,
NULL, 1, NULL, TRUE, TRUE,
NULL);
gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 0)));
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
gtk_widget_show (view);
gtk_widget_show (dialog);
}
void
test_layer_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new ("Layer List", FALSE,
gimp_context_get_user ());
}
void
test_channel_list_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
drawable_view_new ("Channel List", TRUE,
gimp_context_get_user ());
}

45
app/test_commands.h Normal file
View File

@ -0,0 +1,45 @@
/* 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 __TEST_COMMANDS_H__
#define __TEST_COMMANDS_H__
void test_image_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_image_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_brush_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_pattern_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_gradient_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_palette_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_brush_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_pattern_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_gradient_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_palette_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_multi_container_list_view_cmd_callback (GtkWidget *, gpointer);
void test_multi_container_grid_view_cmd_callback (GtkWidget *, gpointer);
void test_layer_list_cmd_callback (GtkWidget *, gpointer);
void test_layer_grid_cmd_callback (GtkWidget *, gpointer);
void test_channel_list_cmd_callback (GtkWidget *, gpointer);
void test_channel_grid_cmd_callback (GtkWidget *, gpointer);
#endif /* __TEST_COMMANDS_H__ */

View File

@ -195,6 +195,7 @@ gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
object_class = (GtkObjectClass *) klass;
tool_class = (GimpToolClass *) klass;
draw_class = (GimpDrawToolClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_DRAW_TOOL);

View File

@ -27,18 +27,19 @@
#include "tools/gimpdrawtool.h"
static void gimp_draw_tool_initialize (GimpDrawTool *);
enum { /* signals */
DRAW,
LAST_SIGNAL
};
static void gimp_draw_tool_class_init (GimpDrawToolClass *klass);
static void gimp_draw_tool_init (GimpDrawTool *draw_tool);
static void gimp_draw_tool_real_draw (GimpDrawTool *draw_tool);
static guint gimp_draw_tool_signals[LAST_SIGNAL] = { 0 };
static void standard_draw_func (GimpDrawTool *tool)
{
}
GtkType
@ -54,7 +55,7 @@ gimp_draw_tool_get_type (void)
sizeof (GimpDrawTool),
sizeof (GimpDrawToolClass),
(GtkClassInitFunc) gimp_draw_tool_class_init,
(GtkObjectInitFunc) gimp_draw_tool_initialize,
(GtkObjectInitFunc) gimp_draw_tool_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
NULL /* (GtkClassInitFunc) gimp_tool_class_init, */
@ -66,31 +67,7 @@ gimp_draw_tool_get_type (void)
return tool_type;
}
GimpDrawTool *
gimp_draw_tool_new (void)
{
GimpDrawTool *tool;
tool = gtk_type_new (GIMP_TYPE_DRAW_TOOL);
return tool;
}
static void
gimp_draw_tool_initialize (GimpDrawTool *tool)
{
tool->draw_state = INVISIBLE;
tool->gc = NULL;
tool->paused_count = 0;
tool->line_width = 0;
tool->line_style = GDK_LINE_SOLID;
tool->cap_style = GDK_CAP_NOT_LAST;
tool->join_style = GDK_JOIN_MITER;
}
void
gimp_draw_tool_class_init (GimpDrawToolClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
@ -108,13 +85,24 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
gtk_object_class_add_signals (object_class, gimp_draw_tool_signals, LAST_SIGNAL);
klass->draw = standard_draw_func;
klass->draw = gimp_draw_tool_real_draw;
}
static void
gimp_draw_tool_init (GimpDrawTool *tool)
{
tool->draw_state = INVISIBLE;
tool->gc = NULL;
tool->paused_count = 0;
tool->line_width = 0;
tool->line_style = GDK_LINE_SOLID;
tool->cap_style = GDK_CAP_NOT_LAST;
tool->join_style = GDK_JOIN_MITER;
}
void
gimp_draw_tool_start (GimpDrawTool *core,
GdkWindow *win)
gimp_draw_tool_start (GimpDrawTool *core,
GdkWindow *win)
{
GdkColor fg, bg;
@ -177,7 +165,6 @@ gimp_draw_tool_pause (GimpDrawTool *core)
core->paused_count++;
}
/*FIXME: make this get called */
void
gimp_draw_tool_destroy (GimpDrawTool *core)
@ -189,4 +176,7 @@ gimp_draw_tool_destroy (GimpDrawTool *core)
}
}
static void
gimp_draw_tool_real_draw (GimpDrawTool *draw_tool)
{
}

View File

@ -19,21 +19,23 @@
#ifndef __GIMP_DRAW_TOOL_H__
#define __GIMP_DRAW_TOOL_H__
#include "tools/tool.h"
/* draw states */
#define INVISIBLE 0
#define VISIBLE 1
#define GIMP_TYPE_DRAW_TOOL (gimp_draw_tool_get_type ())
#define GIMP_DRAW_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAW_TOOL, GimpDrawTool))
#define GIMP_IS_DRAW_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAW_TOOL))
#define GIMP_DRAW_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAW_TOOL, GimpDrawToolClass))
#define GIMP_IS_DRAW_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAW_TOOL))
/* draw states */
#define INVISIBLE 0
#define VISIBLE 1
/* Structure definitions */
typedef void (* DrawToolDraw) (GimpDrawTool *);
typedef struct _GimpDrawToolClass GimpDrawToolClass;
struct _GimpDrawTool
{
@ -56,22 +58,17 @@ struct _GimpDrawToolClass
{
GimpToolClass parent_class;
DrawToolDraw draw;
void (* draw) (GimpDrawTool *draw_tool);
};
typedef struct _GimpDrawToolClass GimpDrawToolClass;
/* draw core functions */
GtkType gimp_draw_tool_get_type (void);
void gimp_draw_tool_class_init (GimpDrawToolClass *);
GimpDrawTool * gimp_draw_tool_new (void); /* create a new, generic DrawTool */
void gimp_draw_tool_start (GimpDrawTool *,
GdkWindow *);
void gimp_draw_tool_stop (GimpDrawTool *);
void gimp_draw_tool_pause (GimpDrawTool *);
void gimp_draw_tool_resume (GimpDrawTool *);
void gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *window);
void gimp_draw_tool_stop (GimpDrawTool *draw_tool);
void gimp_draw_tool_pause (GimpDrawTool *draw_tool);
void gimp_draw_tool_resume (GimpDrawTool *draw_tool);
#endif /* __DRAWTOOL_H__ */
#endif /* __GIMP_DRAW_TOOL_H__ */

View File

@ -499,10 +499,11 @@ gimp_paintbrush_tool_register (void)
{
tool_manager_register_tool (GIMP_TYPE_PAINTBRUSH_TOOL,
"gimp:paintbrush_tool",
N_("Paintbrush"),
N_("Paint fuzzy brush strokes"),
_("Paintbrush"),
_("Paint fuzzy brush strokes"),
N_("/Tools/Paint Tools/Paintbrush"), "P",
NULL, "tools/paintbrush.html", (const gchar **) paint_bits);
NULL, "tools/paintbrush.html",
(const gchar **) paint_bits);
}

View File

@ -37,7 +37,7 @@ struct _GimpPaintbrushToolClass
GimpPaintToolClass parent_class;
};
typedef struct _GimpPaintbrushTool GimpPaintbrushTool;
typedef struct _GimpPaintbrushTool GimpPaintbrushTool;
typedef struct _GimpPaintbrushToolClass GimpPaintbrushToolClass;
/* FIXME: this antique code doesn't follow the coding style */
@ -52,6 +52,8 @@ gboolean gimp_paintbrush_tool_non_gui_default (GimpDrawable *,
gint ,
gdouble *);
void gimp_paintbrush_tool_register (void);
GimpTool * gimp_paintbrush_tool_new (void);
GtkType gimp_paintbrush_tool_get_type (void);

View File

@ -469,22 +469,6 @@ gimp_tool_real_oper_update (GimpTool *tool,
/* Function definitions */
/* Create a default tool object
*/
GimpTool *
gimp_tool_new (void)
{
GimpTool *tool;
tool = gtk_type_new (GIMP_TYPE_TOOL);
return tool;
}
void
gimp_tool_help_func (const gchar *help_data)
{

View File

@ -469,22 +469,6 @@ gimp_tool_real_oper_update (GimpTool *tool,
/* Function definitions */
/* Create a default tool object
*/
GimpTool *
gimp_tool_new (void)
{
GimpTool *tool;
tool = gtk_type_new (GIMP_TYPE_TOOL);
return tool;
}
void
gimp_tool_help_func (const gchar *help_data)
{

View File

@ -54,7 +54,7 @@ static void gimp_container_grid_view_clear_items (GimpContainerView *v
static void gimp_container_grid_view_set_preview_size (GimpContainerView *view);
static void gimp_container_grid_view_item_selected (GtkWidget *widget,
gpointer data);
static void gimp_container_grid_view_item_activate (GtkWidget *widget,
static void gimp_container_grid_view_item_activated (GtkWidget *widget,
gpointer data);
static void gimp_container_grid_view_highlight_item (GimpContainerView *view,
GimpViewable *viewable,
@ -240,7 +240,7 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
view);
gtk_signal_connect (GTK_OBJECT (preview), "double_clicked",
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activate),
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activated),
view);
return (gpointer) preview;
@ -336,20 +336,16 @@ static void
gimp_container_grid_view_item_selected (GtkWidget *widget,
gpointer data)
{
gimp_container_grid_view_highlight_item (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable,
widget);
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
}
static void
gimp_container_grid_view_item_activate (GtkWidget *widget,
gpointer data)
gimp_container_grid_view_item_activated (GtkWidget *widget,
gpointer data)
{
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
}
static void

View File

@ -58,7 +58,7 @@ static void gimp_container_list_view_name_changed (GimpViewable *v
static void gimp_container_list_view_item_selected (GtkWidget *widget,
GtkWidget *child,
gpointer data);
static gint gimp_container_list_view_item_activate (GtkWidget *widget,
static gint gimp_container_list_view_item_activated (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static GimpViewable * gimp_container_list_view_drag_viewable (GtkWidget *widget,
@ -243,7 +243,7 @@ gimp_container_list_view_insert_item (GimpContainerView *view,
GTK_OBJECT (list_view));
gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event",
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activate),
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activated),
list_view);
gimp_gtk_drag_source_set_by_type (list_item,
@ -382,6 +382,10 @@ gimp_container_list_view_select_item (GimpContainerView *view,
gimp_container_list_view_item_selected,
list_view);
}
else
{
gtk_list_unselect_all (GTK_LIST (list_view->gtk_list));
}
}
static void
@ -440,9 +444,9 @@ gimp_container_list_view_item_selected (GtkWidget *widget,
}
static gint
gimp_container_list_view_item_activate (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
gimp_container_list_view_item_activated (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
if (bevent->type == GDK_2BUTTON_PRESS)
{
@ -451,7 +455,7 @@ gimp_container_list_view_item_activate (GtkWidget *widget,
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data), viewable);
gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data), viewable);
}
return FALSE;

View File

@ -427,17 +427,19 @@ gimp_container_view_item_selected (GimpContainerView *view,
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
if (! (view->container && view->context))
return;
if (view->container && view->context)
{
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
gimp_container_view_select_item (view, viewable);
}
void
gimp_container_view_item_activate (GimpContainerView *view,
GimpViewable *viewable)
gimp_container_view_item_activated (GimpContainerView *view,
GimpViewable *viewable)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));

View File

@ -87,7 +87,7 @@ void gimp_container_view_activate_item (GimpContainerView *view,
void gimp_container_view_item_selected (GimpContainerView *view,
GimpViewable *item);
void gimp_container_view_item_activate (GimpContainerView *view,
void gimp_container_view_item_activated (GimpContainerView *view,
GimpViewable *item);

View File

@ -0,0 +1,528 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "gimpcontainer.h"
#include "gimpdrawable.h"
#include "gimpdrawablelistview.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimprc.h"
#include "gimpviewable.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/delete.xpm"
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
#include "pixmaps/duplicate.xpm"
#include "pixmaps/new.xpm"
#include "pixmaps/pennorm.xpm"
static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass);
static void gimp_drawable_list_view_init (GimpDrawableListView *view);
static void gimp_drawable_list_view_destroy (GtkObject *object);
static void gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view);
static GimpContainerListViewClass *parent_class = NULL;
GtkType
gimp_drawable_list_view_get_type (void)
{
static guint view_type = 0;
if (! view_type)
{
GtkTypeInfo view_info =
{
"GimpDrawableListView",
sizeof (GimpDrawableListView),
sizeof (GimpDrawableListViewClass),
(GtkClassInitFunc) gimp_drawable_list_view_class_init,
(GtkObjectInitFunc) gimp_drawable_list_view_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_LIST_VIEW, &view_info);
}
return view_type;
}
static void
gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
{
GtkObjectClass *object_class;
GimpContainerViewClass *container_view_class;
object_class = (GtkObjectClass *) klass;
container_view_class = (GimpContainerViewClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_LIST_VIEW);
object_class->destroy = gimp_drawable_list_view_destroy;
container_view_class->select_item = gimp_drawable_list_view_select_item;
container_view_class->activate_item = gimp_drawable_list_view_activate_item;
}
static void
gimp_drawable_list_view_init (GimpDrawableListView *view)
{
GtkWidget *pixmap;
view->gimage = NULL;
view->drawable_type = GTK_TYPE_NONE;
view->signal_name = NULL;
gtk_box_set_spacing (GTK_BOX (view), 2);
view->button_box = gtk_hbox_new (TRUE, 2);
gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0);
gtk_widget_show (view->button_box);
/* new */
view->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button,
TRUE, TRUE, 0);
gtk_widget_show (view->new_button);
gimp_help_set_help_data (view->new_button, _("New"), NULL);
gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_new_clicked),
view);
pixmap = gimp_pixmap_new (new_xpm);
gtk_container_add (GTK_CONTAINER (view->new_button), pixmap);
gtk_widget_show (pixmap);
/* raise */
view->raise_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->raise_button,
TRUE, TRUE, 0);
gtk_widget_show (view->raise_button);
gimp_help_set_help_data (view->raise_button, _("Raise"), NULL);
gtk_signal_connect (GTK_OBJECT (view->raise_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_raise_clicked),
view);
pixmap = gimp_pixmap_new (raise_xpm);
gtk_container_add (GTK_CONTAINER (view->raise_button), pixmap);
gtk_widget_show (pixmap);
/* lower */
view->lower_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->lower_button,
TRUE, TRUE, 0);
gtk_widget_show (view->lower_button);
gimp_help_set_help_data (view->lower_button, _("Lower"), NULL);
gtk_signal_connect (GTK_OBJECT (view->lower_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_lower_clicked),
view);
pixmap = gimp_pixmap_new (lower_xpm);
gtk_container_add (GTK_CONTAINER (view->lower_button), pixmap);
gtk_widget_show (pixmap);
/* duplicate */
view->duplicate_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button,
TRUE, TRUE, 0);
gtk_widget_show (view->duplicate_button);
gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL);
gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_duplicate_clicked),
view);
pixmap = gimp_pixmap_new (duplicate_xpm);
gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap);
gtk_widget_show (pixmap);
/* edit */
view->edit_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button,
TRUE, TRUE, 0);
gtk_widget_show (view->edit_button);
gimp_help_set_help_data (view->edit_button, _("Edit"), NULL);
gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_edit_clicked),
view);
pixmap = gimp_pixmap_new (pennorm_xpm);
gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap);
gtk_widget_show (pixmap);
/* delete */
view->delete_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button,
TRUE, TRUE, 0);
gtk_widget_show (view->delete_button);
gimp_help_set_help_data (view->delete_button, _("Delete"), NULL);
gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_delete_clicked),
view);
pixmap = gimp_pixmap_new (delete_xpm);
gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap);
gtk_widget_show (pixmap);
gtk_widget_set_sensitive (view->raise_button, FALSE);
gtk_widget_set_sensitive (view->lower_button, FALSE);
gtk_widget_set_sensitive (view->duplicate_button, FALSE);
gtk_widget_set_sensitive (view->delete_button, FALSE);
}
static void
gimp_drawable_list_view_destroy (GtkObject *object)
{
GimpDrawableListView *view;
view = GIMP_DRAWABLE_LIST_VIEW (object);
g_free (view->signal_name);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (signal_name != NULL, NULL);
g_return_val_if_fail (get_container_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
list_view = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_VIEW);
view = GIMP_CONTAINER_VIEW (list_view);
view->preview_size = preview_size;
list_view->drawable_type = drawable_type;
list_view->signal_name = g_strdup (signal_name);
list_view->get_container_func = get_container_func;
list_view->get_drawable_func = get_drawable_func;
list_view->set_drawable_func = set_drawable_func;
/* drop to "new" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->new_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->new_button),
drawable_type,
gimp_drawable_list_view_new_dropped,
list_view);
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->duplicate_button),
drawable_type,
gimp_drawable_list_view_duplicate_dropped,
list_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->edit_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->edit_button),
drawable_type,
gimp_drawable_list_view_edit_dropped,
list_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->delete_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->delete_button),
drawable_type,
gimp_drawable_list_view_delete_dropped,
list_view);
if (gimage)
gimp_drawable_list_view_set_image (list_view, gimage);
return GTK_WIDGET (list_view);
}
void
gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE_LIST_VIEW (view));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (view->gimage == gimage)
return;
if (view->gimage)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (view->gimage),
gimp_drawable_list_view_drawable_changed,
view);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL);
}
view->gimage = gimage;
if (view->gimage)
{
GimpContainer *container;
container = view->get_container_func (view->gimage);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container);
gtk_signal_connect (GTK_OBJECT (view->gimage), view->signal_name,
GTK_SIGNAL_FUNC (gimp_drawable_list_view_drawable_changed),
view);
}
}
static void
gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view,
item,
insert_data);
g_print ("select item\n");
}
static void
gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item (view,
item,
insert_data);
g_print ("activate item\n");
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("new clicked\n");
}
static void
gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("new dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
}
}
static void
gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("duplicate clicked\n");
}
static void
gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("duplicate dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_duplicate_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("raise clicked\n");
}
static void
gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("lower clicked\n");
}
static void
gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("edit clicked\n");
}
static void
gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("edit dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_edit_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("delete clicked\n");
}
static void
gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("delete dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_delete_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view)
{
GimpDrawable *drawable;
drawable = view->get_drawable_func (gimage);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
(GimpViewable *) drawable);
}

View File

@ -0,0 +1,83 @@
/* 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_DRAWABLE_LIST_VIEW_H__
#define __GIMP_DRAWABLE_LIST_VIEW_H__
#include "gimpcontainerlistview.h"
typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *gimage);
typedef GimpDrawable * (* GimpGetDrawableFunc) (const GimpImage *gimage);
typedef void (* GimpSetDrawableFunc) (GimpImage *gimage,
GimpDrawable *drawable);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
#define GIMP_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListView))
#define GIMP_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListViewClass))
#define GIMP_IS_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW))
#define GIMP_IS_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW))
typedef struct _GimpDrawableListViewClass GimpDrawableListViewClass;
struct _GimpDrawableListView
{
GimpContainerListView parent_instance;
GimpImage *gimage;
GtkType drawable_type;
gchar *signal_name;
GimpGetContainerFunc get_container_func;
GimpGetDrawableFunc get_drawable_func;
GimpSetDrawableFunc set_drawable_func;
GtkWidget *button_box;
GtkWidget *new_button;
GtkWidget *raise_button;
GtkWidget *lower_button;
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
};
struct _GimpDrawableListViewClass
{
GimpContainerListViewClass parent_class;
};
GtkType gimp_drawable_list_view_get_type (void);
GtkWidget * gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);
#endif /* __GIMP_DRAWABLE_LIST_VIEW_H__ */

View File

@ -0,0 +1,528 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "gimpcontainer.h"
#include "gimpdrawable.h"
#include "gimpdrawablelistview.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimprc.h"
#include "gimpviewable.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/delete.xpm"
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
#include "pixmaps/duplicate.xpm"
#include "pixmaps/new.xpm"
#include "pixmaps/pennorm.xpm"
static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass);
static void gimp_drawable_list_view_init (GimpDrawableListView *view);
static void gimp_drawable_list_view_destroy (GtkObject *object);
static void gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view);
static GimpContainerListViewClass *parent_class = NULL;
GtkType
gimp_drawable_list_view_get_type (void)
{
static guint view_type = 0;
if (! view_type)
{
GtkTypeInfo view_info =
{
"GimpDrawableListView",
sizeof (GimpDrawableListView),
sizeof (GimpDrawableListViewClass),
(GtkClassInitFunc) gimp_drawable_list_view_class_init,
(GtkObjectInitFunc) gimp_drawable_list_view_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_LIST_VIEW, &view_info);
}
return view_type;
}
static void
gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
{
GtkObjectClass *object_class;
GimpContainerViewClass *container_view_class;
object_class = (GtkObjectClass *) klass;
container_view_class = (GimpContainerViewClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_LIST_VIEW);
object_class->destroy = gimp_drawable_list_view_destroy;
container_view_class->select_item = gimp_drawable_list_view_select_item;
container_view_class->activate_item = gimp_drawable_list_view_activate_item;
}
static void
gimp_drawable_list_view_init (GimpDrawableListView *view)
{
GtkWidget *pixmap;
view->gimage = NULL;
view->drawable_type = GTK_TYPE_NONE;
view->signal_name = NULL;
gtk_box_set_spacing (GTK_BOX (view), 2);
view->button_box = gtk_hbox_new (TRUE, 2);
gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0);
gtk_widget_show (view->button_box);
/* new */
view->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button,
TRUE, TRUE, 0);
gtk_widget_show (view->new_button);
gimp_help_set_help_data (view->new_button, _("New"), NULL);
gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_new_clicked),
view);
pixmap = gimp_pixmap_new (new_xpm);
gtk_container_add (GTK_CONTAINER (view->new_button), pixmap);
gtk_widget_show (pixmap);
/* raise */
view->raise_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->raise_button,
TRUE, TRUE, 0);
gtk_widget_show (view->raise_button);
gimp_help_set_help_data (view->raise_button, _("Raise"), NULL);
gtk_signal_connect (GTK_OBJECT (view->raise_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_raise_clicked),
view);
pixmap = gimp_pixmap_new (raise_xpm);
gtk_container_add (GTK_CONTAINER (view->raise_button), pixmap);
gtk_widget_show (pixmap);
/* lower */
view->lower_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->lower_button,
TRUE, TRUE, 0);
gtk_widget_show (view->lower_button);
gimp_help_set_help_data (view->lower_button, _("Lower"), NULL);
gtk_signal_connect (GTK_OBJECT (view->lower_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_lower_clicked),
view);
pixmap = gimp_pixmap_new (lower_xpm);
gtk_container_add (GTK_CONTAINER (view->lower_button), pixmap);
gtk_widget_show (pixmap);
/* duplicate */
view->duplicate_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button,
TRUE, TRUE, 0);
gtk_widget_show (view->duplicate_button);
gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL);
gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_duplicate_clicked),
view);
pixmap = gimp_pixmap_new (duplicate_xpm);
gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap);
gtk_widget_show (pixmap);
/* edit */
view->edit_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button,
TRUE, TRUE, 0);
gtk_widget_show (view->edit_button);
gimp_help_set_help_data (view->edit_button, _("Edit"), NULL);
gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_edit_clicked),
view);
pixmap = gimp_pixmap_new (pennorm_xpm);
gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap);
gtk_widget_show (pixmap);
/* delete */
view->delete_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button,
TRUE, TRUE, 0);
gtk_widget_show (view->delete_button);
gimp_help_set_help_data (view->delete_button, _("Delete"), NULL);
gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_delete_clicked),
view);
pixmap = gimp_pixmap_new (delete_xpm);
gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap);
gtk_widget_show (pixmap);
gtk_widget_set_sensitive (view->raise_button, FALSE);
gtk_widget_set_sensitive (view->lower_button, FALSE);
gtk_widget_set_sensitive (view->duplicate_button, FALSE);
gtk_widget_set_sensitive (view->delete_button, FALSE);
}
static void
gimp_drawable_list_view_destroy (GtkObject *object)
{
GimpDrawableListView *view;
view = GIMP_DRAWABLE_LIST_VIEW (object);
g_free (view->signal_name);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (signal_name != NULL, NULL);
g_return_val_if_fail (get_container_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
list_view = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_VIEW);
view = GIMP_CONTAINER_VIEW (list_view);
view->preview_size = preview_size;
list_view->drawable_type = drawable_type;
list_view->signal_name = g_strdup (signal_name);
list_view->get_container_func = get_container_func;
list_view->get_drawable_func = get_drawable_func;
list_view->set_drawable_func = set_drawable_func;
/* drop to "new" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->new_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->new_button),
drawable_type,
gimp_drawable_list_view_new_dropped,
list_view);
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->duplicate_button),
drawable_type,
gimp_drawable_list_view_duplicate_dropped,
list_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->edit_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->edit_button),
drawable_type,
gimp_drawable_list_view_edit_dropped,
list_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->delete_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->delete_button),
drawable_type,
gimp_drawable_list_view_delete_dropped,
list_view);
if (gimage)
gimp_drawable_list_view_set_image (list_view, gimage);
return GTK_WIDGET (list_view);
}
void
gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE_LIST_VIEW (view));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (view->gimage == gimage)
return;
if (view->gimage)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (view->gimage),
gimp_drawable_list_view_drawable_changed,
view);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL);
}
view->gimage = gimage;
if (view->gimage)
{
GimpContainer *container;
container = view->get_container_func (view->gimage);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container);
gtk_signal_connect (GTK_OBJECT (view->gimage), view->signal_name,
GTK_SIGNAL_FUNC (gimp_drawable_list_view_drawable_changed),
view);
}
}
static void
gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view,
item,
insert_data);
g_print ("select item\n");
}
static void
gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item (view,
item,
insert_data);
g_print ("activate item\n");
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("new clicked\n");
}
static void
gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("new dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
}
}
static void
gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("duplicate clicked\n");
}
static void
gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("duplicate dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_duplicate_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("raise clicked\n");
}
static void
gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("lower clicked\n");
}
static void
gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("edit clicked\n");
}
static void
gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("edit dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_edit_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("delete clicked\n");
}
static void
gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("delete dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_delete_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view)
{
GimpDrawable *drawable;
drawable = view->get_drawable_func (gimage);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
(GimpViewable *) drawable);
}

View File

@ -0,0 +1,83 @@
/* 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_DRAWABLE_LIST_VIEW_H__
#define __GIMP_DRAWABLE_LIST_VIEW_H__
#include "gimpcontainerlistview.h"
typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *gimage);
typedef GimpDrawable * (* GimpGetDrawableFunc) (const GimpImage *gimage);
typedef void (* GimpSetDrawableFunc) (GimpImage *gimage,
GimpDrawable *drawable);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
#define GIMP_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListView))
#define GIMP_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListViewClass))
#define GIMP_IS_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW))
#define GIMP_IS_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW))
typedef struct _GimpDrawableListViewClass GimpDrawableListViewClass;
struct _GimpDrawableListView
{
GimpContainerListView parent_instance;
GimpImage *gimage;
GtkType drawable_type;
gchar *signal_name;
GimpGetContainerFunc get_container_func;
GimpGetDrawableFunc get_drawable_func;
GimpSetDrawableFunc set_drawable_func;
GtkWidget *button_box;
GtkWidget *new_button;
GtkWidget *raise_button;
GtkWidget *lower_button;
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
};
struct _GimpDrawableListViewClass
{
GimpContainerListViewClass parent_class;
};
GtkType gimp_drawable_list_view_get_type (void);
GtkWidget * gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);
#endif /* __GIMP_DRAWABLE_LIST_VIEW_H__ */

View File

@ -43,6 +43,9 @@
#include "menus.h"
#include "paths_dialog.h"
/* test dialogs */
#include "test_commands.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
@ -157,53 +160,49 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/display_filters/display_filters.html", NULL },
#endif /* DISPLAY_FILTERS */
{ { N_("/File/Test Dialogs/Layer List..."), NULL, dialogs_test_layer_list_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Layer List..."), NULL, test_layer_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Layer Grid..."), NULL, dialogs_test_layer_grid_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, dialogs_test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { N_("/File/Test Dialogs/Channel Grid..."), NULL, dialogs_test_channel_grid_cmd_callback, 1 },
{ { N_("/File/Test Dialogs/Channel List..."), NULL, test_channel_list_cmd_callback, 1 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Images List...", NULL, dialogs_test_image_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images List...", NULL, test_image_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Images Grid...", NULL, dialogs_test_image_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Images Grid...", NULL, test_image_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe List...", NULL, dialogs_test_brush_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe List...", NULL, test_brush_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern List...", NULL, dialogs_test_pattern_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern List...", NULL, test_pattern_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient List...", NULL, dialogs_test_gradient_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient List...", NULL, test_gradient_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette List...", NULL, dialogs_test_palette_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette List...", NULL, test_palette_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, dialogs_test_brush_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Brushe Grid...", NULL, test_brush_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, dialogs_test_pattern_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Pattern Grid...", NULL, test_pattern_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, dialogs_test_gradient_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Gradient Grid...", NULL, test_gradient_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Palette Grid...", NULL, dialogs_test_palette_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Palette Grid...", NULL, test_palette_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { "/File/Test Dialogs/Multi List...", NULL, dialogs_test_multi_container_list_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi List...", NULL, test_multi_container_list_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/Test Dialogs/Multi Grid...", NULL, dialogs_test_multi_container_grid_view_cmd_callback, 0 },
{ { "/File/Test Dialogs/Multi Grid...", NULL, test_multi_container_grid_view_cmd_callback, 0 },
NULL, NULL },
{ { "/File/---", NULL, NULL, 0, "<Separator>" },

View File

@ -0,0 +1,528 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "gimpcontainer.h"
#include "gimpdrawable.h"
#include "gimpdrawablelistview.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimprc.h"
#include "gimpviewable.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/delete.xpm"
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
#include "pixmaps/duplicate.xpm"
#include "pixmaps/new.xpm"
#include "pixmaps/pennorm.xpm"
static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass);
static void gimp_drawable_list_view_init (GimpDrawableListView *view);
static void gimp_drawable_list_view_destroy (GtkObject *object);
static void gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view);
static GimpContainerListViewClass *parent_class = NULL;
GtkType
gimp_drawable_list_view_get_type (void)
{
static guint view_type = 0;
if (! view_type)
{
GtkTypeInfo view_info =
{
"GimpDrawableListView",
sizeof (GimpDrawableListView),
sizeof (GimpDrawableListViewClass),
(GtkClassInitFunc) gimp_drawable_list_view_class_init,
(GtkObjectInitFunc) gimp_drawable_list_view_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_LIST_VIEW, &view_info);
}
return view_type;
}
static void
gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
{
GtkObjectClass *object_class;
GimpContainerViewClass *container_view_class;
object_class = (GtkObjectClass *) klass;
container_view_class = (GimpContainerViewClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_LIST_VIEW);
object_class->destroy = gimp_drawable_list_view_destroy;
container_view_class->select_item = gimp_drawable_list_view_select_item;
container_view_class->activate_item = gimp_drawable_list_view_activate_item;
}
static void
gimp_drawable_list_view_init (GimpDrawableListView *view)
{
GtkWidget *pixmap;
view->gimage = NULL;
view->drawable_type = GTK_TYPE_NONE;
view->signal_name = NULL;
gtk_box_set_spacing (GTK_BOX (view), 2);
view->button_box = gtk_hbox_new (TRUE, 2);
gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0);
gtk_widget_show (view->button_box);
/* new */
view->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button,
TRUE, TRUE, 0);
gtk_widget_show (view->new_button);
gimp_help_set_help_data (view->new_button, _("New"), NULL);
gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_new_clicked),
view);
pixmap = gimp_pixmap_new (new_xpm);
gtk_container_add (GTK_CONTAINER (view->new_button), pixmap);
gtk_widget_show (pixmap);
/* raise */
view->raise_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->raise_button,
TRUE, TRUE, 0);
gtk_widget_show (view->raise_button);
gimp_help_set_help_data (view->raise_button, _("Raise"), NULL);
gtk_signal_connect (GTK_OBJECT (view->raise_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_raise_clicked),
view);
pixmap = gimp_pixmap_new (raise_xpm);
gtk_container_add (GTK_CONTAINER (view->raise_button), pixmap);
gtk_widget_show (pixmap);
/* lower */
view->lower_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->lower_button,
TRUE, TRUE, 0);
gtk_widget_show (view->lower_button);
gimp_help_set_help_data (view->lower_button, _("Lower"), NULL);
gtk_signal_connect (GTK_OBJECT (view->lower_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_lower_clicked),
view);
pixmap = gimp_pixmap_new (lower_xpm);
gtk_container_add (GTK_CONTAINER (view->lower_button), pixmap);
gtk_widget_show (pixmap);
/* duplicate */
view->duplicate_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button,
TRUE, TRUE, 0);
gtk_widget_show (view->duplicate_button);
gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL);
gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_duplicate_clicked),
view);
pixmap = gimp_pixmap_new (duplicate_xpm);
gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap);
gtk_widget_show (pixmap);
/* edit */
view->edit_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button,
TRUE, TRUE, 0);
gtk_widget_show (view->edit_button);
gimp_help_set_help_data (view->edit_button, _("Edit"), NULL);
gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_edit_clicked),
view);
pixmap = gimp_pixmap_new (pennorm_xpm);
gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap);
gtk_widget_show (pixmap);
/* delete */
view->delete_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button,
TRUE, TRUE, 0);
gtk_widget_show (view->delete_button);
gimp_help_set_help_data (view->delete_button, _("Delete"), NULL);
gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_delete_clicked),
view);
pixmap = gimp_pixmap_new (delete_xpm);
gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap);
gtk_widget_show (pixmap);
gtk_widget_set_sensitive (view->raise_button, FALSE);
gtk_widget_set_sensitive (view->lower_button, FALSE);
gtk_widget_set_sensitive (view->duplicate_button, FALSE);
gtk_widget_set_sensitive (view->delete_button, FALSE);
}
static void
gimp_drawable_list_view_destroy (GtkObject *object)
{
GimpDrawableListView *view;
view = GIMP_DRAWABLE_LIST_VIEW (object);
g_free (view->signal_name);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (signal_name != NULL, NULL);
g_return_val_if_fail (get_container_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
list_view = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_VIEW);
view = GIMP_CONTAINER_VIEW (list_view);
view->preview_size = preview_size;
list_view->drawable_type = drawable_type;
list_view->signal_name = g_strdup (signal_name);
list_view->get_container_func = get_container_func;
list_view->get_drawable_func = get_drawable_func;
list_view->set_drawable_func = set_drawable_func;
/* drop to "new" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->new_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->new_button),
drawable_type,
gimp_drawable_list_view_new_dropped,
list_view);
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->duplicate_button),
drawable_type,
gimp_drawable_list_view_duplicate_dropped,
list_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->edit_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->edit_button),
drawable_type,
gimp_drawable_list_view_edit_dropped,
list_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->delete_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->delete_button),
drawable_type,
gimp_drawable_list_view_delete_dropped,
list_view);
if (gimage)
gimp_drawable_list_view_set_image (list_view, gimage);
return GTK_WIDGET (list_view);
}
void
gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE_LIST_VIEW (view));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (view->gimage == gimage)
return;
if (view->gimage)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (view->gimage),
gimp_drawable_list_view_drawable_changed,
view);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL);
}
view->gimage = gimage;
if (view->gimage)
{
GimpContainer *container;
container = view->get_container_func (view->gimage);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container);
gtk_signal_connect (GTK_OBJECT (view->gimage), view->signal_name,
GTK_SIGNAL_FUNC (gimp_drawable_list_view_drawable_changed),
view);
}
}
static void
gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view,
item,
insert_data);
g_print ("select item\n");
}
static void
gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item (view,
item,
insert_data);
g_print ("activate item\n");
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("new clicked\n");
}
static void
gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("new dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
}
}
static void
gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("duplicate clicked\n");
}
static void
gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("duplicate dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_duplicate_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("raise clicked\n");
}
static void
gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("lower clicked\n");
}
static void
gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("edit clicked\n");
}
static void
gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("edit dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_edit_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("delete clicked\n");
}
static void
gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("delete dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_delete_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view)
{
GimpDrawable *drawable;
drawable = view->get_drawable_func (gimage);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
(GimpViewable *) drawable);
}

View File

@ -0,0 +1,83 @@
/* 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_DRAWABLE_LIST_VIEW_H__
#define __GIMP_DRAWABLE_LIST_VIEW_H__
#include "gimpcontainerlistview.h"
typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *gimage);
typedef GimpDrawable * (* GimpGetDrawableFunc) (const GimpImage *gimage);
typedef void (* GimpSetDrawableFunc) (GimpImage *gimage,
GimpDrawable *drawable);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
#define GIMP_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListView))
#define GIMP_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListViewClass))
#define GIMP_IS_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW))
#define GIMP_IS_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW))
typedef struct _GimpDrawableListViewClass GimpDrawableListViewClass;
struct _GimpDrawableListView
{
GimpContainerListView parent_instance;
GimpImage *gimage;
GtkType drawable_type;
gchar *signal_name;
GimpGetContainerFunc get_container_func;
GimpGetDrawableFunc get_drawable_func;
GimpSetDrawableFunc set_drawable_func;
GtkWidget *button_box;
GtkWidget *new_button;
GtkWidget *raise_button;
GtkWidget *lower_button;
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
};
struct _GimpDrawableListViewClass
{
GimpContainerListViewClass parent_class;
};
GtkType gimp_drawable_list_view_get_type (void);
GtkWidget * gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);
#endif /* __GIMP_DRAWABLE_LIST_VIEW_H__ */

View File

@ -0,0 +1,528 @@
/* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "gimpcontainer.h"
#include "gimpdrawable.h"
#include "gimpdrawablelistview.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimprc.h"
#include "gimpviewable.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/delete.xpm"
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
#include "pixmaps/duplicate.xpm"
#include "pixmaps/new.xpm"
#include "pixmaps/pennorm.xpm"
static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass);
static void gimp_drawable_list_view_init (GimpDrawableListView *view);
static void gimp_drawable_list_view_destroy (GtkObject *object);
static void gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer drawable);
static void gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view);
static GimpContainerListViewClass *parent_class = NULL;
GtkType
gimp_drawable_list_view_get_type (void)
{
static guint view_type = 0;
if (! view_type)
{
GtkTypeInfo view_info =
{
"GimpDrawableListView",
sizeof (GimpDrawableListView),
sizeof (GimpDrawableListViewClass),
(GtkClassInitFunc) gimp_drawable_list_view_class_init,
(GtkObjectInitFunc) gimp_drawable_list_view_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_LIST_VIEW, &view_info);
}
return view_type;
}
static void
gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
{
GtkObjectClass *object_class;
GimpContainerViewClass *container_view_class;
object_class = (GtkObjectClass *) klass;
container_view_class = (GimpContainerViewClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_LIST_VIEW);
object_class->destroy = gimp_drawable_list_view_destroy;
container_view_class->select_item = gimp_drawable_list_view_select_item;
container_view_class->activate_item = gimp_drawable_list_view_activate_item;
}
static void
gimp_drawable_list_view_init (GimpDrawableListView *view)
{
GtkWidget *pixmap;
view->gimage = NULL;
view->drawable_type = GTK_TYPE_NONE;
view->signal_name = NULL;
gtk_box_set_spacing (GTK_BOX (view), 2);
view->button_box = gtk_hbox_new (TRUE, 2);
gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0);
gtk_widget_show (view->button_box);
/* new */
view->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button,
TRUE, TRUE, 0);
gtk_widget_show (view->new_button);
gimp_help_set_help_data (view->new_button, _("New"), NULL);
gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_new_clicked),
view);
pixmap = gimp_pixmap_new (new_xpm);
gtk_container_add (GTK_CONTAINER (view->new_button), pixmap);
gtk_widget_show (pixmap);
/* raise */
view->raise_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->raise_button,
TRUE, TRUE, 0);
gtk_widget_show (view->raise_button);
gimp_help_set_help_data (view->raise_button, _("Raise"), NULL);
gtk_signal_connect (GTK_OBJECT (view->raise_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_raise_clicked),
view);
pixmap = gimp_pixmap_new (raise_xpm);
gtk_container_add (GTK_CONTAINER (view->raise_button), pixmap);
gtk_widget_show (pixmap);
/* lower */
view->lower_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->lower_button,
TRUE, TRUE, 0);
gtk_widget_show (view->lower_button);
gimp_help_set_help_data (view->lower_button, _("Lower"), NULL);
gtk_signal_connect (GTK_OBJECT (view->lower_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_lower_clicked),
view);
pixmap = gimp_pixmap_new (lower_xpm);
gtk_container_add (GTK_CONTAINER (view->lower_button), pixmap);
gtk_widget_show (pixmap);
/* duplicate */
view->duplicate_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button,
TRUE, TRUE, 0);
gtk_widget_show (view->duplicate_button);
gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL);
gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_duplicate_clicked),
view);
pixmap = gimp_pixmap_new (duplicate_xpm);
gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap);
gtk_widget_show (pixmap);
/* edit */
view->edit_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button,
TRUE, TRUE, 0);
gtk_widget_show (view->edit_button);
gimp_help_set_help_data (view->edit_button, _("Edit"), NULL);
gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_edit_clicked),
view);
pixmap = gimp_pixmap_new (pennorm_xpm);
gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap);
gtk_widget_show (pixmap);
/* delete */
view->delete_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button,
TRUE, TRUE, 0);
gtk_widget_show (view->delete_button);
gimp_help_set_help_data (view->delete_button, _("Delete"), NULL);
gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked",
GTK_SIGNAL_FUNC (gimp_drawable_list_view_delete_clicked),
view);
pixmap = gimp_pixmap_new (delete_xpm);
gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap);
gtk_widget_show (pixmap);
gtk_widget_set_sensitive (view->raise_button, FALSE);
gtk_widget_set_sensitive (view->lower_button, FALSE);
gtk_widget_set_sensitive (view->duplicate_button, FALSE);
gtk_widget_set_sensitive (view->delete_button, FALSE);
}
static void
gimp_drawable_list_view_destroy (GtkObject *object)
{
GimpDrawableListView *view;
view = GIMP_DRAWABLE_LIST_VIEW (object);
g_free (view->signal_name);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (signal_name != NULL, NULL);
g_return_val_if_fail (get_container_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
g_return_val_if_fail (get_drawable_func != NULL, NULL);
list_view = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_VIEW);
view = GIMP_CONTAINER_VIEW (list_view);
view->preview_size = preview_size;
list_view->drawable_type = drawable_type;
list_view->signal_name = g_strdup (signal_name);
list_view->get_container_func = get_container_func;
list_view->get_drawable_func = get_drawable_func;
list_view->set_drawable_func = set_drawable_func;
/* drop to "new" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->new_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->new_button),
drawable_type,
gimp_drawable_list_view_new_dropped,
list_view);
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->duplicate_button),
drawable_type,
gimp_drawable_list_view_duplicate_dropped,
list_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->edit_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->edit_button),
drawable_type,
gimp_drawable_list_view_edit_dropped,
list_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->delete_button),
GTK_DEST_DEFAULT_ALL,
drawable_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->delete_button),
drawable_type,
gimp_drawable_list_view_delete_dropped,
list_view);
if (gimage)
gimp_drawable_list_view_set_image (list_view, gimage);
return GTK_WIDGET (list_view);
}
void
gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE_LIST_VIEW (view));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
if (view->gimage == gimage)
return;
if (view->gimage)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (view->gimage),
gimp_drawable_list_view_drawable_changed,
view);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL);
}
view->gimage = gimage;
if (view->gimage)
{
GimpContainer *container;
container = view->get_container_func (view->gimage);
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container);
gtk_signal_connect (GTK_OBJECT (view->gimage), view->signal_name,
GTK_SIGNAL_FUNC (gimp_drawable_list_view_drawable_changed),
view);
}
}
static void
gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view,
item,
insert_data);
g_print ("select item\n");
}
static void
gimp_drawable_list_view_activate_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item (view,
item,
insert_data);
g_print ("activate item\n");
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("new clicked\n");
}
static void
gimp_drawable_list_view_new_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("new dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
}
}
static void
gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("duplicate clicked\n");
}
static void
gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("duplicate dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_duplicate_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_raise_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("raise clicked\n");
}
static void
gimp_drawable_list_view_lower_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("lower clicked\n");
}
static void
gimp_drawable_list_view_edit_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("edit clicked\n");
}
static void
gimp_drawable_list_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("edit dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_edit_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_delete_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
g_print ("delete clicked\n");
}
static void
gimp_drawable_list_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDrawableListView *view;
view = (GimpDrawableListView *) data;
g_print ("delete dropped\n");
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_delete_clicked (NULL, data);
}
}
static void
gimp_drawable_list_view_drawable_changed (GimpImage *gimage,
GimpDrawableListView *view)
{
GimpDrawable *drawable;
drawable = view->get_drawable_func (gimage);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
(GimpViewable *) drawable);
}

View File

@ -0,0 +1,83 @@
/* 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_DRAWABLE_LIST_VIEW_H__
#define __GIMP_DRAWABLE_LIST_VIEW_H__
#include "gimpcontainerlistview.h"
typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *gimage);
typedef GimpDrawable * (* GimpGetDrawableFunc) (const GimpImage *gimage);
typedef void (* GimpSetDrawableFunc) (GimpImage *gimage,
GimpDrawable *drawable);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
#define GIMP_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListView))
#define GIMP_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListViewClass))
#define GIMP_IS_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW))
#define GIMP_IS_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW))
typedef struct _GimpDrawableListViewClass GimpDrawableListViewClass;
struct _GimpDrawableListView
{
GimpContainerListView parent_instance;
GimpImage *gimage;
GtkType drawable_type;
gchar *signal_name;
GimpGetContainerFunc get_container_func;
GimpGetDrawableFunc get_drawable_func;
GimpSetDrawableFunc set_drawable_func;
GtkWidget *button_box;
GtkWidget *new_button;
GtkWidget *raise_button;
GtkWidget *lower_button;
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
};
struct _GimpDrawableListViewClass
{
GimpContainerListViewClass parent_class;
};
GtkType gimp_drawable_list_view_get_type (void);
GtkWidget * gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
const gchar *signal_name,
GimpGetContainerFunc get_container_func,
GimpGetDrawableFunc get_drawable_func,
GimpSetDrawableFunc set_drawable_func);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);
#endif /* __GIMP_DRAWABLE_LIST_VIEW_H__ */

View File

@ -82,7 +82,6 @@ app/tools/bucket_fill.c
app/tools/by_color_select.c
app/tools/clone.c
app/tools/color_balance.c
app/tools/color_picker.c
app/tools/convolve.c
app/tools/crop.c
app/tools/curves.c
@ -91,6 +90,9 @@ app/tools/edit_selection.c
app/tools/eraser.c
app/tools/flip_tool.c
app/tools/fuzzy_select.c
app/tools/gimpcolorpickertool.c
app/tools/gimppaintbrushtool.c
app/tools/gimppainttool.c
app/tools/histogram_tool.c
app/tools/hue_saturation.c
app/tools/ink.c
@ -98,9 +100,7 @@ app/tools/levels.c
app/tools/magnify.c
app/tools/measure.c
app/tools/move.c
app/tools/paint_core.c
app/tools/paint_options.c
app/tools/paintbrush.c
app/tools/perspective_tool.c
app/tools/posterize.c
app/tools/rect_select.c