From 2ce8e34c0a59b22307e7bc3e2c52e522c6db249c Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sat, 28 May 2005 23:08:07 +0000 Subject: [PATCH] libgimp/gimpuitypes.h turn this into a GObject with its own type. 2005-05-28 Manish Singh * libgimp/gimpuitypes.h * libgimp/gimpimagecombobox.[ch]: turn this into a GObject with its own type. --- ChangeLog | 6 +++ libgimp/gimpimagecombobox.c | 80 +++++++++++++++++++++++++++++++------ libgimp/gimpimagecombobox.h | 9 ++++- libgimp/gimpuitypes.h | 1 + 4 files changed, 83 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index a34f9a1196..0c0b2cdf3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-28 Manish Singh + + * libgimp/gimpuitypes.h + * libgimp/gimpimagecombobox.[ch]: turn this into a GObject with its + own type. + 2005-05-28 Maurits Rijk * plug-ins/imagemap/imap_about.c: use gtk_about_dialog instead of diff --git a/libgimp/gimpimagecombobox.c b/libgimp/gimpimagecombobox.c index 248cbca0fb..2b2198e467 100644 --- a/libgimp/gimpimagecombobox.c +++ b/libgimp/gimpimagecombobox.c @@ -30,6 +30,7 @@ #include "gimp.h" +#include "gimpuitypes.h" #include "gimpimagecombobox.h" #include "gimppixbuf.h" @@ -38,6 +39,22 @@ #define WIDTH_REQUEST 200 +typedef struct _GimpImageComboBoxClass GimpImageComboBoxClass; + +struct _GimpImageComboBox +{ + GimpIntComboBox parent_instance; +}; + +struct _GimpImageComboBoxClass +{ + GimpIntComboBoxClass parent_class; +}; + + +static void gimp_image_combo_box_class_init (GimpImageComboBoxClass *klass); +static void gimp_image_combo_box_init (GimpImageComboBox *combo_box); + static void gimp_image_combo_box_model_add (GtkListStore *store, gint num_images, gint32 *images, @@ -56,6 +73,56 @@ static void gimp_image_combo_box_drag_data_received (GtkWidget *widget, static const GtkTargetEntry target = { "application/x-gimp-image-id", 0 }; +GType +gimp_image_combo_box_get_type (void) +{ + static GType combo_box_type = 0; + + if (!combo_box_type) + { + static const GTypeInfo combo_box_info = + { + sizeof (GimpImageComboBoxClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gimp_image_combo_box_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpImageComboBox), + 0, + (GInstanceInitFunc) gimp_image_combo_box_init + }; + + combo_box_type = g_type_register_static (GIMP_TYPE_INT_COMBO_BOX, + "GimpImageComboBox", + &combo_box_info, + 0); + } + + return combo_box_type; +} + +static void +gimp_image_combo_box_class_init (GimpImageComboBoxClass *klass) +{ + GtkWidgetClass *widget_class; + + widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->drag_data_received = gimp_image_combo_box_drag_data_received; +} + +static void +gimp_image_combo_box_init (GimpImageComboBox *combo_box) +{ + gtk_drag_dest_set (GTK_WIDGET (combo_box), + GTK_DEST_DEFAULT_HIGHLIGHT | + GTK_DEST_DEFAULT_MOTION | + GTK_DEST_DEFAULT_DROP, + &target, 1, + GDK_ACTION_COPY); +} + /** * gimp_image_combo_box_new: * @constraint: a #GimpImageConstraintFunc or %NULL @@ -85,7 +152,7 @@ gimp_image_combo_box_new (GimpImageConstraintFunc constraint, gint32 *images; gint num_images; - combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX, + combo_box = g_object_new (GIMP_TYPE_IMAGE_COMBO_BOX, "width-request", WIDTH_REQUEST, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL); @@ -102,17 +169,6 @@ 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; } diff --git a/libgimp/gimpimagecombobox.h b/libgimp/gimpimagecombobox.h index 1472f36e88..03b048beff 100644 --- a/libgimp/gimpimagecombobox.h +++ b/libgimp/gimpimagecombobox.h @@ -29,14 +29,21 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ +#define GIMP_TYPE_IMAGE_COMBO_BOX (gimp_image_combo_box_get_type ()) +#define GIMP_IMAGE_COMBO_BOX (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_COMBO_BOX, GimpImageComboBox)) +#define GIMP_IS_IMAGE_COMBO_BOX (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_COMBO_BOX) + + typedef gboolean (* GimpImageConstraintFunc) (gint32 image_id, gpointer data); +GType gimp_image_combo_box_get_type (void) G_GNUC_CONST; + GtkWidget * gimp_image_combo_box_new (GimpImageConstraintFunc constraint, gpointer data); G_END_DECLS -#endif /* __GIMP_DRAWABLE_COMBO_BOX_H__ */ +#endif /* __GIMP_IMAGE_COMBO_BOX_H__ */ diff --git a/libgimp/gimpuitypes.h b/libgimp/gimpuitypes.h index d239931253..b47c82c72d 100644 --- a/libgimp/gimpuitypes.h +++ b/libgimp/gimpuitypes.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS typedef struct _GimpAspectPreview GimpAspectPreview; typedef struct _GimpDrawablePreview GimpDrawablePreview; +typedef struct _GimpImageComboBox GimpImageComboBox; typedef struct _GimpProgressBar GimpProgressBar;