README: add deprecation notice
[nautilus-actions.git] / src / ui / fma-preferences-editor.c
blob9a3dec2a9779f6123117c50bd428b2ca2504c23b
1 /*
2 * FileManager-Actions
3 * A file-manager extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
9 * FileManager-Actions is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * FileManager-Actions is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FileManager-Actions; see the file COPYING. If not, see
21 * <http://www.gnu.org/licenses/>.
23 * Authors:
24 * Frederic Ruaudel <grumz@grumz.net>
25 * Rodrigo Moya <rodrigo@gnome-db.org>
26 * Pierre Wieser <pwieser@trychlos.org>
27 * ... and many others (see AUTHORS)
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
34 #include <glib/gi18n.h>
35 #include <libintl.h>
37 #include <api/fma-iimporter.h>
39 #include <core/fma-desktop-environment.h>
40 #include <core/fma-exporter.h>
41 #include <core/fma-export-format.h>
42 #include <core/fma-gtk-utils.h>
43 #include <core/fma-import-mode.h>
44 #include <core/fma-importer.h>
45 #include <core/fma-ioptions-list.h>
46 #include <core/fma-iprefs.h>
47 #include <core/fma-tokens.h>
49 #include "fma-application.h"
50 #include "base-gtk-utils.h"
51 #include "fma-main-window.h"
52 #include "fma-schemes-list.h"
53 #include "fma-providers-list.h"
54 #include "fma-preferences-editor.h"
56 /* private class data
58 struct _FMAPreferencesEditorClassPrivate {
59 void *empty; /* so that gcc -pedantic is happy */
62 /* private instance data
64 struct _FMAPreferencesEditorPrivate {
65 gboolean dispose_has_run;
66 gboolean preferences_locked;
68 /* first tab: runtime preferences */
69 guint order_mode;
70 gboolean order_mode_mandatory;
71 gboolean root_menu;
72 gboolean root_menu_mandatory;
73 gboolean about_item;
74 gboolean about_item_mandatory;
76 /* second tab: runtime execution */
77 gchar *terminal_pattern;
78 gboolean terminal_pattern_mandatory;
79 gchar *desktop;
80 gboolean desktop_mandatory;
82 /* third tab: ui preferences */
83 gboolean relabel_menu;
84 gboolean relabel_menu_mandatory;
85 gboolean relabel_action;
86 gboolean relabel_action_mandatory;
87 gboolean relabel_profile;
88 gboolean relabel_profile_mandatory;
89 gboolean esc_quit;
90 gboolean esc_quit_mandatory;
91 gboolean esc_confirm;
92 gboolean esc_confirm_mandatory;
93 gboolean auto_save;
94 gboolean auto_save_mandatory;
95 guint auto_save_period;
96 gboolean auto_save_period_mandatory;
98 /* fourth tab: import mode */
99 guint import_mode;
100 gboolean import_mode_mandatory;
102 /* fifth tab: export format */
103 gboolean export_format_mandatory;
105 /* sixth tab: default list of available schemes */
106 /* seventh tab: i/o providers */
109 /* column ordering in the desktop environment combobox
111 enum {
112 DESKTOP_ID_COLUMN = 0,
113 DESKTOP_LABEL_COLUMN = 0,
114 DESKTOP_N_COLUMN
117 /* i18n: the user is not willing to identify his current desktop environment,
118 * and prefers rely on the runtime detection */
119 static const FMADesktopEnv st_no_desktop = { "None", N_( "Rely on runtime detection" ) };
121 #define st_xmlui_filename PKGUIDIR "/fma-preferences.ui"
122 static const gchar *st_toplevel_name = "PreferencesDialog";
123 static const gchar *st_wsp_name = IPREFS_PREFERENCES_WSP;
125 static GObjectClass *st_parent_class = NULL;
126 static guint st_last_tab = 0;
128 static GType register_type( void );
129 static void class_init( FMAPreferencesEditorClass *klass );
130 static void ioptions_list_iface_init( FMAIOptionsListInterface *iface, void *user_data );
131 static GList *ioptions_list_get_options( const FMAIOptionsList *instance, GtkWidget *container );
132 static void ioptions_list_free_options( const FMAIOptionsList *instance, GtkWidget *container, GList *options );
133 static FMAIOption *ioptions_list_get_ask_option( const FMAIOptionsList *instance, GtkWidget *container );
134 static void instance_init( GTypeInstance *instance, gpointer klass );
135 static void instance_constructed( GObject *dialog );
136 static void instance_dispose( GObject *dialog );
137 static void instance_finalize( GObject *dialog );
139 static void on_base_initialize_gtk( FMAPreferencesEditor *editor, GtkDialog *toplevel, gpointer user_data );
140 static void on_base_initialize_window( FMAPreferencesEditor *editor, gpointer user_data );
141 static void on_base_show_widgets( FMAPreferencesEditor *editor, gpointer user_data );
142 static void order_mode_setup( FMAPreferencesEditor *editor );
143 static void order_mode_on_alpha_asc_toggled( GtkToggleButton *togglebutton, FMAPreferencesEditor *editor );
144 static void order_mode_on_alpha_desc_toggled( GtkToggleButton *togglebutton, FMAPreferencesEditor *editor );
145 static void order_mode_on_manual_toggled( GtkToggleButton *togglebutton, FMAPreferencesEditor *editor );
146 static void order_mode_on_toggled( FMAPreferencesEditor *editor, GtkToggleButton *togglebutton, GCallback cb, guint order_mode );
147 static void root_menu_setup( FMAPreferencesEditor *editor );
148 static void root_menu_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
149 static void about_item_setup( FMAPreferencesEditor *editor );
150 static void about_item_set_sensitive( FMAPreferencesEditor *editor );
151 static void about_item_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
152 static void terminal_pattern_setup( FMAPreferencesEditor *editor );
153 static void terminal_pattern_on_changed( GtkEntry *entry, FMAPreferencesEditor *editor );
154 static void desktop_create_model( FMAPreferencesEditor *editor );
155 static void desktop_setup( FMAPreferencesEditor *editor );
156 static void desktop_on_changed( GtkComboBox *combo, FMAPreferencesEditor *editor );
157 static void relabel_menu_setup( FMAPreferencesEditor *editor );
158 static void relabel_menu_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
159 static void relabel_action_setup( FMAPreferencesEditor *editor );
160 static void relabel_action_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
161 static void relabel_profile_setup( FMAPreferencesEditor *editor );
162 static void relabel_profile_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
163 static void esc_quit_setup( FMAPreferencesEditor *editor );
164 static void esc_quit_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
165 static void esc_confirm_setup( FMAPreferencesEditor *editor );
166 static void esc_confirm_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
167 static void auto_save_setup( FMAPreferencesEditor *editor );
168 static void auto_save_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor );
169 static void auto_save_period_on_change_value( GtkSpinButton *spinbutton, FMAPreferencesEditor *editor );
170 static void on_cancel_clicked( GtkButton *button, FMAPreferencesEditor *editor );
171 static void on_ok_clicked( GtkButton *button, FMAPreferencesEditor *editor );
172 static void on_dialog_ok( BaseDialog *dialog );
174 GType
175 fma_preferences_editor_get_type( void )
177 static GType dialog_type = 0;
179 if( !dialog_type ){
180 dialog_type = register_type();
183 return( dialog_type );
186 static GType
187 register_type( void )
189 static const gchar *thisfn = "fma_preferences_editor_register_type";
190 GType type;
192 static GTypeInfo info = {
193 sizeof( FMAPreferencesEditorClass ),
194 ( GBaseInitFunc ) NULL,
195 ( GBaseFinalizeFunc ) NULL,
196 ( GClassInitFunc ) class_init,
197 NULL,
198 NULL,
199 sizeof( FMAPreferencesEditor ),
201 ( GInstanceInitFunc ) instance_init
204 static const GInterfaceInfo ioptions_list_iface_info = {
205 ( GInterfaceInitFunc ) ioptions_list_iface_init,
206 NULL,
207 NULL
210 g_debug( "%s", thisfn );
212 type = g_type_register_static( BASE_TYPE_DIALOG, "FMAPreferencesEditor", &info, 0 );
214 g_type_add_interface_static( type, FMA_TYPE_IOPTIONS_LIST, &ioptions_list_iface_info );
216 return( type );
219 static void
220 class_init( FMAPreferencesEditorClass *klass )
222 static const gchar *thisfn = "fma_preferences_editor_class_init";
223 GObjectClass *object_class;
224 BaseDialogClass *dialog_class;
226 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
228 st_parent_class = g_type_class_peek_parent( klass );
230 object_class = G_OBJECT_CLASS( klass );
231 object_class->constructed = instance_constructed;
232 object_class->dispose = instance_dispose;
233 object_class->finalize = instance_finalize;
235 dialog_class = BASE_DIALOG_CLASS( klass );
236 dialog_class->ok = on_dialog_ok;
239 static void
240 ioptions_list_iface_init( FMAIOptionsListInterface *iface, void *user_data )
242 static const gchar *thisfn = "fma_assistant_export_ioptions_list_iface_init";
244 g_debug( "%s: iface=%p, user_data=%p", thisfn, ( void * ) iface, ( void * ) user_data );
246 iface->get_options = ioptions_list_get_options;
247 iface->free_options = ioptions_list_free_options;
248 iface->get_ask_option = ioptions_list_get_ask_option;
252 * ioptions_list_get_options, ioptions_list_free_options:
253 * manages import mode options or export format options depending of the
254 * current container
256 static GList *
257 ioptions_list_get_options( const FMAIOptionsList *instance, GtkWidget *container )
259 static const gchar *thisfn = "fma_preferences_editor_ioptions_list_get_options";
260 GList *options;
261 FMAApplication *application;
262 FMAUpdater *updater;
264 g_return_val_if_fail( FMA_IS_PREFERENCES_EDITOR( instance ), NULL );
266 options = NULL;
268 if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesExportFormatParent" )){
269 application = FMA_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
270 updater = fma_application_get_updater( application );
271 options = fma_exporter_get_formats( FMA_PIVOT( updater ));
273 } else if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesImportModeParent" )){
274 options = fma_importer_get_modes();
276 } else {
277 g_warning( "%s: container=%p (%s): unmanaged container",
278 thisfn,
279 ( void * ) container, G_OBJECT_TYPE_NAME( container ));
282 return( options );
285 static void
286 ioptions_list_free_options( const FMAIOptionsList *instance, GtkWidget *container, GList *options )
288 static const gchar *thisfn = "fma_preferences_editor_ioptions_list_free_options";
290 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( instance ));
292 if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesExportFormatParent" )){
293 fma_exporter_free_formats( options );
295 } else if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesImportModeParent" )){
296 fma_importer_free_modes( options );
298 } else {
299 g_warning( "%s: container=%p (%s): unmanaged container",
300 thisfn,
301 ( void * ) container, G_OBJECT_TYPE_NAME( container ));
305 static FMAIOption *
306 ioptions_list_get_ask_option( const FMAIOptionsList *instance, GtkWidget *container )
308 static const gchar *thisfn = "fma_preferences_editor_ioptions_list_get_ask_option";
309 FMAIOption *option;
311 g_return_val_if_fail( FMA_IS_PREFERENCES_EDITOR( instance ), NULL );
313 option = NULL;
315 if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesExportFormatParent" )){
316 option = fma_exporter_get_ask_option();
318 } else if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesImportModeParent" )){
319 option = fma_importer_get_ask_mode();
321 } else {
322 g_warning( "%s: container=%p (%s): unmanaged container",
323 thisfn,
324 ( void * ) container, G_OBJECT_TYPE_NAME( container ));
327 return( option );
330 static void
331 instance_init( GTypeInstance *instance, gpointer klass )
333 static const gchar *thisfn = "fma_preferences_editor_instance_init";
334 FMAPreferencesEditor *self;
336 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( instance ));
338 g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
340 self = FMA_PREFERENCES_EDITOR( instance );
342 self->private = g_new0( FMAPreferencesEditorPrivate, 1 );
344 self->private->dispose_has_run = FALSE;
347 static void
348 instance_constructed( GObject *dialog )
350 static const gchar *thisfn = "fma_preferences_editor_instance_constructed";
351 FMAPreferencesEditorPrivate *priv;
353 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( dialog ));
355 priv = FMA_PREFERENCES_EDITOR( dialog )->private;
357 if( !priv->dispose_has_run ){
359 /* chain up to the parent class */
360 if( G_OBJECT_CLASS( st_parent_class )->constructed ){
361 G_OBJECT_CLASS( st_parent_class )->constructed( dialog );
364 g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
366 base_window_signal_connect(
367 BASE_WINDOW( dialog ),
368 G_OBJECT( dialog ),
369 BASE_SIGNAL_INITIALIZE_GTK,
370 G_CALLBACK( on_base_initialize_gtk ));
372 base_window_signal_connect(
373 BASE_WINDOW( dialog ),
374 G_OBJECT( dialog ),
375 BASE_SIGNAL_INITIALIZE_WINDOW,
376 G_CALLBACK( on_base_initialize_window ));
378 base_window_signal_connect(
379 BASE_WINDOW( dialog ),
380 G_OBJECT( dialog ),
381 BASE_SIGNAL_SHOW_WIDGETS,
382 G_CALLBACK( on_base_show_widgets ));
386 static void
387 instance_dispose( GObject *dialog )
389 static const gchar *thisfn = "fma_preferences_editor_instance_dispose";
390 FMAPreferencesEditor *self;
392 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( dialog ));
394 self = FMA_PREFERENCES_EDITOR( dialog );
396 if( !self->private->dispose_has_run ){
397 g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
399 self->private->dispose_has_run = TRUE;
401 fma_schemes_list_dispose( BASE_WINDOW( self ));
402 fma_providers_list_dispose( BASE_WINDOW( self ));
404 /* chain up to the parent class */
405 if( G_OBJECT_CLASS( st_parent_class )->dispose ){
406 G_OBJECT_CLASS( st_parent_class )->dispose( dialog );
411 static void
412 instance_finalize( GObject *dialog )
414 static const gchar *thisfn = "fma_preferences_editor_instance_finalize";
415 FMAPreferencesEditor *self;
417 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( dialog ));
419 g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
421 self = FMA_PREFERENCES_EDITOR( dialog );
423 g_free( self->private );
425 /* chain call to parent class */
426 if( G_OBJECT_CLASS( st_parent_class )->finalize ){
427 G_OBJECT_CLASS( st_parent_class )->finalize( dialog );
432 * fma_preferences_editor_run:
433 * @parent: the FMAMainWindow main window
435 * Initializes and runs the dialog.
437 void
438 fma_preferences_editor_run( FMAMainWindow *parent )
440 static const gchar *thisfn = "fma_preferences_editor_run";
441 FMAPreferencesEditor *editor;
442 gboolean are_locked, mandatory;
443 GtkNotebook *notebook;
445 g_return_if_fail( parent && FMA_IS_MAIN_WINDOW( parent ));
447 g_debug( "%s: parent=%p (%s)", thisfn, ( void * ) parent, G_OBJECT_TYPE_NAME( parent ));
449 editor = g_object_new( FMA_TYPE_PREFERENCES_EDITOR,
450 BASE_PROP_MAIN_WINDOW, parent,
451 BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
453 * having our own builder let us, e.g., set a weak reference on
454 * pixbufs allocated by plugins - but this way we are losing
455 * mutualization of gtk initializations...
457 /*BASE_PROP_HAS_OWN_BUILDER, TRUE,*/
458 BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
459 BASE_PROP_WSP_NAME, st_wsp_name,
460 NULL );
462 are_locked = fma_settings_get_boolean( IPREFS_ADMIN_PREFERENCES_LOCKED, NULL, &mandatory );
463 editor->private->preferences_locked = are_locked && mandatory;
464 g_debug( "%s: are_locked=%s, mandatory=%s",
465 thisfn, are_locked ? "True":"False", mandatory ? "True":"False" );
467 base_window_run( BASE_WINDOW( editor ));
469 notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( editor ), "PreferencesNotebook" ));
470 st_last_tab = gtk_notebook_get_current_page( notebook );
472 g_object_unref( editor );
475 static void
476 on_base_initialize_gtk( FMAPreferencesEditor *editor, GtkDialog *toplevel, gpointer user_data )
478 static const gchar *thisfn = "fma_preferences_editor_on_base_initialize_gtk";
479 GtkWidget *container;
480 GtkTreeView *listview;
482 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( editor ));
484 if( !editor->private->dispose_has_run ){
486 g_debug( "%s: dialog=%p, toplevel=%p, user_data=%p",
487 thisfn, ( void * ) editor, ( void * ) toplevel, ( void * ) user_data );
489 desktop_create_model( editor );
491 container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesImportModeParent" );
492 fma_ioptions_list_gtk_init( FMA_IOPTIONS_LIST( editor ), container, TRUE );
494 container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatParent" );
495 fma_ioptions_list_gtk_init( FMA_IOPTIONS_LIST( editor ), container, TRUE );
497 listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "SchemesTreeView" ));
498 fma_schemes_list_create_model( listview, SCHEMES_LIST_FOR_PREFERENCES );
500 listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
501 fma_providers_list_create_model( listview );
505 static void
506 on_base_initialize_window( FMAPreferencesEditor *editor, gpointer user_data )
508 static const gchar *thisfn = "fma_preferences_editor_on_base_initialize_window";
509 GtkWidget *container;
510 GtkTreeView *listview;
511 GtkWidget *ok_button;
512 gchar *export_format;
513 gchar *import_mode;
515 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( editor ));
517 if( !editor->private->dispose_has_run ){
519 g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
521 /* first tab: runtime preferences
523 order_mode_setup( editor );
524 root_menu_setup( editor );
525 about_item_setup( editor );
527 /* second tab: runtime execution
529 terminal_pattern_setup( editor );
530 desktop_setup( editor );
532 /* third tab: ui preferences
534 relabel_menu_setup( editor );
535 relabel_action_setup( editor );
536 relabel_profile_setup( editor );
537 esc_quit_setup( editor );
538 esc_confirm_setup( editor );
539 auto_save_setup( editor );
541 /* fourth tab: import mode
543 container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesImportModeParent" );
544 import_mode = fma_settings_get_string( IPREFS_IMPORT_PREFERRED_MODE, NULL, &editor->private->import_mode_mandatory );
545 fma_ioptions_list_set_editable(
546 FMA_IOPTIONS_LIST( editor ), container,
547 !editor->private->import_mode_mandatory && !editor->private->preferences_locked );
548 fma_ioptions_list_set_default(
549 FMA_IOPTIONS_LIST( editor ), container,
550 import_mode );
551 g_free( import_mode );
553 /* fifth tab: export format
555 container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatParent" );
556 export_format = fma_settings_get_string( IPREFS_EXPORT_PREFERRED_FORMAT, NULL, &editor->private->export_format_mandatory );
557 fma_ioptions_list_set_editable(
558 FMA_IOPTIONS_LIST( editor ), container,
559 !editor->private->export_format_mandatory && !editor->private->preferences_locked );
560 fma_ioptions_list_set_default(
561 FMA_IOPTIONS_LIST( editor ), container,
562 export_format );
563 g_free( export_format );
565 /* sixth tab: default schemes
567 listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "SchemesTreeView" ));
568 fma_schemes_list_init_view( listview, BASE_WINDOW( editor ), NULL, NULL );
570 /* seventh tab: I/O providers priorities
572 listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
573 fma_providers_list_init_view( BASE_WINDOW( editor ), listview );
575 /* dialog buttons
577 base_window_signal_connect_by_name( BASE_WINDOW( editor ),
578 "CancelButton", "clicked", G_CALLBACK( on_cancel_clicked ));
580 ok_button = base_window_get_widget( BASE_WINDOW( editor ), "OKButton" );
581 base_window_signal_connect( BASE_WINDOW( editor ),
582 G_OBJECT( ok_button ), "clicked", G_CALLBACK( on_ok_clicked ));
583 base_gtk_utils_set_editable( G_OBJECT( ok_button ), !editor->private->preferences_locked );
587 static void
588 on_base_show_widgets( FMAPreferencesEditor *editor, gpointer user_data )
590 static const gchar *thisfn = "fma_preferences_editor_on_base_show_widgets";
591 GtkNotebook *notebook;
593 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( editor ));
595 if( !editor->private->dispose_has_run ){
597 g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
599 notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( editor ), "PreferencesNotebook" ));
600 gtk_notebook_set_current_page( notebook, st_last_tab );
602 fma_schemes_list_show_all( BASE_WINDOW( editor ));
607 * 'order mode' is editable if preferences in general are not locked,
608 * and this one is not mandatory.
610 * This is not related in any way to the level zero order writability status
612 * The radio button group is insensitive if preferences are locked.
613 * If preferences in general are not locked, but this one is mandatory,
614 * then the radio group is sensitive, but not editable.
616 static void
617 order_mode_setup( FMAPreferencesEditor *editor )
619 gboolean editable;
620 GtkWidget *alpha_asc_button, *alpha_desc_button, *manual_button;
621 GtkWidget *active_button;
622 GCallback active_handler;
624 editor->private->order_mode = fma_iprefs_get_order_mode( &editor->private->order_mode_mandatory );
625 editable = !editor->private->preferences_locked && !editor->private->order_mode_mandatory;
627 alpha_asc_button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaAscButton" );
628 base_window_signal_connect( BASE_WINDOW( editor ), G_OBJECT( alpha_asc_button ), "toggled", G_CALLBACK( order_mode_on_alpha_asc_toggled ));
630 alpha_desc_button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaDescButton" );
631 base_window_signal_connect( BASE_WINDOW( editor ), G_OBJECT( alpha_desc_button ), "toggled", G_CALLBACK( order_mode_on_alpha_desc_toggled ));
633 manual_button = base_window_get_widget( BASE_WINDOW( editor ), "OrderManualButton" );
634 base_window_signal_connect( BASE_WINDOW( editor ), G_OBJECT( manual_button ), "toggled", G_CALLBACK( order_mode_on_manual_toggled ));
636 switch( editor->private->order_mode ){
637 case IPREFS_ORDER_ALPHA_ASCENDING:
638 active_button = alpha_asc_button;
639 active_handler = G_CALLBACK( order_mode_on_alpha_asc_toggled );
640 break;
641 case IPREFS_ORDER_ALPHA_DESCENDING:
642 active_button = alpha_desc_button;
643 active_handler = G_CALLBACK( order_mode_on_alpha_desc_toggled );
644 break;
645 case IPREFS_ORDER_MANUAL:
646 default:
647 active_button = manual_button;
648 active_handler = G_CALLBACK( order_mode_on_manual_toggled );
649 break;
652 base_gtk_utils_radio_set_initial_state(
653 GTK_RADIO_BUTTON( active_button ),
654 active_handler, editor, editable, !editor->private->preferences_locked );
657 static void
658 order_mode_on_alpha_asc_toggled( GtkToggleButton *toggle_button, FMAPreferencesEditor *editor )
660 order_mode_on_toggled( editor, toggle_button, G_CALLBACK( order_mode_on_alpha_asc_toggled ), IPREFS_ORDER_ALPHA_ASCENDING );
663 static void
664 order_mode_on_alpha_desc_toggled( GtkToggleButton *toggle_button, FMAPreferencesEditor *editor )
666 order_mode_on_toggled( editor, toggle_button, G_CALLBACK( order_mode_on_alpha_desc_toggled ), IPREFS_ORDER_ALPHA_DESCENDING );
669 static void
670 order_mode_on_manual_toggled( GtkToggleButton *toggle_button, FMAPreferencesEditor *editor )
672 order_mode_on_toggled( editor, toggle_button, G_CALLBACK( order_mode_on_manual_toggled ), IPREFS_ORDER_MANUAL );
675 static void
676 order_mode_on_toggled( FMAPreferencesEditor *editor, GtkToggleButton *toggle_button, GCallback cb, guint order_mode )
678 gboolean editable;
679 gboolean active;
681 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toggle_button ), FMA_TOGGLE_DATA_EDITABLE ));
683 if( editable ){
684 active = gtk_toggle_button_get_active( toggle_button );
685 if( active ){
686 editor->private->order_mode = order_mode;
688 } else {
689 base_gtk_utils_radio_reset_initial_state( GTK_RADIO_BUTTON( toggle_button ), cb );
694 * create a root menu
696 static void
697 root_menu_setup( FMAPreferencesEditor *editor )
699 gboolean editable;
701 editor->private->root_menu = fma_settings_get_boolean( IPREFS_ITEMS_CREATE_ROOT_MENU, NULL, &editor->private->root_menu_mandatory );
702 editable = !editor->private->preferences_locked && !editor->private->root_menu_mandatory;
704 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
705 "CreateRootMenuButton", G_CALLBACK( root_menu_on_toggled ),
706 editor->private->root_menu, editable, !editor->private->preferences_locked );
709 static void
710 root_menu_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
712 gboolean editable;
714 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
716 if( editable ){
717 editor->private->root_menu = gtk_toggle_button_get_active( button );
718 about_item_set_sensitive( editor );
720 } else {
721 base_gtk_utils_toggle_reset_initial_state( button );
726 * add an about item
728 * The About item is only added if the FileManager-Actions root menu exists
730 static void
731 about_item_setup( FMAPreferencesEditor *editor )
733 gboolean editable;
735 editor->private->about_item = fma_settings_get_boolean( IPREFS_ITEMS_ADD_ABOUT_ITEM, NULL, &editor->private->about_item_mandatory );
736 editable = !editor->private->preferences_locked && !editor->private->about_item_mandatory;
738 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
739 "AddAboutButton", G_CALLBACK( about_item_on_toggled ),
740 editor->private->about_item, editable, !editor->private->preferences_locked );
742 about_item_set_sensitive( editor );
745 static void
746 about_item_set_sensitive( FMAPreferencesEditor *editor )
748 GtkWidget *add_about;
750 add_about = base_window_get_widget( BASE_WINDOW( editor ), "AddAboutButton" );
751 gtk_widget_set_sensitive( add_about, editor->private->root_menu );
754 static void
755 about_item_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
757 gboolean editable;
759 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
761 if( editable ){
762 editor->private->about_item = gtk_toggle_button_get_active( button );
764 } else {
765 base_gtk_utils_toggle_reset_initial_state( button );
770 * terminal command
771 * the command when execution mode is 'Terminal'
772 * should have a 'COMMAND' keyword inside
774 static void
775 terminal_pattern_setup( FMAPreferencesEditor *editor )
777 gboolean editable;
778 GtkWidget *entry;
780 editor->private->terminal_pattern = fma_settings_get_string( IPREFS_TERMINAL_PATTERN, NULL, &editor->private->terminal_pattern_mandatory );
781 editable = !editor->private->preferences_locked && !editor->private->terminal_pattern_mandatory;
783 entry = base_window_get_widget( BASE_WINDOW( editor ), "TerminalPrefixEntry" );
784 gtk_entry_set_text( GTK_ENTRY( entry ), editor->private->terminal_pattern );
785 gtk_widget_set_sensitive( entry, !editor->private->preferences_locked );
786 base_gtk_utils_set_editable( G_OBJECT( entry ), editable );
788 terminal_pattern_on_changed( GTK_ENTRY( entry ), editor );
790 base_window_signal_connect( BASE_WINDOW( editor ),
791 G_OBJECT( entry ), "changed", G_CALLBACK( terminal_pattern_on_changed ));
794 static void
795 terminal_pattern_on_changed( GtkEntry *entry, FMAPreferencesEditor *editor )
797 gboolean editable;
798 gchar *example_label;
799 gchar *example_markup;
800 GtkWidget *example_widget;
802 editable = !editor->private->preferences_locked && !editor->private->terminal_pattern_mandatory;
804 if( editable ){
805 g_free( editor->private->terminal_pattern );
806 editor->private->terminal_pattern = g_strdup( gtk_entry_get_text( entry ));
808 example_widget = base_window_get_widget( BASE_WINDOW( editor ), "TerminalPrefixExample" );
809 example_label = fma_tokens_command_for_terminal( editor->private->terminal_pattern, "ls -l" );
811 /* i18n: command-line example: Ex.: gnome-terminal -c "ls -l" */
812 example_markup = g_markup_printf_escaped(
813 "<i><b><span size=\"small\">%s %s</span></b></i>", _( "Ex.:" ), example_label );
815 gtk_label_set_label( GTK_LABEL( example_widget ), example_markup );
817 g_free( example_label );
818 g_free( example_markup );
823 * desktop environment
824 * for OnlyShowIn and NotshowIn contexts
826 static void
827 desktop_create_model( FMAPreferencesEditor *editor )
829 GtkWidget *combo;
830 GtkListStore *model;
831 GtkCellRenderer *text_cell;
832 const FMADesktopEnv *desktops;
833 guint i;
834 GtkTreeIter row;
836 combo = base_window_get_widget( BASE_WINDOW( editor ), "DesktopComboBox" );
837 model = gtk_list_store_new( DESKTOP_N_COLUMN, G_TYPE_STRING, G_TYPE_STRING );
838 gtk_combo_box_set_model( GTK_COMBO_BOX( combo ), GTK_TREE_MODEL( model ));
839 g_object_unref( model );
841 /* id */
842 text_cell = gtk_cell_renderer_text_new();
843 gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), text_cell, FALSE );
844 gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), text_cell, "text", 0, NULL );
845 gtk_cell_renderer_set_visible( GTK_CELL_RENDERER( text_cell ), FALSE );
847 /* label */
848 text_cell = gtk_cell_renderer_text_new();
849 gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), text_cell, TRUE );
850 gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), text_cell, "text", 0, NULL );
851 gtk_cell_renderer_set_visible( GTK_CELL_RENDERER( text_cell ), TRUE );
853 /* insert the "rely on runtime detection item"
854 * this item must be inserted first (see desktop_setup())
856 gtk_list_store_append( model, &row );
857 gtk_list_store_set( model, &row,
858 DESKTOP_ID_COLUMN, st_no_desktop.id,
859 DESKTOP_LABEL_COLUMN, gettext( st_no_desktop.label ),
860 -1 );
862 /* insert list of known desktops
864 desktops = fma_desktop_environment_get_known_list();
865 for( i = 0 ; desktops[i].id ; ++i ){
866 gtk_list_store_append( model, &row );
867 gtk_list_store_set( model, &row,
868 DESKTOP_ID_COLUMN, desktops[i].id,
869 DESKTOP_LABEL_COLUMN, gettext( desktops[i].label ),
870 -1 );
874 static void
875 desktop_setup( FMAPreferencesEditor *editor )
877 GtkWidget *combo;
878 const FMADesktopEnv *desktops;
879 guint i;
880 gint found;
881 GtkWidget *widget;
882 const gchar *desktop_id;
883 const gchar *desktop_label;
885 found = -1;
886 editor->private->desktop = fma_settings_get_string( IPREFS_DESKTOP_ENVIRONMENT, NULL, &editor->private->desktop_mandatory );
888 if( editor->private->desktop && strlen( editor->private->desktop )){
889 desktops = fma_desktop_environment_get_known_list();
890 for( i = 0 ; desktops[i].id && found == -1 ; ++i ){
891 if( !strcmp( desktops[i].id, editor->private->desktop )){
892 found = 1+i;
897 /* if the user has not selected a "preferred" desktop,
898 * we suppose he relies on runtime detection
900 if( found == -1 ){
901 found = 0;
904 combo = base_window_get_widget( BASE_WINDOW( editor ), "DesktopComboBox" );
905 gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), found );
907 base_window_signal_connect(
908 BASE_WINDOW( editor ),
909 G_OBJECT( combo ), "changed",
910 G_CALLBACK( desktop_on_changed ));
912 /* set the currently detected desktop
914 widget = base_window_get_widget( BASE_WINDOW( editor ), "DesktopLabel" );
915 desktop_id = fma_desktop_environment_detect_running_desktop();
916 desktop_label = fma_desktop_environment_get_label( desktop_id );
917 gtk_label_set_text( GTK_LABEL( widget ), desktop_label );
920 static void
921 desktop_on_changed( GtkComboBox *combo, FMAPreferencesEditor *editor )
923 gboolean editable;
924 gint active;
925 const FMADesktopEnv *desktops;
927 editable = !editor->private->preferences_locked && !editor->private->desktop_mandatory;
929 if( editable ){
930 g_free( editor->private->desktop );
931 editor->private->desktop = NULL;
933 active = gtk_combo_box_get_active( combo );
934 if( active > 0 ){
935 desktops = fma_desktop_environment_get_known_list();
936 editor->private->desktop = g_strdup( desktops[active-1].id );
942 * relabel copied/paster menu ?
944 static void
945 relabel_menu_setup( FMAPreferencesEditor *editor )
947 gboolean editable;
949 editor->private->relabel_menu = fma_settings_get_boolean( IPREFS_RELABEL_DUPLICATE_MENU, NULL, &editor->private->relabel_menu_mandatory );
950 editable = !editor->private->preferences_locked && !editor->private->relabel_menu_mandatory;
952 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
953 "RelabelMenuButton", G_CALLBACK( relabel_menu_on_toggled ),
954 editor->private->relabel_menu, editable, !editor->private->preferences_locked );
957 static void
958 relabel_menu_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
960 gboolean editable;
962 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
964 if( editable ){
965 editor->private->relabel_menu = gtk_toggle_button_get_active( button );
967 } else {
968 base_gtk_utils_toggle_reset_initial_state( button );
973 * add an about item
975 static void
976 relabel_action_setup( FMAPreferencesEditor *editor )
978 gboolean editable;
980 editor->private->relabel_action = fma_settings_get_boolean( IPREFS_RELABEL_DUPLICATE_ACTION, NULL, &editor->private->relabel_action_mandatory );
981 editable = !editor->private->preferences_locked && !editor->private->relabel_action_mandatory;
983 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
984 "RelabelActionButton", G_CALLBACK( relabel_action_on_toggled ),
985 editor->private->relabel_action, editable, !editor->private->preferences_locked );
988 static void
989 relabel_action_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
991 gboolean editable;
993 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
995 if( editable ){
996 editor->private->relabel_action = gtk_toggle_button_get_active( button );
998 } else {
999 base_gtk_utils_toggle_reset_initial_state( button );
1004 * add an about item
1006 static void
1007 relabel_profile_setup( FMAPreferencesEditor *editor )
1009 gboolean editable;
1011 editor->private->relabel_profile = fma_settings_get_boolean( IPREFS_RELABEL_DUPLICATE_PROFILE, NULL, &editor->private->relabel_profile_mandatory );
1012 editable = !editor->private->preferences_locked && !editor->private->relabel_profile_mandatory;
1014 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
1015 "RelabelProfileButton", G_CALLBACK( relabel_profile_on_toggled ),
1016 editor->private->relabel_profile, editable, !editor->private->preferences_locked );
1019 static void
1020 relabel_profile_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
1022 gboolean editable;
1024 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
1026 if( editable ){
1027 editor->private->relabel_profile = gtk_toggle_button_get_active( button );
1029 } else {
1030 base_gtk_utils_toggle_reset_initial_state( button );
1035 * whether Esc key quits the assistants
1037 static void
1038 esc_quit_setup( FMAPreferencesEditor *editor )
1040 gboolean editable;
1042 editor->private->esc_quit = fma_settings_get_boolean( IPREFS_ASSISTANT_ESC_QUIT, NULL, &editor->private->esc_quit_mandatory );
1043 editable = !editor->private->preferences_locked && !editor->private->esc_quit_mandatory;
1045 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
1046 "EscCloseButton", G_CALLBACK( esc_quit_on_toggled ),
1047 editor->private->esc_quit, editable, !editor->private->preferences_locked );
1050 static void
1051 esc_quit_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
1053 gboolean editable;
1054 GtkWidget *confirm_button;
1056 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
1058 if( editable ){
1059 editor->private->esc_quit = gtk_toggle_button_get_active( button );
1060 confirm_button = base_window_get_widget( BASE_WINDOW( editor ), "EscConfirmButton" );
1061 gtk_widget_set_sensitive( confirm_button, editor->private->esc_quit );
1063 } else {
1064 base_gtk_utils_toggle_reset_initial_state( button );
1069 * whether we should ask for a user confirmation when quitting an assistant
1070 * on 'Esc' key
1072 static void
1073 esc_confirm_setup( FMAPreferencesEditor *editor )
1075 gboolean editable;
1077 editor->private->esc_confirm = fma_settings_get_boolean( IPREFS_ASSISTANT_ESC_CONFIRM, NULL, &editor->private->esc_confirm_mandatory );
1078 editable = !editor->private->preferences_locked && !editor->private->esc_confirm_mandatory;
1080 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
1081 "EscConfirmButton", G_CALLBACK( esc_confirm_on_toggled ),
1082 editor->private->esc_confirm, editable, !editor->private->preferences_locked );
1085 static void
1086 esc_confirm_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
1088 gboolean editable;
1090 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
1092 if( editable ){
1093 editor->private->esc_confirm = gtk_toggle_button_get_active( button );
1095 } else {
1096 base_gtk_utils_toggle_reset_initial_state( button );
1101 * add an about item
1103 static void
1104 auto_save_setup( FMAPreferencesEditor *editor )
1106 gboolean editable;
1107 GtkWidget *spin_button;
1108 GtkAdjustment *adjustment;
1110 g_debug( "fma_preferences_editor_auto_save_setup" );
1111 editor->private->auto_save = fma_settings_get_boolean( IPREFS_MAIN_SAVE_AUTO, NULL, &editor->private->auto_save_mandatory );
1112 editable = !editor->private->preferences_locked && !editor->private->auto_save_mandatory;
1114 editor->private->auto_save_period = fma_settings_get_uint( IPREFS_MAIN_SAVE_PERIOD, NULL, &editor->private->auto_save_period_mandatory );
1115 spin_button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
1116 adjustment = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin_button ));
1117 gtk_adjustment_configure( adjustment, editor->private->auto_save_period, 1, 999, 1, 10, 0 );
1119 editable = !editor->private->preferences_locked && !editor->private->auto_save_period_mandatory;
1120 gtk_editable_set_editable( GTK_EDITABLE( spin_button ), editable );
1121 base_window_signal_connect( BASE_WINDOW( editor ),
1122 G_OBJECT( spin_button ), "value-changed", G_CALLBACK( auto_save_period_on_change_value ));
1124 editable = !editor->private->preferences_locked && !editor->private->auto_save_mandatory;
1125 base_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
1126 "AutoSaveCheckButton", G_CALLBACK( auto_save_on_toggled ),
1127 editor->private->auto_save, editable, !editor->private->preferences_locked );
1130 static void
1131 auto_save_on_toggled( GtkToggleButton *button, FMAPreferencesEditor *editor )
1133 gboolean editable;
1134 GtkWidget *widget;
1135 gboolean sensitive;
1137 editable = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( button ), FMA_TOGGLE_DATA_EDITABLE ));
1139 if( editable ){
1140 editor->private->auto_save = gtk_toggle_button_get_active( button );
1142 } else {
1143 base_gtk_utils_toggle_reset_initial_state( button );
1146 sensitive = editor->private->auto_save && !editor->private->preferences_locked;
1148 widget = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
1149 gtk_widget_set_sensitive( widget, sensitive );
1151 widget = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveLabel1" );
1152 gtk_widget_set_sensitive( widget, sensitive );
1154 widget = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveLabel2" );
1155 gtk_widget_set_sensitive( widget, sensitive );
1158 static void
1159 auto_save_period_on_change_value( GtkSpinButton *spinbutton, FMAPreferencesEditor *editor )
1161 g_debug( "fma_preferences_editor_auto_save_period_on_change_value" );
1162 editor->private->auto_save_period = gtk_spin_button_get_value_as_int( spinbutton );
1165 static void
1166 on_cancel_clicked( GtkButton *button, FMAPreferencesEditor *editor )
1168 GtkWindow *toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( editor ));
1169 gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_CLOSE );
1172 static void
1173 on_ok_clicked( GtkButton *button, FMAPreferencesEditor *editor )
1175 GtkWindow *toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( editor ));
1176 gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_OK );
1179 static void
1180 on_dialog_ok( BaseDialog *dialog )
1182 FMAPreferencesEditor *editor;
1183 GtkWidget *container;
1184 FMAIOption *option;
1185 gchar *import_mode;
1186 gchar *export_format;
1188 g_return_if_fail( FMA_IS_PREFERENCES_EDITOR( dialog ));
1190 editor = FMA_PREFERENCES_EDITOR( dialog );
1192 if( !editor->private->preferences_locked ){
1194 /* first tab: runtime preferences
1196 if( !editor->private->order_mode_mandatory ){
1197 fma_iprefs_set_order_mode( editor->private->order_mode );
1199 if( !editor->private->root_menu_mandatory ){
1200 fma_settings_set_boolean( IPREFS_ITEMS_CREATE_ROOT_MENU, editor->private->root_menu );
1202 if( !editor->private->about_item_mandatory ){
1203 fma_settings_set_boolean( IPREFS_ITEMS_ADD_ABOUT_ITEM, editor->private->about_item );
1206 /* second tab: runtime execution
1208 if( !editor->private->terminal_pattern_mandatory ){
1209 fma_settings_set_string( IPREFS_TERMINAL_PATTERN, editor->private->terminal_pattern );
1211 if( !editor->private->desktop_mandatory ){
1212 fma_settings_set_string( IPREFS_DESKTOP_ENVIRONMENT, editor->private->desktop );
1215 /* third tab: ui preferences
1217 if( !editor->private->relabel_menu_mandatory ){
1218 fma_settings_set_boolean( IPREFS_RELABEL_DUPLICATE_MENU, editor->private->relabel_menu );
1220 if( !editor->private->relabel_action_mandatory ){
1221 fma_settings_set_boolean( IPREFS_RELABEL_DUPLICATE_ACTION, editor->private->relabel_action );
1223 if( !editor->private->relabel_profile_mandatory ){
1224 fma_settings_set_boolean( IPREFS_RELABEL_DUPLICATE_PROFILE, editor->private->relabel_profile );
1226 if( !editor->private->esc_quit_mandatory ){
1227 fma_settings_set_boolean( IPREFS_ASSISTANT_ESC_QUIT, editor->private->esc_quit );
1229 if( !editor->private->esc_confirm_mandatory ){
1230 fma_settings_set_boolean( IPREFS_ASSISTANT_ESC_CONFIRM, editor->private->esc_confirm );
1232 if( !editor->private->auto_save_mandatory ){
1233 fma_settings_set_boolean( IPREFS_MAIN_SAVE_AUTO, editor->private->auto_save );
1235 if( !editor->private->auto_save_period_mandatory ){
1236 fma_settings_set_uint( IPREFS_MAIN_SAVE_PERIOD, editor->private->auto_save_period );
1239 /* fourth tab: import mode
1241 if( !editor->private->import_mode_mandatory ){
1242 container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesImportModeParent" );
1243 option = fma_ioptions_list_get_selected( FMA_IOPTIONS_LIST( editor ), container );
1244 g_return_if_fail( FMA_IS_IMPORT_MODE( option ));
1245 import_mode = fma_ioption_get_id( option );
1246 fma_settings_set_string( IPREFS_IMPORT_PREFERRED_MODE, import_mode );
1247 g_free( import_mode );
1250 /* fifth tab: export format
1252 if( !editor->private->export_format_mandatory ){
1253 container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatParent" );
1254 option = fma_ioptions_list_get_selected( FMA_IOPTIONS_LIST( editor ), container );
1255 g_debug( "fma_preferences_editor_on_dialog_ok: option=%p", ( void * ) option );
1256 g_return_if_fail( FMA_IS_EXPORT_FORMAT( option ));
1257 export_format = fma_ioption_get_id( option );
1258 fma_settings_set_string( IPREFS_EXPORT_PREFERRED_FORMAT, export_format );
1259 g_free( export_format );
1262 /* sixth tab: list of default schemes
1264 fma_schemes_list_save_defaults( BASE_WINDOW( editor ));
1266 /* seventh tab: priorities of I/O providers
1268 fma_providers_list_save( BASE_WINDOW( editor ));