gimp r27861 - in trunk: . app/widgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27861 - in trunk: . app/widgets
- Date: Wed, 31 Dec 2008 00:01:24 +0000 (UTC)
Author: neo
Date: Wed Dec 31 00:01:24 2008
New Revision: 27861
URL: http://svn.gnome.org/viewvc/gimp?rev=27861&view=rev
Log:
2008-12-31 Sven Neumann <sven gimp org>
* app/widgets/widgets-enums.[ch]: added GimpTagEntryMode.
* app/widgets/gimptagentry.[ch]: removed it here. Also did some
code cleanup, mostly formatting.
* app/widgets/gimpcombotagentry.[ch]
* app/widgets/gimptagpopup.[ch]: some code cleanup, mostly
formatting.
Modified:
trunk/ChangeLog
trunk/app/widgets/gimpcombotagentry.c
trunk/app/widgets/gimpcombotagentry.h
trunk/app/widgets/gimptagentry.c
trunk/app/widgets/gimptagentry.h
trunk/app/widgets/gimptagpopup.c
trunk/app/widgets/gimptagpopup.h
trunk/app/widgets/widgets-enums.c
trunk/app/widgets/widgets-enums.h
Modified: trunk/app/widgets/gimpcombotagentry.c
==============================================================================
--- trunk/app/widgets/gimpcombotagentry.c (original)
+++ trunk/app/widgets/gimpcombotagentry.c Wed Dec 31 00:01:24 2008
@@ -38,6 +38,7 @@
#include "gimptagpopup.h"
#include "gimpcombotagentry.h"
+
static GObject* gimp_combo_tag_entry_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
@@ -51,15 +52,15 @@
static void gimp_combo_tag_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style);
-static void gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry);
+static void gimp_combo_tag_entry_popup_list (GimpComboTagEntry *entry);
static void gimp_combo_tag_entry_popup_destroy (GtkObject *object,
- GimpComboTagEntry *combo_entry);
+ GimpComboTagEntry *entry);
static void gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
gint tag_count,
- GimpComboTagEntry *combo_entry);
+ GimpComboTagEntry *entry);
-static void gimp_combo_tag_entry_get_arrow_rect (GimpComboTagEntry *combo_entry,
+static void gimp_combo_tag_entry_get_arrow_rect (GimpComboTagEntry *entry,
GdkRectangle *arrow_rect);
@@ -81,21 +82,21 @@
}
static void
-gimp_combo_tag_entry_init (GimpComboTagEntry *combo_entry)
+gimp_combo_tag_entry_init (GimpComboTagEntry *entry)
{
GtkBorder border;
- combo_entry->popup = NULL;
- combo_entry->focus_width = 0;
- combo_entry->interior_focus = FALSE;
- combo_entry->normal_item_attr = NULL;
- combo_entry->selected_item_attr = NULL;
- combo_entry->insensitive_item_attr = NULL;
+ entry->popup = NULL;
+ entry->focus_width = 0;
+ entry->interior_focus = FALSE;
+ entry->normal_item_attr = NULL;
+ entry->selected_item_attr = NULL;
+ entry->insensitive_item_attr = NULL;
- gtk_widget_add_events (GTK_WIDGET (combo_entry),
+ gtk_widget_add_events (GTK_WIDGET (entry),
GDK_BUTTON_PRESS_MASK);
- if (gtk_widget_get_direction (GTK_WIDGET (combo_entry)) == GTK_TEXT_DIR_RTL)
+ if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
{
border.left = 18;
border.right = 2;
@@ -107,16 +108,16 @@
}
border.top = 2;
border.bottom = 2;
- gtk_entry_set_inner_border (GTK_ENTRY (combo_entry), &border);
+ gtk_entry_set_inner_border (GTK_ENTRY (entry), &border);
- g_signal_connect_after (combo_entry, "expose-event",
+ g_signal_connect_after (entry, "expose-event",
G_CALLBACK (gimp_combo_tag_entry_expose_event),
NULL);
- g_signal_connect (combo_entry, "style-set",
+ g_signal_connect (entry, "style-set",
G_CALLBACK (gimp_combo_tag_entry_style_set),
NULL);
- g_signal_connect (combo_entry, "event",
+ g_signal_connect (entry, "event",
G_CALLBACK (gimp_combo_tag_entry_event),
NULL);
}
@@ -126,30 +127,27 @@
guint n_params,
GObjectConstructParam *params)
{
- GObject *object;
- GimpComboTagEntry *combo_entry;
+ GObject *object;
+ GimpComboTagEntry *entry;
object = G_OBJECT_CLASS (parent_class)->constructor (type,
n_params,
params);
- combo_entry = GIMP_COMBO_TAG_ENTRY (object);
- combo_entry->filtered_container =
- GIMP_TAG_ENTRY (combo_entry)->filtered_container;
- g_object_ref (combo_entry->filtered_container);
+ entry = GIMP_COMBO_TAG_ENTRY (object);
- g_signal_connect (combo_entry->filtered_container,
+ g_signal_connect (GIMP_TAG_ENTRY (entry)->container,
"tag-count-changed",
G_CALLBACK (gimp_combo_tag_entry_tag_count_changed),
- combo_entry);
+ entry);
return object;
}
static void
-gimp_combo_tag_entry_dispose (GObject *object)
+gimp_combo_tag_entry_dispose (GObject *object)
{
- GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (object);
+ GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (object);
if (combo_entry->normal_item_attr)
{
@@ -167,23 +165,13 @@
combo_entry->insensitive_item_attr = NULL;
}
- if (combo_entry->filtered_container)
- {
- g_signal_handlers_disconnect_by_func (combo_entry->filtered_container,
- G_CALLBACK (gimp_combo_tag_entry_tag_count_changed),
- combo_entry);
-
- g_object_unref (combo_entry->filtered_container);
- combo_entry->filtered_container = NULL;
- }
-
G_OBJECT_CLASS (parent_class)->dispose (object);
}
/**
* gimp_combo_tag_entry_new:
- * @filtered_container: a filtered container to be used.
- * @mode: tag entry mode to work in.
+ * @container: a filtered container to be used.
+ * @mode: tag entry mode to work in.
*
* Creates a new #GimpComboTagEntry widget which extends #GimpTagEntry by
* adding ability to pick tags using popup window (similar to combo box).
@@ -191,39 +179,37 @@
* Return value: a new #GimpComboTagEntry widget.
**/
GtkWidget *
-gimp_combo_tag_entry_new (GimpFilteredContainer *filtered_container,
- GimpTagEntryMode mode)
+gimp_combo_tag_entry_new (GimpFilteredContainer *container,
+ GimpTagEntryMode mode)
{
- GimpComboTagEntry *combo_entry;
-
- g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (filtered_container), NULL);
+ g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (container), NULL);
- combo_entry = g_object_new (GIMP_TYPE_COMBO_TAG_ENTRY,
- "filtered-container", filtered_container,
- "tag-entry-mode", mode,
- NULL);
- return GTK_WIDGET (combo_entry);
+ return g_object_new (GIMP_TYPE_COMBO_TAG_ENTRY,
+ "container", container,
+ "mode", mode,
+ NULL);
}
static gboolean
-gimp_combo_tag_entry_expose_event (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer user_data)
-{
- GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
- GdkRectangle arrow_rect;
- gint tag_count;
- gint window_width;
- gint window_height;
- GtkStateType arrow_state;
+gimp_combo_tag_entry_expose_event (GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer user_data)
+{
+ GimpComboTagEntry *entry = GIMP_COMBO_TAG_ENTRY (widget);
+ GimpFilteredContainer *container = GIMP_TAG_ENTRY (entry)->container;
+ GdkRectangle arrow_rect;
+ gint tag_count;
+ gint window_width;
+ gint window_height;
+ GtkStateType arrow_state;
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);
+ gimp_combo_tag_entry_get_arrow_rect (entry, &arrow_rect);
+ tag_count = gimp_filtered_container_get_tag_count (container);
gdk_drawable_get_size (GDK_DRAWABLE (event->window), &window_width, &window_height);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
@@ -238,7 +224,7 @@
}
if (tag_count > 0
- && ! GIMP_TAG_ENTRY (combo_entry)->has_invalid_tags)
+ && ! GIMP_TAG_ENTRY (entry)->has_invalid_tags)
{
arrow_state = GTK_STATE_NORMAL;
}
@@ -258,11 +244,11 @@
}
static gboolean
-gimp_combo_tag_entry_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
+gimp_combo_tag_entry_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
{
- GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
+ GimpComboTagEntry *entry = GIMP_COMBO_TAG_ENTRY (widget);
if (event->type == GDK_BUTTON_PRESS)
{
@@ -275,19 +261,19 @@
x = button_event->x;
y = button_event->y;
- gimp_combo_tag_entry_get_arrow_rect (combo_entry, &arrow_rect);
+ gimp_combo_tag_entry_get_arrow_rect (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)
+ if (! entry->popup)
{
- gimp_combo_tag_entry_popup_list (combo_entry);
+ gimp_combo_tag_entry_popup_list (entry);
}
else
{
- gtk_widget_destroy (combo_entry->popup);
+ gtk_widget_destroy (entry->popup);
}
return TRUE;
@@ -298,88 +284,90 @@
}
static void
-gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry)
+gimp_combo_tag_entry_popup_list (GimpComboTagEntry *entry)
{
- gint tag_count;
+ GimpFilteredContainer *container = GIMP_TAG_ENTRY (entry)->container;
+ gint tag_count;
+
+ tag_count = gimp_filtered_container_get_tag_count (container);
- tag_count = gimp_filtered_container_get_tag_count (combo_entry->filtered_container);
if (tag_count > 0
- && ! GIMP_TAG_ENTRY (combo_entry)->has_invalid_tags)
+ && ! GIMP_TAG_ENTRY (entry)->has_invalid_tags)
{
- combo_entry->popup = gimp_tag_popup_new (combo_entry);
- g_signal_connect (combo_entry->popup, "destroy",
+ entry->popup = gimp_tag_popup_new (entry);
+ g_signal_connect (entry->popup, "destroy",
G_CALLBACK (gimp_combo_tag_entry_popup_destroy),
- combo_entry);
- gimp_tag_popup_show (GIMP_TAG_POPUP (combo_entry->popup));
+ entry);
+ gimp_tag_popup_show (GIMP_TAG_POPUP (entry->popup));
}
}
static void
-gimp_combo_tag_entry_popup_destroy (GtkObject *object,
- GimpComboTagEntry *combo_entry)
+gimp_combo_tag_entry_popup_destroy (GtkObject *object,
+ GimpComboTagEntry *entry)
{
- combo_entry->popup = NULL;
- gtk_widget_grab_focus (GTK_WIDGET (combo_entry));
+ entry->popup = NULL;
+ gtk_widget_grab_focus (GTK_WIDGET (entry));
}
static void
-gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
- gint tag_count,
- GimpComboTagEntry *combo_entry)
+gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
+ gint tag_count,
+ GimpComboTagEntry *entry)
{
- gtk_widget_queue_draw (GTK_WIDGET (combo_entry));
+ gtk_widget_queue_draw (GTK_WIDGET (entry));
}
static void
-gimp_combo_tag_entry_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+gimp_combo_tag_entry_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
{
- GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (widget);
- GtkStyle *style;
- GdkColor color;
- PangoAttribute *attribute;
+ GimpComboTagEntry *entry = GIMP_COMBO_TAG_ENTRY (widget);
+ GtkStyle *style;
+ GdkColor color;
+ PangoAttribute *attribute;
style = widget->style;
- if (combo_entry->normal_item_attr)
+ if (entry->normal_item_attr)
{
- pango_attr_list_unref (combo_entry->normal_item_attr);
+ pango_attr_list_unref (entry->normal_item_attr);
}
- combo_entry->normal_item_attr = pango_attr_list_new ();
+ entry->normal_item_attr = pango_attr_list_new ();
if (style->font_desc)
{
attribute = pango_attr_font_desc_new (style->font_desc);
- pango_attr_list_insert (combo_entry->normal_item_attr, attribute);
+ pango_attr_list_insert (entry->normal_item_attr, attribute);
}
color = style->text[GTK_STATE_NORMAL];
attribute = pango_attr_foreground_new (color.red, color.green, color.blue);
- pango_attr_list_insert (combo_entry->normal_item_attr, attribute);
+ pango_attr_list_insert (entry->normal_item_attr, attribute);
- if (combo_entry->selected_item_attr)
+ if (entry->selected_item_attr)
{
- pango_attr_list_unref (combo_entry->selected_item_attr);
+ pango_attr_list_unref (entry->selected_item_attr);
}
- combo_entry->selected_item_attr = pango_attr_list_copy (combo_entry->normal_item_attr);
+ entry->selected_item_attr = pango_attr_list_copy (entry->normal_item_attr);
color = style->text[GTK_STATE_SELECTED];
attribute = pango_attr_foreground_new (color.red, color.green, color.blue);
- pango_attr_list_insert (combo_entry->selected_item_attr, attribute);
+ pango_attr_list_insert (entry->selected_item_attr, attribute);
color = style->base[GTK_STATE_SELECTED];
attribute = pango_attr_background_new (color.red, color.green, color.blue);
- pango_attr_list_insert (combo_entry->selected_item_attr, attribute);
+ pango_attr_list_insert (entry->selected_item_attr, attribute);
- if (combo_entry->insensitive_item_attr)
+ if (entry->insensitive_item_attr)
{
- pango_attr_list_unref (combo_entry->insensitive_item_attr);
+ pango_attr_list_unref (entry->insensitive_item_attr);
}
- combo_entry->insensitive_item_attr = pango_attr_list_copy (combo_entry->normal_item_attr);
+ entry->insensitive_item_attr = pango_attr_list_copy (entry->normal_item_attr);
color = style->text[GTK_STATE_INSENSITIVE];
attribute = pango_attr_foreground_new (color.red, color.green, color.blue);
- pango_attr_list_insert (combo_entry->insensitive_item_attr, attribute);
+ pango_attr_list_insert (entry->insensitive_item_attr, attribute);
color = style->base[GTK_STATE_INSENSITIVE];
attribute = pango_attr_background_new (color.red, color.green, color.blue);
- pango_attr_list_insert (combo_entry->insensitive_item_attr, attribute);
+ pango_attr_list_insert (entry->insensitive_item_attr, attribute);
- combo_entry->selected_item_color = style->base[GTK_STATE_SELECTED];
+ entry->selected_item_color = style->base[GTK_STATE_SELECTED];
if (GTK_WIDGET_CLASS (parent_class))
{
@@ -388,10 +376,10 @@
}
static void
-gimp_combo_tag_entry_get_arrow_rect (GimpComboTagEntry *combo_entry,
- GdkRectangle *arrow_rect)
+gimp_combo_tag_entry_get_arrow_rect (GimpComboTagEntry *entry,
+ GdkRectangle *arrow_rect)
{
- GtkWidget *widget = GTK_WIDGET (combo_entry);
+ GtkWidget *widget = GTK_WIDGET (entry);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
{
@@ -401,6 +389,7 @@
{
arrow_rect->x = widget->allocation.width - 16 - widget->style->xthickness * 2;
}
+
arrow_rect->y = 0;
arrow_rect->width = 12;
arrow_rect->height = widget->allocation.height - widget->style->ythickness * 2;
Modified: trunk/app/widgets/gimpcombotagentry.h
==============================================================================
--- trunk/app/widgets/gimpcombotagentry.h (original)
+++ trunk/app/widgets/gimpcombotagentry.h Wed Dec 31 00:01:24 2008
@@ -36,27 +36,27 @@
struct _GimpComboTagEntry
{
- GimpTagEntry parent_instance;
+ GimpTagEntry parent_instance;
- GtkWidget *popup;
- GimpFilteredContainer *filtered_container;
- gint focus_width;
- PangoAttrList *normal_item_attr;
- PangoAttrList *selected_item_attr;
- PangoAttrList *insensitive_item_attr;
- GdkColor selected_item_color;
- gboolean interior_focus;
+ GtkWidget *popup;
+ gint focus_width;
+ PangoAttrList *normal_item_attr;
+ PangoAttrList *selected_item_attr;
+ PangoAttrList *insensitive_item_attr;
+ GdkColor selected_item_color;
+ gboolean interior_focus;
};
struct _GimpComboTagEntryClass
{
- GimpTagEntryClass parent_class;
+ GimpTagEntryClass parent_class;
};
-GType gimp_combo_tag_entry_get_type (void) G_GNUC_CONST;
+GType gimp_combo_tag_entry_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_combo_tag_entry_new (GimpFilteredContainer *container,
+ GimpTagEntryMode mode);
-GtkWidget * gimp_combo_tag_entry_new (GimpFilteredContainer *filtered_container,
- GimpTagEntryMode mode);
#endif /* __GIMP_COMBO_TAG_ENTRY_H__ */
Modified: trunk/app/widgets/gimptagentry.c
==============================================================================
--- trunk/app/widgets/gimptagentry.c (original)
+++ trunk/app/widgets/gimptagentry.c Wed Dec 31 00:01:24 2008
@@ -40,12 +40,14 @@
#include "gimp-intl.h"
+
#define GIMP_TAG_ENTRY_QUERY_DESC _("filter")
#define GIMP_TAG_ENTRY_ASSIGN_DESC _("enter tags")
#define GIMP_TAG_ENTRY_MAX_RECENT_ITEMS 20
-typedef enum GimpTagSearchDir_
+
+typedef enum
{
TAG_SEARCH_NONE,
TAG_SEARCH_LEFT,
@@ -55,9 +57,8 @@
enum
{
PROP_0,
-
- PROP_FILTERED_CONTAINER,
- PROP_TAG_ENTRY_MODE,
+ PROP_CONTAINER,
+ PROP_MODE,
};
static void gimp_tag_entry_set_property (GObject *object,
@@ -69,106 +70,71 @@
GValue *value,
GParamSpec *pspec);
static void gimp_tag_entry_dispose (GObject *object);
-static void gimp_tag_entry_activate (GtkEntry *entry,
- gpointer unused);
-static void gimp_tag_entry_changed (GtkEntry *entry,
- gpointer unused);
+static void gimp_tag_entry_activate (GtkEntry *entry);
+static void gimp_tag_entry_changed (GtkEntry *entry);
static void gimp_tag_entry_insert_text (GtkEditable *editable,
gchar *new_text,
gint text_length,
- gint *position,
- gpointer user_data);
+ gint *position);
static void gimp_tag_entry_delete_text (GtkEditable *editable,
gint start_pos,
- gint end_pos,
- gpointer user_data);
+ gint end_pos);
static gboolean gimp_tag_entry_focus_in (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer user_data);
+ GdkEventFocus *event);
static gboolean gimp_tag_entry_focus_out (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer user_data);
+ GdkEventFocus *event);
static void gimp_tag_entry_container_changed (GimpContainer *container,
GimpObject *object,
- GimpTagEntry *tag_entry);
+ GimpTagEntry *entry);
static gboolean gimp_tag_entry_button_release (GtkWidget *widget,
GdkEventButton *event);
static gboolean gimp_tag_entry_key_press (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data);
+ GdkEventKey *event);
static gboolean gimp_tag_entry_query_tag (GimpTagEntry *entry);
-static void gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry);
+static void gimp_tag_entry_assign_tags (GimpTagEntry *entry);
static void gimp_tag_entry_item_set_tags (GimpTagged *entry,
GList *tags);
-static void gimp_tag_entry_load_selection (GimpTagEntry *tag_entry,
+static void gimp_tag_entry_load_selection (GimpTagEntry *entry,
gboolean sort);
static gchar* gimp_tag_entry_get_completion_prefix (GimpTagEntry *entry);
-static GList * gimp_tag_entry_get_completion_candidates (GimpTagEntry *tag_entry,
+static GList * gimp_tag_entry_get_completion_candidates (GimpTagEntry *entry,
gchar **used_tags,
gchar *prefix);
-static gchar * gimp_tag_entry_get_completion_string (GimpTagEntry *tag_entry,
+static gchar * gimp_tag_entry_get_completion_string (GimpTagEntry *entry,
GList *candidates,
gchar *prefix);
-static gboolean gimp_tag_entry_auto_complete (GimpTagEntry *tag_entry);
+static gboolean gimp_tag_entry_auto_complete (GimpTagEntry *entry);
static void gimp_tag_entry_toggle_desc (GimpTagEntry *widget,
gboolean show);
static gboolean gimp_tag_entry_expose (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer user_data);
+ GdkEventExpose *event);
static void gimp_tag_entry_commit_region (GString *tags,
GString *mask);
-static void gimp_tag_entry_commit_tags (GimpTagEntry *tag_entry);
-static gboolean gimp_tag_entry_commit_source_func (GimpTagEntry *tag_entry);
+static void gimp_tag_entry_commit_tags (GimpTagEntry *entry);
+static gboolean gimp_tag_entry_commit_source_func (GimpTagEntry *entry);
static gboolean gimp_tag_entry_select_jellybean (GimpTagEntry *entry,
gint selection_start,
gint selection_end,
GimpTagSearchDir search_dir);
-static gboolean gimp_tag_entry_try_select_jellybean (GimpTagEntry *tag_entry);
+static gboolean gimp_tag_entry_try_select_jellybean (GimpTagEntry *entry);
-static gboolean gimp_tag_entry_add_to_recent (GimpTagEntry *tag_entry,
+static gboolean gimp_tag_entry_add_to_recent (GimpTagEntry *entry,
const gchar *tags_string,
gboolean to_front);
-static void gimp_tag_entry_next_tag (GimpTagEntry *tag_entry,
+static void gimp_tag_entry_next_tag (GimpTagEntry *entry,
gboolean select);
-static void gimp_tag_entry_previous_tag (GimpTagEntry *tag_entry,
+static void gimp_tag_entry_previous_tag (GimpTagEntry *entry,
gboolean select);
-static void gimp_tag_entry_select_for_deletion (GimpTagEntry *tag_entry,
+static void gimp_tag_entry_select_for_deletion (GimpTagEntry *entry,
GimpTagSearchDir search_dir);
-static gboolean gimp_tag_entry_strip_extra_whitespace (GimpTagEntry *tag_entry);
-
-
-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 gboolean gimp_tag_entry_strip_extra_whitespace (GimpTagEntry *entry);
- 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);
@@ -178,18 +144,18 @@
static void
gimp_tag_entry_class_init (GimpTagEntryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_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;
+ 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;
+ widget_class->button_release_event = gimp_tag_entry_button_release;
g_object_class_install_property (object_class,
- PROP_FILTERED_CONTAINER,
- g_param_spec_object ("filtered-container",
+ PROP_CONTAINER,
+ g_param_spec_object ("container",
("Filtered container"),
("The Filtered container"),
GIMP_TYPE_FILTERED_CONTAINER,
@@ -198,8 +164,8 @@
| G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_TAG_ENTRY_MODE,
- g_param_spec_enum ("tag-entry-mode",
+ PROP_MODE,
+ g_param_spec_enum ("mode",
("Working mode"),
("Mode in which to work."),
GIMP_TYPE_TAG_ENTRY_MODE,
@@ -212,7 +178,7 @@
static void
gimp_tag_entry_init (GimpTagEntry *entry)
{
- entry->filtered_container = NULL;
+ entry->container = NULL;
entry->selected_items = NULL;
entry->tab_completion_index = -1;
entry->mode = GIMP_TAG_ENTRY_MODE_QUERY;
@@ -247,66 +213,66 @@
}
static void
-gimp_tag_entry_dispose (GObject *object)
+gimp_tag_entry_dispose (GObject *object)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (object);
+ GimpTagEntry *entry = GIMP_TAG_ENTRY (object);
- if (tag_entry->selected_items)
+ if (entry->selected_items)
{
- g_list_free (tag_entry->selected_items);
- tag_entry->selected_items = NULL;
+ g_list_free (entry->selected_items);
+ entry->selected_items = NULL;
}
- if (tag_entry->recent_list)
+ if (entry->recent_list)
{
- g_list_foreach (tag_entry->recent_list, (GFunc) g_free, NULL);
- g_list_free (tag_entry->recent_list);
- tag_entry->recent_list = NULL;
+ g_list_foreach (entry->recent_list, (GFunc) g_free, NULL);
+ g_list_free (entry->recent_list);
+ entry->recent_list = NULL;
}
- if (tag_entry->filtered_container)
+ if (entry->container)
{
- g_signal_handlers_disconnect_by_func (tag_entry->filtered_container,
+ g_signal_handlers_disconnect_by_func (entry->container,
gimp_tag_entry_container_changed,
- tag_entry);
- g_object_unref (tag_entry->filtered_container);
- tag_entry->filtered_container = NULL;
+ entry);
+ g_object_unref (entry->container);
+ entry->container = NULL;
}
- if (tag_entry->mask)
+ if (entry->mask)
{
- g_string_free (tag_entry->mask, TRUE);
- tag_entry->mask = NULL;
+ g_string_free (entry->mask, TRUE);
+ entry->mask = 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)
+gimp_tag_entry_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (object);
+ GimpTagEntry *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",
+ case PROP_CONTAINER:
+ entry->container = g_value_get_object (value);
+ g_assert (GIMP_IS_FILTERED_CONTAINER (entry->container));
+ g_object_ref (entry->container);
+ g_signal_connect (entry->container, "add",
G_CALLBACK (gimp_tag_entry_container_changed),
- tag_entry);
- g_signal_connect (tag_entry->filtered_container, "remove",
+ entry);
+ g_signal_connect (entry->container, "remove",
G_CALLBACK (gimp_tag_entry_container_changed),
- tag_entry);
+ entry);
break;
- case PROP_TAG_ENTRY_MODE:
- tag_entry->mode = g_value_get_enum (value);
- gimp_tag_entry_toggle_desc (tag_entry, TRUE);
+ case PROP_MODE:
+ entry->mode = g_value_get_enum (value);
+ gimp_tag_entry_toggle_desc (entry, TRUE);
break;
default:
@@ -316,21 +282,21 @@
}
static void
-gimp_tag_entry_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+gimp_tag_entry_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (object);
+ GimpTagEntry *entry = GIMP_TAG_ENTRY (object);
switch (property_id)
{
- case PROP_FILTERED_CONTAINER:
- g_value_set_object (value, tag_entry->filtered_container);
+ case PROP_CONTAINER:
+ g_value_set_object (value, entry->container);
break;
- case PROP_TAG_ENTRY_MODE:
- g_value_set_enum (value, tag_entry->mode);
+ case PROP_MODE:
+ g_value_set_enum (value, entry->mode);
break;
default:
@@ -341,42 +307,35 @@
/**
* gimp_tag_entry_new:
- * @filtered_container: a #GimpFilteredContainer object
- * @mode: #GimpTagEntryMode to work in.
+ * @container: a #GimpFilteredContainer object
+ * @mode: #GimpTagEntryMode to work in.
*
* #GimpTagEntry is a widget which can query and assign tags to tagged objects.
- * When operating in query mode, @filtered_container is kept up to date with
+ * When operating in query mode, @container is kept up to date with
* tags selected. When operating in assignment mode, tags are assigned to
- * objects selected and visible in @filtered_container.
+ * objects selected and visible in @container.
*
* Return value: a new GimpTagEntry widget.
**/
GtkWidget *
-gimp_tag_entry_new (GimpFilteredContainer *filtered_container,
- GimpTagEntryMode mode)
+gimp_tag_entry_new (GimpFilteredContainer *container,
+ GimpTagEntryMode mode)
{
- GimpTagEntry *entry;
+ g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (container), NULL);
- g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (filtered_container),
- NULL);
-
- entry = g_object_new (GIMP_TYPE_TAG_ENTRY,
- "filtered-container", filtered_container,
- "tag-entry-mode", mode,
- NULL);
- return GTK_WIDGET (entry);
+ return g_object_new (GIMP_TYPE_TAG_ENTRY,
+ "container", container,
+ "mode", mode,
+ NULL);
}
static void
-gimp_tag_entry_activate (GtkEntry *entry,
- gpointer unused)
+gimp_tag_entry_activate (GtkEntry *entry)
{
- GimpTagEntry *tag_entry;
- gint selection_start;
- gint selection_end;
- GList *iterator;
-
- tag_entry = GIMP_TAG_ENTRY (entry);
+ GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (entry);
+ gint selection_start;
+ gint selection_end;
+ GList *iterator;
gimp_tag_entry_toggle_desc (tag_entry, FALSE);
@@ -391,7 +350,7 @@
for (iterator = tag_entry->selected_items; iterator;
iterator = g_list_next (iterator))
{
- if (gimp_container_have (GIMP_CONTAINER (tag_entry->filtered_container),
+ if (gimp_container_have (GIMP_CONTAINER (tag_entry->container),
GIMP_OBJECT(iterator->data)))
{
break;
@@ -407,7 +366,7 @@
/**
* gimp_tag_entry_set_tag_string:
- * @tag_entry: a #GimpTagEntry object.
+ * @entry: a #GimpTagEntry object.
* @tag_string: string of tags, separated by any terminal punctuation
* character.
*
@@ -416,29 +375,28 @@
* selected #GimpTagEntryMode, appropriate action is peformed.
**/
void
-gimp_tag_entry_set_tag_string (GimpTagEntry *tag_entry,
- const gchar *tag_string)
+gimp_tag_entry_set_tag_string (GimpTagEntry *entry,
+ const gchar *tag_string)
{
- g_return_if_fail (GIMP_IS_TAG_ENTRY (tag_entry));
+ g_return_if_fail (GIMP_IS_TAG_ENTRY (entry));
- tag_entry->internal_operation++;
- gtk_entry_set_text (GTK_ENTRY (tag_entry), tag_string);
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), -1);
- tag_entry->internal_operation--;
- gimp_tag_entry_commit_tags (tag_entry);
+ entry->internal_operation++;
+ gtk_entry_set_text (GTK_ENTRY (entry), tag_string);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ entry->internal_operation--;
+ gimp_tag_entry_commit_tags (entry);
- if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
+ if (entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
{
- gimp_tag_entry_assign_tags (tag_entry);
+ gimp_tag_entry_assign_tags (entry);
}
}
static void
-gimp_tag_entry_changed (GtkEntry *entry,
- gpointer unused)
+gimp_tag_entry_changed (GtkEntry *entry)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (entry);
- gchar *text;
+ GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (entry);
+ gchar *text;
text = g_strdup (gtk_entry_get_text (entry));
text = g_strstrip (text);
@@ -458,19 +416,17 @@
&& ! tag_entry->tag_query_pending)
{
tag_entry->tag_query_pending = TRUE;
- g_idle_add ((GSourceFunc)gimp_tag_entry_query_tag,
- GIMP_TAG_ENTRY (entry));
+ g_idle_add ((GSourceFunc) gimp_tag_entry_query_tag, entry);
}
}
static void
-gimp_tag_entry_insert_text (GtkEditable *editable,
- gchar *new_text,
- gint text_length,
- gint *position,
- gpointer user_data)
+gimp_tag_entry_insert_text (GtkEditable *editable,
+ gchar *new_text,
+ gint text_length,
+ gint *position)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (editable);
+ GimpTagEntry *entry = GIMP_TAG_ENTRY (editable);
const gchar *entry_text;
gboolean is_tag[2];
gint i;
@@ -480,18 +436,18 @@
entry_text = gtk_entry_get_text (GTK_ENTRY (editable));
num_chars = g_utf8_strlen (new_text, text_length);
- if (! tag_entry->internal_operation)
+ if (! entry->internal_operation)
{
/* suppress tag queries until auto completion runs */
- tag_entry->suppress_tag_query++;
+ entry->suppress_tag_query++;
}
is_tag[0] = FALSE;
if (*position > 0)
{
- is_tag[0] = (tag_entry->mask->str[*position - 1] == 't' || tag_entry->mask->str[*position - 1] == 's');
+ is_tag[0] = (entry->mask->str[*position - 1] == 't' || entry->mask->str[*position - 1] == 's');
}
- is_tag[1] = (tag_entry->mask->str[*position] == 't' || tag_entry->mask->str[*position] == 's');
+ is_tag[1] = (entry->mask->str[*position] == 't' || entry->mask->str[*position] == 's');
if (is_tag[0] && is_tag[1])
{
g_signal_stop_emission_by_name (editable, "insert_text");
@@ -500,14 +456,14 @@
{
gunichar c = g_utf8_get_char (new_text);
- if (! tag_entry->internal_operation
+ if (! entry->internal_operation
&& *position > 0
- && tag_entry->mask->str[*position - 1] == 's'
+ && entry->mask->str[*position - 1] == 's'
&& ! g_unichar_isspace (c))
{
- if (! tag_entry->suppress_mask_update)
+ if (! entry->suppress_mask_update)
{
- g_string_insert_c (tag_entry->mask, *position, 'u');
+ g_string_insert_c (entry->mask, *position, 'u');
}
g_signal_handlers_block_by_func (editable,
@@ -523,15 +479,15 @@
g_signal_stop_emission_by_name (editable, "insert_text");
}
- else if (! tag_entry->internal_operation
+ else if (! entry->internal_operation
&& num_chars == 1
- && *position < tag_entry->mask->len
- && tag_entry->mask->str[*position] == 't'
+ && *position < entry->mask->len
+ && entry->mask->str[*position] == 't'
&& ! g_unichar_isspace (c))
{
- if (! tag_entry->suppress_mask_update)
+ if (! entry->suppress_mask_update)
{
- g_string_insert_c (tag_entry->mask, *position, 'u');
+ g_string_insert_c (entry->mask, *position, 'u');
}
g_signal_handlers_block_by_func (editable,
@@ -549,52 +505,50 @@
g_signal_stop_emission_by_name (editable, "insert_text");
}
- if (! tag_entry->suppress_mask_update)
+ if (! entry->suppress_mask_update)
{
for (i = 0; i < num_chars; i++)
{
- g_string_insert_c (tag_entry->mask, insert_pos + i, 'u');
+ g_string_insert_c (entry->mask, insert_pos + i, 'u');
}
}
}
- if (! tag_entry->internal_operation)
+ if (! entry->internal_operation)
{
- tag_entry->tab_completion_index = -1;
- g_idle_add ((GSourceFunc)gimp_tag_entry_auto_complete,
- editable);
+ entry->tab_completion_index = -1;
+ g_idle_add ((GSourceFunc) gimp_tag_entry_auto_complete, editable);
}
}
static void
-gimp_tag_entry_delete_text (GtkEditable *editable,
- gint start_pos,
- gint end_pos,
- gpointer user_data)
+gimp_tag_entry_delete_text (GtkEditable *editable,
+ gint start_pos,
+ gint end_pos)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (editable);
+ GimpTagEntry *entry = GIMP_TAG_ENTRY (editable);
- if (! tag_entry->internal_operation)
+ if (! entry->internal_operation)
{
g_signal_handlers_block_by_func (editable,
gimp_tag_entry_delete_text,
NULL);
if (end_pos > start_pos
- && (tag_entry->mask->str[end_pos - 1] == 't'
- || tag_entry->mask->str[end_pos - 1] == 's'))
+ && (entry->mask->str[end_pos - 1] == 't'
+ || entry->mask->str[end_pos - 1] == 's'))
{
- while (end_pos <= tag_entry->mask->len
- && (tag_entry->mask->str[end_pos] == 's'))
+ while (end_pos <= entry->mask->len
+ && (entry->mask->str[end_pos] == 's'))
{
end_pos++;
}
}
gtk_editable_delete_text (editable, start_pos, end_pos);
- if (! tag_entry->suppress_mask_update)
+ if (! entry->suppress_mask_update)
{
- g_string_erase (tag_entry->mask, start_pos, end_pos - start_pos);
+ g_string_erase (entry->mask, start_pos, end_pos - start_pos);
}
g_signal_handlers_unblock_by_func (editable,
@@ -605,22 +559,22 @@
}
else
{
- if (! tag_entry->suppress_mask_update)
+ if (! entry->suppress_mask_update)
{
- g_string_erase (tag_entry->mask, start_pos, end_pos - start_pos);
+ g_string_erase (entry->mask, start_pos, end_pos - start_pos);
}
}
}
static gboolean
-gimp_tag_entry_query_tag (GimpTagEntry *entry)
+gimp_tag_entry_query_tag (GimpTagEntry *entry)
{
- gchar **parsed_tags;
- gint count;
- gint i;
- GimpTag *tag;
- GList *query_list = NULL;
- gboolean has_invalid_tags;
+ gchar **parsed_tags;
+ gint count;
+ gint i;
+ GimpTag *tag;
+ GList *query_list = NULL;
+ gboolean has_invalid_tags;
if (entry->suppress_tag_query)
{
@@ -646,7 +600,7 @@
}
g_strfreev (parsed_tags);
- gimp_filtered_container_set_filter (GIMP_FILTERED_CONTAINER (entry->filtered_container),
+ gimp_filtered_container_set_filter (GIMP_FILTERED_CONTAINER (entry->container),
query_list);
if (has_invalid_tags != entry->has_invalid_tags)
@@ -660,16 +614,16 @@
}
static gboolean
-gimp_tag_entry_auto_complete (GimpTagEntry *tag_entry)
+gimp_tag_entry_auto_complete (GimpTagEntry *tag_entry)
{
- gchar *completion_prefix;
- GList *completion_candidates;
- gint candidate_count;
- gchar **tags;
- gchar *completion;
- gint start_position;
- gint end_position;
- GtkEntry *entry;
+ GtkEntry *entry = GTK_ENTRY (tag_entry);
+ gchar *completion_prefix;
+ GList *completion_candidates;
+ gint candidate_count = 0;
+ gchar **tags;
+ gchar *completion;
+ gint start_position;
+ gint end_position;
tag_entry->suppress_tag_query--;
if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_QUERY)
@@ -677,12 +631,9 @@
/* tag query was suppressed until we got to auto completion (here),
* now queue tag query */
tag_entry->tag_query_pending = TRUE;
- g_idle_add ((GSourceFunc)gimp_tag_entry_query_tag,
- tag_entry);
+ g_idle_add ((GSourceFunc) gimp_tag_entry_query_tag, tag_entry);
}
- entry = GTK_ENTRY (tag_entry);
-
if (tag_entry->tab_completion_index >= 0)
{
tag_entry->internal_operation++;
@@ -709,23 +660,25 @@
completion_prefix);
completion_candidates = g_list_sort (completion_candidates,
gimp_tag_compare_func);
- if (tag_entry->tab_completion_index >= 0
- && completion_candidates)
+
+ if (tag_entry->tab_completion_index >= 0 && completion_candidates)
{
- GimpTag *the_chosen_one;
+ GimpTag *the_chosen_one;
candidate_count = g_list_length (completion_candidates);
tag_entry->tab_completion_index %= candidate_count;
- the_chosen_one = (GimpTag *) g_list_nth_data (completion_candidates,
- tag_entry->tab_completion_index);
+ the_chosen_one = g_list_nth_data (completion_candidates,
+ tag_entry->tab_completion_index);
g_list_free (completion_candidates);
completion_candidates = NULL;
- completion_candidates = g_list_append (completion_candidates, the_chosen_one);
+ completion_candidates = g_list_append (completion_candidates,
+ the_chosen_one);
}
+
completion =
- gimp_tag_entry_get_completion_string (GIMP_TAG_ENTRY (entry),
- completion_candidates,
- completion_prefix);
+ gimp_tag_entry_get_completion_string (GIMP_TAG_ENTRY (entry),
+ completion_candidates,
+ completion_prefix);
if (completion
&& strlen (completion) > 0)
@@ -758,15 +711,15 @@
}
static void
-gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
+gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
{
- GList *selected_iterator = NULL;
- GimpTagged *selected_item;
- gchar **parsed_tags;
- gint count;
- gint i;
- GimpTag *tag;
- GList *tag_list = NULL;
+ GList *selected_iterator = NULL;
+ GimpTagged *selected_item;
+ gchar **parsed_tags;
+ gint count;
+ gint i;
+ GimpTag *tag;
+ GList *tag_list = NULL;
parsed_tags = gimp_tag_entry_parse_tags (tag_entry);
count = g_strv_length (parsed_tags);
@@ -790,11 +743,11 @@
}
static void
-gimp_tag_entry_item_set_tags (GimpTagged *tagged,
- GList *tags)
+gimp_tag_entry_item_set_tags (GimpTagged *tagged,
+ GList *tags)
{
- GList *old_tags;
- GList *tags_iterator;
+ GList *old_tags;
+ GList *tags_iterator;
old_tags = g_list_copy (gimp_tagged_get_tags (tagged));
for (tags_iterator = old_tags; tags_iterator;
@@ -822,16 +775,16 @@
* be freed using g_strfreev().
**/
gchar **
-gimp_tag_entry_parse_tags (GimpTagEntry *entry)
+gimp_tag_entry_parse_tags (GimpTagEntry *entry)
{
- gchar **parsed_tags;
- gint length;
- gint i;
- GString *parsed_tag;
- const gchar *cursor;
- GList *tag_list = NULL;
- GList *iterator;
- gunichar c;
+ gchar **parsed_tags;
+ gint length;
+ gint i;
+ GString *parsed_tag;
+ const gchar *cursor;
+ GList *tag_list = NULL;
+ GList *iterator;
+ gunichar c;
g_return_val_if_fail (GIMP_IS_TAG_ENTRY (entry), NULL);
@@ -886,10 +839,10 @@
* operating in tag assignment mode.
**/
void
-gimp_tag_entry_set_selected_items (GimpTagEntry *tag_entry,
- GList *items)
+gimp_tag_entry_set_selected_items (GimpTagEntry *tag_entry,
+ GList *items)
{
- GList *iterator;
+ GList *iterator;
g_return_if_fail (GIMP_IS_TAG_ENTRY (tag_entry));
@@ -905,7 +858,7 @@
iterator = g_list_next (iterator))
{
if (gimp_tagged_get_tags (GIMP_TAGGED (iterator->data))
- && gimp_container_have (GIMP_CONTAINER (tag_entry->filtered_container),
+ && gimp_container_have (GIMP_CONTAINER (tag_entry->container),
GIMP_OBJECT(iterator->data)))
{
break;
@@ -930,15 +883,15 @@
}
static void
-gimp_tag_entry_load_selection (GimpTagEntry *tag_entry,
- gboolean sort)
+gimp_tag_entry_load_selection (GimpTagEntry *tag_entry,
+ gboolean sort)
{
- GimpTagged *selected_item;
- GList *tag_list;
- GList *tag_iterator;
- gint insert_pos;
- GimpTag *tag;
- gchar *text;
+ GimpTagged *selected_item;
+ GList *tag_list;
+ GList *tag_iterator;
+ gint insert_pos;
+ GimpTag *tag;
+ gchar *text;
tag_entry->internal_operation++;
gtk_editable_delete_text (GTK_EDITABLE (tag_entry), 0, -1);
@@ -974,15 +927,15 @@
}
static gchar*
-gimp_tag_entry_get_completion_prefix (GimpTagEntry *entry)
+gimp_tag_entry_get_completion_prefix (GimpTagEntry *entry)
{
- gchar *original_string;
- gchar *prefix_start;
- gchar *prefix;
- gchar *cursor;
- gint position;
- gint i;
- gunichar c;
+ gchar *original_string;
+ gchar *prefix_start;
+ gchar *prefix;
+ gchar *cursor;
+ gint position;
+ gint i;
+ gunichar c;
position = gtk_editable_get_position (GTK_EDITABLE (entry));
if (position < 1
@@ -1012,18 +965,18 @@
}
static GList *
-gimp_tag_entry_get_completion_candidates (GimpTagEntry *tag_entry,
- gchar **used_tags,
- gchar *src_prefix)
-{
- GList *candidates = NULL;
- GList *all_tags;
- GList *tag_iterator;
- GimpTag *tag;
- const gchar *tag_name;
- gint i;
- gint length;
- gchar *prefix;
+gimp_tag_entry_get_completion_candidates (GimpTagEntry *tag_entry,
+ gchar **used_tags,
+ gchar *src_prefix)
+{
+ GList *candidates = NULL;
+ GList *all_tags;
+ GList *tag_iterator;
+ GimpTag *tag;
+ const gchar *tag_name;
+ gint i;
+ gint length;
+ gchar *prefix;
if (!src_prefix
|| strlen (src_prefix) < 1)
@@ -1037,7 +990,7 @@
return NULL;
}
- all_tags = g_hash_table_get_keys (tag_entry->filtered_container->tag_ref_counts);
+ all_tags = g_hash_table_get_keys (tag_entry->container->tag_ref_counts);
length = g_strv_length (used_tags);
for (tag_iterator = all_tags; tag_iterator;
tag_iterator = g_list_next (tag_iterator))
@@ -1068,9 +1021,9 @@
}
static gchar *
-gimp_tag_entry_get_completion_string (GimpTagEntry *tag_entry,
- GList *candidates,
- gchar *prefix)
+gimp_tag_entry_get_completion_string (GimpTagEntry *tag_entry,
+ GList *candidates,
+ gchar *prefix)
{
const gchar **completions;
guint length;
@@ -1153,9 +1106,8 @@
}
static gboolean
-gimp_tag_entry_focus_in (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer user_data)
+gimp_tag_entry_focus_in (GtkWidget *widget,
+ GdkEventFocus *event)
{
gimp_tag_entry_toggle_desc (GIMP_TAG_ENTRY (widget), FALSE);
@@ -1163,9 +1115,8 @@
}
static gboolean
-gimp_tag_entry_focus_out (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer user_data)
+gimp_tag_entry_focus_out (GtkWidget *widget,
+ GdkEventFocus *event)
{
GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (widget);
@@ -1184,9 +1135,9 @@
}
static void
-gimp_tag_entry_container_changed (GimpContainer *container,
- GimpObject *object,
- GimpTagEntry *tag_entry)
+gimp_tag_entry_container_changed (GimpContainer *container,
+ GimpObject *object,
+ GimpTagEntry *tag_entry)
{
if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
{
@@ -1196,7 +1147,7 @@
selected_iterator = g_list_next (selected_iterator))
{
if (gimp_tagged_get_tags (GIMP_TAGGED (selected_iterator->data))
- && gimp_container_have (GIMP_CONTAINER (tag_entry->filtered_container),
+ && gimp_container_have (GIMP_CONTAINER (tag_entry->container),
GIMP_OBJECT(selected_iterator->data)))
{
break;
@@ -1212,11 +1163,11 @@
}
static void
-gimp_tag_entry_toggle_desc (GimpTagEntry *tag_entry,
- gboolean show)
+gimp_tag_entry_toggle_desc (GimpTagEntry *tag_entry,
+ gboolean show)
{
- GtkWidget *widget = GTK_WIDGET (tag_entry);
- const gchar *display_text;
+ GtkWidget *widget = GTK_WIDGET (tag_entry);
+ const gchar *display_text;
if (! (show ^ tag_entry->description_shown))
{
@@ -1234,8 +1185,8 @@
if (show)
{
- gchar *current_text;
- size_t len;
+ gchar *current_text;
+ size_t len;
current_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (tag_entry)));
current_text = g_strstrip (current_text);
@@ -1258,22 +1209,21 @@
}
static gboolean
-gimp_tag_entry_expose (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer user_data)
-{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (widget);
- PangoContext *context;
- PangoLayout *layout;
- PangoAttrList *attr_list;
- PangoAttribute *attribute;
- PangoRenderer *renderer;
- gint layout_width;
- gint layout_height;
- gint window_width;
- gint window_height;
- gint offset;
- const char *display_text;
+gimp_tag_entry_expose (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (widget);
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoAttrList *attr_list;
+ PangoAttribute *attribute;
+ PangoRenderer *renderer;
+ gint layout_width;
+ gint layout_height;
+ gint window_width;
+ gint window_height;
+ gint offset;
+ const char *display_text;
/* eeeeeek */
if (widget->window == event->window)
@@ -1331,17 +1281,16 @@
}
static gboolean
-gimp_tag_entry_key_press (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data)
+gimp_tag_entry_key_press (GtkWidget *widget,
+ GdkEventKey *event)
{
- GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (widget);
- guchar c;
+ GimpTagEntry *entry = GIMP_TAG_ENTRY (widget);
+ guchar c;
c = gdk_keyval_to_unicode (event->keyval);
if (gimp_tag_is_tag_separator (c))
{
- g_idle_add ((GSourceFunc) gimp_tag_entry_commit_source_func, tag_entry);
+ g_idle_add ((GSourceFunc) gimp_tag_entry_commit_source_func, entry);
return FALSE;
}
@@ -1349,35 +1298,34 @@
{
case GDK_Tab:
{
- tag_entry->tab_completion_index++;
- tag_entry->suppress_tag_query++;
- g_idle_add ((GSourceFunc)gimp_tag_entry_auto_complete,
- tag_entry);
+ entry->tab_completion_index++;
+ entry->suppress_tag_query++;
+ g_idle_add ((GSourceFunc) gimp_tag_entry_auto_complete, entry);
}
return TRUE;
case GDK_Return:
- gimp_tag_entry_commit_tags (tag_entry);
+ gimp_tag_entry_commit_tags (entry);
break;
case GDK_Left:
- gimp_tag_entry_previous_tag (tag_entry,
+ gimp_tag_entry_previous_tag (entry,
(event->state & GDK_SHIFT_MASK) ? TRUE : FALSE);
return TRUE;
case GDK_Right:
- gimp_tag_entry_next_tag (tag_entry,
+ gimp_tag_entry_next_tag (entry,
(event->state & GDK_SHIFT_MASK) ? TRUE : FALSE);
return TRUE;
case GDK_BackSpace:
{
- gint selection_start;
- gint selection_end;
+ gint selection_start;
+ gint selection_end;
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry),
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
&selection_start, &selection_end);
- if (gimp_tag_entry_select_jellybean (tag_entry,
+ if (gimp_tag_entry_select_jellybean (entry,
selection_start, selection_end,
TAG_SEARCH_LEFT))
{
@@ -1385,21 +1333,22 @@
}
else
{
- gimp_tag_entry_select_for_deletion (tag_entry, TAG_SEARCH_LEFT);
+ gimp_tag_entry_select_for_deletion (entry, TAG_SEARCH_LEFT);
+ /* FIXME: need to remove idle handler in dispose */
g_idle_add ((GSourceFunc) gimp_tag_entry_strip_extra_whitespace,
- tag_entry);
+ entry);
}
}
break;
case GDK_Delete:
{
- gint selection_start;
- gint selection_end;
+ gint selection_start;
+ gint selection_end;
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry),
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
&selection_start, &selection_end);
- if (gimp_tag_entry_select_jellybean (tag_entry,
+ if (gimp_tag_entry_select_jellybean (entry,
selection_start, selection_end,
TAG_SEARCH_RIGHT))
{
@@ -1407,42 +1356,43 @@
}
else
{
- gimp_tag_entry_select_for_deletion (tag_entry, TAG_SEARCH_RIGHT);
+ gimp_tag_entry_select_for_deletion (entry, TAG_SEARCH_RIGHT);
+ /* FIXME: need to remove idle handler in dispose */
g_idle_add ((GSourceFunc) gimp_tag_entry_strip_extra_whitespace,
- tag_entry);
+ entry);
}
}
break;
case GDK_Up:
case GDK_Down:
- if (tag_entry->recent_list != NULL)
+ if (entry->recent_list != NULL)
{
- gchar *recent_item;
- gchar *very_recent_item;
+ gchar *recent_item;
+ gchar *very_recent_item;
- very_recent_item = g_strdup (gtk_entry_get_text (GTK_ENTRY (tag_entry)));
- gimp_tag_entry_add_to_recent (tag_entry, very_recent_item, TRUE);
+ very_recent_item = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+ gimp_tag_entry_add_to_recent (entry, very_recent_item, TRUE);
g_free (very_recent_item);
if (event->keyval == GDK_Up)
{
- recent_item = (gchar *) g_list_first (tag_entry->recent_list)->data;
- tag_entry->recent_list = g_list_remove (tag_entry->recent_list, recent_item);
- tag_entry->recent_list = g_list_append (tag_entry->recent_list, recent_item);
+ recent_item = (gchar *) g_list_first (entry->recent_list)->data;
+ entry->recent_list = g_list_remove (entry->recent_list, recent_item);
+ entry->recent_list = g_list_append (entry->recent_list, recent_item);
}
else
{
- recent_item = (gchar *) g_list_last (tag_entry->recent_list)->data;
- tag_entry->recent_list = g_list_remove (tag_entry->recent_list, recent_item);
- tag_entry->recent_list = g_list_prepend (tag_entry->recent_list, recent_item);
+ recent_item = (gchar *) g_list_last (entry->recent_list)->data;
+ entry->recent_list = g_list_remove (entry->recent_list, recent_item);
+ entry->recent_list = g_list_prepend (entry->recent_list, recent_item);
}
- recent_item = (gchar *) g_list_first (tag_entry->recent_list)->data;
- tag_entry->internal_operation++;
- gtk_entry_set_text (GTK_ENTRY (tag_entry), recent_item);
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), -1);
- tag_entry->internal_operation--;
+ recent_item = (gchar *) g_list_first (entry->recent_list)->data;
+ entry->internal_operation++;
+ gtk_entry_set_text (GTK_ENTRY (entry), recent_item);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ entry->internal_operation--;
}
return TRUE;
@@ -1454,11 +1404,12 @@
}
static gboolean
-gimp_tag_entry_button_release (GtkWidget *widget,
- GdkEventButton *event)
+gimp_tag_entry_button_release (GtkWidget *widget,
+ GdkEventButton *event)
{
if (event->button == 1)
{
+ /* FIXME: need to remove idle handler in dispose */
g_idle_add ((GSourceFunc) gimp_tag_entry_try_select_jellybean,
widget);
}
@@ -1467,44 +1418,44 @@
}
static gboolean
-gimp_tag_entry_try_select_jellybean (GimpTagEntry *tag_entry)
+gimp_tag_entry_try_select_jellybean (GimpTagEntry *entry)
{
gint selection_start;
gint selection_end;
- gint selection_pos = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
- gint char_count = g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (tag_entry)), -1);
+ gint selection_pos = gtk_editable_get_position (GTK_EDITABLE (entry));
+ gint char_count = g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (entry)), -1);
if (selection_pos == char_count)
{
return FALSE;
}
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry),
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
&selection_start, &selection_end);
- gimp_tag_entry_select_jellybean (tag_entry, selection_start, selection_end, TAG_SEARCH_NONE);
+ gimp_tag_entry_select_jellybean (entry, selection_start, selection_end, TAG_SEARCH_NONE);
return FALSE;
}
static gboolean
-gimp_tag_entry_select_jellybean (GimpTagEntry *tag_entry,
- gint selection_start,
- gint selection_end,
- GimpTagSearchDir search_dir)
+gimp_tag_entry_select_jellybean (GimpTagEntry *entry,
+ gint selection_start,
+ gint selection_end,
+ GimpTagSearchDir search_dir)
{
- gint prev_selection_start;
- gint prev_selection_end;
+ gint prev_selection_start;
+ gint prev_selection_end;
- if (! tag_entry->mask->len)
+ if (! entry->mask->len)
{
return FALSE;
}
- if (selection_start >= tag_entry->mask->len)
+ if (selection_start >= entry->mask->len)
{
- selection_start = tag_entry->mask->len - 1;
+ selection_start = entry->mask->len - 1;
selection_end = selection_start;
}
- if (tag_entry->mask->str[selection_start] == 'u')
+ if (entry->mask->str[selection_start] == 'u')
{
return FALSE;
}
@@ -1514,14 +1465,14 @@
case TAG_SEARCH_NONE:
{
if (selection_start > 0
- && tag_entry->mask->str[selection_start] == 's')
+ && entry->mask->str[selection_start] == 's')
{
selection_start--;
}
if (selection_start > 0
- && (tag_entry->mask->str[selection_start - 1] == 'w')
- && (tag_entry->mask->str[selection_start] == 't'))
+ && (entry->mask->str[selection_start - 1] == 'w')
+ && (entry->mask->str[selection_start] == 't'))
{
/* between whitespace and tag,
* should allow to select tag. */
@@ -1535,17 +1486,17 @@
if (selection_start == selection_end)
{
if (selection_start > 0
- && tag_entry->mask->str[selection_start] == 't'
- && tag_entry->mask->str[selection_start - 1] == 'w')
+ && entry->mask->str[selection_start] == 't'
+ && entry->mask->str[selection_start - 1] == 'w')
{
selection_start--;
}
- if ((tag_entry->mask->str[selection_start] == 'w'
- || tag_entry->mask->str[selection_start] == 's')
+ if ((entry->mask->str[selection_start] == 'w'
+ || entry->mask->str[selection_start] == 's')
&& selection_start > 0)
{
- while ((tag_entry->mask->str[selection_start] == 'w'
- || tag_entry->mask->str[selection_start] == 's')
+ while ((entry->mask->str[selection_start] == 'w'
+ || entry->mask->str[selection_start] == 's')
&& selection_start > 0)
{
selection_start--;
@@ -1560,13 +1511,13 @@
{
if (selection_start == selection_end)
{
- if ((tag_entry->mask->str[selection_start] == 'w'
- || tag_entry->mask->str[selection_start] == 's')
- && selection_start < tag_entry->mask->len - 1)
+ if ((entry->mask->str[selection_start] == 'w'
+ || entry->mask->str[selection_start] == 's')
+ && selection_start < entry->mask->len - 1)
{
- while ((tag_entry->mask->str[selection_start] == 'w'
- || tag_entry->mask->str[selection_start] == 's')
- && selection_start < tag_entry->mask->len - 1)
+ while ((entry->mask->str[selection_start] == 'w'
+ || entry->mask->str[selection_start] == 's')
+ && selection_start < entry->mask->len - 1)
{
selection_start++;
}
@@ -1577,30 +1528,30 @@
break;
}
- if (selection_start < tag_entry->mask->len
+ if (selection_start < entry->mask->len
&& selection_start == selection_end)
{
selection_end = selection_start + 1;
}
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry),
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
&prev_selection_start,
&prev_selection_end);
- if (tag_entry->mask->str[selection_start] == 't')
+ if (entry->mask->str[selection_start] == 't')
{
while (selection_start > 0
- && (tag_entry->mask->str[selection_start - 1] == 't'))
+ && (entry->mask->str[selection_start - 1] == 't'))
{
selection_start--;
}
}
if (selection_end > selection_start
- && (tag_entry->mask->str[selection_end - 1] == 't'))
+ && (entry->mask->str[selection_end - 1] == 't'))
{
- while (selection_end <= tag_entry->mask->len
- && (tag_entry->mask->str[selection_end] == 't'))
+ while (selection_end <= entry->mask->len
+ && (entry->mask->str[selection_end] == 't'))
{
selection_end++;
}
@@ -1608,25 +1559,25 @@
if (search_dir == TAG_SEARCH_NONE
&& selection_end - selection_start == 1
- && tag_entry->mask->str[selection_start] == 'w')
+ && entry->mask->str[selection_start] == 'w')
{
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), selection_end);
+ gtk_editable_set_position (GTK_EDITABLE (entry), selection_end);
return TRUE;
}
if ((selection_start != prev_selection_start
|| selection_end != prev_selection_end)
- && (tag_entry->mask->str[selection_start] == 't')
+ && (entry->mask->str[selection_start] == 't')
&& selection_start < selection_end)
{
if (search_dir == TAG_SEARCH_LEFT)
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry),
+ gtk_editable_select_region (GTK_EDITABLE (entry),
selection_end, selection_start);
}
else
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry),
+ gtk_editable_select_region (GTK_EDITABLE (entry),
selection_start, selection_end);
}
@@ -1639,16 +1590,16 @@
}
static gboolean
-gimp_tag_entry_add_to_recent (GimpTagEntry *tag_entry,
- const gchar *tags_string,
- gboolean to_front)
-{
- gchar *recent_item = NULL;
- GList *tags_iterator;
- gchar *stripped_string;
- gint stripped_length;
+gimp_tag_entry_add_to_recent (GimpTagEntry *entry,
+ const gchar *tags_string,
+ gboolean to_front)
+{
+ gchar *recent_item = NULL;
+ GList *tags_iterator;
+ gchar *stripped_string;
+ gint stripped_length;
- if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
+ if (entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
{
return FALSE;
}
@@ -1665,21 +1616,20 @@
return FALSE;
}
- if (g_list_length (tag_entry->recent_list) >= GIMP_TAG_ENTRY_MAX_RECENT_ITEMS)
+ if (g_list_length (entry->recent_list) >= GIMP_TAG_ENTRY_MAX_RECENT_ITEMS)
{
- gchar *last_item = (gchar *) g_list_last (tag_entry->recent_list)->data;
- tag_entry->recent_list = g_list_remove (tag_entry->recent_list, last_item);
+ gchar *last_item = (gchar *) g_list_last (entry->recent_list)->data;
+ entry->recent_list = g_list_remove (entry->recent_list, last_item);
g_free (last_item);
}
- for (tags_iterator = tag_entry->recent_list; tags_iterator;
+ for (tags_iterator = entry->recent_list; tags_iterator;
tags_iterator = g_list_next (tags_iterator))
{
if (! strcmp (tags_string, tags_iterator->data))
{
recent_item = tags_iterator->data;
- tag_entry->recent_list = g_list_remove (tag_entry->recent_list,
- recent_item);
+ entry->recent_list = g_list_remove (entry->recent_list, recent_item);
break;
}
}
@@ -1691,13 +1641,11 @@
if (to_front)
{
- tag_entry->recent_list = g_list_prepend (tag_entry->recent_list,
- recent_item);
+ entry->recent_list = g_list_prepend (entry->recent_list, recent_item);
}
else
{
- tag_entry->recent_list = g_list_append (tag_entry->recent_list,
- recent_item);
+ entry->recent_list = g_list_append (entry->recent_list, recent_item);
}
return TRUE;
@@ -1714,23 +1662,25 @@
const gchar *
gimp_tag_entry_get_separator (void)
{
- /* IMPORTANT: use only one of Unicode terminal punctuation chars.
- * http://unicode.org/review/pr-23.html */
+ /* Seperator for tags
+ * IMPORTANT: use only one of Unicode terminal punctuation chars.
+ * http://unicode.org/review/pr-23.html
+ */
return _(",");
}
static void
-gimp_tag_entry_commit_region (GString *tags,
- GString *mask)
+gimp_tag_entry_commit_region (GString *tags,
+ GString *mask)
{
- gint i = 0;
- gint j;
- gint stage = 0;
- gunichar c;
- gchar *cursor;
- GString *out_tags;
- GString *out_mask;
- GString *tag_buffer;
+ gint i = 0;
+ gint j;
+ gint stage = 0;
+ gunichar c;
+ gchar *cursor;
+ GString *out_tags;
+ GString *out_mask;
+ GString *tag_buffer;
out_tags = g_string_new ("");
out_mask = g_string_new ("");
@@ -1765,8 +1715,8 @@
}
else
{
- gchar *valid_tag = gimp_tag_string_make_valid (tag_buffer->str);
- gsize tag_length;
+ gchar *valid_tag = gimp_tag_string_make_valid (tag_buffer->str);
+ gsize tag_length;
if (valid_tag)
{
@@ -1825,7 +1775,7 @@
}
static void
-gimp_tag_entry_commit_tags (GimpTagEntry *tag_entry)
+gimp_tag_entry_commit_tags (GimpTagEntry *entry)
{
gint i;
gint region_start;
@@ -1835,22 +1785,22 @@
gint cursor_position;
glong length_before;
- cursor_position = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
+ cursor_position = gtk_editable_get_position (GTK_EDITABLE (entry));
do
{
found_region = FALSE;
- for (i = 0; i < tag_entry->mask->len; i++)
+ for (i = 0; i < entry->mask->len; i++)
{
- if (tag_entry->mask->str[i] == 'u')
+ if (entry->mask->str[i] == 'u')
{
found_region = TRUE;
region_start = i;
region_end = i + 1;
- for (i++; i < tag_entry->mask->len; i++)
+ for (i++; i < entry->mask->len; i++)
{
- if (tag_entry->mask->str[i] == 'u')
+ if (entry->mask->str[i] == 'u')
{
region_end = i + 1;
}
@@ -1869,18 +1819,18 @@
GString *tags;
GString *mask;
- tags_string = gtk_editable_get_chars (GTK_EDITABLE (tag_entry), region_start, region_end);
+ tags_string = gtk_editable_get_chars (GTK_EDITABLE (entry), region_start, region_end);
tags = g_string_new (tags_string);
g_free (tags_string);
length_before = region_end - region_start;
- mask = g_string_new_len (tag_entry->mask->str + region_start, region_end - region_start);
+ mask = g_string_new_len (entry->mask->str + region_start, region_end - region_start);
gimp_tag_entry_commit_region (tags, mask);
/* prepend space before if needed */
if (region_start > 0
- && tag_entry->mask->str[region_start - 1] != 'w'
+ && entry->mask->str[region_start - 1] != 'w'
&& mask->len > 0
&& mask->str[0] != 'w')
{
@@ -1889,8 +1839,8 @@
}
/* append space after if needed */
- if (region_end <= tag_entry->mask->len
- && tag_entry->mask->str[region_end] != 'w'
+ if (region_end <= entry->mask->len
+ && entry->mask->str[region_end] != 'w'
&& mask->len > 0
&& mask->str[mask->len - 1] != 'w')
{
@@ -1903,53 +1853,53 @@
cursor_position += g_utf8_strlen (tags->str, tags->len) - length_before;
}
- tag_entry->internal_operation++;
- tag_entry->suppress_mask_update++;
- gtk_editable_delete_text (GTK_EDITABLE (tag_entry), region_start, region_end);
+ entry->internal_operation++;
+ entry->suppress_mask_update++;
+ gtk_editable_delete_text (GTK_EDITABLE (entry), region_start, region_end);
position = region_start;
- gtk_editable_insert_text (GTK_EDITABLE (tag_entry), tags->str, tags->len, &position);
- tag_entry->suppress_mask_update--;
- tag_entry->internal_operation--;
+ gtk_editable_insert_text (GTK_EDITABLE (entry), tags->str, tags->len, &position);
+ entry->suppress_mask_update--;
+ entry->internal_operation--;
- g_string_erase (tag_entry->mask, region_start, region_end - region_start);
- g_string_insert_len (tag_entry->mask, region_start, mask->str, mask->len);
+ g_string_erase (entry->mask, region_start, region_end - region_start);
+ g_string_insert_len (entry->mask, region_start, mask->str, mask->len);
g_string_free (mask, TRUE);
g_string_free (tags, TRUE);
}
} while (found_region);
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), cursor_position);
- gimp_tag_entry_strip_extra_whitespace (tag_entry);
+ gtk_editable_set_position (GTK_EDITABLE (entry), cursor_position);
+ gimp_tag_entry_strip_extra_whitespace (entry);
}
static gboolean
-gimp_tag_entry_commit_source_func (GimpTagEntry *tag_entry)
+gimp_tag_entry_commit_source_func (GimpTagEntry *entry)
{
- gimp_tag_entry_commit_tags (GIMP_TAG_ENTRY (tag_entry));
+ gimp_tag_entry_commit_tags (entry);
return FALSE;
}
-
static void
-gimp_tag_entry_next_tag (GimpTagEntry *tag_entry,
- gboolean select)
+gimp_tag_entry_next_tag (GimpTagEntry *entry,
+ gboolean select)
{
- gint position = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
- if (tag_entry->mask->str[position] != 'u')
+ gint position = gtk_editable_get_position (GTK_EDITABLE (entry));
+
+ if (entry->mask->str[position] != 'u')
{
- while (position < tag_entry->mask->len
- && (tag_entry->mask->str[position] != 'w'))
+ while (position < entry->mask->len
+ && (entry->mask->str[position] != 'w'))
{
position++;
}
- if (tag_entry->mask->str[position] == 'w')
+ if (entry->mask->str[position] == 'w')
{
position++;
}
}
- else if (position < tag_entry->mask->len)
+ else if (position < entry->mask->len)
{
position++;
}
@@ -1960,31 +1910,31 @@
gint selection_start;
gint selection_end;
- current_position = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry), &selection_start, &selection_end);
+ current_position = gtk_editable_get_position (GTK_EDITABLE (entry));
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &selection_start, &selection_end);
if (current_position == selection_end)
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry), selection_start, position);
+ gtk_editable_select_region (GTK_EDITABLE (entry), selection_start, position);
}
else if (current_position == selection_start)
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry), selection_end, position);
+ gtk_editable_select_region (GTK_EDITABLE (entry), selection_end, position);
}
}
else
{
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), position);
+ gtk_editable_set_position (GTK_EDITABLE (entry), position);
}
}
static void
-gimp_tag_entry_previous_tag (GimpTagEntry *tag_entry,
- gboolean select)
+gimp_tag_entry_previous_tag (GimpTagEntry *entry,
+ gboolean select)
{
- gint position = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
+ gint position = gtk_editable_get_position (GTK_EDITABLE (entry));
if (position >= 1
- && tag_entry->mask->str[position - 1] == 'w')
+ && entry->mask->str[position - 1] == 'w')
{
position--;
}
@@ -1992,12 +1942,12 @@
{
return;
}
- if (tag_entry->mask->str[position - 1] != 'u')
+ if (entry->mask->str[position - 1] != 'u')
{
while (position > 0
- && (tag_entry->mask->str[position - 1] != 'w'))
+ && (entry->mask->str[position - 1] != 'w'))
{
- if (tag_entry->mask->str[position - 1] == 'u')
+ if (entry->mask->str[position - 1] == 'u')
{
break;
}
@@ -2016,45 +1966,46 @@
gint selection_start;
gint selection_end;
- current_position = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry), &selection_start, &selection_end);
+ current_position = gtk_editable_get_position (GTK_EDITABLE (entry));
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &selection_start, &selection_end);
if (current_position == selection_start)
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry), selection_end, position);
+ gtk_editable_select_region (GTK_EDITABLE (entry), selection_end, position);
}
else if (current_position == selection_end)
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry), selection_start, position);
+ gtk_editable_select_region (GTK_EDITABLE (entry), selection_start, position);
}
}
else
{
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), position);
+ gtk_editable_set_position (GTK_EDITABLE (entry), position);
}
}
static void
-gimp_tag_entry_select_for_deletion (GimpTagEntry *tag_entry,
- GimpTagSearchDir search_dir)
+gimp_tag_entry_select_for_deletion (GimpTagEntry *entry,
+ GimpTagSearchDir search_dir)
{
- gint start_pos;
- gint end_pos;
+ gint start_pos;
+ gint end_pos;
/* make sure the whole tag is selected,
* including a separator */
- gtk_editable_get_selection_bounds (GTK_EDITABLE (tag_entry), &start_pos, &end_pos);
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
+ &start_pos, &end_pos);
while (start_pos > 0
- && (tag_entry->mask->str[start_pos - 1] == 't'))
+ && (entry->mask->str[start_pos - 1] == 't'))
{
start_pos--;
}
if (end_pos > start_pos
- && (tag_entry->mask->str[end_pos - 1] == 't'
- || tag_entry->mask->str[end_pos - 1] == 's'))
+ && (entry->mask->str[end_pos - 1] == 't'
+ || entry->mask->str[end_pos - 1] == 's'))
{
- while (end_pos <= tag_entry->mask->len
- && (tag_entry->mask->str[end_pos] == 's'))
+ while (end_pos <= entry->mask->len
+ && (entry->mask->str[end_pos] == 's'))
{
end_pos++;
}
@@ -2062,12 +2013,12 @@
/* ensure there is no unnecessary whitespace selected */
while (start_pos < end_pos
- && tag_entry->mask->str[start_pos] == 'w')
+ && entry->mask->str[start_pos] == 'w')
{
start_pos++;
}
while (start_pos < end_pos
- && tag_entry->mask->str[end_pos - 1] == 'w')
+ && entry->mask->str[end_pos - 1] == 'w')
{
end_pos--;
}
@@ -2075,52 +2026,53 @@
/* delete spaces in one side */
if (search_dir == TAG_SEARCH_LEFT)
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry), end_pos, start_pos);
+ gtk_editable_select_region (GTK_EDITABLE (entry), end_pos, start_pos);
}
else if (end_pos > start_pos
&& search_dir == TAG_SEARCH_RIGHT
- && (tag_entry->mask->str[end_pos - 1] == 't'
- || tag_entry->mask->str[end_pos - 1] == 's'))
+ && (entry->mask->str[end_pos - 1] == 't'
+ || entry->mask->str[end_pos - 1] == 's'))
{
- gtk_editable_select_region (GTK_EDITABLE (tag_entry), start_pos, end_pos);
+ gtk_editable_select_region (GTK_EDITABLE (entry), start_pos, end_pos);
}
}
static gboolean
-gimp_tag_entry_strip_extra_whitespace (GimpTagEntry *tag_entry)
+gimp_tag_entry_strip_extra_whitespace (GimpTagEntry *entry)
{
gint i;
gint position;
- position = gtk_editable_get_position (GTK_EDITABLE (tag_entry));
+ position = gtk_editable_get_position (GTK_EDITABLE (entry));
/* strip whitespace in front */
- while (tag_entry->mask->len > 0
- && tag_entry->mask->str[0] == 'w')
+ while (entry->mask->len > 0
+ && entry->mask->str[0] == 'w')
{
- gtk_editable_delete_text (GTK_EDITABLE (tag_entry), 0, 1);
+ gtk_editable_delete_text (GTK_EDITABLE (entry), 0, 1);
}
/* strip whitespace in back */
- while (tag_entry->mask->len > 1
- && tag_entry->mask->str[tag_entry->mask->len - 1] == 'w'
- && tag_entry->mask->str[tag_entry->mask->len - 2] == 'w')
+ while (entry->mask->len > 1
+ && entry->mask->str[entry->mask->len - 1] == 'w'
+ && entry->mask->str[entry->mask->len - 2] == 'w')
{
- gtk_editable_delete_text (GTK_EDITABLE (tag_entry), tag_entry->mask->len - 1, tag_entry->mask->len);
+ gtk_editable_delete_text (GTK_EDITABLE (entry),
+ entry->mask->len - 1, entry->mask->len);
- if (position == tag_entry->mask->len)
+ if (position == entry->mask->len)
{
position--;
}
}
/* strip extra whitespace in the middle */
- for (i = tag_entry->mask->len - 1; i > 0; i--)
+ for (i = entry->mask->len - 1; i > 0; i--)
{
- if (tag_entry->mask->str[i] == 'w'
- && tag_entry->mask->str[i - 1] == 'w')
+ if (entry->mask->str[i] == 'w'
+ && entry->mask->str[i - 1] == 'w')
{
- gtk_editable_delete_text (GTK_EDITABLE (tag_entry), i, i + 1);
+ gtk_editable_delete_text (GTK_EDITABLE (entry), i, i + 1);
if (position >= i)
{
@@ -2131,13 +2083,13 @@
/* special case when cursor is in the last position:
* it must be positioned after the last whitespace. */
- if (position == tag_entry->mask->len - 1
- && tag_entry->mask->str[position] == 'w')
+ if (position == entry->mask->len - 1
+ && entry->mask->str[position] == 'w')
{
position++;
}
- gtk_editable_set_position (GTK_EDITABLE (tag_entry), position);
+ gtk_editable_set_position (GTK_EDITABLE (entry), position);
return FALSE;
}
Modified: trunk/app/widgets/gimptagentry.h
==============================================================================
--- trunk/app/widgets/gimptagentry.h (original)
+++ trunk/app/widgets/gimptagentry.h Wed Dec 31 00:01:24 2008
@@ -30,23 +30,15 @@
#define GIMP_IS_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TAG_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, /*< desc="Query" >*/
- GIMP_TAG_ENTRY_MODE_ASSIGN, /*< desc="Assign" >*/
-} GimpTagEntryMode;
typedef struct _GimpTagEntryClass GimpTagEntryClass;
struct _GimpTagEntry
{
- GtkEntry parent_instance;
+ GtkEntry parent_instance;
+
+ GimpFilteredContainer *container;
- GimpFilteredContainer *filtered_container;
/* mask describes the meaning of each char in GimpTagEntry.
* It is maintained automatically on insert-text and delete-text
* events. If manual mask modification is desired, then
@@ -58,17 +50,17 @@
* s - separator
* w - whitespace.
*/
- GString *mask;
- GList *selected_items;
- GList *recent_list;
- gint tab_completion_index;
- gint internal_operation;
- gint suppress_mask_update;
- gint suppress_tag_query;
- GimpTagEntryMode mode;
- gboolean description_shown;
- gboolean has_invalid_tags;
- gboolean tag_query_pending;
+ GString *mask;
+ GList *selected_items;
+ GList *recent_list;
+ gint tab_completion_index;
+ gint internal_operation;
+ gint suppress_mask_update;
+ gint suppress_tag_query;
+ GimpTagEntryMode mode;
+ gboolean description_shown;
+ gboolean has_invalid_tags;
+ gboolean tag_query_pending;
};
struct _GimpTagEntryClass
@@ -77,17 +69,17 @@
};
-GType gimp_tag_entry_get_type (void) G_GNUC_CONST;
+GType gimp_tag_entry_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_tag_entry_new (GimpFilteredContainer *tagged_container,
- GimpTagEntryMode mode);
+GtkWidget * gimp_tag_entry_new (GimpFilteredContainer *container,
+ GimpTagEntryMode mode);
-void gimp_tag_entry_set_selected_items (GimpTagEntry *tag_entry,
- GList *items);
-gchar ** gimp_tag_entry_parse_tags (GimpTagEntry *entry);
-void gimp_tag_entry_set_tag_string (GimpTagEntry *tag_entry,
- const gchar *tag_string);
+void gimp_tag_entry_set_selected_items (GimpTagEntry *entry,
+ GList *items);
+gchar ** gimp_tag_entry_parse_tags (GimpTagEntry *entry);
+void gimp_tag_entry_set_tag_string (GimpTagEntry *entry,
+ const gchar *tag_string);
-const gchar * gimp_tag_entry_get_separator (void);
+const gchar * gimp_tag_entry_get_separator (void);
#endif /* __GIMP_TAG_ENTRY_H__ */
Modified: trunk/app/widgets/gimptagpopup.c
==============================================================================
--- trunk/app/widgets/gimptagpopup.c (original)
+++ trunk/app/widgets/gimptagpopup.c Wed Dec 31 00:01:24 2008
@@ -55,6 +55,15 @@
#define GIMP_TAG_POPUP_MARGIN 5
+
+struct _PopupTagData
+{
+ GimpTag *tag;
+ GdkRectangle bounds;
+ GtkStateType state;
+};
+
+
static GObject* gimp_tag_popup_constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params);
@@ -70,38 +79,37 @@
static gboolean gimp_tag_popup_border_expose (GtkWidget *widget,
GdkEventExpose *event,
- GimpTagPopup *tag_popup);
+ GimpTagPopup *popup);
static gboolean gimp_tag_popup_list_expose (GtkWidget *widget,
GdkEventExpose *event,
- GimpTagPopup *tag_popup);
+ GimpTagPopup *popup);
static gboolean gimp_tag_popup_border_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data);
+ GdkEvent *event);
static gboolean gimp_tag_popup_list_event (GtkWidget *widget,
GdkEvent *event,
- GimpTagPopup *tag_popup);
-static void gimp_tag_popup_toggle_tag (GimpTagPopup *tag_popup,
+ GimpTagPopup *popup);
+static void gimp_tag_popup_toggle_tag (GimpTagPopup *popup,
PopupTagData *tag_data);
static void gimp_tag_popup_check_can_toggle (GimpTagged *tagged,
- GimpTagPopup *tag_popup);
-static gint gimp_tag_popup_layout_tags (GimpTagPopup *tag_popup,
+ GimpTagPopup *popup);
+static gint gimp_tag_popup_layout_tags (GimpTagPopup *popup,
gint width);
-static void gimp_tag_popup_do_timeout_scroll (GimpTagPopup *tag_popup,
+static void gimp_tag_popup_do_timeout_scroll (GimpTagPopup *popup,
gboolean touchscreen_mode);
static gboolean gimp_tag_popup_scroll_timeout (gpointer data);
-static void gimp_tag_popup_remove_scroll_timeout (GimpTagPopup *tag_popup);
+static void gimp_tag_popup_remove_scroll_timeout (GimpTagPopup *popup);
static gboolean gimp_tag_popup_scroll_timeout_initial (gpointer data);
-static void gimp_tag_popup_start_scrolling (GimpTagPopup *tag_popup);
-static void gimp_tag_popup_stop_scrolling (GimpTagPopup *tag_popup);
-static void gimp_tag_popup_scroll_by (GimpTagPopup *tag_popup,
+static void gimp_tag_popup_start_scrolling (GimpTagPopup *popup);
+static void gimp_tag_popup_stop_scrolling (GimpTagPopup *popup);
+static void gimp_tag_popup_scroll_by (GimpTagPopup *popup,
gint step);
-static void gimp_tag_popup_handle_scrolling (GimpTagPopup *tag_popup,
+static void gimp_tag_popup_handle_scrolling (GimpTagPopup *popup,
gint x,
gint y,
gboolean enter,
gboolean motion);
-static gboolean gimp_tag_popup_button_scroll (GimpTagPopup *tag_popup,
+static gboolean gimp_tag_popup_button_scroll (GimpTagPopup *popup,
GdkEventButton *event);
static void get_arrows_visible_area (GimpTagPopup *combo_entry,
@@ -109,7 +117,7 @@
GdkRectangle *upper,
GdkRectangle *lower,
gint *arrow_space);
-static void get_arrows_sensitive_area (GimpTagPopup *tag_popup,
+static void get_arrows_sensitive_area (GimpTagPopup *popup,
GdkRectangle *upper,
GdkRectangle *lower);
@@ -137,7 +145,7 @@
}
static void
-gimp_tag_popup_init (GimpTagPopup *tag_popup)
+gimp_tag_popup_init (GimpTagPopup *popup)
{
}
@@ -146,28 +154,29 @@
guint n_construct_params,
GObjectConstructParam *construct_params)
{
- GObject *object;
- GimpTagPopup *popup;
- GtkWidget *alignment;
- GtkWidget *drawing_area;
- GtkWidget *frame;
- gint x;
- gint y;
- gint width;
- gint height;
- gint popup_height;
- GHashTable *tag_hash;
- GList *tag_list;
- GList *tag_iterator;
- gint i;
- gint j;
- gint max_height;
- gint screen_height;
- gchar **current_tags;
- gint current_count;
- const gchar *list_tag;
- GdkRectangle popup_rects[2]; /* variants of popup placement */
- GdkRectangle popup_rect; /* best popup rect in screen coordinates */
+ GObject *object;
+ GimpTagPopup *popup;
+ GimpFilteredContainer *container;
+ GtkWidget *alignment;
+ GtkWidget *drawing_area;
+ GtkWidget *frame;
+ gint x;
+ gint y;
+ gint width;
+ gint height;
+ gint popup_height;
+ GHashTable *tag_hash;
+ GList *tag_list;
+ GList *tag_iterator;
+ gint i;
+ gint j;
+ gint max_height;
+ gint screen_height;
+ gchar **current_tags;
+ gint current_count;
+ const gchar *list_tag;
+ GdkRectangle popup_rects[2]; /* variants of popup placement */
+ GdkRectangle popup_rect; /* best popup rect in screen coordinates */
object = G_OBJECT_CLASS (parent_class)->constructor (type,
@@ -214,7 +223,9 @@
current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (popup->combo_entry));
current_count = g_strv_length (current_tags);
- tag_hash = popup->combo_entry->filtered_container->tag_ref_counts;
+ container = GIMP_TAG_ENTRY (popup->combo_entry)->container;
+
+ tag_hash = 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);
@@ -247,7 +258,7 @@
popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
}
}
- gimp_container_foreach (GIMP_CONTAINER (popup->combo_entry->filtered_container),
+ gimp_container_foreach (GIMP_CONTAINER (container),
(GFunc) gimp_tag_popup_check_can_toggle, popup);
}
@@ -326,48 +337,48 @@
}
static void
-gimp_tag_popup_dispose (GObject *object)
+gimp_tag_popup_dispose (GObject *object)
{
- GimpTagPopup *tag_popup = GIMP_TAG_POPUP (object);
+ GimpTagPopup *popup = GIMP_TAG_POPUP (object);
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
+ gimp_tag_popup_remove_scroll_timeout (popup);
- if (tag_popup->combo_entry)
+ if (popup->combo_entry)
{
- g_object_unref (tag_popup->combo_entry);
- tag_popup->combo_entry = NULL;
+ g_object_unref (popup->combo_entry);
+ popup->combo_entry = NULL;
}
- if (tag_popup->layout)
+ if (popup->layout)
{
- g_object_unref (tag_popup->layout);
- tag_popup->layout = NULL;
+ g_object_unref (popup->layout);
+ popup->layout = NULL;
}
- if (tag_popup->context)
+ if (popup->context)
{
- g_object_unref (tag_popup->context);
- tag_popup->context = NULL;
+ g_object_unref (popup->context);
+ popup->context = NULL;
}
- if (tag_popup->close_rectangles)
+ if (popup->close_rectangles)
{
- g_list_foreach (tag_popup->close_rectangles, (GFunc) g_free, NULL);
- g_list_free (tag_popup->close_rectangles);
- tag_popup->close_rectangles = NULL;
+ g_list_foreach (popup->close_rectangles, (GFunc) g_free, NULL);
+ g_list_free (popup->close_rectangles);
+ popup->close_rectangles = NULL;
}
- g_free (tag_popup->tag_data);
- tag_popup->tag_data = NULL;
+ g_free (popup->tag_data);
+ popup->tag_data = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-gimp_tag_popup_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+gimp_tag_popup_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GimpTagPopup *tag_popup = GIMP_TAG_POPUP (object);
@@ -408,8 +419,7 @@
/**
* gimp_tag_popup_new:
- * @combo_entry: #GimpComboTagEntry which is owner of the popup
- * window.
+ * @combo_entry: #GimpComboTagEntry which is owner of the popup window.
*
* Tag popup widget is only useful for for #GimpComboTagEntry and
* should not be used elsewhere.
@@ -417,7 +427,7 @@
* Return value: a newly created #GimpTagPopup widget.
**/
GtkWidget *
-gimp_tag_popup_new (GimpComboTagEntry *combo_entry)
+gimp_tag_popup_new (GimpComboTagEntry *combo_entry)
{
g_return_val_if_fail (GIMP_IS_COMBO_TAG_ENTRY (combo_entry), NULL);
@@ -429,7 +439,7 @@
/**
* gimp_tag_popup_show:
- * @tag_popup: an instance of #GimpTagPopup
+ * @tag_popup: an instance of #GimpTagPopup
*
* Show tag popup widget. If mouse grab cannot be obtained for widget,
* it is destroyed.
@@ -438,7 +448,7 @@
gimp_tag_popup_show (GimpTagPopup *popup)
{
- GdkGrabStatus grab_status;
+ GdkGrabStatus grab_status;
g_return_if_fail (popup);
@@ -461,21 +471,21 @@
}
static gint
-gimp_tag_popup_layout_tags (GimpTagPopup *tag_popup,
- gint width)
+gimp_tag_popup_layout_tags (GimpTagPopup *popup,
+ gint width)
{
- gint x;
- gint y;
- gint height = 0;
- gint i;
- gint line_height;
- gint space_width;
- PangoFontMetrics *font_metrics;
+ gint x;
+ gint y;
+ gint height = 0;
+ gint i;
+ gint line_height;
+ gint space_width;
+ PangoFontMetrics *font_metrics;
x = GIMP_TAG_POPUP_MARGIN;
y = GIMP_TAG_POPUP_MARGIN;
- font_metrics = pango_context_get_metrics (tag_popup->context,
- pango_context_get_font_description (tag_popup->context),
+ font_metrics = pango_context_get_metrics (popup->context,
+ pango_context_get_font_description (popup->context),
NULL);
line_height = pango_font_metrics_get_ascent (font_metrics) +
pango_font_metrics_get_descent (font_metrics);
@@ -483,38 +493,38 @@
line_height /= PANGO_SCALE;
space_width /= PANGO_SCALE;
pango_font_metrics_unref (font_metrics);
- for (i = 0; i < tag_popup->tag_count; i++)
+ for (i = 0; i < popup->tag_count; i++)
{
- pango_layout_set_text (tag_popup->layout,
- gimp_tag_get_name (tag_popup->tag_data[i].tag), -1);
- pango_layout_get_size (tag_popup->layout,
- &tag_popup->tag_data[i].bounds.width,
- &tag_popup->tag_data[i].bounds.height);
- tag_popup->tag_data[i].bounds.width /= PANGO_SCALE;
- tag_popup->tag_data[i].bounds.height /= PANGO_SCALE;
- if (tag_popup->tag_data[i].bounds.width + x + 3 +GIMP_TAG_POPUP_MARGIN > width)
+ pango_layout_set_text (popup->layout,
+ gimp_tag_get_name (popup->tag_data[i].tag), -1);
+ pango_layout_get_size (popup->layout,
+ &popup->tag_data[i].bounds.width,
+ &popup->tag_data[i].bounds.height);
+ popup->tag_data[i].bounds.width /= PANGO_SCALE;
+ popup->tag_data[i].bounds.height /= PANGO_SCALE;
+ if (popup->tag_data[i].bounds.width + x + 3 +GIMP_TAG_POPUP_MARGIN > width)
{
- if (tag_popup->tag_data[i].bounds.width + line_height + GIMP_TAG_POPUP_MARGIN < width)
+ if (popup->tag_data[i].bounds.width + line_height + GIMP_TAG_POPUP_MARGIN < width)
{
GdkRectangle *close_rect = g_malloc (sizeof (GdkRectangle));
close_rect->x = x - space_width - 5;
close_rect->y = y;
close_rect->width = width - close_rect->x;
close_rect->height = line_height + 2;
- tag_popup->close_rectangles = g_list_append (tag_popup->close_rectangles,
+ popup->close_rectangles = g_list_append (popup->close_rectangles,
close_rect);
}
x = GIMP_TAG_POPUP_MARGIN;
y += line_height + 2;
}
- tag_popup->tag_data[i].bounds.x = x;
- tag_popup->tag_data[i].bounds.y = y;
+ popup->tag_data[i].bounds.x = x;
+ popup->tag_data[i].bounds.y = y;
- x += tag_popup->tag_data[i].bounds.width + space_width + 5;
+ x += popup->tag_data[i].bounds.width + space_width + 5;
}
- if (tag_popup->tag_count > 0
+ if (popup->tag_count > 0
&& (width - x) > line_height + GIMP_TAG_POPUP_MARGIN)
{
GdkRectangle *close_rect = g_malloc (sizeof (GdkRectangle));
@@ -522,21 +532,21 @@
close_rect->y = y;
close_rect->width = width - close_rect->x;
close_rect->height = line_height + 2;
- tag_popup->close_rectangles = g_list_append (tag_popup->close_rectangles,
+ popup->close_rectangles = g_list_append (popup->close_rectangles,
close_rect);
}
- if (gtk_widget_get_direction (GTK_WIDGET (tag_popup)) == GTK_TEXT_DIR_RTL)
+ if (gtk_widget_get_direction (GTK_WIDGET (popup)) == GTK_TEXT_DIR_RTL)
{
GList *iterator;
- for (i = 0; i < tag_popup->tag_count; i++)
+ for (i = 0; i < popup->tag_count; i++)
{
- PopupTagData *tag_data = &tag_popup->tag_data[i];
+ PopupTagData *tag_data = &popup->tag_data[i];
tag_data->bounds.x = width - tag_data->bounds.x - tag_data->bounds.width;
}
- for (iterator = tag_popup->close_rectangles; iterator;
+ for (iterator = popup->close_rectangles; iterator;
iterator = g_list_next (iterator))
{
GdkRectangle *rect = (GdkRectangle *) iterator->data;
@@ -549,21 +559,21 @@
}
static gboolean
-gimp_tag_popup_border_expose (GtkWidget *widget,
- GdkEventExpose *event,
- GimpTagPopup *tag_popup)
-{
- GdkGC *gc;
- GdkRectangle border;
- GdkRectangle upper;
- GdkRectangle lower;
- gint arrow_space;
+gimp_tag_popup_border_expose (GtkWidget *widget,
+ GdkEventExpose *event,
+ GimpTagPopup *popup)
+{
+ GdkGC *gc;
+ GdkRectangle border;
+ GdkRectangle upper;
+ GdkRectangle lower;
+ gint arrow_space;
if (event->window == widget->window)
{
gc = gdk_gc_new (GDK_DRAWABLE (widget->window));
- get_arrows_visible_area (tag_popup, &border, &upper, &lower, &arrow_space);
+ get_arrows_visible_area (popup, &border, &upper, &lower, &arrow_space);
if (event->window == widget->window)
{
@@ -576,11 +586,11 @@
&event->area, widget, "menu",
0, 0, -1, -1);
- if (tag_popup->arrows_visible)
+ if (popup->arrows_visible)
{
gtk_paint_box (widget->style,
widget->window,
- tag_popup->upper_arrow_state,
+ popup->upper_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu",
upper.x,
@@ -590,7 +600,7 @@
gtk_paint_arrow (widget->style,
widget->window,
- tag_popup->upper_arrow_state,
+ popup->upper_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu_scroll_arrow_up",
GTK_ARROW_UP,
@@ -600,11 +610,11 @@
arrow_size, arrow_size);
}
- if (tag_popup->arrows_visible)
+ if (popup->arrows_visible)
{
gtk_paint_box (widget->style,
widget->window,
- tag_popup->lower_arrow_state,
+ popup->lower_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu",
lower.x,
@@ -614,7 +624,7 @@
gtk_paint_arrow (widget->style,
widget->window,
- tag_popup->lower_arrow_state,
+ popup->lower_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu_scroll_arrow_down",
GTK_ARROW_DOWN,
@@ -632,29 +642,28 @@
}
static gboolean
-gimp_tag_popup_border_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
+gimp_tag_popup_border_event (GtkWidget *widget,
+ GdkEvent *event)
{
- GimpTagPopup *tag_popup = GIMP_TAG_POPUP (widget);
+ GimpTagPopup *popup = GIMP_TAG_POPUP (widget);
if (event->type == GDK_BUTTON_PRESS)
{
- GdkEventButton *button_event;
- gint x;
- gint y;
+ GdkEventButton *button_event;
+ gint x;
+ gint y;
button_event = (GdkEventButton *) event;
if (button_event->window == widget->window
- && gimp_tag_popup_button_scroll (tag_popup, button_event))
+ && gimp_tag_popup_button_scroll (popup, button_event))
{
return TRUE;
}
gdk_window_get_pointer (widget->window, &x, &y, NULL);
- if (button_event->window != tag_popup->drawing_area->window
+ if (button_event->window != popup->drawing_area->window
&& (x < widget->allocation.y
|| y < widget->allocation.x
|| x > widget->allocation.x + widget->allocation.width
@@ -676,17 +685,17 @@
gdk_window_get_pointer (widget->window, &x, &y, NULL);
x += widget->allocation.x;
y += widget->allocation.y;
- tag_popup->ignore_button_release = FALSE;
- gimp_tag_popup_handle_scrolling (tag_popup, x, y,
- tag_popup->timeout_id == 0, TRUE);
+ popup->ignore_button_release = FALSE;
+ gimp_tag_popup_handle_scrolling (popup, x, y,
+ popup->timeout_id == 0, TRUE);
}
else if (event->type == GDK_BUTTON_RELEASE)
{
- tag_popup->single_select_disabled = TRUE;
+ popup->single_select_disabled = TRUE;
if (((GdkEventButton *)event)->window == widget->window
- && ! tag_popup->ignore_button_release
- && gimp_tag_popup_button_scroll (tag_popup, (GdkEventButton *) event))
+ && ! popup->ignore_button_release
+ && gimp_tag_popup_button_scroll (popup, (GdkEventButton *) event))
{
return TRUE;
}
@@ -700,7 +709,7 @@
}
else if (event->type == GDK_KEY_PRESS)
{
- gtk_widget_destroy (GTK_WIDGET (tag_popup));
+ gtk_widget_destroy (GTK_WIDGET (popup));
}
else if (event->type == GDK_SCROLL)
{
@@ -710,12 +719,12 @@
{
case GDK_SCROLL_RIGHT:
case GDK_SCROLL_DOWN:
- gimp_tag_popup_scroll_by (tag_popup, MENU_SCROLL_STEP2);
+ gimp_tag_popup_scroll_by (popup, MENU_SCROLL_STEP2);
return TRUE;
case GDK_SCROLL_LEFT:
case GDK_SCROLL_UP:
- gimp_tag_popup_scroll_by (tag_popup, - MENU_SCROLL_STEP2);
+ gimp_tag_popup_scroll_by (popup, - MENU_SCROLL_STEP2);
return TRUE;
}
}
@@ -724,15 +733,15 @@
}
static gboolean
-gimp_tag_popup_list_expose (GtkWidget *widget,
- GdkEventExpose *event,
- GimpTagPopup *tag_popup)
-{
- GdkGC *gc;
- PangoRenderer *renderer;
- gint i;
- PangoAttribute *attribute;
- PangoAttrList *attributes;
+gimp_tag_popup_list_expose (GtkWidget *widget,
+ GdkEventExpose *event,
+ GimpTagPopup *popup)
+{
+ GdkGC *gc;
+ PangoRenderer *renderer;
+ gint i;
+ PangoAttribute *attribute;
+ PangoAttrList *attributes;
renderer = gdk_pango_renderer_get_default (gtk_widget_get_screen (widget));
gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), widget->style->black_gc);
@@ -740,60 +749,60 @@
widget->window);
gc = gdk_gc_new (GDK_DRAWABLE (widget->window));
- gdk_gc_set_rgb_fg_color (gc, &tag_popup->combo_entry->selected_item_color);
+ gdk_gc_set_rgb_fg_color (gc, &popup->combo_entry->selected_item_color);
gdk_gc_set_line_attributes (gc, 5, GDK_LINE_SOLID, GDK_CAP_ROUND,
GDK_JOIN_ROUND);
- for (i = 0; i < tag_popup->tag_count; i++)
+ for (i = 0; i < popup->tag_count; i++)
{
- pango_layout_set_text (tag_popup->layout,
- gimp_tag_get_name (tag_popup->tag_data[i].tag), -1);
- if (tag_popup->tag_data[i].state == GTK_STATE_SELECTED)
+ pango_layout_set_text (popup->layout,
+ gimp_tag_get_name (popup->tag_data[i].tag), -1);
+ if (popup->tag_data[i].state == GTK_STATE_SELECTED)
{
- attributes = pango_attr_list_copy (tag_popup->combo_entry->selected_item_attr);
+ attributes = pango_attr_list_copy (popup->combo_entry->selected_item_attr);
}
- else if (tag_popup->tag_data[i].state == GTK_STATE_INSENSITIVE)
+ else if (popup->tag_data[i].state == GTK_STATE_INSENSITIVE)
{
- attributes = pango_attr_list_copy (tag_popup->combo_entry->insensitive_item_attr);
+ attributes = pango_attr_list_copy (popup->combo_entry->insensitive_item_attr);
}
else
{
- attributes = pango_attr_list_copy (tag_popup->combo_entry->normal_item_attr);
+ attributes = pango_attr_list_copy (popup->combo_entry->normal_item_attr);
}
- if (&tag_popup->tag_data[i] == tag_popup->prelight
- && tag_popup->tag_data[i].state != GTK_STATE_INSENSITIVE)
+ if (&popup->tag_data[i] == popup->prelight
+ && popup->tag_data[i].state != GTK_STATE_INSENSITIVE)
{
attribute = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
pango_attr_list_insert (attributes, attribute);
}
- pango_layout_set_attributes (tag_popup->layout, attributes);
+ pango_layout_set_attributes (popup->layout, attributes);
pango_attr_list_unref (attributes);
- if (tag_popup->tag_data[i].state == GTK_STATE_SELECTED)
+ if (popup->tag_data[i].state == GTK_STATE_SELECTED)
{
gdk_draw_rectangle (widget->window, gc, FALSE,
- tag_popup->tag_data[i].bounds.x - 1,
- tag_popup->tag_data[i].bounds.y - tag_popup->scroll_y + 1,
- tag_popup->tag_data[i].bounds.width + 2,
- tag_popup->tag_data[i].bounds.height - 2);
- }
- pango_renderer_draw_layout (renderer, tag_popup->layout,
- (tag_popup->tag_data[i].bounds.x) * PANGO_SCALE,
- (tag_popup->tag_data[i].bounds.y - tag_popup->scroll_y) * PANGO_SCALE);
-
- if (&tag_popup->tag_data[i] == tag_popup->prelight
- && tag_popup->tag_data[i].state != GTK_STATE_INSENSITIVE
- && ! tag_popup->single_select_disabled)
+ popup->tag_data[i].bounds.x - 1,
+ popup->tag_data[i].bounds.y - popup->scroll_y + 1,
+ popup->tag_data[i].bounds.width + 2,
+ popup->tag_data[i].bounds.height - 2);
+ }
+ pango_renderer_draw_layout (renderer, popup->layout,
+ (popup->tag_data[i].bounds.x) * PANGO_SCALE,
+ (popup->tag_data[i].bounds.y - popup->scroll_y) * PANGO_SCALE);
+
+ if (&popup->tag_data[i] == popup->prelight
+ && popup->tag_data[i].state != GTK_STATE_INSENSITIVE
+ && ! popup->single_select_disabled)
{
gtk_paint_focus (widget->style, widget->window,
- tag_popup->tag_data[i].state,
+ popup->tag_data[i].state,
&event->area, widget, NULL,
- tag_popup->tag_data[i].bounds.x,
- tag_popup->tag_data[i].bounds.y - tag_popup->scroll_y,
- tag_popup->tag_data[i].bounds.width,
- tag_popup->tag_data[i].bounds.height);
+ popup->tag_data[i].bounds.x,
+ popup->tag_data[i].bounds.y - popup->scroll_y,
+ popup->tag_data[i].bounds.width,
+ popup->tag_data[i].bounds.height);
}
}
@@ -806,48 +815,48 @@
}
static gboolean
-gimp_tag_popup_list_event (GtkWidget *widget,
- GdkEvent *event,
- GimpTagPopup *tag_popup)
+gimp_tag_popup_list_event (GtkWidget *widget,
+ GdkEvent *event,
+ GimpTagPopup *popup)
{
if (event->type == GDK_BUTTON_PRESS)
{
- GdkEventButton *button_event;
- gint x;
- gint y;
- gint i;
- GdkRectangle *bounds;
- GimpTag *tag;
+ GdkEventButton *button_event;
+ gint x;
+ gint y;
+ gint i;
+ GdkRectangle *bounds;
+ GimpTag *tag;
- tag_popup->single_select_disabled = TRUE;
+ popup->single_select_disabled = TRUE;
button_event = (GdkEventButton *) event;
x = button_event->x;
y = button_event->y;
- y += tag_popup->scroll_y;
+ y += popup->scroll_y;
- for (i = 0; i < tag_popup->tag_count; i++)
+ for (i = 0; i < popup->tag_count; i++)
{
- bounds = &tag_popup->tag_data[i].bounds;
+ bounds = &popup->tag_data[i].bounds;
if (x >= bounds->x
&& y >= bounds->y
&& x < bounds->x + bounds->width
&& y < bounds->y + bounds->height)
{
- tag = tag_popup->tag_data[i].tag;
- gimp_tag_popup_toggle_tag (tag_popup,
- &tag_popup->tag_data[i]);
+ tag = popup->tag_data[i].tag;
+ gimp_tag_popup_toggle_tag (popup,
+ &popup->tag_data[i]);
gtk_widget_queue_draw (widget);
break;
}
}
- if (i == tag_popup->tag_count)
+ if (i == popup->tag_count)
{
- GList *iterator;
+ GList *iterator;
- for (iterator = tag_popup->close_rectangles; iterator;
+ for (iterator = popup->close_rectangles; iterator;
iterator = g_list_next (iterator))
{
bounds = (GdkRectangle *) iterator->data;
@@ -856,7 +865,7 @@
&& x < bounds->x + bounds->width
&& y < bounds->y + bounds->height)
{
- gtk_widget_destroy (GTK_WIDGET (tag_popup));
+ gtk_widget_destroy (GTK_WIDGET (popup));
break;
}
}
@@ -864,39 +873,39 @@
}
else if (event->type == GDK_MOTION_NOTIFY)
{
- GdkEventMotion *motion_event;
- gint x;
- gint y;
- gint i;
- GdkRectangle *bounds;
- PopupTagData *previous_prelight = tag_popup->prelight;
+ GdkEventMotion *motion_event;
+ gint x;
+ gint y;
+ gint i;
+ GdkRectangle *bounds;
+ PopupTagData *previous_prelight = popup->prelight;
motion_event = (GdkEventMotion*) event;
x = motion_event->x;
y = motion_event->y;
- y += tag_popup->scroll_y;
+ y += popup->scroll_y;
- tag_popup->prelight = NULL;
- for (i = 0; i < tag_popup->tag_count; i++)
+ popup->prelight = NULL;
+ for (i = 0; i < popup->tag_count; i++)
{
- bounds = &tag_popup->tag_data[i].bounds;
+ bounds = &popup->tag_data[i].bounds;
if (x >= bounds->x
&& y >= bounds->y
&& x < bounds->x + bounds->width
&& y < bounds->y + bounds->height)
{
- tag_popup->prelight = &tag_popup->tag_data[i];
+ popup->prelight = &popup->tag_data[i];
break;
}
}
- if (previous_prelight != tag_popup->prelight)
+ if (previous_prelight != popup->prelight)
{
gtk_widget_queue_draw (widget);
}
}
else if (event->type == GDK_BUTTON_RELEASE
- && !tag_popup->single_select_disabled)
+ && !popup->single_select_disabled)
{
GdkEventButton *button_event;
gint x;
@@ -905,26 +914,25 @@
GdkRectangle *bounds;
GimpTag *tag;
- tag_popup->single_select_disabled = TRUE;
+ popup->single_select_disabled = TRUE;
button_event = (GdkEventButton *) event;
x = button_event->x;
y = button_event->y;
- y += tag_popup->scroll_y;
+ y += popup->scroll_y;
- for (i = 0; i < tag_popup->tag_count; i++)
+ for (i = 0; i < popup->tag_count; i++)
{
- bounds = &tag_popup->tag_data[i].bounds;
+ bounds = &popup->tag_data[i].bounds;
if (x >= bounds->x
&& y >= bounds->y
&& x < bounds->x + bounds->width
&& y < bounds->y + bounds->height)
{
- tag = tag_popup->tag_data[i].tag;
- gimp_tag_popup_toggle_tag (tag_popup,
- &tag_popup->tag_data[i]);
- gtk_widget_destroy (GTK_WIDGET (tag_popup));
+ tag = popup->tag_data[i].tag;
+ gimp_tag_popup_toggle_tag (popup, &popup->tag_data[i]);
+ gtk_widget_destroy (GTK_WIDGET (popup));
break;
}
}
@@ -934,15 +942,15 @@
}
static void
-gimp_tag_popup_toggle_tag (GimpTagPopup *tag_popup,
- PopupTagData *tag_data)
+gimp_tag_popup_toggle_tag (GimpTagPopup *popup,
+ PopupTagData *tag_data)
{
- gchar **current_tags;
- GString *tag_str;
- const gchar *tag;
- gint length;
- gint i;
- gboolean tag_toggled_off = FALSE;
+ gchar **current_tags;
+ GString *tag_str;
+ const gchar *tag;
+ gint length;
+ gint i;
+ gboolean tag_toggled_off = FALSE;
if (tag_data->state == GTK_STATE_NORMAL)
{
@@ -958,7 +966,7 @@
}
tag = gimp_tag_get_name (tag_data->tag);
- current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (tag_popup->combo_entry));
+ current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (popup->combo_entry));
tag_str = g_string_new ("");
length = g_strv_length (current_tags);
for (i = 0; i < length; i++)
@@ -990,36 +998,42 @@
g_string_append (tag_str, tag);
}
- gimp_tag_entry_set_tag_string (GIMP_TAG_ENTRY (tag_popup->combo_entry),
+ gimp_tag_entry_set_tag_string (GIMP_TAG_ENTRY (popup->combo_entry),
tag_str->str);
g_string_free (tag_str, TRUE);
g_strfreev (current_tags);
- if (GIMP_TAG_ENTRY (tag_popup->combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
+ if (GIMP_TAG_ENTRY (popup->combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
{
- for (i = 0; i < tag_popup->tag_count; i++)
+ GimpFilteredContainer *container;
+
+ container = GIMP_TAG_ENTRY (popup->combo_entry)->container;
+
+ for (i = 0; i < popup->tag_count; i++)
{
- if (tag_popup->tag_data[i].state != GTK_STATE_SELECTED)
+ if (popup->tag_data[i].state != GTK_STATE_SELECTED)
{
- tag_popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
+ popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
}
}
- gimp_container_foreach (GIMP_CONTAINER (tag_popup->combo_entry->filtered_container),
- (GFunc) gimp_tag_popup_check_can_toggle, tag_popup);
+ gimp_container_foreach (GIMP_CONTAINER (container),
+ (GFunc) gimp_tag_popup_check_can_toggle,
+ popup);
}
}
static int
-gimp_tag_popup_data_compare (const void *a, const void *b)
+gimp_tag_popup_data_compare (const void *a,
+ const void *b)
{
return gimp_tag_compare_func (GIMP_TAG (((PopupTagData *) a)->tag),
GIMP_TAG (((PopupTagData *) b)->tag));
}
static void
-gimp_tag_popup_check_can_toggle (GimpTagged *tagged,
- GimpTagPopup *tag_popup)
+gimp_tag_popup_check_can_toggle (GimpTagged *tagged,
+ GimpTagPopup *popup)
{
GList *tag_iterator;
PopupTagData search_key;
@@ -1030,7 +1044,7 @@
{
search_key.tag = GIMP_TAG (tag_iterator->data);
search_result =
- (PopupTagData *) bsearch (&search_key, tag_popup->tag_data, tag_popup->tag_count,
+ (PopupTagData *) bsearch (&search_key, popup->tag_data, popup->tag_count,
sizeof (PopupTagData), gimp_tag_popup_data_compare);
if (search_result)
{
@@ -1045,165 +1059,163 @@
static gboolean
gimp_tag_popup_scroll_timeout (gpointer data)
{
- GimpTagPopup *tag_popup;
- gboolean touchscreen_mode;
-
- tag_popup = (GimpTagPopup*) data;
+ GimpTagPopup *popup = (GimpTagPopup *) data;
+ gboolean touchscreen_mode;
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (tag_popup)),
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
- gimp_tag_popup_do_timeout_scroll (tag_popup, touchscreen_mode);
+ gimp_tag_popup_do_timeout_scroll (popup, touchscreen_mode);
return TRUE;
}
static void
-gimp_tag_popup_remove_scroll_timeout (GimpTagPopup *tag_popup)
+gimp_tag_popup_remove_scroll_timeout (GimpTagPopup *popup)
{
- if (tag_popup->timeout_id)
+ if (popup->timeout_id)
{
- g_source_remove (tag_popup->timeout_id);
- tag_popup->timeout_id = 0;
+ g_source_remove (popup->timeout_id);
+ popup->timeout_id = 0;
}
}
static gboolean
gimp_tag_popup_scroll_timeout_initial (gpointer data)
{
- GimpTagPopup *tag_popup;
+ GimpTagPopup *popup;
guint timeout;
gboolean touchscreen_mode;
- tag_popup = (GimpTagPopup*) (data);
+ popup = (GimpTagPopup*) (data);
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (tag_popup)),
- "gtk-timeout-repeat", &timeout,
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
+ "gtk-timeout-repeat", &timeout,
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
- gimp_tag_popup_do_timeout_scroll (tag_popup, touchscreen_mode);
+ gimp_tag_popup_do_timeout_scroll (popup, touchscreen_mode);
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
+ gimp_tag_popup_remove_scroll_timeout (popup);
- tag_popup->timeout_id = gdk_threads_add_timeout (timeout,
+ popup->timeout_id = gdk_threads_add_timeout (timeout,
gimp_tag_popup_scroll_timeout,
- tag_popup);
+ popup);
return FALSE;
}
static void
-gimp_tag_popup_start_scrolling (GimpTagPopup *tag_popup)
+gimp_tag_popup_start_scrolling (GimpTagPopup *popup)
{
guint timeout;
gboolean touchscreen_mode;
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (tag_popup)),
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
"gtk-timeout-repeat", &timeout,
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
- gimp_tag_popup_do_timeout_scroll (tag_popup, touchscreen_mode);
+ gimp_tag_popup_do_timeout_scroll (popup, touchscreen_mode);
- tag_popup->timeout_id = gdk_threads_add_timeout (timeout,
- gimp_tag_popup_scroll_timeout_initial,
- tag_popup);
+ popup->timeout_id = gdk_threads_add_timeout (timeout,
+ gimp_tag_popup_scroll_timeout_initial,
+ popup);
}
static void
-gimp_tag_popup_stop_scrolling (GimpTagPopup *tag_popup)
+gimp_tag_popup_stop_scrolling (GimpTagPopup *popup)
{
gboolean touchscreen_mode;
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
+ gimp_tag_popup_remove_scroll_timeout (popup);
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (tag_popup)),
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
if (!touchscreen_mode)
{
- tag_popup->upper_arrow_prelight = FALSE;
- tag_popup->lower_arrow_prelight = FALSE;
+ popup->upper_arrow_prelight = FALSE;
+ popup->lower_arrow_prelight = FALSE;
}
}
static void
-gimp_tag_popup_scroll_by (GimpTagPopup *tag_popup,
- gint step)
+gimp_tag_popup_scroll_by (GimpTagPopup *popup,
+ gint step)
{
- gint new_scroll_y = tag_popup->scroll_y + step;
+ gint new_scroll_y = popup->scroll_y + step;
if (new_scroll_y < 0)
{
new_scroll_y = 0;
- if (tag_popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
+ if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
{
- gimp_tag_popup_stop_scrolling (tag_popup);
- gtk_widget_queue_draw (GTK_WIDGET (tag_popup));
+ gimp_tag_popup_stop_scrolling (popup);
+ gtk_widget_queue_draw (GTK_WIDGET (popup));
}
- tag_popup->upper_arrow_state = GTK_STATE_INSENSITIVE;
+ popup->upper_arrow_state = GTK_STATE_INSENSITIVE;
}
else
{
- tag_popup->upper_arrow_state = tag_popup->upper_arrow_prelight ?
+ popup->upper_arrow_state = popup->upper_arrow_prelight ?
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
}
- if (new_scroll_y >= tag_popup->scroll_height)
+ if (new_scroll_y >= popup->scroll_height)
{
- new_scroll_y = tag_popup->scroll_height - 1;
- if (tag_popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
+ new_scroll_y = popup->scroll_height - 1;
+ if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
{
- gimp_tag_popup_stop_scrolling (tag_popup);
- gtk_widget_queue_draw (GTK_WIDGET (tag_popup));
+ gimp_tag_popup_stop_scrolling (popup);
+ gtk_widget_queue_draw (GTK_WIDGET (popup));
}
- tag_popup->lower_arrow_state = GTK_STATE_INSENSITIVE;
+ popup->lower_arrow_state = GTK_STATE_INSENSITIVE;
}
else
{
- tag_popup->lower_arrow_state = tag_popup->lower_arrow_prelight ?
+ popup->lower_arrow_state = popup->lower_arrow_prelight ?
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
}
- if (new_scroll_y != tag_popup->scroll_y)
+ if (new_scroll_y != popup->scroll_y)
{
- tag_popup->scroll_y = new_scroll_y;
- gdk_window_scroll (tag_popup->drawing_area->window, 0, -step);
+ popup->scroll_y = new_scroll_y;
+ gdk_window_scroll (popup->drawing_area->window, 0, -step);
}
}
static void
-gimp_tag_popup_do_timeout_scroll (GimpTagPopup *tag_popup,
+gimp_tag_popup_do_timeout_scroll (GimpTagPopup *popup,
gboolean touchscreen_mode)
{
- gimp_tag_popup_scroll_by (tag_popup, tag_popup->scroll_step);
+ gimp_tag_popup_scroll_by (popup, popup->scroll_step);
}
static void
-gimp_tag_popup_handle_scrolling (GimpTagPopup *tag_popup,
+gimp_tag_popup_handle_scrolling (GimpTagPopup *popup,
gint x,
gint y,
gboolean enter,
gboolean motion)
{
GdkRectangle rect;
- gboolean in_arrow;
- gboolean scroll_fast = FALSE;
- gboolean touchscreen_mode;
+ gboolean in_arrow;
+ gboolean scroll_fast = FALSE;
+ gboolean touchscreen_mode;
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (tag_popup)),
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
/* upper arrow handling */
- get_arrows_sensitive_area (tag_popup, &rect, NULL);
+ get_arrows_sensitive_area (popup, &rect, NULL);
in_arrow = FALSE;
- if (tag_popup->arrows_visible &&
+ if (popup->arrows_visible &&
(x >= rect.x) && (x < rect.x + rect.width) &&
(y >= rect.y) && (y < rect.y + rect.height))
{
@@ -1211,27 +1223,27 @@
}
if (touchscreen_mode)
- tag_popup->upper_arrow_prelight = in_arrow;
+ popup->upper_arrow_prelight = in_arrow;
- if (tag_popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
+ if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
{
gboolean arrow_pressed = FALSE;
- if (tag_popup->arrows_visible)
+ if (popup->arrows_visible)
{
if (touchscreen_mode)
{
- if (enter && tag_popup->upper_arrow_prelight)
+ if (enter && popup->upper_arrow_prelight)
{
- if (tag_popup->timeout_id == 0)
+ if (popup->timeout_id == 0)
{
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
- tag_popup->scroll_step = -MENU_SCROLL_STEP2; /* always fast */
+ gimp_tag_popup_remove_scroll_timeout (popup);
+ popup->scroll_step = -MENU_SCROLL_STEP2; /* always fast */
if (!motion)
{
/* Only do stuff on click. */
- gimp_tag_popup_start_scrolling (tag_popup);
+ gimp_tag_popup_start_scrolling (popup);
arrow_pressed = TRUE;
}
}
@@ -1242,7 +1254,7 @@
}
else if (!enter)
{
- gimp_tag_popup_stop_scrolling (tag_popup);
+ gimp_tag_popup_stop_scrolling (popup);
}
}
else /* !touchscreen_mode */
@@ -1250,25 +1262,25 @@
scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE);
if (enter && in_arrow &&
- (!tag_popup->upper_arrow_prelight ||
- tag_popup->scroll_fast != scroll_fast))
+ (!popup->upper_arrow_prelight ||
+ popup->scroll_fast != scroll_fast))
{
- tag_popup->upper_arrow_prelight = TRUE;
- tag_popup->scroll_fast = scroll_fast;
+ popup->upper_arrow_prelight = TRUE;
+ popup->scroll_fast = scroll_fast;
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
- tag_popup->scroll_step = scroll_fast ?
+ gimp_tag_popup_remove_scroll_timeout (popup);
+ popup->scroll_step = scroll_fast ?
-MENU_SCROLL_STEP2 : -MENU_SCROLL_STEP1;
- tag_popup->timeout_id =
+ popup->timeout_id =
gdk_threads_add_timeout (scroll_fast ?
MENU_SCROLL_TIMEOUT2 :
MENU_SCROLL_TIMEOUT1,
- gimp_tag_popup_scroll_timeout, tag_popup);
+ gimp_tag_popup_scroll_timeout, popup);
}
- else if (!enter && !in_arrow && tag_popup->upper_arrow_prelight)
+ else if (!enter && !in_arrow && popup->upper_arrow_prelight)
{
- gimp_tag_popup_stop_scrolling (tag_popup);
+ gimp_tag_popup_stop_scrolling (popup);
}
}
}
@@ -1277,20 +1289,20 @@
* tag_popup, so check if the button isn't insensitive before
* changing it to something else.
*/
- if (tag_popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
+ if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
{
GtkStateType arrow_state = GTK_STATE_NORMAL;
if (arrow_pressed)
arrow_state = GTK_STATE_ACTIVE;
- else if (tag_popup->upper_arrow_prelight)
+ else if (popup->upper_arrow_prelight)
arrow_state = GTK_STATE_PRELIGHT;
- if (arrow_state != tag_popup->upper_arrow_state)
+ if (arrow_state != popup->upper_arrow_state)
{
- tag_popup->upper_arrow_state = arrow_state;
+ popup->upper_arrow_state = arrow_state;
- gdk_window_invalidate_rect (GTK_WIDGET (tag_popup)->window,
+ gdk_window_invalidate_rect (GTK_WIDGET (popup)->window,
&rect, FALSE);
}
}
@@ -1298,10 +1310,10 @@
/* lower arrow handling */
- get_arrows_sensitive_area (tag_popup, NULL, &rect);
+ get_arrows_sensitive_area (popup, NULL, &rect);
in_arrow = FALSE;
- if (tag_popup->arrows_visible &&
+ if (popup->arrows_visible &&
(x >= rect.x) && (x < rect.x + rect.width) &&
(y >= rect.y) && (y < rect.y + rect.height))
{
@@ -1309,27 +1321,27 @@
}
if (touchscreen_mode)
- tag_popup->lower_arrow_prelight = in_arrow;
+ popup->lower_arrow_prelight = in_arrow;
- if (tag_popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
+ if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
{
gboolean arrow_pressed = FALSE;
- if (tag_popup->arrows_visible)
+ if (popup->arrows_visible)
{
if (touchscreen_mode)
{
- if (enter && tag_popup->lower_arrow_prelight)
+ if (enter && popup->lower_arrow_prelight)
{
- if (tag_popup->timeout_id == 0)
+ if (popup->timeout_id == 0)
{
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
- tag_popup->scroll_step = MENU_SCROLL_STEP2; /* always fast */
+ gimp_tag_popup_remove_scroll_timeout (popup);
+ popup->scroll_step = MENU_SCROLL_STEP2; /* always fast */
if (!motion)
{
/* Only do stuff on click. */
- gimp_tag_popup_start_scrolling (tag_popup);
+ gimp_tag_popup_start_scrolling (popup);
arrow_pressed = TRUE;
}
}
@@ -1340,7 +1352,7 @@
}
else if (!enter)
{
- gimp_tag_popup_stop_scrolling (tag_popup);
+ gimp_tag_popup_stop_scrolling (popup);
}
}
else /* !touchscreen_mode */
@@ -1348,47 +1360,47 @@
scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE);
if (enter && in_arrow &&
- (!tag_popup->lower_arrow_prelight ||
- tag_popup->scroll_fast != scroll_fast))
+ (!popup->lower_arrow_prelight ||
+ popup->scroll_fast != scroll_fast))
{
- tag_popup->lower_arrow_prelight = TRUE;
- tag_popup->scroll_fast = scroll_fast;
+ popup->lower_arrow_prelight = TRUE;
+ popup->scroll_fast = scroll_fast;
- gimp_tag_popup_remove_scroll_timeout (tag_popup);
- tag_popup->scroll_step = scroll_fast ?
+ gimp_tag_popup_remove_scroll_timeout (popup);
+ popup->scroll_step = scroll_fast ?
MENU_SCROLL_STEP2 : MENU_SCROLL_STEP1;
- tag_popup->timeout_id =
+ popup->timeout_id =
gdk_threads_add_timeout (scroll_fast ?
MENU_SCROLL_TIMEOUT2 :
MENU_SCROLL_TIMEOUT1,
- gimp_tag_popup_scroll_timeout, tag_popup);
+ gimp_tag_popup_scroll_timeout, popup);
}
- else if (!enter && !in_arrow && tag_popup->lower_arrow_prelight)
+ else if (!enter && !in_arrow && popup->lower_arrow_prelight)
{
- gimp_tag_popup_stop_scrolling (tag_popup);
+ gimp_tag_popup_stop_scrolling (popup);
}
}
}
/* gimp_tag_popup_start_scrolling() might have hit the bottom of the
- * tag_popup, so check if the button isn't insensitive before
+ * popup, so check if the button isn't insensitive before
* changing it to something else.
*/
- if (tag_popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
+ if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
{
GtkStateType arrow_state = GTK_STATE_NORMAL;
if (arrow_pressed)
arrow_state = GTK_STATE_ACTIVE;
- else if (tag_popup->lower_arrow_prelight)
+ else if (popup->lower_arrow_prelight)
arrow_state = GTK_STATE_PRELIGHT;
- if (arrow_state != tag_popup->lower_arrow_state)
+ if (arrow_state != popup->lower_arrow_state)
{
- tag_popup->lower_arrow_state = arrow_state;
+ popup->lower_arrow_state = arrow_state;
- gdk_window_invalidate_rect (GTK_WIDGET (tag_popup)->window,
+ gdk_window_invalidate_rect (GTK_WIDGET (popup)->window,
&rect, FALSE);
}
}
@@ -1396,20 +1408,20 @@
}
static gboolean
-gimp_tag_popup_button_scroll (GimpTagPopup *tag_popup,
- GdkEventButton *event)
+gimp_tag_popup_button_scroll (GimpTagPopup *popup,
+ GdkEventButton *event)
{
- if (tag_popup->upper_arrow_prelight
- || tag_popup->lower_arrow_prelight)
+ if (popup->upper_arrow_prelight
+ || popup->lower_arrow_prelight)
{
gboolean touchscreen_mode;
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (tag_popup)),
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
if (touchscreen_mode)
- gimp_tag_popup_handle_scrolling (tag_popup,
+ gimp_tag_popup_handle_scrolling (popup,
event->x_root, event->y_root,
event->type == GDK_BUTTON_PRESS,
FALSE);
@@ -1421,20 +1433,20 @@
}
static void
-get_arrows_visible_area (GimpTagPopup *tag_popup,
+get_arrows_visible_area (GimpTagPopup *popup,
GdkRectangle *border,
GdkRectangle *upper,
GdkRectangle *lower,
gint *arrow_space)
{
- GtkWidget *widget = GTK_WIDGET (tag_popup->alignment);
- gint scroll_arrow_height = tag_popup->scroll_arrow_height;
- guint padding_top;
- guint padding_bottom;
- guint padding_left;
- guint padding_right;
+ GtkWidget *widget = GTK_WIDGET (popup->alignment);
+ gint scroll_arrow_height = popup->scroll_arrow_height;
+ guint padding_top;
+ guint padding_bottom;
+ guint padding_left;
+ guint padding_right;
- gtk_alignment_get_padding (GTK_ALIGNMENT (tag_popup->alignment),
+ gtk_alignment_get_padding (GTK_ALIGNMENT (popup->alignment),
&padding_top, &padding_bottom,
&padding_left, &padding_right);
@@ -1454,16 +1466,17 @@
}
static void
-get_arrows_sensitive_area (GimpTagPopup *tag_popup,
- GdkRectangle *upper,
- GdkRectangle *lower)
+get_arrows_sensitive_area (GimpTagPopup *popup,
+ GdkRectangle *upper,
+ GdkRectangle *lower)
{
GdkRectangle tmp_border;
GdkRectangle tmp_upper;
GdkRectangle tmp_lower;
gint tmp_arrow_space;
- get_arrows_visible_area (tag_popup, &tmp_border, &tmp_upper, &tmp_lower, &tmp_arrow_space);
+ get_arrows_visible_area (popup,
+ &tmp_border, &tmp_upper, &tmp_lower, &tmp_arrow_space);
if (upper)
{
*upper = tmp_upper;
Modified: trunk/app/widgets/gimptagpopup.h
==============================================================================
--- trunk/app/widgets/gimptagpopup.h (original)
+++ trunk/app/widgets/gimptagpopup.h Wed Dec 31 00:01:24 2008
@@ -32,49 +32,46 @@
typedef struct _GimpTagPopupClass GimpTagPopupClass;
-typedef struct
-{
- GimpTag *tag;
- GdkRectangle bounds;
- GtkStateType state;
-} PopupTagData;
+typedef struct _PopupTagData PopupTagData;
struct _GimpTagPopup
{
- GtkWindow parent_instance;
- GimpComboTagEntry *combo_entry;
- GtkWidget *alignment;
- GtkWidget *drawing_area;
- PangoContext *context;
- PangoLayout *layout;
- PopupTagData *tag_data;
- PopupTagData *prelight;
- gint tag_count;
- GList *close_rectangles;
- guint timeout_id;
- gint scroll_height;
- gint scroll_y;
- gint scroll_step;
- gint scroll_arrow_height;
- gboolean scroll_fast;
- gboolean arrows_visible;
- gboolean ignore_button_release;
- gboolean upper_arrow_prelight;
- gboolean lower_arrow_prelight;
- gboolean single_select_disabled;
- GtkStateType upper_arrow_state;
- GtkStateType lower_arrow_state;
+ GtkWindow parent_instance;
+ GimpComboTagEntry *combo_entry;
+ GtkWidget *alignment;
+ GtkWidget *drawing_area;
+ PangoContext *context;
+ PangoLayout *layout;
+ PopupTagData *tag_data;
+ PopupTagData *prelight;
+ gint tag_count;
+ GList *close_rectangles;
+ guint timeout_id;
+ gint scroll_height;
+ gint scroll_y;
+ gint scroll_step;
+ gint scroll_arrow_height;
+ gboolean scroll_fast;
+ gboolean arrows_visible;
+ gboolean ignore_button_release;
+ gboolean upper_arrow_prelight;
+ gboolean lower_arrow_prelight;
+ gboolean single_select_disabled;
+ GtkStateType upper_arrow_state;
+ GtkStateType lower_arrow_state;
};
struct _GimpTagPopupClass
{
- GtkWindowClass parent_class;
+ GtkWindowClass parent_class;
};
-GType gimp_tag_popup_get_type (void) G_GNUC_CONST;
+GType gimp_tag_popup_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_tag_popup_new (GimpComboTagEntry *entry);
+
+void gimp_tag_popup_show (GimpTagPopup *popup);
-GtkWidget * gimp_tag_popup_new (GimpComboTagEntry *combo_entry);
-void gimp_tag_popup_show (GimpTagPopup *popup);
#endif /* __GIMP_TAG_POPUP_H__ */
Modified: trunk/app/widgets/widgets-enums.c
==============================================================================
--- trunk/app/widgets/widgets-enums.c (original)
+++ trunk/app/widgets/widgets-enums.c Wed Dec 31 00:01:24 2008
@@ -292,6 +292,35 @@
}
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, "GIMP_TAG_ENTRY_MODE_QUERY", NULL },
+ { GIMP_TAG_ENTRY_MODE_ASSIGN, "GIMP_TAG_ENTRY_MODE_ASSIGN", NULL },
+ { 0, NULL, NULL }
+ };
+
+ static GType type = 0;
+
+ if (G_UNLIKELY (! type))
+ {
+ type = g_enum_register_static ("GimpTagEntryMode", values);
+ gimp_type_set_translation_context (type, "tag-entry-mode");
+ gimp_enum_set_value_descriptions (type, descs);
+ }
+
+ return type;
+}
+
+GType
gimp_window_hint_get_type (void)
{
static const GEnumValue values[] =
Modified: trunk/app/widgets/widgets-enums.h
==============================================================================
--- trunk/app/widgets/widgets-enums.h (original)
+++ trunk/app/widgets/widgets-enums.h Wed Dec 31 00:01:24 2008
@@ -134,6 +134,17 @@
} GimpTabStyle;
+#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,
+} GimpTagEntryMode;
+
+
#define GIMP_TYPE_WINDOW_HINT (gimp_window_hint_get_type ())
GType gimp_window_hint_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]