diff --git a/data/style.css b/data/style.css index 26cc77f..5cdfd57 100644 --- a/data/style.css +++ b/data/style.css @@ -13,3 +13,11 @@ box-shadow: inset 0 -1px alpha(@shade_color, .75); background: linear-gradient(to top, alpha(@shade_color, .75), transparent 4px); } + + +/* Global */ + +scrolledwindow > viewport > clamp > box { + margin: 42px 12px; + border-spacing: 24px; +} diff --git a/data/ui/window.blp b/data/ui/window.blp index 316b630..086ebd5 100644 --- a/data/ui/window.blp +++ b/data/ui/window.blp @@ -39,181 +39,195 @@ template $BavarderWindow : Adw.ApplicationWindow { orientation: vertical; vexpand: true; hexpand: true; - margin-top: 0; - margin-bottom: 24; margin-start: 24; margin-end: 24; spacing: 12; - Adw.PreferencesGroup prompt_group { - title: _("Message"); + Adw.Bin { + vexpand: true; + hexpand: true; Box { orientation: vertical; - hexpand: true; - vexpand: true; - styles ["card", "text-box"] + Stack stack { + transition-type: crossfade; - ScrolledWindow { - margin-top: 12; - margin-bottom: 0; - margin-start: 12; - margin-end: 12; - styles ["scrolled-window"] + Gtk.StackPage { + name: "page_content"; + child: Overlay overlay { - TextView prompt_text_view { - wrap-mode: word_char; - hexpand: true; - vexpand: true; - buffer: TextBuffer { }; - //key-press => on_key_press_event(); + Adw.PreferencesGroup bot_group { + title: _("Response"); + + Box { + orientation: vertical; + hexpand: true; + vexpand: true; + + styles ["card", "text-box"] + + ScrolledWindow scrolled_response_window { + margin-top: 12; + margin-bottom: 0; + margin-start: 12; + margin-end: 12; + styles ["scrolled-window"] + + Gtk.Stack response_stack { + vexpand: true; + hexpand: true; + Gtk.StackPage { + name: "page_response"; + child: TextView bot_text_view { + wrap-mode: word_char; + hexpand: true; + vexpand: true; + editable: false; + }; + } + + // Gtk.StackPage { + // name: "page_offline"; + // child: Adw.StatusPage { + // //icon-name: "network-wireless-offline-symbolic"; + // title: _("Offline"); + // }; + // } + } + + } + + Box { + hexpand: true; + halign: end; + + styles ["toolbar"] + + // Button speak { + // action-name: "app.speak"; + // tooltip-text: _("Speak"); + // icon-name: "audio-speakers-symbolic"; + // } + + // Button speak_wait { + // visible: false; + // sensitive: false; + // tooltip-text: _("Speaking"); + // Spinner speak_spinner { + // margin-top: 8; + // margin-bottom: 8; + // margin-start: 8; + // margin-end: 8; + // } + // } + + Button copy_bot { + sensitive: false; + icon-name: "edit-copy-symbolic"; + tooltip-text: _("Copy to Clipboard"); + hexpand: true; + halign: end; + action-name: "app.copy_bot"; + } + + Button stop_button { + visible: false; + sensitive: false; + icon-name: "x-circular-symbolic"; + tooltip-text: _("Stop"); + hexpand: true; + halign: end; + action-name: "app.stop"; + styles ["suggested-action", "circular"] + } + } + } + } + + }; } + + + Gtk.StackPage { + name: "page_loading"; + child: Spinner { + valign: center; + halign: center; + vexpand: true; + }; + } + + Gtk.StackPage { + name: "page_error"; + child: Adw.StatusPage error { + visible: true; + vexpand: true; + icon-name: "dialog-error-symbolic"; + title: _("ERROR"); + description: _("DESCRIPTION"); + + Button { + label: _("Try Again"); + halign: center; + styles ["pill"] + } + + }; + } } - Box { - hexpand: true; - halign: end; - styles ["toolbar"] - Button { - sensitive: false; - icon-name: "edit-copy-symbolic"; - tooltip-text: _("Copy to Clipboard"); - action-name: "app.copy_prompt"; - } - // Button listen { - // action-name: "app.listen"; - // tooltip-text: _("Listen"); - // icon-name: "audio-input-microphone-symbolic"; - // } + Separator {} - // Button listen_wait { - // visible: false; - // sensitive: false; - // tooltip-text: _("Listening"); - // Spinner listen_spinner { - // margin-top: 8; - // margin-bottom: 8; - // margin-start: 8; - // margin-end: 8; - // } - // } - Button ask_button { - visible: true; - sensitive: false; - icon-name: "paper-plane-symbolic"; - tooltip-text: _("Ask"); - hexpand: true; - halign: end; - action-name: "app.ask"; - styles ["suggested-action", "circular"] - } - Button wait_button { - visible: false; - sensitive: false; - tooltip-text: _("Wait"); - styles ["suggested-action", "circular"] - Spinner spinner { - margin-top: 8; - margin-bottom: 8; - margin-start: 8; - margin-end: 8; + Adw.Clamp { + vexpand: false; + hexpand: true; + maximum-size: 750; + tightening-threshold: 550; + + Box { + + styles [ "toolbar" ] + + Button { + valign: end; + icon-name: "mail-attachment-symbolic"; + } + + ScrolledWindow { + vexpand: true; + hexpand: true; + vscrollbar-policy: external; + max-content-height: 200; + propagate-natural-height: true; + + styles ["scrolled-window"] + + TextView prompt_text_view { + hexpand: true; + accepts-tab: false; + top-margin: 7; + bottom-margin: 7; + wrap-mode: word; + buffer: TextBuffer { }; + } + } + + Button ask_button { + valign: end; + + icon-name: "paper-plane-symbolic"; + tooltip-text: _("Ask"); + halign: end; + action-name: "app.ask"; styles ["suggested-action", "circular"] } + } } } - } - - Adw.PreferencesGroup bot_group { - title: _("Response"); - - - Box { - orientation: vertical; - hexpand: true; - vexpand: true; - - styles ["card", "text-box"] - - ScrolledWindow scrolled_response_window { - margin-top: 12; - margin-bottom: 0; - margin-start: 12; - margin-end: 12; - styles ["scrolled-window"] - - Gtk.Stack response_stack { - vexpand: true; - hexpand: true; - Gtk.StackPage { - name: "page_response"; - child: TextView bot_text_view { - wrap-mode: word_char; - hexpand: true; - vexpand: true; - editable: false; - }; - } - - // Gtk.StackPage { - // name: "page_offline"; - // child: Adw.StatusPage { - // //icon-name: "network-wireless-offline-symbolic"; - // title: _("Offline"); - // }; - // } - } - - } - - Box { - hexpand: true; - halign: end; - - styles ["toolbar"] - - // Button speak { - // action-name: "app.speak"; - // tooltip-text: _("Speak"); - // icon-name: "audio-speakers-symbolic"; - // } - - // Button speak_wait { - // visible: false; - // sensitive: false; - // tooltip-text: _("Speaking"); - // Spinner speak_spinner { - // margin-top: 8; - // margin-bottom: 8; - // margin-start: 8; - // margin-end: 8; - // } - // } - - Button copy_bot { - sensitive: false; - icon-name: "edit-copy-symbolic"; - tooltip-text: _("Copy to Clipboard"); - hexpand: true; - halign: end; - action-name: "app.copy_bot"; - } - - Button stop_button { - visible: false; - sensitive: false; - icon-name: "x-circular-symbolic"; - tooltip-text: _("Stop"); - hexpand: true; - halign: end; - action-name: "app.stop"; - styles ["suggested-action", "circular"] - } - } - } - } + } } } } diff --git a/src/main.py b/src/main.py index 94dfbe7..6fd0b8a 100644 --- a/src/main.py +++ b/src/main.py @@ -1044,7 +1044,9 @@ class BavarderApplication(Adw.Application): variables["headerbar_border_color"] = variables.get("headerbar_border_color", "#e1e2e4") variables["headerbar_bg_color"] = variables.get("headerbar_bg_color", "#d8dadd") theme_css = ":root {\n" + CUSTOM_STYLE.format(**variables) + " \n}\n" + "@media (prefers-color-scheme: dark) {\n:root {\n" + \ - DARK_CUSTOM_STYLE.format(**variables) + "\n}\n}\n" + css + DARK_CUSTOM_STYLE.format(**variables) + "\n}\n}\n" + print(theme_css) + theme_css += css else: self.use_theme = False theme_css = ADWAITA_STYLE @@ -1078,9 +1080,13 @@ class BavarderApplication(Adw.Application): if self.prompt == "" or self.prompt is None: # empty prompt return else: + self.win.spinner = Gtk.Spinner() + self.win.spinner.set_margin_top(8) + self.win.spinner.set_margin_bottom(8) + self.win.spinner.set_margin_start(8) + self.win.spinner.set_margin_end(8) + self.win.ask_button.set_child(self.win.spinner) self.win.spinner.start() - self.win.ask_button.set_visible(False) - self.win.wait_button.set_visible(True) self.win.stop_button.set_visible(True) def thread_run(): @@ -1094,8 +1100,7 @@ class BavarderApplication(Adw.Application): def cleanup(response): self.win.spinner.stop() - self.win.ask_button.set_visible(True) - self.win.wait_button.set_visible(False) + self.win.ask_button.set_icon_name("paper-plane-symbolic") self.win.stop_button.set_visible(False) GLib.idle_add(self.update_response, response) self.t.join() diff --git a/src/views/main_window.py b/src/views/main_window.py index e73db7b..7659581 100644 --- a/src/views/main_window.py +++ b/src/views/main_window.py @@ -9,9 +9,7 @@ class BavarderWindow(Adw.ApplicationWindow): toast_overlay = Gtk.Template.Child() prompt_text_view = Gtk.Template.Child() - spinner = Gtk.Template.Child() ask_button = Gtk.Template.Child() - wait_button = Gtk.Template.Child() scrolled_response_window = Gtk.Template.Child() bot_text_view = Gtk.Template.Child() response_stack = Gtk.Template.Child()