Skip to content

Commit c352194

Browse files
authored
Merge pull request #315 from AlexanderVanhee/newer-adw-styling
Move to newer Adwaita guidelines
2 parents b2bd93d + 034837b commit c352194

File tree

10 files changed

+258
-244
lines changed

10 files changed

+258
-244
lines changed

src/GearleverWindow.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from gi.repository import Gtk, Adw, Gio, Gdk, GLib
3131

3232

33-
class GearleverWindow(Gtk.ApplicationWindow):
33+
class GearleverWindow(Adw.Window):
3434
def __init__(self, from_file=False, **kwargs):
3535
super().__init__(**kwargs)
3636
self.from_file = from_file
@@ -64,7 +64,9 @@ def __init__(self, from_file=False, **kwargs):
6464
self.titlebar.pack_end(self.search_btn)
6565

6666
self.titlebar.set_title_widget(self.view_title_widget)
67-
self.set_titlebar(self.titlebar)
67+
68+
toolbar_view = Adw.ToolbarView()
69+
toolbar_view.add_top_bar(self.titlebar)
6870

6971
self.set_title('Gear lever')
7072
self.set_default_size(700, 700)
@@ -128,7 +130,8 @@ def __init__(self, from_file=False, **kwargs):
128130

129131
toast_overlay.set_child(self.container_stack)
130132

131-
self.set_child(toast_overlay)
133+
toolbar_view.set_content(toast_overlay)
134+
self.set_content(toolbar_view)
132135

133136
if self.settings.get_boolean('is-maximized'):
134137
self.maximize()
@@ -291,4 +294,4 @@ def on_window_maximixed_changed(self, *args):
291294
self.settings.set_boolean('is-maximized', self.is_maximized())
292295

293296
def on_trigger_search_mode(self, *args):
294-
self.installed_apps_list.trigger_search_mode()
297+
self.installed_apps_list.trigger_search_mode()

src/InstalledAppsList.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,4 @@ def on_update_all_btn_clicked(self, *args):
257257

258258
def on_open_welcome_screen(self, widget):
259259
tutorial = WelcomeScreen()
260-
tutorial.present()
260+
tutorial.present(self)

src/WelcomeScreen.py

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,47 @@
88
from .lib.utils import get_element_without_overscroll, get_gsettings, gio_copy
99
from .lib.constants import APP_ID, APP_NAME, APP_DATA
1010

11-
class WelcomeScreen(Gtk.Window):
11+
class WelcomeScreen(Adw.Dialog):
1212

1313
def __init__(self):
1414
super().__init__()
15-
self.set_default_size(700, 700)
16-
self.set_resizable(False)
1715

1816
pkgdatadir = APP_DATA['PKGDATADIR']
1917

20-
container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, valign=Gtk.Align.CENTER)
21-
self.carousel = Adw.Carousel()
22-
self.carousel.connect('page-changed', self.on_page_changed)
18+
self.set_content_height(600)
19+
self.set_content_width(600)
20+
21+
toolbar_view = Adw.ToolbarView()
2322

24-
self.titlebar = Adw.HeaderBar(show_end_title_buttons=False)
25-
self.left_button = Gtk.Button(icon_name='go-previous', visible=True, sensitive=False)
26-
self.right_button = Gtk.Button(label='Next', visible=True, css_classes=['suggested-action'])
23+
self.titlebar = Adw.HeaderBar()
24+
toolbar_view.add_top_bar(self.titlebar)
2725

28-
self.titlebar.set_title_widget(Gtk.Label(label='Tutorial'))
29-
self.titlebar.pack_start(self.left_button)
30-
self.titlebar.pack_end(self.right_button)
26+
overlay = Gtk.Overlay()
27+
28+
self.carousel = Adw.Carousel(spacing=200)
29+
self.carousel.connect('page-changed', self.on_page_changed)
3130

32-
self.set_titlebar(self.titlebar)
31+
dots = Adw.CarouselIndicatorDots()
32+
dots.set_carousel(self.carousel)
33+
self.titlebar.set_title_widget(dots)
34+
35+
overlay.set_child(self.carousel)
36+
37+
self.left_button = Gtk.Button(icon_name='go-previous')
38+
self.left_button.add_css_class('circular')
39+
self.left_button.set_sensitive(False)
40+
self.left_button.set_halign(Gtk.Align.START)
41+
self.left_button.set_valign(Gtk.Align.CENTER)
42+
self.left_button.set_margin_start(20)
43+
44+
self.right_button = Gtk.Button(icon_name='go-next')
45+
self.right_button.add_css_class('circular')
46+
self.right_button.set_halign(Gtk.Align.END)
47+
self.right_button.set_valign(Gtk.Align.CENTER)
48+
self.right_button.set_margin_end(20)
49+
50+
overlay.add_overlay(self.left_button)
51+
overlay.add_overlay(self.right_button)
3352

