Commit bf8759df authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

libgimp/gimpdrawablecombobox.c accept DND of image / drawable IDs.

2005-03-26  Sven Neumann  <sven@gimp.org>

	* libgimp/gimpdrawablecombobox.c
	* libgimp/gimpimagecombobox.c: accept DND of image / drawable IDs.
parent deb8eaea
2005-03-26 Sven Neumann <sven@gimp.org>
* libgimp/gimpdrawablecombobox.c
* libgimp/gimpimagecombobox.c: accept DND of image / drawable IDs.
2005-03-26 Sven Neumann <sven@gimp.org>
* app/widgets/gimptoolbox-image-area.c: added a hint about XDS to
......
......@@ -22,6 +22,8 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -43,6 +45,21 @@ static gint gimp_drawable_combo_box_model_add (GtkListStore *stor
GimpDrawableConstraintFunc constraint,
gpointer data);
static void gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time);
static const GtkTargetEntry targets[] =
{
{ "application/x-gimp-channel-id", 0 },
{ "application/x-gimp-layer-id", 0 }
};
/**
* gimp_drawable_combo_box_new:
......@@ -108,6 +125,17 @@ gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets, 2,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_drawable_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -161,6 +189,17 @@ gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets, 1,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_drawable_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -214,6 +253,17 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets + 1, 1,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_drawable_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -266,3 +316,28 @@ gimp_drawable_combo_box_model_add (GtkListStore *store,
return added;
}
static void
gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time)
{
gchar *id;
gint ID;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid drawable ID data!");
return;
}
id = g_strndup (selection->data, selection->length);
ID = atoi (id);
g_free (id);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (widget), ID);
}
......@@ -22,6 +22,8 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -42,6 +44,17 @@ static void gimp_image_combo_box_model_add (GtkListStore *store,
GimpImageConstraintFunc constraint,
gpointer data);
static void gimp_image_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time);
static const GtkTargetEntry target = { "application/x-gimp-image-id", 0 };
/**
* gimp_image_combo_box_new:
......@@ -89,6 +102,17 @@ gimp_image_combo_box_new (GimpImageConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
&target, 1,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_image_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -132,3 +156,28 @@ gimp_image_combo_box_model_add (GtkListStore *store,
}
}
}
static void
gimp_image_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time)
{
gchar *id;
gint ID;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid image ID data!");
return;
}
id = g_strndup (selection->data, selection->length);
ID = atoi (id);
g_free (id);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (widget), ID);
}
......@@ -22,6 +22,8 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -43,6 +45,21 @@ static gint gimp_drawable_combo_box_model_add (GtkListStore *stor
GimpDrawableConstraintFunc constraint,
gpointer data);
static void gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time);
static const GtkTargetEntry targets[] =
{
{ "application/x-gimp-channel-id", 0 },
{ "application/x-gimp-layer-id", 0 }
};
/**
* gimp_drawable_combo_box_new:
......@@ -108,6 +125,17 @@ gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets, 2,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_drawable_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -161,6 +189,17 @@ gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets, 1,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_drawable_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -214,6 +253,17 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_drag_dest_set (combo_box,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets + 1, 1,
GDK_ACTION_COPY);
g_signal_connect (combo_box, "drag-data-received",
G_CALLBACK (gimp_drawable_combo_box_drag_data_received),
NULL);
return combo_box;
}
......@@ -266,3 +316,28 @@ gimp_drawable_combo_box_model_add (GtkListStore *store,
return added;
}
static void
gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time)
{
gchar *id;
gint ID;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid drawable ID data!");
return;
}
id = g_strndup (selection->data, selection->length);
ID = atoi (id);
g_free (id);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (widget), ID);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment