diff options
Diffstat (limited to 'src/ui/settings.c')
-rw-r--r-- | src/ui/settings.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/ui/settings.c b/src/ui/settings.c index 7583941..87812f2 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -26,6 +26,24 @@ | |||
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | static gboolean | ||
30 | handle_general_switch_state(UNUSED GtkSwitch *widget, | ||
31 | gboolean state, | ||
32 | gpointer user_data) | ||
33 | { | ||
34 | gboolean *setting = (gboolean*) user_data; | ||
35 | *setting = state; | ||
36 | return FALSE; | ||
37 | } | ||
38 | |||
39 | static gboolean | ||
40 | handle_inverted_switch_state(GtkSwitch *widget, | ||
41 | gboolean state, | ||
42 | gpointer user_data) | ||
43 | { | ||
44 | return handle_general_switch_state(widget, !state, user_data); | ||
45 | } | ||
46 | |||
29 | static void | 47 | static void |
30 | handle_dialog_destroy(UNUSED GtkWidget *window, | 48 | handle_dialog_destroy(UNUSED GtkWidget *window, |
31 | gpointer user_data) | 49 | gpointer user_data) |
@@ -50,6 +68,118 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
50 | GTK_WINDOW(app->ui.messenger.main_window) | 68 | GTK_WINDOW(app->ui.messenger.main_window) |
51 | ); | 69 | ); |
52 | 70 | ||
71 | handle->enable_notifications_switch = GTK_SWITCH( | ||
72 | gtk_builder_get_object(handle->builder, "enable_notifications_switch") | ||
73 | ); | ||
74 | |||
75 | gtk_switch_set_active( | ||
76 | handle->enable_notifications_switch, | ||
77 | !(app->settings.disable_notifications) | ||
78 | ); | ||
79 | |||
80 | g_signal_connect( | ||
81 | handle->enable_notifications_switch, | ||
82 | "state-set", | ||
83 | G_CALLBACK(handle_inverted_switch_state), | ||
84 | &(app->settings.disable_notifications) | ||
85 | ); | ||
86 | |||
87 | handle->read_receipts_switch = GTK_SWITCH( | ||
88 | gtk_builder_get_object(handle->builder, "read_receipts_switch") | ||
89 | ); | ||
90 | |||
91 | gtk_switch_set_active( | ||
92 | handle->read_receipts_switch, | ||
93 | app->settings.send_read_receipts | ||
94 | ); | ||
95 | |||
96 | g_signal_connect( | ||
97 | handle->read_receipts_switch, | ||
98 | "state-set", | ||
99 | G_CALLBACK(handle_general_switch_state), | ||
100 | &(app->settings.send_read_receipts) | ||
101 | ); | ||
102 | |||
103 | handle->whispering_switch = GTK_SWITCH( | ||
104 | gtk_builder_get_object(handle->builder, "whispering_switch") | ||
105 | ); | ||
106 | |||
107 | gtk_switch_set_active( | ||
108 | handle->whispering_switch, | ||
109 | app->settings.show_whispering | ||
110 | ); | ||
111 | |||
112 | g_signal_connect( | ||
113 | handle->whispering_switch, | ||
114 | "state-set", | ||
115 | G_CALLBACK(handle_general_switch_state), | ||
116 | &(app->settings.show_whispering) | ||
117 | ); | ||
118 | |||
119 | handle->auto_delete_combo_box = GTK_COMBO_BOX( | ||
120 | gtk_builder_get_object(handle->builder, "auto_delete_combo_box") | ||
121 | ); | ||
122 | |||
123 | handle->auto_accept_invitations_switch = GTK_SWITCH( | ||
124 | gtk_builder_get_object(handle->builder, "auto_accept_invitations_switch") | ||
125 | ); | ||
126 | |||
127 | gtk_switch_set_active( | ||
128 | handle->auto_accept_invitations_switch, | ||
129 | app->settings.accept_all_invitations | ||
130 | ); | ||
131 | |||
132 | g_signal_connect( | ||
133 | handle->auto_accept_invitations_switch, | ||
134 | "state-set", | ||
135 | G_CALLBACK(handle_general_switch_state), | ||
136 | &(app->settings.accept_all_invitations) | ||
137 | ); | ||
138 | |||
139 | handle->delete_invitations_combo_box = GTK_COMBO_BOX( | ||
140 | gtk_builder_get_object(handle->builder, "delete_invitations_combo_box") | ||
141 | ); | ||
142 | |||
143 | handle->delete_invitations_button = GTK_BUTTON( | ||
144 | gtk_builder_get_object(handle->builder, "delete_invitations_button") | ||
145 | ); | ||
146 | |||
147 | handle->auto_accept_files_switch = GTK_SWITCH( | ||
148 | gtk_builder_get_object(handle->builder, "auto_accept_files_switch") | ||
149 | ); | ||
150 | |||
151 | gtk_switch_set_active( | ||
152 | handle->auto_accept_files_switch, | ||
153 | app->settings.accept_all_files | ||
154 | ); | ||
155 | |||
156 | g_signal_connect( | ||
157 | handle->auto_accept_files_switch, | ||
158 | "state-set", | ||
159 | G_CALLBACK(handle_general_switch_state), | ||
160 | &(app->settings.accept_all_files) | ||
161 | ); | ||
162 | |||
163 | handle->download_folder_button = GTK_FILE_CHOOSER_BUTTON( | ||
164 | gtk_builder_get_object(handle->builder, "download_folder_button") | ||
165 | ); | ||
166 | |||
167 | handle->delete_files_combo_box = GTK_COMBO_BOX( | ||
168 | gtk_builder_get_object(handle->builder, "delete_files_combo_box") | ||
169 | ); | ||
170 | |||
171 | handle->delete_files_button = GTK_BUTTON( | ||
172 | gtk_builder_get_object(handle->builder, "delete_files_button") | ||
173 | ); | ||
174 | |||
175 | handle->leave_chats_combo_box = GTK_COMBO_BOX( | ||
176 | gtk_builder_get_object(handle->builder, "leave_chats_combo_box") | ||
177 | ); | ||
178 | |||
179 | handle->leave_chats_button = GTK_BUTTON( | ||
180 | gtk_builder_get_object(handle->builder, "leave_chats_button") | ||
181 | ); | ||
182 | |||
53 | g_signal_connect( | 183 | g_signal_connect( |
54 | handle->dialog, | 184 | handle->dialog, |
55 | "destroy", | 185 | "destroy", |