3453
first_page = Gtk.Builder.new_from_resource(f'/it/mijorus/{APP_NAME}/gtk/tutorial/1.ui')
3554
second_page = Gtk.Builder.new_from_resource(f'/it/mijorus/{APP_NAME}/gtk/tutorial/2.ui')
@@ -46,7 +65,7 @@ def __init__(self):
4665
self.left_button.connect('clicked', lambda w: self.carousel.scroll_to(get_element_without_overscroll(pages, int(self.carousel.get_position()) - 1), True))
4766
self.right_button.connect('clicked', lambda w: self.carousel.scroll_to(get_element_without_overscroll(pages, int(self.carousel.get_position()) + 1), True))
4867

49-
container.append(self.carousel)
68+
toolbar_view.set_content(overlay)
5069

5170
self.demo_folder = os.path.join(GLib.get_user_cache_dir(), APP_ID, 'demo')
5271
demo_app = Gio.File.new_for_path(os.path.join(pkgdatadir, APP_NAME, 'assets', 'demo.AppImage'))
@@ -63,7 +82,7 @@ def __init__(self):
6382
third_page.get_object('open-demo-folder').connect('clicked', self.on_open_demo_folder_clicked)
6483
second_page.get_object('open-preferences').connect('clicked', self.on_default_localtion_btn_clicked)
6584

66-
self.set_child(container)
85+
self.set_child(toolbar_view)
6786

6887

6988
def on_page_changed(self, widget, index):
@@ -98,7 +117,7 @@ def on_default_localtion_btn_clicked(self, widget):
98117
dialog = Gtk.FileDialog(title=_('Select a folder'), modal=True)
99118

100119
dialog.select_folder(
101-
parent=self,
120+
parent=self.get_root(),
102121
cancellable=None,
103122
callback=self.on_select_default_location_response
104-
)
123+
)

src/gtk/tutorial/1.ui

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<interface>
3-
<requires lib="gtk" version="4.0" />
4-
<object class="GtkBox" id="target">
5-
<property name="orientation">1</property>
6-
<property name="valign">3</property>
7-
<property name="halign">3</property>
8-
<property name="hexpand">1</property>
9-
<child>
10-
<object class="GtkLabel">
11-
<property name="label" translatable="no">👋</property>
12-
<property name="margin-bottom">30</property>
13-
<style>
14-
<class name="title-xl">
15-
</class>
16-
</style>
17-
</object>
18-
</child>
19-
<child>
20-
<object class="GtkLabel">
21-
<property name="label" translatable="yes">Hi, welcome to Gear lever</property>
22-
<property name="margin-bottom">30</property>
23-
<style>
24-
<class name="title-1" />
25-
</style>
26-
</object>
27-
</child>
28-
<child>
29-
<object class="GtkLabel">
30-
<property name="label" translatable="yes">An app that helps you integrate AppImages into your system.</property>
31-
<property name="margin-bottom">30</property>
32-
</object>
33-
</child>
34-
<child>
35-
<object class="GtkLabel">
36-
<property name="label" translatable="yes">Click "Next" to follow this tutorial.</property>
37-
<property name="margin-bottom">30</property>
38-
</object>
39-
</child>
40-
</object>
41-
</interface>
3+
<requires lib="gtk" version="4.0" />
4+
<requires lib="libadwaita" version="1.0" />
5+
<object class="GtkBox" id="target">
6+
<property name="orientation">1</property>
7+
<property name="width-request">400</property>
8+
<property name="valign">center</property>
9+
<child>
10+
<object class="GtkLabel">
11+
<property name="halign">3</property>
12+
<property name="valign">1</property>
13+
<property name="label" translatable="no">👋</property>
14+
<style>
15+
<class name="title-xl" />
16+
</style>
17+
</object>
18+
</child>
19+
<child>
20+
<object class="GtkBox">
21+
<property name="orientation">1</property>
22+
<property name="spacing">12</property>
23+
<property name="halign">center</property>
24+
<child>
25+
<object class="GtkLabel">
26+
<property name="label" translatable="yes">Hi, welcome to Gear lever</property>
27+
<property name="halign">center</property>
28+
<style>
29+
<class name="title-1" />
30+
</style>
31+
</object>
32+
</child>
33+
<child>
34+
<object class="GtkLabel">
35+
<property name="label" translatable="yes">An app that helps you integrate AppImages into your system.</property>
36+
<property name="halign">center</property>
37+
<property name="justify">center</property>
38+
<property name="wrap">true</property>
39+
</object>
40+
</child>
41+
<child>
42+
<object class="GtkLabel">
43+
<property name="label" translatable="yes">Click "Next" to follow this tutorial.</property>
44+
<property name="halign">center</property>
45+
</object>
46+
</child>
47+
</object>
48+
</child>
49+
</object>
50+
</interface>

