gimp r26414 - in branches/soc-2008-tagging: . app/core app/widgets
- From: aurisj svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26414 - in branches/soc-2008-tagging: . app/core app/widgets
- Date: Thu, 7 Aug 2008 11:16:25 +0000 (UTC)
Author: aurisj
Date: Thu Aug 7 11:16:25 2008
New Revision: 26414
URL: http://svn.gnome.org/viewvc/gimp?rev=26414&view=rev
Log:
2008-08-07 Aurimas JuÅka <aurisj svn gnome org>
* app/core/gimpfilteredcontainer.[ch]
* app/core/gimptag.[ch]
* app/core/gimptagcache.[ch]
* app/widgets/gimpcombotagentry.[ch]
* app/widgets/gimptagentry.[ch]
* app/widgets/gimptagpopup.c: code cleanup and documentation.
Modified:
branches/soc-2008-tagging/ChangeLog
branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c
branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h
branches/soc-2008-tagging/app/core/gimptag.c
branches/soc-2008-tagging/app/core/gimptag.h
branches/soc-2008-tagging/app/core/gimptagcache.c
branches/soc-2008-tagging/app/core/gimptagcache.h
branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c
branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
branches/soc-2008-tagging/app/widgets/gimptagentry.c
branches/soc-2008-tagging/app/widgets/gimptagentry.h
branches/soc-2008-tagging/app/widgets/gimptagpopup.c
Modified: branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c (original)
+++ branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c Thu Aug 7 11:16:25 2008
@@ -2,7 +2,7 @@
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* gimpfilteredcontainer.c
- * Copyright (C) Aurimas JuÅka <aurisj svn gnome org>
+ * Copyright (C) 2008 Aurimas JuÅka <aurisj svn gnome org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -149,12 +149,12 @@
* gimp_filtered_container_new:
* @src_container: container to be filtered.
*
- * Creates a new #GimpFilteredContainer object. Since #GimpFilteredContainer is a #GimpContainer
- * implementation, it holds GimpObjects. It filters @src_container for objects containing
- * all of the filtering tags. Syncronization with @src_container data is performed
+ * Creates a new #GimpFilteredContainer object. Since #GimpFilteredContainer is a
+ * #GimpContainer implementation, it holds GimpObjects. It filters @src_container for objects
+ * containing all of the filtering tags. Syncronization with @src_container data is performed
* automatically.
*
- * Return value: a new #GimpFilteredContainer object
+ * Return value: a new #GimpFilteredContainer object.
**/
GimpContainer *
gimp_filtered_container_new (GimpContainer *src_container)
@@ -162,6 +162,8 @@
GimpFilteredContainer *filtered_container;
GType children_type;
+ g_return_val_if_fail (GIMP_IS_CONTAINER (src_container), NULL);
+
children_type = gimp_container_children_type (src_container);
filtered_container = g_object_new (GIMP_TYPE_FILTERED_CONTAINER,
@@ -190,10 +192,20 @@
return GIMP_CONTAINER (filtered_container);
}
+/**
+ * gimp_filtered_container_set_filter:
+ * @filtered_container: a #GimpFilteredContainer object.
+ * @tags: list of #GimpTag objects.
+ *
+ * Sets list of tags to be used for filtering. Only objects which have all of
+ * the tags assigned match filtering criteria.
+ **/
void
gimp_filtered_container_set_filter (GimpFilteredContainer *filtered_container,
GList *tags)
{
+ g_return_if_fail (GIMP_IS_FILTERED_CONTAINER (filtered_container));
+
filtered_container->filter = tags;
gimp_container_freeze (GIMP_CONTAINER (filtered_container));
@@ -202,9 +214,20 @@
gimp_container_thaw (GIMP_CONTAINER (filtered_container));
}
-GList *
+/**
+ * gimp_filtered_container_get_filter:
+ * @filtered_container: a #GimpFilteredContainer object.
+ *
+ * Returns current tag filter. Tag filter is a list of GimpTag objects, which
+ * must be contained by each object matching filter criteria.
+ *
+ * Return value: a list of GimpTag objects used as filter. This value should
+ * not be modified or freed.
+ **/
+const GList *
gimp_filtered_container_get_filter (GimpFilteredContainer *filtered_container)
{
+ g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (filtered_container), NULL);
return filtered_container->filter;
}
@@ -415,6 +438,17 @@
{
}
+/**
+ * gimp_filtered_container_get_tag_count:
+ * @container: a #GimpFilteredContainer object.
+ *
+ * Get number of distinct tags that are currently assigned to all objects
+ * in the container. The count is independent of currently used filter, it
+ * is provided for all available objects (ie. empty filter).
+ *
+ * Return value: number of distinct tags assigned to all objects in the
+ * container.
+ **/
gint
gimp_filtered_container_get_tag_count (GimpFilteredContainer *container)
{
Modified: branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h (original)
+++ branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h Thu Aug 7 11:16:25 2008
@@ -61,7 +61,7 @@
void gimp_filtered_container_set_filter (GimpFilteredContainer *container,
GList *tags);
-GList * gimp_filtered_container_get_filter (GimpFilteredContainer *container);
+const GList * gimp_filtered_container_get_filter (GimpFilteredContainer *container);
gint gimp_filtered_container_get_tag_count (GimpFilteredContainer *container);
Modified: branches/soc-2008-tagging/app/core/gimptag.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptag.c (original)
+++ branches/soc-2008-tagging/app/core/gimptag.c Thu Aug 7 11:16:25 2008
@@ -44,6 +44,16 @@
tag->collate_key = 0;
}
+/**
+ * gimp_tag_new:
+ * @tag_string: a tag name.
+ *
+ * Given tag name does not need to be valid. If it is not valid, an attempt
+ * will be made to fix it.
+ *
+ * Return value: a new #GimpTag object, or NULL if tag string is invalid and
+ * cannot be fixed.
+ **/
GimpTag *
gimp_tag_new (const char *tag_string)
{
@@ -74,6 +84,18 @@
return tag;
}
+/**
+ * gimp_tag_try_new:
+ * @tag_string: a tag name.
+ *
+ * Similar to gimp_tag_new(), but returns NULL if tag is surely not equal
+ * to any of currently created tags. It is useful for tag querying to avoid
+ * unneeded comparisons. If tag is created, however, it does not mean that
+ * it would necessarily match with some other tag.
+ *
+ * Return value: new #GimpTag object, or NULL if tag will not match with any
+ * other #GimpTag.
+ **/
GimpTag *
gimp_tag_try_new (const char *tag_string)
{
@@ -90,7 +112,7 @@
return NULL;
}
- tag_quark = g_quark_from_string (tag_name);
+ tag_quark = g_quark_try_string (tag_name);
if (! tag_quark)
{
g_free (tag_name);
@@ -99,7 +121,7 @@
case_folded = g_utf8_casefold (tag_name, -1);
collate_key = g_utf8_collate_key (case_folded, -1);
- collate_key_quark = g_quark_from_string (collate_key);
+ collate_key_quark = g_quark_try_string (collate_key);
g_free (collate_key);
g_free (case_folded);
g_free (tag_name);
@@ -115,6 +137,12 @@
return tag;
}
+/**
+ * gimp_tag_get_name:
+ * @tag: a gimp tag.
+ *
+ * Return value: name of tag.
+ **/
const gchar *
gimp_tag_get_name (GimpTag *tag)
{
@@ -123,6 +151,15 @@
return g_quark_to_string (tag->tag);
}
+/**
+ * gimp_tag_get_hash:
+ * @tag: a gimp tag.
+ *
+ * Hashing function which is useful, for example, to store #GimpTag in
+ * a #GHashTable.
+ *
+ * Return value: hash value for tag.
+ **/
guint
gimp_tag_get_hash (GimpTag *tag)
{
@@ -131,6 +168,15 @@
return tag->collate_key;
}
+/**
+ * gimp_tag_equals:
+ * @tag: a gimp tag.
+ * @other: an other gimp tag to compare with.
+ *
+ * Compares tags for equality according to tag comparison rules.
+ *
+ * Return value: TRUE if tags are equal, FALSE otherwise.
+ **/
gboolean
gimp_tag_equals (GimpTag *tag,
GimpTag *other)
@@ -141,6 +187,16 @@
return tag->tag == other->tag;
}
+/**
+ * gimp_tag_compare_func:
+ * @p1: pointer to left-hand #GimpTag object.
+ * @p2: pointer to right-hand #GimpTag object.
+ *
+ * Compares tags according to tag comparison rules. Useful for sorting
+ * functions.
+ *
+ * Return value: meaning of return value is the same as in strcmp().
+ **/
int
gimp_tag_compare_func (const void *p1,
const void *p2)
@@ -152,6 +208,17 @@
g_quark_to_string (t2->collate_key));
}
+/**
+ * gimp_tag_compare_with_string:
+ * @tag: a #GimpTag object.
+ * @tag_string: pointer to right-hand #GimpTag object.
+ *
+ * Compares tag and a string according to tag comparison rules. Similar to
+ * gimp_tag_compare_func(), but can be used without creating temporary tag
+ * object.
+ *
+ * Return value: meaning of return value is the same as in strcmp().
+ **/
gint
gimp_tag_compare_with_string (GimpTag *tag,
const char *tag_string)
@@ -319,6 +386,16 @@
}
}
+/**
+ * gimp_tag_string_make_valid:
+ * @string: a text string.
+ *
+ * Tries to create a valid tag string from given @string.
+ *
+ * Return value: a newly allocated tag string in case given @string was valid
+ * or could be fixed, otherwise NULL. Allocated value should be freed using
+ * g_free().
+ **/
gchar *
gimp_tag_string_make_valid (const gchar *string)
{
Modified: branches/soc-2008-tagging/app/core/gimptag.h
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptag.h (original)
+++ branches/soc-2008-tagging/app/core/gimptag.h Thu Aug 7 11:16:25 2008
@@ -66,6 +66,7 @@
gchar * gimp_tag_string_make_valid (const gchar *tag_string);
+/* one day they should find a better home */
gboolean g_unichar_is_sentence_terminal (gunichar c);
gboolean g_unichar_is_terminal_punctuation (gunichar c);
Modified: branches/soc-2008-tagging/app/core/gimptagcache.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptagcache.c (original)
+++ branches/soc-2008-tagging/app/core/gimptagcache.c Thu Aug 7 11:16:25 2008
@@ -54,15 +54,15 @@
};
-static void gimp_tag_cache_finalize (GObject *object);
+static void gimp_tag_cache_finalize (GObject *object);
-static gint64 gimp_tag_cache_get_memsize (GimpObject *object,
- gint64 *gui_size);
-static void gimp_tag_cache_object_initialize (GimpTagged *tagged,
- GimpTagCache *cache);
-static void gimp_tag_cache_object_add (GimpContainer *container,
- GimpTagged *tagged,
- GimpTagCache *cache);
+static gint64 gimp_tag_cache_get_memsize (GimpObject *object,
+ gint64 *gui_size);
+static void gimp_tag_cache_object_initialize (GimpTagged *tagged,
+ GimpTagCache *cache);
+static void gimp_tag_cache_object_add (GimpContainer *container,
+ GimpTagged *tagged,
+ GimpTagCache *cache);
static void gimp_tag_cache_load_start_element (GMarkupParseContext *context,
const gchar *element_name,
@@ -70,24 +70,24 @@
const gchar **attribute_values,
gpointer user_data,
GError **error);
-static void gimp_tag_cache_load_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error);
-static void gimp_tag_cache_load_text (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error);
-static void gimp_tag_cache_load_error (GMarkupParseContext *context,
- GError *error,
- gpointer user_data);
-
-static const gchar* attribute_name_to_value (const gchar **attribute_names,
- const gchar **attribute_values,
- const gchar *name);
+static void gimp_tag_cache_load_end_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error);
+static void gimp_tag_cache_load_text (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
+static void gimp_tag_cache_load_error (GMarkupParseContext *context,
+ GError *error,
+ gpointer user_data);
+
+static const gchar* attribute_name_to_value (const gchar **attribute_names,
+ const gchar **attribute_values,
+ const gchar *name);
-static GQuark gimp_tag_cache_get_error_domain (void);
+static GQuark gimp_tag_cache_get_error_domain (void);
G_DEFINE_TYPE (GimpTagCache, gimp_tag_cache, GIMP_TYPE_OBJECT)
@@ -157,6 +157,12 @@
gui_size);
}
+/**
+ * gimp_tag_cache_new:
+ * @gimp: a Gimp object.
+ *
+ * Return value: creates new GimpTagCache object.
+ **/
GimpTagCache *
gimp_tag_cache_new (Gimp *gimp)
{
@@ -172,10 +178,24 @@
return cache;
}
+/**
+ * gimp_tag_cache_add_container:
+ * @cache: a GimpTagCache object.
+ * @container: container containing GimpTagged objects.
+ *
+ * Adds container of GimpTagged objects to tag cache. Objects in container
+ * are assigned tags when cache is loaded from file. When tag cache is saved
+ * to file, tags are collected from objects in container. Therefore, before
+ * loading and saving tag cache, containers added to tag cache must be already
+ * initialized and not freed.
+ **/
void
gimp_tag_cache_add_container (GimpTagCache *cache,
GimpContainer *container)
{
+ g_return_if_fail (GIMP_IS_TAG_CACHE (cache));
+ g_return_if_fail (GIMP_IS_CONTAINER (container));
+
cache->containers = g_list_append (cache->containers, container);
gimp_container_foreach (container, (GFunc) gimp_tag_cache_object_initialize, cache);
@@ -214,9 +234,6 @@
tag_iterator = rec->tags;
while (tag_iterator)
{
- printf ("assigning cached tag: %s to %s\n",
- gimp_tag_get_name (GIMP_TAG (tag_iterator->data)),
- g_quark_to_string (identifier_quark));
gimp_tagged_add_tag (tagged, GIMP_TAG (tag_iterator->data));
tag_iterator = g_list_next (tag_iterator);
@@ -248,9 +265,6 @@
tag_iterator = rec->tags;
while (tag_iterator)
{
- printf ("assigning cached tag: %s to %s\n",
- gimp_tag_get_name (GIMP_TAG (tag_iterator->data)),
- g_quark_to_string (identifier_quark));
gimp_tagged_add_tag (tagged, GIMP_TAG (tag_iterator->data));
tag_iterator = g_list_next (tag_iterator);
@@ -292,6 +306,12 @@
g_free (identifier);
}
+/**
+ * gimp_tag_cache_save:
+ * @cache: a GimpTagCache object.
+ *
+ * Saves tag cache to cache file.
+ **/
void
gimp_tag_cache_save (GimpTagCache *cache)
{
@@ -302,7 +322,7 @@
GError *error;
gint i;
- printf ("saving cache to disk ...\n");
+ g_return_if_fail (GIMP_IS_TAG_CACHE (cache));
saved_records = NULL;
for (i = 0; i < cache->records->len; i++)
@@ -384,6 +404,12 @@
g_list_free (saved_records);
}
+/**
+ * gimp_tag_cache_load:
+ * @cache: a GimpTagCache object.
+ *
+ * Loads tag cache from file.
+ **/
void
gimp_tag_cache_load (GimpTagCache *cache)
{
@@ -395,11 +421,12 @@
GMarkupParseContext *parse_context;
ParseData parse_data;
+ g_return_if_fail (GIMP_IS_TAG_CACHE (cache));
+
/* clear any previous records */
cache->records = g_array_set_size (cache->records, 0);
filename = g_build_filename (gimp_directory (), GIMP_TAG_CACHE_FILE, NULL);
- printf ("reading tag cache to %s\n", filename);
error = NULL;
if (! g_file_get_contents (filename, &buffer, &length, &error))
{
Modified: branches/soc-2008-tagging/app/core/gimptagcache.h
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptagcache.h (original)
+++ branches/soc-2008-tagging/app/core/gimptagcache.h Thu Aug 7 11:16:25 2008
@@ -57,11 +57,11 @@
struct _GimpTagCacheClass
{
- GimpObjectClass parent_class;
+ GimpObjectClass parent_class;
};
-GType gimp_tag_cache_get_type (void) G_GNUC_CONST;
+GType gimp_tag_cache_get_type (void) G_GNUC_CONST;
GimpTagCache * gimp_tag_cache_new (Gimp *gimp);
Modified: branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c Thu Aug 7 11:16:25 2008
@@ -38,20 +38,20 @@
#include "gimptagpopup.h"
#include "gimpcombotagentry.h"
-static void gimp_combo_tag_entry_dispose (GObject *object);
-static gboolean gimp_combo_tag_entry_expose_event (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer user_data);
-static gboolean gimp_combo_tag_entry_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data);
+static void gimp_combo_tag_entry_dispose (GObject *object);
+static gboolean gimp_combo_tag_entry_expose_event (GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer user_data);
+static gboolean gimp_combo_tag_entry_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
static void gimp_combo_tag_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style,
gpointer user_data);
-static void gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry);
-static void gimp_combo_tag_entry_popup_destroy (GtkObject *object,
- GimpComboTagEntry *combo_entry);
+static void gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry);
+static void gimp_combo_tag_entry_popup_destroy (GtkObject *object,
+ GimpComboTagEntry *combo_entry);
static void gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
gint tag_count,
@@ -122,6 +122,16 @@
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.
+ *
+ * Creates a new #GimpComboTagEntry widget which extends #GimpTagEntry by
+ * adding ability to pick tags using popup window (similar to combo box).
+ *
+ * Return value: a new #GimpComboTagEntry widget.
+ **/
GtkWidget *
gimp_combo_tag_entry_new (GimpFilteredContainer *filtered_container,
GimpTagEntryMode mode)
@@ -129,6 +139,8 @@
GimpComboTagEntry *combo_entry;
GtkBorder border;
+ g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (filtered_container), NULL);
+
combo_entry = g_object_new (GIMP_TYPE_COMBO_TAG_ENTRY,
"filtered-container", filtered_container,
"tag-entry-mode", mode,
Modified: branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h (original)
+++ branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h Thu Aug 7 11:16:25 2008
@@ -26,10 +26,10 @@
#define GIMP_TYPE_COMBO_TAG_ENTRY (gimp_combo_tag_entry_get_type ())
#define GIMP_COMBO_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COMBO_TAG_ENTRY, GimpComboTagEntry))
-#define GIMP_COMBO_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TAG_ENTRY, GimpComboTagEntryClass))
-#define GIMP_IS_COMBO_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTAINER_ENTRY))
-#define GIMP_IS_COMBO_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_ENTRY))
-#define GIMP_COMBO_TAG_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TAG_ENTRY, GimpComboTagEntryClass))
+#define GIMP_COMBO_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COMBO_TAG_ENTRY, GimpComboTagEntryClass))
+#define GIMP_IS_COMBO_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COMBO_TAG_ENTRY))
+#define GIMP_IS_COMBO_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COMBO_TAG_ENTRY))
+#define GIMP_COMBO_TAG_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COMBO_TAG_ENTRY, GimpComboTagEntryClass))
typedef struct _GimpComboTagEntryClass GimpComboTagEntryClass;
Modified: branches/soc-2008-tagging/app/widgets/gimptagentry.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagentry.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.c Thu Aug 7 11:16:25 2008
@@ -310,14 +310,25 @@
}
}
+/**
+ * gimp_tag_entry_new:
+ * @filtered_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
+ * tags selected. When operating in assignment mode, tags are assigned to
+ * objects selected and visible in @filtered_container.
+ *
+ * Return value: a new GimpTagEntry widget.
+ **/
GtkWidget *
gimp_tag_entry_new (GimpFilteredContainer *filtered_container,
GimpTagEntryMode mode)
{
GimpTagEntry *entry;
- g_return_val_if_fail (filtered_container == NULL
- || GIMP_IS_FILTERED_CONTAINER (filtered_container),
+ g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (filtered_container),
NULL);
entry = g_object_new (GIMP_TYPE_TAG_ENTRY,
@@ -367,10 +378,22 @@
}
}
+/**
+ * gimp_tag_entry_set_tag_string:
+ * @tag_entry: a #GimpTagEntry object.
+ * @tag_string: string of tags, separated by any terminal punctuation
+ * character.
+ *
+ * Sets tags from @tag_string to @tag_entry. Given tags do not need to
+ * be valid as they can be fixed or dropped automatically. Depending on
+ * selected #GimpTagEntryMode, appropriate action is peformed.
+ **/
void
gimp_tag_entry_set_tag_string (GimpTagEntry *tag_entry,
const gchar *tag_string)
{
+ g_return_if_fail (GIMP_IS_TAG_ENTRY (tag_entry));
+
tag_entry->internal_change = TRUE;
gtk_entry_set_text (GTK_ENTRY (tag_entry), tag_string);
gtk_editable_set_position (GTK_EDITABLE (tag_entry), -1);
@@ -597,6 +620,16 @@
}
}
+/**
+ * gimp_tag_entry_parse_tags:
+ * @entry: a #GimpTagEntry widget.
+ *
+ * Parses currently entered tags from @entry. Tags do not need to be valid as
+ * they are fixed when necessary. Only valid tags are returned.
+ *
+ * Return value: a newly allocated NULL terminated list of strings. It should
+ * be freed using g_strfreev().
+ **/
gchar **
gimp_tag_entry_parse_tags (GimpTagEntry *entry)
{
@@ -609,6 +642,8 @@
GList *iterator;
gunichar c;
+ g_return_val_if_fail (GIMP_IS_TAG_ENTRY (entry), NULL);
+
parsed_tag = g_string_new ("");
cursor = gtk_entry_get_text (GTK_ENTRY (entry));
do
@@ -719,12 +754,23 @@
gtk_editable_set_position (GTK_EDITABLE (entry), position);
}
+/**
+ * gimp_tag_entry_set_selected_items:
+ * @entry: a #GimpTagEntry widget.
+ * @items: a list of #GimpTagged objects.
+ *
+ * Set list of currently selected #GimpTagged objects. Only selected and
+ * visible (not filtered out) #GimpTagged objects are assigned tags when
+ * operating in tag assignment mode.
+ **/
void
gimp_tag_entry_set_selected_items (GimpTagEntry *entry,
GList *items)
{
GList *iterator;
+ g_return_if_fail (GIMP_IS_TAG_ENTRY (entry));
+
if (entry->selected_items)
{
g_list_free (entry->selected_items);
@@ -1458,7 +1504,7 @@
const gchar *
gimp_tag_entry_get_separator (void)
{
- /* IMPORTANT: use only one of UNICODE terminal punctuation chars followed by space.
+ /* IMPORTANT: use only one of Unicode terminal punctuation chars followed by space.
* http://unicode.org/review/pr-23.html */
return _(", ");
}
Modified: branches/soc-2008-tagging/app/widgets/gimptagentry.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagentry.h (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.h Thu Aug 7 11:16:25 2008
@@ -26,8 +26,8 @@
#define GIMP_TYPE_TAG_ENTRY (gimp_tag_entry_get_type ())
#define GIMP_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TAG_ENTRY, GimpTagEntry))
#define GIMP_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TAG_ENTRY, GimpTagEntryClass))
-#define GIMP_IS_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTAINER_ENTRY))
-#define GIMP_IS_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_ENTRY))
+#define GIMP_IS_TAG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TAG_ENTRY))
+#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 ())
@@ -61,17 +61,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 *tagged_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 *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);
-const gchar * gimp_tag_entry_get_separator (void);
+const gchar * gimp_tag_entry_get_separator (void);
#endif /* __GIMP_TAG_ENTRY_H__ */
Modified: branches/soc-2008-tagging/app/widgets/gimptagpopup.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagpopup.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagpopup.c Thu Aug 7 11:16:25 2008
@@ -41,11 +41,11 @@
#include "gimp-intl.h"
-#define MENU_SCROLL_STEP1 8
-#define MENU_SCROLL_STEP2 15
-#define MENU_SCROLL_FAST_ZONE 8
-#define MENU_SCROLL_TIMEOUT1 50
-#define MENU_SCROLL_TIMEOUT2 20
+#define MENU_SCROLL_STEP1 8
+#define MENU_SCROLL_STEP2 15
+#define MENU_SCROLL_FAST_ZONE 8
+#define MENU_SCROLL_TIMEOUT1 50
+#define MENU_SCROLL_TIMEOUT2 20
#define GIMP_TAG_POPUP_MARGIN 5
@@ -149,6 +149,16 @@
G_OBJECT_CLASS (parent_class)->dispose (object);
}
+/**
+ * gimp_tag_popup_new:
+ * @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.
+ *
+ * Return value: a newly created #GimpTagPopup widget.
+ **/
GtkWidget *
gimp_tag_popup_new (GimpComboTagEntry *combo_entry)
{
@@ -175,6 +185,8 @@
GdkRectangle popup_rects[2]; /* variants of popup placement */
GdkRectangle popup_rect; /* best popup rect in screen coordinates */
+ g_return_val_if_fail (GIMP_IS_COMBO_TAG_ENTRY (combo_entry), NULL);
+
popup = g_object_new (GIMP_TYPE_TAG_POPUP,
"type", GTK_WINDOW_POPUP,
NULL);
@@ -1051,17 +1063,17 @@
static void
gimp_tag_popup_do_timeout_scroll (GimpTagPopup *tag_popup,
- gboolean touchscreen_mode)
+ gboolean touchscreen_mode)
{
gimp_tag_popup_scroll_by (tag_popup, tag_popup->scroll_step);
}
static void
-gimp_tag_popup_handle_scrolling (GimpTagPopup *tag_popup,
- gint x,
- gint y,
- gboolean enter,
- gboolean motion)
+gimp_tag_popup_handle_scrolling (GimpTagPopup *tag_popup,
+ gint x,
+ gint y,
+ gboolean enter,
+ gboolean motion)
{
GdkRectangle rect;
gboolean in_arrow;
@@ -1270,8 +1282,8 @@
}
static gboolean
-gimp_tag_popup_button_scroll (GimpTagPopup *tag_popup,
- GdkEventButton *event)
+gimp_tag_popup_button_scroll (GimpTagPopup *tag_popup,
+ GdkEventButton *event)
{
if (tag_popup->upper_arrow_prelight
|| tag_popup->lower_arrow_prelight)
@@ -1295,11 +1307,11 @@
}
static void
-get_arrows_visible_area (GimpTagPopup *tag_popup,
- GdkRectangle *border,
- GdkRectangle *upper,
- GdkRectangle *lower,
- gint *arrow_space)
+get_arrows_visible_area (GimpTagPopup *tag_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;
@@ -1328,9 +1340,9 @@
}
static void
-get_arrows_sensitive_area (GimpTagPopup *tag_popup,
- GdkRectangle *upper,
- GdkRectangle *lower)
+get_arrows_sensitive_area (GimpTagPopup *tag_popup,
+ GdkRectangle *upper,
+ GdkRectangle *lower)
{
GdkRectangle tmp_border;
GdkRectangle tmp_upper;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]