[Xfce4-commits] <midori:master> NULL placeholder text should unset it (gtk3 compat)

Christian Dywan noreply at xfce.org
Fri Aug 31 10:56:01 CEST 2012


Updating branch refs/heads/master
         to ebd0847a3910fcd15581345c0e23271794254829 (commit)
       from a0d95170539955aeffbbcf3918f04d5047fcac50 (commit)

commit ebd0847a3910fcd15581345c0e23271794254829
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Aug 30 22:00:08 2012 +0200

    NULL placeholder text should unset it (gtk3 compat)
    
    Fixes: https://bugs.launchpad.net/midori/+bug/1043681

 katze/gtk3-compat.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/katze/gtk3-compat.c b/katze/gtk3-compat.c
index 9586aac..d7fd249 100644
--- a/katze/gtk3-compat.c
+++ b/katze/gtk3-compat.c
@@ -71,17 +71,15 @@ gtk_entry_set_placeholder_text (GtkEntry*    entry,
                                 const gchar* default_text)
 {
     /* Note: The default text initially overwrites any previous text */
-    gchar* old_value = g_object_get_data (G_OBJECT (entry),
-                                          "sokoke_default_text");
-    g_object_set_data (G_OBJECT (entry), "sokoke_default_text",
-                       (gpointer)default_text);
+    gchar* old_value = g_object_get_data (G_OBJECT (entry), "sokoke_default_text");
+    g_object_set_data (G_OBJECT (entry), "sokoke_default_text", (gpointer)default_text);
 
-    if (!old_value)
+    if (default_text == NULL)
+        g_object_set_data (G_OBJECT (entry), "sokoke_has_default", GINT_TO_POINTER (0));
+    else if (!old_value)
     {
-        g_object_set_data (G_OBJECT (entry), "sokoke_has_default",
-                           GINT_TO_POINTER (1));
-        sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
-                                            PANGO_STYLE_ITALIC);
+        g_object_set_data (G_OBJECT (entry), "sokoke_has_default", GINT_TO_POINTER (1));
+        sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
         gtk_entry_set_text (entry, default_text);
         g_signal_connect (entry, "drag-data-received",
             G_CALLBACK (sokoke_on_entry_drag_data_received), NULL);
@@ -92,13 +90,11 @@ gtk_entry_set_placeholder_text (GtkEntry*    entry,
     }
     else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
     {
-        gint has_default = GPOINTER_TO_INT (
-            g_object_get_data (G_OBJECT (entry), "sokoke_has_default"));
+        gint has_default = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (entry), "sokoke_has_default"));
         if (has_default)
         {
             gtk_entry_set_text (entry, default_text);
-            sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
-                                                PANGO_STYLE_ITALIC);
+            sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
         }
     }
 }


More information about the Xfce4-commits mailing list