]> Pileus Git - ~andy/gtk/commitdiff
Add properties and getters for icon tooltips.
authorMatthias Clasen <matthiasc@src.gnome.org>
Sun, 18 Jan 2009 20:22:10 +0000 (20:22 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 18 Jan 2009 20:22:10 +0000 (20:22 +0000)
       * gtk/gtk.symbols:
        * gtk/gtkentry.[hc]: Add properties and getters for icon tooltips.

svn path=/trunk/; revision=22139

ChangeLog
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtk.symbols
gtk/gtkentry.c
gtk/gtkentry.h

index 7fb468efe735ebc1b4da8c419d60e5bfb9d65ee2..725f9da283cf007a0d64a35d19117a0d8f2ca98d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-18  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtk.symbols:
+       * gtk/gtkentry.[hc]: Add properties and getters for icon tooltips.
+
 2009-01-18  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 563280 – stock items & translation context
index a9e50264d03f4da1e8b1449a1c2473556417e22e..41500314edc5bfb2bed83f41eec1b5c3b07e017e 100644 (file)
@@ -1,3 +1,7 @@
+2009-01-18  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtk-sections.txt: Add new api
+
 2009-01-13  Christian Dywan  <christian@imendio.com>
 
        Bug 567569 – Typo in GtkFileChooser example in GTK+ documentation
index 9cf46d0f23d6b9b2cb6e0957224d198f2154a7c6..448ba4e68a7afed32607b7c703dae27743a0d8f8 100644 (file)
@@ -1283,7 +1283,9 @@ gtk_entry_set_icon_sensitive
 gtk_entry_get_icon_sensitive
 gtk_entry_get_icon_at_pos
 gtk_entry_set_icon_tooltip_text
+gtk_entry_get_icon_tooltip_text
 gtk_entry_set_icon_tooltip_markup
+gtk_entry_get_icon_tooltip_markup
 gtk_entry_set_icon_drag_source
 gtk_entry_get_current_icon_drag_source
 
index 3f648fafa6590f7ff546cb806c5960dd33bc4cfe..0e73df53de1a1a0604e0e2c354fdabd11fa4265d 100644 (file)
@@ -1288,6 +1288,8 @@ gtk_entry_get_icon_pixbuf
 gtk_entry_get_icon_sensitive
 gtk_entry_get_icon_stock
 gtk_entry_get_icon_storage_type
+gtk_entry_get_icon_tooltip_markup
+gtk_entry_get_icon_tooltip_text
 gtk_entry_get_inner_border
 gtk_entry_get_invisible_char
 gtk_entry_get_layout
index 9a72884475c963a1a1cf43e8e24353ad84333aea..ea53d6f435fc3af44e34698bf7ec03c2cda6983c 100644 (file)
@@ -216,6 +216,10 @@ enum {
   PROP_ACTIVATABLE_SECONDARY,
   PROP_SENSITIVE_PRIMARY,
   PROP_SENSITIVE_SECONDARY,
+  PROP_TOOLTIP_TEXT_PRIMARY,
+  PROP_TOOLTIP_TEXT_SECONDARY,
+  PROP_TOOLTIP_MARKUP_PRIMARY,
+  PROP_TOOLTIP_MARKUP_SECONDARY,
   PROP_IM_MODULE
 };
 
@@ -1086,6 +1090,78 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                          TRUE,
                                                          GTK_PARAM_READWRITE));
   
