diff options
Diffstat (limited to 'src/ui/settings.c')
-rw-r--r-- | src/ui/settings.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/ui/settings.c b/src/ui/settings.c index 87812f2..99b487b 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -45,12 +45,49 @@ handle_inverted_switch_state(GtkSwitch *widget, | |||
45 | } | 45 | } |
46 | 46 | ||
47 | static void | 47 | static void |
48 | handle_general_combo_box_change(GtkComboBox *widget, | ||
49 | gpointer user_data) | ||
50 | { | ||
51 | gulong *delay = (gulong*) user_data; | ||
52 | GtkTreeModel *model = gtk_combo_box_get_model(widget); | ||
53 | |||
54 | GtkTreeIter iter; | ||
55 | if (gtk_combo_box_get_active_iter(widget, &iter)) | ||
56 | gtk_tree_model_get(model, &iter, 1, delay, -1); | ||
57 | } | ||
58 | |||
59 | static void | ||
48 | handle_dialog_destroy(UNUSED GtkWidget *window, | 60 | handle_dialog_destroy(UNUSED GtkWidget *window, |
49 | gpointer user_data) | 61 | gpointer user_data) |
50 | { | 62 | { |
51 | ui_settings_dialog_cleanup((UI_SETTINGS_Handle*) user_data); | 63 | ui_settings_dialog_cleanup((UI_SETTINGS_Handle*) user_data); |
52 | } | 64 | } |
53 | 65 | ||
66 | static void | ||
67 | _set_combobox_to_active_by_delay(GtkComboBox *widget, | ||
68 | gulong delay) | ||
69 | { | ||
70 | GtkTreeModel *model = gtk_combo_box_get_model(widget); | ||
71 | |||
72 | GtkTreeIter iter; | ||
73 | if (!gtk_tree_model_get_iter_first(model, &iter)) | ||
74 | return; | ||
75 | |||
76 | gulong value; | ||
77 | |||
78 | do { | ||
79 | gtk_tree_model_get(model, &iter, 1, &value, -1); | ||
80 | |||
81 | if (value == delay) | ||
82 | goto set_active; | ||
83 | |||
84 | } while (gtk_tree_model_iter_next(model, &iter)); | ||
85 | |||
86 | return; | ||
87 | set_active: | ||
88 | gtk_combo_box_set_active_iter(widget, &iter); | ||
89 | } | ||
90 | |||
54 | void | 91 | void |
55 | ui_settings_dialog_init(MESSENGER_Application *app, | 92 | ui_settings_dialog_init(MESSENGER_Application *app, |
56 | UI_SETTINGS_Handle *handle) | 93 | UI_SETTINGS_Handle *handle) |
@@ -120,6 +157,18 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
120 | gtk_builder_get_object(handle->builder, "auto_delete_combo_box") | 157 | gtk_builder_get_object(handle->builder, "auto_delete_combo_box") |
121 | ); | 158 | ); |
122 | 159 | ||
160 | _set_combobox_to_active_by_delay( | ||
161 | handle->auto_delete_combo_box, | ||
162 | app->settings.auto_delete_delay | ||
163 | ); | ||
164 | |||
165 | g_signal_connect( | ||
166 | handle->auto_delete_combo_box, | ||
167 | "changed", | ||
168 | G_CALLBACK(handle_general_combo_box_change), | ||
169 | &(app->settings.auto_delete_delay) | ||
170 | ); | ||
171 | |||
123 | handle->auto_accept_invitations_switch = GTK_SWITCH( | 172 | handle->auto_accept_invitations_switch = GTK_SWITCH( |
124 | gtk_builder_get_object(handle->builder, "auto_accept_invitations_switch") | 173 | gtk_builder_get_object(handle->builder, "auto_accept_invitations_switch") |
125 | ); | 174 | ); |
@@ -140,6 +189,18 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
140 | gtk_builder_get_object(handle->builder, "delete_invitations_combo_box") | 189 | gtk_builder_get_object(handle->builder, "delete_invitations_combo_box") |
141 | ); | 190 | ); |
142 | 191 | ||
192 | _set_combobox_to_active_by_delay( | ||
193 | handle->delete_invitations_combo_box, | ||
194 | app->settings.delete_invitations_delay | ||
195 | ); | ||
196 | |||
197 | g_signal_connect( | ||
198 | handle->delete_invitations_combo_box, | ||
199 | "changed", | ||
200 | G_CALLBACK(handle_general_combo_box_change), | ||
201 | &(app->settings.delete_invitations_delay) | ||
202 | ); | ||
203 | |||
143 | handle->delete_invitations_button = GTK_BUTTON( | 204 | handle->delete_invitations_button = GTK_BUTTON( |
144 | gtk_builder_get_object(handle->builder, "delete_invitations_button") | 205 | gtk_builder_get_object(handle->builder, "delete_invitations_button") |
145 | ); | 206 | ); |
@@ -168,6 +229,18 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
168 | gtk_builder_get_object(handle->builder, "delete_files_combo_box") | 229 | gtk_builder_get_object(handle->builder, "delete_files_combo_box") |
169 | ); | 230 | ); |
170 | 231 | ||
232 | _set_combobox_to_active_by_delay( | ||
233 | handle->delete_files_combo_box, | ||
234 | app->settings.delete_files_delay | ||
235 | ); | ||
236 | |||
237 | g_signal_connect( | ||
238 | handle->delete_files_combo_box, | ||
239 | "changed", | ||
240 | G_CALLBACK(handle_general_combo_box_change), | ||
241 | &(app->settings.delete_files_delay) | ||
242 | ); | ||
243 | |||
171 | handle->delete_files_button = GTK_BUTTON( | 244 | handle->delete_files_button = GTK_BUTTON( |
172 | gtk_builder_get_object(handle->builder, "delete_files_button") | 245 | gtk_builder_get_object(handle->builder, "delete_files_button") |
173 | ); | 246 | ); |
@@ -176,6 +249,18 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
176 | gtk_builder_get_object(handle->builder, "leave_chats_combo_box") | 249 | gtk_builder_get_object(handle->builder, "leave_chats_combo_box") |
177 | ); | 250 | ); |
178 | 251 | ||
252 | _set_combobox_to_active_by_delay( | ||
253 | handle->leave_chats_combo_box, | ||
254 | app->settings.leave_chats_delay | ||
255 | ); | ||
256 | |||
257 | g_signal_connect( | ||
258 | handle->leave_chats_combo_box, | ||
259 | "changed", | ||
260 | G_CALLBACK(handle_general_combo_box_change), | ||
261 | &(app->settings.leave_chats_delay) | ||
262 | ); | ||
263 | |||
179 | handle->leave_chats_button = GTK_BUTTON( | 264 | handle->leave_chats_button = GTK_BUTTON( |
180 | gtk_builder_get_object(handle->builder, "leave_chats_button") | 265 | gtk_builder_get_object(handle->builder, "leave_chats_button") |
181 | ); | 266 | ); |