gimp r26381 - in branches/soc-2008-tagging: . app/core app/widgets
- From: aurisj svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26381 - in branches/soc-2008-tagging: . app/core app/widgets
- Date: Tue, 5 Aug 2008 14:16:22 +0000 (UTC)
Author: aurisj
Date: Tue Aug 5 14:16:21 2008
New Revision: 26381
URL: http://svn.gnome.org/viewvc/gimp?rev=26381&view=rev
Log:
2008-08-05 Aurimas JuÅka <aurisj svn gnome org>
* app/core/gimpfilteredcontainer.[ch]
* app/widgets/gimpcombotagentry.[ch]: make tag popup arrow insensitive
when tag list is empty.
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/widgets/gimpcombotagentry.c
branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
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 Tue Aug 5 14:16:21 2008
@@ -29,11 +29,20 @@
#include "core-types.h"
#include "gimp.h"
+#include "gimpmarshal.h"
#include "gimptag.h"
#include "gimptagged.h"
#include "gimplist.h"
#include "gimpfilteredcontainer.h"
+enum
+{
+ TAG_COUNT_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint gimp_filtered_container_signals[LAST_SIGNAL] = { 0, };
+
static void gimp_filtered_container_dispose (GObject *object);
static gint64 gimp_filtered_container_get_memsize (GimpObject *object,
@@ -64,6 +73,8 @@
GimpFilteredContainer *filtered_container);
static void gimp_filtered_container_tagged_item_removed(GimpTagged *tagged,
GimpFilteredContainer *filtered_container);
+static void gimp_filtered_container_tag_count_changed (GimpFilteredContainer *filtered_container,
+ gint tag_count);
G_DEFINE_TYPE (GimpFilteredContainer, gimp_filtered_container, GIMP_TYPE_LIST)
@@ -80,6 +91,18 @@
g_object_class->dispose = gimp_filtered_container_dispose;
gimp_object_class->get_memsize = gimp_filtered_container_get_memsize;
+
+ klass->tag_count_changed = gimp_filtered_container_tag_count_changed;
+
+ gimp_filtered_container_signals[TAG_COUNT_CHANGED] =
+ g_signal_new ("tag-count-changed",
+ GIMP_TYPE_FILTERED_CONTAINER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GimpFilteredContainerClass, tag_count_changed),
+ NULL, NULL,
+ gimp_marshal_VOID__INT,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
}
static void
@@ -88,6 +111,7 @@
filtered_container->src_container = NULL;
filtered_container->filter = NULL;
filtered_container->tag_ref_counts = NULL;
+ filtered_container->tag_count = 0;
}
static void
@@ -277,7 +301,9 @@
{
gimp_container_freeze (GIMP_CONTAINER (filtered_container));
gimp_container_clear (GIMP_CONTAINER (filtered_container));
+
g_hash_table_remove_all (filtered_container->tag_ref_counts);
+ filtered_container->tag_count = 0;
}
static void
@@ -347,6 +373,13 @@
ref_count++;
g_hash_table_insert (filtered_container->tag_ref_counts,
tag, GINT_TO_POINTER (ref_count));
+ if (ref_count == 1)
+ {
+ filtered_container->tag_count++;
+ g_signal_emit (filtered_container,
+ gimp_filtered_container_signals[TAG_COUNT_CHANGED],
+ 0, filtered_container->tag_count);
+ }
}
static void
@@ -366,7 +399,27 @@
}
else
{
- g_hash_table_remove (filtered_container->tag_ref_counts, tag);
+ if (g_hash_table_remove (filtered_container->tag_ref_counts, tag))
+ {
+ filtered_container->tag_count--;
+ g_signal_emit (filtered_container,
+ gimp_filtered_container_signals[TAG_COUNT_CHANGED],
+ 0, filtered_container->tag_count);
+ }
}
}
+static void
+gimp_filtered_container_tag_count_changed (GimpFilteredContainer *container,
+ gint tag_count)
+{
+}
+
+gint
+gimp_filtered_container_get_tag_count (GimpFilteredContainer *container)
+{
+ g_return_val_if_fail (GIMP_IS_FILTERED_CONTAINER (container), 0);
+
+ return container->tag_count;
+}
+
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 Tue Aug 5 14:16:21 2008
@@ -42,11 +42,15 @@
GimpContainer *src_container;
GList *filter;
GHashTable *tag_ref_counts;
+ gint tag_count;
};
struct _GimpFilteredContainerClass
{
GimpContainerClass parent_class;
+
+ void (* tag_count_changed) (GimpFilteredContainer *container,
+ gint count);
};
@@ -59,5 +63,6 @@
GList * gimp_filtered_container_get_filter (GimpFilteredContainer *container);
+gint gimp_filtered_container_get_tag_count (GimpFilteredContainer *container);
#endif /* __GIMP_FILTERED_CONTAINER_H__ */
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 Tue Aug 5 14:16:21 2008
@@ -53,6 +53,10 @@
gpointer user_data);
static void gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry);
+static void gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
+ gint tag_count,
+ GimpComboTagEntry *combo_entry);
+
G_DEFINE_TYPE (GimpComboTagEntry, gimp_combo_tag_entry, GTK_TYPE_EVENT_BOX);
@@ -104,6 +108,16 @@
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);
}
@@ -114,6 +128,8 @@
combo_entry = g_object_new (GIMP_TYPE_COMBO_TAG_ENTRY, NULL);
combo_entry->tag_entry = GTK_WIDGET (tag_entry);
+ combo_entry->filtered_container = tag_entry->tagged_container;
+ g_object_ref (combo_entry->filtered_container);
gtk_widget_add_events (GTK_WIDGET (combo_entry),
GDK_BUTTON_PRESS_MASK);
@@ -141,6 +157,11 @@
G_CALLBACK (gimp_combo_tag_entry_focus_in_out),
combo_entry);
+ g_signal_connect (combo_entry->filtered_container,
+ "tag-count-changed",
+ G_CALLBACK (gimp_combo_tag_entry_tag_count_changed),
+ combo_entry);
+
return GTK_WIDGET (combo_entry);
}
@@ -155,6 +176,7 @@
GtkAllocation *allocation;
GdkRectangle client_area;
GdkRectangle shadow_area;
+ gint tag_count;
tag_entry = combo_entry->tag_entry;
style = gtk_widget_get_style (tag_entry);
@@ -197,7 +219,9 @@
client_area.width, client_area.width);
}
- gtk_paint_arrow (style, widget->window, GTK_WIDGET_STATE (tag_entry),
+ tag_count = gimp_filtered_container_get_tag_count (combo_entry->filtered_container);
+
+ gtk_paint_arrow (style, widget->window, tag_count > 0 ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
GTK_SHADOW_NONE, NULL, NULL, NULL,
GTK_ARROW_DOWN, TRUE,
shadow_area.x + shadow_area.width - 14,
@@ -340,6 +364,20 @@
static void
gimp_combo_tag_entry_popup_list (GimpComboTagEntry *combo_entry)
{
- combo_entry->popup = gimp_tag_popup_new (combo_entry);
+ gint tag_count;
+
+ tag_count = gimp_filtered_container_get_tag_count (combo_entry->filtered_container);
+ if (tag_count > 0)
+ {
+ combo_entry->popup = gimp_tag_popup_new (combo_entry);
+ }
+}
+
+static void
+gimp_combo_tag_entry_tag_count_changed (GimpFilteredContainer *container,
+ gint tag_count,
+ GimpComboTagEntry *combo_entry)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (combo_entry));
}
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 Tue Aug 5 14:16:21 2008
@@ -40,6 +40,7 @@
GtkWidget *tag_entry;
GtkWidget *alignment;
GtkWidget *popup;
+ GimpFilteredContainer *filtered_container;
gint focus_width;
PangoAttrList *normal_item_attr;
PangoAttrList *selected_item_attr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]