added DND source functions which work by GtkType.

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

	* app/gimpdnd.[ch]: added DND source functions which work by
	GtkType.

	* app/commands.c
	* app/brush_select.c
	* app/gradient_select.[ch]
	* app/pattern_select.c: removed the DND code here because it's all
	done by the GimpContainerView now.

	* app/gimpbrushpreview.c
	* app/gimpgradientpreview.c
	* app/gimppalettepreview.c
	* app/gimppatternpreview.c: use the DND by-type connect functions.

	* app/gimpbrushgenerated.c: implemented "duplicate", cleanup.

	* app/gimpcontainergridview.c
	* app/gimpcontainerlistview.c
	* app/gimpcontainerview.[ch]: added a "activate_item" signal
	method which is emitted by the subclasses to indicate double click.

	* app/gimpdatafactoryview.c: connect to "activate_item" and show
	the editor.

	* app/convert.c
	* app/gimppalette.[ch]
	* app/palette.c
	* app/paletteP.h
	* app/palette_import.c
	* app/palette_select.[ch]: major cleanup: Behaves like the other
	datatypes now: DND, context stuff, GimpContainerListViews in
	the dialogs etc. Mostly just removal of code.

	* app/gradient_editor.c: fixed signal blocking/unblocking.

	* plug-ins/script-fu/scripts/Makefile.am: install the "Test Sphere"
	script again.
This commit is contained in:
Michael Natterer 2001-02-18 19:44:28 +00:00 committed by Michael Natterer
parent 2f6f9bdd0b
commit a80dd4d071
65 changed files with 3070 additions and 4296 deletions

View File

@ -1,3 +1,43 @@
2001-02-18 Michael Natterer <mitch@gimp.org>
* app/gimpdnd.[ch]: added DND source functions which work by
GtkType.
* app/commands.c
* app/brush_select.c
* app/gradient_select.[ch]
* app/pattern_select.c: removed the DND code here because it's all
done by the GimpContainerView now.
* app/gimpbrushpreview.c
* app/gimpgradientpreview.c
* app/gimppalettepreview.c
* app/gimppatternpreview.c: use the DND by-type connect functions.
* app/gimpbrushgenerated.c: implemented "duplicate", cleanup.
* app/gimpcontainergridview.c
* app/gimpcontainerlistview.c
* app/gimpcontainerview.[ch]: added a "activate_item" signal
method which is emitted by the subclasses to indicate double click.
* app/gimpdatafactoryview.c: connect to "activate_item" and show
the editor.
* app/convert.c
* app/gimppalette.[ch]
* app/palette.c
* app/paletteP.h
* app/palette_import.c
* app/palette_select.[ch]: major cleanup: Behaves like the other
datatypes now: DND, context stuff, GimpContainerListViews in
the dialogs etc. Mostly just removal of code.
* app/gradient_editor.c: fixed signal blocking/unblocking.
* plug-ins/script-fu/scripts/Makefile.am: install the "Test Sphere"
script again.
2001-02-17 Michael Natterer <mitch@gimp.org> 2001-02-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontainer.[ch] * app/gimpcontainer.[ch]

View File

@ -83,7 +83,6 @@
#include "gimpcontainergridview.h" #include "gimpcontainergridview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdatafactoryview.h" #include "gimpdatafactoryview.h"
#include "gimpdnd.h"
#include "gimppreview.h" #include "gimppreview.h"
@ -1335,108 +1334,38 @@ container_view_scale_callback (GtkAdjustment *adj,
gimp_container_view_set_preview_size (view, ROUND (adj->value)); gimp_container_view_set_preview_size (view, ROUND (adj->value));
} }
static void
drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (widget);
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}
static void static void
brushes_callback (GtkWidget *widget, brushes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_brush_factory->container); gimp_container_view_set_container (view, global_brush_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
patterns_callback (GtkWidget *widget, patterns_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_pattern_factory->container); gimp_container_view_set_container (view, global_pattern_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
gradients_callback (GtkWidget *widget, gradients_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_gradient_factory->container); gimp_container_view_set_container (view, global_gradient_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
palettes_callback (GtkWidget *widget, palettes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_palette_factory->container); gimp_container_view_set_container (view, global_palette_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
images_callback (GtkWidget *widget, images_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, image_context); gimp_container_view_set_container (view, image_context);
} }
@ -1585,15 +1514,6 @@ container_multi_view_new (gboolean list,
5, 5); 5, 5);
} }
gimp_gtk_drag_dest_set_by_type (view,
GTK_DEST_DEFAULT_ALL,
container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
GIMP_CONTAINER_VIEW (view)->container->children_type,
drop_viewable_callback,
NULL);
dialog = gimp_dialog_new (title, "test", dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func, gimp_standard_help_func,
NULL, NULL,
@ -1772,7 +1692,7 @@ dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_LIST, data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List", "Gradient List",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }
@ -1820,7 +1740,7 @@ dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_GRID, data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid", "Gradient Grid",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }

View File

@ -37,7 +37,6 @@
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdata.h" #include "gimpdata.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimprc.h" #include "gimprc.h"
#include "session.h" #include "session.h"
#include "temp_buf.h" #include "temp_buf.h"
@ -58,9 +57,6 @@
static void brush_select_change_callbacks (BrushSelect *bsp, static void brush_select_change_callbacks (BrushSelect *bsp,
gboolean closing); gboolean closing);
static void brush_select_drop_brush (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void brush_select_brush_changed (GimpContext *context, static void brush_select_brush_changed (GimpContext *context,
GimpBrush *brush, GimpBrush *brush,
BrushSelect *bsp); BrushSelect *bsp);
@ -93,8 +89,9 @@ GSList *brush_active_dialogs = NULL;
/* the main brush selection dialog */ /* the main brush selection dialog */
BrushSelect *brush_select_dialog = NULL; BrushSelect *brush_select_dialog = NULL;
/* Brush editor dialog */
static BrushEditGeneratedWindow *brush_edit_generated_dialog; /* the main brush editor dialog */
static BrushEditGeneratedWindow *brush_edit_generated_dialog = NULL;
/* public functions */ /* public functions */
@ -246,15 +243,6 @@ brush_select_new (gchar *title,
TRUE, TRUE, 0); TRUE, TRUE, 0);
gtk_widget_show (bsp->view); gtk_widget_show (bsp->view);
gimp_gtk_drag_dest_set_by_type (bsp->view,
GTK_DEST_DEFAULT_ALL,
GIMP_TYPE_BRUSH,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (bsp->view),
GIMP_TYPE_BRUSH,
brush_select_drop_brush,
bsp);
gtk_widget_show (bsp->brush_selection_box); gtk_widget_show (bsp->brush_selection_box);
gtk_widget_show (bsp->left_box); gtk_widget_show (bsp->left_box);
@ -264,6 +252,7 @@ brush_select_new (gchar *title,
/* Create the active brush label */ /* Create the active brush label */
util_box = gtk_hbox_new (FALSE, 0); util_box = gtk_hbox_new (FALSE, 0);
gtk_container_set_resize_mode (GTK_CONTAINER (util_box), GTK_RESIZE_QUEUE);
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2); gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2);
bsp->brush_name = gtk_label_new (_("No Brushes available")); bsp->brush_name = gtk_label_new (_("No Brushes available"));
@ -535,18 +524,6 @@ brush_select_dialogs_check (void)
* Local functions * Local functions
*/ */
static void
brush_select_drop_brush (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
gimp_context_set_brush (bsp->context, GIMP_BRUSH (viewable));
}
static void static void
brush_select_brush_changed (GimpContext *context, brush_select_brush_changed (GimpContext *context,
GimpBrush *brush, GimpBrush *brush,
@ -556,6 +533,9 @@ brush_select_brush_changed (GimpContext *context,
{ {
brush_select_update_active_brush_field (bsp); brush_select_update_active_brush_field (bsp);
gtk_widget_set_sensitive (GIMP_DATA_FACTORY_VIEW (bsp->view)->edit_button,
GIMP_IS_BRUSH_GENERATED (brush));
if (bsp->callback_name) if (bsp->callback_name)
brush_select_change_callbacks (bsp, FALSE); brush_select_change_callbacks (bsp, FALSE);
} }

View File

@ -83,7 +83,6 @@
#include "gimpcontainergridview.h" #include "gimpcontainergridview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdatafactoryview.h" #include "gimpdatafactoryview.h"
#include "gimpdnd.h"
#include "gimppreview.h" #include "gimppreview.h"
@ -1335,108 +1334,38 @@ container_view_scale_callback (GtkAdjustment *adj,
gimp_container_view_set_preview_size (view, ROUND (adj->value)); gimp_container_view_set_preview_size (view, ROUND (adj->value));
} }
static void
drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (widget);
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}
static void static void
brushes_callback (GtkWidget *widget, brushes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_brush_factory->container); gimp_container_view_set_container (view, global_brush_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
patterns_callback (GtkWidget *widget, patterns_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_pattern_factory->container); gimp_container_view_set_container (view, global_pattern_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
gradients_callback (GtkWidget *widget, gradients_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_gradient_factory->container); gimp_container_view_set_container (view, global_gradient_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
palettes_callback (GtkWidget *widget, palettes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_palette_factory->container); gimp_container_view_set_container (view, global_palette_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
images_callback (GtkWidget *widget, images_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, image_context); gimp_container_view_set_container (view, image_context);
} }
@ -1585,15 +1514,6 @@ container_multi_view_new (gboolean list,
5, 5); 5, 5);
} }
gimp_gtk_drag_dest_set_by_type (view,
GTK_DEST_DEFAULT_ALL,
container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
GIMP_CONTAINER_VIEW (view)->container->children_type,
drop_viewable_callback,
NULL);
dialog = gimp_dialog_new (title, "test", dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func, gimp_standard_help_func,
NULL, NULL,
@ -1772,7 +1692,7 @@ dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_LIST, data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List", "Gradient List",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }
@ -1820,7 +1740,7 @@ dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_GRID, data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid", "Gradient Grid",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }

View File

@ -949,29 +949,23 @@ indexed_palette_select_destroy_callback (GtkWidget *widget,
} }
static gint static gint
indexed_palette_select_row_callback (GtkCList *clist, indexed_palette_select_palette (GimpContext *context,
gint row, GimpPalette *palette,
gint column, gpointer data)
GdkEventButton *event,
gpointer data)
{ {
IndexedDialog *dialog = (IndexedDialog *)data; IndexedDialog *dialog;
GimpPalette *palette;
palette = (GimpPalette *) gtk_clist_get_row_data (clist, row); dialog = (IndexedDialog *) data;
if (palette) if (palette)
{ {
if (palette->n_colors <= 256) if (palette->n_colors <= 256)
{ {
theCustomPalette = palette; theCustomPalette = palette;
gtk_label_set_text (GTK_LABEL (GTK_BIN (dialog->custom_palette_button)->child), gtk_label_set_text (GTK_LABEL (GTK_BIN (dialog->custom_palette_button)->child),
GIMP_OBJECT (theCustomPalette)->name); GIMP_OBJECT (theCustomPalette)->name);
} }
else
{
gtk_clist_unselect_row (clist, row, column);
}
} }
return FALSE; return FALSE;
@ -993,8 +987,9 @@ indexed_custom_palette_button_callback (GtkWidget *widget,
gtk_signal_connect (GTK_OBJECT (dialog->palette_select->shell), "destroy", gtk_signal_connect (GTK_OBJECT (dialog->palette_select->shell), "destroy",
GTK_SIGNAL_FUNC (indexed_palette_select_destroy_callback), GTK_SIGNAL_FUNC (indexed_palette_select_destroy_callback),
dialog); dialog);
gtk_signal_connect (GTK_OBJECT (dialog->palette_select->clist), "select_row", gtk_signal_connect (GTK_OBJECT (dialog->palette_select->context),
GTK_SIGNAL_FUNC (indexed_palette_select_row_callback), "palette_changed",
GTK_SIGNAL_FUNC (indexed_palette_select_palette),
dialog); dialog);
} }
else else

View File

@ -48,12 +48,13 @@
/* local function prototypes */ /* local function prototypes */
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass); static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush); static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static void gimp_brush_generated_destroy (GtkObject *object); static void gimp_brush_generated_destroy (GtkObject *object);
static gboolean gimp_brush_generated_save (GimpData *data); static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data); static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data); static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static GimpBrushClass *parent_class = NULL; static GimpBrushClass *parent_class = NULL;
@ -100,6 +101,7 @@ gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
data_class->save = gimp_brush_generated_save; data_class->save = gimp_brush_generated_save;
data_class->dirty = gimp_brush_generated_dirty; data_class->dirty = gimp_brush_generated_dirty;
data_class->get_extension = gimp_brush_generated_get_extension; data_class->get_extension = gimp_brush_generated_get_extension;
data_class->duplicate = gimp_brush_generated_duplicate;
} }
static void static void
@ -172,6 +174,19 @@ gimp_brush_generated_get_extension (GimpData *data)
return GIMP_BRUSH_GENERATED_FILE_EXTENSION; return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
} }
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
{
GimpBrushGenerated *brush;
brush = GIMP_BRUSH_GENERATED (data);
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
}
static double static double
gauss (gdouble f) gauss (gdouble f)
{ {

View File

@ -48,12 +48,13 @@
/* local function prototypes */ /* local function prototypes */
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass); static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush); static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static void gimp_brush_generated_destroy (GtkObject *object); static void gimp_brush_generated_destroy (GtkObject *object);
static gboolean gimp_brush_generated_save (GimpData *data); static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data); static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data); static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static GimpBrushClass *parent_class = NULL; static GimpBrushClass *parent_class = NULL;
@ -100,6 +101,7 @@ gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
data_class->save = gimp_brush_generated_save; data_class->save = gimp_brush_generated_save;
data_class->dirty = gimp_brush_generated_dirty; data_class->dirty = gimp_brush_generated_dirty;
data_class->get_extension = gimp_brush_generated_get_extension; data_class->get_extension = gimp_brush_generated_get_extension;
data_class->duplicate = gimp_brush_generated_duplicate;
} }
static void static void
@ -172,6 +174,19 @@ gimp_brush_generated_get_extension (GimpData *data)
return GIMP_BRUSH_GENERATED_FILE_EXTENSION; return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
} }
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
{
GimpBrushGenerated *brush;
brush = GIMP_BRUSH_GENERATED (data);
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
}
static double static double
gauss (gdouble f) gauss (gdouble f)
{ {

View File

@ -48,12 +48,13 @@
/* local function prototypes */ /* local function prototypes */
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass); static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush); static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static void gimp_brush_generated_destroy (GtkObject *object); static void gimp_brush_generated_destroy (GtkObject *object);
static gboolean gimp_brush_generated_save (GimpData *data); static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data); static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data); static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static GimpBrushClass *parent_class = NULL; static GimpBrushClass *parent_class = NULL;
@ -100,6 +101,7 @@ gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
data_class->save = gimp_brush_generated_save; data_class->save = gimp_brush_generated_save;
data_class->dirty = gimp_brush_generated_dirty; data_class->dirty = gimp_brush_generated_dirty;
data_class->get_extension = gimp_brush_generated_get_extension; data_class->get_extension = gimp_brush_generated_get_extension;
data_class->duplicate = gimp_brush_generated_duplicate;
} }
static void static void
@ -172,6 +174,19 @@ gimp_brush_generated_get_extension (GimpData *data)
return GIMP_BRUSH_GENERATED_FILE_EXTENSION; return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
} }
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
{
GimpBrushGenerated *brush;
brush = GIMP_BRUSH_GENERATED (data);
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
}
static double static double
gauss (gdouble f) gauss (gdouble f)
{ {

View File

@ -949,29 +949,23 @@ indexed_palette_select_destroy_callback (GtkWidget *widget,
} }
static gint static gint
indexed_palette_select_row_callback (GtkCList *clist, indexed_palette_select_palette (GimpContext *context,
gint row, GimpPalette *palette,
gint column, gpointer data)
GdkEventButton *event,
gpointer data)
{ {
IndexedDialog *dialog = (IndexedDialog *)data; IndexedDialog *dialog;
GimpPalette *palette;
palette = (GimpPalette *) gtk_clist_get_row_data (clist, row); dialog = (IndexedDialog *) data;
if (palette) if (palette)
{ {
if (palette->n_colors <= 256) if (palette->n_colors <= 256)
{ {
theCustomPalette = palette; theCustomPalette = palette;
gtk_label_set_text (GTK_LABEL (GTK_BIN (dialog->custom_palette_button)->child), gtk_label_set_text (GTK_LABEL (GTK_BIN (dialog->custom_palette_button)->child),
GIMP_OBJECT (theCustomPalette)->name); GIMP_OBJECT (theCustomPalette)->name);
} }
else
{
gtk_clist_unselect_row (clist, row, column);
}
} }
return FALSE; return FALSE;
@ -993,8 +987,9 @@ indexed_custom_palette_button_callback (GtkWidget *widget,
gtk_signal_connect (GTK_OBJECT (dialog->palette_select->shell), "destroy", gtk_signal_connect (GTK_OBJECT (dialog->palette_select->shell), "destroy",
GTK_SIGNAL_FUNC (indexed_palette_select_destroy_callback), GTK_SIGNAL_FUNC (indexed_palette_select_destroy_callback),
dialog); dialog);
gtk_signal_connect (GTK_OBJECT (dialog->palette_select->clist), "select_row", gtk_signal_connect (GTK_OBJECT (dialog->palette_select->context),
GTK_SIGNAL_FUNC (indexed_palette_select_row_callback), "palette_changed",
GTK_SIGNAL_FUNC (indexed_palette_select_palette),
dialog); dialog);
} }
else else

View File

@ -115,8 +115,6 @@ gimp_palette_init (GimpPalette *palette)
palette->n_colors = 0; palette->n_colors = 0;
palette->n_columns = 0; palette->n_columns = 0;
palette->pixmap = NULL;
} }
static void static void
@ -139,9 +137,6 @@ gimp_palette_destroy (GtkObject *object)
g_list_free (palette->colors); g_list_free (palette->colors);
if (palette->pixmap)
gdk_pixmap_unref (palette->pixmap);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object); GTK_OBJECT_CLASS (parent_class)->destroy (object);
} }
@ -555,70 +550,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
} }
} }
void
gimp_palette_update_preview (GimpPalette *palette,
GdkGC *gc)
{
GimpPaletteEntry *entry;
guchar rgb_buf[SM_PREVIEW_WIDTH * SM_PREVIEW_HEIGHT * 3];
GList *list;
gint index;
g_return_if_fail (palette != NULL);
g_return_if_fail (GIMP_IS_PALETTE (palette));
g_return_if_fail (gc != NULL);
memset (rgb_buf, 0x0, sizeof (rgb_buf));
gdk_draw_rgb_image (palette->pixmap,
gc,
0,
0,
SM_PREVIEW_WIDTH,
SM_PREVIEW_HEIGHT,
GDK_RGB_DITHER_NORMAL,
rgb_buf,
SM_PREVIEW_WIDTH * 3);
index = 0;
for (list = palette->colors; list; list = g_list_next (list))
{
guchar cell[3 * 3 * 3];
gint loop;
entry = (GimpPaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (palette->pixmap,
gc,
1 + (index % ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
1 + (index / ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
3,
3,
GDK_RGB_DITHER_NORMAL,
cell,
3);
index++;
if (index >= (((SM_PREVIEW_WIDTH - 2) * (SM_PREVIEW_HEIGHT - 2)) / 9))
break;
}
}
static void static void
gimp_palette_entry_free (GimpPaletteEntry *entry) gimp_palette_entry_free (GimpPaletteEntry *entry)
{ {

View File

@ -115,8 +115,6 @@ gimp_palette_init (GimpPalette *palette)
palette->n_colors = 0; palette->n_colors = 0;
palette->n_columns = 0; palette->n_columns = 0;
palette->pixmap = NULL;
} }
static void static void
@ -139,9 +137,6 @@ gimp_palette_destroy (GtkObject *object)
g_list_free (palette->colors); g_list_free (palette->colors);
if (palette->pixmap)
gdk_pixmap_unref (palette->pixmap);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object); GTK_OBJECT_CLASS (parent_class)->destroy (object);
} }
@ -555,70 +550,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
} }
} }
void
gimp_palette_update_preview (GimpPalette *palette,
GdkGC *gc)
{
GimpPaletteEntry *entry;
guchar rgb_buf[SM_PREVIEW_WIDTH * SM_PREVIEW_HEIGHT * 3];
GList *list;
gint index;
g_return_if_fail (palette != NULL);
g_return_if_fail (GIMP_IS_PALETTE (palette));
g_return_if_fail (gc != NULL);
memset (rgb_buf, 0x0, sizeof (rgb_buf));
gdk_draw_rgb_image (palette->pixmap,
gc,
0,
0,
SM_PREVIEW_WIDTH,
SM_PREVIEW_HEIGHT,
GDK_RGB_DITHER_NORMAL,
rgb_buf,
SM_PREVIEW_WIDTH * 3);
index = 0;
for (list = palette->colors; list; list = g_list_next (list))
{
guchar cell[3 * 3 * 3];
gint loop;
entry = (GimpPaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (palette->pixmap,
gc,
1 + (index % ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
1 + (index / ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
3,
3,
GDK_RGB_DITHER_NORMAL,
cell,
3);
index++;
if (index >= (((SM_PREVIEW_WIDTH - 2) * (SM_PREVIEW_HEIGHT - 2)) / 9))
break;
}
}
static void static void
gimp_palette_entry_free (GimpPaletteEntry *entry) gimp_palette_entry_free (GimpPaletteEntry *entry)
{ {

View File

@ -115,8 +115,6 @@ gimp_palette_init (GimpPalette *palette)
palette->n_colors = 0; palette->n_colors = 0;
palette->n_columns = 0; palette->n_columns = 0;
palette->pixmap = NULL;
} }
static void static void
@ -139,9 +137,6 @@ gimp_palette_destroy (GtkObject *object)
g_list_free (palette->colors); g_list_free (palette->colors);
if (palette->pixmap)
gdk_pixmap_unref (palette->pixmap);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object); GTK_OBJECT_CLASS (parent_class)->destroy (object);
} }
@ -555,70 +550,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
} }
} }
void
gimp_palette_update_preview (GimpPalette *palette,
GdkGC *gc)
{
GimpPaletteEntry *entry;
guchar rgb_buf[SM_PREVIEW_WIDTH * SM_PREVIEW_HEIGHT * 3];
GList *list;
gint index;
g_return_if_fail (palette != NULL);
g_return_if_fail (GIMP_IS_PALETTE (palette));
g_return_if_fail (gc != NULL);
memset (rgb_buf, 0x0, sizeof (rgb_buf));
gdk_draw_rgb_image (palette->pixmap,
gc,
0,
0,
SM_PREVIEW_WIDTH,
SM_PREVIEW_HEIGHT,
GDK_RGB_DITHER_NORMAL,
rgb_buf,
SM_PREVIEW_WIDTH * 3);
index = 0;
for (list = palette->colors; list; list = g_list_next (list))
{
guchar cell[3 * 3 * 3];
gint loop;
entry = (GimpPaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (palette->pixmap,
gc,
1 + (index % ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
1 + (index / ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
3,
3,
GDK_RGB_DITHER_NORMAL,
cell,
3);
index++;
if (index >= (((SM_PREVIEW_WIDTH - 2) * (SM_PREVIEW_HEIGHT - 2)) / 9))
break;
}
}
static void static void
gimp_palette_entry_free (GimpPaletteEntry *entry) gimp_palette_entry_free (GimpPaletteEntry *entry)
{ {

View File

@ -55,9 +55,6 @@ struct _GimpPalette
gint n_colors; gint n_colors;
gint n_columns; gint n_columns;
/* EEK */
GdkPixmap *pixmap;
}; };
struct _GimpPaletteClass struct _GimpPaletteClass

View File

@ -573,8 +573,6 @@ palette_import_create_from_grad (gchar *name)
gimp_container_add (global_palette_factory->container, gimp_container_add (global_palette_factory->container,
GIMP_OBJECT (palette)); GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
} }
@ -758,8 +756,6 @@ palette_import_image_make_palette (GHashTable *h_array,
g_slist_free (sorted_list); g_slist_free (sorted_list);
gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette)); gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
static void static void
@ -874,8 +870,6 @@ palette_import_create_from_indexed (GImage *gimage,
} }
gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette)); gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
/* the palette import action area callbacks ********************************/ /* the palette import action area callbacks ********************************/

View File

@ -48,12 +48,13 @@
/* local function prototypes */ /* local function prototypes */
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass); static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush); static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static void gimp_brush_generated_destroy (GtkObject *object); static void gimp_brush_generated_destroy (GtkObject *object);
static gboolean gimp_brush_generated_save (GimpData *data); static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data); static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data); static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static GimpBrushClass *parent_class = NULL; static GimpBrushClass *parent_class = NULL;
@ -100,6 +101,7 @@ gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
data_class->save = gimp_brush_generated_save; data_class->save = gimp_brush_generated_save;
data_class->dirty = gimp_brush_generated_dirty; data_class->dirty = gimp_brush_generated_dirty;
data_class->get_extension = gimp_brush_generated_get_extension; data_class->get_extension = gimp_brush_generated_get_extension;
data_class->duplicate = gimp_brush_generated_duplicate;
} }
static void static void
@ -172,6 +174,19 @@ gimp_brush_generated_get_extension (GimpData *data)
return GIMP_BRUSH_GENERATED_FILE_EXTENSION; return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
} }
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
{
GimpBrushGenerated *brush;
brush = GIMP_BRUSH_GENERATED (data);
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
}
static double static double
gauss (gdouble f) gauss (gdouble f)
{ {

View File

@ -41,8 +41,8 @@ static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview)
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview); static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview); static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview);
static GimpBrush * gimp_brush_preview_drag_brush (GtkWidget *widget, static GimpViewable * gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -94,20 +94,14 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
static void static void
gimp_brush_preview_init (GimpBrushPreview *brush_preview) gimp_brush_preview_init (GimpBrushPreview *brush_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (brush_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_BRUSH GIMP_TYPE_BRUSH,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (brush_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_BRUSH,
gimp_brush_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (brush_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_source_set (GTK_WIDGET (brush_preview),
gimp_brush_preview_drag_brush,
brush_preview);
brush_preview->pipe_timeout_id = 0; brush_preview->pipe_timeout_id = 0;
brush_preview->pipe_animation_index = 0; brush_preview->pipe_animation_index = 0;
@ -379,13 +373,9 @@ gimp_brush_preview_render_timeout_func (GimpBrushPreview *brush_preview)
return TRUE; return TRUE;
} }
static GimpBrush * static GimpViewable *
gimp_brush_preview_drag_brush (GtkWidget *widget, gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_BRUSH (preview->viewable);
} }

View File

@ -54,6 +54,8 @@ 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_set_preview_size (GimpContainerView *view);
static void gimp_container_grid_view_item_selected (GtkWidget *widget, static void gimp_container_grid_view_item_selected (GtkWidget *widget,
gpointer data); gpointer data);
static void gimp_container_grid_view_item_activate (GtkWidget *widget,
gpointer data);
static void gimp_container_grid_view_highlight_item (GimpContainerView *view, static void gimp_container_grid_view_highlight_item (GimpContainerView *view,
GimpViewable *viewable, GimpViewable *viewable,
gpointer insert_data); gpointer insert_data);
@ -237,6 +239,10 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected), GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected),
view); view);
gtk_signal_connect (GTK_OBJECT (preview), "double_clicked",
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activate),
view);
return (gpointer) preview; return (gpointer) preview;
} }
@ -338,6 +344,14 @@ gimp_container_grid_view_item_selected (GtkWidget *widget,
GIMP_PREVIEW (widget)->viewable); GIMP_PREVIEW (widget)->viewable);
} }
static void
gimp_container_grid_view_item_activate (GtkWidget *widget,
gpointer data)
{
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
}
static void static void
gimp_container_grid_view_highlight_item (GimpContainerView *view, gimp_container_grid_view_highlight_item (GimpContainerView *view,
GimpViewable *viewable, GimpViewable *viewable,

View File

@ -28,6 +28,7 @@
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpcontainerlistview.h" #include "gimpcontainerlistview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimplist.h" #include "gimplist.h"
#include "gimppreview.h" #include "gimppreview.h"
@ -57,6 +58,11 @@ static void gimp_container_list_view_name_changed (GimpViewable *v
static void gimp_container_list_view_item_selected (GtkWidget *widget, static void gimp_container_list_view_item_selected (GtkWidget *widget,
GtkWidget *child, GtkWidget *child,
gpointer data); gpointer data);
static gint gimp_container_list_view_item_activate (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static GimpViewable * gimp_container_list_view_drag_viewable (GtkWidget *widget,
gpointer data);
static GimpContainerViewClass *parent_class = NULL; static GimpContainerViewClass *parent_class = NULL;
@ -236,6 +242,19 @@ gimp_container_list_view_insert_item (GimpContainerView *view,
label, label,
GTK_OBJECT (list_view)); GTK_OBJECT (list_view));
gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event",
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activate),
list_view);
gimp_gtk_drag_source_set_by_type (list_item,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (list_item),
view->container->children_type,
gimp_container_list_view_drag_viewable,
list_view);
gtk_widget_show (list_item); gtk_widget_show (list_item);
list = g_list_prepend (NULL, list_item); list = g_list_prepend (NULL, list_item);
@ -417,6 +436,35 @@ gimp_container_list_view_item_selected (GtkWidget *widget,
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child), viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child),
"preview"))->viewable; "preview"))->viewable;
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), viewable);
viewable); }
static gint
gimp_container_list_view_item_activate (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
if (bevent->type == GDK_2BUTTON_PRESS)
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data), viewable);
}
return FALSE;
}
static GimpViewable *
gimp_container_list_view_drag_viewable (GtkWidget *widget,
gpointer data)
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
return viewable;
} }

View File

@ -25,6 +25,7 @@
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpcontainerview.h" #include "gimpcontainerview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "gimpviewable.h" #include "gimpviewable.h"
@ -35,6 +36,7 @@ enum
REMOVE_ITEM, REMOVE_ITEM,
REORDER_ITEM, REORDER_ITEM,
SELECT_ITEM, SELECT_ITEM,
ACTIVATE_ITEM,
CLEAR_ITEMS, CLEAR_ITEMS,
SET_PREVIEW_SIZE, SET_PREVIEW_SIZE,
LAST_SIGNAL LAST_SIGNAL
@ -64,6 +66,9 @@ static void gimp_container_view_reorder (GimpContainerView *view,
static void gimp_container_view_context_changed (GimpContext *context, static void gimp_container_view_context_changed (GimpContext *context,
GimpViewable *viewable, GimpViewable *viewable,
GimpContainerView *view); GimpContainerView *view);
static void gimp_container_view_drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static guint view_signals[LAST_SIGNAL] = { 0 }; static guint view_signals[LAST_SIGNAL] = { 0 };
@ -150,6 +155,17 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
GIMP_TYPE_OBJECT, GIMP_TYPE_OBJECT,
GTK_TYPE_POINTER); GTK_TYPE_POINTER);
view_signals[ACTIVATE_ITEM] =
gtk_signal_new ("activate_item",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
activate_item),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2,
GIMP_TYPE_OBJECT,
GTK_TYPE_POINTER);
view_signals[CLEAR_ITEMS] = view_signals[CLEAR_ITEMS] =
gtk_signal_new ("clear_items", gtk_signal_new ("clear_items",
GTK_RUN_FIRST, GTK_RUN_FIRST,
@ -176,6 +192,7 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
klass->remove_item = NULL; klass->remove_item = NULL;
klass->reorder_item = NULL; klass->reorder_item = NULL;
klass->select_item = NULL; klass->select_item = NULL;
klass->activate_item = NULL;
klass->clear_items = gimp_container_view_real_clear_items; klass->clear_items = gimp_container_view_real_clear_items;
klass->set_preview_size = NULL; klass->set_preview_size = NULL;
} }
@ -244,6 +261,10 @@ gimp_container_view_set_container (GimpContainerView *view,
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context), gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
gimp_container_view_context_changed, gimp_container_view_context_changed,
view); view);
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
} }
} }
@ -285,6 +306,15 @@ gimp_container_view_set_container (GimpContainerView *view,
gimp_container_view_select_item (view, gimp_container_view_select_item (view,
object ? GIMP_VIEWABLE (object): NULL); object ? GIMP_VIEWABLE (object): NULL);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
gimp_container_view_drop_viewable_callback,
NULL);
} }
} }
} }
@ -305,6 +335,10 @@ gimp_container_view_set_context (GimpContainerView *view,
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context), gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
gimp_container_view_context_changed, gimp_container_view_context_changed,
view); view);
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
} }
view->context = context; view->context = context;
@ -326,6 +360,15 @@ gimp_container_view_set_context (GimpContainerView *view,
gimp_container_view_select_item (view, gimp_container_view_select_item (view,
object ? GIMP_VIEWABLE (object) : NULL); object ? GIMP_VIEWABLE (object) : NULL);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
gimp_container_view_drop_viewable_callback,
NULL);
} }
} }
@ -358,6 +401,23 @@ gimp_container_view_select_item (GimpContainerView *view,
viewable, insert_data); viewable, insert_data);
} }
void
gimp_container_view_activate_item (GimpContainerView *view,
GimpViewable *viewable)
{
gpointer insert_data;
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
insert_data = g_hash_table_lookup (view->hash_table, viewable);
gtk_signal_emit (GTK_OBJECT (view), view_signals[ACTIVATE_ITEM],
viewable, insert_data);
}
void void
gimp_container_view_item_selected (GimpContainerView *view, gimp_container_view_item_selected (GimpContainerView *view,
GimpViewable *viewable) GimpViewable *viewable)
@ -375,6 +435,18 @@ gimp_container_view_item_selected (GimpContainerView *view,
GIMP_OBJECT (viewable)); GIMP_OBJECT (viewable));
} }
void
gimp_container_view_item_activate (GimpContainerView *view,
GimpViewable *viewable)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
gimp_container_view_activate_item (view, viewable);
}
static void static void
gimp_container_view_clear_items (GimpContainerView *view) gimp_container_view_clear_items (GimpContainerView *view)
{ {
@ -465,3 +537,17 @@ gimp_container_view_context_changed (GimpContext *context,
gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM], gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM],
viewable, insert_data); viewable, insert_data);
} }
static void
gimp_container_view_drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (widget);
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}

