gimp r26344 - in branches/soc-2008-tagging: . app/widgets



Author: aurisj
Date: Wed Jul 30 21:24:39 2008
New Revision: 26344
URL: http://svn.gnome.org/viewvc/gimp?rev=26344&view=rev

Log:
2008-07-31  Aurimas JuÅka  <aurisj svn gnome org>

	* app/widgets/gimpcombotagentry.[ch]
	* app/widgets/gimptagpopup.[ch]: when selecting tags in the popup
	list, grayout tags which if selected would result in empty resource
	list.



Modified:
   branches/soc-2008-tagging/ChangeLog
   branches/soc-2008-tagging/app/widgets/gimpcombotagentry.c
   branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
   branches/soc-2008-tagging/app/widgets/gimptagpopup.c
   branches/soc-2008-tagging/app/widgets/gimptagpopup.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	Wed Jul 30 21:24:39 2008
@@ -76,6 +76,7 @@
   combo_entry->interior_focus       = FALSE;
   combo_entry->normal_item_attr     = NULL;
   combo_entry->selected_item_attr   = NULL;
+  combo_entry->insensitive_item_attr = NULL;
 
   g_signal_connect (combo_entry, "event",
                     G_CALLBACK (gimp_combo_tag_entry_event),
@@ -97,6 +98,11 @@
       pango_attr_list_unref (combo_entry->selected_item_attr);
       combo_entry->selected_item_attr = NULL;
     }
+  if (combo_entry->insensitive_item_attr)
+    {
+      pango_attr_list_unref (combo_entry->insensitive_item_attr);
+      combo_entry->insensitive_item_attr = NULL;
+    }
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -249,6 +255,7 @@
   pango_attr_list_insert (combo_entry->normal_item_attr, attribute);
   attribute = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
   pango_attr_list_insert (combo_entry->normal_item_attr, attribute);
+
   if (combo_entry->selected_item_attr)
     {
       pango_attr_list_unref (combo_entry->selected_item_attr);
@@ -261,6 +268,19 @@
   attribute = pango_attr_background_new (color.red, color.green, color.blue);
   pango_attr_list_insert (combo_entry->selected_item_attr, attribute);
 
+  if (combo_entry->insensitive_item_attr)
+    {
+      pango_attr_list_unref (combo_entry->insensitive_item_attr);
+    }
+  combo_entry->insensitive_item_attr = pango_attr_list_copy (combo_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);
+  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);
+
+
   combo_entry->selected_item_color = style->base[GTK_STATE_SELECTED];
 }
 

Modified: branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h	(original)
+++ branches/soc-2008-tagging/app/widgets/gimpcombotagentry.h	Wed Jul 30 21:24:39 2008
@@ -43,6 +43,7 @@
   gint                          focus_width;
   PangoAttrList                *normal_item_attr;
   PangoAttrList                *selected_item_attr;
+  PangoAttrList                *insensitive_item_attr;
   GdkColor                      selected_item_color;
   gboolean                      interior_focus;
 };

