[gtk/matthiasc/for-main: 2/2] dragicon: Provide default icons for more types




commit df025fcb887b1fa0ff9970ba9ada7430f1fa50e7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 12 20:43:50 2021 -0500

    dragicon: Provide default icons for more types
    
    Provide default icons for paintables and files.
    This is easy to do, and makes sense.
    
    fixup drag icon

 gtk/gtkdragicon.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/gtk/gtkdragicon.c b/gtk/gtkdragicon.c
index e4deb8adf7..02c20d42e5 100644
--- a/gtk/gtkdragicon.c
+++ b/gtk/gtkdragicon.c
@@ -532,6 +532,15 @@ gtk_drag_icon_create_widget_for_value (const GValue *value)
     {
       return gtk_label_new (g_value_get_string (value));
     }
+  else if (G_VALUE_HOLDS (value, GDK_TYPE_PAINTABLE))
+    {
+      GtkWidget *image;
+
+      image = gtk_image_new_from_paintable (g_value_get_object (value));
+      gtk_widget_add_css_class (image, "large-icons");
+
+      return image;
+    }
   else if (G_VALUE_HOLDS (value, GDK_TYPE_RGBA))
     {
       GtkWidget *swatch;
@@ -541,6 +550,18 @@ gtk_drag_icon_create_widget_for_value (const GValue *value)
 
       return swatch;
     }
+  else if (G_VALUE_HOLDS (value, G_TYPE_FILE))
+    {
+      GFileInfo *info;
+      GtkWidget *image;
+
+      info = g_file_query_info (G_FILE (g_value_get_object (value)), "standard::icon", 0, NULL, NULL);
+      image = gtk_image_new_from_gicon (g_file_info_get_icon (info));
+      gtk_widget_add_css_class (image, "large-icons");
+      g_object_unref (info);
+
+      return image;
+    }
   else if (G_VALUE_HOLDS (value, GTK_TYPE_TEXT_BUFFER))
     {
       GtkTextBuffer *buffer = g_value_get_object (value);


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