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
=== modified file 'katze/katze-item.c'
--- katze/katze-item.c 2014-09-06 09:02:47 +0000
+++ katze/katze-item.c 2016-02-20 12:51:50 +0000
@@ -512,7 +512,7 @@
512 g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);512 g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
513513
514 pixbuf = katze_item_get_pixbuf (item, widget);514 pixbuf = katze_item_get_pixbuf (item, widget);
515 image = gtk_image_new_from_pixbuf (pixbuf);515 image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_MENU);
516 gtk_widget_show (image);516 gtk_widget_show (image);
517 if (pixbuf != NULL)517 if (pixbuf != NULL)
518 g_object_unref (pixbuf);518 g_object_unref (pixbuf);
519519
=== modified file 'midori/midori-notebook.vala'
--- midori/midori-notebook.vala 2014-03-30 14:00:38 +0000
+++ midori/midori-notebook.vala 2016-02-20 12:51:50 +0000
@@ -103,10 +103,24 @@
103 tooltip_text = label.label;103 tooltip_text = label.label;
104 }104 }
105105
106 GLib.Icon? scale_if_needed (GLib.Icon? icon, int scale) {
107 if (icon is Gdk.Pixbuf) {
108 var pixbuf = icon as Gdk.Pixbuf;
109 int icon_width = 16, icon_height = 16;
110 Gtk.icon_size_lookup (Gtk.IconSize.MENU, out icon_width, out icon_height);
111 // Apply scale factor which is only automatically applied on ThemedIcon
112 icon_width *= scale;
113 icon_height *= scale;
114 if (pixbuf.width != icon_width || pixbuf.height != icon_height)
115 return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
116 }
117 return icon;
118 }
119
106 void icon_changed (GLib.ParamSpec pspec) {120 void icon_changed (GLib.ParamSpec pspec) {
107 Icon? icon;121 GLib.Icon? icon;
108 tab.get ("icon", out icon);122 tab.get ("icon", out icon);
109 this.icon.set_from_gicon (icon, Gtk.IconSize.MENU);123 this.icon.set_from_gicon (scale_if_needed (icon, scale_factor), Gtk.IconSize.MENU);
110 }124 }
111125
112 void colors_changed () {126 void colors_changed () {
113127
=== modified file 'midori/midori-view.c'
--- midori/midori-view.c 2015-09-26 22:37:02 +0000
+++ midori/midori-view.c 2016-02-20 12:51:50 +0000
@@ -344,7 +344,7 @@
344 "icon",344 "icon",
345 "Icon",345 "Icon",
346 "The icon of the view",346 "The icon of the view",
347 GDK_TYPE_PIXBUF,347 G_TYPE_ICON,
348 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));348 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
349349
350 g_object_class_install_property (gobject_class,350 g_object_class_install_property (gobject_class,
@@ -398,21 +398,18 @@
398398
399static void399static void
400midori_view_apply_icon (MidoriView* view,400midori_view_apply_icon (MidoriView* view,
401 GdkPixbuf* icon,401 GIcon* icon,
402 const gchar* icon_name)402 const gchar* icon_name)
403{403{
404 g_return_if_fail (icon != NULL);
405
404 katze_item_set_icon (view->item, icon_name);406 katze_item_set_icon (view->item, icon_name);
405 /* katze_item_get_image knows about this pixbuf */407 katze_object_assign (view->icon, g_object_ref (icon));
406 if (icon != NULL)
407 g_object_ref (icon);
408 g_object_set_data_full (G_OBJECT (view->item), "pixbuf", icon,
409 (GDestroyNotify)g_object_unref);
410 katze_object_assign (view->icon, icon);
411 g_object_notify (G_OBJECT (view), "icon");408 g_object_notify (G_OBJECT (view), "icon");
412409
413 if (view->menu_item)410 if (view->menu_item)
414 {411 {
415 GtkWidget* image = katze_item_get_image (view->item, view->web_view);412 GtkWidget* image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
416 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (view->menu_item), image);413 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (view->menu_item), image);
417 }414 }
418}415}
@@ -420,36 +417,24 @@
420static void417static void
421midori_view_unset_icon (MidoriView* view)418midori_view_unset_icon (MidoriView* view)
422{419{
423 GdkScreen* screen;
424 GtkIconTheme* icon_theme;
425 gchar* content_type;420 gchar* content_type;
426 GIcon* icon;421 GIcon* icon;
427 GtkIconInfo* icon_info;422
428 GdkPixbuf* pixbuf = NULL;423 katze_assign (view->icon_uri, NULL);
429424
430 content_type = g_content_type_from_mime_type (425 content_type = g_content_type_from_mime_type (
431 midori_tab_get_mime_type (MIDORI_TAB (view)));426 midori_tab_get_mime_type (MIDORI_TAB (view)));
432 icon = g_content_type_get_icon (content_type);427 icon = g_content_type_get_icon (content_type);
433 g_free (content_type);428 g_free (content_type);
434 g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");429 g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
435430 g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html-symbolic");
436 if ((screen = gtk_widget_get_screen (view->web_view))431
437 && (icon_theme = gtk_icon_theme_get_for_screen (screen)))432 midori_view_apply_icon (view, icon, NULL);
438 {
439 if ((icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, 16, 0)))
440 pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
441 }
442
443 midori_view_apply_icon (view, pixbuf, NULL);
444 g_object_unref (icon);
445}433}
446434
447static void435static void
448_midori_web_view_load_icon (MidoriView* view)436_midori_web_view_load_icon (MidoriView* view)
449{437{
450 gint icon_width = 16, icon_height = 16;
451 GtkSettings* settings = gtk_widget_get_settings (view->web_view);
452 gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
453 GdkPixbuf* pixbuf = NULL;438 GdkPixbuf* pixbuf = NULL;
454 #ifdef HAVE_WEBKIT2439 #ifdef HAVE_WEBKIT2
455 cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view));440 cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view));
@@ -458,15 +443,12 @@
458 cairo_image_surface_get_width (surface),443 cairo_image_surface_get_width (surface),
459 cairo_image_surface_get_height (surface))))444 cairo_image_surface_get_height (surface))))
460 {445 {
461 GdkPixbuf* pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf,446 midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
462 icon_width, icon_height, GDK_INTERP_BILINEAR);
463 g_object_unref (pixbuf);
464 midori_view_apply_icon (view, pixbuf_scaled, view->icon_uri);
465 }447 }
466 #else448 #else
467 if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf (449 if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf (
468 WEBKIT_WEB_VIEW (view->web_view), icon_width, icon_height)))450 WEBKIT_WEB_VIEW (view->web_view), 0, 0)))
469 midori_view_apply_icon (view, pixbuf, view->icon_uri);451 midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
470 #endif452 #endif
471}453}
472454
@@ -703,8 +685,6 @@
703static void685static void
704midori_view_load_committed (MidoriView* view)686midori_view_load_committed (MidoriView* view)
705{687{
706 katze_assign (view->icon_uri, NULL);
707
708 GList* children = gtk_container_get_children (GTK_CONTAINER (view));688 GList* children = gtk_container_get_children (GTK_CONTAINER (view));
709 for (; children; children = g_list_next (children))689 for (; children; children = g_list_next (children))
710 if (g_object_get_data (G_OBJECT (children->data), "midori-infobar-cb"))690 if (g_object_get_data (G_OBJECT (children->data), "midori-infobar-cb"))

Subscribers

People subscribed via source and target branches

to all changes: