[shotwell/wip/gtk4: 36/45] Remove custom icon loader




commit 7797f36b2a05927b27360871de1dc1c0f3cdd553
Author: Jens Georg <mail jensge org>
Date:   Sun Apr 10 10:20:37 2022 +0200

    Remove custom icon loader

 src/AppWindow.vala               |  2 +-
 src/Resources.vala               | 66 ----------------------------------------
 src/plugins/ManifestWidget.vala  |  8 +----
 src/plugins/SpitInterfaces.vala  |  2 +-
 src/publishing/PublishingUI.vala | 14 ++++-----
 5 files changed, 10 insertions(+), 82 deletions(-)
---
diff --git a/src/AppWindow.vala b/src/AppWindow.vala
index 387f2ad3..697aedb6 100644
--- a/src/AppWindow.vala
+++ b/src/AppWindow.vala
@@ -604,7 +604,7 @@ public abstract class AppWindow : PageWindow {
             "license", Resources.LICENSE,
             "website-label", _("Visit the Shotwell web site"),
             "authors", Resources.AUTHORS,
-            "logo", Resources.get_icon(Resources.ICON_ABOUT_LOGO, -1),
+            "logo-icon-name", "shotwell",
             "translator-credits", _("translator-credits"),
             null
         );
diff --git a/src/Resources.vala b/src/Resources.vala
index 08d86a07..40e75d01 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -1012,72 +1012,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
         icon_theme.add_resource_path("/org/gnome/Shotwell/icons/hicolor");
     }
     
-    // This method returns a reference to a cached pixbuf that may be shared throughout the system.
-    // If the pixbuf is to be modified, make a copy of it.
-    public Gdk.Pixbuf? get_icon(string name, int scale = DEFAULT_ICON_SCALE) {
-        if (scaled_icon_cache != null) {
-            string scaled_name = "%s-%d".printf(name, scale);
-            if (scaled_icon_cache.has_key(scaled_name))
-                return scaled_icon_cache.get(scaled_name);
-        }
-        
-        // stash icons not available through the UI Manager (i.e. used directly as pixbufs)
-        // in the local cache
-        if (icon_cache == null)
-            icon_cache = new Gee.HashMap<string, Gdk.Pixbuf>();
-        
-        // fetch from cache and if not present, from disk
-        Gdk.Pixbuf? pixbuf = icon_cache.get(name);
-        if (pixbuf == null) {
-            pixbuf = load_icon(name, scale);
-            if (pixbuf == null)
-                return null;
-            
-            icon_cache.set(name, pixbuf);
-        }
-        
-        if (scale <= 0)
-            return pixbuf;
-        
-        Gdk.Pixbuf scaled_pixbuf = scale_pixbuf(pixbuf, scale, Gdk.InterpType.BILINEAR, false);
-        
-        if (scaled_icon_cache == null)
-            scaled_icon_cache = new Gee.HashMap<string, Gdk.Pixbuf>();
-        
-        scaled_icon_cache.set("%s-%d".printf(name, scale), scaled_pixbuf);
-        
-        return scaled_pixbuf;
-    }
-    
-    public Gdk.Pixbuf? load_icon(string name, int scale = DEFAULT_ICON_SCALE) {
-    #if 0
-        Gdk.Pixbuf pixbuf = null;
-        try {
-            var theme = Gtk.IconTheme.get_default();
-            var info = theme.lookup_icon(name, scale, Gtk.IconLookupFlags.GENERIC_FALLBACK);
-            pixbuf = info.load_symbolic_for_context(AppWindow.get_instance().get_style_context(), null);
-        } catch (Error err) {
-            debug("Failed to find icon %s in theme, falling back to resources", name);
-        }
-
-        if (pixbuf == null) {
-            try {
-                var path = "/org/gnome/Shotwell/icons/%s".printf(name);
-                pixbuf = new Gdk.Pixbuf.from_resource(path);
-            } catch (Error err) {
-                critical("Unable to load icon %s: %s", name, err.message);
-            }
-        }
-
-        if (pixbuf == null)
-            return null;
-
-        return (scale > 0) ? scale_pixbuf(pixbuf, scale, Gdk.InterpType.BILINEAR, false) : pixbuf;
-        #endif
-        // TODO
-        return null;
-    }
-
     // Get the directory where our help files live.  Returns a string
     // describing the help path we want, or, if we're installed system
     // -wide already, returns null.
