Skip to content

Commit 5e2c0b4

Browse files
committed
Change Settings dialog to popover
1 parent d909627 commit 5e2c0b4

File tree

5 files changed

+47
-50
lines changed

5 files changed

+47
-50
lines changed

data/Application.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
box-shadow: none;
1313
}
1414

15-
.settings-dialog {
16-
padding-right: 16px;
17-
padding-left: 16px;
15+
.settings-view {
16+
padding: 16px 32px 16px 32px;
1817
}
1918

2019
.form-field {

data/io.github.xchan14.larawan.metainfo.xml.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343

4444

4545
<releases>
46+
<release version="1.3.0" date="2025-04-07">
47+
<description>
48+
<ul>
49+
<li>Changed Settings from dialog to popover</li>
50+
<li>Updated runtime version</li>
51+
</ul>
52+
</description>
53+
</release>
54+
4655
<release version="1.1.1" date="2024-03-03">
4756
<description>
4857
<ul>

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ executable(
3333
'src' / 'widgets' / 'EntryButton.vala',
3434
'src' / 'widgets' / 'AlbumPicker.vala',
3535
'src' / 'views' / 'MainWindow.vala',
36-
'src' / 'views' / 'SettingsDialog.vala',
36+
'src' / 'views' / 'SettingsView.vala',
3737
'src' / 'models' / 'SlideshowImage.vala',
3838
'src' / 'models' / 'SlideshowPlaylist.vala',
3939
'src' / 'models' / 'FileHelper.vala',

src/views/MainWindow.vala

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public class Larawan.Views.MainWindow : Adw.ApplicationWindow {
1616
uint resize_timeout_id = 0;
1717

1818
Stack picture_stack;
19-
SettingsDialog settings_dialog;
2019
GLib.Settings settings;
2120
WindowHandle window_handle;
2221
ScrolledWindow scrolled_window;
23-
Button settings_button;
22+
MenuButton settings_button;
23+
Popover settings_popover;
2424
Stack main_content;
2525
Placeholder empty_dir_placeholder;
2626
Button empty_dir_placeholder_button;
@@ -74,18 +74,24 @@ public class Larawan.Views.MainWindow : Adw.ApplicationWindow {
7474
child = scrolled_window,
7575
};
7676

77-
settings_button = new Button.from_icon_name ("open-menu") {
77+
settings_button = new MenuButton () {
7878
halign = Align.END,
7979
valign = Align.END,
8080
can_focus = false,
8181
tooltip_text = _("Settings"),
8282
vexpand = true,
83-
hexpand = true
83+
hexpand = true,
84+
icon_name = "open-menu",
8485
};
8586
settings_button.add_css_class ("settings-button");
86-
settings_button.clicked.connect (on_settings_button_clicked);
8787
settings_button.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS);
8888

89+
settings_popover = new Popover () {
90+
child = new SettingsView (this),
91+
has_arrow = false,
92+
};
93+
settings_button.popover = settings_popover;
94+
8995
var overlay = new Overlay () {
9096
child = window_handle,
9197
can_target = true,
@@ -123,13 +129,6 @@ public class Larawan.Views.MainWindow : Adw.ApplicationWindow {
123129
}
124130
}
125131

126-
private void on_settings_button_clicked () {
127-
if (settings_dialog == null) {
128-
settings_dialog = new SettingsDialog (this);
129-
}
130-
settings_dialog.show ();
131-
}
132-
133132
private void on_empty_dir_placeholder_button_clicked () {
134133
var initial_folder = File.new_for_path (settings.get_string ("album-folder"));
135134
var file_dialog = new FileDialog () {
@@ -227,6 +226,6 @@ public class Larawan.Views.MainWindow : Adw.ApplicationWindow {
227226

228227
void reload_image () {
229228
info ("Reloading image...");
230-
slideshow_playlist.current ? .load_picture (width_request, height_request);
229+
slideshow_playlist.current ?.load_picture (width_request, height_request);
231230
}
232231
}

src/views/SettingsDialog.vala renamed to src/views/SettingsView.vala

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Granite;
77
using Larawan.Constants;
88
using Larawan.Widgets;
99

10-
public class Larawan.Views.SettingsDialog : Granite.Dialog {
10+
public class Larawan.Views.SettingsView : Box {
1111

1212
const double MAX_WINDOW_HEIGHT = 650;
1313
const double MAX_WINDOW_WIDTH = 650;
@@ -23,26 +23,24 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
2323
Scale window_width_scale;
2424
Scale window_height_scale;
2525
LinkButton startup_linkbutton;
26-
Box root_box;
2726

2827
public ApplicationWindow window { get; construct set; }
2928

30-
public SettingsDialog (ApplicationWindow window) {
29+
public SettingsView (ApplicationWindow window) {
3130
Object (window: window);
3231
}
3332

3433
construct {
35-
transient_for = window;
3634
set_size_request (700, 0);
37-
add_css_class ("settings-dialog");
38-
resizable = false;
39-
root_box = new Box (Orientation.VERTICAL, 10);
35+
add_css_class ("settings-view");
36+
orientation = Orientation.VERTICAL;
37+
spacing = 10;
4038

4139
var slideshow_label = new Label (_("Slideshow")) {
4240
xalign = 0.0f
4341
};
4442
slideshow_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL);
45-
root_box.append (slideshow_label);
43+
append (slideshow_label);
4644
add_album_folder_field ();
4745
add_recursive_field ();
4846
add_duration_field ();
@@ -53,14 +51,12 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
5351
window_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL);
5452
window_label.add_css_class ("window-legend-label");
5553

56-
root_box.append (window_label);
54+
append (window_label);
5755
add_startup_field ();
5856
add_always_visible_field ();
5957
add_width_field ();
6058
add_height_field ();
6159

62-
add_button (_("Close"), Gtk.ResponseType.CANCEL);
63-
get_content_area ().append (root_box);
6460
bind_settings ();
6561
bind_events ();
6662
}
@@ -76,12 +72,6 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
7672
}
7773
});
7874
});
79-
80-
response.connect ((response_id) => {
81-
if (response_id == Gtk.ResponseType.CANCEL) {
82-
hide ();
83-
}
84-
});
8575
}
8676

8777
private void bind_settings () {
@@ -101,17 +91,17 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
10191
hexpand = false
10292
};
10393
album_picker = new AlbumPicker.from_icon_name ("folder-open");
104-
album_picker.hexpand = true;
10594
string pictures_dir = Path.build_filename (Environment.get_home_dir (), "Pictures");
10695

10796
file_dialog = new FileDialog () {
108-
initial_folder = File.new_for_path (pictures_dir)
97+
initial_folder = File.new_for_path (pictures_dir),
98+
modal = true
10999
};
110100

111101
var album_folder_box = new Box (Orientation.HORIZONTAL, 10);
112102
album_folder_box.append (folder_label);
113103
album_folder_box.append (album_picker);
114-
root_box.append (album_folder_box);
104+
append (album_folder_box);
115105
}
116106