src/gtk/tutorial/2.ui

Lines changed: 49 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,51 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<interface>
3-
<requires lib="gtk" version="4.0" />
4-
<object class="GtkBox" id="target">
5-
<property name="orientation">1</property>
6-
<property name="valign">3</property>
7-
<property name="halign">3</property>
8-
<property name="hexpand">1</property>
9-
<child>
10-
<object class="GtkImage">
11-
<property name="name">logo</property>
12-
<property name="icon-name">gearlever-file-manager-symbolic</property>
13-
<property name="pixel-size">120</property>
14-
<property name="margin-bottom">30</property>
15-
</object>
16-
</child>
17-
<child>
18-
<object class="GtkLabel">
19-
<property name="label" translatable="yes">Set the AppImage location</property>
20-
<property name="margin-bottom">30</property>
21-
<style>
22-
<class name="title-1" />
23-
</style>
24-
</object>
25-
</child>
26-
<child>
27-
<object class="GtkLabel">
28-
<property name="label" translatable="yes">Gear lever groups all your AppImages into a specific folder and keeps them organized.</property>
29-
</object>
30-
</child>
31-
<child>
32-
<object class="GtkLabel" id="location-label">
33-
<property name="label" translatable="yes">By default, AppImages are saved at: {location}</property>
34-
<style>
35-
<class name="heading" />
36-
</style>
37-
<property name="margin-bottom">30</property>
38-
</object>
39-
</child>
40-
<child>
41-
<object class="GtkBox">
42-
<property name="orientation">1</property>
43-
<property name="valign">3</property>
44-
<property name="halign">3</property>
45-
<child>
46-
<object class="GtkButton" id="open-preferences">
47-
<property name="label" translatable="yes">Change AppImage location</property>
48-
<property name="margin-bottom">10</property>
49-
<property name="vexpand">0</property>
50-
<style>
51-
<class name="pill" />
52-
</style>
53-
</object>
54-
</child>
55-
</object>
56-
</child>
57-
<child>
58-
<object class="GtkLabel">
59-
<property name="label" translatable="yes">You can customize it later in the preferences.</property>
60-
<property name="margin-bottom">30</property>
61-
<style>
62-
<class name="dim-label" />
63-
</style>
64-
</object>
65-
</child>
66-
</object>
67-
</interface>
3+
<requires lib="gtk" version="4.0" />
4+
<requires lib="libadwaita" version="1.0" />
5+
<object class="GtkBox" id="target">
6+
<property name="orientation">1</property>
7+
<property name="width-request">400</property>
8+
<property name="valign">3</property>
9+
<child>
10+
<object class="AdwStatusPage">
11+
<property name="icon-name">gearlever-file-manager-symbolic</property>
12+
<property name="title" translatable="yes">Set the AppImage location</property>
13+
<property name="description" translatable="yes">Gear lever groups all your AppImages into a specific folder and keeps them organized.</property>
14+
<child>
15+
<object class="GtkBox">
16+
<property name="orientation">1</property>
17+
<property name="halign">3</property>
18+
<property name="spacing">20</property>
19+
<child>
20+
<object class="GtkLabel" id="location-label">
21+
<property name="label" translatable="yes">&lt;b&gt;By default, AppImages are saved at: {location}&lt;/b&gt;</property>
22+
<property name="use-markup">1</property>
23+
<property name="wrap">1</property>
24+
<property name="justify">2</property>
25+
</object>
26+
</child>
27+
<child>
28+
<object class="GtkButton" id="open-preferences">
29+
<property name="label" translatable="yes">Change AppImage location</property>
30+
<style>
31+
<class name="pill" />
32+
<class name="suggested-action" />
33+
</style>
34+
</object>
35+
</child>
36+
<child>
37+
<object class="GtkLabel">
38+
<property name="label" translatable="yes">You can customize it later in the preferences.</property>
39+
<property name="wrap">1</property>
40+
<property name="justify">2</property>
41+
<style>
42+
<class name="dim-label" />
43+
</style>
44+
</object>
45+
</child>
46+
</object>
47+
</child>
48+
</object>
49+
</child>
50+
</object>
51+
</interface>

0 commit comments

Comments
 (0)