Skip to content

Commit

Permalink
feat: Save selected tool between sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
liferooter committed Oct 24, 2022
1 parent bc89ea9 commit 520c4bb
Show file tree
Hide file tree
Showing 22 changed files with 444 additions and 416 deletions.
6 changes: 3 additions & 3 deletions data/com.github.liferooter.textpieces.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
<summary>Is maximized</summary>
<description>Whether the application window is maximized</description>
</key>
<key name="default-tool" type="s">
<key name="selected-tool" type="s">
<default>''</default>
<summary>Default tool</summary>
<description>Tool to select on start. Its value must be a name of tool's script.</description>
<summary>Selected tool</summary>
<description>Used to restore tool choice on restart. Its value must be a name of tool's script.</description>
</key>
</schema>
</schemalist>
15 changes: 9 additions & 6 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
data/com.github.liferooter.textpieces.desktop.in
data/com.github.liferooter.textpieces.appdata.xml.in
data/com.github.liferooter.textpieces.gschema.xml
src/Editor.vala
src/NewToolPage.vala
src/Preferences.vala
src/SearchEntry.vala
src/ToolSettings.vala
src/Window.vala

src/widgets/Editor.vala
src/widgets/Window.vala
src/widgets/SearchEntry.vala
src/widgets/preferences/Preferences.vala
src/widgets/preferences/ToolSettings.vala
src/widgets/preferences/pages/NewToolPage.vala

resources/ui/CustomToolPage.blp
resources/ui/Search.blp
resources/ui/Editor.blp
resources/ui/NewToolPage.blp
resources/ui/Preferences.blp
Expand Down
1 change: 1 addition & 0 deletions resources/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ blueprints = custom_target('blueprints',
'ui/ShortcutsWindow.blp',
'ui/ToolSettings.blp',
'ui/Window.blp',
'ui/Search.blp',
),
output: '.',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
Expand Down
1 change: 1 addition & 0 deletions resources/textpieces.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<file preprocess="xml-stripblanks">ui/ToolSettings.ui</file>
<file preprocess="xml-stripblanks">ui/Window.ui</file>
<file preprocess="xml-stripblanks">ui/Editor.ui</file>
<file preprocess="xml-stripblanks">ui/Search.ui</file>

<!-- Shortcuts window -->
<file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/ShortcutsWindow.ui</file>
Expand Down
2 changes: 1 addition & 1 deletion resources/ui/Preferences.blp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ template TextPiecesPreferences : Adw.PreferencesWindow {
SpinButton spaces_in_tab {
valign: center;
climb-rate: 1;
adjustment:
adjustment:
Adjustment {
lower: 1;
upper: 21;
Expand Down
60 changes: 60 additions & 0 deletions resources/ui/Search.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-FileCopyrightText: 2022 Gleb Smirnov <[email protected]>
//
// SPDX-License-Identifier: GPL-3.0-or-later

using Gtk 4.0;
using Adw 1;

template TextPiecesSearch : Adw.Bin {
Stack search_stack {
transition-type: crossfade;

StackPage {
name: "search";
child: ScrolledWindow {
child: Viewport results_viewport {
scroll-to-focus: true;

Adw.Clamp {
maximum-size: 600;

ListBox results_listbox {
styles [
"boxed-list",
]

row-activated => on_row_activated();
margin-top: 24;
margin-bottom: 24;
valign: start;
selection-mode: browse;
}
}
};
};
}

StackPage {
name: "placeholder";
child: Adw.StatusPage {
icon-name: "applications-utilities-symbolic";
title: _("No Tools Found");

Button {
styles [
"flat",
]

halign: center;
action-name: "win.tools-settings";

Adw.ButtonContent {
icon-name: "list-add-symbolic";
label: _("_Add Custom Tool");
use-underline: true;
}
}
};
}
}
}
94 changes: 5 additions & 89 deletions resources/ui/Window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,7 @@ template TextPiecesWindow : Adw.ApplicationWindow {

SearchBar search_bar {
search-mode-enabled: bind tool_button.active bidirectional;
child:
SearchEntry search_entry {
changed => update_search_results();
activate => on_search_activated();

EventControllerKey search_event_controller {
key-pressed => on_search_entry_key();
}
}

;
child: SearchEntry search_entry {};
}

Stack content_stack {
Expand All @@ -118,84 +108,10 @@ template TextPiecesWindow : Adw.ApplicationWindow {

StackPage {
name: "search";
child:
Stack search_stack {
transition-type: crossfade;

StackPage {
name: "search";
child:
ScrolledWindow {
child: Viewport search_viewport {
scroll-to-focus: true;

Adw.Clamp {
maximum-size: 600;

ListBox search_listbox {
styles [
"boxed-list",
]

row-activated => on_row_activated();
margin-top: 24;
margin-bottom: 24;
valign: start;
selection-mode: browse;
}
}
}

;
}

;
}

StackPage {
name: "placeholder";
child:
Adw.StatusPage {
icon-name: "applications-utilities-symbolic";
title: _("No Tools Found");

Button {
styles [
"flat",
]

halign: center;
action-name: "win.tools-settings";
child:
Box {
spacing: 8;

Image {
styles [
"dim-label",
]

icon-name: "list-add-symbolic";
}

Label {
styles [
"dim-label",
]

label: _("Add Custom Tool");
}
}

;
}
}

;
}
}

;
child: .TextPiecesSearch search {
search-entry: search_entry;
tool-selected => on_tool_selected();
};
}
}
}
Expand Down
151 changes: 0 additions & 151 deletions src/Search.vala

This file was deleted.

Loading

0 comments on commit 520c4bb

Please sign in to comment.