mirror of https://github.com/GNOME/gimp.git
removed...
2006-11-16 Simon Budig <simon@gimp.org> * libgimp/gimpdrawablecombobox.[ch]: removed... * libgimp/gimpitemcombobox.[ch]: and added here. Factored out a lot of common code and added a combo box for vectors objects. * libgimp/Makefile.am * libgimp/gimpui.h * libgimp/gimpuitypes.h: changed accordingly.
This commit is contained in:
parent
13004433f5
commit
fd0e9de40f
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2006-11-16 Simon Budig <simon@gimp.org>
|
||||||
|
|
||||||
|
* libgimp/gimpdrawablecombobox.[ch]: removed...
|
||||||
|
|
||||||
|
* libgimp/gimpitemcombobox.[ch]: and added here. Factored out
|
||||||
|
a lot of common code and added a combo box for vectors objects.
|
||||||
|
|
||||||
|
* libgimp/Makefile.am
|
||||||
|
* libgimp/gimpui.h
|
||||||
|
* libgimp/gimpuitypes.h: changed accordingly.
|
||||||
|
|
||||||
2006-11-15 Sven Neumann <sven@gimp.org>
|
2006-11-15 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* cursors/Makefile.am
|
* cursors/Makefile.am
|
||||||
|
|
|
@ -243,8 +243,6 @@ libgimpui_2_0_la_sources = \
|
||||||
gimpbrushmenu.h \
|
gimpbrushmenu.h \
|
||||||
gimpbrushselectbutton.c \
|
gimpbrushselectbutton.c \
|
||||||
gimpbrushselectbutton.h \
|
gimpbrushselectbutton.h \
|
||||||
gimpdrawablecombobox.c \
|
|
||||||
gimpdrawablecombobox.h \
|
|
||||||
gimpdrawablepreview.c \
|
gimpdrawablepreview.c \
|
||||||
gimpdrawablepreview.h \
|
gimpdrawablepreview.h \
|
||||||
gimpexport.c \
|
gimpexport.c \
|
||||||
|
@ -259,6 +257,8 @@ libgimpui_2_0_la_sources = \
|
||||||
gimpgradientselectbutton.h \
|
gimpgradientselectbutton.h \
|
||||||
gimpimagecombobox.c \
|
gimpimagecombobox.c \
|
||||||
gimpimagecombobox.h \
|
gimpimagecombobox.h \
|
||||||
|
gimpitemcombobox.c \
|
||||||
|
gimpitemcombobox.h \
|
||||||
gimpmenu.c \
|
gimpmenu.c \
|
||||||
gimpmenu.h \
|
gimpmenu.h \
|
||||||
gimppalettemenu.c \
|
gimppalettemenu.c \
|
||||||
|
|
|
@ -1,424 +0,0 @@
|
||||||
/* LIBGIMP - The GIMP Library
|
|
||||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
||||||
*
|
|
||||||
* gimpdrawablecombobox.c
|
|
||||||
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
|
||||||
*
|
|
||||||
* 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"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
|
||||||
|
|
||||||
#include "gimp.h"
|
|
||||||
|
|
||||||
#include "gimpuitypes.h"
|
|
||||||
#include "gimpdrawablecombobox.h"
|
|
||||||
#include "gimppixbuf.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define THUMBNAIL_SIZE 24
|
|
||||||
#define WIDTH_REQUEST 200
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpDrawableComboBoxClass GimpDrawableComboBoxClass;
|
|
||||||
typedef struct _GimpChannelComboBoxClass GimpChannelComboBoxClass;
|
|
||||||
typedef struct _GimpLayerComboBoxClass GimpLayerComboBoxClass;
|
|
||||||
|
|
||||||
struct _GimpDrawableComboBox
|
|
||||||
{
|
|
||||||
GimpIntComboBox parent_instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpDrawableComboBoxClass
|
|
||||||
{
|
|
||||||
GimpIntComboBoxClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpChannelComboBox
|
|
||||||
{
|
|
||||||
GimpIntComboBox parent_instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpChannelComboBoxClass
|
|
||||||
{
|
|
||||||
GimpIntComboBoxClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpLayerComboBox
|
|
||||||
{
|
|
||||||
GimpIntComboBox parent_instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpLayerComboBoxClass
|
|
||||||
{
|
|
||||||
GimpIntComboBoxClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void gimp_drawable_combo_box_model_add (GtkListStore *store,
|
|
||||||
gint32 image,
|
|
||||||
gint num_drawables,
|
|
||||||
gint32 *drawables,
|
|
||||||
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 }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpDrawableComboBox, gimp_drawable_combo_box,
|
|
||||||
GIMP_TYPE_INT_COMBO_BOX)
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_drawable_combo_box_class_init (GimpDrawableComboBoxClass *klass)
|
|
||||||
{
|
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
widget_class->drag_data_received = gimp_drawable_combo_box_drag_data_received;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* You should use gimp_int_combo_box_connect() to initialize and connect
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* Return value: a new #GimpIntComboBox.
|
|
||||||
*
|
|
||||||
* Since: GIMP 2.2
|
|
||||||
**/
|
|
||||||
GtkWidget *
|
|
||||||
gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GtkWidget *combo_box;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint32 *images;
|
|
||||||
gint num_images;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
combo_box = g_object_new (GIMP_TYPE_DRAWABLE_COMBO_BOX,
|
|
||||||
"width-request", WIDTH_REQUEST,
|
|
||||||
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
|
|
||||||
|
|
||||||
images = gimp_image_list (&num_images);
|
|
||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
|
||||||
{
|
|
||||||
gint32 *drawables;
|
|
||||||
gint num_drawables;
|
|
||||||
|
|
||||||
drawables = gimp_image_get_layers (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
|
|
||||||
drawables = gimp_image_get_channels (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE(GimpChannelComboBox,
|
|
||||||
gimp_channel_combo_box,
|
|
||||||
GIMP_TYPE_INT_COMBO_BOX);
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_channel_combo_box_class_init (GimpChannelComboBoxClass *klass)
|
|
||||||
{
|
|
||||||
GtkWidgetClass *widget_class;
|
|
||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
widget_class->drag_data_received = gimp_drawable_combo_box_drag_data_received;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_channel_combo_box_init (GimpChannelComboBox *combo_box)
|
|
||||||
{
|
|
||||||
gtk_drag_dest_set (GTK_WIDGET (combo_box),
|
|
||||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
||||||
GTK_DEST_DEFAULT_MOTION |
|
|
||||||
GTK_DEST_DEFAULT_DROP,
|
|
||||||
targets, 1,
|
|
||||||
GDK_ACTION_COPY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* channels. See gimp_drawable_combo_box() for more info.
|
|
||||||
*
|
|
||||||
* Return value: a new #GimpIntComboBox.
|
|
||||||
*
|
|
||||||
* Since: GIMP 2.2
|
|
||||||
**/
|
|
||||||
GtkWidget *
|
|
||||||
gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GtkWidget *combo_box;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint32 *images;
|
|
||||||
gint num_images;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
combo_box = g_object_new (GIMP_TYPE_CHANNEL_COMBO_BOX,
|
|
||||||
"width-request", WIDTH_REQUEST,
|
|
||||||
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
|
|
||||||
|
|
||||||
images = gimp_image_list (&num_images);
|
|
||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
|
||||||
{
|
|
||||||
gint32 *drawables;
|
|
||||||
gint num_drawables;
|
|
||||||
|
|
||||||
drawables = gimp_image_get_channels (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE(GimpLayerComboBox,
|
|
||||||
gimp_layer_combo_box,
|
|
||||||
GIMP_TYPE_INT_COMBO_BOX);
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_layer_combo_box_class_init (GimpLayerComboBoxClass *klass)
|
|
||||||
{
|
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
widget_class->drag_data_received = gimp_drawable_combo_box_drag_data_received;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_layer_combo_box_init (GimpLayerComboBox *combo_box)
|
|
||||||
{
|
|
||||||
gtk_drag_dest_set (GTK_WIDGET (combo_box),
|
|
||||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
||||||
GTK_DEST_DEFAULT_MOTION |
|
|
||||||
GTK_DEST_DEFAULT_DROP,
|
|
||||||
targets + 1, 1,
|
|
||||||
GDK_ACTION_COPY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* layers. See gimp_drawable_combo_box() for more info.
|
|
||||||
*
|
|
||||||
* Return value: a new #GimpIntComboBox.
|
|
||||||
*
|
|
||||||
* Since: GIMP 2.2
|
|
||||||
**/
|
|
||||||
GtkWidget *
|
|
||||||
gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GtkWidget *combo_box;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint32 *images;
|
|
||||||
gint num_images;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
combo_box = g_object_new (GIMP_TYPE_LAYER_COMBO_BOX,
|
|
||||||
"width-request", WIDTH_REQUEST,
|
|
||||||
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
|
|
||||||
|
|
||||||
images = gimp_image_list (&num_images);
|
|
||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
|
||||||
{
|
|
||||||
gint32 *drawables;
|
|
||||||
gint num_drawables;
|
|
||||||
|
|
||||||
drawables = gimp_image_get_layers (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_drawable_combo_box_model_add (GtkListStore *store,
|
|
||||||
gint32 image,
|
|
||||||
gint num_drawables,
|
|
||||||
gint32 *drawables,
|
|
||||||
GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
for (i = 0; i < num_drawables; i++)
|
|
||||||
{
|
|
||||||
if (! constraint || (* constraint) (image, drawables[i], data))
|
|
||||||
{
|
|
||||||
gchar *image_name = gimp_image_get_name (image);
|
|
||||||
gchar *drawable_name = gimp_drawable_get_name (drawables[i]);
|
|
||||||
gchar *label;
|
|
||||||
GdkPixbuf *thumb;
|
|
||||||
|
|
||||||
label = g_strdup_printf ("%s-%d/%s-%d",
|
|
||||||
image_name, image,
|
|
||||||
drawable_name, drawables[i]);
|
|
||||||
|
|
||||||
g_free (drawable_name);
|
|
||||||
g_free (image_name);
|
|
||||||
|
|
||||||
thumb = gimp_drawable_get_thumbnail (drawables[i],
|
|
||||||
THUMBNAIL_SIZE, THUMBNAIL_SIZE,
|
|
||||||
GIMP_PIXBUF_SMALL_CHECKS);
|
|
||||||
|
|
||||||
gtk_list_store_append (store, &iter);
|
|
||||||
gtk_list_store_set (store, &iter,
|
|
||||||
GIMP_INT_STORE_VALUE, drawables[i],
|
|
||||||
GIMP_INT_STORE_LABEL, label,
|
|
||||||
GIMP_INT_STORE_PIXBUF, thumb,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
if (thumb)
|
|
||||||
g_object_unref (thumb);
|
|
||||||
|
|
||||||
g_free (label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
|
|
||||||
GdkDragContext *context,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
GtkSelectionData *selection,
|
|
||||||
guint info,
|
|
||||||
guint time)
|
|
||||||
{
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
if ((selection->format != 8) || (selection->length < 1))
|
|
||||||
{
|
|
||||||
g_warning ("Received invalid drawable ID data!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
str = g_strndup ((const gchar *) selection->data, selection->length);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
/* LIBGIMP - The GIMP Library
|
|
||||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
||||||
*
|
|
||||||
* gimpdrawablecombobox.h
|
|
||||||
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GIMP_DRAWABLE_COMBO_BOX_H__
|
|
||||||
#define __GIMP_DRAWABLE_COMBO_BOX_H__
|
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
/* For information look into the C source or the html documentation */
|
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_DRAWABLE_COMBO_BOX (gimp_drawable_combo_box_get_type ())
|
|
||||||
#define GIMP_DRAWABLE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DRAWABLE_COMBO_BOX, GimpDrawableComboBox))
|
|
||||||
#define GIMP_IS_DRAWABLE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DRAWABLE_COMBO_BOX)
|
|
||||||
|
|
||||||
#define GIMP_TYPE_CHANNEL_COMBO_BOX (gimp_channel_combo_box_get_type ())
|
|
||||||
#define GIMP_CHANNEL_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CHANNEL_COMBO_BOX, GimpChannelComboBox))
|
|
||||||
#define GIMP_IS_CHANNEL_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CHANNEL_COMBO_BOX)
|
|
||||||
|
|
||||||
#define GIMP_TYPE_LAYER_COMBO_BOX (gimp_layer_combo_box_get_type ())
|
|
||||||
#define GIMP_LAYER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_COMBO_BOX, GimpLayerComboBox))
|
|
||||||
#define GIMP_IS_LAYER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_LAYER_COMBO_BOX)
|
|
||||||
|
|
||||||
|
|
||||||
typedef gboolean (* GimpDrawableConstraintFunc) (gint32 image_id,
|
|
||||||
gint32 drawable_id,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
|
|
||||||
GType gimp_drawable_combo_box_get_type (void) G_GNUC_CONST;
|
|
||||||
GType gimp_channel_combo_box_get_type (void) G_GNUC_CONST;
|
|
||||||
GType gimp_layer_combo_box_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GtkWidget * gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data);
|
|
||||||
GtkWidget * gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data);
|
|
||||||
GtkWidget * gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GIMP_DRAWABLE_COMBO_BOX_H__ */
|
|
|
@ -1,8 +1,9 @@
|
||||||
/* LIBGIMP - The GIMP Library
|
/* LIBGIMP - The GIMP Library
|
||||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||||
*
|
*
|
||||||
* gimpdrawablecombobox.c
|
* gimpitemcombobox.c
|
||||||
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
||||||
|
* Copyright (C) 2006 Simon Budig <simon@gimp.org>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -31,17 +32,26 @@
|
||||||
#include "gimp.h"
|
#include "gimp.h"
|
||||||
|
|
||||||
#include "gimpuitypes.h"
|
#include "gimpuitypes.h"
|
||||||
#include "gimpdrawablecombobox.h"
|
#include "gimpitemcombobox.h"
|
||||||
#include "gimppixbuf.h"
|
#include "gimppixbuf.h"
|
||||||
|
|
||||||
|
|
||||||
#define THUMBNAIL_SIZE 24
|
#define THUMBNAIL_SIZE 24
|
||||||
#define WIDTH_REQUEST 200
|
#define WIDTH_REQUEST 200
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DRAWABLE_COMBO_BOX,
|
||||||
|
CHANNEL_COMBO_BOX,
|
||||||
|
LAYER_COMBO_BOX,
|
||||||
|
VECTORS_COMBO_BOX
|
||||||
|
} GimpComboBoxType;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpDrawableComboBoxClass GimpDrawableComboBoxClass;
|
typedef struct _GimpDrawableComboBoxClass GimpDrawableComboBoxClass;
|
||||||
typedef struct _GimpChannelComboBoxClass GimpChannelComboBoxClass;
|
typedef struct _GimpChannelComboBoxClass GimpChannelComboBoxClass;
|
||||||
typedef struct _GimpLayerComboBoxClass GimpLayerComboBoxClass;
|
typedef struct _GimpLayerComboBoxClass GimpLayerComboBoxClass;
|
||||||
|
typedef struct _GimpVectorsComboBoxClass GimpVectorsComboBoxClass;
|
||||||
|
|
||||||
struct _GimpDrawableComboBox
|
struct _GimpDrawableComboBox
|
||||||
{
|
{
|
||||||
|
@ -73,27 +83,43 @@ struct _GimpLayerComboBoxClass
|
||||||
GimpIntComboBoxClass parent_class;
|
GimpIntComboBoxClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _GimpVectorsComboBox
|
||||||
|
{
|
||||||
|
GimpIntComboBox parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
static void gimp_drawable_combo_box_model_add (GtkListStore *store,
|
struct _GimpVectorsComboBoxClass
|
||||||
gint32 image,
|
{
|
||||||
gint num_drawables,
|
GimpIntComboBoxClass parent_class;
|
||||||
gint32 *drawables,
|
};
|
||||||
GimpDrawableConstraintFunc constraint,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
static void gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
|
|
||||||
GdkDragContext *context,
|
static GtkWidget * gimp_item_combo_box_new (GimpComboBoxType type,
|
||||||
gint x,
|
GimpItemConstraintFunc constraint,
|
||||||
gint y,
|
gpointer data);
|
||||||
GtkSelectionData *selection,
|
|
||||||
guint info,
|
static void gimp_item_combo_box_model_add (GtkListStore *store,
|
||||||
guint time);
|
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);
|
||||||
|
|
||||||
|
|
||||||
static const GtkTargetEntry targets[] =
|
static const GtkTargetEntry targets[] =
|
||||||
{
|
{
|
||||||
{ "application/x-gimp-channel-id", 0 },
|
{ "application/x-gimp-channel-id", 0 },
|
||||||
{ "application/x-gimp-layer-id", 0 }
|
{ "application/x-gimp-layer-id", 0 },
|
||||||
|
{ "application/x-gimp-vectors-id", 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,7 +132,7 @@ gimp_drawable_combo_box_class_init (GimpDrawableComboBoxClass *klass)
|
||||||
{
|
{
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
widget_class->drag_data_received = gimp_drawable_combo_box_drag_data_received;
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -143,48 +169,7 @@ GtkWidget *
|
||||||
gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *combo_box;
|
return gimp_item_combo_box_new (DRAWABLE_COMBO_BOX, constraint, data);
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint32 *images;
|
|
||||||
gint num_images;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
combo_box = g_object_new (GIMP_TYPE_DRAWABLE_COMBO_BOX,
|
|
||||||
"width-request", WIDTH_REQUEST,
|
|
||||||
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
|
|
||||||
|
|
||||||
images = gimp_image_list (&num_images);
|
|
||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
|
||||||
{
|
|
||||||
gint32 *drawables;
|
|
||||||
gint num_drawables;
|
|
||||||
|
|
||||||
drawables = gimp_image_get_layers (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
|
|
||||||
drawables = gimp_image_get_channels (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,7 +184,7 @@ gimp_channel_combo_box_class_init (GimpChannelComboBoxClass *klass)
|
||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
widget_class->drag_data_received = gimp_drawable_combo_box_drag_data_received;
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -229,41 +214,7 @@ GtkWidget *
|
||||||
gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
|
gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *combo_box;
|
return gimp_item_combo_box_new (CHANNEL_COMBO_BOX, constraint, data);
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint32 *images;
|
|
||||||
gint num_images;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
combo_box = g_object_new (GIMP_TYPE_CHANNEL_COMBO_BOX,
|
|
||||||
"width-request", WIDTH_REQUEST,
|
|
||||||
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
|
|
||||||
|
|
||||||
images = gimp_image_list (&num_images);
|
|
||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
|
||||||
{
|
|
||||||
gint32 *drawables;
|
|
||||||
gint num_drawables;
|
|
||||||
|
|
||||||
drawables = gimp_image_get_channels (images[i], &num_drawables);
|
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
|
||||||
images[i],
|
|
||||||
num_drawables, drawables,
|
|
||||||
constraint, data);
|
|
||||||
g_free (drawables);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,7 +227,7 @@ gimp_layer_combo_box_class_init (GimpLayerComboBoxClass *klass)
|
||||||
{
|
{
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
widget_class->drag_data_received = gimp_drawable_combo_box_drag_data_received;
|
widget_class->drag_data_received = gimp_item_combo_box_drag_data_received;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -306,6 +257,65 @@ GtkWidget *
|
||||||
gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
GType combo_box_type;
|
||||||
GtkWidget *combo_box;
|
GtkWidget *combo_box;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
@ -313,7 +323,23 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gint num_images;
|
gint num_images;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
combo_box = g_object_new (GIMP_TYPE_LAYER_COMBO_BOX,
|
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,
|
||||||
"width-request", WIDTH_REQUEST,
|
"width-request", WIDTH_REQUEST,
|
||||||
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -324,15 +350,40 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
for (i = 0; i < num_images; i++)
|
||||||
{
|
{
|
||||||
gint32 *drawables;
|
gint32 *items;
|
||||||
gint num_drawables;
|
gint num_items;
|
||||||
|
|
||||||
drawables = gimp_image_get_layers (images[i], &num_drawables);
|
if (type == DRAWABLE_COMBO_BOX ||
|
||||||
gimp_drawable_combo_box_model_add (GTK_LIST_STORE (model),
|
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],
|
images[i],
|
||||||
num_drawables, drawables,
|
num_items, items, type,
|
||||||
constraint, data);
|
constraint, data);
|
||||||
g_free (drawables);
|
g_free (items);
|
||||||
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
|
images[i],
|
||||||
|
num_items, items, type,
|
||||||
|
constraint, data);
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (images);
|
g_free (images);
|
||||||
|
@ -343,40 +394,50 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
return combo_box;
|
return combo_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_drawable_combo_box_model_add (GtkListStore *store,
|
gimp_item_combo_box_model_add (GtkListStore *store,
|
||||||
gint32 image,
|
gint32 image,
|
||||||
gint num_drawables,
|
gint num_items,
|
||||||
gint32 *drawables,
|
gint32 *items,
|
||||||
GimpDrawableConstraintFunc constraint,
|
GimpComboBoxType type,
|
||||||
gpointer data)
|
GimpItemConstraintFunc constraint,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < num_drawables; i++)
|
for (i = 0; i < num_items; i++)
|
||||||
{
|
{
|
||||||
if (! constraint || (* constraint) (image, drawables[i], data))
|
if (! constraint || (* constraint) (image, items[i], data))
|
||||||
{
|
{
|
||||||
gchar *image_name = gimp_image_get_name (image);
|
gchar *image_name = gimp_image_get_name (image);
|
||||||
gchar *drawable_name = gimp_drawable_get_name (drawables[i]);
|
gchar *item_name;
|
||||||
gchar *label;
|
gchar *label;
|
||||||
GdkPixbuf *thumb;
|
GdkPixbuf *thumb;
|
||||||
|
|
||||||
label = g_strdup_printf ("%s-%d/%s-%d",
|
if (type == VECTORS_COMBO_BOX)
|
||||||
image_name, image,
|
item_name = gimp_vectors_get_name (items[i]);
|
||||||
drawable_name, drawables[i]);
|
else
|
||||||
|
item_name = gimp_drawable_get_name (items[i]);
|
||||||
|
|
||||||
g_free (drawable_name);
|
label = g_strdup_printf ("%s-%d/%s-%d",
|
||||||
|
image_name, image,
|
||||||
|
item_name, items[i]);
|
||||||
|
|
||||||
|
g_free (item_name);
|
||||||
g_free (image_name);
|
g_free (image_name);
|
||||||
|
|
||||||
thumb = gimp_drawable_get_thumbnail (drawables[i],
|
if (type == VECTORS_COMBO_BOX)
|
||||||
THUMBNAIL_SIZE, THUMBNAIL_SIZE,
|
thumb = NULL;
|
||||||
GIMP_PIXBUF_SMALL_CHECKS);
|
else
|
||||||
|
thumb = gimp_drawable_get_thumbnail (items[i],
|
||||||
|
THUMBNAIL_SIZE, THUMBNAIL_SIZE,
|
||||||
|
GIMP_PIXBUF_SMALL_CHECKS);
|
||||||
|
|
||||||
gtk_list_store_append (store, &iter);
|
gtk_list_store_append (store, &iter);
|
||||||
gtk_list_store_set (store, &iter,
|
gtk_list_store_set (store, &iter,
|
||||||
GIMP_INT_STORE_VALUE, drawables[i],
|
GIMP_INT_STORE_VALUE, items[i],
|
||||||
GIMP_INT_STORE_LABEL, label,
|
GIMP_INT_STORE_LABEL, label,
|
||||||
GIMP_INT_STORE_PIXBUF, thumb,
|
GIMP_INT_STORE_PIXBUF, thumb,
|
||||||
-1);
|
-1);
|
||||||
|
@ -390,19 +451,19 @@ gimp_drawable_combo_box_model_add (GtkListStore *store,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_drawable_combo_box_drag_data_received (GtkWidget *widget,
|
gimp_item_combo_box_drag_data_received (GtkWidget *widget,
|
||||||
GdkDragContext *context,
|
GdkDragContext *context,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
GtkSelectionData *selection,
|
GtkSelectionData *selection,
|
||||||
guint info,
|
guint info,
|
||||||
guint time)
|
guint time)
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
if ((selection->format != 8) || (selection->length < 1))
|
if ((selection->format != 8) || (selection->length < 1))
|
||||||
{
|
{
|
||||||
g_warning ("Received invalid drawable ID data!");
|
g_warning ("Received invalid item ID data!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
/* LIBGIMP - The GIMP Library
|
/* LIBGIMP - The GIMP Library
|
||||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||||
*
|
*
|
||||||
* gimpdrawablecombobox.h
|
* gimpitemcombobox.h
|
||||||
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
||||||
|
* Copyright (C) 2006 Simon Budig <simon@gimp.org>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +21,8 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __GIMP_DRAWABLE_COMBO_BOX_H__
|
#ifndef __GIMP_ITEM_COMBO_BOX_H__
|
||||||
#define __GIMP_DRAWABLE_COMBO_BOX_H__
|
#define __GIMP_ITEM_COMBO_BOX_H__
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -41,15 +42,23 @@ G_BEGIN_DECLS
|
||||||
#define GIMP_LAYER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_COMBO_BOX, GimpLayerComboBox))
|
#define GIMP_LAYER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_COMBO_BOX, GimpLayerComboBox))
|
||||||
#define GIMP_IS_LAYER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_LAYER_COMBO_BOX)
|
#define GIMP_IS_LAYER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_LAYER_COMBO_BOX)
|
||||||
|
|
||||||
|
#define GIMP_TYPE_VECTORS_COMBO_BOX (gimp_vectors_combo_box_get_type ())
|
||||||
|
#define GIMP_VECTORS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VECTORS_COMBO_BOX, GimpVectorsComboBox))
|
||||||
|
#define GIMP_IS_VECTORS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VECTORS_COMBO_BOX)
|
||||||
|
|
||||||
typedef gboolean (* GimpDrawableConstraintFunc) (gint32 image_id,
|
|
||||||
gint32 drawable_id,
|
typedef gboolean (* GimpItemConstraintFunc) (gint32 image_id,
|
||||||
gpointer data);
|
gint32 item_id,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
typedef GimpItemConstraintFunc GimpVectorsConstraintFunc;
|
||||||
|
typedef GimpItemConstraintFunc GimpDrawableConstraintFunc;
|
||||||
|
|
||||||
|
|
||||||
GType gimp_drawable_combo_box_get_type (void) G_GNUC_CONST;
|
GType gimp_drawable_combo_box_get_type (void) G_GNUC_CONST;
|
||||||
GType gimp_channel_combo_box_get_type (void) G_GNUC_CONST;
|
GType gimp_channel_combo_box_get_type (void) G_GNUC_CONST;
|
||||||
GType gimp_layer_combo_box_get_type (void) G_GNUC_CONST;
|
GType gimp_layer_combo_box_get_type (void) G_GNUC_CONST;
|
||||||
|
GType gimp_vectors_combo_box_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget * gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
GtkWidget * gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
@ -57,8 +66,10 @@ GtkWidget * gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
GtkWidget * gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
GtkWidget * gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
GtkWidget * gimp_vectors_combo_box_new (GimpVectorsConstraintFunc constraint,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GIMP_DRAWABLE_COMBO_BOX_H__ */
|
#endif /* __GIMP_ITEM_COMBO_BOX_H__ */
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include <libgimp/gimpprocbrowserdialog.h>
|
#include <libgimp/gimpprocbrowserdialog.h>
|
||||||
#include <libgimp/gimpprocview.h>
|
#include <libgimp/gimpprocview.h>
|
||||||
#include <libgimp/gimpprogressbar.h>
|
#include <libgimp/gimpprogressbar.h>
|
||||||
#include <libgimp/gimpdrawablecombobox.h>
|
#include <libgimp/gimpitemcombobox.h>
|
||||||
#include <libgimp/gimpimagecombobox.h>
|
#include <libgimp/gimpimagecombobox.h>
|
||||||
#include <libgimp/gimpselectbutton.h>
|
#include <libgimp/gimpselectbutton.h>
|
||||||
#include <libgimp/gimpbrushselectbutton.h>
|
#include <libgimp/gimpbrushselectbutton.h>
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef struct _GimpZoomPreview GimpZoomPreview;
|
||||||
typedef struct _GimpDrawableComboBox GimpDrawableComboBox;
|
typedef struct _GimpDrawableComboBox GimpDrawableComboBox;
|
||||||
typedef struct _GimpChannelComboBox GimpChannelComboBox;
|
typedef struct _GimpChannelComboBox GimpChannelComboBox;
|
||||||
typedef struct _GimpLayerComboBox GimpLayerComboBox;
|
typedef struct _GimpLayerComboBox GimpLayerComboBox;
|
||||||
|
typedef struct _GimpVectorsComboBox GimpVectorsComboBox;
|
||||||
typedef struct _GimpImageComboBox GimpImageComboBox;
|
typedef struct _GimpImageComboBox GimpImageComboBox;
|
||||||
|
|
||||||
typedef struct _GimpSelectButton GimpSelectButton;
|
typedef struct _GimpSelectButton GimpSelectButton;
|
||||||
|
|
Loading…
Reference in New Issue