[nautilus-actions] Setup new auto-save preferences
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Setup new auto-save preferences
- Date: Sat, 7 Aug 2010 18:52:43 +0000 (UTC)
commit 31e921fc390f253cbdc52150605d46927ade50ee
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Aug 7 15:31:57 2010 +0200
Setup new auto-save preferences
ChangeLog | 19 ++++++
data/nautilus-actions-prefs.schemas.in | 22 +++++++
src/nact/nact-iprefs.c | 53 ++++++++++++++++
src/nact/nact-iprefs.h | 7 +-
src/nact/nact-preferences-editor.c | 70 +++++++++++++++++++++-
src/nact/nact-preferences.ui | 97 +++++++++++++++++++++++++++++-
src/nact/nautilus-actions-config-tool.ui | 39 ++++++++----
7 files changed, 287 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a3019cd..231082e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-08-07 Pierre Wieser <pwieser trychlos org>
+
+ Setup auto-save in preferences.
+
+ * data/nautilus-actions-prefs.schemas.in:
+ Describe new auto-save-on and auto-save-period preference keys.
+
+ * src/nact/nact-iprefs.c:
+ * src/nact/nact-iprefs.h
+ (nact_iprefs_read_uint, nact_iprefs_write_uint): New functions.
+ IPREFS_AUTOSAVE_ON, IPREFS_AUTOSAVE_PERIOD: New preference keys.
+
+ * src/nact/nact-preferences-editor.c:
+ Update the new auto-save-on and auto-save-period preference keys.
+
+
+ * src/nact/nact-preferences.ui:
+ * src/nact/nautilus-actions-config-tool.ui: New preference frame.
+
2010-08-05 Pierre Wieser <pwieser trychlos org>
* src/api/na-core-utils.h:
diff --git a/data/nautilus-actions-prefs.schemas.in b/data/nautilus-actions-prefs.schemas.in
index e40388f..b12de6e 100644
--- a/data/nautilus-actions-prefs.schemas.in
+++ b/data/nautilus-actions-prefs.schemas.in
@@ -27,6 +27,28 @@
</schema>
<schema>
+ <key>/schemas/apps/nautilus-actions/preferences/auto-save-on</key>
+ <owner>nautilus-actions</owner>
+ <type>bool</type>
+ <locale name="C">
+ <short>Whether the auto-save feature should be activated</short>
+ <long>If TRUE, the pending modifications will be periodically and automatically saved.</long>
+ </locale>
+ <default>false</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/auto-save-period</key>
+ <owner>nautilus-actions</owner>
+ <type>int</type>
+ <locale name="C">
+ <short>Periodicity of the auto-save</short>
+ <long>Defines the periodicity in minutes of the automatic save.</long>
+ </locale>
+ <default>5</default>
+ </schema>
+
+ <schema>
<key>/schemas/apps/nautilus-actions/preferences/export-assistant</key>
<owner>nautilus-actions</owner>
<type>list</type>
diff --git a/src/nact/nact-iprefs.c b/src/nact/nact-iprefs.c
index 92a69e8..a8ef8ce 100644
--- a/src/nact/nact-iprefs.c
+++ b/src/nact/nact-iprefs.c
@@ -232,6 +232,35 @@ nact_iprefs_migrate_key( const BaseWindow *window, const gchar *old_key, const g
}
/**
+ * nact_iprefs_read_uint:
+ * @window: this #BaseWindow-derived window.
+ * @name: the preference entry.
+ * @default_value: the value to be returned if the key is not found.
+ *
+ * Returns: the uint value associated with the given key.
+ */
+guint
+nact_iprefs_read_uint( const BaseWindow *window, const gchar *name, guint default_value )
+{
+ guint value;
+ gchar *path;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), 0 );
+ g_return_val_if_fail( NACT_IS_IPREFS( window ), 0 );
+
+ value = 0;
+
+ if( st_initialized && !st_finalized ){
+
+ path = gconf_concat_dir_and_key( IPREFS_GCONF_PREFS_PATH, name );
+ value = na_gconf_utils_read_int( NACT_IPREFS_GET_INTERFACE( window )->private->client, path, TRUE, default_value );
+ g_free( path );
+ }
+
+ return( value );
+}
+
+/**
* nact_iprefs_write_bool:
* @window: this #BaseWindow-derived window.
* @name: the preference entry.
@@ -256,6 +285,30 @@ nact_iprefs_write_bool( const BaseWindow *window, const gchar *name, gboolean va
}
/**
+ * nact_iprefs_write_uint:
+ * @window: this #BaseWindow-derived window.
+ * @name: the preference entry.
+ * @value: the value to be written.
+ *
+ * Writes the given uint value.
+ */
+void
+nact_iprefs_write_uint( const BaseWindow *window, const gchar *name, guint value )
+{
+ gchar *path;
+
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+
+ path = gconf_concat_dir_and_key( IPREFS_GCONF_PREFS_PATH, name );
+ na_gconf_utils_write_int( NACT_IPREFS_GET_INTERFACE( window )->private->client, path, value, NULL );
+ g_free( path );
+ }
+}
+
+/**
* nact_iprefs_write_string:
* @window: this #BaseWindow-derived window.
* @name: the preference key.
diff --git a/src/nact/nact-iprefs.h b/src/nact/nact-iprefs.h
index 7e332d0..fe2b186 100644
--- a/src/nact/nact-iprefs.h
+++ b/src/nact/nact-iprefs.h
@@ -61,13 +61,12 @@ typedef struct {
#define IPREFS_EXPORT_ITEMS_FOLDER_URI "export-folder-uri"
#define IPREFS_EXPORT_FORMAT "export-format"
#define IPREFS_EXPORT_ASK_LAST_FORMAT "export-ask-user-last-format"
-
#define IPREFS_EXPORT_FORMAT_DEFAULT "GConfEntry"
-
#define IPREFS_IMPORT_ITEMS_FOLDER_URI "import-folder-uri"
-
#define IPREFS_ASSIST_ESC_QUIT "assistant-esc-quit"
#define IPREFS_ASSIST_ESC_CONFIRM "assistant-esc-confirm"
+#define IPREFS_AUTOSAVE_ON "auto-save-on"
+#define IPREFS_AUTOSAVE_PERIOD "auto-save-period"
/* these are special export formats
*/
@@ -83,7 +82,9 @@ void nact_iprefs_set_export_format( const BaseWindow *window, const gchar *pre
void nact_iprefs_migrate_key ( const BaseWindow *window, const gchar *old_key, const gchar *new_key );
+guint nact_iprefs_read_uint ( const BaseWindow *window, const gchar *key, guint defaut_value );
void nact_iprefs_write_bool ( const BaseWindow *window, const gchar *key, gboolean value );
+void nact_iprefs_write_uint ( const BaseWindow *window, const gchar *key, guint value );
void nact_iprefs_write_string ( const BaseWindow *window, const gchar *name, const gchar *value );
G_END_DECLS
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 77c535e..8046b00 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -73,6 +73,9 @@ static void on_base_initial_load_dialog( NactPreferencesEditor *editor, gpoi
static void on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data );
static void on_base_all_widgets_showed( NactPreferencesEditor *editor, gpointer user_data );
static void on_esc_quit_toggled( GtkToggleButton *button, NactPreferencesEditor *editor );
+static void esc_quit_activated( NactPreferencesEditor *editor, gboolean esc_quit_active );
+static void on_auto_save_toggled( GtkToggleButton *button, NactPreferencesEditor *editor );
+static void auto_save_activated( NactPreferencesEditor *editor, gboolean auto_save_active );
static void on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void on_ok_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void enable_order_mode_buttons( NactPreferencesEditor *editor );
@@ -311,6 +314,9 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
GtkWidget *button;
gboolean esc_quit, esc_confirm;
GtkTreeView *listview;
+ gboolean auto_save_on;
+ guint auto_save_period;
+ GtkAdjustment *adjustment;
g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
@@ -369,11 +375,28 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
esc_quit = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_QUIT, TRUE );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), esc_quit );
+ esc_quit_activated( editor, esc_quit );
esc_confirm = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_CONFIRM, TRUE );
button = base_window_get_widget( BASE_WINDOW( editor ), "EscConfirmButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), esc_confirm );
+ auto_save_on = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_AUTOSAVE_ON, FALSE );
+ button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveCheckButton" );
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), auto_save_on );
+ auto_save_activated( editor, auto_save_on );
+
+ base_window_signal_connect(
+ BASE_WINDOW( editor ),
+ G_OBJECT( button ),
+ "toggled",
+ G_CALLBACK( on_auto_save_toggled ));
+
+ auto_save_period = nact_iprefs_read_uint( BASE_WINDOW( editor ), IPREFS_AUTOSAVE_PERIOD, 5 );
+ button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
+ adjustment = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( button ));
+ gtk_adjustment_configure( adjustment, auto_save_period, 1, 999, 1, 10, 0 );
+
/* third tab: import tool
*/
import_mode = na_iprefs_get_import_mode( editor->private->gconf, IPREFS_IMPORT_ITEMS_IMPORT_MODE );
@@ -445,11 +468,42 @@ static void
on_esc_quit_toggled( GtkToggleButton *button, NactPreferencesEditor *editor )
{
gboolean is_active;
- GtkWidget *toggle;
is_active = gtk_toggle_button_get_active( button );
+ esc_quit_activated( editor, is_active );
+}
+
+static void
+esc_quit_activated( NactPreferencesEditor *editor, gboolean esc_quit_active )
+{
+ GtkWidget *toggle;
+
toggle = base_window_get_widget( BASE_WINDOW( editor ), "EscConfirmButton" );
- gtk_widget_set_sensitive( toggle, is_active );
+ gtk_widget_set_sensitive( toggle, esc_quit_active );
+}
+
+static void
+on_auto_save_toggled( GtkToggleButton *button, NactPreferencesEditor *editor )
+{
+ gboolean is_active;
+
+ is_active = gtk_toggle_button_get_active( button );
+ auto_save_activated( editor, is_active );
+}
+
+static void
+auto_save_activated( NactPreferencesEditor *editor, gboolean auto_save_activated )
+{
+ GtkWidget *widget;
+
+ widget = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
+ gtk_widget_set_sensitive( widget, auto_save_activated );
+
+ widget = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveLabel1" );
+ gtk_widget_set_sensitive( widget, auto_save_activated );
+
+ widget = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveLabel2" );
+ gtk_widget_set_sensitive( widget, auto_save_activated );
}
static void
@@ -503,6 +557,9 @@ save_preferences( NactPreferencesEditor *editor )
GtkWidget *container;
NAExportFormat *export_format;
gboolean esc_quit, esc_confirm;
+ gboolean auto_save_on;
+ guint auto_save_period;
+ GtkAdjustment *adjustment;
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
updater = nact_application_get_updater( application );
@@ -556,6 +613,15 @@ save_preferences( NactPreferencesEditor *editor )
esc_confirm = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_ASSIST_ESC_CONFIRM, esc_confirm );
+ button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveCheckButton" );
+ auto_save_on = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
+ nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_AUTOSAVE_ON, auto_save_on );
+
+ button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
+ adjustment = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( button ));
+ auto_save_period = ( guint ) gtk_adjustment_get_value( adjustment );
+ nact_iprefs_write_uint( BASE_WINDOW( editor ), IPREFS_AUTOSAVE_PERIOD, auto_save_period );
+
/* third tab: import tool
*/
import_mode = IMPORTER_MODE_NO_IMPORT;
diff --git a/src/nact/nact-preferences.ui b/src/nact/nact-preferences.ui
index c0a637e..0837a0d 100644
--- a/src/nact/nact-preferences.ui
+++ b/src/nact/nact-preferences.ui
@@ -293,7 +293,7 @@ Note that this item will be displayed only if a unique menu is defined in the Na
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="EscCloseButton">
- <property name="label" translatable="yes">Esc key quits the assistant</property>
+ <property name="label" translatable="yes">Esc key _quits the assistant</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -307,7 +307,7 @@ Note that this item will be displayed only if a unique menu is defined in the Na
</child>
<child>
<object class="GtkCheckButton" id="EscConfirmButton">
- <property name="label" translatable="yes">Ask for a confirmation when quitting the assistant on Esc key</property>
+ <property name="label" translatable="yes">Ask for a _confirmation when quitting the assistant on Esc key</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -340,6 +340,99 @@ Note that this item will be displayed only if a unique menu is defined in the Na
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame" id="frame8">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkAlignment" id="alignment8">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="AutoSaveCheckButton">
+ <property name="label" translatable="yes">Automatically _saves pending modifications</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">When this option is checked, pending modification will be periodically and automatically saved.</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="AutoSaveLabel1">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="xpad">4</property>
+ <property name="label" translatable="yes">Periodicity :</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="AutoSavePeriodicitySpinButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">5</property>
+ <property name="snap_to_ticks">True</property>
+ <property name="numeric">True</property>
+ <property name="update_policy">if-valid</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="AutoSaveLabel2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">4</property>
+ <property name="label" translatable="yes">minutes</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes"><b>Auto-save</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index 89896bd..932be14 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -1926,6 +1926,7 @@ Filters may be negated to specify for which capabilities your item must not appe
<property name="tooltip_text" translatable="yes">Select the operator which will be used when comparing your count with those of the current selection.</property>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
@@ -1935,12 +1936,21 @@ Filters may be negated to specify for which capabilities your item must not appe
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Your count limit as a positive integer.</property>
<property name="invisible_char">●</property>
+ <property name="width_chars">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label87">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -2752,6 +2762,9 @@ If the command is not found, or does not display the correct result, your item w
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">This assistant will guide you through the process of importing items, actions or menus.</property>
@@ -2768,8 +2781,8 @@ If the command is not found, or does not display the correct result, your item w
<object class="GtkFileChooserWidget" id="ImportFileChooser">
<property name="visible">True</property>
<property name="select_multiple">True</property>
- <property name="local_only">False</property>
<property name="use_preview_label">False</property>
+ <property name="local_only">False</property>
<property name="preview_widget_active">False</property>
</object>
<packing>
@@ -3790,39 +3803,39 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
</object>
<object class="GtkSizeGroup" id="CommandLabelSizeGroup">
<widgets>
- <widget name="ProfileLabelLabel"/>
- <widget name="CommandPathLabel"/>
- <widget name="CommandParametersLabel"/>
<widget name="label4"/>
+ <widget name="CommandParametersLabel"/>
+ <widget name="CommandPathLabel"/>
+ <widget name="ProfileLabelLabel"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="CommandButtonSizeGroup">
<widgets>
- <widget name="CommandPathButton"/>
<widget name="CommandLegendButton"/>
+ <widget name="CommandPathButton"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="ActionLabelSizeGroup">
<widgets>
- <widget name="ActionIconLabel"/>
- <widget name="ActionTooltipLabel"/>
- <widget name="ActionToolbarLabelLabel"/>
<widget name="ActionMenuLabelLabel"/>
+ <widget name="ActionToolbarLabelLabel"/>
+ <widget name="ActionTooltipLabel"/>
+ <widget name="ActionIconLabel"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="ExecutionModeSizeGroup">
<widgets>
- <widget name="label45"/>
- <widget name="label44"/>
<widget name="label43"/>
+ <widget name="label44"/>
+ <widget name="label45"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="PropertiesLabelSizeGroup">
<widgets>
- <widget name="label19"/>
- <widget name="label49"/>
- <widget name="label39"/>
<widget name="label18"/>
+ <widget name="label39"/>
+ <widget name="label49"/>
+ <widget name="label19"/>
</widgets>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]