Merge lp:~midori/midori/hidpiTabs into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: gue5t gue5t
Approved revision: 7019
Merged at revision: 7105
Proposed branch: lp:~midori/midori/hidpiTabs
Merge into: lp:midori
Diff against target: 153 lines (+31/-37)
3 files modified
katze/katze-item.c (+1/-1)
midori/midori-notebook.vala (+16/-2)
midori/midori-view.c (+14/-34)
To merge this branch: bzr merge lp:~midori/midori/hidpiTabs
Reviewer Review Type Date Requested Status
gue5t gue5t Approve
Review via email: mp+267467@code.launchpad.net

Commit message

Scale tab icons taking scale factor into account

Use GLib.Icon all the way.

To post a comment you must log in.
lp:~midori/midori/hidpiTabs updated
7018. By Cris Dywan

No need to deal with icon size in _midori_web_view_load_icon

Revision history for this message
gue5t gue5t (gue5t) wrote :

Pages like <https://developer.gnome.org/gtk3/unstable/GtkApplication.html> still show a small icon (which makes tabs different sizes) with wk1; locally it looks like changing the "> icon_width" condition to "!= icon_width" (and same for height) is enough to allow upscaling to make sure we get the right size.

Also, the "Tabs" menubar menu as well as bookmarks and history still have blurry icons that we should fix, but I blame Katze infrastructure for that. It might be better to address that stuff in a separate branch.

review: Needs Fixing
lp:~midori/midori/hidpiTabs updated
7019. By gue5t <email address hidden>

Scale both larger- and smaller-than-expected tab icons

Revision history for this message
gue5t gue5t (gue5t) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'katze/katze-item.c'
2--- katze/katze-item.c 2014-09-06 09:02:47 +0000
3+++ katze/katze-item.c 2016-02-20 12:51:50 +0000
4@@ -512,7 +512,7 @@
5 g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
6
7 pixbuf = katze_item_get_pixbuf (item, widget);
8- image = gtk_image_new_from_pixbuf (pixbuf);
9+ image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_MENU);
10 gtk_widget_show (image);
11 if (pixbuf != NULL)
12 g_object_unref (pixbuf);
13
14=== modified file 'midori/midori-notebook.vala'
15--- midori/midori-notebook.vala 2014-03-30 14:00:38 +0000
16+++ midori/midori-notebook.vala 2016-02-20 12:51:50 +0000
17@@ -103,10 +103,24 @@
18 tooltip_text = label.label;
19 }
20
21+ GLib.Icon? scale_if_needed (GLib.Icon? icon, int scale) {
22+ if (icon is Gdk.Pixbuf) {
23+ var pixbuf = icon as Gdk.Pixbuf;
24+ int icon_width = 16, icon_height = 16;
25+ Gtk.icon_size_lookup (Gtk.IconSize.MENU, out icon_width, out icon_height);
26+ // Apply scale factor which is only automatically applied on ThemedIcon
27+ icon_width *= scale;
28+ icon_height *= scale;
29+ if (pixbuf.width != icon_width || pixbuf.height != icon_height)
30+ return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
31+ }
32+ return icon;
33+ }
34+
35 void icon_changed (GLib.ParamSpec pspec) {
36- Icon? icon;
37+ GLib.Icon? icon;
38 tab.get ("icon", out icon);
39- this.icon.set_from_gicon (icon, Gtk.IconSize.MENU);
40+ this.icon.set_from_gicon (scale_if_needed (icon, scale_factor), Gtk.IconSize.MENU);
41 }
42
43 void colors_changed () {
44
45=== modified file 'midori/midori-view.c'
46--- midori/midori-view.c 2015-09-26 22:37:02 +0000
47+++ midori/midori-view.c 2016-02-20 12:51:50 +0000
48@@ -344,7 +344,7 @@
49 "icon",
50 "Icon",
51 "The icon of the view",
52- GDK_TYPE_PIXBUF,
53+ G_TYPE_ICON,
54 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
55
56 g_object_class_install_property (gobject_class,
57@@ -398,21 +398,18 @@
58
59 static void
60 midori_view_apply_icon (MidoriView* view,
61- GdkPixbuf* icon,
62+ GIcon* icon,
63 const gchar* icon_name)
64 {
65+ g_return_if_fail (icon != NULL);
66+
67 katze_item_set_icon (view->item, icon_name);
68- /* katze_item_get_image knows about this pixbuf */
69- if (icon != NULL)
70- g_object_ref (icon);
71- g_object_set_data_full (G_OBJECT (view->item), "pixbuf", icon,
72- (GDestroyNotify)g_object_unref);
73- katze_object_assign (view->icon, icon);
74+ katze_object_assign (view->icon, g_object_ref (icon));
75 g_object_notify (G_OBJECT (view), "icon");
76
77 if (view->menu_item)
78 {
79- GtkWidget* image = katze_item_get_image (view->item, view->web_view);
80+ GtkWidget* image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
81 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (view->menu_item), image);
82 }
83 }
84@@ -420,36 +417,24 @@
85 static void
86 midori_view_unset_icon (MidoriView* view)
87 {
88- GdkScreen* screen;
89- GtkIconTheme* icon_theme;
90 gchar* content_type;
91 GIcon* icon;
92- GtkIconInfo* icon_info;
93- GdkPixbuf* pixbuf = NULL;
94+
95+ katze_assign (view->icon_uri, NULL);
96
97 content_type = g_content_type_from_mime_type (
98 midori_tab_get_mime_type (MIDORI_TAB (view)));
99 icon = g_content_type_get_icon (content_type);
100 g_free (content_type);
101 g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
102-
103- if ((screen = gtk_widget_get_screen (view->web_view))
104- && (icon_theme = gtk_icon_theme_get_for_screen (screen)))
105- {
106- if ((icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, 16, 0)))
107- pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
108- }
109-
110- midori_view_apply_icon (view, pixbuf, NULL);
111- g_object_unref (icon);
112+ g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html-symbolic");
113+
114+ midori_view_apply_icon (view, icon, NULL);
115 }
116
117 static void
118 _midori_web_view_load_icon (MidoriView* view)
119 {
120- gint icon_width = 16, icon_height = 16;
121- GtkSettings* settings = gtk_widget_get_settings (view->web_view);
122- gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
123 GdkPixbuf* pixbuf = NULL;
124 #ifdef HAVE_WEBKIT2
125 cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view));
126@@ -458,15 +443,12 @@
127 cairo_image_surface_get_width (surface),
128 cairo_image_surface_get_height (surface))))
129 {
130- GdkPixbuf* pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf,
131- icon_width, icon_height, GDK_INTERP_BILINEAR);
132- g_object_unref (pixbuf);
133- midori_view_apply_icon (view, pixbuf_scaled, view->icon_uri);
134+ midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
135 }
136 #else
137 if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf (
138- WEBKIT_WEB_VIEW (view->web_view), icon_width, icon_height)))
139- midori_view_apply_icon (view, pixbuf, view->icon_uri);
140+ WEBKIT_WEB_VIEW (view->web_view), 0, 0)))
141+ midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
142 #endif
143 }
144
145@@ -703,8 +685,6 @@
146 static void
147 midori_view_load_committed (MidoriView* view)
148 {
149- katze_assign (view->icon_uri, NULL);
150-
151 GList* children = gtk_container_get_children (GTK_CONTAINER (view));
152 for (; children; children = g_list_next (children))
153 if (g_object_get_data (G_OBJECT (children->data), "midori-infobar-cb"))

Subscribers

People subscribed via source and target branches

to all changes: