diff --git a/data/gtk.css b/data/gtk.css
index 469b262..b5d1b6d 100644
--- a/data/gtk.css
+++ b/data/gtk.css
@@ -1,8 +1,20 @@
-.bg-texture {
+#content_stack {
box-shadow:inset 4px 4px 10px rgba(0,0,0,0.3);
background-image:url('noise-texture.png');
}
+#port_spinner {
+ background:none;
+ margin-top:-13px;
+}
+#port_spinner text {
+ padding-left: 0;
+}
+
+#server_stack_sidebar {
+ background-color:alpha(@theme_bg_color, 1);
+}
+
.no-bg {
background:none;
}
@@ -18,13 +30,13 @@
font-weight:bold;
}
-revealer.sidebar > * {
+#cover_info_revealer {
background-color:alpha(@theme_bg_color, 0.8);
box-shadow:0 0 10px @theme_bg_color;
- margin-left:20px
+ margin-left:20px;
}
-revealer.sidebar scale mark indicator {
+#cover_info_revealer scale mark indicator {
margin-right:5px;
}
@@ -32,24 +44,6 @@ actionbar {
background-color:@theme_unfocused_bg_color;
}
-/* Icon View in regular mode */
-iconview.view:selected,
-iconview.view:selected:focus {
- background-color:@theme_selected_bg_color;
-}
-iconview.view:hover {
- -gtk-icon-effect:highlight;
-}
-
-/* Icon View in selection mode */
-iconview.view.selection {
- -gtk-icon-effect:dim;
-}
-iconview.view.selection:selected,
-iconview.view.selection:selected:focus {
- background-color:@theme_selected_bg_color;
- -gtk-icon-effect:highlight;
-}
-iconview.view.selection:hover {
- -gtk-icon-effect:none;
+gridview child {
+ padding: 10px;
}
diff --git a/data/ui/album-headerbar.ui b/data/ui/album-headerbar.ui
index 76ade01..376c07c 100644
--- a/data/ui/album-headerbar.ui
+++ b/data/ui/album-headerbar.ui
@@ -1,8 +1,10 @@
-
-
-
diff --git a/data/ui/connection-panel.ui b/data/ui/connection-panel.ui
index f388d43..de6bf0c 100644
--- a/data/ui/connection-panel.ui
+++ b/data/ui/connection-panel.ui
@@ -1,182 +1,86 @@
-
-
-
-
-
- True
- False
- vertical
-
-
-
-
- True
- False
- 0
-
-
-
+
diff --git a/data/ui/cover-panel.ui b/data/ui/cover-panel.ui
index 304d9d0..e41148b 100644
--- a/data/ui/cover-panel.ui
+++ b/data/ui/cover-panel.ui
@@ -1,199 +1,198 @@
-
-
-
- True
- False
-
-
- True
- False
-
-
- True
- False
-
-
- cover-spinner
-
-
-
-
- True
- True
- False
- False
-
-
-
- True
- False
-
-
- True
- False
-
-
-
- True
- False
- 0
-
-
-
-
-
-
-
-
- cover-scroll
- 1
-
-
-
-
- -1
-
-
-
-
- True
- False
+
+
+
+ horizontal
end
- slide-right
+ 6
-
- True
- True
- start
- never
- 200
- True
-
-
- True
- False
- none
+
+ True
+ Show the cover in fullscreen mode
+ win.toggle-fullscreen
-
- True
- False
- start
- 5
- 5
- 5
- 5
- vertical
-
-
-
- True
- False
- 5
- 5
- 5
- True
-
-
- True
- False
- start
- Album
- True
- 0
-
-
- 0
- 0
-
-
-
-
- True
- False
- start
- Date
- True
- 0
-
-
- 0
- 1
-
-
-
-
- True
- False
- start
- Artist
- True
- 0
-
-
- 0
- 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
- True
- 10
- 0
-
-
-
-
- True
- True
- vertical
- False
- 0
- False
-
-
-
-
- True
- True
- end
- 1
-
-
-
+
+ view-fullscreen-symbolic
+
-
-
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ image-x-generic-symbolic
+
+
+
+
+ False
+ False
+ true
+ fill
+ true
+ fill
+
+
+ true
+ fill
+ true
+ fill
+
+
+ true
+ fill
+ true
+ fill
+ image-x-generic-symbolic
+ large
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+ slide-right
+ cover_info_revealer
+
+
+
+ start
+ never
+ 200
+ True
+ cover_info_scroll
+
+
+
+
+
+ vertical
+ start
+ fill
+ true
+ 5
+ 5
+ 5
+ 5
+
+
+ 5
+ 5
+ 5
+ True
+
+
+
+ start
+ Album
+ True
+ 0
+
+ 0
+ 0
+
+
+
+
+
+ start
+ Date
+ True
+ 0
+
+ 0
+ 1
+
+
+
+
+
+ start
+ Artist
+ True
+ 0
+
+ 0
+ 2
+
+
+
+
+
+
+
+
+ vertical
+ fill
+ true
+ False
+ 0
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/ui/cover-toolbar.ui b/data/ui/cover-toolbar.ui
deleted file mode 100644
index 7d3fcdd..0000000
--- a/data/ui/cover-toolbar.ui
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
- True
- False
- 6
- end
-
-
- True
- True
- True
- Show the cover in fullscreen mode
- win.toggle-fullscreen
-
-
- True
- False
- view-fullscreen-symbolic
-
-
-
-
- False
- False
- 0
- True
-
-
-
-
diff --git a/data/ui/library-panel.ui b/data/ui/library-panel.ui
index 0e499d9..3471ce3 100644
--- a/data/ui/library-panel.ui
+++ b/data/ui/library-panel.ui
@@ -1,11 +1,278 @@
-
-
-
- True
- False
- slide-left-right
+
+
+
+ 100
+ 1000
+ 150
+ 1
+ 10
+
+
+ False
+
+
+ vertical
+ end
+
+
+ 350
+ True
+ True
+ grid_adjustment
+ False
+ -1
+ 0
+ 0
+ False
+
+
+
+
+
+
+
+ gtk-refresh
+ True
+ True
+ True
+
+
+
+
+
+
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+ vertical
+
+
+
+
+
+ True
+ False
+ Sort
+
+
+
+
+
+ sort by artist
+ True
+ True
+ False
+
+ sort_year
+
+
+
+
+
+
+ sort by title
+ True
+ True
+ False
+
+ sort_year
+
+
+
+
+
+
+ sort by year
+ True
+ True
+ False
+ True
+
+
+
+
+
+
+
+ gtk-sort-descending
+ True
+ True
+ False
+
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+ horizontal
+ end
+ 6
+
+
+ True
+ True
+ True
+ Search the library
+
+
+
+ True
+ False
+ system-search-symbolic
+
+
+
+
+
+
+
+
+ True
+ True
+ True
+ Select multiple albums
+
+
+
+ True
+ False
+ object-select-symbolic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ slide-left-right
True
@@ -13,27 +280,31 @@
vertical
- True
+
True
True
+
search library
+
@@ -62,15 +333,16 @@
10
- True
- False
- 6
+ large
+ image-x-generic-symbolic
+
@@ -80,87 +352,135 @@
0
True
+
+
+
+
- True
- True
+ true
-
- True
- True
- 0
- horizontal
- 0
- 0
- 1
- 0
- True
-
-
-
-
-
+
+ vertical
+
+
+
+
+
+
+
+
+
+
+ vertical
+
+
+
+ contain
+ false
+
+
+ GtkListItem
+
+
+
+
+ GtkListItem
+
+
+
+
+
+
+
+
+]]>
+
+
+
+
+
+
- True
- False
none
+ false
- True
- False
cancel
@@ -169,10 +489,12 @@
True
+
@@ -182,25 +504,31 @@
True
+
+
+
@@ -217,9 +545,11 @@
True
False
+
@@ -227,7 +557,9 @@
True
False
False
+
True
@@ -237,23 +569,29 @@
True
False
gtk-missing-image
+
+
+
@@ -267,10 +605,12 @@
True
+
@@ -280,24 +620,32 @@
True
+
+
+
-
+
+
+
diff --git a/data/ui/library-toolbar.ui b/data/ui/library-toolbar.ui
deleted file mode 100644
index 97cad01..0000000
--- a/data/ui/library-toolbar.ui
+++ /dev/null
@@ -1,232 +0,0 @@
-
-
-
-
-
- 100
- 1000
- 150
- 1
- 10
-
-
- False
-
-
- True
- False
- vertical
-
-
- 350
- True
- True
- grid_adjustment
- False
- -1
- 0
- 0
- False
-
-
-
-
- True
- True
- 0
-
-
-
-
- gtk-refresh
- True
- True
- True
- none
- True
-
-
-
- False
- True
- 1
-
-
-
-
- True
- False
- vertical
-
-
- True
- False
- vertical
-
-
- False
- True
- 0
-
-
-
-
- True
- False
- Sort
-
-
- False
- True
- 1
-
-
-
-
- sort by artist
- True
- True
- False
- True
- sort_year
-
-
-
- False
- True
- 2
-
-
-
-
- sort by title
- True
- True
- False
- True
- sort_year
-
-
-
- False
- True
- 3
-
-
-
-
- sort by year
- True
- True
- False
- True
- True
-
-
-
- False
- True
- 4
-
-
-
-
- gtk-sort-descending
- True
- True
- False
- True
- True
- True
-
-
-
- False
- True
- 5
-
-
-
-
- False
- True
- 2
-
-
-
-
-
-
- True
- False
- 6
- end
-
-
- True
- True
- True
- Search the library
-
-
-
- True
- False
- system-search-symbolic
-
-
-
-
-
- False
- False
- 0
- True
-
-
-
-
- True
- True
- True
- Select multiple albums
-
-
-
- True
- False
- object-select-symbolic
-
-
-
-
- False
- False
- 1
- True
-
-
-
-
-
- False
- False
- 2
- True
-
-
-
-
diff --git a/data/ui/playlist-panel.ui b/data/ui/playlist-panel.ui
index 9ee8b7a..e3a5e9f 100644
--- a/data/ui/playlist-panel.ui
+++ b/data/ui/playlist-panel.ui
@@ -1,194 +1,204 @@
-
-
-
- True
- False
- slide-left-right
-
-
- True
- False
- vertical
+
+
+
+ horizontal
+ end
+ 6
-
- True
- True
-
-
+
True
True
- 0
- horizontal
- 0
- 0
- 1
- 0
- True
-
-
-
-
-
-
-
-
- True
- True
- 0
-
+ True
+ Select multiple albums
+
+
+
+ object-select-symbolic
+
+
+
-
- True
- False
- slide-up
-
-
- True
- False
-
-
- cancel
- True
- True
- True
-
-
-
- end
- 1
-
-
-
-
- remove
- True
- True
- True
-
-
-
- end
- 0
-
-
-
-
-
-
- False
- True
- end
- 1
-
-
-
-
- page2
- page2
-
-
-
-
- True
- False
- vertical
-
-
- True
- False
-
-
- True
- False
-
-
- standalone-spinne
-
-
-
-
+
True
True
- False
- False
-
+ True
+ Clear the playlist
+
-
- True
- False
-
-
+
True
False
- gtk-missing-image
- 6
-
-
-
+ edit-clear
+
-
-
- standalone-scroll
- 1
-
-
-
-
- True
- True
- 0
-
+
+
+
-
- True
- False
-
-
- remove
- True
- True
- True
-
-
-
- end
- 1
-
-
-
-
- play
- True
- True
- True
-
-
-
- end
- 0
-
-
-
-
- False
- True
- 1
-
+
+ slide-left-right
+
+
+ vertical
+
+
+ true
+
+
+ vertical
+
+ true
+
+
+
+
+
+
+
+
+
+ true
+
+
+ vertical
+
+
+ contain
+ false
+
+
+ GtkListItem
+
+
+
+
+ GtkListItem
+
+
+
+
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+ slide-up
+
+
+
+
+ cancel
+ True
+
+
+
+
+
+ remove
+ True
+
+
+
+
+
+
+
+
+
+
+
+ vertical
+
+
+
+
+ True
+ False
+
+
+
+
+ True
+ True
+ False
+ False
+
+
+
+ True
+ False
+
+
+ gtk-missing-image
+
+
+
+
+
+
+
+
+
+
+
+
+
+ remove
+ True
+
+
+
+
+
+ play
+ True
+
+
+
+
+
+
+
+
-
-
- page1
- page1
- 1
-
-
-
+
diff --git a/data/ui/playlist-toolbar.ui b/data/ui/playlist-toolbar.ui
deleted file mode 100644
index 843625c..0000000
--- a/data/ui/playlist-toolbar.ui
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
- True
- False
- 6
- end
-
-
- True
- True
- True
- Select multiple albums
-
-
-
- True
- False
- object-select-symbolic
-
-
-
-
- False
- False
- 0
- True
-
-
-
-
- True
- True
- True
- Clear the playlist
-
-
-
- True
- False
- edit-clear
-
-
-
-
- False
- False
- 1
- True
-
-
-
-
diff --git a/data/ui/server-panel.ui b/data/ui/server-panel.ui
index 333919d..91ffe99 100644
--- a/data/ui/server-panel.ui
+++ b/data/ui/server-panel.ui
@@ -1,547 +1,326 @@
-
-
-
- True
- False
-
-
-
- False
- True
- 0
-
-
-
-
- True
- False
+
+
+
+ horizontal
+ end
-
- True
- False
-
-
- True
- False
- vertical
-
-
- True
- False
- 5
- 5
- 5
- 5
- vertical
- 10
-
-
- True
- False
- dialog-information-symbolic
- 6
-
-
- False
- True
- 0
-
-
-
-
-
- True
- False
- 2
- 5
-
-
- True
- False
- start
- start
- File:
-
-
- 0
- 0
-
-
-
-
- True
- False
- start
- start
- Audio:
-
-
- 0
- 1
-
-
-
-
- True
- False
- start
- start
- Bitrate:
-
-
- 0
- 2
-
-
-
-
- True
- False
- start
- start
- Error:
-
-
- 0
- 3
-
-
-
-
- True
- False
- start
- <i>none</i>
- True
- True
- True
- 0
-
-
- 1
- 2
-
-
-
-
- True
- False
- start
- <i>none</i>
- True
- True
- True
- 0
-
-
- 1
- 1
-
-
-
-
- True
- False
- start
- <i>none</i>
- True
- True
- True
- 0
-
-
- 1
- 0
-
-
-
-
- True
- False
- start
- <i>none</i>
- True
- True
- True
- 0
-
-
- 1
- 3
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
- True
- 1
-
-
-
-
- False
- True
- 1
-
-
-
-
-
-
-
- False
- True
- 1
-
-
-
-
-
-
-
- page0
- Status
-
+
+
+
-
- True
- False
-
-
- True
- False
- vertical
-
-
- True
- False
- vertical
- 10
-
-
- True
- False
- starred-symbolic
- 6
-
-
- False
- True
- 0
-
-
-
-
-
- True
- False
- 2
- 5
+
+ end
+
+
+
+
+
+
+
+
+
-
- True
- False
- end
- right
- True
-
-
- 0
- 0
-
+
+ status
+ Status
+
+
+ dialog-information-symbolic
+
+
+ 2
+ 5
+ false
+ center
+
+
+ start
+ start
+ File:
+
+ 0
+ 0
+
+
+
+
+
+ start
+ start
+ Audio:
+
+ 0
+ 1
+
+
+
+
+
+ start
+ start
+ Bitrate:
+
+ 0
+ 2
+
+
+
+
+
+ start
+ start
+ Error:
+
+ 0
+ 3
+
+
+
+
+
+ start
+ <i>none</i>
+ True
+ True
+ True
+ 0
+
+ 1
+ 0
+
+
+
+
+
+ start
+ <i>none</i>
+ True
+ True
+ True
+ 0
+
+ 1
+ 1
+
+
+
+
+
+ start
+ <i>none</i>
+ True
+ True
+ True
+ 0
+
+ 1
+ 2
+
+
+
+
+
+ start
+ <i>none</i>
+ True
+ True
+ True
+ 0
+
+ 1
+ 3
+
+
+
+
+
+
+
+
-
- True
- False
- end
- right
-
-
- 0
- 1
-
+
+ stats
+ Statistics
+
+
+ starred-symbolic
+
+
+ 2
+ 5
+ true
+ false
+ center
+
+
+ end
+ right
+
+ 0
+ 0
+
+
+
+
+
+ start
+ Artists
+
+ 1
+ 0
+
+
+
+
+
+ end
+ right
+
+ 0
+ 1
+
+
+
+
+
+ start
+ Albums
+
+ 1
+ 1
+
+
+
+
+
+ end
+ right
+
+ 0
+ 2
+
+
+
+
+
+ start
+ Songs
+
+ 1
+ 2
+
+
+
+
+
+ end
+ right
+
+ 0
+ 3
+
+
+
+
+
+ start
+ Seconds
+
+ 1
+ 3
+
+
+
+
+
+
+ 0
+ 4
+ 2
+
+
+
+
+
+ end
+ right
+
+ 0
+ 5
+
+
+
+
+
+ start
+ Seconds played
+
+ 1
+ 5
+
+
+
+
+
+ end
+ right
+
+ 0
+ 6
+
+
+
+
+
+ start
+ Seconds running
+
+ 1
+ 6
+
+
+
+
+
+
+
+
-
- True
- False
- end
- right
-
-
- 0
- 2
-
+
+ devices
+ Audio Devices
+
+
+ audio-speakers-symbolic
+
+
+ false
+ center
+ none
+
+
+
+
+
+
-
-
- True
- False
- start
- Albums
-
-
- 1
- 1
-
-
-
-
- True
- False
- start
- Songs
-
-
- 1
- 2
-
-
-
-
- True
- False
- start
- Artists
-
-
- 1
- 0
-
-
-
-
- True
- False
- end
- right
-
-
- 0
- 3
-
-
-
-
- True
- False
- start
- Seconds
-
-
- 1
- 3
-
-
-
-
- True
- False
- end
- right
-
-
- 0
- 6
-
-
-
-
- True
- False
- end
- right
-
-
- 0
- 5
-
-
-
-
- True
- False
-
-
- 0
- 4
- 2
-
-
-
-
- True
- False
- start
- Seconds played
-
-
- 1
- 5
-
-
-
-
- True
- False
- Seconds running
-
-
- 1
- 6
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
- True
- 1
-
-
-
-
- False
- True
- 1
-
-
-
-
-
-
-
- False
- True
- 1
-
-
-
-
-
-
-
- page1
- Statistics
- 1
-
+
+
+
-
-
- True
- False
-
-
- True
- False
- vertical
-
-
- True
- False
- vertical
- 10
-
-
- True
- False
- audio-speakers-symbolic
- 6
-
-
- False
- True
- 0
-
-
-
-
- True
- False
- none
-
-
-
- False
- True
- 1
-
-
-
-
- False
- True
- 1
-
-
-
-
-
-
-
- False
- True
- 1
-
-
-
-
-
-
-
- page2
- Audio Devices
- 2
-
-
-
-
- True
- True
- 1
-
-
-
+
diff --git a/data/ui/server-toolbar.ui b/data/ui/server-toolbar.ui
deleted file mode 100644
index c1857a4..0000000
--- a/data/ui/server-toolbar.ui
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- True
- False
- vertical
- start
-
-
-
-
-
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 5e24217..420be73 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -1,229 +1,74 @@
-
-
-
- False
- xyz.suruatoel.mcg
-
-
-
-
- True
- False
-
-
- True
- False
- 100
- crossfade
-
-
- True
- False
-
-
-
-
-
- page0
- page0
-
-
-
-
- -1
-
-
-
-
- True
- False
- start
-
-
- False
- start
- 10
- 10
+
+
+
+
+
vertical
- top
- True
-
-
-
-
- False
-
-
- False
- False
- 0
-
+
+
-
-
- False
-
-
- True
- False
-
-
- False
- True
- 0
-
-
-
-
- False
- False
- 0
-
+
+
+
+
+ content_stack
+ true
+
+
+ true
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+ panel_stack
+
+ headerbar_panel_switcher
+
+
+
+
+
+
diff --git a/data/xyz.suruatoel.mcg.gresource.xml b/data/xyz.suruatoel.mcg.gresource.xml
index 9ebd10e..3511840 100644
--- a/data/xyz.suruatoel.mcg.gresource.xml
+++ b/data/xyz.suruatoel.mcg.gresource.xml
@@ -4,18 +4,16 @@
gtk.css
noise-texture.png
ui/window.ui
+
ui/connection-panel.ui
ui/album-headerbar.ui
- ui/server-toolbar.ui
ui/server-panel.ui
- ui/cover-toolbar.ui
ui/cover-panel.ui
- ui/playlist-toolbar.ui
ui/playlist-panel.ui
- ui/library-toolbar.ui
ui/library-panel.ui
diff --git a/src/albumheaderbar.py b/src/albumheaderbar.py
index 1c3e892..ab6607a 100644
--- a/src/albumheaderbar.py
+++ b/src/albumheaderbar.py
@@ -2,15 +2,16 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
-from gi.repository import Gtk, GObject
+from gi.repository import Gtk, GObject, Adw
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/album-headerbar.ui')
-class AlbumHeaderbar(Gtk.HeaderBar):
+class AlbumHeaderbar(Adw.Bin):
__gtype_name__ = 'McgAlbumHeaderbar'
__gsignals__ = {
'close': (GObject.SIGNAL_RUN_FIRST, None, ())
diff --git a/src/application.py b/src/application.py
index c9f18e6..e3a92c4 100644
--- a/src/application.py
+++ b/src/application.py
@@ -5,11 +5,12 @@ import logging
import urllib
import gi
-gi.require_version('Gtk', '3.0')
-from gi.repository import Gio, Gtk, Gdk, GLib
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
+from gi.repository import Gio, Gtk, Gdk, GLib, Adw
from .window import Window
-from .infodialog import InfoDialog
+#from .infodialog import InfoDialog
@@ -38,6 +39,7 @@ class Application(Gtk.Application):
self._load_css()
self._setup_actions()
self._load_appmenu()
+ self._setup_adw()
def do_activate(self):
@@ -48,10 +50,12 @@ class Application(Gtk.Application):
def on_menu_info(self, action, value):
- if not self._info_dialog:
- self._info_dialog = InfoDialog()
- self._info_dialog.run()
- self._info_dialog.hide()
+ # FIXME Info dialog
+ #if not self._info_dialog:
+ # self._info_dialog = InfoDialog()
+ #self._info_dialog.run()
+ #self._info_dialog.hide()
+ pass
def on_menu_quit(self, action, value):
@@ -70,15 +74,15 @@ class Application(Gtk.Application):
def _set_default_settings(self):
- settings = Gtk.Settings.get_default()
- settings.set_property('gtk-application-prefer-dark-theme', True)
+ style_manager = Adw.StyleManager.get_default()
+ style_manager.set_color_scheme(Adw.ColorScheme.PREFER_DARK)
def _load_css(self):
styleProvider = Gtk.CssProvider()
styleProvider.load_from_resource(self._get_resource_path('gtk.css'))
- Gtk.StyleContext.add_provider_for_screen(
- Gdk.Screen.get_default(),
+ Gtk.StyleContext.add_provider_for_display(
+ Gdk.Display.get_default(),
styleProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
@@ -95,10 +99,23 @@ class Application(Gtk.Application):
def _load_appmenu(self):
builder = Gtk.Builder()
- builder.set_translation_domain(Application.DOMAIN)
- builder.add_from_resource(self._get_resource_path('ui/gtk.menu.ui'))
- self.set_app_menu(builder.get_object('app-menu'))
+ # FIXME Handle menu
+ #builder.set_translation_domain(Application.DOMAIN)
+ #builder.add_from_resource(self._get_resource_path('ui/gtk.menu.ui'))
+ #self.set_app_menu(builder.get_object('app-menu'))
def _get_resource_path(self, path):
return "/{}/{}".format(Application.ID.replace('.', '/'), path)
+
+
+ def _setup_adw(self):
+ Adw.HeaderBar()
+ Adw.ViewSwitcherTitle()
+ Adw.ViewSwitcherBar()
+ Adw.ViewStackPage()
+ Adw.ToastOverlay()
+ Adw.StatusPage()
+ Adw.Flap()
+ Adw.EntryRow()
+ Adw.PasswordEntryRow()
diff --git a/src/connectionpanel.py b/src/connectionpanel.py
index 1ba5f7e..9d5cd63 100644
--- a/src/connectionpanel.py
+++ b/src/connectionpanel.py
@@ -2,9 +2,11 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
+import locale
-from gi.repository import Gtk, GObject
+from gi.repository import Gtk, Gio, GObject, Adw
from mcg.zeroconf import ZeroconfProvider
@@ -12,56 +14,58 @@ from mcg.zeroconf import ZeroconfProvider
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/connection-panel.ui')
-class ConnectionPanel(Gtk.Box):
+class ConnectionPanel(Adw.Bin):
__gtype_name__ = 'McgConnectionPanel'
__gsignals__ = {
'connection-changed': (GObject.SIGNAL_RUN_FIRST, None, (str, int, str))
}
# Widgets
+ toolbar = Gtk.Template.Child()
zeroconf_list = Gtk.Template.Child()
- host_entry = Gtk.Template.Child()
+ host_row = Gtk.Template.Child()
port_spinner = Gtk.Template.Child()
- password_entry = Gtk.Template.Child()
+ password_row = Gtk.Template.Child()
- def __init__(self):
- super().__init__()
- self._services = Gtk.ListStore(str, str, int)
- self._profile = None
-
- # Zeroconf
- self.zeroconf_list.set_model(self._services)
- renderer = Gtk.CellRendererText()
- column = Gtk.TreeViewColumn("Zeroconf", renderer, text=0)
- self.zeroconf_list.append_column(column)
+ def __init__(self, **kwargs):
+ super().__init__(**kwargs)
# Zeroconf provider
self._zeroconf_provider = ZeroconfProvider()
self._zeroconf_provider.connect_signal(ZeroconfProvider.SIGNAL_SERVICE_NEW, self.on_new_service)
+ def get_toolbar(self):
+ return self.toolbar
+
+
+ def set_selected(self, selected):
+ pass
+
+
def on_new_service(self, service):
name, host, port = service
- self._services.append([name, host, port])
+
+ row_button = Gtk.Button()
+ row_button.set_label(locale.gettext("use"))
+ row_button.connect("clicked", self.on_service_selected, host, port)
+
+ row = Adw.ActionRow()
+ row.set_title(name)
+ row.set_subtitle("{} ({})".format(host, port))
+ row.add_suffix(row_button)
+
+ self.zeroconf_list.insert(row, -1)
+
+
+ def on_service_selected(self, widget, host, port):
+ self.set_host(host)
+ self.set_port(port)
@Gtk.Template.Callback()
- def on_service_selected(self, selection):
- model, treeiter = selection.get_selected()
- if treeiter != None:
- service = model[treeiter]
- self.set_host(service[1])
- self.set_port(service[2])
-
-
- @Gtk.Template.Callback()
- def on_zeroconf_list_outfocused(self, widget, event):
- self.zeroconf_list.get_selection().unselect_all()
-
-
- @Gtk.Template.Callback()
- def on_host_entry_outfocused(self, widget, event):
+ def on_host_entry_apply(self, widget):
self._call_back()
@@ -70,17 +74,12 @@ class ConnectionPanel(Gtk.Box):
self._call_back()
- @Gtk.Template.Callback()
- def on_password_entry_outfocused(self, widget, event):
- self._call_back()
-
-
def set_host(self, host):
- self.host_entry.set_text(host)
+ self.host_row.set_text(host)
def get_host(self):
- return self.host_entry.get_text()
+ return self.host_row.get_text()
def set_port(self, port):
@@ -94,11 +93,11 @@ class ConnectionPanel(Gtk.Box):
def set_password(self, password):
if password is None:
password = ""
- self.password_entry.set_text(password)
+ self.password_row.set_text(password)
def get_password(self):
- if self.password_entry.get_text() == "":
+ if self.password_row.get_text() == "":
return None
else:
return self.password_entry.get_text()
diff --git a/src/coverpanel.py b/src/coverpanel.py
index 102b69c..a3adb52 100644
--- a/src/coverpanel.py
+++ b/src/coverpanel.py
@@ -2,7 +2,7 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
import logging
import math
@@ -13,27 +13,6 @@ from mcg.utils import Utils
-@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/cover-toolbar.ui')
-class CoverToolbar(Gtk.ButtonBox):
- __gtype_name__ = 'McgCoverToolbar'
- __gsignals__ = {
- 'fullscreen': (GObject.SIGNAL_RUN_FIRST, None, ())
- }
-
- # Widgets
- fullscreen_button = Gtk.Template.Child()
-
-
- def __init__(self):
- super().__init__()
-
-
- def set_fullscreen_sensitive(self, sensitive):
- self.fullscreen_button.set_sensitive(sensitive)
-
-
-
-
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/cover-panel.ui')
class CoverPanel(Gtk.Overlay):
__gtype_name__ = 'McgCoverPanel'
@@ -44,9 +23,13 @@ class CoverPanel(Gtk.Overlay):
}
# Widgets
+ # Toolbar
+ toolbar = Gtk.Template.Child()
+ fullscreen_button = Gtk.Template.Child()
# Cover
cover_stack = Gtk.Template.Child()
cover_spinner = Gtk.Template.Child()
+ cover_default = Gtk.Template.Child()
cover_scroll = Gtk.Template.Child()
cover_box = Gtk.Template.Child()
cover_image = Gtk.Template.Child()
@@ -61,22 +44,20 @@ class CoverPanel(Gtk.Overlay):
- def __init__(self):
- super().__init__()
+ def __init__(self, **kwargs):
+ super().__init__(**kwargs)
self._current_album = None
self._current_cover_album = None
self._cover_pixbuf = None
self._timer = None
self._properties = {}
- self._icon_theme = Gtk.IconTheme.get_default()
+ self._icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
self._fullscreened = False
- self._is_selected = False
self._current_size = None
- self._cover_pixbuf = self._get_default_image()
+ #self._cover_pixbuf = self._get_default_image()
# Widgets
- self._toolbar = CoverToolbar()
self.cover_stack.set_visible_child(self.cover_scroll)
# Initial actions
@@ -84,33 +65,34 @@ class CoverPanel(Gtk.Overlay):
def get_toolbar(self):
- return self._toolbar
+ return self.toolbar
def set_selected(self, selected):
- self._is_selected = selected
+ pass
- @Gtk.Template.Callback()
- def on_cover_box_pressed(self, widget, event):
- if self._current_album and event.type == Gdk.EventType._2BUTTON_PRESS:
- self.emit('toggle-fullscreen')
+ # FIXME on_cover_box_pressed()
+ #@Gtk.Template.Callback()
+ #def on_cover_box_pressed(self, widget, event):
+ # if self._current_album and event.type == Gdk.EventType._2BUTTON_PRESS:
+ # self.emit('toggle-fullscreen')
- @Gtk.Template.Callback()
- def on_cover_size_allocate(self, widget, allocation):
+ def set_width(self, width):
GObject.idle_add(self._resize_image)
- self.cover_info_scroll.set_max_content_width(allocation.width // 2)
+ self.cover_info_scroll.set_max_content_width(width // 2)
- @Gtk.Template.Callback()
- def on_songs_start_change(self, widget, event):
- if self._timer:
- GObject.source_remove(self._timer)
- self._timer = None
+ # FIXME on_songs_start_change()
+ #@Gtk.Template.Callback()
+ #def on_songs_start_change(self, widget, event):
+ # if self._timer:
+ # GObject.source_remove(self._timer)
+ # self._timer = None
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_songs_change(self, widget, event):
value = int(self.songs_scale.get_value())
time = self._current_album.get_length()
@@ -144,7 +126,7 @@ class CoverPanel(Gtk.Overlay):
# Set current album
self._current_album = album
self._enable_tracklist()
- self._toolbar.set_fullscreen_sensitive(self._current_album is not None)
+ self.fullscreen_button.set_sensitive(self._current_album is not None)
def set_play(self, pos, time):
@@ -186,10 +168,11 @@ class CoverPanel(Gtk.Overlay):
self._cover_pixbuf = Utils.load_pixbuf(data)
except Exception as e:
self._logger.exception("Failed to set albumart")
- self._cover_pixbuf = self._get_default_image()
+ self._cover_pixbuf = None
else:
# Reset image
self._cover_pixbuf = self._get_default_image()
+ self._cover_pixbuf = None
self._current_size = None
self._current_cover_album = album
# Show image
@@ -236,8 +219,11 @@ class CoverPanel(Gtk.Overlay):
def _show_image(self):
- self._resize_image()
- self.cover_stack.set_visible_child(self.cover_scroll)
+ if self._cover_pixbuf:
+ self._resize_image()
+ self.cover_stack.set_visible_child(self.cover_scroll)
+ else:
+ self.cover_stack.set_visible_child(self.cover_default)
self.cover_spinner.stop()
@@ -245,12 +231,15 @@ class CoverPanel(Gtk.Overlay):
"""Diese Methode skaliert das geladene Bild aus dem Pixelpuffer
auf die Größe des Fensters unter Beibehalt der Seitenverhältnisse
"""
- # Get size
- size = self.cover_scroll.get_allocation()
+ # FIXME Get size
+ size_width = self.cover_stack.get_size(Gtk.Orientation.HORIZONTAL)
+ size_height = self.cover_stack.get_size(Gtk.Orientation.HORIZONTAL)
# Abort if size is the same
- if self._current_size and size.width == self._current_size.width and size.height == self._current_size.height:
- return
- self._current_size = size
+ if self._current_size:
+ current_width, current_height = self._current_size
+ if size_width == current_width and size_height == current_height:
+ return
+ self._current_size = (size_width, size_height,)
# Get pixelbuffer
pixbuf = self._cover_pixbuf
@@ -259,8 +248,8 @@ class CoverPanel(Gtk.Overlay):
return
# Skalierungswert für Breite und Höhe ermitteln
- ratioW = float(size.width) / float(pixbuf.get_width())
- ratioH = float(size.height) / float(pixbuf.get_height())
+ ratioW = float(size_width) / float(pixbuf.get_width())
+ ratioH = float(size_height) / float(pixbuf.get_height())
# Kleineren beider Skalierungswerte nehmen, nicht Hochskalieren
ratio = min(ratioW, ratioH)
ratio = min(ratio, 1)
@@ -269,15 +258,7 @@ class CoverPanel(Gtk.Overlay):
height = int(math.floor(pixbuf.get_height()*ratio))
if width <= 0 or height <= 0:
return
- # Pixelpuffer auf Oberfläche zeichnen
- self.cover_image.set_allocation(self.cover_scroll.get_allocation())
+ # FIXME Pixelpuffer auf Oberfläche zeichnen
+ #self.cover_image.set_allocation(self.cover_scroll.get_allocation())
self.cover_image.set_from_pixbuf(pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.HYPER))
self.cover_image.show()
-
-
- def _get_default_image(self):
- return self._icon_theme.load_icon(
- Utils.STOCK_ICON_DEFAULT,
- 512,
- Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE
- )
diff --git a/src/librarypanel.py b/src/librarypanel.py
index 48b5342..79c85f6 100644
--- a/src/librarypanel.py
+++ b/src/librarypanel.py
@@ -2,120 +2,26 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
import locale
import logging
import math
import threading
-from gi.repository import Gtk, GObject, GdkPixbuf
+from gi.repository import Gtk, Gdk, GObject, GdkPixbuf, Gio, Adw
from mcg import client
from mcg.albumheaderbar import AlbumHeaderbar
from mcg.utils import SortOrder
from mcg.utils import Utils
-
-
-
-
-@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/library-toolbar.ui')
-class LibraryToolbar(Gtk.ButtonBox):
- __gtype_name__ = 'McgLibraryToolbar'
- __gsignals__ = {
- 'select': (GObject.SIGNAL_RUN_FIRST, None, (bool,)),
- 'toggle-search': (GObject.SIGNAL_RUN_FIRST, None, (bool,)),
- 'update': (GObject.SIGNAL_RUN_FIRST, None, ()),
- 'start-scale': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
- 'end-scale': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
- 'sort': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
- 'sort-type': (GObject.SIGNAL_RUN_FIRST, None, (Gtk.SortType,))
- }
-
- # Widgets
- select_button = Gtk.Template.Child()
- toolbar_search_bar = Gtk.Template.Child()
- toolbar_popover = Gtk.Template.Child()
- toolbar_sort_order_button = Gtk.Template.Child()
- sort_artist = Gtk.Template.Child()
- sort_title = Gtk.Template.Child()
- sort_year = Gtk.Template.Child()
- grid_scale = Gtk.Template.Child()
-
-
- def __init__(self, item_size):
- super().__init__()
-
- # Toolbar menu
- self.grid_scale.set_value(item_size)
- self._toolbar_sort_buttons = {
- SortOrder.ARTIST: self.sort_artist,
- SortOrder.TITLE: self.sort_title,
- SortOrder.YEAR: self.sort_year
- }
-
-
- @Gtk.Template.Callback()
- def on_select_toggled(self, widget):
- self.emit('select', widget.get_active())
-
-
- @Gtk.Template.Callback()
- def on_search_toggled(self, widget):
- self.emit('toggle-search', widget.get_active())
-
-
- @Gtk.Template.Callback()
- def on_update_clicked(self, widget):
- self.emit('update')
-
-
- @Gtk.Template.Callback()
- def on_grid_scale_change(self, widget, scroll, value):
- self.emit('start-scale', value)
-
-
- @Gtk.Template.Callback()
- def on_grid_scale_changed(self, widget, event):
- self.emit('end-scale', self.grid_scale.get_value())
- self.toolbar_popover.popdown()
-
-
- @Gtk.Template.Callback()
- def on_sort_toggled(self, widget):
- if widget.get_active():
- sort = [key for key, value in self._toolbar_sort_buttons.items() if value is widget][0]
- self.emit('sort', sort)
-
-
- @Gtk.Template.Callback()
- def on_sort_order_toggled(self, button):
- if button.get_active():
- sort_type = Gtk.SortType.DESCENDING
- else:
- sort_type = Gtk.SortType.ASCENDING
- self.emit('sort-type', sort_type)
-
-
- def get_grid_scale(self):
- return self.grid_scale
-
-
- def is_search_active(self):
- return self.toolbar_search_bar.get_active()
-
-
- def set_search_active(self, active):
- self.toolbar_search_bar.set_active(active)
-
-
- def exit_selection(self):
- self.select_button.set_active(False)
+from mcg.utils import GridItem
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/library-panel.ui')
-class LibraryPanel(Gtk.Stack):
+class LibraryPanel(Adw.Bin):
__gtype_name__ = 'McgLibraryPanel'
__gsignals__ = {
'open-standalone': (GObject.SIGNAL_RUN_FIRST, None, ()),
@@ -127,13 +33,31 @@ class LibraryPanel(Gtk.Stack):
'item-size-changed': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
'sort-order-changed': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
'sort-type-changed': (GObject.SIGNAL_RUN_FIRST, None, (Gtk.SortType,)),
- 'albumart': (GObject.SIGNAL_RUN_FIRST, None, (str,))
+ 'albumart': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
+
+ 'select': (GObject.SIGNAL_RUN_FIRST, None, (bool,)),
+ 'toggle-search': (GObject.SIGNAL_RUN_FIRST, None, (bool,)),
+ 'update': (GObject.SIGNAL_RUN_FIRST, None, ()),
+ 'start-scale': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
+ 'end-scale': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
+ 'sort': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
+ 'sort-type': (GObject.SIGNAL_RUN_FIRST, None, (Gtk.SortType,))
}
# Widgets
panel_standalone = Gtk.Template.Child()
actionbar_revealer = Gtk.Template.Child()
+ # Toolbar
+ toolbar = Gtk.Template.Child()
+ select_button = Gtk.Template.Child()
+ toolbar_search_bar = Gtk.Template.Child()
+ toolbar_popover = Gtk.Template.Child()
+ toolbar_sort_order_button = Gtk.Template.Child()
+ sort_artist = Gtk.Template.Child()
+ sort_title = Gtk.Template.Child()
+ sort_year = Gtk.Template.Child()
+ grid_scale = Gtk.Template.Child()
# Filter/search bar
filter_bar = Gtk.Template.Child()
filter_entry = Gtk.Template.Child()
@@ -152,8 +76,8 @@ class LibraryPanel(Gtk.Stack):
standalone_image = Gtk.Template.Child()
- def __init__(self, client):
- super().__init__()
+ def __init__(self, client, **kwargs):
+ super().__init__(**kwargs)
self._logger = logging.getLogger(__name__)
self._client = client
self._buttons = {}
@@ -167,37 +91,37 @@ class LibraryPanel(Gtk.Stack):
self._old_ranges = {}
self._library_lock = threading.Lock()
self._library_stop = threading.Event()
- self._icon_theme = Gtk.IconTheme.get_default()
+ self._icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
self._standalone_pixbuf = None
self._selected_albums = []
self._allocation = (0, 0)
self._is_selected = False
# Widgets
- self._toolbar = LibraryToolbar(self._item_size)
- self._toolbar.connect('select', self.on_toolbar_select)
- self._toolbar.connect('toggle-search', self.on_toolbar_toggle_search)
- self._toolbar.connect('update', self.on_toolbar_update)
- self._toolbar.connect('start-scale', self.on_toolbar_scale)
- self._toolbar.connect('end-scale', self.on_toolbar_scaled)
- self._toolbar.connect('sort', self.on_toolbar_sort)
- self._toolbar.connect('sort-type', self.on_toolbar_sort_type)
+ # FIXME Toolbar signals
+ #self._toolbar.connect('select', self.on_toolbar_select)
+ #self._toolbar.connect('toggle-search', self.on_toolbar_toggle_search)
+ #self._toolbar.connect('update', self.on_toolbar_update)
+ #self._toolbar.connect('start-scale', self.on_toolbar_scale)
+ #self._toolbar.connect('end-scale', self.on_toolbar_scaled)
+ #self._toolbar.connect('sort', self.on_toolbar_sort)
+ #self._toolbar.connect('sort-type', self.on_toolbar_sort_type)
# Header bar
self._headerbar_standalone = AlbumHeaderbar()
self._headerbar_standalone.connect('close', self.on_standalone_close_clicked)
- # Progress Bar
- self.progress_image.set_from_pixbuf(self._get_default_image())
# Library Grid: Model
- self._library_grid_model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)
- self._library_grid_model.set_sort_func(2, self.compare_albums, self._sort_order)
- self._library_grid_model.set_sort_column_id(2, self._sort_type)
- self._library_grid_filter = self._library_grid_model.filter_new()
- self._library_grid_filter.set_visible_func(self.on_filter_visible)
+ self._library_grid_model = Gio.ListStore()
+ self._library_grid_selection = Gtk.MultiSelection.new(self._library_grid_model)
+ self._library_grid_filter = self._library_grid_selection
# Library Grid
self.library_grid.set_model(self._library_grid_filter)
- self.library_grid.set_pixbuf_column(0)
- self.library_grid.set_text_column(-1)
- self.library_grid.set_tooltip_column(1)
+ # Toolbar menu
+ self.grid_scale.set_value(self._item_size)
+ self._toolbar_sort_buttons = {
+ SortOrder.ARTIST: self.sort_artist,
+ SortOrder.TITLE: self.sort_title,
+ SortOrder.YEAR: self.sort_year
+ }
def get_headerbar_standalone(self):
@@ -205,30 +129,75 @@ class LibraryPanel(Gtk.Stack):
def get_toolbar(self):
- return self._toolbar
+ return self.toolbar
def set_selected(self, selected):
self._is_selected = selected
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
+ def on_select_toggled(self, widget):
+ self.emit('select', widget.get_active())
+
+
+ #@Gtk.Template.Callback()
+ def on_search_toggled(self, widget):
+ self.emit('toggle-search', widget.get_active())
+
+
+ #@Gtk.Template.Callback()
+ def on_update_clicked(self, widget):
+ self.emit('update')
+
+
+ # FXME on_grid_scale_changed
+ #@Gtk.Template.Callback()
+ def on_grid_scale_change(self, widget, scroll, value):
+ self.emit('start-scale', value)
+
+
+ # FXME on_grid_scale_changed
+ #@Gtk.Template.Callback()
+ def on_grid_scale_changed(self, widget, event):
+ self.emit('end-scale', self.grid_scale.get_value())
+ self.toolbar_popover.popdown()
+
+
+ #@Gtk.Template.Callback()
+ def on_sort_toggled(self, widget):
+ if widget.get_active():
+ sort = [key for key, value in self._toolbar_sort_buttons.items() if value is widget][0]
+ self.emit('sort', sort)
+
+
+ #@Gtk.Template.Callback()
+ def on_sort_order_toggled(self, button):
+ if button.get_active():
+ sort_type = Gtk.SortType.DESCENDING
+ else:
+ sort_type = Gtk.SortType.ASCENDING
+ self.emit('sort-type', sort_type)
+
+
+ # FIXME on_resize()
+ #@Gtk.Template.Callback()
def on_resize(self, widget, event):
new_allocation = (widget.get_allocation().width, widget.get_allocation().height)
if new_allocation == self._allocation:
return
self._allocation = new_allocation
- self._toolbar.get_grid_scale().clear_marks()
+ self.grid_scale.clear_marks()
width = widget.get_allocation().width
- lower = int(self._toolbar.get_grid_scale().get_adjustment().get_lower())
- upper = int(self._toolbar.get_grid_scale().get_adjustment().get_upper())
+ lower = int(self.grid_scale.get_adjustment().get_lower())
+ upper = int(self.grid_scale.get_adjustment().get_upper())
countMin = max(int(width / upper), 1)
countMax = max(int(width / lower), 1)
for index in range(countMin, countMax):
pixel = int(width / index)
pixel = pixel - (2 * int(pixel / 100))
- self._toolbar.get_grid_scale().add_mark(
+ self.grid_scale.add_mark(
pixel,
Gtk.PositionType.BOTTOM,
None
@@ -256,17 +225,17 @@ class LibraryPanel(Gtk.Stack):
def on_toolbar_scale(self, widget, value):
size = math.floor(value)
- range = self._toolbar.get_grid_scale().get_adjustment()
+ range = self.grid_scale.get_adjustment()
if size < range.get_lower() or size > range.get_upper():
return
self._item_size = size
- GObject.idle_add(self.library_grid.set_item_padding, size / 100)
+ #GObject.idle_add(self.library_grid.set_item_padding, size / 100)
GObject.idle_add(self._set_widget_grid_size, self.library_grid, size, True)
def on_toolbar_scaled(self, widget, value):
size = round(value)
- range = self._toolbar.get_grid_scale().get_adjustment()
+ range = self.grid_scale.get_adjustment()
if size < range.get_lower() or size > range.get_upper():
return False
self.emit('item-size-changed', size)
@@ -280,23 +249,24 @@ class LibraryPanel(Gtk.Stack):
def on_toolbar_sort_type(self, widget, sort_type):
self._sort_type = sort_type
- self._library_grid_model.set_sort_column_id(2, sort_type)
+ #self._library_grid_model.set_sort_column_id(2, sort_type)
self.emit('sort-type-changed', sort_type)
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_filter_bar_notify(self, widget, value):
- if self._toolbar.is_search_active() is not self.filter_bar.get_search_mode():
- self._toolbar.set_search_active(self.filter_bar.get_search_mode())
+ if self.toolbar_search_bar.get_active() is not self.filter_bar.get_search_mode():
+ self.toolbar_search_bar.set_active(self.filter_bar.get_search_mode())
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_filter_entry_changed(self, widget):
self._filter_string = self.filter_entry.get_text()
GObject.idle_add(self._library_grid_filter.refilter)
- @Gtk.Template.Callback()
+ # FIXME on_library_grid_clicked()
+ #@Gtk.Template.Callback()
def on_library_grid_clicked(self, widget, path):
# Get selected album
path = self._library_grid_filter.convert_path_to_child_path(path)
@@ -319,7 +289,8 @@ class LibraryPanel(Gtk.Stack):
self.standalone_spinner.start()
- @Gtk.Template.Callback()
+ # FIXME on_library_grid_selection_changed()
+ #@Gtk.Template.Callback()
def on_library_grid_selection_changed(self, widget):
self._selected_albums = []
for path in widget.get_selected_items():
@@ -337,30 +308,31 @@ class LibraryPanel(Gtk.Stack):
return album.filter(self._filter_string)
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_selection_cancel_clicked(self, widget):
- self._toolbar.exit_selection()
+ self.select_button.set_active(False)
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_selection_add_clicked(self, widget):
ids = [album.get_id() for album in self._selected_albums]
self.emit('queue-multiple', ids)
- self._toolbar.exit_selection()
+ self.select_button.set_active(False)
- @Gtk.Template.Callback()
+ # FIXME on_standalone_scroll_size_allocate()
+ #@Gtk.Template.Callback()
def on_standalone_scroll_size_allocate(self, widget, allocation):
self._resize_standalone_image()
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_standalone_play_clicked(self, widget):
self.emit('play', self._selected_albums[0].get_id())
self._close_standalone()
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_standalone_queue_clicked(self, widget):
self.emit('queue', self._selected_albums[0].get_id())
self._close_standalone()
@@ -377,7 +349,7 @@ class LibraryPanel(Gtk.Stack):
def set_item_size(self, item_size):
if self._item_size != item_size:
self._item_size = item_size
- self._toolbar.get_grid_scale().set_value(item_size)
+ self.grid_scale.set_value(item_size)
self._redraw()
@@ -464,6 +436,7 @@ class LibraryPanel(Gtk.Stack):
def _set_albums(self, host, albums, size):
+ """
if not self._is_selected and albums != self._albums:
GObject.idle_add(
self.get_parent().child_set_property,
@@ -471,15 +444,16 @@ class LibraryPanel(Gtk.Stack):
'needs-attention',
True
)
+ """
self._library_lock.acquire()
self._library_stop.clear()
self._albums = albums
GObject.idle_add(self.stack.set_visible_child, self.progress_box)
GObject.idle_add(self.progress_bar.set_fraction, 0.0)
- GObject.idle_add(self.library_grid.set_item_padding, size / 100)
+ #GObject.idle_add(self.library_grid.set_item_padding, size / 100)
self.library_grid.set_model(None)
- self.library_grid.freeze_child_notify()
- self._library_grid_model.clear()
+ #self.library_grid.freeze_child_notify()
+ self._library_grid_model.remove_all()
i = 0
n = len(albums)
@@ -496,23 +470,17 @@ class LibraryPanel(Gtk.Stack):
except Exception as e:
self._logger.exception("Failed to load albumart")
if pixbuf is None:
- pixbuf = self._icon_theme.load_icon(
+ pixbuf = self._icon_theme.lookup_icon(
Utils.STOCK_ICON_DEFAULT,
+ None,
self._item_size,
- Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE
+ self._item_size,
+ Gtk.TextDirection.LTR,
+ Gtk.IconLookupFlags.FORCE_SYMBOLIC
)
if pixbuf is not None:
self._grid_pixbufs[album.get_id()] = pixbuf
- self._library_grid_model.append([
- pixbuf,
- GObject.markup_escape_text("\n".join([
- album.get_title(),
- ', '.join(album.get_dates()),
- Utils.create_artists_label(album),
- Utils.create_length_label(album)
- ])),
- album_id
- ])
+ self._library_grid_model.append(GridItem(album, pixbuf))
i += 1
GObject.idle_add(self.progress_bar.set_fraction, i/n)
@@ -522,8 +490,8 @@ class LibraryPanel(Gtk.Stack):
return
self.library_grid.set_model(self._library_grid_filter)
- self.library_grid.thaw_child_notify()
- self.library_grid.set_item_width(-1)
+ #self.library_grid.thaw_child_notify()
+ #self.library_grid.set_item_width(-1)
self._library_lock.release()
self.stack.set_visible_child(self.scroll)
@@ -632,12 +600,11 @@ class LibraryPanel(Gtk.Stack):
def _get_default_image(self):
- return self._icon_theme.load_icon(
+ return self._icon_theme.lookup_icon(
Utils.STOCK_ICON_DEFAULT,
+ None,
512,
- Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE
+ 512,
+ Gtk.TextDirection.LTR,
+ Gtk.IconLookupFlags.FORCE_SYMBOLIC
)
-
-
-
-
diff --git a/src/main.py b/src/main.py
index d1b5a53..39e5be5 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,6 +1,4 @@
import sys
-import gi
-gi.require_version('Gtk', '3.0')
from .application import Application
diff --git a/src/playlistpanel.py b/src/playlistpanel.py
index a268233..82d4f00 100644
--- a/src/playlistpanel.py
+++ b/src/playlistpanel.py
@@ -2,56 +2,24 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
import logging
import math
import threading
-from gi.repository import Gtk, GObject, GdkPixbuf
+from gi.repository import Gtk, Gdk, Gio, GObject, GdkPixbuf, Adw
from mcg import client
from mcg.albumheaderbar import AlbumHeaderbar
from mcg.utils import Utils
-
-
-
-
-@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/playlist-toolbar.ui')
-class PlaylistToolbar(Gtk.ButtonBox):
- __gtype_name__ = 'McgPlaylistToolbar'
- __gsignals__ = {
- 'select': (GObject.SIGNAL_RUN_FIRST, None, (bool,)),
- 'clear-playlist': (GObject.SIGNAL_RUN_FIRST, None, ())
- }
-
- # Widgets
- playlist_clear_button = Gtk.Template.Child()
- select_button = Gtk.Template.Child()
-
-
- def __init__(self):
- super().__init__()
-
-
- @Gtk.Template.Callback()
- def on_select_toggled(self, widget):
- self.emit('select', widget.get_active())
-
-
- @Gtk.Template.Callback()
- def on_clear_clicked(self, widget):
- if widget is self.playlist_clear_button:
- self.emit('clear-playlist')
-
-
- def exit_selection(self):
- self.select_button.set_active(False)
+from mcg.utils import GridItem
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/playlist-panel.ui')
-class PlaylistPanel(Gtk.Stack):
+class PlaylistPanel(Adw.Bin):
__gtype_name__ = 'McgPlaylistPanel'
__gsignals__ = {
'open-standalone': (GObject.SIGNAL_RUN_FIRST, None, ()),
@@ -60,13 +28,20 @@ class PlaylistPanel(Gtk.Stack):
'remove-album': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
'remove-multiple-albums': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
'play': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
- 'albumart': (GObject.SIGNAL_RUN_FIRST, None, (str,))
+ 'albumart': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
+
+ 'select': (GObject.SIGNAL_RUN_FIRST, None, (bool,)),
+ 'clear-playlist': (GObject.SIGNAL_RUN_FIRST, None, ())
}
# Widgets
panel_standalone = Gtk.Template.Child()
actionbar_revealer = Gtk.Template.Child()
+ # Toolbar
+ toolbar = Gtk.Template.Child()
+ playlist_clear_button = Gtk.Template.Child()
+ select_button = Gtk.Template.Child()
# Playlist Grid
playlist_grid = Gtk.Template.Child()
# Action bar (normal)
@@ -79,8 +54,8 @@ class PlaylistPanel(Gtk.Stack):
standalone_image = Gtk.Template.Child()
- def __init__(self, client):
- GObject.GObject.__init__(self)
+ def __init__(self, client, **kwargs):
+ super().__init__(**kwargs)
self._client = client
self._host = None
self._item_size = 150
@@ -88,25 +63,23 @@ class PlaylistPanel(Gtk.Stack):
self._playlist_albums = None
self._playlist_lock = threading.Lock()
self._playlist_stop = threading.Event()
- self._icon_theme = Gtk.IconTheme.get_default()
+ self._icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
self._standalone_pixbuf = None
self._selected_albums = []
self._is_selected = False
# Widgets
- self._toolbar = PlaylistToolbar()
- self._toolbar.connect('select', self.on_toolbar_select)
- self._toolbar.connect('clear-playlist', self.on_toolbar_clear)
+ # FIXME Toolbar signals
+ #self._toolbar.connect('select', self.on_toolbar_select)
+ #self._toolbar.connect('clear-playlist', self.on_toolbar_clear)
# Header bar
self._headerbar_standalone = AlbumHeaderbar()
self._headerbar_standalone.connect('close', self.on_headerbar_close_clicked)
# Playlist Grid: Model
- self._playlist_grid_model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)
+ self._playlist_grid_model = Gio.ListStore()
+ self._playlist_grid_selection = Gtk.MultiSelection.new(self._playlist_grid_model)
# Playlist Grid
- self.playlist_grid.set_model(self._playlist_grid_model)
- self.playlist_grid.set_pixbuf_column(0)
- self.playlist_grid.set_text_column(-1)
- self.playlist_grid.set_tooltip_column(1)
+ self.playlist_grid.set_model(self._playlist_grid_selection)
def get_headerbar_standalone(self):
@@ -114,7 +87,7 @@ class PlaylistPanel(Gtk.Stack):
def get_toolbar(self):
- return self._toolbar
+ return self.toolbar
def set_selected(self, selected):
@@ -136,16 +109,30 @@ class PlaylistPanel(Gtk.Stack):
self.emit('clear-playlist')
- @Gtk.Template.Callback()
- def on_playlist_grid_clicked(self, widget, path):
- # Get selected album
- iter = self._playlist_grid_model.get_iter(path)
- hash = self._playlist_grid_model.get_value(iter, 2)
- album = self._playlist_albums[hash]
- self._selected_albums = [album]
- self.emit('albumart', hash)
+ # FIXME on_select_toggled()
+ #@Gtk.Template.Callback()
+ def on_select_toggled(self, widget):
+ self.emit('select', widget.get_active())
- # Show standalone album
+
+ # FIXME on_clear_clicked()
+ #@Gtk.Template.Callback()
+ def on_clear_clicked(self, widget):
+ if widget is self.playlist_clear_button:
+ self.emit('clear-playlist')
+
+
+ @Gtk.Template.Callback()
+ def on_playlist_grid_clicked(self, widget, position):
+ # Get selected album
+ item = self._playlist_grid_model.get_item(position)
+ album = item.get_album()
+ id = album.get_id()
+ self._selected_albums = [album]
+ self.emit('albumart', id)
+
+ # FIXME Show standalone album
+ return
if widget.get_selection_mode() == Gtk.SelectionMode.SINGLE:
# Set labels
self._headerbar_standalone.set_album(album)
@@ -158,7 +145,8 @@ class PlaylistPanel(Gtk.Stack):
self.standalone_spinner.start()
- @Gtk.Template.Callback()
+ # FIXME on_playlist_grid_selection_changed()
+ #@Gtk.Template.Callback()
def on_playlist_grid_selection_changed(self, widget):
self._selected_albums = []
for path in widget.get_selected_items():
@@ -167,18 +155,19 @@ class PlaylistPanel(Gtk.Stack):
self._selected_albums.append(self._playlist_albums[hash])
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_selection_cancel_clicked(self, widget):
- self._toolbar.exit_selection()
+ self.select_button.set_active(False)
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_selection_remove_clicked(self, widget):
self.emit('remove-multiple-albums', self._selected_albums)
- self._toolbar.exit_selection()
+ self.select_button.set_active(False)
- @Gtk.Template.Callback()
+ # FIXME on_standalone_scroll_size_allocate()
+ #@Gtk.Template.Callback()
def on_standalone_scroll_size_allocate(self, widget, allocation):
self._resize_standalone_image()
@@ -187,13 +176,13 @@ class PlaylistPanel(Gtk.Stack):
self._close_standalone()
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_standalone_remove_clicked(self, widget):
self.emit('remove-album', self._selected_albums[0])
self._close_standalone()
- @Gtk.Template.Callback()
+ #@Gtk.Template.Callback()
def on_standalone_play_clicked(self, widget):
self.emit('play', self._selected_albums[0])
self._close_standalone()
@@ -235,6 +224,7 @@ class PlaylistPanel(Gtk.Stack):
def _set_playlist(self, host, playlist, size):
+ """
if not self._is_selected and self._playlist != playlist:
GObject.idle_add(
self.get_parent().child_set_property,
@@ -242,16 +232,16 @@ class PlaylistPanel(Gtk.Stack):
'needs-attention',
True
)
+ """
self._playlist_lock.acquire()
self._playlist_stop.clear()
self._playlist = playlist
self._playlist_albums = {}
for album in playlist:
self._playlist_albums[album.get_id()] = album
- self.playlist_grid.set_model(None)
- self.playlist_grid.freeze_child_notify()
- self._playlist_grid_model.clear()
- GObject.idle_add(self.playlist_grid.set_item_padding, size / 100)
+ self._playlist_grid_model.remove_all()
+ # FIXME Set item padding dynamically?
+ #GObject.idle_add(self.playlist_grid.set_item_padding, size / 100)
cache = client.MCGCache(host, size)
for album in playlist:
@@ -265,31 +255,22 @@ class PlaylistPanel(Gtk.Stack):
except Exception:
self._logger.exception("Failed to load albumart")
if pixbuf is None:
- pixbuf = self._icon_theme.load_icon(
+ pixbuf = self._icon_theme.lookup_icon(
Utils.STOCK_ICON_DEFAULT,
+ None,
self._item_size,
- Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE
+ self._item_size,
+ Gtk.TextDirection.LTR,
+ Gtk.IconLookupFlags.FORCE_SYMBOLIC
)
if pixbuf is not None:
- self._playlist_grid_model.append([
- pixbuf,
- GObject.markup_escape_text("\n".join([
- album.get_title(),
- ', '.join(album.get_dates()),
- Utils.create_artists_label(album),
- Utils.create_length_label(album)
- ])),
- album.get_id()
- ])
+ self._playlist_grid_model.append(GridItem(album, pixbuf))
if self._playlist_stop.is_set():
self._playlist_lock.release()
return
- self.playlist_grid.set_model(self._playlist_grid_model)
- self.playlist_grid.thaw_child_notify()
- # TODO why set_columns()?
- #self.playlist_grid.set_columns(len(playlist))
+ self.playlist_grid.set_model(self._playlist_grid_selection)
self._playlist_lock.release()
@@ -342,12 +323,11 @@ class PlaylistPanel(Gtk.Stack):
def _get_default_image(self):
- return self._icon_theme.load_icon(
+ return self._icon_theme.lookup_icon(
Utils.STOCK_ICON_DEFAULT,
+ None,
512,
- Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE
+ 512,
+ Gtk.TextDirection.LTR,
+ Gtk.IconLookupFlags.FORCE_SYMBOLIC
)
-
-
-
-
diff --git a/src/serverpanel.py b/src/serverpanel.py
index 22f3836..75c3628 100644
--- a/src/serverpanel.py
+++ b/src/serverpanel.py
@@ -2,32 +2,23 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
-from gi.repository import Gtk, GObject
-
-
-
-
-@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/server-toolbar.ui')
-class ServerToolbar(Gtk.ButtonBox):
- __gtype_name__ = 'McgServerToolbar'
-
-
- def __init__(self):
- super().__init__()
+from gi.repository import Gtk, Adw, GObject
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/server-panel.ui')
-class ServerPanel(Gtk.Box):
+class ServerPanel(Adw.Bin):
__gtype_name__ = 'McgServerPanel'
__gsignals__ = {
'change-output-device': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,bool,)),
}
# Widgets
+ toolbar = Gtk.Template.Child()
# Status widgets
status_file = Gtk.Template.Child()
status_audio = Gtk.Template.Child()
@@ -44,14 +35,13 @@ class ServerPanel(Gtk.Box):
output_devices = Gtk.Template.Child()
- def __init__(self):
- super().__init__()
+ def __init__(self, **kwargs):
+ super().__init__(**kwargs)
self._none_label = ""
self._output_buttons = {}
self._is_selected = False
# Widgets
- self._toolbar = ServerToolbar()
self._none_label = self.status_file.get_label()
@@ -60,7 +50,7 @@ class ServerPanel(Gtk.Box):
def get_toolbar(self):
- return self._toolbar
+ return self.toolbar
def on_output_device_toggled(self, widget, device):
@@ -115,13 +105,12 @@ class ServerPanel(Gtk.Box):
self._output_buttons[device.get_id()].set_active(device.is_enabled())
self._output_buttons[device.get_id()].thaw_notify()
else:
- button = Gtk.CheckButton(device.get_name())
+ button = Gtk.CheckButton.new_with_label(device.get_name())
if device.is_enabled():
button.set_active(True)
handler = button.connect('toggled', self.on_output_device_toggled, device)
self.output_devices.insert(button, -1)
self._output_buttons[device.get_id()] = button
- self.output_devices.show_all()
# Remove devices
for id in self._output_buttons.keys():
diff --git a/src/utils.py b/src/utils.py
index 713c85c..f5ad22e 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -2,13 +2,13 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
import hashlib
import locale
import os
import urllib
-from gi.repository import GdkPixbuf
+from gi.repository import Gdk, GdkPixbuf, GObject
@@ -86,3 +86,29 @@ class SortOrder:
ARTIST = 0
TITLE = 1
YEAR = 2
+
+
+
+
+class GridItem(GObject.GObject):
+ __gtype_name__ = "GridItem"
+
+ tooltip = GObject.Property(type=str, default=None)
+ cover = GObject.Property(type=Gdk.Paintable, default=None)
+
+
+ def __init__(self, album, cover):
+ super().__init__()
+ self._album = album
+ if cover:
+ self.cover = Gdk.Texture.new_for_pixbuf(cover)
+ self.tooltip = GObject.markup_escape_text("\n".join([
+ album.get_title(),
+ ', '.join(album.get_dates()),
+ Utils.create_artists_label(album),
+ Utils.create_length_label(album)
+ ]))
+
+
+ def get_album(self):
+ return self._album
diff --git a/src/window.py b/src/window.py
index c0dd46c..a438b6f 100644
--- a/src/window.py
+++ b/src/window.py
@@ -2,7 +2,8 @@
import gi
-gi.require_version('Gtk', '3.0')
+gi.require_version('Gtk', '4.0')
+gi.require_version('Adw', '1')
try:
import keyring
use_keyring = True
@@ -11,10 +12,10 @@ except:
import locale
import logging
-from gi.repository import Gtk, Gdk, GObject, GLib, Gio
+from gi.repository import Gtk, Adw, Gdk, GObject, GLib, Gio
from . import client
-from .shortcutsdialog import ShortcutsDialog
+#from .shortcutsdialog import ShortcutsDialog
from .connectionpanel import ConnectionPanel
from .serverpanel import ServerPanel
from .coverpanel import CoverPanel
@@ -43,7 +44,7 @@ class WindowState(GObject.Object):
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/window.ui')
-class Window(Gtk.ApplicationWindow):
+class Window(Adw.ApplicationWindow):
__gtype_name__ = 'McgAppWindow'
SETTING_HOST = 'host'
SETTING_PORT = 'port'
@@ -63,31 +64,30 @@ class Window(Gtk.ApplicationWindow):
toolbar_stack = Gtk.Template.Child()
# Headerbar
headerbar = Gtk.Template.Child()
- headerbar_title_stack = Gtk.Template.Child()
+ #headerbar_title_stack = Gtk.Template.Child()
headerbar_panel_switcher = Gtk.Template.Child()
- headerbar_connection_label = Gtk.Template.Child()
+ #headerbar_connection_label = Gtk.Template.Child()
headerbar_button_connect = Gtk.Template.Child()
headerbar_button_playpause = Gtk.Template.Child()
headerbar_button_volume = Gtk.Template.Child()
# Infobar
- info_revealer = Gtk.Template.Child()
- info_bar = Gtk.Template.Child()
- info_label = Gtk.Template.Child()
+ info_toast = Gtk.Template.Child()
- def __init__(self, app, title, settings):
- super().__init__()
+ def __init__(self, app, title, settings, **kwargs):
+ super().__init__(**kwargs)
self.set_application(app)
self.set_title(title)
self._settings = settings
self._panels = []
self._mcg = client.Client()
self._state = WindowState()
- self._changing_volume = False
self._setting_volume = False
+ self._headerbar_connection_button_active = True
+ self._headerbar_playpause_button_active = True
- # Help/Shortcuts dialog
- self.set_help_overlay(ShortcutsDialog())
+ # FIXME Help/Shortcuts dialog
+ #self.set_help_overlay(ShortcutsDialog())
# Login screen
self._connection_panel = ConnectionPanel()
@@ -99,28 +99,28 @@ class Window(Gtk.ApplicationWindow):
self._panels.append(self._cover_panel)
# Playlist panel
self._playlist_panel = PlaylistPanel(self._mcg)
- self._playlist_panel.connect('open-standalone', self.on_panel_open_standalone)
- self._playlist_panel.connect('close-standalone', self.on_panel_close_standalone)
+ #self._playlist_panel.connect('open-standalone', self.on_panel_open_standalone)
+ #self._playlist_panel.connect('close-standalone', self.on_panel_close_standalone)
self._panels.append(self._playlist_panel)
# Library panel
self._library_panel = LibraryPanel(self._mcg)
- self._library_panel.connect('open-standalone', self.on_panel_open_standalone)
- self._library_panel.connect('close-standalone', self.on_panel_close_standalone)
+ #self._library_panel.connect('open-standalone', self.on_panel_open_standalone)
+ #self._library_panel.connect('close-standalone', self.on_panel_close_standalone)
self._panels.append(self._library_panel)
# Stack
- self.content_stack.add(self._connection_panel)
+ self.content_stack.add_child(self._connection_panel)
self.panel_stack.add_titled(self._server_panel, 'server-panel', locale.gettext("Server"))
- self.panel_stack.add_titled(self._cover_panel, 'cover-panel', locale.gettext("Cover"))
+ self.panel_stack.add_titled_with_icon(self._cover_panel, 'cover-panel', locale.gettext("Cover"), "image-x-generic-symbolic")
self.panel_stack.add_titled(self._playlist_panel, 'playlist-panel', locale.gettext("Playlist"))
self.panel_stack.add_titled(self._library_panel, 'library-panel', locale.gettext("Library"))
# Header
- self._playlist_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
- self._library_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
+ #self._playlist_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
+ #self._library_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
# Toolbar stack
- self.toolbar_stack.add(self._server_panel.get_toolbar())
- self.toolbar_stack.add(self._cover_panel.get_toolbar())
- self.toolbar_stack.add(self._playlist_panel.get_toolbar())
- self.toolbar_stack.add(self._library_panel.get_toolbar())
+ self.toolbar_stack.add_child(self._server_panel.get_toolbar())
+ self.toolbar_stack.add_child(self._cover_panel.get_toolbar())
+ self.toolbar_stack.add_child(self._playlist_panel.get_toolbar())
+ self.toolbar_stack.add_child(self._library_panel.get_toolbar())
# Properties
self._set_headerbar_sensitive(False, False)
@@ -134,6 +134,9 @@ class Window(Gtk.ApplicationWindow):
self._library_panel.set_sort_type(self._settings.get_boolean(Window.SETTING_SORT_TYPE))
# Signals
+ self.connect("notify::default-width", self.on_resize)
+ self.connect("notify::maximized", self.on_maximized)
+ self.connect("notify::fullscreened", self.on_fullscreened)
self._connection_panel.connect('connection-changed', self.on_connection_panel_connection_changed)
self.panel_stack.connect('notify::visible-child', self.on_stack_switched)
self._server_panel.connect('change-output-device', self.on_server_panel_output_device_changed)
@@ -176,7 +179,6 @@ class Window(Gtk.ApplicationWindow):
self.set_default_size(self._state.width, self._state.height)
if self._state.get_property(WindowState.IS_MAXIMIZED):
self.maximize()
- self.show_all()
self.content_stack.set_visible_child(self._connection_panel)
if self._settings.get_boolean(Window.SETTING_CONNECTED):
self._connect()
@@ -228,7 +230,7 @@ class Window(Gtk.ApplicationWindow):
def on_menu_toggle_fullscreen(self, action, value):
- self.panel_stack.set_visible_child(self._cover_panel)
+ self.panel_stack.set_visible_child(self.cover_panel_page)
if not self._state.get_property(WindowState.IS_FULLSCREENED):
self.fullscreen()
else:
@@ -236,52 +238,36 @@ class Window(Gtk.ApplicationWindow):
def on_menu_search_library(self, action, value):
- self.panel_stack.set_visible_child(self._library_panel)
+ self.panel_stack.set_visible_child(self.library_panel_page)
self._library_panel.show_search()
# Window callbacks
- @Gtk.Template.Callback()
def on_resize(self, widget, event):
- if not self._state.get_property(WindowState.IS_MAXIMIZED):
- size = self.get_size()
- self._state.set_property(WindowState.WIDTH, size.width)
- self._state.set_property(WindowState.HEIGHT, size.height)
+ width = self.get_size(Gtk.Orientation.HORIZONTAL)
+ height = self.get_size(Gtk.Orientation.VERTICAL)
+ if width > 0:
+ self._cover_panel.set_width(width)
+ if not self._state.get_property(WindowState.IS_MAXIMIZED):
+ self._state.set_property(WindowState.WIDTH, width)
+ self._state.set_property(WindowState.HEIGHT, height)
- @Gtk.Template.Callback()
- def on_state(self, widget, state):
- self._state.set_property(WindowState.IS_MAXIMIZED, (state.new_window_state & Gdk.WindowState.MAXIMIZED > 0))
- self._fullscreen((state.new_window_state & Gdk.WindowState.FULLSCREEN > 0))
+ def on_maximized(self, widget, maximized):
+ self._state.set_property(WindowState.IS_MAXIMIZED, maximized is True)
+
+
+ def on_fullscreened(self, widget, fullscreened):
+ self._fullscreen(fullscreened is True)
# HeaderBar callbacks
- @Gtk.Template.Callback()
- def on_headerbar_connection_active_notify(self, widget, status):
- self._connect()
-
-
@Gtk.Template.Callback()
def on_headerbar_connection_state_set(self, widget, state):
- return True
-
-
- @Gtk.Template.Callback()
- def on_headerbar_volume_press(self, widget, active):
- self._changing_volume = active
-
-
- @Gtk.Template.Callback()
- def on_headerbar_volume_release(self, widget, active):
- self._changing_volume = active
-
-
- @Gtk.Template.Callback()
- def on_headerbar_playpause_toggled(self, widget):
- self._mcg.playpause()
- self._mcg.get_status()
+ if self._headerbar_connection_button_active:
+ self._connect()
@Gtk.Template.Callback()
@@ -290,17 +276,11 @@ class Window(Gtk.ApplicationWindow):
self._mcg.set_volume(int(value*100))
- # Infobar callback
-
@Gtk.Template.Callback()
- def on_info_bar_close(self, *args):
- self.info_revealer.set_reveal_child(False)
-
-
- @Gtk.Template.Callback()
- def on_info_bar_response(self, widget, response):
- self.info_revealer.set_reveal_child(False)
-
+ def on_headerbar_playpause_toggled(self, widget):
+ if self._headerbar_playpause_button_active:
+ self._mcg.playpause()
+ self._mcg.get_status()
# Panel callbacks
@@ -311,12 +291,12 @@ class Window(Gtk.ApplicationWindow):
self._set_menu_visible_panel()
for panel in self._panels:
panel.set_selected(panel == self.panel_stack.get_visible_child())
- GObject.idle_add(
- self.panel_stack.child_set_property,
- self.panel_stack.get_visible_child(),
- 'needs-attention',
- False
- )
+ #GObject.idle_add(
+ # self.panel_stack.child_set_property,
+ # self.panel_stack.get_visible_child(),
+ # 'needs-attention',
+ # False
+ #)
def on_panel_open_standalone(self, panel):
self.set_titlebar(panel.get_headerbar_standalone())
@@ -450,9 +430,7 @@ class Window(Gtk.ApplicationWindow):
# Status
self._server_panel.set_status(file, audio, bitrate, error)
# Error
- if error is None:
- self.info_revealer.set_reveal_child(False)
- else:
+ if error:
self._show_error(error)
@@ -487,6 +465,8 @@ class Window(Gtk.ApplicationWindow):
def on_mcg_custom(self, name):
+ pass
+ """
if name == Window._CUSTOM_STARTUP_COMPLETE:
for panel in self._panels:
GObject.idle_add(
@@ -495,6 +475,7 @@ class Window(Gtk.ApplicationWindow):
'needs-attention',
False
)
+ """
def on_mcg_error(self, error):
@@ -593,58 +574,39 @@ class Window(Gtk.ApplicationWindow):
def _set_play(self):
- self.headerbar_button_playpause.handler_block_by_func(
- self.on_headerbar_playpause_toggled
- )
+ self._headerbar_playpause_button_active = False
self.headerbar_button_playpause.set_active(True)
- self.headerbar_button_playpause.handler_unblock_by_func(
- self.on_headerbar_playpause_toggled
- )
+ self._headerbar_playpause_button_active = True
def _set_pause(self):
- self.headerbar_button_playpause.handler_block_by_func(
- self.on_headerbar_playpause_toggled
- )
+ self._headerbar_playpause_button_active = False
self.headerbar_button_playpause.set_active(False)
- self.headerbar_button_playpause.handler_unblock_by_func(
- self.on_headerbar_playpause_toggled
- )
+ self._headerbar_playpause_button_active = True
def _set_volume(self, volume):
if volume >= 0:
self.headerbar_button_volume.set_visible(True)
- if not self._changing_volume:
- self._setting_volume = True
- self.headerbar_button_volume.set_value(volume / 100)
- self._setting_volume = False
+ self._setting_volume = True
+ self.headerbar_button_volume.set_value(volume / 100)
+ self._setting_volume = False
else:
self.headerbar_button_volume.set_visible(False)
def _headerbar_connected(self):
- self.headerbar_button_connect.handler_block_by_func(
- self.on_headerbar_connection_active_notify
- )
+ self._headerbar_connection_button_active = False
self.headerbar_button_connect.set_active(True)
self.headerbar_button_connect.set_state(True)
- self.headerbar_button_connect.handler_unblock_by_func(
- self.on_headerbar_connection_active_notify
- )
- self.headerbar_title_stack.set_visible_child(self.headerbar_panel_switcher)
+ self._headerbar_connection_button_active = True
def _headerbar_disconnected(self):
- self.headerbar_button_connect.handler_block_by_func(
- self.on_headerbar_connection_active_notify
- )
+ self._headerbar_connection_button_active = False
self.headerbar_button_connect.set_active(False)
self.headerbar_button_connect.set_state(False)
- self.headerbar_button_connect.handler_unblock_by_func(
- self.on_headerbar_connection_active_notify
- )
- self.headerbar_title_stack.set_visible_child(self.headerbar_connection_label)
+ self._headerbar_connection_button_active = True
def _set_headerbar_sensitive(self, sensitive, connecting):
@@ -655,6 +617,4 @@ class Window(Gtk.ApplicationWindow):
def _show_error(self, message):
- self.info_bar.set_message_type(Gtk.MessageType.ERROR)
- self.info_label.set_text(message)
- self.info_revealer.set_reveal_child(True)
+ self.info_toast.add_toast(Adw.Toast.new(message))