[nautilus-actions] Fix position, size and status for command chooser
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Subject: [nautilus-actions] Fix position, size and status for command chooser
- Date: Tue, 14 Jul 2009 18:48:35 +0000 (UTC)
commit 8d7f84f2b1c0ecb2d510823134986ed65c2814f3
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Jul 1 00:24:28 2009 +0200
Fix position, size and status for command chooser
ChangeLog | 10 +++++++
src/nact/nact-iprefs.c | 49 +++++++++++++++++++++++++++++++++++
src/nact/nact-iprefs.h | 11 +++++---
src/nact/nact-iprofile-conditions.c | 25 +++++++++++++++--
4 files changed, 88 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d73c411..f28daee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-07-01 Pierre Wieser <pwieser trychlos org>
+
+ * src/nact/nact-iprefs.c:
+ * src/nact/nact-iprefs.h
+ (nact_iprefs_get_iprofile_conditions_folder_uri,
+ nact_iprefs_save_iprofile_conditions_folder_uri): New functions.
+
+ * src/nact/nact-iprofile-conditions.c:
+ Save state and position of LegendDialog and GtkFileChooser.
+
2009-06-30 Pierre Wieser <pwieser trychlos org>
* src/common/na-action-profile.c:
diff --git a/src/nact/nact-iprefs.c b/src/nact/nact-iprefs.c
index f448a9b..56d1def 100644
--- a/src/nact/nact-iprefs.c
+++ b/src/nact/nact-iprefs.c
@@ -45,6 +45,10 @@ struct NactIPrefsInterfacePrivate {
*/
#define NA_GCONF_PREFS_PATH NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR "/preferences"
+/* key to read/write the last visited folder when browsing for command
+ */
+#define IPREFS_IPROFILE_CONDITION_FOLDER_URI "iprofile-conditions-folder-uri"
+
static GType register_type( void );
static void interface_base_init( NactIPrefsInterface *klass );
static void interface_base_finalize( NactIPrefsInterface *klass );
@@ -323,6 +327,51 @@ free_listint( GSList *list )
g_slist_free( list );
}
+/**
+ * Save the last visited folder when browsing for command in
+ * IProfileConditions interface.
+ *
+ * @window: this NactWindow-derived window.
+ *
+ * Returns the last visited folder if any, or NULL.
+ * The returned string must be g_free by the caller.
+ */
+gchar *
+nact_iprefs_get_iprofile_conditions_folder_uri( NactWindow *window )
+{
+ static const gchar *thisfn = "nact_iprefs_get_iprofile_conditions_folder_uri";
+ GError *error = NULL;
+ gchar *path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, IPREFS_IPROFILE_CONDITION_FOLDER_URI );
+
+ gchar *uri = gconf_client_get_string( NACT_IPREFS_GET_INTERFACE( window )->private->client, path, &error );
+
+ if( error ){
+ g_warning( "%s: %s", thisfn, error->message );
+ g_error_free( error );
+ uri = NULL;
+ }
+
+ g_free( path );
+ return( uri );
+}
+
+void
+nact_iprefs_save_iprofile_conditions_folder_uri( NactWindow *window, const gchar *uri )
+{
+ static const gchar *thisfn = "nact_iprefs_save_iprofile_conditions_folder_uri";
+ GError *error = NULL;
+ gchar *path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, IPREFS_IPROFILE_CONDITION_FOLDER_URI );
+
+ gconf_client_set_string( NACT_IPREFS_GET_INTERFACE( window )->private->client, path, uri, &error );
+
+ if( error ){
+ g_warning( "%s: %s", thisfn, error->message );
+ g_error_free( error );
+ }
+
+ g_free( path );
+}
+
/* ... */
#include <glib/gi18n.h>
diff --git a/src/nact/nact-iprefs.h b/src/nact/nact-iprefs.h
index b90f5d2..1294ae5 100644
--- a/src/nact/nact-iprefs.h
+++ b/src/nact/nact-iprefs.h
@@ -65,11 +65,14 @@ typedef struct {
GType nact_iprefs_get_type( void );
-void nact_iprefs_position_window( NactWindow *window );
-void nact_iprefs_position_named_window( NactWindow *window, GtkWindow *toplevel, const gchar *name );
+void nact_iprefs_position_window( NactWindow *window );
+void nact_iprefs_position_named_window( NactWindow *window, GtkWindow *toplevel, const gchar *name );
-void nact_iprefs_save_window_position( NactWindow *window );
-void nact_iprefs_save_named_window_position( NactWindow *window, GtkWindow *toplevel, const gchar *name );
+void nact_iprefs_save_window_position( NactWindow *window );
+void nact_iprefs_save_named_window_position( NactWindow *window, GtkWindow *toplevel, const gchar *name );
+
+gchar *nact_iprefs_get_iprofile_conditions_folder_uri( NactWindow *window );
+void nact_iprefs_save_iprofile_conditions_folder_uri( NactWindow *window, const gchar *uri );
/* .. */
#include <gconf/gconf-client.h>
diff --git a/src/nact/nact-iprofile-conditions.c b/src/nact/nact-iprofile-conditions.c
index 8e6e800..03b333c 100644
--- a/src/nact/nact-iprofile-conditions.c
+++ b/src/nact/nact-iprofile-conditions.c
@@ -56,6 +56,11 @@ enum {
SCHEMES_N_COLUMN
};
+/* the GConf key used to read/write size and position of auxiliary dialogs
+ */
+#define IPREFS_LEGEND_DIALOG "iprofile-conditions-legend-dialog"
+#define IPREFS_COMMAND_CHOOSER "iprofile-conditions-command-chooser"
+
static GType register_type( void );
static void interface_base_init( NactIProfileConditionsInterface *klass );
static void interface_base_finalize( NactIProfileConditionsInterface *klass );
@@ -316,12 +321,12 @@ on_path_changed( GtkEntry *entry, gpointer user_data )
v_field_modified( dialog );
}
-/* TODO: keep trace of last browsed dir */
static void
on_path_browse( GtkButton *button, gpointer user_data )
{
g_assert( NACT_IS_IPROFILE_CONDITIONS( user_data ));
gboolean set_current_location = FALSE;
+ gchar *uri = NULL;
GtkWidget *dialog = gtk_file_chooser_dialog_new(
_( "Choosing a command" ),
@@ -332,10 +337,18 @@ on_path_browse( GtkButton *button, gpointer user_data )
NULL
);
+ nact_iprefs_position_named_window( NACT_WINDOW( user_data ), GTK_WINDOW( dialog ), IPREFS_COMMAND_CHOOSER );
+
GtkWidget *path_widget = get_path_widget( NACT_WINDOW( user_data ));
const gchar *path = gtk_entry_get_text( GTK_ENTRY( path_widget ));
+
if( path && strlen( path )){
set_current_location = gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), path );
+
+ } else {
+ uri = nact_iprefs_get_iprofile_conditions_folder_uri( NACT_WINDOW( user_data ));
+ gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( dialog ), uri );
+ g_free( uri );
}
if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){
@@ -344,6 +357,12 @@ on_path_browse( GtkButton *button, gpointer user_data )
g_free (filename);
}
+ uri = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( dialog ));
+ nact_iprefs_save_iprofile_conditions_folder_uri( NACT_WINDOW( user_data ), uri );
+ g_free( uri );
+
+ nact_iprefs_save_named_window_position( NACT_WINDOW( user_data ), GTK_WINDOW( dialog ), IPREFS_COMMAND_CHOOSER );
+
gtk_widget_destroy( dialog );
}
@@ -573,7 +592,7 @@ show_legend_dialog( NactWindow *window )
GtkWindow *toplevel = base_window_get_toplevel_widget( BASE_WINDOW( window ));
gtk_window_set_transient_for( GTK_WINDOW( legend_dialog ), toplevel );
- nact_iprefs_position_named_window( window, legend_dialog, "legend-dialog" );
+ nact_iprefs_position_named_window( window, legend_dialog, IPREFS_LEGEND_DIALOG );
gtk_widget_show( GTK_WIDGET( legend_dialog ));
}
@@ -581,7 +600,7 @@ static void
hide_legend_dialog( NactWindow *window )
{
GtkWindow *legend_dialog = get_legend_dialog( window );
- nact_iprefs_save_named_window_position( window, legend_dialog, "legend-dialog" );
+ nact_iprefs_save_named_window_position( window, legend_dialog, IPREFS_LEGEND_DIALOG );
gtk_widget_hide( GTK_WIDGET( legend_dialog ));
/* set the legend button state consistent for when the dialog is
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]