Compare commits
5 commits
2c5217e744
...
126bd19770
| Author | SHA1 | Date | |
|---|---|---|---|
| 126bd19770 | |||
| 60fc9d7cfd | |||
| d75c63a8ce | |||
| 6d6d928733 | |||
| db41a691e6 |
3 changed files with 102 additions and 11 deletions
|
|
@ -9,8 +9,8 @@ template $FeedTheMonkeyWindow : Adw.ApplicationWindow {
|
||||||
Adw.ToastOverlay toast_overlay {
|
Adw.ToastOverlay toast_overlay {
|
||||||
Paned paned {
|
Paned paned {
|
||||||
focusable: false;
|
focusable: false;
|
||||||
shrink-start-child: false;
|
|
||||||
resize-start-child: false;
|
resize-start-child: false;
|
||||||
|
shrink-end-child: false;
|
||||||
|
|
||||||
start-child: Adw.ToolbarView sidebar_toolbar {
|
start-child: Adw.ToolbarView sidebar_toolbar {
|
||||||
top-bar-style: raised;
|
top-bar-style: raised;
|
||||||
|
|
@ -107,6 +107,7 @@ template $FeedTheMonkeyWindow : Adw.ApplicationWindow {
|
||||||
|
|
||||||
end-child: Adw.ToolbarView {
|
end-child: Adw.ToolbarView {
|
||||||
top-bar-style: raised;
|
top-bar-style: raised;
|
||||||
|
width-request: 320;
|
||||||
|
|
||||||
[top]
|
[top]
|
||||||
Adw.HeaderBar {
|
Adw.HeaderBar {
|
||||||
|
|
@ -117,10 +118,39 @@ template $FeedTheMonkeyWindow : Adw.ApplicationWindow {
|
||||||
action-name: "win.toggle-sidebar";
|
action-name: "win.toggle-sidebar";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[start]
|
||||||
|
Stack content_refresh_stack {
|
||||||
|
visible: false;
|
||||||
|
StackPage {
|
||||||
|
name: "button";
|
||||||
|
child: Button {
|
||||||
|
icon-name: "view-refresh-symbolic";
|
||||||
|
tooltip-text: _("Refresh");
|
||||||
|
action-name: "win.reload";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
StackPage {
|
||||||
|
name: "spinner";
|
||||||
|
child: Spinner {
|
||||||
|
spinning: true;
|
||||||
|
width-request: 16;
|
||||||
|
height-request: 16;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
title-widget: Adw.WindowTitle {
|
title-widget: Adw.WindowTitle {
|
||||||
title: _("FeedTheMonkey");
|
title: _("FeedTheMonkey");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[end]
|
||||||
|
MenuButton content_menu_button {
|
||||||
|
icon-name: "open-menu-symbolic";
|
||||||
|
primary: true;
|
||||||
|
menu-model: primary_menu;
|
||||||
|
visible: false;
|
||||||
|
}
|
||||||
|
|
||||||
[end]
|
[end]
|
||||||
MenuButton article_menu_button {
|
MenuButton article_menu_button {
|
||||||
icon-name: "view-more-symbolic";
|
icon-name: "view-more-symbolic";
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPaned" id="paned">
|
<object class="GtkPaned" id="paned">
|
||||||
<property name="focusable">false</property>
|
<property name="focusable">false</property>
|
||||||
<property name="shrink-start-child">false</property>
|
|
||||||
<property name="resize-start-child">false</property>
|
<property name="resize-start-child">false</property>
|
||||||
|
<property name="shrink-end-child">false</property>
|
||||||
<property name="start-child">
|
<property name="start-child">
|
||||||
<object class="AdwToolbarView" id="sidebar_toolbar">
|
<object class="AdwToolbarView" id="sidebar_toolbar">
|
||||||
<property name="top-bar-style">1</property>
|
<property name="top-bar-style">1</property>
|
||||||
|
|
@ -146,6 +146,7 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||||
<property name="end-child">
|
<property name="end-child">
|
||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<property name="top-bar-style">1</property>
|
<property name="top-bar-style">1</property>
|
||||||
|
<property name="width-request">320</property>
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar">
|
<object class="AdwHeaderBar">
|
||||||
<child type="start">
|
<child type="start">
|
||||||
|
|
@ -155,11 +156,48 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||||
<property name="action-name">win.toggle-sidebar</property>
|
<property name="action-name">win.toggle-sidebar</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="start">
|
||||||
|
<object class="GtkStack" id="content_refresh_stack">
|
||||||
|
<property name="visible">false</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStackPage">
|
||||||
|
<property name="name">button</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="icon-name">view-refresh-symbolic</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Refresh</property>
|
||||||
|
<property name="action-name">win.reload</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStackPage">
|
||||||
|
<property name="name">spinner</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkSpinner">
|
||||||
|
<property name="spinning">true</property>
|
||||||
|
<property name="width-request">16</property>
|
||||||
|
<property name="height-request">16</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<property name="title-widget">
|
<property name="title-widget">
|
||||||
<object class="AdwWindowTitle">
|
<object class="AdwWindowTitle">
|
||||||
<property name="title" translatable="yes">FeedTheMonkey</property>
|
<property name="title" translatable="yes">FeedTheMonkey</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
<child type="end">
|
||||||
|
<object class="GtkMenuButton" id="content_menu_button">
|
||||||
|
<property name="icon-name">open-menu-symbolic</property>
|
||||||
|
<property name="primary">true</property>
|
||||||
|
<property name="menu-model">primary_menu</property>
|
||||||
|
<property name="visible">false</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkMenuButton" id="article_menu_button">
|
<object class="GtkMenuButton" id="article_menu_button">
|
||||||
<property name="icon-name">view-more-symbolic</property>
|
<property name="icon-name">view-more-symbolic</property>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ pub mod imp {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub article_menu_button: TemplateChild<gtk4::MenuButton>,
|
pub article_menu_button: TemplateChild<gtk4::MenuButton>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
pub content_refresh_stack: TemplateChild<gtk4::Stack>,
|
||||||
|
#[template_child]
|
||||||
|
pub content_menu_button: TemplateChild<gtk4::MenuButton>,
|
||||||
|
#[template_child]
|
||||||
pub sidebar_content: TemplateChild<gtk4::Stack>,
|
pub sidebar_content: TemplateChild<gtk4::Stack>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub article_list_view: TemplateChild<gtk4::ListView>,
|
pub article_list_view: TemplateChild<gtk4::ListView>,
|
||||||
|
|
@ -164,12 +168,24 @@ pub mod imp {
|
||||||
self.sidebar_zoom_css.set(zoom_css).ok();
|
self.sidebar_zoom_css.set(zoom_css).ok();
|
||||||
self.update_sidebar_zoom(zoom);
|
self.update_sidebar_zoom(zoom);
|
||||||
|
|
||||||
// Persist sidebar width while dragging (only when visible)
|
// Persist sidebar width while dragging; collapse when dragged too narrow.
|
||||||
let s2 = settings.clone();
|
let s2 = settings.clone();
|
||||||
let sidebar_weak = self.sidebar_toolbar.downgrade();
|
let win_weak = self.obj().downgrade();
|
||||||
self.paned.connect_notify_local(Some("position"), move |paned, _| {
|
self.paned.connect_notify_local(Some("position"), move |paned, _| {
|
||||||
if sidebar_weak.upgrade().map(|s| s.is_visible()).unwrap_or(false) {
|
let Some(win) = win_weak.upgrade() else { return };
|
||||||
s2.set_int("sidebar-width", paned.position()).ok();
|
let imp = win.imp();
|
||||||
|
if !imp.sidebar_toolbar.is_visible() { return; }
|
||||||
|
let pos = paned.position();
|
||||||
|
if pos < 150 {
|
||||||
|
// Defer so we don't change widget visibility mid-drag.
|
||||||
|
let win_weak2 = win_weak.clone();
|
||||||
|
glib::idle_add_local_once(move || {
|
||||||
|
if let Some(win) = win_weak2.upgrade() {
|
||||||
|
win.imp().set_sidebar_visible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
s2.set_int("sidebar-width", pos).ok();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -409,11 +425,16 @@ pub mod imp {
|
||||||
fn setup_sidebar_toggle(&self) {}
|
fn setup_sidebar_toggle(&self) {}
|
||||||
|
|
||||||
fn do_toggle_sidebar(&self) {
|
fn do_toggle_sidebar(&self) {
|
||||||
let sidebar = &*self.sidebar_toolbar;
|
self.set_sidebar_visible(!self.sidebar_toolbar.is_visible());
|
||||||
if sidebar.is_visible() {
|
}
|
||||||
sidebar.set_visible(false);
|
|
||||||
} else {
|
fn set_sidebar_visible(&self, visible: bool) {
|
||||||
sidebar.set_visible(true);
|
self.sidebar_toolbar.set_visible(visible);
|
||||||
|
// Mirror refresh stack state and primary menu in the content header
|
||||||
|
// when the sidebar is hidden, so those controls remain accessible.
|
||||||
|
self.content_refresh_stack.set_visible(!visible);
|
||||||
|
self.content_menu_button.set_visible(!visible);
|
||||||
|
if visible {
|
||||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||||
let saved = settings.int("sidebar-width");
|
let saved = settings.int("sidebar-width");
|
||||||
self.paned.set_position(if saved > 0 { saved } else { 280 });
|
self.paned.set_position(if saved > 0 { saved } else { 280 });
|
||||||
|
|
@ -630,6 +651,7 @@ pub mod imp {
|
||||||
*self.filter_rules.borrow_mut() = crate::filters::load_rules();
|
*self.filter_rules.borrow_mut() = crate::filters::load_rules();
|
||||||
|
|
||||||
self.refresh_stack.set_visible_child_name("spinner");
|
self.refresh_stack.set_visible_child_name("spinner");
|
||||||
|
self.content_refresh_stack.set_visible_child_name("spinner");
|
||||||
|
|
||||||
// Only show the loading screen if there's nothing to show yet.
|
// Only show the loading screen if there's nothing to show yet.
|
||||||
let has_articles = self.article_store.borrow()
|
let has_articles = self.article_store.borrow()
|
||||||
|
|
@ -725,6 +747,7 @@ pub mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imp.refresh_stack.set_visible_child_name("button");
|
imp.refresh_stack.set_visible_child_name("button");
|
||||||
|
imp.content_refresh_stack.set_visible_child_name("button");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue