2004-04-21 06:14:49 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
2006-11-16 07:20:06 +08:00
|
|
|
* gimpitemcombobox.c
|
2004-04-21 06:14:49 +08:00
|
|
|
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
2006-11-16 07:20:06 +08:00
|
|
|
* Copyright (C) 2006 Simon Budig <simon@gimp.org>
|
2004-04-21 06:14:49 +08:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2005-03-26 22:05:03 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-04-21 06:14:49 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
|
2005-06-04 07:38:45 +08:00
|
|
|
#include "gimpuitypes.h"
|
2006-11-16 07:20:06 +08:00
|
|
|
#include "gimpitemcombobox.h"
|
2004-04-21 06:14:49 +08:00
|
|
|
#include "gimppixbuf.h"
|
|
|
|
|
|
|
|
|
2005-03-03 08:06:28 +08:00
|
|
|
#define THUMBNAIL_SIZE 24
|
|
|
|
#define WIDTH_REQUEST 200
|
2004-04-21 06:14:49 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DRAWABLE_COMBO_BOX,
|
|
|
|
CHANNEL_COMBO_BOX,
|
|
|
|
LAYER_COMBO_BOX,
|
|
|
|
VECTORS_COMBO_BOX
|
|
|
|
} GimpComboBoxType;
|
|
|
|
|
2004-04-21 06:14:49 +08:00
|
|
|
|
2005-06-04 07:38:45 +08:00
|
|
|
typedef struct _GimpDrawableComboBoxClass GimpDrawableComboBoxClass;
|
|
|
|
typedef struct _GimpChannelComboBoxClass GimpChannelComboBoxClass;
|
|
|
|
typedef struct _GimpLayerComboBoxClass GimpLayerComboBoxClass;
|
2006-11-16 07:20:06 +08:00
|
|
|
typedef struct _GimpVectorsComboBoxClass GimpVectorsComboBoxClass;
|
2005-06-04 07:38:45 +08:00
|
|
|
|
|
|
|
struct _GimpDrawableComboBox
|
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
GimpIntComboBox parent_instance;
|
2005-06-04 07:38:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpDrawableComboBoxClass
|
|
|
|
{
|
|
|
|
GimpIntComboBoxClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpChannelComboBox
|
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
GimpIntComboBox parent_instance;
|
2005-06-04 07:38:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpChannelComboBoxClass
|
|
|
|
{
|
|
|
|
GimpIntComboBoxClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpLayerComboBox
|
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
GimpIntComboBox parent_instance;
|
2005-06-04 07:38:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpLayerComboBoxClass
|
|
|
|
{
|
|
|
|
GimpIntComboBoxClass parent_class;
|
|
|
|
};
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
struct _GimpVectorsComboBox
|
|
|
|
{
|
|
|
|
GimpIntComboBox parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpVectorsComboBoxClass
|
|
|
|
{
|
|
|
|
GimpIntComboBoxClass parent_class;
|
|
|
|
};
|
|
|
|
|
2005-06-04 07:38:45 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
static GtkWidget * gimp_item_combo_box_new (GimpComboBoxType type,
|
|
|
|
GimpItemConstraintFunc constraint,
|
|
|
|
gpointer data);
|
2004-04-21 06:14:49 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
static void gimp_item_combo_box_model_add (GtkListStore *store,
|
|
|
|
gint32 image,
|
|
|
|
gint num_items,
|
|
|
|
gint32 *items,
|
|
|
|
GimpComboBoxType type,
|
|
|
|
GimpItemConstraintFunc constraint,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void gimp_item_combo_box_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection,
|
|
|
|
guint info,
|
|
|
|
guint time);
|
2005-03-26 22:05:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
static const GtkTargetEntry targets[] =
|
|
|
|
{
|
|
|
|
{ "application/x-gimp-channel-id", 0 },
|
2006-11-16 07:20:06 +08:00
|
|
|
{ "application/x-gimp-layer-id", 0 },
|
|
|
|
{ "application/x-gimp-vectors-id", 0 }
|
2005-03-26 22:05:03 +08:00
|
|
|
};
|
|
|
|
|
2004-04-21 06:14:49 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpDrawableComboBox, gimp_drawable_combo_box,
|
|
|
|
GIMP_TYPE_INT_COMBO_BOX)
|
|
|
|
|
2005-06-04 07:38:45 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_combo_box_class_init (GimpDrawableComboBoxClass *klass)
|
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2005-06-04 07:38:45 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
2005-06-04 07:38:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_combo_box_init (GimpDrawableComboBox *combo_box)
|
|
|
|
{
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (combo_box),
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
targets, 2,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
}
|
|
|
|
|
2004-04-21 19:51:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_combo_box_new:
|
|
|
|
* @constraint: a #GimpDrawableConstraintFunc or %NULL
|
|
|
|
* @data: a pointer that is passed to @constraint
|
|
|
|
*
|
|
|
|
* Creates a new #GimpIntComboBox filled with all currently opened
|
|
|
|
* drawables. If a @constraint function is specified, it is called for
|
|
|
|
* each drawable and only if the function returns %TRUE, the drawable
|
|
|
|
* is added to the combobox.
|
|
|
|
*
|
2004-12-13 20:38:26 +08:00
|
|
|
* You should use gimp_int_combo_box_connect() to initialize and connect
|
2004-10-29 04:58:16 +08:00
|
|
|
* the combo. Use gimp_int_combo_box_set_active() to get the active
|
|
|
|
* drawable ID and gimp_int_combo_box_get_active() to retrieve the ID
|
|
|
|
* of the selected drawable.
|
2004-04-21 19:51:21 +08:00
|
|
|
*
|
|
|
|
* Return value: a new #GimpIntComboBox.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.2
|
|
|
|
**/
|
2004-04-21 06:14:49 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
return gimp_item_combo_box_new (DRAWABLE_COMBO_BOX, constraint, data);
|
2005-06-04 07:38:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(GimpChannelComboBox,
|
|
|
|
gimp_channel_combo_box,
|
2006-04-12 18:53:28 +08:00
|
|
|
GIMP_TYPE_INT_COMBO_BOX);
|
2005-06-04 07:38:45 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_channel_combo_box_class_init (GimpChannelComboBoxClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
2005-06-04 07:38:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_channel_combo_box_init (GimpChannelComboBox *combo_box)
|
|
|
|
{
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (combo_box),
|
2005-03-26 22:05:03 +08:00
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
2005-06-04 07:38:45 +08:00
|
|
|
targets, 1,
|
2005-03-26 22:05:03 +08:00
|
|
|
GDK_ACTION_COPY);
|
2004-04-21 06:14:49 +08:00
|
|
|
}
|
|
|
|
|
2004-04-21 19:51:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_channel_combo_box_new:
|
|
|
|
* @constraint: a #GimpDrawableConstraintFunc or %NULL
|
|
|
|
* @data: a pointer that is passed to @constraint
|
|
|
|
*
|
|
|
|
* Creates a new #GimpIntComboBox filled with all currently opened
|
2008-06-03 21:46:50 +08:00
|
|
|
* channels. See gimp_drawable_combo_box_new() for more information.
|
2004-04-21 19:51:21 +08:00
|
|
|
*
|
|
|
|
* Return value: a new #GimpIntComboBox.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.2
|
|
|
|
**/
|
2004-04-21 06:14:49 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
return gimp_item_combo_box_new (CHANNEL_COMBO_BOX, constraint, data);
|
2005-06-04 07:38:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(GimpLayerComboBox,
|
|
|
|
gimp_layer_combo_box,
|
2006-04-12 18:53:28 +08:00
|
|
|
GIMP_TYPE_INT_COMBO_BOX);
|
2005-06-04 07:38:45 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_combo_box_class_init (GimpLayerComboBoxClass *klass)
|
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2005-06-04 07:38:45 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
2005-06-04 07:38:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_combo_box_init (GimpLayerComboBox *combo_box)
|
|
|
|
{
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (combo_box),
|
2005-03-26 22:05:03 +08:00
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
2005-06-04 07:38:45 +08:00
|
|
|
targets + 1, 1,
|
2005-03-26 22:05:03 +08:00
|
|
|
GDK_ACTION_COPY);
|
2004-04-21 06:14:49 +08:00
|
|
|
}
|
|
|
|
|
2004-04-21 19:51:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_layer_combo_box_new:
|
|
|
|
* @constraint: a #GimpDrawableConstraintFunc or %NULL
|
|
|
|
* @data: a pointer that is passed to @constraint
|
|
|
|
*
|
|
|
|
* Creates a new #GimpIntComboBox filled with all currently opened
|
2008-06-03 21:46:50 +08:00
|
|
|
* layers. See gimp_drawable_combo_box_new() for more information.
|
2004-04-21 19:51:21 +08:00
|
|
|
*
|
|
|
|
* Return value: a new #GimpIntComboBox.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.2
|
|
|
|
**/
|
2004-04-21 06:14:49 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
return gimp_item_combo_box_new (LAYER_COMBO_BOX, constraint, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpVectorsComboBox, gimp_vectors_combo_box,
|
|
|
|
GIMP_TYPE_INT_COMBO_BOX)
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_vectors_combo_box_class_init (GimpVectorsComboBoxClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_vectors_combo_box_init (GimpVectorsComboBox *combo_box)
|
|
|
|
{
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (combo_box),
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
targets + 2, 1,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_combo_box_new:
|
|
|
|
* @constraint: a #GimpVectorsConstraintFunc or %NULL
|
|
|
|
* @data: a pointer that is passed to @constraint
|
|
|
|
*
|
|
|
|
* Creates a new #GimpIntComboBox filled with all currently opened
|
|
|
|
* vectors objects. If a @constraint function is specified, it is called for
|
|
|
|
* each vectors object and only if the function returns %TRUE, the vectors
|
|
|
|
* object is added to the combobox.
|
|
|
|
*
|
|
|
|
* You should use gimp_int_combo_box_connect() to initialize and connect
|
|
|
|
* the combo. Use gimp_int_combo_box_set_active() to set the active
|
|
|
|
* vectors ID and gimp_int_combo_box_get_active() to retrieve the ID
|
|
|
|
* of the selected vectors object.
|
|
|
|
*
|
|
|
|
* Return value: a new #GimpIntComboBox.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_vectors_combo_box_new (GimpVectorsConstraintFunc constraint,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
return gimp_item_combo_box_new (VECTORS_COMBO_BOX, constraint, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_item_combo_box_new (GimpComboBoxType type,
|
|
|
|
GimpItemConstraintFunc constraint,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2007-04-12 22:32:44 +08:00
|
|
|
GType combo_box_type = G_TYPE_NONE;
|
2004-04-21 06:14:49 +08:00
|
|
|
GtkWidget *combo_box;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gint32 *images;
|
|
|
|
gint num_images;
|
|
|
|
gint i;
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case DRAWABLE_COMBO_BOX:
|
|
|
|
combo_box_type = GIMP_TYPE_DRAWABLE_COMBO_BOX;
|
|
|
|
break;
|
|
|
|
case CHANNEL_COMBO_BOX:
|
|
|
|
combo_box_type = GIMP_TYPE_CHANNEL_COMBO_BOX;
|
|
|
|
break;
|
|
|
|
case LAYER_COMBO_BOX:
|
|
|
|
combo_box_type = GIMP_TYPE_LAYER_COMBO_BOX;
|
|
|
|
break;
|
|
|
|
case VECTORS_COMBO_BOX:
|
|
|
|
combo_box_type = GIMP_TYPE_VECTORS_COMBO_BOX;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
combo_box = g_object_new (combo_box_type,
|
2005-03-03 08:06:28 +08:00
|
|
|
"width-request", WIDTH_REQUEST,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
2005-02-28 03:41:42 +08:00
|
|
|
NULL);
|
2004-04-21 06:14:49 +08:00
|
|
|
|
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
images = gimp_image_list (&num_images);
|
|
|
|
|
|
|
|
for (i = 0; i < num_images; i++)
|
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
gint32 *items;
|
|
|
|
gint num_items;
|
|
|
|
|
|
|
|
if (type == DRAWABLE_COMBO_BOX ||
|
|
|
|
type == LAYER_COMBO_BOX)
|
|
|
|
{
|
|
|
|
items = gimp_image_get_layers (images[i], &num_items);
|
|
|
|
gimp_item_combo_box_model_add (GTK_LIST_STORE (model),
|
|
|
|
images[i],
|
|
|
|
num_items, items, type,
|
|
|
|
constraint, data);
|
|
|
|
g_free (items);
|
|
|
|
}
|
2004-04-21 06:14:49 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
if (type == DRAWABLE_COMBO_BOX ||
|
|
|
|
type == CHANNEL_COMBO_BOX)
|
|
|
|
{
|
|
|
|
items = gimp_image_get_channels (images[i], &num_items);
|
|
|
|
gimp_item_combo_box_model_add (GTK_LIST_STORE (model),
|
2004-04-22 23:25:01 +08:00
|
|
|
images[i],
|
2006-11-16 07:20:06 +08:00
|
|
|
num_items, items, type,
|
2004-04-22 23:25:01 +08:00
|
|
|
constraint, data);
|
2006-11-16 07:20:06 +08:00
|
|
|
g_free (items);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == VECTORS_COMBO_BOX)
|
|
|
|
{
|
|
|
|
items = gimp_image_get_vectors (images[i], &num_items);
|
|
|
|
gimp_item_combo_box_model_add (GTK_LIST_STORE (model),
|
|
|
|
images[i],
|
|
|
|
num_items, items, type,
|
|
|
|
constraint, data);
|
|
|
|
g_free (items);
|
|
|
|
}
|
2004-04-21 06:14:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (images);
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_first (model, &iter))
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
|
|
|
|
|
|
|
|
return combo_box;
|
|
|
|
}
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
|
2005-06-04 07:38:45 +08:00
|
|
|
static void
|
2006-11-16 07:20:06 +08:00
|
|
|
gimp_item_combo_box_model_add (GtkListStore *store,
|
|
|
|
gint32 image,
|
|
|
|
gint num_items,
|
|
|
|
gint32 *items,
|
|
|
|
GimpComboBoxType type,
|
|
|
|
GimpItemConstraintFunc constraint,
|
|
|
|
gpointer data)
|
2004-04-21 06:14:49 +08:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gint i;
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
for (i = 0; i < num_items; i++)
|
2004-04-21 06:14:49 +08:00
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
if (! constraint || (* constraint) (image, items[i], data))
|
2004-04-21 06:14:49 +08:00
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
gchar *image_name = gimp_image_get_name (image);
|
|
|
|
gchar *item_name;
|
2004-04-21 06:14:49 +08:00
|
|
|
gchar *label;
|
|
|
|
GdkPixbuf *thumb;
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
if (type == VECTORS_COMBO_BOX)
|
|
|
|
item_name = gimp_vectors_get_name (items[i]);
|
|
|
|
else
|
|
|
|
item_name = gimp_drawable_get_name (items[i]);
|
|
|
|
|
2004-04-21 06:14:49 +08:00
|
|
|
label = g_strdup_printf ("%s-%d/%s-%d",
|
2006-11-16 07:20:06 +08:00
|
|
|
image_name, image,
|
|
|
|
item_name, items[i]);
|
2004-04-21 06:14:49 +08:00
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
g_free (item_name);
|
2004-04-21 06:14:49 +08:00
|
|
|
g_free (image_name);
|
|
|
|
|
2006-11-16 07:20:06 +08:00
|
|
|
if (type == VECTORS_COMBO_BOX)
|
|
|
|
thumb = NULL;
|
|
|
|
else
|
|
|
|
thumb = gimp_drawable_get_thumbnail (items[i],
|
|
|
|
THUMBNAIL_SIZE, THUMBNAIL_SIZE,
|
|
|
|
GIMP_PIXBUF_SMALL_CHECKS);
|
2004-04-21 06:14:49 +08:00
|
|
|
|
|
|
|
gtk_list_store_append (store, &iter);
|
|
|
|
gtk_list_store_set (store, &iter,
|
2006-11-16 07:20:06 +08:00
|
|
|
GIMP_INT_STORE_VALUE, items[i],
|
2004-04-21 06:14:49 +08:00
|
|
|
GIMP_INT_STORE_LABEL, label,
|
|
|
|
GIMP_INT_STORE_PIXBUF, thumb,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (thumb)
|
|
|
|
g_object_unref (thumb);
|
|
|
|
|
|
|
|
g_free (label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-03-26 22:05:03 +08:00
|
|
|
|
|
|
|
static void
|
2006-11-16 07:20:06 +08:00
|
|
|
gimp_item_combo_box_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection,
|
|
|
|
guint info,
|
|
|
|
guint time)
|
2005-03-26 22:05:03 +08:00
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
gchar *str;
|
2005-03-26 22:05:03 +08:00
|
|
|
|
|
|
|
if ((selection->format != 8) || (selection->length < 1))
|
|
|
|
{
|
2006-11-16 07:20:06 +08:00
|
|
|
g_warning ("Received invalid item ID data!");
|
2005-03-26 22:05:03 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-03 06:15:33 +08:00
|
|
|
str = g_strndup ((const gchar *) selection->data, selection->length);
|
2005-07-25 21:53:00 +08:00
|
|
|
|
|
|
|
if (g_utf8_validate (str, -1, NULL))
|
|
|
|
{
|
|
|
|
gint pid;
|
|
|
|
gint ID;
|
|
|
|
|
|
|
|
if (sscanf (str, "%i:%i", &pid, &ID) == 2 &&
|
|
|
|
pid == gimp_getpid ())
|
|
|
|
{
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (widget), ID);
|
|
|
|
}
|
|
|
|
}
|
2005-03-26 22:05:03 +08:00
|
|
|
|
2005-07-25 21:53:00 +08:00
|
|
|
g_free (str);
|
2005-03-26 22:05:03 +08:00
|
|
|
}
|