View File

@ -61,6 +61,9 @@ struct _GimpContainerViewClass
void (* select_item) (GimpContainerView *view, void (* select_item) (GimpContainerView *view,
GimpViewable *object, GimpViewable *object,
gpointer insert_data); gpointer insert_data);
void (* activate_item) (GimpContainerView *view,
GimpViewable *object,
gpointer insert_data);
void (* clear_items) (GimpContainerView *view); void (* clear_items) (GimpContainerView *view);
void (* set_preview_size) (GimpContainerView *view); void (* set_preview_size) (GimpContainerView *view);
}; };
@ -76,12 +79,16 @@ void gimp_container_view_set_preview_size (GimpContainerView *view,
gint preview_size); gint preview_size);
void gimp_container_view_select_item (GimpContainerView *view, void gimp_container_view_select_item (GimpContainerView *view,
GimpViewable *viewable); GimpViewable *viewable);
void gimp_container_view_activate_item (GimpContainerView *view,
GimpViewable *viewable);
/* private */ /* private */
void gimp_container_view_item_selected (GimpContainerView *view, void gimp_container_view_item_selected (GimpContainerView *view,
GimpViewable *item); GimpViewable *item);
void gimp_container_view_item_activate (GimpContainerView *view,
GimpViewable *item);
#endif /* __GIMP_CONTAINER_VIEW_H__ */ #endif /* __GIMP_CONTAINER_VIEW_H__ */

View File

@ -32,6 +32,7 @@
#include "gimpcontainergridview.h" #include "gimpcontainergridview.h"
#include "gimpcontainerlistview.h" #include "gimpcontainerlistview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "gimpviewable.h" #include "gimpviewable.h"
@ -52,16 +53,29 @@ static void gimp_data_factory_view_new_clicked (GtkWidget *wid
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_duplicate_clicked (GtkWidget *widget, static void gimp_data_factory_view_duplicate_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_data_factory_view_edit_clicked (GtkWidget *widget, static void gimp_data_factory_view_edit_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_data_factory_view_delete_clicked (GtkWidget *widget, static void gimp_data_factory_view_delete_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_data_factory_view_refresh_clicked (GtkWidget *widget, static void gimp_data_factory_view_refresh_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_data_changed (GimpContext *context, static void gimp_data_factory_view_data_changed (GimpContext *context,
GimpData *data, GimpData *data,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_data_activate (GtkWidget *context,
GimpData *data,
gpointer insert_data,
GimpDataFactoryView *view);
static GtkVBoxClass *parent_class = NULL; static GtkVBoxClass *parent_class = NULL;
@ -277,6 +291,42 @@ gimp_data_factory_view_new (GimpViewType view_type,
factory_view, factory_view,
GTK_OBJECT (factory_view)); GTK_OBJECT (factory_view));
gtk_signal_connect_while_alive
(GTK_OBJECT (factory_view->view), "activate_item",
GTK_SIGNAL_FUNC (gimp_data_factory_view_data_activate),
factory_view,
GTK_OBJECT (factory_view));
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
factory_view->factory->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->duplicate_button),
factory_view->factory->container->children_type,
gimp_data_factory_view_duplicate_dropped,
factory_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->edit_button),
GTK_DEST_DEFAULT_ALL,
factory_view->factory->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->edit_button),
factory_view->factory->container->children_type,
gimp_data_factory_view_edit_dropped,
factory_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->delete_button),
GTK_DEST_DEFAULT_ALL,
factory_view->factory->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->delete_button),
factory_view->factory->container->children_type,
gimp_data_factory_view_delete_dropped,
factory_view);
/* set button sensitivity */ /* set button sensitivity */
gimp_data_factory_view_data_changed gimp_data_factory_view_data_changed
(context, (context,
@ -346,6 +396,26 @@ gimp_data_factory_view_duplicate_clicked (GtkWidget *widget,
} }
} }
static void
gimp_data_factory_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) data;
if (viewable && gimp_container_have (view->factory->container,
GIMP_OBJECT (viewable)))
{
gimp_context_set_by_type (view->view->context,
view->factory->container->children_type,
GIMP_OBJECT (viewable));
gimp_data_factory_view_duplicate_clicked (NULL, data);
}
}
static void static void
gimp_data_factory_view_edit_clicked (GtkWidget *widget, gimp_data_factory_view_edit_clicked (GtkWidget *widget,
GimpDataFactoryView *view) GimpDataFactoryView *view)
@ -365,6 +435,26 @@ gimp_data_factory_view_edit_clicked (GtkWidget *widget,
} }
} }
static void
gimp_data_factory_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) data;
if (viewable && gimp_container_have (view->factory->container,
GIMP_OBJECT (viewable)))
{
gimp_context_set_by_type (view->view->context,
view->factory->container->children_type,
GIMP_OBJECT (viewable));
gimp_data_factory_view_edit_clicked (NULL, data);
}
}
typedef struct _GimpDataDeleteData GimpDataDeleteData; typedef struct _GimpDataDeleteData GimpDataDeleteData;
@ -444,6 +534,26 @@ gimp_data_factory_view_delete_clicked (GtkWidget *widget,
} }
} }
static void
gimp_data_factory_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) data;
if (viewable && gimp_container_have (view->factory->container,
GIMP_OBJECT (viewable)))
{
gimp_context_set_by_type (view->view->context,
view->factory->container->children_type,
GIMP_OBJECT (viewable));
gimp_data_factory_view_delete_clicked (NULL, data);
}
}
static void static void
gimp_data_factory_view_refresh_clicked (GtkWidget *widget, gimp_data_factory_view_refresh_clicked (GtkWidget *widget,
GimpDataFactoryView *view) GimpDataFactoryView *view)
@ -466,11 +576,24 @@ gimp_data_factory_view_data_changed (GimpContext *context,
duplicate_sensitive = duplicate_sensitive =
(GIMP_DATA_CLASS (GTK_OBJECT (data)->klass)->duplicate != NULL); (GIMP_DATA_CLASS (GTK_OBJECT (data)->klass)->duplicate != NULL);
edit_sensitive = (view->data_edit_func != NULL); edit_sensitive = (view->data_edit_func != NULL);
delete_sensitive = TRUE; /* TODO: check permissions */ delete_sensitive = TRUE; /* TODO: check permissions */
} }
gtk_widget_set_sensitive (view->duplicate_button, duplicate_sensitive); gtk_widget_set_sensitive (view->duplicate_button, duplicate_sensitive);
gtk_widget_set_sensitive (view->edit_button, edit_sensitive); gtk_widget_set_sensitive (view->edit_button, edit_sensitive);
gtk_widget_set_sensitive (view->delete_button, delete_sensitive); gtk_widget_set_sensitive (view->delete_button, delete_sensitive);
} }
static void
gimp_data_factory_view_data_activate (GtkWidget *widget,
GimpData *data,
gpointer insert_data,
GimpDataFactoryView *view)
{
if (data && gimp_container_have (view->factory->container,
GIMP_OBJECT (data)))
{
gimp_data_factory_view_edit_clicked (NULL, view);
}
}

View File

@ -624,6 +624,79 @@ gimp_dnd_color_dest_unset (GtkWidget *widget)
/* GimpViewable (by GtkType) dnd functions */ /* GimpViewable (by GtkType) dnd functions */
/*********************************************/ /*********************************************/
static const GtkTargetEntry brush_target_table[] =
{
GIMP_TARGET_BRUSH
};
static const guint brush_n_targets = (sizeof (brush_target_table) /
sizeof (brush_target_table[0]));
static const GtkTargetEntry pattern_target_table[] =
{
GIMP_TARGET_PATTERN
};
static const guint pattern_n_targets = (sizeof (pattern_target_table) /
sizeof (pattern_target_table[0]));
static const GtkTargetEntry gradient_target_table[] =
{
GIMP_TARGET_GRADIENT
};
static const guint gradient_n_targets = (sizeof (gradient_target_table) /
sizeof (gradient_target_table[0]));
static const GtkTargetEntry palette_target_table[] =
{
GIMP_TARGET_PALETTE
};
static const guint palette_n_targets = (sizeof (palette_target_table) /
sizeof (palette_target_table[0]));
void
gimp_gtk_drag_source_set_by_type (GtkWidget *widget,
GdkModifierType start_button_mask,
GtkType type,
GdkDragAction actions)
{
const GtkTargetEntry *target_table = NULL;
guint n_targets = 0;
if (type == GIMP_TYPE_BRUSH)
{
target_table = brush_target_table;
n_targets = brush_n_targets;
}
else if (type == GIMP_TYPE_PATTERN)
{
target_table = pattern_target_table;
n_targets = pattern_n_targets;
}
else if (type == GIMP_TYPE_GRADIENT)
{
target_table = gradient_target_table;
n_targets = gradient_n_targets;
}
else if (type == GIMP_TYPE_PALETTE)
{
target_table = palette_target_table;
n_targets = palette_n_targets;
}
else
{
g_warning ("%s(): unsupported GtkType", G_GNUC_FUNCTION);
}
if (target_table && n_targets)
{
gtk_drag_source_set (widget, start_button_mask,
target_table,
n_targets,
actions);
}
}
void void
gimp_gtk_drag_dest_set_by_type (GtkWidget *widget, gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
GtkDestDefaults flags, GtkDestDefaults flags,
@ -633,34 +706,6 @@ gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
const GtkTargetEntry *target_table = NULL; const GtkTargetEntry *target_table = NULL;
guint n_targets = 0; guint n_targets = 0;
static const GtkTargetEntry brush_target_table[] =
{
GIMP_TARGET_BRUSH
};
static const guint brush_n_targets = (sizeof (brush_target_table) /
sizeof (brush_target_table[0]));
static const GtkTargetEntry pattern_target_table[] =
{
GIMP_TARGET_PATTERN
};
static const guint pattern_n_targets = (sizeof (pattern_target_table) /
sizeof (pattern_target_table[0]));
static const GtkTargetEntry gradient_target_table[] =
{
GIMP_TARGET_GRADIENT
};
static const guint gradient_n_targets = (sizeof (gradient_target_table) /
sizeof (gradient_target_table[0]));
static const GtkTargetEntry palette_target_table[] =
{
GIMP_TARGET_PALETTE
};
static const guint palette_n_targets = (sizeof (palette_target_table) /
sizeof (palette_target_table[0]));
if (type == GIMP_TYPE_BRUSH) if (type == GIMP_TYPE_BRUSH)
{ {
target_table = brush_target_table; target_table = brush_target_table;
@ -695,6 +740,42 @@ gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
} }
} }
void
gimp_dnd_viewable_source_set (GtkWidget *widget,
GtkType type,
GimpDndDragViewableFunc get_viewable_func,
gpointer data)
{
if (type == GIMP_TYPE_BRUSH)
{
gimp_dnd_brush_source_set (widget,
(GimpDndDragBrushFunc) get_viewable_func,
data);
}
else if (type == GIMP_TYPE_PATTERN)
{
gimp_dnd_pattern_source_set (widget,
(GimpDndDragPatternFunc) get_viewable_func,
data);
}
else if (type == GIMP_TYPE_GRADIENT)
{
gimp_dnd_gradient_source_set (widget,
(GimpDndDragGradientFunc) get_viewable_func,
data);
}
else if (type == GIMP_TYPE_PALETTE)
{
gimp_dnd_palette_source_set (widget,
(GimpDndDragPaletteFunc) get_viewable_func,
data);
}
else
{
g_warning ("%s(): unsupported GtkType", G_GNUC_FUNCTION);
}
}
void void
gimp_dnd_viewable_dest_set (GtkWidget *widget, gimp_dnd_viewable_dest_set (GtkWidget *widget,
GtkType type, GtkType type,

View File

@ -113,20 +113,31 @@ void gimp_dnd_color_dest_unset (GtkWidget *widget);
/* GimpViewable (by GtkType) dnd functions */ /* GimpViewable (by GtkType) dnd functions */
typedef void (* GimpDndDropViewableFunc) (GtkWidget *widget, typedef void (* GimpDndDropViewableFunc) (GtkWidget *widget,
GimpViewable *viewable, GimpViewable *viewable,
gpointer data); gpointer data);
typedef GimpViewable * (* GimpDndDragViewableFunc) (GtkWidget *widget,
gpointer data);
void gimp_gtk_drag_dest_set_by_type (GtkWidget *widget, void gimp_gtk_drag_source_set_by_type (GtkWidget *widget,
GtkDestDefaults flags, GdkModifierType start_button_mask,
GtkType type, GtkType type,
GdkDragAction actions); GdkDragAction actions);
void gimp_dnd_viewable_dest_set (GtkWidget *widget, void gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
GtkType type, GtkDestDefaults flags,
GimpDndDropViewableFunc set_viewable_func, GtkType type,
gpointer data); GdkDragAction actions);
void gimp_dnd_viewable_dest_unset (GtkWidget *widget,
GtkType type); void gimp_dnd_viewable_source_set (GtkWidget *widget,
GtkType type,
GimpDndDragViewableFunc get_viewable_func,
gpointer data);
void gimp_dnd_viewable_dest_set (GtkWidget *widget,
GtkType type,
GimpDndDropViewableFunc set_viewable_func,
gpointer data);
void gimp_dnd_viewable_dest_unset (GtkWidget *widget,
GtkType type);
/* brush dnd functions */ /* brush dnd functions */

View File

@ -42,7 +42,7 @@ static void gimp_gradient_preview_get_size (GimpPreview *preview,
static gboolean gimp_gradient_preview_needs_popup (GimpPreview *preview); static gboolean gimp_gradient_preview_needs_popup (GimpPreview *preview);
static GtkWidget * gimp_gradient_preview_create_popup (GimpPreview *preview); static GtkWidget * gimp_gradient_preview_create_popup (GimpPreview *preview);
static GimpGradient * gimp_gradient_preview_drag_gradient (GtkWidget *widget, static GimpViewable * gimp_gradient_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
@ -94,20 +94,14 @@ gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass)
static void static void
gimp_gradient_preview_init (GimpGradientPreview *gradient_preview) gimp_gradient_preview_init (GimpGradientPreview *gradient_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (gradient_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_GRADIENT GIMP_TYPE_GRADIENT,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (gradient_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_GRADIENT,
gimp_gradient_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (gradient_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_gradient_source_set (GTK_WIDGET (gradient_preview),
gimp_gradient_preview_drag_gradient,
gradient_preview);
} }
static void static void
@ -181,13 +175,9 @@ gimp_gradient_preview_create_popup (GimpPreview *preview)
TRUE, FALSE, FALSE); TRUE, FALSE, FALSE);
} }
static GimpGradient * static GimpViewable *
gimp_gradient_preview_drag_gradient (GtkWidget *widget, gimp_gradient_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_GRADIENT (preview->viewable);
} }

View File

@ -949,29 +949,23 @@ indexed_palette_select_destroy_callback (GtkWidget *widget,
} }
static gint static gint
indexed_palette_select_row_callback (GtkCList *clist, indexed_palette_select_palette (GimpContext *context,
gint row, GimpPalette *palette,
gint column, gpointer data)
GdkEventButton *event,
gpointer data)
{ {
IndexedDialog *dialog = (IndexedDialog *)data; IndexedDialog *dialog;
GimpPalette *palette;
palette = (GimpPalette *) gtk_clist_get_row_data (clist, row); dialog = (IndexedDialog *) data;
if (palette) if (palette)
{ {
if (palette->n_colors <= 256) if (palette->n_colors <= 256)
{ {
theCustomPalette = palette; theCustomPalette = palette;
gtk_label_set_text (GTK_LABEL (GTK_BIN (dialog->custom_palette_button)->child), gtk_label_set_text (GTK_LABEL (GTK_BIN (dialog->custom_palette_button)->child),
GIMP_OBJECT (theCustomPalette)->name); GIMP_OBJECT (theCustomPalette)->name);
} }
else
{
gtk_clist_unselect_row (clist, row, column);
}
} }
return FALSE; return FALSE;
@ -993,8 +987,9 @@ indexed_custom_palette_button_callback (GtkWidget *widget,
gtk_signal_connect (GTK_OBJECT (dialog->palette_select->shell), "destroy", gtk_signal_connect (GTK_OBJECT (dialog->palette_select->shell), "destroy",
GTK_SIGNAL_FUNC (indexed_palette_select_destroy_callback), GTK_SIGNAL_FUNC (indexed_palette_select_destroy_callback),
dialog); dialog);
gtk_signal_connect (GTK_OBJECT (dialog->palette_select->clist), "select_row", gtk_signal_connect (GTK_OBJECT (dialog->palette_select->context),
GTK_SIGNAL_FUNC (indexed_palette_select_row_callback), "palette_changed",
GTK_SIGNAL_FUNC (indexed_palette_select_palette),
dialog); dialog);
} }
else else

View File

@ -115,8 +115,6 @@ gimp_palette_init (GimpPalette *palette)
palette->n_colors = 0; palette->n_colors = 0;
palette->n_columns = 0; palette->n_columns = 0;
palette->pixmap = NULL;
} }
static void static void
@ -139,9 +137,6 @@ gimp_palette_destroy (GtkObject *object)
g_list_free (palette->colors); g_list_free (palette->colors);
if (palette->pixmap)
gdk_pixmap_unref (palette->pixmap);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object); GTK_OBJECT_CLASS (parent_class)->destroy (object);
} }
@ -555,70 +550,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
} }
} }
void
gimp_palette_update_preview (GimpPalette *palette,
GdkGC *gc)
{
GimpPaletteEntry *entry;
guchar rgb_buf[SM_PREVIEW_WIDTH * SM_PREVIEW_HEIGHT * 3];
GList *list;
gint index;
g_return_if_fail (palette != NULL);
g_return_if_fail (GIMP_IS_PALETTE (palette));
g_return_if_fail (gc != NULL);
memset (rgb_buf, 0x0, sizeof (rgb_buf));
gdk_draw_rgb_image (palette->pixmap,
gc,
0,
0,
SM_PREVIEW_WIDTH,
SM_PREVIEW_HEIGHT,
GDK_RGB_DITHER_NORMAL,
rgb_buf,
SM_PREVIEW_WIDTH * 3);
index = 0;
for (list = palette->colors; list; list = g_list_next (list))
{
guchar cell[3 * 3 * 3];
gint loop;
entry = (GimpPaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (palette->pixmap,
gc,
1 + (index % ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
1 + (index / ((SM_PREVIEW_WIDTH-2) / 3)) * 3,
3,
3,
GDK_RGB_DITHER_NORMAL,
cell,
3);
index++;
if (index >= (((SM_PREVIEW_WIDTH - 2) * (SM_PREVIEW_HEIGHT - 2)) / 9))
break;
}
}
static void static void
gimp_palette_entry_free (GimpPaletteEntry *entry) gimp_palette_entry_free (GimpPaletteEntry *entry)
{ {

View File

@ -55,9 +55,6 @@ struct _GimpPalette
gint n_colors; gint n_colors;
gint n_columns; gint n_columns;
/* EEK */
GdkPixmap *pixmap;
}; };
struct _GimpPaletteClass struct _GimpPaletteClass

View File

@ -38,8 +38,8 @@ static void gimp_palette_preview_render (GimpPreview *preview);
static GtkWidget * gimp_palette_preview_create_popup (GimpPreview *preview); static GtkWidget * gimp_palette_preview_create_popup (GimpPreview *preview);
static gboolean gimp_palette_preview_needs_popup (GimpPreview *preview); static gboolean gimp_palette_preview_needs_popup (GimpPreview *preview);
static GimpPalette * gimp_palette_preview_drag_palette (GtkWidget *widget, static GimpViewable * gimp_palette_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -89,20 +89,14 @@ gimp_palette_preview_class_init (GimpPalettePreviewClass *klass)
static void static void
gimp_palette_preview_init (GimpPalettePreview *palette_preview) gimp_palette_preview_init (GimpPalettePreview *palette_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (palette_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_PALETTE GIMP_TYPE_PALETTE,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (palette_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_PALETTE,
gimp_palette_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (palette_preview), palette_preview);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_palette_source_set (GTK_WIDGET (palette_preview),
gimp_palette_preview_drag_palette,
palette_preview);
} }
static void static void
@ -176,13 +170,9 @@ gimp_palette_preview_needs_popup (GimpPreview *preview)
return FALSE; return FALSE;
} }
static GimpPalette * static GimpViewable *
gimp_palette_preview_drag_palette (GtkWidget *widget, gimp_palette_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_PALETTE (preview->viewable);
} }

View File

@ -34,12 +34,12 @@
static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass); static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass);
static void gimp_pattern_preview_init (GimpPatternPreview *preview); static void gimp_pattern_preview_init (GimpPatternPreview *preview);
static void gimp_pattern_preview_render (GimpPreview *preview); static void gimp_pattern_preview_render (GimpPreview *preview);
static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview); static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview);
static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview); static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview);
static GimpPattern * gimp_pattern_preview_drag_pattern (GtkWidget *widget, static GimpViewable * gimp_pattern_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -89,20 +89,14 @@ gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass)
static void static void
gimp_pattern_preview_init (GimpPatternPreview *pattern_preview) gimp_pattern_preview_init (GimpPatternPreview *pattern_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (pattern_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_PATTERN GIMP_TYPE_PATTERN,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (pattern_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_PATTERN,
gimp_pattern_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (pattern_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_pattern_source_set (GTK_WIDGET (pattern_preview),
gimp_pattern_preview_drag_pattern,
pattern_preview);
} }
static void static void
@ -184,13 +178,9 @@ gimp_pattern_preview_needs_popup (GimpPreview *preview)
return FALSE; return FALSE;
} }
static GimpPattern * static GimpViewable *
gimp_pattern_preview_drag_pattern (GtkWidget *widget, gimp_pattern_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_PATTERN (preview->viewable);
} }

View File

@ -2933,7 +2933,8 @@ cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_block_by_data gtk_signal_handler_block_by_data
(GTK_OBJECT (gradient_editor->control_blending_items[i]), (gpointer) i); (GTK_OBJECT (gradient_editor->control_blending_items[i]),
gradient_editor);
/* Set state */ /* Set state */
if (equal) if (equal)
@ -2949,7 +2950,8 @@ cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
/* Unblock signals */ /* Unblock signals */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]), (gpointer) i); gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]),
gradient_editor);
} }
static void static void
@ -2968,7 +2970,8 @@ cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
coloring = (int) gradient_editor->control_sel_l->color; coloring = (int) gradient_editor->control_sel_l->color;
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]), (gpointer) i); gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
gradient_editor);
/* Set state */ /* Set state */
if (equal) if (equal)
@ -2984,7 +2987,8 @@ cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
/* Unblock signals */ /* Unblock signals */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]), (gpointer) i); gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
gradient_editor);
} }
static void static void

View File

@ -34,7 +34,6 @@
#include "gimpdatafactoryview.h" #include "gimpdatafactoryview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimpgradient.h" #include "gimpgradient.h"
#include "gradient_editor.h" #include "gradient_editor.h"
#include "gradient_select.h" #include "gradient_select.h"
@ -47,9 +46,6 @@
static void gradient_select_change_callbacks (GradientSelect *gsp, static void gradient_select_change_callbacks (GradientSelect *gsp,
gboolean closing); gboolean closing);
static void gradient_select_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gradient_select_gradient_changed (GimpContext *context, static void gradient_select_gradient_changed (GimpContext *context,
GimpGradient *gradient, GimpGradient *gradient,
GradientSelect *gsp); GradientSelect *gsp);
@ -62,10 +58,11 @@ static void gradient_select_edit_gradient (GimpData *data);
GSList *gradient_active_dialogs = NULL; GSList *gradient_active_dialogs = NULL;
/* the main gradient selection dialog */ /* the main gradient selection dialog */
GradientSelect *gradient_select_dialog = NULL; GradientSelect *gradient_select_dialog = NULL;
/* gradient editor dialog */
static GradientEditor *gradient_editor_dialog; /* the main gradient editor dialog */
static GradientEditor *gradient_editor_dialog = NULL;
/* public functions */ /* public functions */
@ -179,15 +176,6 @@ gradient_select_new (gchar *title,
gtk_box_pack_start (GTK_BOX (vbox), gsp->view, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), gsp->view, TRUE, TRUE, 0);
gtk_widget_show (gsp->view); gtk_widget_show (gsp->view);
gimp_gtk_drag_dest_set_by_type (gsp->view,
GTK_DEST_DEFAULT_ALL,
GIMP_TYPE_GRADIENT,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (gsp->view),
GIMP_TYPE_GRADIENT,
gradient_select_drop_gradient,
gsp);
gtk_widget_show (vbox); gtk_widget_show (vbox);
gtk_widget_show (gsp->shell); gtk_widget_show (gsp->shell);
@ -322,18 +310,6 @@ gradient_select_dialogs_check (void)
} }
} }
static void
gradient_select_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GradientSelect *gsp;
gsp = (GradientSelect *) data;
gimp_context_set_gradient (gsp->context, GIMP_GRADIENT (viewable));
}
static void static void
gradient_select_gradient_changed (GimpContext *context, gradient_select_gradient_changed (GimpContext *context,
GimpGradient *gradient, GimpGradient *gradient,

View File

@ -37,7 +37,7 @@ struct _GradientSelect
}; };
/* list of active dialogs */ /* list of active dialogs */
extern GSList *gradient_active_dialogs; extern GSList *gradient_active_dialogs;
/* the main gradient selection dialog */ /* the main gradient selection dialog */

View File

@ -37,7 +37,6 @@
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdata.h" #include "gimpdata.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimprc.h" #include "gimprc.h"
#include "session.h" #include "session.h"
#include "temp_buf.h" #include "temp_buf.h"
@ -58,9 +57,6 @@
static void brush_select_change_callbacks (BrushSelect *bsp, static void brush_select_change_callbacks (BrushSelect *bsp,
gboolean closing); gboolean closing);
static void brush_select_drop_brush (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void brush_select_brush_changed (GimpContext *context, static void brush_select_brush_changed (GimpContext *context,
GimpBrush *brush, GimpBrush *brush,
BrushSelect *bsp); BrushSelect *bsp);
@ -93,8 +89,9 @@ GSList *brush_active_dialogs = NULL;
/* the main brush selection dialog */ /* the main brush selection dialog */
BrushSelect *brush_select_dialog = NULL; BrushSelect *brush_select_dialog = NULL;
/* Brush editor dialog */
static BrushEditGeneratedWindow *brush_edit_generated_dialog; /* the main brush editor dialog */
static BrushEditGeneratedWindow *brush_edit_generated_dialog = NULL;
/* public functions */ /* public functions */
@ -246,15 +243,6 @@ brush_select_new (gchar *title,
TRUE, TRUE, 0); TRUE, TRUE, 0);
gtk_widget_show (bsp->view); gtk_widget_show (bsp->view);
gimp_gtk_drag_dest_set_by_type (bsp->view,
GTK_DEST_DEFAULT_ALL,
GIMP_TYPE_BRUSH,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (bsp->view),
GIMP_TYPE_BRUSH,
brush_select_drop_brush,
bsp);
gtk_widget_show (bsp->brush_selection_box); gtk_widget_show (bsp->brush_selection_box);
gtk_widget_show (bsp->left_box); gtk_widget_show (bsp->left_box);
@ -264,6 +252,7 @@ brush_select_new (gchar *title,
/* Create the active brush label */ /* Create the active brush label */
util_box = gtk_hbox_new (FALSE, 0); util_box = gtk_hbox_new (FALSE, 0);
gtk_container_set_resize_mode (GTK_CONTAINER (util_box), GTK_RESIZE_QUEUE);
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2); gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2);
bsp->brush_name = gtk_label_new (_("No Brushes available")); bsp->brush_name = gtk_label_new (_("No Brushes available"));
@ -535,18 +524,6 @@ brush_select_dialogs_check (void)
* Local functions * Local functions
*/ */
static void
brush_select_drop_brush (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
gimp_context_set_brush (bsp->context, GIMP_BRUSH (viewable));
}
static void static void
brush_select_brush_changed (GimpContext *context, brush_select_brush_changed (GimpContext *context,
GimpBrush *brush, GimpBrush *brush,
@ -556,6 +533,9 @@ brush_select_brush_changed (GimpContext *context,
{ {
brush_select_update_active_brush_field (bsp); brush_select_update_active_brush_field (bsp);
gtk_widget_set_sensitive (GIMP_DATA_FACTORY_VIEW (bsp->view)->edit_button,
GIMP_IS_BRUSH_GENERATED (brush));
if (bsp->callback_name) if (bsp->callback_name)
brush_select_change_callbacks (bsp, FALSE); brush_select_change_callbacks (bsp, FALSE);
} }

View File

@ -83,7 +83,6 @@
#include "gimpcontainergridview.h" #include "gimpcontainergridview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdatafactoryview.h" #include "gimpdatafactoryview.h"
#include "gimpdnd.h"
#include "gimppreview.h" #include "gimppreview.h"
@ -1335,108 +1334,38 @@ container_view_scale_callback (GtkAdjustment *adj,
gimp_container_view_set_preview_size (view, ROUND (adj->value)); gimp_container_view_set_preview_size (view, ROUND (adj->value));
} }
static void
drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (widget);
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}
static void static void
brushes_callback (GtkWidget *widget, brushes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_brush_factory->container); gimp_container_view_set_container (view, global_brush_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
patterns_callback (GtkWidget *widget, patterns_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_pattern_factory->container); gimp_container_view_set_container (view, global_pattern_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
gradients_callback (GtkWidget *widget, gradients_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_gradient_factory->container); gimp_container_view_set_container (view, global_gradient_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
palettes_callback (GtkWidget *widget, palettes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_palette_factory->container); gimp_container_view_set_container (view, global_palette_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
images_callback (GtkWidget *widget, images_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, image_context); gimp_container_view_set_container (view, image_context);
} }
@ -1585,15 +1514,6 @@ container_multi_view_new (gboolean list,
5, 5); 5, 5);
} }
gimp_gtk_drag_dest_set_by_type (view,
GTK_DEST_DEFAULT_ALL,
container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
GIMP_CONTAINER_VIEW (view)->container->children_type,
drop_viewable_callback,
NULL);
dialog = gimp_dialog_new (title, "test", dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func, gimp_standard_help_func,
NULL, NULL,
@ -1772,7 +1692,7 @@ dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_LIST, data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List", "Gradient List",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }
@ -1820,7 +1740,7 @@ dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_GRID, data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid", "Gradient Grid",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }

View File

@ -2933,7 +2933,8 @@ cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_block_by_data gtk_signal_handler_block_by_data
(GTK_OBJECT (gradient_editor->control_blending_items[i]), (gpointer) i); (GTK_OBJECT (gradient_editor->control_blending_items[i]),
gradient_editor);
/* Set state */ /* Set state */
if (equal) if (equal)
@ -2949,7 +2950,8 @@ cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
/* Unblock signals */ /* Unblock signals */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]), (gpointer) i); gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]),
gradient_editor);
} }
static void static void
@ -2968,7 +2970,8 @@ cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
coloring = (int) gradient_editor->control_sel_l->color; coloring = (int) gradient_editor->control_sel_l->color;
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]), (gpointer) i); gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
gradient_editor);
/* Set state */ /* Set state */
if (equal) if (equal)
@ -2984,7 +2987,8 @@ cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
/* Unblock signals */ /* Unblock signals */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]), (gpointer) i); gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
gradient_editor);
} }
static void static void

View File

@ -34,7 +34,6 @@
#include "gimpdatafactoryview.h" #include "gimpdatafactoryview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimpgradient.h" #include "gimpgradient.h"
#include "gradient_editor.h" #include "gradient_editor.h"
#include "gradient_select.h" #include "gradient_select.h"
@ -47,9 +46,6 @@
static void gradient_select_change_callbacks (GradientSelect *gsp, static void gradient_select_change_callbacks (GradientSelect *gsp,
gboolean closing); gboolean closing);
static void gradient_select_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gradient_select_gradient_changed (GimpContext *context, static void gradient_select_gradient_changed (GimpContext *context,
GimpGradient *gradient, GimpGradient *gradient,
GradientSelect *gsp); GradientSelect *gsp);
@ -62,10 +58,11 @@ static void gradient_select_edit_gradient (GimpData *data);
GSList *gradient_active_dialogs = NULL; GSList *gradient_active_dialogs = NULL;
/* the main gradient selection dialog */ /* the main gradient selection dialog */
GradientSelect *gradient_select_dialog = NULL; GradientSelect *gradient_select_dialog = NULL;
/* gradient editor dialog */
static GradientEditor *gradient_editor_dialog; /* the main gradient editor dialog */
static GradientEditor *gradient_editor_dialog = NULL;
/* public functions */ /* public functions */
@ -179,15 +176,6 @@ gradient_select_new (gchar *title,
gtk_box_pack_start (GTK_BOX (vbox), gsp->view, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), gsp->view, TRUE, TRUE, 0);
gtk_widget_show (gsp->view); gtk_widget_show (gsp->view);
gimp_gtk_drag_dest_set_by_type (gsp->view,
GTK_DEST_DEFAULT_ALL,
GIMP_TYPE_GRADIENT,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (gsp->view),
GIMP_TYPE_GRADIENT,
gradient_select_drop_gradient,
gsp);
gtk_widget_show (vbox); gtk_widget_show (vbox);
gtk_widget_show (gsp->shell); gtk_widget_show (gsp->shell);
@ -322,18 +310,6 @@ gradient_select_dialogs_check (void)
} }
} }
static void
gradient_select_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GradientSelect *gsp;
gsp = (GradientSelect *) data;
gimp_context_set_gradient (gsp->context, GIMP_GRADIENT (viewable));
}
static void static void
gradient_select_gradient_changed (GimpContext *context, gradient_select_gradient_changed (GimpContext *context,
GimpGradient *gradient, GimpGradient *gradient,

View File

@ -37,7 +37,7 @@ struct _GradientSelect
}; };
/* list of active dialogs */ /* list of active dialogs */
extern GSList *gradient_active_dialogs; extern GSList *gradient_active_dialogs;
/* the main gradient selection dialog */ /* the main gradient selection dialog */

View File

@ -83,7 +83,6 @@
#include "gimpcontainergridview.h" #include "gimpcontainergridview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdatafactoryview.h" #include "gimpdatafactoryview.h"
#include "gimpdnd.h"
#include "gimppreview.h" #include "gimppreview.h"
@ -1335,108 +1334,38 @@ container_view_scale_callback (GtkAdjustment *adj,
gimp_container_view_set_preview_size (view, ROUND (adj->value)); gimp_container_view_set_preview_size (view, ROUND (adj->value));
} }
static void
drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (widget);
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}
static void static void
brushes_callback (GtkWidget *widget, brushes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_brush_factory->container); gimp_container_view_set_container (view, global_brush_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
patterns_callback (GtkWidget *widget, patterns_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_pattern_factory->container); gimp_container_view_set_container (view, global_pattern_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
gradients_callback (GtkWidget *widget, gradients_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_gradient_factory->container); gimp_container_view_set_container (view, global_gradient_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
palettes_callback (GtkWidget *widget, palettes_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, global_palette_factory->container); gimp_container_view_set_container (view, global_palette_factory->container);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
drop_viewable_callback,
NULL);
} }
static void static void
images_callback (GtkWidget *widget, images_callback (GtkWidget *widget,
GimpContainerView *view) GimpContainerView *view)
{ {
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
gimp_container_view_set_container (view, image_context); gimp_container_view_set_container (view, image_context);
} }
@ -1585,15 +1514,6 @@ container_multi_view_new (gboolean list,
5, 5); 5, 5);
} }
gimp_gtk_drag_dest_set_by_type (view,
GTK_DEST_DEFAULT_ALL,
container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
GIMP_CONTAINER_VIEW (view)->container->children_type,
drop_viewable_callback,
NULL);
dialog = gimp_dialog_new (title, "test", dialog = gimp_dialog_new (title, "test",
gimp_standard_help_func, gimp_standard_help_func,
NULL, NULL,
@ -1772,7 +1692,7 @@ dialogs_test_gradient_container_list_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_LIST, data_factory_view_new (GIMP_VIEW_TYPE_LIST,
"Gradient List", "Gradient List",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }
@ -1820,7 +1740,7 @@ dialogs_test_gradient_container_grid_view_cmd_callback (GtkWidget *widget,
data_factory_view_new (GIMP_VIEW_TYPE_GRID, data_factory_view_new (GIMP_VIEW_TYPE_GRID,
"Gradient Grid", "Gradient Grid",
global_gradient_factory, global_gradient_factory,
gradient_editor_set_gradient, NULL,
gimp_context_get_user (), gimp_context_get_user (),
24); 24);
} }

File diff suppressed because it is too large Load Diff

View File

@ -573,8 +573,6 @@ palette_import_create_from_grad (gchar *name)
gimp_container_add (global_palette_factory->container, gimp_container_add (global_palette_factory->container,
GIMP_OBJECT (palette)); GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
} }
@ -758,8 +756,6 @@ palette_import_image_make_palette (GHashTable *h_array,
g_slist_free (sorted_list); g_slist_free (sorted_list);
gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette)); gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
static void static void
@ -874,8 +870,6 @@ palette_import_create_from_indexed (GImage *gimage,
} }
gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette)); gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
/* the palette import action area callbacks ********************************/ /* the palette import action area callbacks ********************************/

View File

@ -27,31 +27,39 @@
#include "apptypes.h" #include "apptypes.h"
#include "appenv.h"
#include "context_manager.h" #include "context_manager.h"
#include "dialog_handler.h"
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdatafactoryview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimppalette.h" #include "gimppalette.h"
#include "palette_select.h" #include "palette_select.h"
#include "palette.h" #include "palette.h"
#include "paletteP.h" #include "paletteP.h"
#include "session.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#define STD_PALETTE_COLUMNS 6
#define STD_PALETTE_ROWS 5
/* local function prototypes */ /* local function prototypes */
static gint palette_select_button_press (GtkWidget *widget, static void palette_select_drop_palette (GtkWidget *widget,
GdkEventButton *bevent, GimpViewable *viewable,
gpointer data); gpointer data);
static void palette_select_close_callback (GtkWidget *widget, static void palette_select_close_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void palette_select_edit_callback (GtkWidget *widget, static void palette_select_edit_palette (GimpData *data);
gpointer data);
/* list of active dialogs */ /* list of active dialogs */
static GSList *palette_active_dialogs = NULL;
static GSList *active_dialogs = NULL;
/* public functions */ /* public functions */
@ -60,17 +68,14 @@ PaletteSelect *
palette_select_new (const gchar *title, palette_select_new (const gchar *title,
const gchar *initial_palette) const gchar *initial_palette)
{ {
GimpPalette *palette;
PaletteSelect *psp; PaletteSelect *psp;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *hbox; GimpPalette *active = NULL;
GtkWidget *scrolled_win;
gchar *titles[3];
gint select_pos = -1;
palette_select_palette_init (); static gboolean first_call = TRUE;
psp = g_new0 (PaletteSelect, 1);
psp = g_new (PaletteSelect, 1);
psp->callback_name = NULL; psp->callback_name = NULL;
/* The shell and main vbox */ /* The shell and main vbox */
@ -81,182 +86,99 @@ palette_select_new (const gchar *title,
GTK_WIN_POS_MOUSE, GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
_("Edit"), palette_select_edit_callback, "_delete_event_", palette_select_close_callback,
psp, NULL, NULL, TRUE, FALSE,
_("Close"), palette_select_close_callback,
psp, NULL, NULL, FALSE, TRUE, psp, NULL, NULL, FALSE, TRUE,
NULL); NULL);
vbox = gtk_vbox_new (FALSE, 1); gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox)), 0)));
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
gtk_widget_hide (GTK_DIALOG (psp->shell)->action_area);
if (title)
{
psp->context = gimp_context_new (title, NULL);
}
else
{
psp->context = gimp_context_get_user ();
/*
session_set_window_geometry (psp->shell, &palette_select_session_info,
TRUE);
*/
dialog_register (psp->shell);
}
if (no_data && first_call)
gimp_data_factory_data_init (global_palette_factory, FALSE);
first_call = FALSE;
if (title && initial_palette && strlen (initial_palette))
{
active = (GimpPalette *)
gimp_container_get_child_by_name (global_palette_factory->container,
initial_palette);
}
else
{
active = gimp_context_get_palette (gimp_context_get_user ());
}
if (!active)
active = gimp_context_get_palette (gimp_context_get_standard ());
if (title)
gimp_context_set_palette (psp->context, active);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox);
hbox = gtk_hbox_new (FALSE, 8); /* The Palette List */
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); psp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
gtk_widget_show (hbox); global_palette_factory,
palette_select_edit_palette,
psp->context,
64, /* FIXME: SM_PREVIEW_WIDTH */
3, /* FIXME: STD_PALETTE_COLUMNS */
3); /* FIXME: STD_PALETTE_ROWS */
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
gtk_widget_show (psp->view);
/* clist preview of gradients */ gimp_gtk_drag_dest_set_by_type (psp->view,
scrolled_win = gtk_scrolled_window_new (NULL, NULL); GTK_DEST_DEFAULT_ALL,
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GIMP_TYPE_PALETTE,
GTK_POLICY_AUTOMATIC, GDK_ACTION_COPY);
GTK_POLICY_ALWAYS); gimp_dnd_viewable_dest_set (GTK_WIDGET (psp->view),
gtk_box_pack_start (GTK_BOX (hbox), scrolled_win, TRUE, TRUE, 0); GIMP_TYPE_PALETTE,
gtk_widget_show (scrolled_win); palette_select_drop_palette,
psp);
titles[0] = _("Palette");
titles[1] = _("Ncols");
titles[2] = _("Name");
psp->clist = gtk_clist_new_with_titles (3, titles);
gtk_clist_set_shadow_type (GTK_CLIST (psp->clist), GTK_SHADOW_IN);
gtk_clist_set_row_height (GTK_CLIST (psp->clist), SM_PREVIEW_HEIGHT + 2);
gtk_clist_set_use_drag_icons (GTK_CLIST (psp->clist), FALSE);
gtk_clist_column_titles_passive (GTK_CLIST (psp->clist));
gtk_widget_set_usize (psp->clist, 203, 200);
gtk_clist_set_column_width (GTK_CLIST (psp->clist), 0, SM_PREVIEW_WIDTH + 2);
gtk_container_add (GTK_CONTAINER (scrolled_win), psp->clist);
gtk_widget_show (psp->clist);
palette = (GimpPalette *)
gimp_container_get_child_by_name (global_palette_factory->container,
initial_palette);
if (palette)
select_pos = gimp_container_get_child_index (global_palette_factory->container,
GIMP_OBJECT (palette));
gtk_widget_realize (psp->shell);
psp->gc = gdk_gc_new (psp->shell->window);
palette_clist_init (psp->clist, psp->shell, psp->gc);
gtk_signal_connect (GTK_OBJECT (psp->clist), "button_press_event",
GTK_SIGNAL_FUNC (palette_select_button_press),
(gpointer) psp);
/* Now show the dialog */
gtk_widget_show (vbox); gtk_widget_show (vbox);
gtk_widget_show (psp->shell); gtk_widget_show (psp->shell);
if (select_pos != -1) palette_active_dialogs = g_slist_append (palette_active_dialogs, psp);
{
gtk_clist_select_row (GTK_CLIST (psp->clist), select_pos, -1);
gtk_clist_moveto (GTK_CLIST (psp->clist), select_pos, 0, 0.0, 0.0);
}
else
gtk_clist_select_row (GTK_CLIST (psp->clist), 0, -1);
active_dialogs = g_slist_append (active_dialogs, psp);
return psp; return psp;
} }
void
palette_select_clist_insert_all (GimpPalette *entries)
{
PaletteSelect *psp;
GSList *list;
gint pos;
pos = gimp_container_get_child_index (global_palette_factory->container,
GIMP_OBJECT (entries));
for (list = active_dialogs; list; list = g_slist_next (list))
{
psp = (PaletteSelect *) list->data;
gtk_clist_freeze (GTK_CLIST (psp->clist));
palette_clist_insert (psp->clist, psp->shell, psp->gc, entries, pos);
gtk_clist_thaw (GTK_CLIST (psp->clist));
}
}
void
palette_select_set_text_all (GimpPalette *entries)
{
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
gint pos;
pos = gimp_container_get_child_index (global_palette_factory->container,
GIMP_OBJECT (entries));
num_buf = g_strdup_printf ("%d", entries->n_colors);
for (list = active_dialogs; list; list = g_slist_next (list))
{
psp = (PaletteSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (psp->clist), pos, 1, num_buf);
}
g_free (num_buf);
}
void
palette_select_refresh_all (void)
{
PaletteSelect *psp;
GSList *list;
for (list = active_dialogs; list; list = g_slist_next (list))
{
psp = (PaletteSelect *) list->data;
gtk_clist_freeze (GTK_CLIST (psp->clist));
gtk_clist_clear (GTK_CLIST (psp->clist));
palette_clist_init (psp->clist, psp->shell, psp->gc);
gtk_clist_thaw (GTK_CLIST (psp->clist));
}
}
/* local functions */ /* local functions */
static gint
palette_select_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
PaletteSelect *psp;
psp = (PaletteSelect *) data;
if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS)
{
palette_select_edit_callback (widget, data);
return TRUE;
}
return FALSE;
}
static void static void
palette_select_edit_callback (GtkWidget *widget, palette_select_drop_palette (GtkWidget *widget,
gpointer data) GimpViewable *viewable,
gpointer data)
{ {
GimpPalette *p_entries = NULL;
PaletteSelect *psp; PaletteSelect *psp;
GList *sel_list;
psp = (PaletteSelect *) data; psp = (PaletteSelect *) data;
sel_list = GTK_CLIST (psp->clist)->selection; gimp_context_set_palette (psp->context, GIMP_PALETTE (viewable));
while (sel_list)
{
gint row;
row = GPOINTER_TO_INT (sel_list->data);
p_entries =
(GimpPalette *) gtk_clist_get_row_data (GTK_CLIST (psp->clist), row);
palette_create_edit (p_entries);
/* One only */
return;
}
} }
static void static void
@ -270,7 +192,7 @@ palette_select_free (PaletteSelect *psp)
*/ */
/* remove from active list */ /* remove from active list */
active_dialogs = g_slist_remove (active_dialogs, psp); palette_active_dialogs = g_slist_remove (palette_active_dialogs, psp);
g_free (psp); g_free (psp);
} }
@ -290,3 +212,13 @@ palette_select_close_callback (GtkWidget *widget,
gtk_widget_destroy (psp->shell); gtk_widget_destroy (psp->shell);
palette_select_free (psp); palette_select_free (psp);
} }
static void
palette_select_edit_palette (GimpData *data)
{
GimpPalette *palette;
palette = GIMP_PALETTE (data);
palette_create_edit (palette);
}

