[gnome-screenshot/wip/christopherdavis/screenshot-redesign] screenshot-interactive: Use automatic icon loading



commit 89307573ad0e30dbc0d580277fb94a79ff3fa1e3
Author: Christopher Davis <brainblasted disroot org>
Date:   Sun Mar 10 19:40:08 2019 -0400

    screenshot-interactive: Use automatic icon loading
    
    Instead of using placeholder icons and switching them out
    on startup, we can take use of g_application's ability to
    handle automatic resources. This requires aliasing
    the icons in the gresource in so that GtkIconTheme can
    detect them.

 src/gnome-screenshot.gresource.xml  |  6 +++---
 src/screenshot-application.c        |  1 +
 src/screenshot-interactive-dialog.c | 16 ----------------
 src/screenshot-interactive.ui       | 12 ++++++------
 4 files changed, 10 insertions(+), 25 deletions(-)
---
diff --git a/src/gnome-screenshot.gresource.xml b/src/gnome-screenshot.gresource.xml
index a38d549..91b4c98 100644
--- a/src/gnome-screenshot.gresource.xml
+++ b/src/gnome-screenshot.gresource.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/screenshot">
-    <file>display-symbolic.svg</file>
-    <file>selection-symbolic.svg</file>
-    <file>window-symbolic.svg</file>
+    <file alias="icons/display-symbolic.svg">display-symbolic.svg</file>
+    <file alias="icons/selection-symbolic.svg">selection-symbolic.svg</file>
+    <file alias="icons/window-symbolic.svg">window-symbolic.svg</file>
     <file preprocess="xml-stripblanks">screenshot-app-menu.ui</file>
     <file preprocess="xml-stripblanks">screenshot-interactive.ui</file>
     <file preprocess="xml-stripblanks">screenshot-dialog.ui</file>
diff --git a/src/screenshot-application.c b/src/screenshot-application.c
index 16c394c..6177062 100644
--- a/src/screenshot-application.c
+++ b/src/screenshot-application.c
@@ -822,6 +822,7 @@ static void
 screenshot_application_startup (GApplication *app)
 {
   ScreenshotApplication *self = SCREENSHOT_APPLICATION (app);
+  g_application_set_resource_base_path (app, "/org/gnome/screenshot");
 
   G_APPLICATION_CLASS (screenshot_application_parent_class)->startup (app);
 
diff --git a/src/screenshot-interactive-dialog.c b/src/screenshot-interactive-dialog.c
index 1a37385..e80d697 100644
--- a/src/screenshot-interactive-dialog.c
+++ b/src/screenshot-interactive-dialog.c
@@ -223,9 +223,6 @@ screenshot_interactive_dialog_new (CaptureClickedCallback f, gpointer user_data)
   GtkWidget *dialog;
   GtkWidget *capture_button;
   GtkWidget *menu;
-  GtkWidget *screen_img;
-  GtkWidget *selection_img;
-  GtkWidget *window_img;
   GtkWidget *listbox;
   GMenuModel *app_menu;
   GtkBuilder *ui;
@@ -246,19 +243,6 @@ screenshot_interactive_dialog_new (CaptureClickedCallback f, gpointer user_data)
 
   gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu), app_menu);
 
-  screen_img = GTK_WIDGET (gtk_builder_get_object (ui, "screen_img"));
-  selection_img = GTK_WIDGET (gtk_builder_get_object (ui, "selection_img"));
-  window_img = GTK_WIDGET (gtk_builder_get_object (ui, "window_img"));
-
-  /* Replace placeholder icons */
-  GdkPixbuf *d = gdk_pixbuf_new_from_resource_at_scale ("/org/gnome/screenshot/display-symbolic.svg", 32, 
32, TRUE, NULL);
-  GdkPixbuf *s = gdk_pixbuf_new_from_resource_at_scale ("/org/gnome/screenshot/selection-symbolic.svg", 32, 
32, TRUE, NULL);
-  GdkPixbuf *w = gdk_pixbuf_new_from_resource_at_scale ("/org/gnome/screenshot/window-symbolic.svg", 32, 32, 
TRUE, NULL);
-
-  gtk_image_set_from_pixbuf (GTK_IMAGE (screen_img), d);
-  gtk_image_set_from_pixbuf (GTK_IMAGE (selection_img), s);
-  gtk_image_set_from_pixbuf (GTK_IMAGE (window_img), w);
-
   gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
 
   listbox = GTK_WIDGET (gtk_builder_get_object (ui, "listbox"));
diff --git a/src/screenshot-interactive.ui b/src/screenshot-interactive.ui
index 4465d22..11e3224 100644
--- a/src/screenshot-interactive.ui
+++ b/src/screenshot-interactive.ui
@@ -61,8 +61,8 @@
                           <object class="GtkImage" id="screen_img">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="icon_name">video-display-symbolic</property>
-                            <property name="icon_size">3</property>
+                            <property name="icon_name">display-symbolic</property>
+                            <property name="pixel_size">32</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -114,8 +114,8 @@
                           <object class="GtkImage" id="window_img">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="icon_name">window-maximize-symbolic</property>
-                            <property name="icon_size">3</property>
+                            <property name="icon_name">window-symbolic</property>
+                            <property name="pixel_size">32</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -166,8 +166,8 @@
                           <object class="GtkImage" id="selection_img">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="icon_name">input-tablet-symbolic</property>
-                            <property name="icon_size">3</property>
+                            <property name="icon_name">selection-symbolic</property>
+                            <property name="pixel_size">32</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>


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