diff --git a/src/plugins/ManifestWidget.vala b/src/plugins/ManifestWidget.vala
index 2ccff212..44d0e334 100644
--- a/src/plugins/ManifestWidget.vala
+++ b/src/plugins/ManifestWidget.vala
@@ -175,13 +175,7 @@ private class ManifestListView : Gtk.TreeView {
                 
                 Spit.PluggableInfo info = Spit.PluggableInfo();
                 pluggable.get_info(ref info);
-                
-                #if 0
-                icon = (info.icons != null && info.icons.length > 0) 
-                    ? info.icons[0]
-                    : Resources.get_icon(Resources.ICON_GENERIC_PLUGIN, ICON_SIZE);
-                    #endif
-                
+                                
                 Gtk.TreeIter plugin_iter;
                 store.append(out plugin_iter, category_iter);
                 
diff --git a/src/plugins/SpitInterfaces.vala b/src/plugins/SpitInterfaces.vala
index 3e2c70e1..dd2b8a5c 100644
--- a/src/plugins/SpitInterfaces.vala
+++ b/src/plugins/SpitInterfaces.vala
@@ -176,7 +176,7 @@ public struct PluggableInfo {
      * An icon representing this plugin at one or more sizes. Shotwell may select an icon 
      * according to the size that closest fits the control its being drawn in.
      */
-    public Gdk.Pixbuf[]? icons;
+    public string icon;
 }
 
 /**
diff --git a/src/publishing/PublishingUI.vala b/src/publishing/PublishingUI.vala
index 1461c1d9..78a1605a 100644
--- a/src/publishing/PublishingUI.vala
+++ b/src/publishing/PublishingUI.vala
@@ -77,12 +77,12 @@ public class PublishingDialog : Gtk.Dialog {
         }
         set_title(title);
 
-        service_selector_box_model = new Gtk.ListStore(2, typeof(Gdk.Pixbuf), typeof(string));
+        service_selector_box_model = new Gtk.ListStore(2, typeof(string), typeof(string));
         service_selector_box = new Gtk.ComboBox.with_model(service_selector_box_model);
 
         Gtk.CellRendererPixbuf renderer_pix = new Gtk.CellRendererPixbuf();
         service_selector_box.pack_start(renderer_pix,true);
-        service_selector_box.add_attribute(renderer_pix, "pixbuf", 0);
+        service_selector_box.add_attribute(renderer_pix, "icon-name", 0);
 
         Gtk.CellRendererText renderer_text = new Gtk.CellRendererText();
         service_selector_box.pack_start(renderer_text,true);
@@ -104,17 +104,17 @@ public class PublishingDialog : Gtk.Dialog {
 
             service.get_info(ref info);
 
-            if (null != info.icons && 0 < info.icons.length) {
+            if (info.icon != null) {
                 // check if the icons object is set -- if set use that icon
-                service_selector_box_model.set(iter, 0, info.icons[0], 1,
+                service_selector_box_model.set(iter, 0, info.icon, 1,
                     service.get_pluggable_name());
                 
                 // in case the icons object is not set on the next iteration
-                info.icons[0] = Resources.get_icon(Resources.ICON_GENERIC_PLUGIN);
+                info.icon = Resources.ICON_GENERIC_PLUGIN;
             } else {
                 // if icons object is null or zero length use a generic icon
-                service_selector_box_model.set(iter, 0, Resources.get_icon(
-                    Resources.ICON_GENERIC_PLUGIN), 1, service.get_pluggable_name());
+                service_selector_box_model.set(iter, 0,
+                    Resources.ICON_GENERIC_PLUGIN, 1, service.get_pluggable_name());
             }
             
             if (last_used_service == null) {


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