[gnome-photos] Use libhandy Hdy.ViewSwitcher instead of Gtk.StackSwitcher



commit bee3ca57682af1ee82e37c677a77883e134ca2c8
Author: Felix Häcker <haeckerfelix gnome org>
Date:   Sun May 24 16:52:15 2020 +0200

    Use libhandy Hdy.ViewSwitcher instead of Gtk.StackSwitcher
    
    This commit also adds libhandy as a dependency.
    
    This is a part of the View-Switcher-Initative.
    More information: https://gitlab.gnome.org/GNOME/Initiatives/-/issues/16

 flatpak/org.gnome.Photos.json | 18 ++++++++++++++++++
 meson.build                   |  1 +
 src/meson.build               |  1 +
 src/photos-application.c      |  3 +++
 src/photos-embed.c            |  9 +++++++++
 src/photos-main-toolbar.c     |  6 ++++--
 6 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/flatpak/org.gnome.Photos.json b/flatpak/org.gnome.Photos.json
index 4d3ac2a8..76dfc70f 100644
--- a/flatpak/org.gnome.Photos.json
+++ b/flatpak/org.gnome.Photos.json
@@ -75,6 +75,24 @@
                 }
             ]
         },
+        {
+            "name" : "libhandy",
+            "buildsystem" : "meson",
+            "config-opts" : [
+                "-Dintrospection=disabled",
+                "-Dtests=false",
+                "-Dexamples=false",
+                "-Dvapi=false",
+                "-Dglade_catalog=disabled"
+            ],
+            "cleanup" : [ "/include", "/lib/pkgconfig" ],
+            "sources" : [
+                {
+                    "type" : "git",
+                    "url" : "https://gitlab.gnome.org/GNOME/libhandy.git";
+                }
+            ]
+        },
         {
             "name": "librest",
             "config-opts": [ "--disable-introspection" ],
diff --git a/meson.build b/meson.build
index 0d0ed1a2..5a9519b6 100644
--- a/meson.build
+++ b/meson.build
@@ -171,6 +171,7 @@ libdazzle_dep = dependency('libdazzle-1.0', version: '>= 3.26.0')
 libgdata_dep = dependency('libgdata', version: '>= 0.17.13')
 libgfgraph_dep = dependency('libgfbgraph-0.2', version: '>= 0.2.1')
 libjpeg_dep = dependency('libjpeg')
+libhandy_dep = dependency ('libhandy-1', version: '>= 1.0.0')
 libpng_dep = dependency('libpng16')
 tracker_control_dep = dependency('tracker-control-2.0')
 tracker_sparql_dep = dependency('tracker-sparql-2.0')
diff --git a/src/meson.build b/src/meson.build
index 9919f0cf..10957ee0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -395,6 +395,7 @@ deps = common_deps + [
   libgd_dep,
   libgdata_dep,
   libgfgraph_dep,
+  libhandy_dep,
   m_dep,
   tracker_control_dep,
   tracker_sparql_dep,
diff --git a/src/photos-application.c b/src/photos-application.c
index f7b4b56e..0393f68a 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -36,6 +36,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <grilo.h>
+#include <handy.h>
 #include <libtracker-control/tracker-control.h>
 
 #include "photos-application.h"
@@ -2640,6 +2641,8 @@ photos_application_startup (GApplication *application)
 
   G_APPLICATION_CLASS (photos_application_parent_class)->startup (application);
 
+  hdy_init ();
+
   photos_gegl_init ();
 
   grl_init (NULL, NULL);
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 5f638115..90771637 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -825,6 +825,9 @@ photos_embed_init (PhotosEmbed *self)
   self->overview = photos_view_container_new (PHOTOS_WINDOW_MODE_OVERVIEW, _("Photos"));
   name = photos_view_container_get_name (PHOTOS_VIEW_CONTAINER (self->overview));
   gtk_stack_add_titled (GTK_STACK (self->stack), self->overview, "overview", name);
+  gtk_container_child_set (GTK_CONTAINER (self->stack), self->overview,
+                           "icon-name", "camera-photo-symbolic",
+                           NULL);
 
   self->collection_view = photos_view_container_new (PHOTOS_WINDOW_MODE_COLLECTION_VIEW, _("Collection 
View"));
   gtk_stack_add_named (GTK_STACK (self->stack), self->collection_view, "collection-view");
@@ -832,10 +835,16 @@ photos_embed_init (PhotosEmbed *self)
   self->collections = photos_view_container_new (PHOTOS_WINDOW_MODE_COLLECTIONS, _("Albums"));
   name = photos_view_container_get_name (PHOTOS_VIEW_CONTAINER (self->collections));
   gtk_stack_add_titled (GTK_STACK (self->stack), self->collections, "collections", name);
+  gtk_container_child_set (GTK_CONTAINER (self->stack), self->collections,
+                           "icon-name", "emblem-photos-symbolic",
+                           NULL);
 
   self->favorites = photos_view_container_new (PHOTOS_WINDOW_MODE_FAVORITES, _("Favorites"));
   name = photos_view_container_get_name (PHOTOS_VIEW_CONTAINER (self->favorites));
   gtk_stack_add_titled (GTK_STACK (self->stack), self->favorites, "favorites", name);
+  gtk_container_child_set (GTK_CONTAINER (self->stack), self->favorites,
+                           "icon-name", "starred-symbolic",
+                           NULL);
 
   self->import = photos_view_container_new (PHOTOS_WINDOW_MODE_IMPORT, _("Import"));
   gtk_stack_add_named (GTK_STACK (self->stack), self->import, "import");
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 3040e07c..bc83fed5 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -27,6 +27,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
+#include <handy.h>
 
 #include "photos-base-manager.h"
 #include "photos-dlna-renderers-manager.h"
@@ -730,7 +731,8 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
   context = gtk_widget_get_style_context (self->selection_menu);
   gtk_style_context_add_class (context, "selection-menu");
 
-  self->stack_switcher = g_object_ref_sink (gtk_stack_switcher_new ());
+  self->stack_switcher = g_object_ref_sink (hdy_view_switcher_new ());
+  hdy_view_switcher_set_policy (HDY_VIEW_SWITCHER (self->stack_switcher), HDY_VIEW_SWITCHER_POLICY_WIDE);
   /* Don't show buttons for untitled children. */
   gtk_widget_set_no_show_all (self->stack_switcher, TRUE);
   gtk_widget_show (self->stack_switcher);
@@ -895,5 +897,5 @@ photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self)
 void
 photos_main_toolbar_set_stack (PhotosMainToolbar *self, GtkStack *stack)
 {
-  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (self->stack_switcher), stack);
+  hdy_view_switcher_set_stack (HDY_VIEW_SWITCHER (self->stack_switcher), stack);
 }


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