[bijiben] empty-results-box: fix blurry icon in hi-dpi



commit de0858918b5e63dbc711f56d686c4a66b54f4007
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jul 1 00:13:12 2015 +0200

    empty-results-box: fix blurry icon in hi-dpi
    
    Just put the icon in our GResource instead of loading it from disk. Also
    don't use the pixbuf loader directly, or we won't get scaling factor and
    CSS styling.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751683

 src/Makefile.am                                    |    1 +
 src/bjb-empty-results-box.c                        |   33 +++++--------------
 src/bjb.gresource.xml                              |    1 +
 .../resources/note-symbolic.svg                    |    0
 4 files changed, 11 insertions(+), 24 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1075ab1..e8e1811 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,7 @@ bijiben_LDFLAGS = \
 resource_files = \
        resources/Adwaita.css \
        resources/app-menu.ui \
+       resources/note-symbolic.svg \
        resources/thumbnail-frame.png
 
 bjb-resources.c: bjb.gresource.xml $(resource_files)
diff --git a/src/bjb-empty-results-box.c b/src/bjb-empty-results-box.c
index 9ea56f2..200c446 100644
--- a/src/bjb-empty-results-box.c
+++ b/src/bjb-empty-results-box.c
@@ -48,10 +48,10 @@ bjb_empty_results_box_constructed (GObject *object)
   BjbEmptyResultsBox *self;
   BjbEmptyResultsBoxPrivate *priv;
   GtkStyleContext *context;
-  GdkPixbuf *pixbuf;
   GtkWidget *labels_grid;
-  gchar *label, *icons_path, *note_icon_path, *markup;
-  GError *error;
+  gchar *label, *markup;
+  GFile *note_icon_file;
+  GIcon *icon;
 
   G_OBJECT_CLASS (bjb_empty_results_box_parent_class)->constructed (object);
   self = BJB_EMPTY_RESULTS_BOX (object);
@@ -68,27 +68,12 @@ bjb_empty_results_box_constructed (GObject *object)
   context = gtk_widget_get_style_context (GTK_WIDGET (self));
   gtk_style_context_add_class (context, "dim-label");
 
-  icons_path = (gchar*) bijiben_get_bijiben_dir ();
-  note_icon_path = g_build_filename (icons_path,
-                                "bijiben",
-                                "icons",
-                                "hicolor",
-                                "scalable",
-                                "actions",
-                                "note.svg",
-                                NULL);
+  note_icon_file = g_file_new_for_uri ("resource://org/gnome/bijiben/note-symbolic.svg");
+  icon = g_file_icon_new (note_icon_file);
+  g_object_unref (note_icon_file);
 
-  error = NULL;
-  pixbuf = gdk_pixbuf_new_from_file_at_size (note_icon_path, 64, 64, &error);
-
-  if (error)
-  {
-    g_warning ("%s", error->message);
-    g_error_free (error);
-  }
-
-  priv->image  = gtk_image_new_from_pixbuf (pixbuf);
-  g_free (note_icon_path);
+  priv->image  = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
+  g_object_unref (icon);
 
   gtk_container_add (GTK_CONTAINER (self), priv->image);
 
diff --git a/src/bjb.gresource.xml b/src/bjb.gresource.xml
index f156788..792c555 100644
--- a/src/bjb.gresource.xml
+++ b/src/bjb.gresource.xml
@@ -4,5 +4,6 @@
     <file alias="Adwaita.css">resources/Adwaita.css</file>
     <file alias="app-menu.ui">resources/app-menu.ui</file>
     <file alias="thumbnail-frame.png">resources/thumbnail-frame.png</file>
+    <file alias="note-symbolic.svg">resources/note-symbolic.svg</file>
   </gresource>
 </gresources>
diff --git a/data/icons/hicolor_actions_scalable_note.svg b/src/resources/note-symbolic.svg
similarity index 100%
rename from data/icons/hicolor_actions_scalable_note.svg
rename to src/resources/note-symbolic.svg


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