Mercurial > geeqie.yaz
comparison src/preferences.c @ 1042:e59a9c96d290
Shorten config_window_apply() a bit, reduce code redunancy.
author | zas_ |
---|---|
date | Sun, 07 Sep 2008 19:42:19 +0000 |
parents | 9c8d7ba674cf |
children | 77ca9a5d42be |
comparison
equal
deleted
inserted
replaced
1041:ba6462c11bb1 | 1042:e59a9c96d290 |
---|---|
147 *----------------------------------------------------------------------------- | 147 *----------------------------------------------------------------------------- |
148 * sync progam to config window routine (private) | 148 * sync progam to config window routine (private) |
149 *----------------------------------------------------------------------------- | 149 *----------------------------------------------------------------------------- |
150 */ | 150 */ |
151 | 151 |
152 static void config_window_apply(void) | 152 static void config_entry_to_option(GtkWidget *entry, gchar **option, gchar *(*func)(const gchar *)) |
153 { | 153 { |
154 const gchar *buf; | 154 const gchar *buf; |
155 gint new_style; | 155 |
156 g_free(*option); | |
157 *option = NULL; | |
158 buf = gtk_entry_get_text(GTK_ENTRY(entry)); | |
159 if (buf && strlen(buf) > 0) | |
160 { | |
161 if (func) | |
162 *option = func(buf); | |
163 else | |
164 *option = g_strdup(buf); | |
165 } | |
166 } | |
167 | |
168 static void config_parse_editor_entries(GtkWidget **editor_name_entry, GtkWidget **editor_command_entry) | |
169 { | |
156 gint i; | 170 gint i; |
157 gint refresh = FALSE; | 171 const gchar *buf; |
158 | |
159 { | |
160 GString *errmsg = g_string_new(""); | 172 GString *errmsg = g_string_new(""); |
161 | 173 |
162 for (i = 0; i < GQ_EDITOR_SLOTS; i++) | 174 for (i = 0; i < GQ_EDITOR_SLOTS; i++) |
163 { | 175 { |
164 gchar *command = NULL; | 176 gchar *command = NULL; |
196 { | 208 { |
197 file_util_warning_dialog(_("Invalid editor command"), errmsg->str, GTK_STOCK_DIALOG_ERROR, NULL); | 209 file_util_warning_dialog(_("Invalid editor command"), errmsg->str, GTK_STOCK_DIALOG_ERROR, NULL); |
198 } | 210 } |
199 | 211 |
200 g_string_free(errmsg, TRUE); | 212 g_string_free(errmsg, TRUE); |
201 } | 213 } |
214 | |
215 | |
216 static void config_window_apply(void) | |
217 { | |
218 gint new_style; | |
219 gint i; | |
220 gint refresh = FALSE; | |
221 | |
222 config_parse_editor_entries(editor_name_entry, editor_command_entry); | |
202 layout_edit_update_all(); | 223 layout_edit_update_all(); |
203 | 224 |
204 g_free(options->file_ops.safe_delete_path); | 225 config_entry_to_option(safe_delete_path_entry, &options->file_ops.safe_delete_path, remove_trailing_slash); |
205 options->file_ops.safe_delete_path = NULL; | 226 |
206 buf = gtk_entry_get_text(GTK_ENTRY(safe_delete_path_entry)); | |
207 if (buf && strlen(buf) > 0) options->file_ops.safe_delete_path = remove_trailing_slash(buf); | |
208 | |
209 if (options->file_filter.show_hidden_files != c_options->file_filter.show_hidden_files) refresh = TRUE; | 227 if (options->file_filter.show_hidden_files != c_options->file_filter.show_hidden_files) refresh = TRUE; |
210 if (options->file_filter.show_dot_directory != c_options->file_filter.show_dot_directory) refresh = TRUE; | 228 if (options->file_filter.show_dot_directory != c_options->file_filter.show_dot_directory) refresh = TRUE; |
211 if (options->file_sort.case_sensitive != c_options->file_sort.case_sensitive) refresh = TRUE; | 229 if (options->file_sort.case_sensitive != c_options->file_sort.case_sensitive) refresh = TRUE; |
212 if (options->file_filter.disable != c_options->file_filter.disable) refresh = TRUE; | 230 if (options->file_filter.disable != c_options->file_filter.disable) refresh = TRUE; |
213 | 231 |
214 options->startup.restore_path = c_options->startup.restore_path; | 232 options->startup.restore_path = c_options->startup.restore_path; |
215 options->startup.use_last_path = c_options->startup.use_last_path; | 233 options->startup.use_last_path = c_options->startup.use_last_path; |
216 g_free(options->startup.path); | 234 config_entry_to_option(startup_path_entry, &options->startup.path, remove_trailing_slash); |
217 options->startup.path = NULL; | 235 config_entry_to_option(home_path_entry, &options->layout.home_path, remove_trailing_slash); |
218 buf = gtk_entry_get_text(GTK_ENTRY(startup_path_entry)); | |
219 if (buf && strlen(buf) > 0) options->startup.path = remove_trailing_slash(buf); | |
220 | |
221 g_free(options->layout.home_path); | |
222 options->layout.home_path = NULL; | |
223 buf = gtk_entry_get_text(GTK_ENTRY(home_path_entry)); | |
224 if (buf && strlen(buf) > 0) options->layout.home_path = remove_trailing_slash(buf); | |
225 | 236 |
226 options->file_ops.confirm_delete = c_options->file_ops.confirm_delete; | 237 options->file_ops.confirm_delete = c_options->file_ops.confirm_delete; |
227 options->file_ops.enable_delete_key = c_options->file_ops.enable_delete_key; | 238 options->file_ops.enable_delete_key = c_options->file_ops.enable_delete_key; |
228 options->file_ops.safe_delete_enable = c_options->file_ops.safe_delete_enable; | 239 options->file_ops.safe_delete_enable = c_options->file_ops.safe_delete_enable; |
229 options->file_ops.safe_delete_folder_maxsize = c_options->file_ops.safe_delete_folder_maxsize; | 240 options->file_ops.safe_delete_folder_maxsize = c_options->file_ops.safe_delete_folder_maxsize; |
321 #endif | 332 #endif |
322 | 333 |
323 #ifdef HAVE_LCMS | 334 #ifdef HAVE_LCMS |
324 for (i = 0; i < COLOR_PROFILE_INPUTS; i++) | 335 for (i = 0; i < COLOR_PROFILE_INPUTS; i++) |
325 { | 336 { |
326 g_free(options->color_profile.input_name[i]); | 337 config_entry_to_option(color_profile_input_name_entry[i], &options->color_profile.input_name[i], NULL); |
327 options->color_profile.input_name[i] = NULL; | 338 config_entry_to_option(color_profile_input_file_entry[i], &options->color_profile.input_file[i], NULL); |
328 buf = gtk_entry_get_text(GTK_ENTRY(color_profile_input_name_entry[i])); | 339 } |
329 if (buf && strlen(buf) > 0) options->color_profile.input_name[i] = g_strdup(buf); | 340 config_entry_to_option(color_profile_screen_file_entry, &options->color_profile.screen_file, NULL); |
330 | |
331 g_free(options->color_profile.input_file[i]); | |
332 options->color_profile.input_file[i] = NULL; | |
333 buf = gtk_entry_get_text(GTK_ENTRY(color_profile_input_file_entry[i])); | |
334 if (buf && strlen(buf) > 0) options->color_profile.input_file[i] = g_strdup(buf); | |
335 } | |
336 g_free(options->color_profile.screen_file); | |
337 options->color_profile.screen_file = NULL; | |
338 buf = gtk_entry_get_text(GTK_ENTRY(color_profile_screen_file_entry)); | |
339 if (buf && strlen(buf) > 0) options->color_profile.screen_file = g_strdup(buf); | |
340 #endif | 341 #endif |
341 | 342 |
342 for (i = 0; ExifUIList[i].key; i++) | 343 for (i = 0; ExifUIList[i].key; i++) |
343 { | 344 { |
344 ExifUIList[i].current = ExifUIList[i].temp; | 345 ExifUIList[i].current = ExifUIList[i].temp; |