View File

@ -28,19 +28,17 @@ typedef struct _PaletteSelect PaletteSelect;
struct _PaletteSelect struct _PaletteSelect
{ {
GtkWidget *shell; GtkWidget *shell;
GtkWidget *clist; GtkWidget *view;
GdkGC *gc;
gchar *callback_name; gchar *callback_name;
GimpContext *context;
}; };
PaletteSelect * palette_select_new (const gchar *title, PaletteSelect * palette_select_new (const gchar *title,
const gchar *initial_palette); const gchar *initial_palette);
void palette_select_clist_insert_all (GimpPalette *palette);
void palette_select_set_text_all (GimpPalette *palette);
void palette_select_refresh_all (void);
#endif /* __PALETTE_SELECT_H__ */ #endif /* __PALETTE_SELECT_H__ */

View File

@ -30,10 +30,9 @@
#include "context_manager.h" #include "context_manager.h"
#include "dialog_handler.h" #include "dialog_handler.h"
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpdatafactoryview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdatafactoryview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimppattern.h" #include "gimppattern.h"
#include "pattern_select.h" #include "pattern_select.h"
#include "session.h" #include "session.h"
@ -53,9 +52,6 @@
static void pattern_select_change_callbacks (PatternSelect *psp, static void pattern_select_change_callbacks (PatternSelect *psp,
gboolean closing); gboolean closing);
static void pattern_select_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void pattern_select_pattern_changed (GimpContext *context, static void pattern_select_pattern_changed (GimpContext *context,
GimpPattern *pattern, GimpPattern *pattern,
PatternSelect *psp); PatternSelect *psp);
@ -209,15 +205,6 @@ pattern_select_new (gchar *title,
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
gtk_widget_show (psp->view); gtk_widget_show (psp->view);
gimp_gtk_drag_dest_set_by_type (psp->view,
GTK_DEST_DEFAULT_ALL,
GIMP_TYPE_PATTERN,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (psp->view),
GIMP_TYPE_PATTERN,
pattern_select_drop_pattern,
psp);
gtk_widget_show (vbox); gtk_widget_show (vbox);
/* add callbacks to keep the display area current */ /* add callbacks to keep the display area current */
@ -353,19 +340,6 @@ pattern_select_dialogs_check (void)
* Local functions * Local functions
*/ */
static void
pattern_select_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
PatternSelect *psp;
psp = (PatternSelect *) data;
gimp_context_set_pattern (psp->context, GIMP_PATTERN (viewable));
}
static void static void
pattern_select_pattern_changed (GimpContext *context, pattern_select_pattern_changed (GimpContext *context,
GimpPattern *pattern, GimpPattern *pattern,

File diff suppressed because it is too large Load Diff

View File

@ -20,19 +20,8 @@
#define __PALETTE_P_H__ #define __PALETTE_P_H__
void palette_clist_init (GtkWidget *clist,
GtkWidget *shell,
GdkGC *gc);
void palette_clist_insert (GtkWidget *clist,
GtkWidget *shell,
GdkGC *gc,
GimpPalette *palette,
gint pos);
void palette_select_palette_init (void); void palette_select_palette_init (void);
void palette_create_edit (GimpPalette *palette); void palette_create_edit (GimpPalette *palette);
void palette_insert_all (GimpPalette *palette);
#endif /* __PALETTE_P_H__ */ #endif /* __PALETTE_P_H__ */

View File

@ -573,8 +573,6 @@ palette_import_create_from_grad (gchar *name)
gimp_container_add (global_palette_factory->container, gimp_container_add (global_palette_factory->container,
GIMP_OBJECT (palette)); GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
} }
@ -758,8 +756,6 @@ palette_import_image_make_palette (GHashTable *h_array,
g_slist_free (sorted_list); g_slist_free (sorted_list);
gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette)); gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
static void static void
@ -874,8 +870,6 @@ palette_import_create_from_indexed (GImage *gimage,
} }
gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette)); gimp_container_add (global_palette_factory->container, GIMP_OBJECT (palette));
palette_insert_all (palette);
} }
/* the palette import action area callbacks ********************************/ /* the palette import action area callbacks ********************************/

View File

@ -27,31 +27,39 @@
#include "apptypes.h" #include "apptypes.h"
#include "appenv.h"
#include "context_manager.h" #include "context_manager.h"
#include "dialog_handler.h"
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdatafactoryview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimppalette.h" #include "gimppalette.h"
#include "palette_select.h" #include "palette_select.h"
#include "palette.h" #include "palette.h"
#include "paletteP.h" #include "paletteP.h"
#include "session.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#define STD_PALETTE_COLUMNS 6
#define STD_PALETTE_ROWS 5
/* local function prototypes */ /* local function prototypes */
static gint palette_select_button_press (GtkWidget *widget, static void palette_select_drop_palette (GtkWidget *widget,
GdkEventButton *bevent, GimpViewable *viewable,
gpointer data); gpointer data);
static void palette_select_close_callback (GtkWidget *widget, static void palette_select_close_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void palette_select_edit_callback (GtkWidget *widget, static void palette_select_edit_palette (GimpData *data);
gpointer data);
/* list of active dialogs */ /* list of active dialogs */
static GSList *palette_active_dialogs = NULL;
static GSList *active_dialogs = NULL;
/* public functions */ /* public functions */
@ -60,17 +68,14 @@ PaletteSelect *
palette_select_new (const gchar *title, palette_select_new (const gchar *title,
const gchar *initial_palette) const gchar *initial_palette)
{ {
GimpPalette *palette;
PaletteSelect *psp; PaletteSelect *psp;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *hbox; GimpPalette *active = NULL;
GtkWidget *scrolled_win;
gchar *titles[3];
gint select_pos = -1;
palette_select_palette_init (); static gboolean first_call = TRUE;
psp = g_new0 (PaletteSelect, 1);
psp = g_new (PaletteSelect, 1);
psp->callback_name = NULL; psp->callback_name = NULL;
/* The shell and main vbox */ /* The shell and main vbox */
@ -81,182 +86,99 @@ palette_select_new (const gchar *title,
GTK_WIN_POS_MOUSE, GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
_("Edit"), palette_select_edit_callback, "_delete_event_", palette_select_close_callback,
psp, NULL, NULL, TRUE, FALSE,
_("Close"), palette_select_close_callback,
psp, NULL, NULL, FALSE, TRUE, psp, NULL, NULL, FALSE, TRUE,
NULL); NULL);
vbox = gtk_vbox_new (FALSE, 1); gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox)), 0)));
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
gtk_widget_hide (GTK_DIALOG (psp->shell)->action_area);
if (title)
{
psp->context = gimp_context_new (title, NULL);
}
else
{
psp->context = gimp_context_get_user ();
/*
session_set_window_geometry (psp->shell, &palette_select_session_info,
TRUE);
*/
dialog_register (psp->shell);
}
if (no_data && first_call)
gimp_data_factory_data_init (global_palette_factory, FALSE);
first_call = FALSE;
if (title && initial_palette && strlen (initial_palette))
{
active = (GimpPalette *)
gimp_container_get_child_by_name (global_palette_factory->container,
initial_palette);
}
else
{
active = gimp_context_get_palette (gimp_context_get_user ());
}
if (!active)
active = gimp_context_get_palette (gimp_context_get_standard ());
if (title)
gimp_context_set_palette (psp->context, active);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox);
hbox = gtk_hbox_new (FALSE, 8); /* The Palette List */
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); psp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
gtk_widget_show (hbox); global_palette_factory,
palette_select_edit_palette,
psp->context,
64, /* FIXME: SM_PREVIEW_WIDTH */
3, /* FIXME: STD_PALETTE_COLUMNS */
3); /* FIXME: STD_PALETTE_ROWS */
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
gtk_widget_show (psp->view);
/* clist preview of gradients */ gimp_gtk_drag_dest_set_by_type (psp->view,
scrolled_win = gtk_scrolled_window_new (NULL, NULL); GTK_DEST_DEFAULT_ALL,
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GIMP_TYPE_PALETTE,
GTK_POLICY_AUTOMATIC, GDK_ACTION_COPY);
GTK_POLICY_ALWAYS); gimp_dnd_viewable_dest_set (GTK_WIDGET (psp->view),
gtk_box_pack_start (GTK_BOX (hbox), scrolled_win, TRUE, TRUE, 0); GIMP_TYPE_PALETTE,
gtk_widget_show (scrolled_win); palette_select_drop_palette,
psp);
titles[0] = _("Palette");
titles[1] = _("Ncols");
titles[2] = _("Name");
psp->clist = gtk_clist_new_with_titles (3, titles);
gtk_clist_set_shadow_type (GTK_CLIST (psp->clist), GTK_SHADOW_IN);
gtk_clist_set_row_height (GTK_CLIST (psp->clist), SM_PREVIEW_HEIGHT + 2);
gtk_clist_set_use_drag_icons (GTK_CLIST (psp->clist), FALSE);
gtk_clist_column_titles_passive (GTK_CLIST (psp->clist));
gtk_widget_set_usize (psp->clist, 203, 200);
gtk_clist_set_column_width (GTK_CLIST (psp->clist), 0, SM_PREVIEW_WIDTH + 2);
gtk_container_add (GTK_CONTAINER (scrolled_win), psp->clist);
gtk_widget_show (psp->clist);
palette = (GimpPalette *)
gimp_container_get_child_by_name (global_palette_factory->container,
initial_palette);
if (palette)
select_pos = gimp_container_get_child_index (global_palette_factory->container,
GIMP_OBJECT (palette));
gtk_widget_realize (psp->shell);
psp->gc = gdk_gc_new (psp->shell->window);
palette_clist_init (psp->clist, psp->shell, psp->gc);
gtk_signal_connect (GTK_OBJECT (psp->clist), "button_press_event",
GTK_SIGNAL_FUNC (palette_select_button_press),
(gpointer) psp);
/* Now show the dialog */
gtk_widget_show (vbox); gtk_widget_show (vbox);
gtk_widget_show (psp->shell); gtk_widget_show (psp->shell);
if (select_pos != -1) palette_active_dialogs = g_slist_append (palette_active_dialogs, psp);
{
gtk_clist_select_row (GTK_CLIST (psp->clist), select_pos, -1);
gtk_clist_moveto (GTK_CLIST (psp->clist), select_pos, 0, 0.0, 0.0);
}
else
gtk_clist_select_row (GTK_CLIST (psp->clist), 0, -1);
active_dialogs = g_slist_append (active_dialogs, psp);
return psp; return psp;
} }
void
palette_select_clist_insert_all (GimpPalette *entries)
{
PaletteSelect *psp;
GSList *list;
gint pos;
pos = gimp_container_get_child_index (global_palette_factory->container,
GIMP_OBJECT (entries));
for (list = active_dialogs; list; list = g_slist_next (list))
{
psp = (PaletteSelect *) list->data;
gtk_clist_freeze (GTK_CLIST (psp->clist));
palette_clist_insert (psp->clist, psp->shell, psp->gc, entries, pos);
gtk_clist_thaw (GTK_CLIST (psp->clist));
}
}
void
palette_select_set_text_all (GimpPalette *entries)
{
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
gint pos;
pos = gimp_container_get_child_index (global_palette_factory->container,
GIMP_OBJECT (entries));
num_buf = g_strdup_printf ("%d", entries->n_colors);
for (list = active_dialogs; list; list = g_slist_next (list))
{
psp = (PaletteSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (psp->clist), pos, 1, num_buf);
}
g_free (num_buf);
}
void
palette_select_refresh_all (void)
{
PaletteSelect *psp;
GSList *list;
for (list = active_dialogs; list; list = g_slist_next (list))
{
psp = (PaletteSelect *) list->data;
gtk_clist_freeze (GTK_CLIST (psp->clist));
gtk_clist_clear (GTK_CLIST (psp->clist));
palette_clist_init (psp->clist, psp->shell, psp->gc);
gtk_clist_thaw (GTK_CLIST (psp->clist));
}
}
/* local functions */ /* local functions */
static gint
palette_select_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
PaletteSelect *psp;
psp = (PaletteSelect *) data;
if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS)
{
palette_select_edit_callback (widget, data);
return TRUE;
}
return FALSE;
}
static void static void
palette_select_edit_callback (GtkWidget *widget, palette_select_drop_palette (GtkWidget *widget,
gpointer data) GimpViewable *viewable,
gpointer data)
{ {
GimpPalette *p_entries = NULL;
PaletteSelect *psp; PaletteSelect *psp;
GList *sel_list;
psp = (PaletteSelect *) data; psp = (PaletteSelect *) data;
sel_list = GTK_CLIST (psp->clist)->selection; gimp_context_set_palette (psp->context, GIMP_PALETTE (viewable));
while (sel_list)
{
gint row;
row = GPOINTER_TO_INT (sel_list->data);
p_entries =
(GimpPalette *) gtk_clist_get_row_data (GTK_CLIST (psp->clist), row);
palette_create_edit (p_entries);
/* One only */
return;
}
} }
static void static void
@ -270,7 +192,7 @@ palette_select_free (PaletteSelect *psp)
*/ */
/* remove from active list */ /* remove from active list */
active_dialogs = g_slist_remove (active_dialogs, psp); palette_active_dialogs = g_slist_remove (palette_active_dialogs, psp);
g_free (psp); g_free (psp);
} }
@ -290,3 +212,13 @@ palette_select_close_callback (GtkWidget *widget,
gtk_widget_destroy (psp->shell); gtk_widget_destroy (psp->shell);
palette_select_free (psp); palette_select_free (psp);
} }
static void
palette_select_edit_palette (GimpData *data)
{
GimpPalette *palette;
palette = GIMP_PALETTE (data);
palette_create_edit (palette);
}

View File

@ -28,19 +28,17 @@ typedef struct _PaletteSelect PaletteSelect;
struct _PaletteSelect struct _PaletteSelect
{ {
GtkWidget *shell; GtkWidget *shell;
GtkWidget *clist; GtkWidget *view;
GdkGC *gc;
gchar *callback_name; gchar *callback_name;
GimpContext *context;
}; };
PaletteSelect * palette_select_new (const gchar *title, PaletteSelect * palette_select_new (const gchar *title,
const gchar *initial_palette); const gchar *initial_palette);
void palette_select_clist_insert_all (GimpPalette *palette);
void palette_select_set_text_all (GimpPalette *palette);
void palette_select_refresh_all (void);
#endif /* __PALETTE_SELECT_H__ */ #endif /* __PALETTE_SELECT_H__ */

View File

@ -30,10 +30,9 @@
#include "context_manager.h" #include "context_manager.h"
#include "dialog_handler.h" #include "dialog_handler.h"
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpdatafactoryview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdatafactoryview.h"
#include "gimpdatafactory.h" #include "gimpdatafactory.h"
#include "gimpdnd.h"
#include "gimppattern.h" #include "gimppattern.h"
#include "pattern_select.h" #include "pattern_select.h"
#include "session.h" #include "session.h"
@ -53,9 +52,6 @@
static void pattern_select_change_callbacks (PatternSelect *psp, static void pattern_select_change_callbacks (PatternSelect *psp,
gboolean closing); gboolean closing);
static void pattern_select_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void pattern_select_pattern_changed (GimpContext *context, static void pattern_select_pattern_changed (GimpContext *context,
GimpPattern *pattern, GimpPattern *pattern,
PatternSelect *psp); PatternSelect *psp);
@ -209,15 +205,6 @@ pattern_select_new (gchar *title,
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
gtk_widget_show (psp->view); gtk_widget_show (psp->view);
gimp_gtk_drag_dest_set_by_type (psp->view,
GTK_DEST_DEFAULT_ALL,
GIMP_TYPE_PATTERN,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (psp->view),
GIMP_TYPE_PATTERN,
pattern_select_drop_pattern,
psp);
gtk_widget_show (vbox); gtk_widget_show (vbox);
/* add callbacks to keep the display area current */ /* add callbacks to keep the display area current */
@ -353,19 +340,6 @@ pattern_select_dialogs_check (void)
* Local functions * Local functions
*/ */
static void
pattern_select_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
PatternSelect *psp;
psp = (PatternSelect *) data;
gimp_context_set_pattern (psp->context, GIMP_PATTERN (viewable));
}
static void static void
pattern_select_pattern_changed (GimpContext *context, pattern_select_pattern_changed (GimpContext *context,
GimpPattern *pattern, GimpPattern *pattern,

View File

@ -41,8 +41,8 @@ static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview)
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview); static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview); static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview);
static GimpBrush * gimp_brush_preview_drag_brush (GtkWidget *widget, static GimpViewable * gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -94,20 +94,14 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
static void static void
gimp_brush_preview_init (GimpBrushPreview *brush_preview) gimp_brush_preview_init (GimpBrushPreview *brush_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (brush_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_BRUSH GIMP_TYPE_BRUSH,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (brush_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_BRUSH,
gimp_brush_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (brush_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_source_set (GTK_WIDGET (brush_preview),
gimp_brush_preview_drag_brush,
brush_preview);
brush_preview->pipe_timeout_id = 0; brush_preview->pipe_timeout_id = 0;
brush_preview->pipe_animation_index = 0; brush_preview->pipe_animation_index = 0;
@ -379,13 +373,9 @@ gimp_brush_preview_render_timeout_func (GimpBrushPreview *brush_preview)
return TRUE; return TRUE;
} }
static GimpBrush * static GimpViewable *
gimp_brush_preview_drag_brush (GtkWidget *widget, gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_BRUSH (preview->viewable);
} }

View File

@ -54,6 +54,8 @@ 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_set_preview_size (GimpContainerView *view);
static void gimp_container_grid_view_item_selected (GtkWidget *widget, static void gimp_container_grid_view_item_selected (GtkWidget *widget,
gpointer data); gpointer data);
static void gimp_container_grid_view_item_activate (GtkWidget *widget,
gpointer data);
static void gimp_container_grid_view_highlight_item (GimpContainerView *view, static void gimp_container_grid_view_highlight_item (GimpContainerView *view,
GimpViewable *viewable, GimpViewable *viewable,
gpointer insert_data); gpointer insert_data);
@ -237,6 +239,10 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected), GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected),
view); view);
gtk_signal_connect (GTK_OBJECT (preview), "double_clicked",
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activate),
view);
return (gpointer) preview; return (gpointer) preview;
} }
@ -338,6 +344,14 @@ gimp_container_grid_view_item_selected (GtkWidget *widget,
GIMP_PREVIEW (widget)->viewable); GIMP_PREVIEW (widget)->viewable);
} }
static void
gimp_container_grid_view_item_activate (GtkWidget *widget,
gpointer data)
{
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data),
GIMP_PREVIEW (widget)->viewable);
}
static void static void
gimp_container_grid_view_highlight_item (GimpContainerView *view, gimp_container_grid_view_highlight_item (GimpContainerView *view,
GimpViewable *viewable, GimpViewable *viewable,

View File

@ -28,6 +28,7 @@
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpcontainerlistview.h" #include "gimpcontainerlistview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimplist.h" #include "gimplist.h"
#include "gimppreview.h" #include "gimppreview.h"
@ -57,6 +58,11 @@ static void gimp_container_list_view_name_changed (GimpViewable *v
static void gimp_container_list_view_item_selected (GtkWidget *widget, static void gimp_container_list_view_item_selected (GtkWidget *widget,
GtkWidget *child, GtkWidget *child,
gpointer data); gpointer data);
static gint gimp_container_list_view_item_activate (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static GimpViewable * gimp_container_list_view_drag_viewable (GtkWidget *widget,
gpointer data);
static GimpContainerViewClass *parent_class = NULL; static GimpContainerViewClass *parent_class = NULL;
@ -236,6 +242,19 @@ gimp_container_list_view_insert_item (GimpContainerView *view,
label, label,
GTK_OBJECT (list_view)); GTK_OBJECT (list_view));
gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event",
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activate),
list_view);
gimp_gtk_drag_source_set_by_type (list_item,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (list_item),
view->container->children_type,
gimp_container_list_view_drag_viewable,
list_view);
gtk_widget_show (list_item); gtk_widget_show (list_item);
list = g_list_prepend (NULL, list_item); list = g_list_prepend (NULL, list_item);
@ -417,6 +436,35 @@ gimp_container_list_view_item_selected (GtkWidget *widget,
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child), viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child),
"preview"))->viewable; "preview"))->viewable;
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), viewable);
viewable); }
static gint
gimp_container_list_view_item_activate (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
if (bevent->type == GDK_2BUTTON_PRESS)
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
gimp_container_view_item_activate (GIMP_CONTAINER_VIEW (data), viewable);
}
return FALSE;
}
static GimpViewable *
gimp_container_list_view_drag_viewable (GtkWidget *widget,
gpointer data)
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
return viewable;
} }

View File

@ -25,6 +25,7 @@
#include "gimpcontainer.h" #include "gimpcontainer.h"
#include "gimpcontainerview.h" #include "gimpcontainerview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "gimpviewable.h" #include "gimpviewable.h"
@ -35,6 +36,7 @@ enum
REMOVE_ITEM, REMOVE_ITEM,
REORDER_ITEM, REORDER_ITEM,
SELECT_ITEM, SELECT_ITEM,
ACTIVATE_ITEM,
CLEAR_ITEMS, CLEAR_ITEMS,
SET_PREVIEW_SIZE, SET_PREVIEW_SIZE,
LAST_SIGNAL LAST_SIGNAL
@ -64,6 +66,9 @@ static void gimp_container_view_reorder (GimpContainerView *view,
static void gimp_container_view_context_changed (GimpContext *context, static void gimp_container_view_context_changed (GimpContext *context,
GimpViewable *viewable, GimpViewable *viewable,
GimpContainerView *view); GimpContainerView *view);
static void gimp_container_view_drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static guint view_signals[LAST_SIGNAL] = { 0 }; static guint view_signals[LAST_SIGNAL] = { 0 };
@ -150,6 +155,17 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
GIMP_TYPE_OBJECT, GIMP_TYPE_OBJECT,
GTK_TYPE_POINTER); GTK_TYPE_POINTER);
view_signals[ACTIVATE_ITEM] =
gtk_signal_new ("activate_item",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
activate_item),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2,
GIMP_TYPE_OBJECT,
GTK_TYPE_POINTER);
view_signals[CLEAR_ITEMS] = view_signals[CLEAR_ITEMS] =
gtk_signal_new ("clear_items", gtk_signal_new ("clear_items",
GTK_RUN_FIRST, GTK_RUN_FIRST,
@ -176,6 +192,7 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
klass->remove_item = NULL; klass->remove_item = NULL;
klass->reorder_item = NULL; klass->reorder_item = NULL;
klass->select_item = NULL; klass->select_item = NULL;
klass->activate_item = NULL;
klass->clear_items = gimp_container_view_real_clear_items; klass->clear_items = gimp_container_view_real_clear_items;
klass->set_preview_size = NULL; klass->set_preview_size = NULL;
} }
@ -244,6 +261,10 @@ gimp_container_view_set_container (GimpContainerView *view,
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context), gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
gimp_container_view_context_changed, gimp_container_view_context_changed,
view); view);
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
} }
} }
@ -285,6 +306,15 @@ gimp_container_view_set_container (GimpContainerView *view,
gimp_container_view_select_item (view, gimp_container_view_select_item (view,
object ? GIMP_VIEWABLE (object): NULL); object ? GIMP_VIEWABLE (object): NULL);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
gimp_container_view_drop_viewable_callback,
NULL);
} }
} }
} }
@ -305,6 +335,10 @@ gimp_container_view_set_context (GimpContainerView *view,
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context), gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
gimp_container_view_context_changed, gimp_container_view_context_changed,
view); view);
gtk_drag_dest_unset (GTK_WIDGET (view));
gimp_dnd_viewable_dest_unset (GTK_WIDGET (view),
view->container->children_type);
} }
view->context = context; view->context = context;
@ -326,6 +360,15 @@ gimp_container_view_set_context (GimpContainerView *view,
gimp_container_view_select_item (view, gimp_container_view_select_item (view,
object ? GIMP_VIEWABLE (object) : NULL); object ? GIMP_VIEWABLE (object) : NULL);
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view),
GTK_DEST_DEFAULT_ALL,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (view),
view->container->children_type,
gimp_container_view_drop_viewable_callback,
NULL);
} }
} }
@ -358,6 +401,23 @@ gimp_container_view_select_item (GimpContainerView *view,
viewable, insert_data); viewable, insert_data);
} }
void
gimp_container_view_activate_item (GimpContainerView *view,
GimpViewable *viewable)
{
gpointer insert_data;
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
insert_data = g_hash_table_lookup (view->hash_table, viewable);
gtk_signal_emit (GTK_OBJECT (view), view_signals[ACTIVATE_ITEM],
viewable, insert_data);
}
void void
gimp_container_view_item_selected (GimpContainerView *view, gimp_container_view_item_selected (GimpContainerView *view,
GimpViewable *viewable) GimpViewable *viewable)
@ -375,6 +435,18 @@ gimp_container_view_item_selected (GimpContainerView *view,
GIMP_OBJECT (viewable)); GIMP_OBJECT (viewable));
} }
void
gimp_container_view_item_activate (GimpContainerView *view,
GimpViewable *viewable)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
gimp_container_view_activate_item (view, viewable);
}
static void static void
gimp_container_view_clear_items (GimpContainerView *view) gimp_container_view_clear_items (GimpContainerView *view)
{ {
@ -465,3 +537,17 @@ gimp_container_view_context_changed (GimpContext *context,
gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM], gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM],
viewable, insert_data); viewable, insert_data);
} }
static void
gimp_container_view_drop_viewable_callback (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (widget);
gimp_context_set_by_type (view->context,
view->container->children_type,
GIMP_OBJECT (viewable));
}

View File

@ -61,6 +61,9 @@ struct _GimpContainerViewClass
void (* select_item) (GimpContainerView *view, void (* select_item) (GimpContainerView *view,
GimpViewable *object, GimpViewable *object,
gpointer insert_data); gpointer insert_data);
void (* activate_item) (GimpContainerView *view,
GimpViewable *object,
gpointer insert_data);
void (* clear_items) (GimpContainerView *view); void (* clear_items) (GimpContainerView *view);
void (* set_preview_size) (GimpContainerView *view); void (* set_preview_size) (GimpContainerView *view);
}; };
@ -76,12 +79,16 @@ void gimp_container_view_set_preview_size (GimpContainerView *view,
gint preview_size); gint preview_size);
void gimp_container_view_select_item (GimpContainerView *view, void gimp_container_view_select_item (GimpContainerView *view,
GimpViewable *viewable); GimpViewable *viewable);
void gimp_container_view_activate_item (GimpContainerView *view,
GimpViewable *viewable);
/* private */ /* private */
void gimp_container_view_item_selected (GimpContainerView *view, void gimp_container_view_item_selected (GimpContainerView *view,
GimpViewable *item); GimpViewable *item);
void gimp_container_view_item_activate (GimpContainerView *view,
GimpViewable *item);
#endif /* __GIMP_CONTAINER_VIEW_H__ */ #endif /* __GIMP_CONTAINER_VIEW_H__ */

View File

@ -32,6 +32,7 @@
#include "gimpcontainergridview.h" #include "gimpcontainergridview.h"
#include "gimpcontainerlistview.h" #include "gimpcontainerlistview.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "gimpviewable.h" #include "gimpviewable.h"
@ -52,16 +53,29 @@ static void gimp_data_factory_view_new_clicked (GtkWidget *wid
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_duplicate_clicked (GtkWidget *widget, static void gimp_data_factory_view_duplicate_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_data_factory_view_edit_clicked (GtkWidget *widget, static void gimp_data_factory_view_edit_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_data_factory_view_delete_clicked (GtkWidget *widget, static void gimp_data_factory_view_delete_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_data_factory_view_refresh_clicked (GtkWidget *widget, static void gimp_data_factory_view_refresh_clicked (GtkWidget *widget,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_data_changed (GimpContext *context, static void gimp_data_factory_view_data_changed (GimpContext *context,
GimpData *data, GimpData *data,
GimpDataFactoryView *view); GimpDataFactoryView *view);
static void gimp_data_factory_view_data_activate (GtkWidget *context,
GimpData *data,
gpointer insert_data,
GimpDataFactoryView *view);
static GtkVBoxClass *parent_class = NULL; static GtkVBoxClass *parent_class = NULL;
@ -277,6 +291,42 @@ gimp_data_factory_view_new (GimpViewType view_type,
factory_view, factory_view,
GTK_OBJECT (factory_view)); GTK_OBJECT (factory_view));
gtk_signal_connect_while_alive
(GTK_OBJECT (factory_view->view), "activate_item",
GTK_SIGNAL_FUNC (gimp_data_factory_view_data_activate),
factory_view,
GTK_OBJECT (factory_view));
/* drop to "duplicate" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->duplicate_button),
GTK_DEST_DEFAULT_ALL,
factory_view->factory->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->duplicate_button),
factory_view->factory->container->children_type,
gimp_data_factory_view_duplicate_dropped,
factory_view);
/* drop to "edit" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->edit_button),
GTK_DEST_DEFAULT_ALL,
factory_view->factory->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->edit_button),
factory_view->factory->container->children_type,
gimp_data_factory_view_edit_dropped,
factory_view);
/* drop to "delete" */
gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->delete_button),
GTK_DEST_DEFAULT_ALL,
factory_view->factory->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->delete_button),
factory_view->factory->container->children_type,
gimp_data_factory_view_delete_dropped,
factory_view);
/* set button sensitivity */ /* set button sensitivity */
gimp_data_factory_view_data_changed gimp_data_factory_view_data_changed
(context, (context,
@ -346,6 +396,26 @@ gimp_data_factory_view_duplicate_clicked (GtkWidget *widget,
} }
} }
static void
gimp_data_factory_view_duplicate_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) data;
if (viewable && gimp_container_have (view->factory->container,
GIMP_OBJECT (viewable)))
{
gimp_context_set_by_type (view->view->context,
view->factory->container->children_type,
GIMP_OBJECT (viewable));
gimp_data_factory_view_duplicate_clicked (NULL, data);
}
}
static void static void
gimp_data_factory_view_edit_clicked (GtkWidget *widget, gimp_data_factory_view_edit_clicked (GtkWidget *widget,
GimpDataFactoryView *view) GimpDataFactoryView *view)
@ -365,6 +435,26 @@ gimp_data_factory_view_edit_clicked (GtkWidget *widget,
} }
} }
static void
gimp_data_factory_view_edit_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) data;
if (viewable && gimp_container_have (view->factory->container,
GIMP_OBJECT (viewable)))
{
gimp_context_set_by_type (view->view->context,
view->factory->container->children_type,
GIMP_OBJECT (viewable));
gimp_data_factory_view_edit_clicked (NULL, data);
}
}
typedef struct _GimpDataDeleteData GimpDataDeleteData; typedef struct _GimpDataDeleteData GimpDataDeleteData;
@ -444,6 +534,26 @@ gimp_data_factory_view_delete_clicked (GtkWidget *widget,
} }
} }
static void
gimp_data_factory_view_delete_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpDataFactoryView *view;
view = (GimpDataFactoryView *) data;
if (viewable && gimp_container_have (view->factory->container,
GIMP_OBJECT (viewable)))
{
gimp_context_set_by_type (view->view->context,
view->factory->container->children_type,
GIMP_OBJECT (viewable));
gimp_data_factory_view_delete_clicked (NULL, data);
}
}
static void static void
gimp_data_factory_view_refresh_clicked (GtkWidget *widget, gimp_data_factory_view_refresh_clicked (GtkWidget *widget,
GimpDataFactoryView *view) GimpDataFactoryView *view)
@ -466,11 +576,24 @@ gimp_data_factory_view_data_changed (GimpContext *context,
duplicate_sensitive = duplicate_sensitive =
(GIMP_DATA_CLASS (GTK_OBJECT (data)->klass)->duplicate != NULL); (GIMP_DATA_CLASS (GTK_OBJECT (data)->klass)->duplicate != NULL);
edit_sensitive = (view->data_edit_func != NULL); edit_sensitive = (view->data_edit_func != NULL);
delete_sensitive = TRUE; /* TODO: check permissions */ delete_sensitive = TRUE; /* TODO: check permissions */
} }
gtk_widget_set_sensitive (view->duplicate_button, duplicate_sensitive); gtk_widget_set_sensitive (view->duplicate_button, duplicate_sensitive);
gtk_widget_set_sensitive (view->edit_button, edit_sensitive); gtk_widget_set_sensitive (view->edit_button, edit_sensitive);
gtk_widget_set_sensitive (view->delete_button, delete_sensitive); gtk_widget_set_sensitive (view->delete_button, delete_sensitive);
} }
static void
gimp_data_factory_view_data_activate (GtkWidget *widget,
GimpData *data,
gpointer insert_data,
GimpDataFactoryView *view)
{
if (data && gimp_container_have (view->factory->container,
GIMP_OBJECT (data)))
{
gimp_data_factory_view_edit_clicked (NULL, view);
}
}

View File

@ -624,6 +624,79 @@ gimp_dnd_color_dest_unset (GtkWidget *widget)
/* GimpViewable (by GtkType) dnd functions */ /* GimpViewable (by GtkType) dnd functions */
/*********************************************/ /*********************************************/
static const GtkTargetEntry brush_target_table[] =
{
GIMP_TARGET_BRUSH
};
static const guint brush_n_targets = (sizeof (brush_target_table) /
sizeof (brush_target_table[0]));
static const GtkTargetEntry pattern_target_table[] =
{
GIMP_TARGET_PATTERN
};
static const guint pattern_n_targets = (sizeof (pattern_target_table) /
sizeof (pattern_target_table[0]));
static const GtkTargetEntry gradient_target_table[] =
{
GIMP_TARGET_GRADIENT
};
static const guint gradient_n_targets = (sizeof (gradient_target_table) /
sizeof (gradient_target_table[0]));
static const GtkTargetEntry palette_target_table[] =
{
GIMP_TARGET_PALETTE
};
static const guint palette_n_targets = (sizeof (palette_target_table) /
sizeof (palette_target_table[0]));
void
gimp_gtk_drag_source_set_by_type (GtkWidget *widget,
GdkModifierType start_button_mask,
GtkType type,
GdkDragAction actions)
{
const GtkTargetEntry *target_table = NULL;
guint n_targets = 0;
if (type == GIMP_TYPE_BRUSH)
{
target_table = brush_target_table;
n_targets = brush_n_targets;
}
else if (type == GIMP_TYPE_PATTERN)
{
target_table = pattern_target_table;
n_targets = pattern_n_targets;
}
else if (type == GIMP_TYPE_GRADIENT)
{
target_table = gradient_target_table;
n_targets = gradient_n_targets;
}
else if (type == GIMP_TYPE_PALETTE)
{
target_table = palette_target_table;
n_targets = palette_n_targets;
}
else
{
g_warning ("%s(): unsupported GtkType", G_GNUC_FUNCTION);
}
if (target_table && n_targets)
{
gtk_drag_source_set (widget, start_button_mask,
target_table,
n_targets,
actions);
}
}
void void
gimp_gtk_drag_dest_set_by_type (GtkWidget *widget, gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
GtkDestDefaults flags, GtkDestDefaults flags,
@ -633,34 +706,6 @@ gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
const GtkTargetEntry *target_table = NULL; const GtkTargetEntry *target_table = NULL;
guint n_targets = 0; guint n_targets = 0;
static const GtkTargetEntry brush_target_table[] =
{
GIMP_TARGET_BRUSH
};
static const guint brush_n_targets = (sizeof (brush_target_table) /
sizeof (brush_target_table[0]));
static const GtkTargetEntry pattern_target_table[] =
{
GIMP_TARGET_PATTERN
};
static const guint pattern_n_targets = (sizeof (pattern_target_table) /
sizeof (pattern_target_table[0]));
static const GtkTargetEntry gradient_target_table[] =
{
GIMP_TARGET_GRADIENT
};
static const guint gradient_n_targets = (sizeof (gradient_target_table) /
sizeof (gradient_target_table[0]));
static const GtkTargetEntry palette_target_table[] =
{
GIMP_TARGET_PALETTE
};
static const guint palette_n_targets = (sizeof (palette_target_table) /
sizeof (palette_target_table[0]));
if (type == GIMP_TYPE_BRUSH) if (type == GIMP_TYPE_BRUSH)
{ {
target_table = brush_target_table; target_table = brush_target_table;
@ -695,6 +740,42 @@ gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
} }
} }
void
gimp_dnd_viewable_source_set (GtkWidget *widget,
GtkType type,
GimpDndDragViewableFunc get_viewable_func,
gpointer data)
{
if (type == GIMP_TYPE_BRUSH)
{
gimp_dnd_brush_source_set (widget,
(GimpDndDragBrushFunc) get_viewable_func,
data);
}
else if (type == GIMP_TYPE_PATTERN)
{
gimp_dnd_pattern_source_set (widget,
(GimpDndDragPatternFunc) get_viewable_func,
data);
}
else if (type == GIMP_TYPE_GRADIENT)
{
gimp_dnd_gradient_source_set (widget,
(GimpDndDragGradientFunc) get_viewable_func,
data);
}
else if (type == GIMP_TYPE_PALETTE)
{
gimp_dnd_palette_source_set (widget,
(GimpDndDragPaletteFunc) get_viewable_func,
data);
}
else
{
g_warning ("%s(): unsupported GtkType", G_GNUC_FUNCTION);
}
}
void void
gimp_dnd_viewable_dest_set (GtkWidget *widget, gimp_dnd_viewable_dest_set (GtkWidget *widget,
GtkType type, GtkType type,

View File

@ -113,20 +113,31 @@ void gimp_dnd_color_dest_unset (GtkWidget *widget);
/* GimpViewable (by GtkType) dnd functions */ /* GimpViewable (by GtkType) dnd functions */
typedef void (* GimpDndDropViewableFunc) (GtkWidget *widget, typedef void (* GimpDndDropViewableFunc) (GtkWidget *widget,
GimpViewable *viewable, GimpViewable *viewable,
gpointer data); gpointer data);
typedef GimpViewable * (* GimpDndDragViewableFunc) (GtkWidget *widget,
gpointer data);
void gimp_gtk_drag_dest_set_by_type (GtkWidget *widget, void gimp_gtk_drag_source_set_by_type (GtkWidget *widget,
GtkDestDefaults flags, GdkModifierType start_button_mask,
GtkType type, GtkType type,
GdkDragAction actions); GdkDragAction actions);
void gimp_dnd_viewable_dest_set (GtkWidget *widget, void gimp_gtk_drag_dest_set_by_type (GtkWidget *widget,
GtkType type, GtkDestDefaults flags,
GimpDndDropViewableFunc set_viewable_func, GtkType type,
gpointer data); GdkDragAction actions);
void gimp_dnd_viewable_dest_unset (GtkWidget *widget,
GtkType type); void gimp_dnd_viewable_source_set (GtkWidget *widget,
GtkType type,
GimpDndDragViewableFunc get_viewable_func,
gpointer data);
void gimp_dnd_viewable_dest_set (GtkWidget *widget,
GtkType type,
GimpDndDropViewableFunc set_viewable_func,
gpointer data);
void gimp_dnd_viewable_dest_unset (GtkWidget *widget,
GtkType type);
/* brush dnd functions */ /* brush dnd functions */

View File

@ -2933,7 +2933,8 @@ cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_block_by_data gtk_signal_handler_block_by_data
(GTK_OBJECT (gradient_editor->control_blending_items[i]), (gpointer) i); (GTK_OBJECT (gradient_editor->control_blending_items[i]),
gradient_editor);
/* Set state */ /* Set state */
if (equal) if (equal)
@ -2949,7 +2950,8 @@ cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
/* Unblock signals */ /* Unblock signals */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]), (gpointer) i); gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]),
gradient_editor);
} }
static void static void
@ -2968,7 +2970,8 @@ cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
coloring = (int) gradient_editor->control_sel_l->color; coloring = (int) gradient_editor->control_sel_l->color;
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]), (gpointer) i); gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
gradient_editor);
/* Set state */ /* Set state */
if (equal) if (equal)
@ -2984,7 +2987,8 @@ cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
/* Unblock signals */ /* Unblock signals */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]), (gpointer) i); gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
gradient_editor);
} }
static void static void

View File

@ -42,7 +42,7 @@ static void gimp_gradient_preview_get_size (GimpPreview *preview,
static gboolean gimp_gradient_preview_needs_popup (GimpPreview *preview); static gboolean gimp_gradient_preview_needs_popup (GimpPreview *preview);
static GtkWidget * gimp_gradient_preview_create_popup (GimpPreview *preview); static GtkWidget * gimp_gradient_preview_create_popup (GimpPreview *preview);
static GimpGradient * gimp_gradient_preview_drag_gradient (GtkWidget *widget, static GimpViewable * gimp_gradient_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
@ -94,20 +94,14 @@ gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass)
static void static void
gimp_gradient_preview_init (GimpGradientPreview *gradient_preview) gimp_gradient_preview_init (GimpGradientPreview *gradient_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (gradient_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_GRADIENT GIMP_TYPE_GRADIENT,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (gradient_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_GRADIENT,
gimp_gradient_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (gradient_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_gradient_source_set (GTK_WIDGET (gradient_preview),
gimp_gradient_preview_drag_gradient,
gradient_preview);
} }
static void static void
@ -181,13 +175,9 @@ gimp_gradient_preview_create_popup (GimpPreview *preview)
TRUE, FALSE, FALSE); TRUE, FALSE, FALSE);
} }
static GimpGradient * static GimpViewable *
gimp_gradient_preview_drag_gradient (GtkWidget *widget, gimp_gradient_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_GRADIENT (preview->viewable);
} }

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,8 @@ static void gimp_palette_preview_render (GimpPreview *preview);
static GtkWidget * gimp_palette_preview_create_popup (GimpPreview *preview); static GtkWidget * gimp_palette_preview_create_popup (GimpPreview *preview);
static gboolean gimp_palette_preview_needs_popup (GimpPreview *preview); static gboolean gimp_palette_preview_needs_popup (GimpPreview *preview);
static GimpPalette * gimp_palette_preview_drag_palette (GtkWidget *widget, static GimpViewable * gimp_palette_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -89,20 +89,14 @@ gimp_palette_preview_class_init (GimpPalettePreviewClass *klass)
static void static void
gimp_palette_preview_init (GimpPalettePreview *palette_preview) gimp_palette_preview_init (GimpPalettePreview *palette_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (palette_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_PALETTE GIMP_TYPE_PALETTE,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (palette_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_PALETTE,
gimp_palette_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (palette_preview), palette_preview);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_palette_source_set (GTK_WIDGET (palette_preview),
gimp_palette_preview_drag_palette,
palette_preview);
} }
static void static void
@ -176,13 +170,9 @@ gimp_palette_preview_needs_popup (GimpPreview *preview)
return FALSE; return FALSE;
} }
static GimpPalette * static GimpViewable *
gimp_palette_preview_drag_palette (GtkWidget *widget, gimp_palette_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_PALETTE (preview->viewable);
} }

View File

@ -34,12 +34,12 @@
static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass); static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass);
static void gimp_pattern_preview_init (GimpPatternPreview *preview); static void gimp_pattern_preview_init (GimpPatternPreview *preview);
static void gimp_pattern_preview_render (GimpPreview *preview); static void gimp_pattern_preview_render (GimpPreview *preview);
static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview); static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview);
static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview); static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview);
static GimpPattern * gimp_pattern_preview_drag_pattern (GtkWidget *widget, static GimpViewable * gimp_pattern_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -89,20 +89,14 @@ gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass)
static void static void
gimp_pattern_preview_init (GimpPatternPreview *pattern_preview) gimp_pattern_preview_init (GimpPatternPreview *pattern_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (pattern_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_PATTERN GIMP_TYPE_PATTERN,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (pattern_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_PATTERN,
gimp_pattern_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (pattern_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_pattern_source_set (GTK_WIDGET (pattern_preview),
gimp_pattern_preview_drag_pattern,
pattern_preview);
} }
static void static void
@ -184,13 +178,9 @@ gimp_pattern_preview_needs_popup (GimpPreview *preview)
return FALSE; return FALSE;
} }
static GimpPattern * static GimpViewable *
gimp_pattern_preview_drag_pattern (GtkWidget *widget, gimp_pattern_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_PATTERN (preview->viewable);
} }

View File

@ -41,8 +41,8 @@ static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview)
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview); static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview); static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview);
static GimpBrush * gimp_brush_preview_drag_brush (GtkWidget *widget, static GimpViewable * gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -94,20 +94,14 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
static void static void
gimp_brush_preview_init (GimpBrushPreview *brush_preview) gimp_brush_preview_init (GimpBrushPreview *brush_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (brush_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_BRUSH GIMP_TYPE_BRUSH,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (brush_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_BRUSH,
gimp_brush_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (brush_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_source_set (GTK_WIDGET (brush_preview),
gimp_brush_preview_drag_brush,
brush_preview);
brush_preview->pipe_timeout_id = 0; brush_preview->pipe_timeout_id = 0;
brush_preview->pipe_animation_index = 0; brush_preview->pipe_animation_index = 0;
@ -379,13 +373,9 @@ gimp_brush_preview_render_timeout_func (GimpBrushPreview *brush_preview)
return TRUE; return TRUE;
} }
static GimpBrush * static GimpViewable *
gimp_brush_preview_drag_brush (GtkWidget *widget, gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_BRUSH (preview->viewable);
} }

View File

@ -41,8 +41,8 @@ static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview)
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview); static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview); static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview);
static GimpBrush * gimp_brush_preview_drag_brush (GtkWidget *widget, static GimpViewable * gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data); gpointer data);
static GimpPreviewClass *parent_class = NULL; static GimpPreviewClass *parent_class = NULL;
@ -94,20 +94,14 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
static void static void
gimp_brush_preview_init (GimpBrushPreview *brush_preview) gimp_brush_preview_init (GimpBrushPreview *brush_preview)
{ {
static GtkTargetEntry preview_target_table[] = gimp_gtk_drag_source_set_by_type (GTK_WIDGET (brush_preview),
{ GDK_BUTTON2_MASK,
GIMP_TARGET_BRUSH GIMP_TYPE_BRUSH,
}; GDK_ACTION_COPY);
static guint preview_n_targets = (sizeof (preview_target_table) / gimp_dnd_viewable_source_set (GTK_WIDGET (brush_preview),
sizeof (preview_target_table[0])); GIMP_TYPE_BRUSH,
gimp_brush_preview_drag_viewable,
gtk_drag_source_set (GTK_WIDGET (brush_preview), NULL);
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_source_set (GTK_WIDGET (brush_preview),
gimp_brush_preview_drag_brush,
brush_preview);
brush_preview->pipe_timeout_id = 0; brush_preview->pipe_timeout_id = 0;
brush_preview->pipe_animation_index = 0; brush_preview->pipe_animation_index = 0;
@ -379,13 +373,9 @@ gimp_brush_preview_render_timeout_func (GimpBrushPreview *brush_preview)
return TRUE; return TRUE;
} }
static GimpBrush * static GimpViewable *
gimp_brush_preview_drag_brush (GtkWidget *widget, gimp_brush_preview_drag_viewable (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpPreview *preview; return GIMP_PREVIEW (widget)->viewable;
preview = GIMP_PREVIEW (data);
return GIMP_BRUSH (preview->viewable);
} }

View File

@ -97,11 +97,12 @@ scriptdata_DATA = \
unsharp-mask.scm \ unsharp-mask.scm \
waves-anim.scm \ waves-anim.scm \
weave.scm \ weave.scm \
xach-effect.scm xach-effect.scm \
\
EXTRA_DIST = $(scriptdata_DATA) \
test-sphere.scm test-sphere.scm
EXTRA_DIST = $(scriptdata_DATA)
files: files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \ @files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \ echo $$p; \