[gnome-music/wip/cdavis/hdywindow-hdyviewswitcher: 1/4] Use HdyViewSwitcher
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/cdavis/hdywindow-hdyviewswitcher: 1/4] Use HdyViewSwitcher
- Date: Tue, 23 Mar 2021 21:27:26 +0000 (UTC)
commit f67c6cb8a68bfb38f37cdbb72f93f03695974cad
Author: Christopher Davis <brainblasted disroot org>
Date: Wed Feb 3 23:04:36 2021 -0800
Use HdyViewSwitcher
Apps are now moving to use HdyViewSwitcher instead of
GtkStackSwitcher for their main navigation.
gnomemusic/application.py | 5 ++++-
gnomemusic/views/albumsview.py | 3 +++
gnomemusic/views/artistsview.py | 2 ++
gnomemusic/views/playlistsview.py | 2 ++
gnomemusic/views/songsview.py | 2 ++
gnomemusic/widgets/headerbar.py | 4 ++--
gnomemusic/window.py | 6 ++++++
meson.build | 1 +
8 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index c92a6aa1e..dfb1d8b6b 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -32,7 +32,9 @@
from gettext import gettext as _
-from gi.repository import Gtk, Gio, GLib, Gdk, GObject
+import gi
+gi.require_version("Handy", "1")
+from gi.repository import Gtk, Gio, GLib, Gdk, GObject, Handy
from gnomemusic.coregrilo import CoreGrilo
from gnomemusic.coremodel import CoreModel
@@ -220,6 +222,7 @@ class Application(Gtk.Application):
def do_startup(self):
Gtk.Application.do_startup(self)
+ Handy.init()
self._set_actions()
def _quit(self, action=None, param=None):
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 0b2f0ab8a..bd2c0936a 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -45,6 +45,9 @@ class AlbumsView(Gtk.Stack):
selection_mode = GObject.Property(type=bool, default=False)
title = GObject.Property(
type=str, default=_("Albums"), flags=GObject.ParamFlags.READABLE)
+ icon_name = GObject.Property(
+ type=str, default="media-optical-cd-audio-symbolic",
+ flags=GObject.ParamFlags.READABLE)
_scrolled_window = Gtk.Template.Child()
_flowbox = Gtk.Template.Child()
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 7666b6ce2..bdffdadda 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -41,6 +41,8 @@ class ArtistsView(Gtk.Box):
title = GObject.Property(
type=str, default=_("Artists"), flags=GObject.ParamFlags.READABLE)
+ icon_name = GObject.Property(type=str, default="system-users-symbolic",
+ flags=GObject.ParamFlags.READABLE)
_artist_container = Gtk.Template.Child()
_artist_view = Gtk.Template.Child()
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index 9f4bde820..9cdf7098b 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -39,6 +39,8 @@ class PlaylistsView(Gtk.Box):
title = GObject.Property(
type=str, default=_("Playlists"), flags=GObject.ParamFlags.READABLE)
+ icon_name = GObject.Property(type=str, default="view-list-symbolic",
+ flags=GObject.ParamFlags.READABLE)
_sidebar = Gtk.Template.Child()
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index d347d5dce..85d3d1b93 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -42,6 +42,8 @@ class SongsView(Gtk.ScrolledWindow):
title = GObject.Property(
type=str, default=_("Songs"), flags=GObject.ParamFlags.READABLE)
+ icon_name = GObject.Property(type=str, default="emblem-music-symbolic",
+ flags=GObject.ParamFlags.READABLE)
_duration_renderer = Gtk.Template.Child()
_now_playing_column = Gtk.Template.Child()
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index ee1639637..37b98eeda 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -25,7 +25,7 @@
from enum import IntEnum
from gettext import gettext as _, ngettext
-from gi.repository import GObject, Gtk
+from gi.repository import GObject, Gtk, Handy
from gnomemusic.widgets.appmenu import AppMenu
@@ -108,7 +108,7 @@ class HeaderBar(Gtk.HeaderBar):
self._selection_mode = False
- self._stack_switcher = Gtk.StackSwitcher(
+ self._stack_switcher = Handy.ViewSwitcher(
can_focus=False, halign="center")
self._stack_switcher.show()
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 3b5d13998..e540caed9 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -259,9 +259,15 @@ class Window(Gtk.ApplicationWindow):
for i in self.views[View.ALBUM:]:
if i.props.title:
self._stack.add_titled(i, i.props.name, i.props.title)
+ self._stack.child_set_property(
+ i, "icon-name", i.props.icon_name)
else:
self._stack.add_named(i, i.props.name)
+ # FIXME: For some reason neither GtkStackSwitcher or
+ # HdyViewSwitcher show the selected child here, unless we set
+ # A different visible child and then set this before.
+ # Not included here because it's a bad hack.
self._stack.props.visible_child = self.views[View.ALBUM]
self.views[View.SEARCH].bind_property(
diff --git a/meson.build b/meson.build
index b7501435b..dedac78cf 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,7 @@ PKGLIB_DIR = join_paths(get_option('prefix'), get_option('libdir'), APPLICATION_
dependency('goa-1.0', version: '>= 3.35.90')
dependency('gobject-introspection-1.0', version: '>= 1.35.0')
dependency('gtk+-3.0', version: '>= 3.24.7')
+dependency('libhandy-1', version: '>= 1.0.0')
dependency('libdazzle-1.0', version: '>= 3.28.0')
dependency('libmediaart-2.0', version: '>= 1.9.1')
dependency('libsoup-2.4')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]