[gtk+] Add a GtkEntry::invisible-char style property



commit 8f1a578ade0e94a6370917e2bfee23cfcf8d01d0
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Apr 30 14:40:22 2009 -0400

    Add a GtkEntry::invisible-char style property
    
    Allow themes to set a preferred invisible character. GTK+ will
    still fall back to other candidates if the character is not available
    in the font.
---
 NEWS           |    8 ++++++++
 gtk/gtkentry.c |   30 +++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 0019b13..5037f3e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Overview of Changes from GTK+ 2.16.x to 2.17.0
+==============================================
+
+* Changes that are relevant for theme authors
+ - GtkEntry now has a ::invisible-char style property that allows
+   themes to set the preferred invisible character
+
+
 Overview of Changes from GTK+ 2.16.0 to 2.16.1
 ==============================================
 
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 607ef87..a21e94f 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -1214,6 +1214,27 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                                GTK_PARAM_READABLE));
   
   /**
+   * GtkEntry::invisible-char:
+   *
+   * The invisible character is used when masking entry contents (in
+   * \"password mode\")"). When it is not explicitly set with the
+   * #GtkEntry::invisible-char property, GTK+ determines the character
+   * to use from a list of possible candidates, depending on availability
+   * in the current font.
+   *
+   * This style property allows the theme to prepend a character
+   * to the list of candidates.
+   *
+   * Since: 2.22
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_unichar ("invisible-char",
+					    		         P_("Invisible character"),
+							         P_("The character to use when masking entry contents (in \"password mode\")"),
+							         0,
+							         GTK_PARAM_READABLE));
+  
+  /**
    * GtkEntry::populate-popup:
    * @entry: The entry on which the signal is emitted
    * @menu: the menu that is being populated
@@ -2149,12 +2170,18 @@ find_invisible_char (GtkWidget *widget)
   PangoAttrList *attr_list;
   gint i;
   gunichar invisible_chars [] = {
+    0,
     0x25cf, /* BLACK CIRCLE */
     0x2022, /* BULLET */
     0x2731, /* HEAVY ASTERISK */
     0x273a  /* SIXTEEN POINTED ASTERISK */
   };
 
+  if (widget->style)
+    gtk_widget_style_get (widget,
+                          "invisible-char", &invisible_chars[0],
+                          NULL);
+
   layout = gtk_widget_create_pango_layout (widget, NULL);
 
   attr_list = pango_attr_list_new ();
@@ -2163,7 +2190,7 @@ find_invisible_char (GtkWidget *widget)
   pango_layout_set_attributes (layout, attr_list);
   pango_attr_list_unref (attr_list);
 
-  for (i = 0; i < G_N_ELEMENTS (invisible_chars); i++)
+  for (i = (invisible_chars[0] != 0 ? 0 : 1); i < G_N_ELEMENTS (invisible_chars); i++)
     {
       gchar text[7] = { 0, };
       gint len, count;
@@ -2181,6 +2208,7 @@ find_invisible_char (GtkWidget *widget)
     }
 
   g_object_unref (layout);
+
   return '*';
 }
 



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