gimp r26402 - in branches/soc-2008-tagging: . app/widgets
- From: aurisj svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26402 - in branches/soc-2008-tagging: . app/widgets
- Date: Wed, 6 Aug 2008 18:18:08 +0000 (UTC)
Author: aurisj
Date: Wed Aug 6 18:18:08 2008
New Revision: 26402
URL: http://svn.gnome.org/viewvc/gimp?rev=26402&view=rev
Log:
2008-08-06 Aurimas JuÅka <aurisj svn gnome org>
* app/widgets/gimpcombotagentry.[ch]
* app/widgets/gimpdatafactoryview.c
* app/widgets/gimptagentry.[ch]
* app/widgets/gimptagpopup.c: cleaned up and reorganized code in
order to prepare widget code for RTL support.
Modified:
branches/soc-2008-tagging/ChangeLog
branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c
branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c
branches/soc-2008-tagging/app/widgets/gimptagentry.c
branches/soc-2008-tagging/app/widgets/gimptagentry.h
branches/soc-2008-tagging/app/widgets/gimptagpopup.c
Modified: branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c Wed Aug 6 18:18:08 2008
@@ -41,24 +41,25 @@
static void gimp_combo_tag_entry_dispose (GObject *object);
static gboolean gimp_combo_tag_entry_expose_event (GtkWidget *widget,
GdkEventExpose *event,
- GimpComboTagEntry *combo_entry);
-static void gimp_combo_tag_entry_style_set (GtkWidget *widget,
- GtkStyle *previous_style,
- GimpComboTagEntry *combo_entry);
-static gboolean gimp_combo_tag_entry_focus_in_out (GtkWidget *widget,
- GdkEventFocus *event,
- GimpComboTagEntry *combo_entry);
+ gpointer user_data);
static gboolean gimp_combo_tag_entry_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
+static void gimp_combo_tag_entry_style_set (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data);
+
static void gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry);
static void gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
gint tag_count,
GimpComboTagEntry *combo_entry);
+static void gimp_combo_tag_entry_get_arrow_rect (GimpComboTagEntry *combo_entry,
+ GdkRectangle *arrow_rect);
-G_DEFINE_TYPE (GimpComboTagEntry, gimp_combo_tag_entry, GTK_TYPE_EVENT_BOX);
+
+G_DEFINE_TYPE (GimpComboTagEntry, gimp_combo_tag_entry, GIMP_TYPE_TAG_ENTRY);
#define parent_class gimp_combo_tag_entry_parent_class
@@ -73,8 +74,6 @@
static void
gimp_combo_tag_entry_init (GimpComboTagEntry *combo_entry)
{
- combo_entry->tag_entry = NULL;
- combo_entry->alignment = NULL;
combo_entry->popup = NULL;
combo_entry->focus_width = 0;
combo_entry->interior_focus = FALSE;
@@ -122,41 +121,34 @@
}
GtkWidget *
-gimp_combo_tag_entry_new (GimpTagEntry *tag_entry)
+gimp_combo_tag_entry_new (GimpFilteredContainer *filtered_container,
+ GimpTagEntryMode mode)
{
GimpComboTagEntry *combo_entry;
+ GtkBorder border;
- combo_entry = g_object_new (GIMP_TYPE_COMBO_TAG_ENTRY, NULL);
- combo_entry->tag_entry = GTK_WIDGET (tag_entry);
- combo_entry->filtered_container = tag_entry->tagged_container;
+ combo_entry = g_object_new (GIMP_TYPE_COMBO_TAG_ENTRY,
+ "filtered-container", filtered_container,
+ "tag-entry-mode", mode,
+ NULL);
+ combo_entry->filtered_container = filtered_container;
g_object_ref (combo_entry->filtered_container);
gtk_widget_add_events (GTK_WIDGET (combo_entry),
GDK_BUTTON_PRESS_MASK);
- combo_entry->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
- gtk_widget_show (combo_entry->alignment);
- gtk_container_add (GTK_CONTAINER (combo_entry), combo_entry->alignment);
-
- g_signal_connect (combo_entry->alignment, "expose-event",
- G_CALLBACK (gimp_combo_tag_entry_expose_event),
- combo_entry);
-
- gtk_entry_set_has_frame (GTK_ENTRY (tag_entry), FALSE);
- gtk_widget_show (GTK_WIDGET (tag_entry));
- gtk_container_add (GTK_CONTAINER (combo_entry->alignment),
- GTK_WIDGET (tag_entry));
-
- g_signal_connect (combo_entry->tag_entry, "style-set",
+ border.left = 2;
+ border.right = 8 + 2 * 2 + 2;
+ border.top = 2;
+ border.bottom = 2;
+ gtk_entry_set_inner_border (GTK_ENTRY (combo_entry), &border);
+
+ g_signal_connect_after (combo_entry, "expose-event",
+ G_CALLBACK (gimp_combo_tag_entry_expose_event),
+ NULL);
+ g_signal_connect (combo_entry, "style-set",
G_CALLBACK (gimp_combo_tag_entry_style_set),
- combo_entry);
- g_signal_connect (combo_entry->tag_entry, "focus-in-event",
- G_CALLBACK (gimp_combo_tag_entry_focus_in_out),
- combo_entry);
- g_signal_connect (combo_entry->tag_entry, "focus-out-event",
- G_CALLBACK (gimp_combo_tag_entry_focus_in_out),
- combo_entry);
-
+ NULL);
g_signal_connect (combo_entry->filtered_container,
"tag-count-changed",
G_CALLBACK (gimp_combo_tag_entry_tag_count_changed),
@@ -168,101 +160,104 @@
static gboolean
gimp_combo_tag_entry_expose_event (GtkWidget *widget,
GdkEventExpose *event,
- GimpComboTagEntry *combo_entry)
+ gpointer user_data)
{
- GdkGC *gc;
- GtkWidget *tag_entry;
- GtkStyle *style;
- GtkAllocation *allocation;
- GdkRectangle client_area;
- GdkRectangle shadow_area;
+ GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
+ GdkRectangle arrow_rect;
gint tag_count;
+ gint window_width;
+ gint window_height;
- tag_entry = combo_entry->tag_entry;
- style = gtk_widget_get_style (tag_entry);
- allocation = &widget->allocation;
-
- gc = gdk_gc_new (widget->window);
-
- client_area.x = widget->allocation.x;
- client_area.y = widget->allocation.y;
- client_area.width = widget->allocation.width;
- client_area.height = widget->allocation.height;
-
- shadow_area = client_area;
- if (GTK_WIDGET_HAS_FOCUS (tag_entry)
- && ! combo_entry->interior_focus)
- {
- shadow_area.x += combo_entry->interior_focus;
- shadow_area.y += combo_entry->interior_focus;
- shadow_area.width -= combo_entry->interior_focus * 2;
- shadow_area.height -= combo_entry->interior_focus * 2;
- }
-
- gtk_paint_flat_box (style, widget->window,
- GTK_WIDGET_STATE (tag_entry), GTK_SHADOW_NONE,
- &event->area, tag_entry, "entry_bg",
- client_area.x, client_area.y,
- client_area.width, client_area.height);
- gtk_paint_shadow (style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- &event->area, tag_entry, "entry",
- shadow_area.x, shadow_area.y,
- shadow_area.width, shadow_area.height);
- if (GTK_WIDGET_HAS_FOCUS (tag_entry)
- && ! combo_entry->interior_focus)
- {
- gtk_paint_focus (widget->style, widget->window,
- GTK_WIDGET_STATE (tag_entry),
- &event->area, tag_entry, "entry",
- client_area.x, client_area.y,
- client_area.width, client_area.width);
+ if (widget->window == event->window)
+ {
+ return FALSE;
}
+ gimp_combo_tag_entry_get_arrow_rect (combo_entry, &arrow_rect);
tag_count = gimp_filtered_container_get_tag_count (combo_entry->filtered_container);
- gtk_paint_arrow (style, widget->window, tag_count > 0 ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_NONE, NULL, NULL, NULL,
- GTK_ARROW_DOWN, TRUE,
- shadow_area.x + shadow_area.width - 14,
- shadow_area.y + shadow_area.height / 2 - 4, 8, 8);
+ gdk_drawable_get_size (GDK_DRAWABLE (event->window), &window_width, &window_height);
+ gdk_draw_rectangle (event->window, widget->style->base_gc[widget->state],
+ TRUE, window_width - 16, 0, 16, window_height);
+
+ gtk_paint_arrow (widget->style,
+ event->window, tag_count > 0 ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_NONE, NULL, NULL, NULL,
+ GTK_ARROW_DOWN, TRUE,
+ arrow_rect.x + arrow_rect.width - 14,
+ arrow_rect.y + arrow_rect.height / 2 - 4, 8, 8);
+
+ return FALSE;
+}
+
+static gboolean
+gimp_combo_tag_entry_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
+
+ if (event->type == GDK_BUTTON_PRESS)
+ {
+ GdkEventButton *button_event;
+ gint x;
+ gint y;
+ GdkRectangle arrow_rect;
- g_object_unref (gc);
+ button_event = (GdkEventButton *) event;
+ x = button_event->x;
+ y = button_event->y;
+
+ gimp_combo_tag_entry_get_arrow_rect (combo_entry, &arrow_rect);
+ if (x > arrow_rect.x
+ && y > arrow_rect.y
+ && x < arrow_rect.x + arrow_rect.width
+ && y < arrow_rect.y + arrow_rect.height)
+ {
+ if (! combo_entry->popup)
+ {
+ gimp_combo_tag_entry_popup_list (combo_entry);
+ }
+ else
+ {
+ gtk_widget_destroy (combo_entry->popup);
+ }
+ }
+ }
return FALSE;
}
static void
+gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry)
+{
+ gint tag_count;
+
+ tag_count = gimp_filtered_container_get_tag_count (combo_entry->filtered_container);
+ if (tag_count > 0)
+ {
+ combo_entry->popup = gimp_tag_popup_new (combo_entry);
+ }
+}
+
+static void
+gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
+ gint tag_count,
+ GimpComboTagEntry *combo_entry)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (combo_entry));
+}
+
+static void
gimp_combo_tag_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style,
- GimpComboTagEntry *combo_entry)
+ gpointer user_data)
{
+ GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
GtkStyle *style;
- gint xmargin;
- gint ymargin;
GdkColor color;
PangoAttribute *attribute;
- gtk_widget_style_get (combo_entry->tag_entry,
- "focus-line-width", &combo_entry->focus_width,
- "interior-focus", &combo_entry->interior_focus,
- NULL);
-
- style = gtk_widget_get_style (combo_entry->tag_entry);
- xmargin = style->xthickness;
- if (! combo_entry->interior_focus)
- {
- xmargin += combo_entry->focus_width;
- }
- ymargin = style->ythickness;
- if (! combo_entry->interior_focus)
- {
- ymargin += combo_entry->focus_width;
- }
-
- gtk_alignment_set_padding (GTK_ALIGNMENT (combo_entry->alignment),
- ymargin, ymargin, xmargin, xmargin + 16);
-
style = widget->style;
if (combo_entry->normal_item_attr)
{
@@ -306,78 +301,15 @@
combo_entry->selected_item_color = style->base[GTK_STATE_SELECTED];
}
-static gboolean
-gimp_combo_tag_entry_focus_in_out (GtkWidget *widget,
- GdkEventFocus *event,
- GimpComboTagEntry *combo_entry)
-{
- gtk_widget_queue_draw (GTK_WIDGET (combo_entry));
-
- return FALSE;
-}
-
-static gboolean
-gimp_combo_tag_entry_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- GimpComboTagEntry *combo_entry;
-
- combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
-
- if (event->type == GDK_BUTTON_PRESS)
- {
- GdkEventButton *button_event;
- gint x;
- gint y;
- guint padding_top;
- guint padding_bottom;
- guint padding_left;
- guint padding_right;
-
- button_event = (GdkEventButton *) event;
- x = button_event->x;
- y = button_event->y;
-
- gtk_alignment_get_padding (GTK_ALIGNMENT (combo_entry->alignment),
- &padding_top, &padding_bottom,
- &padding_left, &padding_right);
- if (x > widget->allocation.width - padding_right
- && y > padding_top
- && x < widget->allocation.width - padding_left
- && y < widget->allocation.height - padding_bottom)
- {
- if (! combo_entry->popup)
- {
- gimp_combo_tag_entry_popup_list (combo_entry);
- }
- else
- {
- gtk_widget_destroy (combo_entry->popup);
- }
- }
- }
-
- return FALSE;
-}
-
static void
-gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry)
+gimp_combo_tag_entry_get_arrow_rect (GimpComboTagEntry *combo_entry,
+ GdkRectangle *arrow_rect)
{
- gint tag_count;
+ GtkWidget *widget = GTK_WIDGET (combo_entry);
- tag_count = gimp_filtered_container_get_tag_count (combo_entry->filtered_container);
- if (tag_count > 0)
- {
- combo_entry->popup = gimp_tag_popup_new (combo_entry);
- }
-}
-
-static void
-gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
- gint tag_count,
- GimpComboTagEntry *combo_entry)
-{
- gtk_widget_queue_draw (GTK_WIDGET (combo_entry));
+ arrow_rect->x = widget->allocation.width - 16 - widget->style->xthickness;
+ arrow_rect->y = 0;
+ arrow_rect->width = 16;
+ arrow_rect->height = widget->allocation.height - widget->style->ythickness * 2;
}
Modified: branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h (original)
+++ branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h Wed Aug 6 18:18:08 2008
@@ -22,6 +22,7 @@
#ifndef __GIMP_COMBO_TAG_ENTRY_H__
#define __GIMP_COMBO_TAG_ENTRY_H__
+#include "gimptagentry.h"
#define GIMP_TYPE_COMBO_TAG_ENTRY (gimp_combo_tag_entry_get_type ())
#define GIMP_COMBO_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COMBO_TAG_ENTRY, GimpComboTagEntry))
@@ -35,10 +36,8 @@
struct _GimpComboTagEntry
{
- GtkEventBox parent_instance;
+ GimpTagEntry parent_instance;
- GtkWidget *tag_entry;
- GtkWidget *alignment;
GtkWidget *popup;
GimpFilteredContainer *filtered_container;
gint focus_width;
@@ -51,14 +50,13 @@
struct _GimpComboTagEntryClass
{
- GtkEventBoxClass parent_class;
+ GimpTagEntryClass parent_class;
};
GType gimp_combo_tag_entry_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_combo_tag_entry_new (GimpTagEntry *tag_entry);
-
-GtkWidget * gimp_combo_tag_entry_get_tag_entry (GimpComboTagEntry *combo_entry);
+GtkWidget * gimp_combo_tag_entry_new (GimpFilteredContainer *filtered_container,
+ GimpTagEntryMode mode);
#endif /* __GIMP_COMBO_TAG_ENTRY_H__ */
Modified: branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c Wed Aug 6 18:18:08 2008
@@ -141,7 +141,6 @@
{
GimpContainerEditor *editor;
gchar *str;
- GtkWidget *tag_combo;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE);
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE);
@@ -227,32 +226,26 @@
editor = GIMP_CONTAINER_EDITOR (factory_view);
factory_view->query_tag_entry =
- gimp_tag_entry_new (GIMP_FILTERED_CONTAINER (factory_view->filtered_container),
- GIMP_TAG_ENTRY_MODE_QUERY);
+ gimp_combo_tag_entry_new (GIMP_FILTERED_CONTAINER (factory_view->filtered_container),
+ GIMP_TAG_ENTRY_MODE_QUERY);
gtk_widget_show (factory_view->query_tag_entry);
- tag_combo = gimp_combo_tag_entry_new (GIMP_TAG_ENTRY (factory_view->query_tag_entry));
- gtk_widget_show (tag_combo);
-
gtk_box_pack_start (GTK_BOX (editor->view),
- tag_combo,
+ factory_view->query_tag_entry,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (editor->view),
- tag_combo, 0);
+ factory_view->query_tag_entry, 0);
factory_view->assign_tag_entry =
- gimp_tag_entry_new (GIMP_FILTERED_CONTAINER (factory_view->filtered_container),
- GIMP_TAG_ENTRY_MODE_ASSIGN);
+ gimp_combo_tag_entry_new (GIMP_FILTERED_CONTAINER (factory_view->filtered_container),
+ GIMP_TAG_ENTRY_MODE_ASSIGN);
gimp_tag_entry_set_selected_items (GIMP_TAG_ENTRY (factory_view->assign_tag_entry),
factory_view->selected_items);
g_list_free (factory_view->selected_items);
factory_view->selected_items = NULL;
-
- tag_combo = gimp_combo_tag_entry_new (GIMP_TAG_ENTRY (factory_view->assign_tag_entry));
- gtk_widget_show (tag_combo);
-
+ gtk_widget_show (factory_view->assign_tag_entry);
gtk_box_pack_start (GTK_BOX (editor->view),
- tag_combo,
+ factory_view->assign_tag_entry,
FALSE, FALSE, 0);
return TRUE;
Modified: branches/soc-2008-tagging/app/widgets/gimptagentry.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagentry.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.c Wed Aug 6 18:18:08 2008
@@ -44,6 +44,22 @@
#define GIMP_TAG_ENTRY_MAX_RECENT_ITEMS 20
+enum
+{
+ PROP_0,
+
+ PROP_FILTERED_CONTAINER,
+ PROP_TAG_ENTRY_MODE,
+};
+
+static void gimp_tag_entry_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_tag_entry_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void gimp_tag_entry_dispose (GObject *object);
static void gimp_tag_entry_activate (GtkEntry *entry,
gpointer unused);
@@ -108,6 +124,34 @@
gboolean to_front);
+GType
+gimp_tag_entry_mode_get_type (void)
+{
+ static const GEnumValue values[] =
+ {
+ { GIMP_TAG_ENTRY_MODE_QUERY, "GIMP_TAG_ENTRY_MODE_QUERY", "query" },
+ { GIMP_TAG_ENTRY_MODE_ASSIGN, "GIMP_TAG_ENTRY_MODE_ASSIGN", "assign" },
+ { 0, NULL, NULL }
+ };
+
+ static const GimpEnumDesc descs[] =
+ {
+ { GIMP_TAG_ENTRY_MODE_QUERY, N_("Query"), NULL },
+ { GIMP_TAG_ENTRY_MODE_ASSIGN, N_("Assign"), NULL },
+ { 0, NULL, NULL }
+ };
+
+ static GType type = 0;
+
+ if (! type)
+ {
+ type = g_enum_register_static ("GimpTagEntryMode", values);
+ gimp_enum_set_value_descriptions (type, descs);
+ }
+
+ return type;
+}
+
G_DEFINE_TYPE (GimpTagEntry, gimp_tag_entry, GTK_TYPE_ENTRY);
#define parent_class gimp_tag_entry_parent_class
@@ -121,17 +165,40 @@
GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
object_class->dispose = gimp_tag_entry_dispose;
+ object_class->get_property = gimp_tag_entry_get_property;
+ object_class->set_property = gimp_tag_entry_set_property;
widget_class->button_release_event = gimp_tag_entry_button_release;
entry_class->backspace = gimp_tag_entry_backspace;
entry_class->delete_from_cursor = gimp_tag_entry_delete_from_cursor;
+
+ g_object_class_install_property (object_class,
+ PROP_FILTERED_CONTAINER,
+ g_param_spec_object ("filtered-container",
+ ("Filtered container"),
+ ("The Filtered container"),
+ GIMP_TYPE_FILTERED_CONTAINER,
+ G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_WRITABLE
+ | G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_TAG_ENTRY_MODE,
+ g_param_spec_enum ("tag-entry-mode",
+ ("Working mode"),
+ ("Mode in which to work."),
+ GIMP_TYPE_TAG_ENTRY_MODE,
+ GIMP_TAG_ENTRY_MODE_QUERY,
+ G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_WRITABLE
+ | G_PARAM_READABLE));
}
static void
gimp_tag_entry_init (GimpTagEntry *entry)
{
- entry->tagged_container = NULL;
+ entry->filtered_container = NULL;
entry->selected_items = NULL;
entry->mode = GIMP_TAG_ENTRY_MODE_QUERY;
entry->description_shown = FALSE;
@@ -177,39 +244,86 @@
tag_entry->recent_list = NULL;
}
- if (tag_entry->tagged_container)
+ if (tag_entry->filtered_container)
{
- g_signal_handlers_disconnect_by_func (tag_entry->tagged_container,
+ g_signal_handlers_disconnect_by_func (tag_entry->filtered_container,
gimp_tag_entry_container_changed, tag_entry);
- g_object_unref (tag_entry->tagged_container);
- tag_entry->tagged_container = NULL;
+ g_object_unref (tag_entry->filtered_container);
+ tag_entry->filtered_container = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
+static void
+gimp_tag_entry_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (object);
+
+ switch (property_id)
+ {
+ case PROP_FILTERED_CONTAINER:
+ tag_entry->filtered_container = g_value_get_object (value);
+ g_assert (GIMP_IS_FILTERED_CONTAINER (tag_entry->filtered_container));
+ g_object_ref (tag_entry->filtered_container);
+ g_signal_connect (tag_entry->filtered_container, "add",
+ G_CALLBACK (gimp_tag_entry_container_changed), tag_entry);
+ g_signal_connect (tag_entry->filtered_container, "remove",
+ G_CALLBACK (gimp_tag_entry_container_changed), tag_entry);
+ break;
+
+ case PROP_TAG_ENTRY_MODE:
+ tag_entry->mode = g_value_get_enum (value);
+ gimp_tag_entry_toggle_desc (tag_entry, TRUE);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_tag_entry_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (object);
+
+ switch (property_id)
+ {
+ case PROP_FILTERED_CONTAINER:
+ g_value_set_object (value, tag_entry->filtered_container);
+ break;
+
+ case PROP_TAG_ENTRY_MODE:
+ g_value_set_enum (value, tag_entry->mode);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
GtkWidget *
-gimp_tag_entry_new (GimpFilteredContainer *tagged_container,
+gimp_tag_entry_new (GimpFilteredContainer *filtered_container,
GimpTagEntryMode mode)
{
GimpTagEntry *entry;
- g_return_val_if_fail (tagged_container == NULL
- || GIMP_IS_FILTERED_CONTAINER (tagged_container),
+ g_return_val_if_fail (filtered_container == NULL
+ || GIMP_IS_FILTERED_CONTAINER (filtered_container),
NULL);
- entry = g_object_new (GIMP_TYPE_TAG_ENTRY, NULL);
- entry->tagged_container = tagged_container;
- entry->mode = mode;
-
- g_object_ref (tagged_container);
- g_signal_connect (entry->tagged_container, "add",
- G_CALLBACK (gimp_tag_entry_container_changed), entry);
- g_signal_connect (entry->tagged_container, "remove",
- G_CALLBACK (gimp_tag_entry_container_changed), entry);
-
- gimp_tag_entry_toggle_desc (entry, TRUE);
-
+ entry = g_object_new (GIMP_TYPE_TAG_ENTRY,
+ "filtered-container", filtered_container,
+ "tag-entry-mode", mode,
+ NULL);
return GTK_WIDGET (entry);
}
@@ -237,7 +351,7 @@
iterator = tag_entry->selected_items;
while (iterator)
{
- if (gimp_container_have (GIMP_CONTAINER (tag_entry->tagged_container),
+ if (gimp_container_have (GIMP_CONTAINER (tag_entry->filtered_container),
GIMP_OBJECT(iterator->data)))
{
break;
@@ -334,7 +448,7 @@
}
g_strfreev (parsed_tags);
- gimp_filtered_container_set_filter (GIMP_FILTERED_CONTAINER (entry->tagged_container),
+ gimp_filtered_container_set_filter (GIMP_FILTERED_CONTAINER (entry->filtered_container),
query_list);
}
@@ -431,7 +545,7 @@
while (iterator)
{
if (gimp_tagged_get_tags (GIMP_TAGGED (iterator->data))
- && gimp_container_have (GIMP_CONTAINER (tag_entry->tagged_container),
+ && gimp_container_have (GIMP_CONTAINER (tag_entry->filtered_container),
GIMP_OBJECT(iterator->data)))
{
break;
@@ -623,7 +737,7 @@
while (iterator)
{
if (gimp_tagged_get_tags (GIMP_TAGGED (iterator->data))
- && gimp_container_have (GIMP_CONTAINER (entry->tagged_container),
+ && gimp_container_have (GIMP_CONTAINER (entry->filtered_container),
GIMP_OBJECT(iterator->data)))
{
break;
@@ -751,7 +865,7 @@
return NULL;
}
- all_tags = g_hash_table_get_keys (tag_entry->tagged_container->tag_ref_counts);
+ all_tags = g_hash_table_get_keys (tag_entry->filtered_container->tag_ref_counts);
tag_iterator = all_tags;
length = g_strv_length (used_tags);
while (tag_iterator)
@@ -897,7 +1011,7 @@
while (selected_iterator)
{
if (gimp_tagged_get_tags (GIMP_TAGGED (selected_iterator->data))
- && gimp_container_have (GIMP_CONTAINER (tag_entry->tagged_container),
+ && gimp_container_have (GIMP_CONTAINER (tag_entry->filtered_container),
GIMP_OBJECT(selected_iterator->data)))
{
break;
Modified: branches/soc-2008-tagging/app/widgets/gimptagentry.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagentry.h (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.h Wed Aug 6 18:18:08 2008
@@ -30,11 +30,14 @@
#define GIMP_IS_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_ENTRY))
#define GIMP_TAG_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TAG_ENTRY, GimpTagEntryClass))
+#define GIMP_TYPE_TAG_ENTRY_MODE (gimp_tag_entry_mode_get_type ())
+
+GType gimp_tag_entry_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
- GIMP_TAG_ENTRY_MODE_QUERY,
- GIMP_TAG_ENTRY_MODE_ASSIGN,
+ GIMP_TAG_ENTRY_MODE_QUERY, /*< desc="Query" >*/
+ GIMP_TAG_ENTRY_MODE_ASSIGN, /*< desc="Assign" >*/
} GimpTagEntryMode;
typedef struct _GimpTagEntryClass GimpTagEntryClass;
@@ -43,7 +46,7 @@
{
GtkEntry parent_instance;
- GimpFilteredContainer *tagged_container;
+ GimpFilteredContainer *filtered_container;
GList *selected_items;
GList *recent_list;
GimpTagEntryMode mode;
Modified: branches/soc-2008-tagging/app/widgets/gimptagpopup.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagpopup.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagpopup.c Wed Aug 6 18:18:08 2008
@@ -125,7 +125,7 @@
/* FIXME: parent should do this on destroy event */
if (tag_popup->combo_entry)
{
- gtk_widget_grab_focus (tag_popup->combo_entry->tag_entry);
+ gtk_widget_grab_focus (GTK_WIDGET (tag_popup->combo_entry));
tag_popup->combo_entry->popup = NULL;
tag_popup->combo_entry = NULL;
}
@@ -221,10 +221,10 @@
pango_layout_set_attributes (popup->layout, combo_entry->normal_item_attr);
- current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (combo_entry->tag_entry));
+ current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (combo_entry));
current_count = g_strv_length (current_tags);
- tag_hash = GIMP_TAG_ENTRY (combo_entry->tag_entry)->tagged_container->tag_ref_counts;
+ tag_hash = combo_entry->filtered_container->tag_ref_counts;
tag_list = g_hash_table_get_keys (tag_hash);
tag_list = g_list_sort (tag_list, gimp_tag_compare_func);
popup->tag_count = g_list_length (tag_list);
@@ -248,7 +248,7 @@
g_list_free (tag_list);
g_strfreev (current_tags);
- if (GIMP_TAG_ENTRY (combo_entry->tag_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
+ if (GIMP_TAG_ENTRY (combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
{
for (i = 0; i < popup->tag_count; i++)
{
@@ -257,7 +257,7 @@
popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
}
}
- gimp_container_foreach (GIMP_CONTAINER (GIMP_TAG_ENTRY (combo_entry->tag_entry)->tagged_container),
+ gimp_container_foreach (GIMP_CONTAINER (combo_entry->filtered_container),
(GFunc) gimp_tag_popup_check_can_toggle, popup);
}
@@ -819,7 +819,7 @@
}
tag = gimp_tag_get_name (tag_data->tag);
- current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry));
+ current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (tag_popup->combo_entry));
tag_str = g_string_new ("");
length = g_strv_length (current_tags);
for (i = 0; i < length; i++)
@@ -849,13 +849,13 @@
g_string_append (tag_str, tag);
}
- gimp_tag_entry_set_tag_string (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry),
+ gimp_tag_entry_set_tag_string (GIMP_TAG_ENTRY (tag_popup->combo_entry),
tag_str->str);
g_string_free (tag_str, TRUE);
g_strfreev (current_tags);
- if (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
+ if (GIMP_TAG_ENTRY (tag_popup->combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
{
for (i = 0; i < tag_popup->tag_count; i++)
{
@@ -864,7 +864,7 @@
tag_popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
}
}
- gimp_container_foreach (GIMP_CONTAINER (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry)->tagged_container),
+ gimp_container_foreach (GIMP_CONTAINER (tag_popup->combo_entry->filtered_container),
(GFunc) gimp_tag_popup_check_can_toggle, tag_popup);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]