[gtk+/gtk-3-10] GtkAboutDialog: fixed calling gtk_about_dialog_set_logo_icon_name() with a NULL icon_name. Now it wi



commit 41e876039bdb7104b82083e43b4a8838ebdabba3
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Thu Nov 28 17:01:18 2013 -0300

    GtkAboutDialog: fixed calling gtk_about_dialog_set_logo_icon_name()
    with a NULL icon_name. Now it will actually use the default
    window icon set as mention in the docs

 gtk/gtkaboutdialog.c |   62 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index a1f70f0..891e60d 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -1774,8 +1774,7 @@ gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
                                      const gchar    *icon_name)
 {
   GtkAboutDialogPrivate *priv;
-  gint *sizes;
-  gint i, best_size;
+  GList *icons;
 
   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
 
@@ -1786,33 +1785,48 @@ gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
   if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
     g_object_notify (G_OBJECT (about), "logo");
 
-  sizes = gtk_icon_theme_get_icon_sizes (gtk_icon_theme_get_default (), icon_name);
-  best_size = 0;
-  for (i = 0; sizes[i]; i++)
+  if (icon_name)
     {
-      if (sizes[i] >= 128 || sizes[i] == -1)
-        {
-          best_size = 128;
-          break;
-        }
-      else if (sizes[i] >= 96)
-        {
-          best_size = MAX (96, best_size);
-        }
-      else if (sizes[i] >= 64)
-        {
-          best_size = MAX (64, best_size);
-        }
-      else
+      gint *sizes = gtk_icon_theme_get_icon_sizes (gtk_icon_theme_get_default (),
+                                                   icon_name);
+      gint i, best_size = 0;
+
+      for (i = 0; sizes[i]; i++)
         {
-          best_size = MAX (48, best_size);
+          if (sizes[i] >= 128 || sizes[i] == -1)
+            {
+              best_size = 128;
+              break;
+            }
+          else if (sizes[i] >= 96)
+            {
+              best_size = MAX (96, best_size);
+            }
+          else if (sizes[i] >= 64)
+            {
+              best_size = MAX (64, best_size);
+            }
+          else
+            {
+              best_size = MAX (48, best_size);
+            }
         }
-    }
-  g_free (sizes);
+      g_free (sizes);
 
-  gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
+      gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
                                 GTK_ICON_SIZE_DIALOG);
-  gtk_image_set_pixel_size (GTK_IMAGE (priv->logo_image), best_size);
+      gtk_image_set_pixel_size (GTK_IMAGE (priv->logo_image), best_size);
+    }
+  else if ((icons = gtk_window_get_default_icon_list ()))
+    {
+      gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), icons->data);
+      g_list_free (icons);
+    }
+  else
+    {
+      gtk_image_clear (GTK_IMAGE (priv->logo_image));
+    }
+
   g_object_notify (G_OBJECT (about), "logo-icon-name");
 
   g_object_thaw_notify (G_OBJECT (about));


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