[shotwell] Remove Gtk.IconFactory



commit 7589900c4ee3f790fd57474a64978193bd839424
Author: Jens Georg <mail jensge org>
Date:   Thu Dec 1 01:31:50 2016 +0100

    Remove Gtk.IconFactory
    
    Use Gtk.IconTheme and add the four -disabled variants used in SearchBar.
    
    Signed-off-by: Jens Georg <mail jensge org>

 icons/filter-flagged-disabled.png |  Bin 0 -> 3158 bytes
 icons/filter-photos-disabled.png  |  Bin 0 -> 3109 bytes
 icons/filter-raw-disabled.png     |  Bin 0 -> 4248 bytes
 icons/filter-videos-disabled.png  |  Bin 0 -> 3614 bytes
 src/Resources.vala                |   69 +-----------------------------------
 src/SearchFilter.vala             |    5 +--
 src/util/image.vala               |    8 ----
 7 files changed, 3 insertions(+), 79 deletions(-)
---
diff --git a/icons/filter-flagged-disabled.png b/icons/filter-flagged-disabled.png
new file mode 100644
index 0000000..2d50b23
Binary files /dev/null and b/icons/filter-flagged-disabled.png differ
diff --git a/icons/filter-photos-disabled.png b/icons/filter-photos-disabled.png
new file mode 100644
index 0000000..fb3f8e2
Binary files /dev/null and b/icons/filter-photos-disabled.png differ
diff --git a/icons/filter-raw-disabled.png b/icons/filter-raw-disabled.png
new file mode 100644
index 0000000..4641ada
Binary files /dev/null and b/icons/filter-raw-disabled.png differ
diff --git a/icons/filter-videos-disabled.png b/icons/filter-videos-disabled.png
new file mode 100644
index 0000000..7925c41
Binary files /dev/null and b/icons/filter-videos-disabled.png differ
diff --git a/src/Resources.vala b/src/Resources.vala
index bf34ae0..d7f237c 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -676,7 +676,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
     public const string SELECT_ALL_MENU = _("Select _All");
     public const string SELECT_ALL_TOOLTIP = _("Select all items");
     
-    private Gtk.IconFactory factory = null;
     private Gee.HashMap<string, Gdk.Pixbuf> icon_cache = null;
     Gee.HashMap<string, Gdk.Pixbuf> scaled_icon_cache = null;
     
@@ -689,35 +688,9 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
     private string END_MULTIMONTH_DATE_FORMAT_STRING = null;
         
     public void init () {
+        var icon_theme = Gtk.IconTheme.get_default();
         // load application-wide stock icons as IconSets
-        factory = new Gtk.IconFactory();
-
-        File icons_dir = AppDirs.get_resources_dir().get_child("icons");
-        add_stock_icon(icons_dir.get_child("crop.svg"), CROP);
-        add_stock_icon(icons_dir.get_child("redeye.png"), REDEYE);
-        add_stock_icon(icons_dir.get_child("make-primary.svg"), MAKE_PRIMARY);
-        add_stock_icon(icons_dir.get_child("import.svg"), IMPORT);
-        add_stock_icon(icons_dir.get_child("straighten.svg"), STRAIGHTEN);
-        add_stock_icon(icons_dir.get_child("import-all.png"), IMPORT_ALL);
-        add_stock_icon(icons_dir.get_child("shotwell-auto-enhance.png"), ENHANCE);
-        add_stock_icon(icons_dir.get_child("crop-pivot-reticle.png"), CROP_PIVOT_RETICLE);
-        add_stock_icon(icons_dir.get_child("merge.svg"), MERGE);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_FLAGGED_PAGE), ICON_FLAGGED_PAGE);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_VIDEOS_PAGE), ICON_VIDEOS_PAGE);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_SINGLE_PHOTO), ICON_SINGLE_PHOTO);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_CAMERAS), ICON_CAMERAS);
-        
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_FILTER_FLAGGED), 
-            ICON_FILTER_FLAGGED_DISABLED, dim_pixbuf);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_FILTER_PHOTOS), 
-            ICON_FILTER_PHOTOS_DISABLED, dim_pixbuf);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_FILTER_VIDEOS), 
-            ICON_FILTER_VIDEOS_DISABLED, dim_pixbuf);
-        add_stock_icon_from_themed_icon(new GLib.ThemedIcon(ICON_FILTER_RAW), 
-            ICON_FILTER_RAW_DISABLED, dim_pixbuf);
-        
-        factory.add_default();
-
+        icon_theme.append_search_path(AppDirs.get_resources_dir().get_child("icons").get_path());
         generate_rating_strings();
     }
     
@@ -935,44 +908,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
         return (scale > 0) ? scale_pixbuf(pixbuf, scale, Gdk.InterpType.BILINEAR, false) : pixbuf;
     }
     
-    private void add_stock_icon(File file, string stock_id) {
-        Gdk.Pixbuf pixbuf = null;
-        try {
-            pixbuf = new Gdk.Pixbuf.from_file(file.get_path());
-        } catch (Error err) {
-            critical("Unable to load stock icon %s: %s", stock_id, err.message);
-        }
-        
-        Gtk.IconSet icon_set = new Gtk.IconSet.from_pixbuf(pixbuf);
-        factory.add(stock_id, icon_set);
-    }
-    
-    public delegate void AddStockIconModify(Gdk.Pixbuf pixbuf);
-    
-    private void add_stock_icon_from_themed_icon(GLib.ThemedIcon gicon, string stock_id, 
-        AddStockIconModify? modify = null) {
-        Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default();
-        icon_theme.append_search_path(AppDirs.get_resources_dir().get_child("icons").get_path());
-
-        Gtk.IconInfo? info = icon_theme.lookup_by_gicon(gicon, 
-            Resources.DEFAULT_ICON_SCALE, Gtk.IconLookupFlags.FORCE_SIZE);
-        if (info == null) {
-            debug("unable to load icon for: %s", stock_id);
-            return;
-        }
-        
-        try {
-            Gdk.Pixbuf pix = info.load_icon();
-            if (modify != null) {
-                modify(pix);
-            }
-            Gtk.IconSet icon_set = new Gtk.IconSet.from_pixbuf(pix);
-                factory.add(stock_id, icon_set);
-        } catch (Error err) {
-            debug("%s", err.message);
-        }
-    }
-
     // 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/SearchFilter.vala b/src/SearchFilter.vala
index c02e0de..3429c02 100644
--- a/src/SearchFilter.vala
+++ b/src/SearchFilter.vala
@@ -646,10 +646,7 @@ public class SearchFilterToolbar : Gtk.Revealer {
         public void set_icon_name(string icon_name) {
             Gtk.Image? image = null;
             button.set_always_show_image(true);
-            if (icon_name.contains("disabled"))
-                image = new Gtk.Image.from_stock(icon_name, Gtk.IconSize.SMALL_TOOLBAR);
-            else
-                image = new Gtk.Image.from_icon_name(icon_name, Gtk.IconSize.SMALL_TOOLBAR);
+            image = new Gtk.Image.from_icon_name(icon_name, Gtk.IconSize.SMALL_TOOLBAR);
             image.set_margin_end(6);
             button.set_image(image);
         }
diff --git a/src/util/image.vala b/src/util/image.vala
index db872df..4adafae 100644
--- a/src/util/image.vala
+++ b/src/util/image.vala
@@ -250,14 +250,6 @@ public void shift_colors(Gdk.Pixbuf pixbuf, int red, int green, int blue, int al
     }
 }
 
-public void dim_pixbuf(Gdk.Pixbuf pixbuf) {
-    PixelTransformer transformer = new PixelTransformer();
-    SaturationTransformation sat = new SaturationTransformation(SaturationTransformation.MIN_PARAMETER);
-    transformer.attach_transformation(sat);
-    transformer.transform_pixbuf(pixbuf);
-    shift_colors(pixbuf, 0, 0, 0, -100);
-}
-
 bool coord_in_rectangle(int x, int y, Gdk.Rectangle rect) {
     return (x >= rect.x && x < (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height));
 }


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