Skip to content

Commit

Permalink
Merge pull request #50 from luleyleo/adaptive-sidebar
Browse files Browse the repository at this point in the history
Make the sidebar adaptive and reduce min-width to 300
  • Loading branch information
luleyleo authored Dec 5, 2024
2 parents cff2840 + dd9d4ed commit 92e173d
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 209 deletions.
2 changes: 1 addition & 1 deletion assets/de.leopoldluley.Clapgrep.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<color type="primary" scheme_preference="dark">#575243</color>
</branding>
<requires>
<display_length compare="ge">400</display_length>
<display_length compare="ge">300</display_length>
<internet>offline-only</internet>
</requires>
<supports>
Expand Down
1 change: 1 addition & 0 deletions gnome/src/ui/error_window/error_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ template $ClapgrepErrorWindow: Adw.Window {
margin-end: 16;
margin-bottom: 2;
xalign: 0.0;
wrap: true;
label: bind template.item as <StringObject>.string;
};
}
Expand Down
32 changes: 21 additions & 11 deletions gnome/src/ui/search_window/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ pub struct SearchWindow {
pub searched_files: Cell<u32>,
#[property(get)]
pub number_of_matches: Cell<u32>,
#[property(get)]

#[property(get, set)]
pub search_progress_visible: Cell<bool>,
#[property(get, set)]
pub search_progress_notification: RefCell<String>,
#[property(get, set)]
pub search_progress_action: RefCell<String>,

#[property(get)]
pub errors: StringList,
Expand All @@ -69,8 +74,6 @@ pub struct SearchWindow {
#[template_child]
pub results_page: TemplateChild<gtk::StackPage>,
#[template_child]
pub search_progress_banner: TemplateChild<gtk::Revealer>,
#[template_child]
pub split_view: TemplateChild<adw::NavigationSplitView>,

pub engine: SearchEngine,
Expand Down Expand Up @@ -112,13 +115,12 @@ impl SearchWindow {
}

#[template_callback]
fn on_cancel_search(&self, _: &gtk::Button) {
self.stop_search();
}

#[template_callback]
fn on_close_search_progress(&self, _: &gtk::Button) {
self.search_progress_banner.set_reveal_child(false);
fn on_search_progress_action(&self, _: &adw::Banner) {
if self.search_running.get() {
self.stop_search();
} else {
self.obj().set_search_progress_visible(false);
}
}

#[template_callback]
Expand Down Expand Up @@ -237,7 +239,7 @@ impl SearchWindow {
self.errors.splice(0, self.errors.n_items(), &[]);
self.obj().set_searched_files(0);
self.obj().set_search_running(true);
self.search_progress_banner.set_reveal_child(true);
self.obj().set_search_progress_visible(true);
self.split_view.set_show_content(true);

self.engine.search(search);
Expand Down Expand Up @@ -331,6 +333,14 @@ impl ObjectImpl for SearchWindow {
obj.connect_search_running_notify(|obj| {
let imp = obj.imp();

if imp.search_running.get() {
let label = gettext("Cancel Search");
obj.set_search_progress_action(label);
} else {
let label = gettext("Close");
obj.set_search_progress_action(label);
}

if imp.search_running.get() || imp.number_of_matches.get() > 0 {
imp.results_stack
.set_visible_child(&imp.results_page.child());
Expand Down
45 changes: 10 additions & 35 deletions gnome/src/ui/search_window/search_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Adw 1;

template $ClapgrepSearchWindow: Adw.ApplicationWindow {
title: _("Clapgrep");
width-request: 400;
width-request: 300;

Adw.Breakpoint {
condition ("max-width: 800")
Expand All @@ -14,9 +14,12 @@ template $ClapgrepSearchWindow: Adw.ApplicationWindow {
}

content: Adw.NavigationSplitView split_view {
min-sidebar-width: 300;
max-sidebar-width: 400;
sidebar-width-fraction: 0.3;

sidebar: Adw.NavigationPage {
title: _("Search Settings");
width-request: 400;

child: Adw.ToolbarView {
top-bar-style: flat;
Expand Down Expand Up @@ -160,39 +163,11 @@ template $ClapgrepSearchWindow: Adw.ApplicationWindow {
child: Box {
orientation: vertical;

Gtk.Revealer search_progress_banner {
child: Box {
orientation: horizontal;
margin-top: 4;
margin-start: 4;
margin-bottom: 4;
margin-end: 4;

Label {
hexpand: true;
label: bind template.search_progress_notification;

styles [
"heading"
]
}

Button {
visible: bind template.search_running;
label: _("Cancel Search");
clicked => $on_cancel_search() swapped;
}

Button {
visible: bind template.search_running inverted;
icon-name: "window-close-symbolic";
clicked => $on_close_search_progress() swapped;
}
};

styles [
"cg-banner"
]
Adw.Banner {
revealed: bind template.search_progress_visible;
title: bind template.search_progress_notification;
button-label: bind template.search_progress_action;
button-clicked => $on_search_progress_action() swapped;
}

Adw.Banner {
Expand Down
5 changes: 4 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ gettext:
--omit-header \
--keywords gettext \
--keywords gettext_f \
gnome/src/main.rs >> po/messages.pot
--output=po/messages.rs.pot \
gnome/src/main.rs
cat po/messages.rs.pot >> po/messages.pot
rm po/messages.rs.pot
cat po/LINGUAS | while read lang; do \
msgmerge -N -U po/$lang.po po/messages.pot; \
rm -f po/$lang.po~; \
Expand Down
70 changes: 37 additions & 33 deletions po/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-15 11:57+0100\n"
"POT-Creation-Date: 2024-12-05 13:24+0100\n"
"PO-Revision-Date: 2024-09-26 23:16+0200\n"
"Last-Translator: Amerey <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -22,90 +22,86 @@ msgstr ""
msgid "Clapgrep"
msgstr "Clapgrep"

#: gnome/src/ui/search_window/search_window.blp:18
#: gnome/src/ui/search_window/search_window.blp:22
msgid "Search Settings"
msgstr "Nastavení vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:41
#: gnome/src/ui/search_window/search_window.blp:44
msgid "Search Pattern"
msgstr "Vzor vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:47
#: gnome/src/ui/search_window/search_window.blp:50
#: gnome/src/ui/shortcuts/shortcuts.blp:28
msgid "Start Search"
msgstr "Spustit vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:55
#: gnome/src/ui/search_window/search_window.blp:58
msgid "Search Path"
msgstr "Cesta vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:73
#: gnome/src/ui/search_window/search_window.blp:76
msgid "Search Options"
msgstr "Možnosti vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:76
#: gnome/src/ui/search_window/search_window.blp:79
msgid "Case Sensitive"
msgstr "Rozlišovat malá a velká písmena"

#: gnome/src/ui/search_window/search_window.blp:81
#: gnome/src/ui/search_window/search_window.blp:84
msgid "Disable Regex"
msgstr "Zakázat Regex"

#: gnome/src/ui/search_window/search_window.blp:86
#: gnome/src/ui/search_window/search_window.blp:89
msgid "Include Hidden"
msgstr "Zahrnout skryté"

#: gnome/src/ui/search_window/search_window.blp:91
#: gnome/src/ui/search_window/search_window.blp:94
msgid "Include Ignored"
msgstr "Zahrnout ignorované"

#: gnome/src/ui/search_window/search_window.blp:97
#: gnome/src/ui/search_window/search_window.blp:100
msgid "Extra File Formats"
msgstr "Extra formáty souborů"

#: gnome/src/ui/search_window/search_window.blp:100
#: gnome/src/ui/search_window/search_window.blp:103
msgid "PDF files"
msgstr "PDF soubory"

#: gnome/src/ui/search_window/search_window.blp:105
#: gnome/src/ui/search_window/search_window.blp:108
msgid "Office files"
msgstr "Soubory Office"

#: gnome/src/ui/search_window/search_window.blp:116
#: gnome/src/ui/search_window/search_window.blp:119
msgid "Search Results"
msgstr "Výsledky vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:136
#: gnome/src/ui/search_window/search_window.blp:139
msgid "No Search Yet"
msgstr ""

#: gnome/src/ui/search_window/search_window.blp:137
#: gnome/src/ui/search_window/search_window.blp:140
msgid "Try to start a search"
msgstr ""

#: gnome/src/ui/search_window/search_window.blp:146
#: gnome/src/ui/search_window/search_window.blp:149
msgid "No Results"
msgstr ""

#: gnome/src/ui/search_window/search_window.blp:152
#: gnome/src/ui/search_window/search_window.blp:155
msgid ""
"You might want to try changing your search pattern, activating document "
"search, or changing to a different directory"
msgstr ""

#: gnome/src/ui/search_window/search_window.blp:182
msgid "Cancel Search"
msgstr "Zrušit vyhledávání"

#: gnome/src/ui/search_window/search_window.blp:201
#: gnome/src/ui/search_window/search_window.blp:176
msgid "Show Errors"
msgstr ""

#: gnome/src/ui/search_window/search_window.blp:284
#: gnome/src/ui/search_window/search_window.blp:259
msgid "Keyboard Shortcuts"
msgstr "Klávesové zkratky"

#: gnome/src/ui/search_window/search_window.blp:289
#: gnome/src/ui/search_window/search_window.blp:264
msgid "About Clapgrep"
msgstr "O Clapgrep"

Expand Down Expand Up @@ -137,14 +133,22 @@ msgstr "Ovládání vyhledávání"
msgid "Stop Search"
msgstr "Zastavit vyhledávání"

#~ msgid "Current Search"
#~ msgstr "Aktuální vyhledávání"
#: gnome/src/ui/search_window/imp.rs:132
msgid "Choose Search Path"
msgstr ""

#~ msgid "Searched Files"
#~ msgstr "Hledané soubory"
#: gnome/src/ui/search_window/imp.rs:257
msgid "Searched {files} files and found {matches} matches"
msgstr ""

#~ msgid "Number of Matches"
#~ msgstr "Počet shod"
#: gnome/src/ui/search_window/imp.rs:337
msgid "Cancel Search"
msgstr "Zrušit vyhledávání"

#~ msgid "Errors Encountered"
#~ msgstr "Zjištěné chyby"
#: gnome/src/ui/search_window/imp.rs:340
msgid "Close"
msgstr ""

#: gnome/src/ui/search_window/imp.rs:363
msgid "Encountered {errors} errors during search"
msgstr ""
Loading

0 comments on commit 92e173d

Please sign in to comment.