Skip to content

Commit a5a7447

Browse files
danirabbitalainm23
authored andcommitted
Use GLib.Settings for mode (#71)
1 parent d056e8a commit a5a7447

File tree

5 files changed

+6
-64
lines changed

5 files changed

+6
-64
lines changed

meson.build

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ executable(
2020
'src/Application.vala',
2121
'src/MainWindow.vala',
2222
'src/Utils.vala',
23-
'src/Backend/Settings.vala',
2423
'src/Widgets/CameraView.vala',
2524
'src/Widgets/HeaderBar.vala',
2625
'src/Widgets/LoadingView.vala',

po/POTFILES

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
src/Application.vala
22
src/MainWindow.vala
33
src/Utils.vala
4-
src/Backend/Settings.vala
54
src/Widgets/CameraView.vala
65
src/Widgets/HeaderBar.vala
76
src/Widgets/LoadingView.vala

src/Backend/Settings.vala

-46
This file was deleted.

src/MainWindow.vala

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
public class Camera.MainWindow : Gtk.Window {
2323
private bool is_fullscreened = false;
2424

25-
private Backend.Settings settings;
26-
2725
private Gtk.Stack stack;
2826
private Granite.Widgets.AlertView no_device_view;
2927

@@ -41,8 +39,6 @@ public class Camera.MainWindow : Gtk.Window {
4139
}
4240

4341
construct {
44-
settings = new Backend.Settings ();
45-
4642
weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_default ();
4743
default_theme.add_resource_path ("/io/elementary/camera");
4844

@@ -54,7 +50,7 @@ public class Camera.MainWindow : Gtk.Window {
5450
this.window_position = Gtk.WindowPosition.CENTER;
5551
this.add_events (Gdk.EventMask.KEY_PRESS_MASK);
5652

57-
header_bar = new Widgets.HeaderBar (settings);
53+
header_bar = new Widgets.HeaderBar ();
5854

5955
stack = new Gtk.Stack ();
6056
stack.transition_type = Gtk.StackTransitionType.CROSSFADE;

src/Widgets/HeaderBar.vala

+5-11
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,10 @@ public class Camera.Widgets.HeaderBar : Gtk.HeaderBar {
4747
}
4848
""";
4949

50-
public Backend.Settings settings { private get; construct; }
51-
5250
public signal void take_photo_clicked ();
5351
public signal void start_recording_clicked ();
5452
public signal void stop_recording_clicked ();
5553

56-
public HeaderBar (Backend.Settings settings) {
57-
Object (settings: settings);
58-
}
59-
6054
construct {
6155
timer_button = new Widgets.TimerButton ();
6256

@@ -104,10 +98,10 @@ public class Camera.Widgets.HeaderBar : Gtk.HeaderBar {
10498

10599
update_take_button_icon ();
106100

107-
settings.action_type_changed.connect (update_take_button_icon);
101+
Camera.Application.settings.changed.connect (update_take_button_icon);
108102

109103
take_button.clicked.connect (() => {
110-
if (settings.get_action_type () == Utils.ActionType.PHOTO) {
104+
if (Camera.Application.settings.get_enum ("mode") == Utils.ActionType.PHOTO) {
111105
start_delay_time (timer_button.delay);
112106
// Time to take a photo
113107
Timeout.add_seconds (timer_button.delay, () => {
@@ -126,9 +120,9 @@ public class Camera.Widgets.HeaderBar : Gtk.HeaderBar {
126120

127121
mode_switch.notify["active"].connect (() => {
128122
if (mode_switch.active) {
129-
settings.set_action_type (Utils.ActionType.VIDEO);
123+
Camera.Application.settings.set_enum ("mode", Utils.ActionType.VIDEO);
130124
} else {
131-
settings.set_action_type (Utils.ActionType.PHOTO);
125+
Camera.Application.settings.set_enum ("mode", Utils.ActionType.PHOTO);
132126
}
133127
});
134128

@@ -157,7 +151,7 @@ public class Camera.Widgets.HeaderBar : Gtk.HeaderBar {
157151
}
158152

159153
private void update_take_button_icon () {
160-
Utils.ActionType action_type = settings.get_action_type ();
154+
var action_type = (Utils.ActionType) Camera.Application.settings.get_enum ("mode");
161155

162156
if (action_type == Utils.ActionType.PHOTO) {
163157
take_image.icon_name = PHOTO_ICON_SYMBOLIC;

0 commit comments

Comments
 (0)