[latexila] Add theme icon to stock: fix and simplify the code
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Add theme icon to stock: fix and simplify the code
- Date: Sun, 11 Mar 2012 00:45:43 +0000 (UTC)
commit b3a459b9f7ec6cfb6d9330a10ccf8f9ae0815478
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Sun Mar 11 01:46:11 2012 +0100
Add theme icon to stock: fix and simplify the code
Why do simple when you can make it complicated?
src/latexila.vala | 37 ++++---------------------------------
1 files changed, 4 insertions(+), 33 deletions(-)
---
diff --git a/src/latexila.vala b/src/latexila.vala
index d9b4d38..ffa0fe1 100644
--- a/src/latexila.vala
+++ b/src/latexila.vala
@@ -322,40 +322,11 @@ public class Latexila : GLib.Object
private void add_theme_icon_to_stock (string icon_name, string stock_id)
{
- Gtk.IconTheme theme = Gtk.IconTheme.get_default ();
- Gtk.IconSet icon_set = new Gtk.IconSet ();
-
- Gtk.IconSize[] sizes =
- {
- Gtk.IconSize.MENU,
- Gtk.IconSize.SMALL_TOOLBAR,
- Gtk.IconSize.LARGE_TOOLBAR,
- Gtk.IconSize.BUTTON,
- Gtk.IconSize.DND,
- Gtk.IconSize.DIALOG
- };
-
- foreach (Gtk.IconSize size in sizes)
- {
- int nb_pixels;
- Gtk.icon_size_lookup (size, out nb_pixels, null);
-
- Gdk.Pixbuf pixbuf = null;
- try
- {
- pixbuf = theme.load_icon (icon_name, nb_pixels, 0);
- }
- catch (Error e)
- {
- warning ("Get theme icon failed: %s", e.message);
- continue;
- }
+ Gtk.IconSource icon_source = new Gtk.IconSource ();
+ icon_source.set_icon_name (icon_name);
- Gtk.IconSource icon_source = new Gtk.IconSource ();
- icon_source.set_pixbuf (pixbuf);
- icon_source.set_size (size);
- icon_set.add_source (icon_source);
- }
+ Gtk.IconSet icon_set = new Gtk.IconSet ();
+ icon_set.add_source (icon_source);
Gtk.IconFactory icon_factory = new Gtk.IconFactory ();
icon_factory.add (stock_id, icon_set);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]