add keyboard selection and split up pages in seperate classes/files
parent
0ce2e83acd
commit
f0faccb07f
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
if [[ $1 == "build" ]]; then
|
||||||
|
if [[ ! -d "build" ]]; then
|
||||||
|
meson build
|
||||||
|
else
|
||||||
|
meson --reconfigure build
|
||||||
|
fi
|
||||||
|
ninja -C build
|
||||||
|
elif [[ $1 == "install" ]]; then
|
||||||
|
pushd build
|
||||||
|
sudo ninja install
|
||||||
|
elif [[ $1 == "build-install" ]]; then
|
||||||
|
if [[ ! -d "build" ]]; then
|
||||||
|
meson build
|
||||||
|
else
|
||||||
|
meson --reconfigure build
|
||||||
|
fi
|
||||||
|
ninja -C build
|
||||||
|
pushd build
|
||||||
|
sudo ninja install
|
||||||
|
else
|
||||||
|
echo "Unkown command $1"
|
||||||
|
echo "usage:"
|
||||||
|
echo "build build jade gui"
|
||||||
|
echo "install install jade gui"
|
||||||
|
echo "build-install build and install jade_gui"
|
||||||
|
fi
|
@ -0,0 +1,45 @@
|
|||||||
|
from gi.repository import Gtk, Adw
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/al/getcyrst/jadegui/pages/keyboard_screen.ui')
|
||||||
|
class KeyboardScreen(Adw.Bin):
|
||||||
|
__gtype_name__ = 'KeyboardScreen'
|
||||||
|
|
||||||
|
event_controller = Gtk.EventControllerKey.new()
|
||||||
|
#carousel = Gtk.Template.Child()
|
||||||
|
|
||||||
|
### Page and widgets for keyboard screen
|
||||||
|
# keyboard_page = Gtk.Template.Child()
|
||||||
|
keyboard_entry_search = Gtk.Template.Child()
|
||||||
|
keyboard_search = Gtk.Template.Child()
|
||||||
|
keyboard_carousel = Gtk.Template.Child()
|
||||||
|
list_keyboard_layouts = Gtk.Template.Child()
|
||||||
|
list_keyboard_variants = Gtk.Template.Child()
|
||||||
|
keyboard_layouts = Gtk.Template.Child()
|
||||||
|
keyboard_variants = Gtk.Template.Child()
|
||||||
|
|
||||||
|
def __init__(self, window, main_carousel, next_page, application, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.window = window
|
||||||
|
self.carousel = main_carousel
|
||||||
|
self.next_page = next_page
|
||||||
|
### Widgets for third page (keyboard layout)
|
||||||
|
self.keyboard_search.set_key_capture_widget(self)
|
||||||
|
self.list_keyboard_layouts.connect("row-selected", self.selected_layout)
|
||||||
|
self.list_keyboard_variants.connect("row-selected", self.selected_variant)
|
||||||
|
|
||||||
|
def search_keyboards(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def selected_layout(self, widget, row):
|
||||||
|
if row is not None:
|
||||||
|
self.keyboard_carousel.scroll_to(self.keyboard_variants, True)
|
||||||
|
else:
|
||||||
|
print("row is none!! layout")
|
||||||
|
|
||||||
|
def selected_variant(self, widget, row):
|
||||||
|
if row is not None:
|
||||||
|
print("variant selected")
|
||||||
|
else:
|
||||||
|
print("row is none!! variant")
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
|
||||||
|
functionsdir = join_paths(pkgdatadir, 'jade_gui/functions')
|
||||||
|
|
||||||
|
jade_gui_sources = [
|
||||||
|
'__init__.py',
|
||||||
|
'keyboard_screen.py',
|
||||||
|
'timezone_screen.py',
|
||||||
|
]
|
||||||
|
install_data(jade_gui_sources, install_dir: functionsdir)
|
@ -0,0 +1,48 @@
|
|||||||
|
from gi.repository import Gtk, Adw
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/al/getcyrst/jadegui/pages/timezone_screen.ui')
|
||||||
|
class TimezoneScreen(Adw.Bin):
|
||||||
|
__gtype_name__ = 'TimezoneScreen'
|
||||||
|
|
||||||
|
event_controller = Gtk.EventControllerKey.new()
|
||||||
|
#carousel = Gtk.Template.Child()
|
||||||
|
|
||||||
|
### Page and widgets on timezone screen
|
||||||
|
#timezone_page = Gtk.Template.Child()
|
||||||
|
list_timezones = Gtk.Template.Child()
|
||||||
|
timezone_entry_search = Gtk.Template.Child()
|
||||||
|
timezone_search = Gtk.Template.Child()
|
||||||
|
|
||||||
|
def __init__(self, window, main_carousel, next_page, application, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.window = window
|
||||||
|
self.carousel = main_carousel
|
||||||
|
self.next_page = next_page
|
||||||
|
|
||||||
|
|
||||||
|
### Widgets for second page (timezone selection)
|
||||||
|
self.event_controller.connect("key-released", self.search_timezones)
|
||||||
|
self.timezone_entry_search.add_controller(self.event_controller)
|
||||||
|
self.timezone_search.set_key_capture_widget(self)
|
||||||
|
self.list_timezones.connect("row-selected", self.selected_timezone)
|
||||||
|
### ---------
|
||||||
|
|
||||||
|
def selected_timezone(self, widget, row):
|
||||||
|
if row is not None:
|
||||||
|
print(row.get_title())
|
||||||
|
self.carousel.scroll_to(self.next_page, True)
|
||||||
|
else:
|
||||||
|
print("row is none!!")
|
||||||
|
|
||||||
|
def search_timezones(self, *args):
|
||||||
|
terms = self.entry_search.get_text()
|
||||||
|
self.list_timezones.set_filter_func(self.filter_timezones, terms)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def filter_timezones(row, terms=None):
|
||||||
|
text = row.get_title()
|
||||||
|
text = text.lower() + row.get_subtitle().lower()
|
||||||
|
if terms.lower() in text:
|
||||||
|
return True
|
||||||
|
return False
|
@ -0,0 +1,57 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
template KeyboardScreen : Adw.Bin {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
Gtk.Box {
|
||||||
|
vexpand: true;
|
||||||
|
hexpand: true;
|
||||||
|
//halign: center;
|
||||||
|
//valign: center;
|
||||||
|
Adw.StatusPage {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
title: "Next question: keyboard layout?";
|
||||||
|
description: "What is it? Huh?";
|
||||||
|
Gtk.Box {
|
||||||
|
orientation: vertical;
|
||||||
|
Gtk.SearchBar keyboard_search {
|
||||||
|
Gtk.SearchEntry keyboard_entry_search {
|
||||||
|
placeholder-text: "Search for a timezone...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Adw.PreferencesPage {
|
||||||
|
Adw.Carousel keyboard_carousel {
|
||||||
|
orientation: horizontal;
|
||||||
|
vexpand: true;
|
||||||
|
hexpand: true;
|
||||||
|
Adw.PreferencesGroup keyboard_layouts {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
margin-end: 5;
|
||||||
|
Gtk.ListBox list_keyboard_layouts {
|
||||||
|
//selection-mode: none;
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
// margin-end: 5;
|
||||||
|
styles ["boxed-list"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Adw.PreferencesGroup keyboard_variants {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
margin-start: 5;
|
||||||
|
Gtk.ListBox list_keyboard_variants {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
// margin-start: 5;
|
||||||
|
styles ["boxed-list"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
template TimezoneScreen : Adw.Bin {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
Gtk.Box {
|
||||||
|
vexpand: true;
|
||||||
|
hexpand: true;
|
||||||
|
//valign: center;
|
||||||
|
//halign: center;
|
||||||
|
Adw.StatusPage {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
title: "Let's get started, shall we?";
|
||||||
|
description: "What's your curent timezone?";
|
||||||
|
Gtk.Box {
|
||||||
|
orientation: vertical;
|
||||||
|
Gtk.SearchBar timezone_search {
|
||||||
|
Gtk.SearchEntry timezone_entry_search {
|
||||||
|
placeholder-text: "Search for a timezone...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Adw.PreferencesPage {
|
||||||
|
Adw.PreferencesGroup {
|
||||||
|
Gtk.ListBox list_timezones {
|
||||||
|
styles ["boxed-list"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
template KeyboardLayout : Adw.ActionRow {
|
||||||
|
title: "Country";
|
||||||
|
subtitle: "Country Code";
|
||||||
|
Gtk.Box {
|
||||||
|
spacing: 6;
|
||||||
|
Gtk.Image {
|
||||||
|
icon-name: "go-next-symbolic";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
# layout.py
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2022 user
|
||||||
|
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from gi.repository import Gtk, GLib, Adw
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/al/getcyrst/jadegui/widgets/layout.ui')
|
||||||
|
class KeyboardLayout(Adw.ActionRow):
|
||||||
|
__gtype_name__ = 'KeyboardLayout'
|
||||||
|
|
||||||
|
def __init__(self, window, country, country_shorthand, application, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
self.set_title(country)
|
||||||
|
self.set_subtitle(country_shorthand)
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
template KeyboardVariant : Adw.ActionRow {
|
||||||
|
title: "Variant";
|
||||||
|
subtitle: "Country - Country code";
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
# variant.py
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2022 user
|
||||||
|
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from gi.repository import Gtk, GLib, Adw
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/al/getcyrst/jadegui/widgets/variant.ui')
|
||||||
|
class KeyboardVariant(Adw.ActionRow):
|
||||||
|
__gtype_name__ = 'KeyboardVariant'
|
||||||
|
|
||||||
|
def __init__(self, window, variant, country, country_shorthand, application, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
self.set_title(variant)
|
||||||
|
self.set_subtitle(country+" - "+country_shorthand)
|
||||||
|
|
Loading…
Reference in New Issue