Skip to content

Commit

Permalink
feat(ui): Complete port to Blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeedali committed Oct 10, 2024
1 parent 14b7faa commit 19c4ddd
Show file tree
Hide file tree
Showing 13 changed files with 775 additions and 737 deletions.
2 changes: 2 additions & 0 deletions data/resources/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ gnome = import('gnome')
blueprints = custom_target('blueprints',
input: files(
'ui/shortcuts_window.blp',
'ui/settings_window.blp',
'ui/window.blp',
),
output: '.',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
Expand Down
42 changes: 42 additions & 0 deletions data/resources/ui/settings_window.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Gtk 4.0;
using Adw 1;

template $SettingsDialog: Adw.PreferencesDialog {
content-width: 450;
content-height: 350;

Adw.PreferencesPage {
Adw.PreferencesGroup appearance {
title: _("Appearance");

Adw.SwitchRow dark_ui_switch {
title: _("Force Dark Mode");
}
}

Adw.PreferencesGroup {
title: _("Behavior");

Adw.SwitchRow live_search_switch {
title: _("Live Search");
subtitle: _("Show definition as the terms are typed in");
}

Adw.SwitchRow double_click_switch {
title: _("Double Click Search");
subtitle: _("Search any word by double clicking on it");
}

Adw.ComboRow pronunciations_accent_row {
title: _("Pronunciations Accent");

model: StringList {
strings [
"American English",
"British English",
]
};
}
}
}
}
313 changes: 313 additions & 0 deletions data/resources/ui/window.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
using Gtk 4.0;
using Adw 1;

menu app-menu {
section {
id: "search-section";

item {
label: _("Paste & Search");
action: "win.paste-search";
}

item {
label: _("Search Selected Text");
action: "win.search-selected";
}

item {
label: _("_Random Word");
action: "win.random-word";
}
}

section {
id: "help-section";

item {
label: _("_Preferences");
action: "win.preferences";
}

item {
label: _("_Keyboard Shortcuts");
action: "win.show-help-overlay";
}

item {
label: _("_About Wordbook");
action: "app.about";
}
}
}

template $WordbookWindow: Adw.ApplicationWindow {
default-width: 390;
default-height: 610;
focus-widget: search_entry;
default-widget: search_button;
icon-name: "accesories-dictionary";

Adw.Breakpoint {
condition ("max-width: 400sp")

setters {
main_split_view.collapsed: true;
}
}

content: Adw.OverlaySplitView main_split_view {
show-sidebar: false;

sidebar: Adw.ToolbarView {
[top]
Adw.HeaderBar {
[title]
Adw.WindowTitle {
title: _("History");
}
}

content: Adw.ViewStack history_stack {
vexpand: true;

Adw.ViewStackPage {
name: "list";

child: ScrolledWindow {
hscrollbar-policy: never;
has-frame: false;

child: Viewport {
child: ListBox history_listbox {
selection-mode: none;

styles [
"navigation-sidebar",
]
};
};
};
}

Adw.ViewStackPage {
name: "empty";

child: Adw.StatusPage {
icon-name: "document-open-recent-symbolic";
title: "No recent searches";
};
}
};
};

content: Adw.ToolbarView {
[top]
Adw.HeaderBar header_bar {
centering-policy: strict;

[title]
Adw.Clamp title_clamp {
tightening-threshold: 300;

Box {
hexpand: true;
spacing: 4;

Entry search_entry {
hexpand: true;
primary-icon-name: "edit-find-symbolic";
activates-default: true;
}

Button search_button {
icon-name: "edit-find-symbolic";
tooltip-text: _("Search");

styles [
"suggested-action",
]
}
}
}

ToggleButton split_view_toggle_button {
icon-name: "sidebar-show-symbolic";
tooltip-text: _("Show History");
}

[end]
MenuButton wordbook_menu_button {
menu-model: app-menu;
receives-default: true;
direction: none;
}
}

content: ScrolledWindow main_scroll {
hexpand: true;
vexpand: true;
hscrollbar-policy: never;

child: Viewport {
Adw.Clamp main_clamp {
tightening-threshold: 500;

Box clamped_box {
orientation: vertical;

Adw.ViewStack main_stack {
Adw.ViewStackPage {
name: "download_page";

child: Adw.StatusPage download_status_page {
title: _("Setting things up…");
description: _("Downloading WordNet…");

child: Adw.Clamp {
tightening-threshold: 200;

ProgressBar loading_progress {
ellipsize: end;
}
};
};
}

Adw.ViewStackPage {
name: "welcome_page";

child: Adw.StatusPage before_search_page {
icon-name: "dev.mufeed.Wordbook-symbolic";
title: _("Wordbook");
description: _("Look up definitions of any English term");
};
}

Adw.ViewStackPage {
name: "content_page";

child: Box content_box {
orientation: vertical;

Box {
hexpand: false;

Box {
margin-start: 18;
margin-end: 12;
margin-top: 12;
margin-bottom: 12;
orientation: vertical;
hexpand: false;

Label term_view {
label: "Term>";
use-markup: true;
single-line-mode: true;
ellipsize: end;
xalign: 0;
hexpand: false;
}

Label pronunciation_view {
label: _("/Pronunciation/");
use-markup: true;
selectable: true;
ellipsize: end;
single-line-mode: true;
xalign: 0;
hexpand: false;
}
}

Button speak_button {
margin-start: 4;
margin-end: 12;
margin-top: 12;
margin-bottom: 12;
receives-default: true;
halign: center;
valign: center;
icon-name: "audio-volume-high-symbolic";
has-frame: false;
hexpand: false;
tooltip-text: _("Listen to Pronunciation");

styles [
"circular",
]
}
}

Label def_view {
margin-start: 18;
margin-end: 18;
margin-top: 12;
margin-bottom: 12;
wrap: true;
selectable: true;
xalign: 0;
yalign: 0;

GestureClick def_ctrlr {}
}
};
}

Adw.ViewStackPage {
name: "search_fail_page";

child: Adw.StatusPage search_fail_status_page {
vexpand: true;
icon-name: "edit-find-symbolic";
title: _("No definition found");
};
}

Adw.ViewStackPage {
name: "network_fail_page";

child: Adw.StatusPage network_fail_status_page {
icon-name: "network-error-symbolic";
title: _("Download failed");

child: Box {
spacing: 12;
halign: center;

Button retry_button {
label: _("Retry");

styles [
"pill",
"suggested-action",
]
}

Button exit_button {
label: _("Exit");

styles [
"pill",
]
}
};
};
}

Adw.ViewStackPage {
name: "spinner_page";

child: Adw.Spinner {};
}
}
}
}
};
};
};
};

EventControllerKey key_ctrlr {}
}
Loading

0 comments on commit 19c4ddd

Please sign in to comment.