Merge lp:~xapantu/granite/fix-956544 into lp:~elementary-pantheon/granite/granite

Proposed by xapantu
Status: Merged
Approved by: Victor Martinez
Approved revision: 204
Merged at revision: 204
Proposed branch: lp:~xapantu/granite/fix-956544
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 51 lines (+22/-5)
1 file modified
lib/Widgets/DynamicNotebook.vala (+22/-5)
To merge this branch: bzr merge lp:~xapantu/granite/fix-956544
Reviewer Review Type Date Requested Status
Victor Martinez (community) Approve
Review via email: mp+98269@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Victor Martinez (victored) wrote :

It looks fine to me Lucas. Have you considered using GLib.Icon for the fallbacks?

Revision history for this message
xapantu (xapantu) wrote :

Ah, yes, we can use gtk_icon_theme_choose_icon, I didn't know this function. I updated the branch.

lp:~xapantu/granite/fix-956544 updated
204. By xapantu

Avoid a few lines of cose using choose_icon directly from gtk

Revision history for this message
Victor Martinez (victored) wrote :

I didn't know about that function either :P

Looks perfect Lucas.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/DynamicNotebook.vala'
2--- lib/Widgets/DynamicNotebook.vala 2012-03-19 18:39:32 +0000
3+++ lib/Widgets/DynamicNotebook.vala 2012-03-20 18:16:21 +0000
4@@ -158,6 +158,27 @@
5 public signal void switch_page (Tab tab);
6 public signal void page_removed (Tab tab);
7
8+ // FIXME: probably needs to be moved somewhere with a public API
9+ Gdk.Pixbuf load_pixbuf_with_fallbacks (string[] icons_name, int icon_size) {
10+ Gdk.Pixbuf pixbuf = null;
11+ try {
12+ var icon_info = Gtk.IconTheme.get_default ().choose_icon (icons_name, icon_size, 0);
13+ if (icon_info != null) {
14+ pixbuf = icon_info.load_symbolic_for_context (button_context, null);
15+ }
16+ }
17+ catch (Error e) {
18+ try {
19+ pixbuf = Gtk.IconTheme.get_default ().load_icon ("gtk-missing-image", icon_size, 0);
20+ }
21+ catch (Error e) {
22+ error ("gtk-missing-image not found");
23+ }
24+ }
25+ return pixbuf;
26+ }
27+
28+
29 public Tabs () {
30 tabs = new Gee.ArrayList<Tab>();
31
32@@ -175,11 +196,6 @@
33 }
34 }
35
36- try {
37- close_pixbuf = Gtk.IconTheme.get_default ().load_icon ("gtk-close", close_size, 0);
38- }
39- catch (Error e) {
40- }
41
42 height_request = 35;
43 width_request = (int)(2*max_width);
44@@ -229,6 +245,7 @@
45 }
46 return true;
47 });
48+ close_pixbuf = load_pixbuf_with_fallbacks ( {"window-close-symbolic", "window-close", "gtk-close"}, close_size);
49 }
50
51 public void add_tab (Tab tab) {

Subscribers

People subscribed via source and target branches