Modified: branches/soc-2008-tagging/app/widgets/gimptagpopup.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagpopup.c	(original)
+++ branches/soc-2008-tagging/app/widgets/gimptagpopup.c	Wed Jul 30 21:24:39 2008
@@ -21,6 +21,7 @@
 
 #include "config.h"
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <gtk/gtk.h>
@@ -62,6 +63,8 @@
                                                         GimpTagPopup       *tag_popup);
 static void     gimp_tag_popup_toggle_tag              (GimpTagPopup       *tag_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,
                                                         gint                width);
 static void     gimp_tag_popup_do_timeout_scroll       (GimpTagPopup       *tag_popup,
@@ -213,13 +216,13 @@
   for (i = 0; i < popup->tag_count; i++)
     {
       popup->tag_data[i].tag = GIMP_TAG (tag_iterator->data);
-      popup->tag_data[i].selected = FALSE;
+      popup->tag_data[i].state = GTK_STATE_NORMAL;
       list_tag = gimp_tag_get_name (popup->tag_data[i].tag);
       for (j = 0; j < current_count; j++)
         {
           if (! strcmp (current_tags[j], list_tag))
             {
-              popup->tag_data[i].selected = TRUE;
+              popup->tag_data[i].state = GTK_STATE_SELECTED;
               break;
             }
         }
@@ -228,6 +231,19 @@
   g_list_free (tag_list);
   g_strfreev (current_tags);
 
+  if (GIMP_TAG_ENTRY (combo_entry->tag_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
+    {
+      for (i = 0; i < popup->tag_count; i++)
+        {
+          if (popup->tag_data[i].state != GTK_STATE_SELECTED)
+            {
+              popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
+            }
+        }
+      gimp_container_foreach (GIMP_CONTAINER (GIMP_TAG_ENTRY (combo_entry->tag_entry)->tagged_container),
+                              (GFunc) gimp_tag_popup_check_can_toggle, popup);
+    }
+
   width = GTK_WIDGET (combo_entry)->allocation.width - frame->style->xthickness * 2;
   height = gimp_tag_popup_layout_tags (popup, width);
   gdk_window_get_origin (GTK_WIDGET (combo_entry)->window, &x, &y);
@@ -277,7 +293,6 @@
       popup->scroll_step   = 0;
     }
 
-
   drawing_area->requisition.width = width;
   drawing_area->requisition.height = popup_height;
 
@@ -543,18 +558,24 @@
     {
       pango_layout_set_text (tag_popup->layout,
                              gimp_tag_get_name (tag_popup->tag_data[i].tag), -1);
-      if (tag_popup->tag_data[i].selected)
+      if (tag_popup->tag_data[i].state == GTK_STATE_SELECTED)
         {
           pango_layout_set_attributes (tag_popup->layout,
                                        tag_popup->combo_entry->selected_item_attr);
         }
+      else if (tag_popup->tag_data[i].state == GTK_STATE_INSENSITIVE)
+        {
+          pango_layout_set_attributes (tag_popup->layout,
+                                       tag_popup->combo_entry->insensitive_item_attr);
+        }
+
       else
         {
           pango_layout_set_attributes (tag_popup->layout,
                                        tag_popup->combo_entry->normal_item_attr);
         }
 
-      if (tag_popup->tag_data[i].selected)
+      if (tag_popup->tag_data[i].state == GTK_STATE_SELECTED)
         {
           gdk_draw_rectangle (widget->window, gc, FALSE,
                               tag_popup->tag_data[i].bounds.x,
@@ -569,7 +590,7 @@
       if (&tag_popup->tag_data[i] == tag_popup->prelight)
         {
           gtk_paint_focus (widget->style, widget->window,
-                           tag_popup->tag_data[i].selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
+                           tag_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,
@@ -706,7 +727,18 @@
   gint                  i;
   gboolean              tag_toggled_off = FALSE;
 
-  tag_data->selected = ! tag_data->selected;
+  if (tag_data->state == GTK_STATE_NORMAL)
+    {
+      tag_data->state = GTK_STATE_SELECTED;
+    }
+  else if (tag_data->state == GTK_STATE_SELECTED)
+    {
+      tag_data->state = GTK_STATE_NORMAL;
+    }
+  else
+    {
+      return;
+    }
 
   tag = gimp_tag_get_name (tag_data->tag);
   current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry));
@@ -744,6 +776,53 @@
 
   g_string_free (tag_str, TRUE);
   g_strfreev (current_tags);
+
+  if (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY)
+    {
+      for (i = 0; i < tag_popup->tag_count; i++)
+        {
+          if (tag_popup->tag_data[i].state != GTK_STATE_SELECTED)
+            {
+              tag_popup->tag_data[i].state = GTK_STATE_INSENSITIVE;
+            }
+        }
+      gimp_container_foreach (GIMP_CONTAINER (GIMP_TAG_ENTRY (tag_popup->combo_entry->tag_entry)->tagged_container),
+                              (GFunc) gimp_tag_popup_check_can_toggle, tag_popup);
+    }
+}
+
+static int
+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)
+{
+  GList        *tag_iterator;
+  PopupTagData  search_key;
+  PopupTagData *search_result;
+
+  tag_iterator = gimp_tagged_get_tags (tagged);
+  while (tag_iterator)
+    {
+      search_key.tag = GIMP_TAG (tag_iterator->data);
+      search_result =
+          (PopupTagData *) bsearch (&search_key, tag_popup->tag_data, tag_popup->tag_count,
+                                    sizeof (PopupTagData), gimp_tag_popup_data_compare);
+      if (search_result)
+        {
+          if (search_result->state == GTK_STATE_INSENSITIVE)
+            {
+              search_result->state = GTK_STATE_NORMAL;
+            }
+        }
+
+      tag_iterator = g_list_next (tag_iterator);
+    }
 }
 
 static gboolean

Modified: branches/soc-2008-tagging/app/widgets/gimptagpopup.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagpopup.h	(original)
+++ branches/soc-2008-tagging/app/widgets/gimptagpopup.h	Wed Jul 30 21:24:39 2008
@@ -36,7 +36,7 @@
 {
   GimpTag              *tag;
   GdkRectangle          bounds;
-  gboolean              selected;
+  GtkStateType          state;
 } PopupTagData;
 
 struct _GimpTagPopup



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]