[gtk+/gtk-2-16] Allow unsetting the icon title set with gdk_window_set_icon_name



commit f1bb36c9d764fd3ce97a4c99fd07d4bca2230a38
Author: Christian Persch <chpe gnome org>
Date:   Mon Apr 20 14:53:51 2009 +0200

    Allow unsetting the icon title set with gdk_window_set_icon_name
    
    Change gdk_window_set_icon_name to allow using NULL to unset a
    previously set icon title, so that the icon title tracks the normal
    title again. Bug #535557.
---
 gdk/x11/gdkwindow-x11.c |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 54810a8..0a09f67 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -4205,13 +4205,18 @@ gdk_window_icon_name_set (GdkWindow *window)
  * idea from a user interface standpoint. But you can set such a name
  * with this function, if you like.
  *
+ * After calling this with a non-%NULL @name, calls to gdk_window_set_title()
+ * will not update the icon title.
+ *
+ * Using %NULL for @name unsets the icon title; further calls to
+ * gdk_window_set_title() will again update the icon title as well.
  **/
-void          
+void
 gdk_window_set_icon_name (GdkWindow   *window, 
 			  const gchar *name)
 {
   GdkDisplay *display;
-  
+
   g_return_if_fail (GDK_IS_WINDOW (window));
 
   if (GDK_WINDOW_DESTROYED (window))
@@ -4220,17 +4225,29 @@ gdk_window_set_icon_name (GdkWindow   *window,
   display = gdk_drawable_get_display (window);
 
   g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
-		      GUINT_TO_POINTER (TRUE));
+                      GUINT_TO_POINTER (name != NULL));
 
-  XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
-		   GDK_WINDOW_XID (window),
-		   gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
-		   gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
-		   PropModeReplace, (guchar *)name, strlen (name));
-  
-  set_text_property (display, GDK_WINDOW_XID (window),
-		     gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
-		     name);
+  if (name != NULL)
+    {
+      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+                       GDK_WINDOW_XID (window),
+                       gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
+                       gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
+                       PropModeReplace, (guchar *)name, strlen (name));
+
+      set_text_property (display, GDK_WINDOW_XID (window),
+                         gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
+                         name);
+    }
+  else
+    {
+      XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
+                       GDK_WINDOW_XID (window),
+                       gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"));
+      XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
+                       GDK_WINDOW_XID (window),
+                       gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"));
+    }
 }
 
 /**



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