117107
private void add_recursive_field () {
@@ -138,7 +128,7 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
138128

139129
box.append (control_box);
140130

141-
root_box.append (box);
131+
append (box);
142132
}
143133

144134
private void add_duration_field () {
@@ -161,7 +151,7 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
161151
duration_box.append (duration_label);
162152
duration_box.append (duration_scale);
163153

164-
root_box.append (duration_box);
154+
append (duration_box);
165155
}
166156

167157
private void add_startup_field () {
@@ -186,7 +176,7 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
186176
box.add_css_class ("form-field");
187177
box.append (label);
188178
box.append (value_box);
189-
root_box.append (box);
179+
append (box);
190180
}
191181

192182
private void add_width_field () {
@@ -197,11 +187,11 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
197187
};
198188

199189
window_width_scale = new Scale.with_range (
200-
Orientation.HORIZONTAL,
201-
MIN_WINDOW_WIDTH,
202-
MAX_WINDOW_WIDTH,
190+
Orientation.HORIZONTAL,
191+
MIN_WINDOW_WIDTH,
192+
MAX_WINDOW_WIDTH,
203193
1
204-
) {
194+
) {
205195
digits = 0,
206196
draw_value = true,
207197
hexpand = true,
@@ -211,7 +201,7 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
211201
box.add_css_class ("form-field");
212202
box.append (window_width_label);
213203
box.append (window_width_scale);
214-
root_box.append (box);
204+
append (box);
215205
}
216206

217207
private void add_height_field () {
@@ -222,11 +212,11 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
222212
};
223213

224214
window_height_scale = new Scale.with_range (
225-
Orientation.HORIZONTAL,
215+
Orientation.HORIZONTAL,
226216
MIN_WINDOW_HEIGHT,
227-
MAX_WINDOW_HEIGHT,
217+
MAX_WINDOW_HEIGHT,
228218
1
229-
) {
219+
) {
230220
digits = 0,
231221
draw_value = true,
232222
hexpand = true,
@@ -236,7 +226,7 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
236226
box.add_css_class ("form-field");
237227
box.append (window_height_label);
238228
box.append (window_height_scale);
239-
root_box.append (box);
229+
append (box);
240230
}
241231

242232
private void add_always_visible_field () {
@@ -254,6 +244,6 @@ public class Larawan.Views.SettingsDialog : Granite.Dialog {
254244
box.add_css_class ("form-field");
255245
box.append (label);
256246
box.append (always_visible_label);
257-
root_box.append (box);
247+
append (box);
258248
}
259249
}

0 commit comments

Comments
 (0)