+  /**
+   * GtkEntry:primary-icon-tooltip-text:
+   * 
+   * The contents of the tooltip on the primary icon.
+   *
+   * Also see gtk_entry_set_icon_tooltip_text().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_TEXT_PRIMARY,
+                                   g_param_spec_string ("primary-icon-tooltip-text",
+                                                        P_("Primary icon tooltip text"),
+                                                        P_("The contents of the tooltip on the primary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+  
+  /**
+   * GtkEntry:secondary-icon-tooltip-text:
+   * 
+   * The contents of the tooltip on the secondary icon.
+   *
+   * Also see gtk_entry_set_icon_tooltip_text().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_TEXT_SECONDARY,
+                                   g_param_spec_string ("secondary-icon-tooltip-text",
+                                                        P_("Secondary icon tooltip text"),
+                                                        P_("The contents of the tooltip on the secondary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:primary-icon-tooltip-markup:
+   * 
+   * The contents of the tooltip on the primary icon, which is marked up
+   * with the <link linkend="PangoMarkupFormat">Pango text markup 
+   * language</link>.
+   *
+   * Also see gtk_entry_set_icon_tooltip_markup().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_MARKUP_PRIMARY,
+                                   g_param_spec_string ("primary-icon-tooltip-markup",
+                                                        P_("Primary icon tooltip markup"),
+                                                        P_("The contents of the tooltip on the primary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
+  /**
+   * GtkEntry:secondary-icon-tooltip-markup:
+   * 
+   * The contents of the tooltip on the secondary icon, which is marked up
+   * with the <link linkend="PangoMarkupFormat">Pango text markup 
+   * language</link>.
+   *
+   * Also see gtk_entry_set_icon_tooltip_markup().
+   *
+   * Since: 2.16
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TOOLTIP_MARKUP_SECONDARY,
+                                   g_param_spec_string ("secondary-icon-tooltip-markup",
+                                                        P_("Secondary icon tooltip markup"),
+                                                        P_("The contents of the tooltip on the secondary icon"),                              
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
   /**
    * GtkEntry:im-module:
    *
@@ -1806,6 +1882,30 @@ gtk_entry_set_property (GObject         *object,
                                     g_value_get_boolean (value));
       break;
 
+    case PROP_TOOLTIP_TEXT_PRIMARY:
+      gtk_entry_set_icon_tooltip_text (entry,
+                                       GTK_ENTRY_ICON_PRIMARY,
+                                       g_value_get_string (value));
+      break;
+
+    case PROP_TOOLTIP_TEXT_SECONDARY:
+      gtk_entry_set_icon_tooltip_text (entry,
+                                       GTK_ENTRY_ICON_SECONDARY,
+                                       g_value_get_string (value));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_PRIMARY:
+      gtk_entry_set_icon_tooltip_markup (entry,
+                                         GTK_ENTRY_ICON_PRIMARY,
+                                         g_value_get_string (value));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_SECONDARY:
+      gtk_entry_set_icon_tooltip_markup (entry,
+                                         GTK_ENTRY_ICON_SECONDARY,
+                                         g_value_get_string (value));
+      break;
+
     case PROP_IM_MODULE:
       g_free (priv->im_module);
       priv->im_module = g_strdup (g_value_get_string (value));
@@ -2000,6 +2100,26 @@ gtk_entry_get_property (GObject         *object,
                            gtk_entry_get_icon_sensitive (entry, GTK_ENTRY_ICON_SECONDARY));
       break;
 
+    case PROP_TOOLTIP_TEXT_PRIMARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_TOOLTIP_TEXT_SECONDARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_PRIMARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY));
+      break;
+
+    case PROP_TOOLTIP_MARKUP_SECONDARY:
+      g_value_take_string (value,
+                           gtk_entry_get_icon_tooltip_markup (entry, GTK_ENTRY_ICON_SECONDARY));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -7744,6 +7864,43 @@ ensure_has_tooltip (GtkEntry *entry)
   gtk_widget_set_has_tooltip (GTK_WIDGET (entry), has_tooltip);
 }
 
+/**
+ * gtk_entry_get_icon_tooltip_text:
+ * @entry: a #GtkEntry
+ * @icon_pos: the icon position
+ *
+ * Gets the contents of the tooltip on the icon at the specified 
+ * position in @entry.
+ * 
+ * Returns: the tooltip text, or %NULL. Free the returned string
+ *     with g_free() when done.
+ * 
+ * Since: 2.16
+ */
+gchar *
+gtk_entry_get_icon_tooltip_text (GtkEntry             *entry,
+                                 GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  gchar *text = NULL;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+  if (icon_info->tooltip && 
+      !pango_parse_markup (icon_info->tooltip, -1, 0, NULL, &text, NULL, NULL))
+    g_assert (NULL == text); /* text should still be NULL in case of markup errors */
+
+  return text;
+}
+
 /**
  * gtk_entry_set_icon_tooltip_text:
  * @entry: a #GtkEntry
@@ -7779,11 +7936,50 @@ gtk_entry_set_icon_tooltip_text (GtkEntry             *entry,
   if (icon_info->tooltip)
     g_free (icon_info->tooltip);
 
+  /* Treat an empty string as a NULL string,
+   * because an empty string would be useless for a tooltip:
+   */
+  if (tooltip && tooltip[0] == '\0')
+    tooltip = NULL;
+
   icon_info->tooltip = tooltip ? g_markup_escape_text (tooltip, -1) : NULL;
 
   ensure_has_tooltip (entry);
 }
 
+/**
+ * gtk_entry_get_icon_tooltip_markup:
+ * @entry: a #GtkEntry
+ * @icon_pos: the icon position
+ *
+ * Gets the contents of the tooltip on the icon at the specified 
+ * position in @entry.
+ * 
+ * Returns: the tooltip text, or %NULL. Free the returned string
+ *     with g_free() when done.
+ * 
+ * Since: 2.16
+ */
+gchar *
+gtk_entry_get_icon_tooltip_markup (GtkEntry             *entry,
+                                   GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv;
+  EntryIconInfo *icon_info;
+  gchar *text = NULL;
+
+  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
+  g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
+
+  priv = GTK_ENTRY_GET_PRIVATE (entry);
+  icon_info = priv->icons[icon_pos];
+
+  if (!icon_info)
+    return NULL;
+  return g_strdup (icon_info->tooltip);
+}
+
 /**
  * gtk_entry_set_icon_tooltip_markup:
  * @entry: a #GtkEntry
@@ -7820,6 +8016,12 @@ gtk_entry_set_icon_tooltip_markup (GtkEntry             *entry,
   if (icon_info->tooltip)
     g_free (icon_info->tooltip);
 
+  /* Treat an empty string as a NULL string,
+   * because an empty string would be useless for a tooltip:
+   */
+  if (tooltip && tooltip[0] == '\0')
+    tooltip = NULL;
+
   icon_info->tooltip = g_strdup (tooltip);
 
   ensure_has_tooltip (entry);
index 9c1545272a4671e558825a439f61cac536e2620b..be0444752bbd6d859cd6efdd7811a95c8949cdb2 100644 (file)
@@ -275,9 +275,13 @@ gint         gtk_entry_get_icon_at_pos                   (GtkEntry             *
 void         gtk_entry_set_icon_tooltip_text             (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos,
                                                          const gchar          *tooltip);
+gchar *      gtk_entry_get_icon_tooltip_text             (GtkEntry             *entry,
+                                                          GtkEntryIconPosition  icon_pos);
 void         gtk_entry_set_icon_tooltip_markup           (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos,
                                                          const gchar          *tooltip);
+gchar *      gtk_entry_get_icon_tooltip_markup           (GtkEntry             *entry,
+                                                          GtkEntryIconPosition  icon_pos);
 void         gtk_entry_set_icon_drag_source              (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos,
                                                          GtkTargetList        *target_list,