Changes
4 changed files (+138/-13)
-
-
@@ -24,11 +24,15 @@ <property name="title">Plac</property><style> <class name="devel" /> </style> <child> <object class="AdwBreakpoint"> <condition>max-width: 800sp</condition> <setter object="split_view" property="collapsed">true</setter> </object> </child> <property name="content"> <object class="AdwToolbarView"> <child type="top"> <object class="AdwHeaderBar" /> </child> <property name="bottom-bar-style">raised</property> <property name="content"> <object class="GtkOverlay"> <child>
-
@@ -38,7 +42,39 @@ <child><object class="GtkStackPage"> <property name="name">main</property> <property name="child"> <object class="PlacGtkAdwaitaBrowse" id="browse" /> <object class="AdwOverlaySplitView" id="split_view"> <property name="sidebar"> <object class="GtkListBox" id="browse_hierarchy"> <property name="selection-mode">browse</property> <style> <class name="navigation-sidebar" /> </style> </object> </property> <property name="content"> <object class="AdwToolbarView"> <child type="top"> <object class="AdwHeaderBar"> <child type="start"> <object class="GtkToggleButton"> <property name="icon-name">sidebar-show-symbolic</property> <property name="tooltip-text">Toggle Sidebar</property> <property name="active" bind-source="split_view" bind-property="show-sidebar" bind-flags="sync-create|bidirectional" /> </object> </child> </object> </child> <property name="content"> <object class="PlacGtkAdwaitaBrowse" id="browse" /> </property> </object> </property> </object> </property> </object> </child>
-
-
-
@@ -17,6 +17,9 @@namespace PlacGtkAdwaita { [GtkTemplate(ui = "/jp/pocka/plac/gtk-adwaita/ui/browse.ui")] class Browse : Gtk.Box { public signal void loading_start(); public signal void loading_end(); [GtkChild] private unowned Gtk.Label title;
-
@@ -46,9 +49,21 @@ load();} } public Plac.Browse.Hierarchy hierarchy = BROWSE; private Plac.Browse.Hierarchy? _hierarchy = null; public Plac.Browse.Hierarchy hierarchy { get { return _hierarchy; } construct set { if (_hierarchy != value) { _hierarchy = value; item = null; load(); } } } private Plac.Browse.Item? item = null; private bool is_loading = false; public Browse() { Object();
-
@@ -72,17 +87,28 @@ this.conn = conn;this.load(); } private void start_loading() { is_loading = true; loading_start(); loading.visible = true; this.sensitive = false; } private void end_loading() { is_loading = false; loading_end(); loading.visible = false; this.sensitive = true; } private void load(bool pop = false) { if (conn == null) { if (conn == null || _hierarchy == null || is_loading) { return; } loading.visible = true; this.sensitive = false; conn.browse.begin(hierarchy, _zone, item, pop, (obj, res) => { start_loading(); conn.browse.begin(_hierarchy, _zone, item, pop, (obj, res) => { var result = conn.browse.end(res); this.sensitive = true; if (result.code != OK) { GLib.log("Plac", LEVEL_WARNING, "Browse request failed: %s", result.code.to_string());
-
@@ -113,8 +139,7 @@ items.append(new BrowseItem.Row(item, conn));} back.visible = action.level > 0; loading.visible = false; end_loading(); }); } }
-
-
-
@@ -0,0 +1,32 @@// Copyright 2025 Shota FUJI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 namespace PlacGtkAdwaita { class BrowseHierarchyRow : Gtk.ListBoxRow { public Plac.Browse.Hierarchy hierarchy { get; construct set; } public string label { get; construct set; } public BrowseHierarchyRow(Plac.Browse.Hierarchy hierarchy, string label) { Object(hierarchy: hierarchy, label: label); } construct { var text = new Gtk.Label(label); text.halign = START; this.child = text; } } }
-
-
-
@@ -34,6 +34,9 @@[GtkChild] private unowned Browse browse; [GtkChild] private unowned Gtk.ListBox browse_hierarchy; private Settings settings = new Settings(); private Plac.Discovery.Server? server = null;
-
@@ -74,6 +77,35 @@ });playback_toolbar.zone_selected.connect((zone) => { browse.zone = zone; }); var explore_row = new BrowseHierarchyRow(BROWSE, "Explore"); browse_hierarchy.append(explore_row); browse_hierarchy.select_row(explore_row); browse_hierarchy.append(new BrowseHierarchyRow(ALBUMS, "Albums")); browse_hierarchy.append(new BrowseHierarchyRow(PLAYLISTS, "Playlists")); browse_hierarchy.append(new BrowseHierarchyRow(ARTISTS, "Artists")); browse_hierarchy.append(new BrowseHierarchyRow(GENRES, "Genres")); browse_hierarchy.append(new BrowseHierarchyRow(COMPOSERS, "Composers")); browse_hierarchy.append(new BrowseHierarchyRow(INTERNET_RADIO, "Internet Radio")); browse_hierarchy.append(new BrowseHierarchyRow(SETTINGS, "Settings")); browse_hierarchy.row_selected.connect((row) => { if (row == null) { return; } browse.hierarchy = ((BrowseHierarchyRow) row).hierarchy; }); browse.loading_start.connect(() => { browse_hierarchy.sensitive = false; }); browse.loading_end.connect(() => { browse_hierarchy.sensitive = true; }); }
-