nautilus r15169 - in trunk: . libnautilus-private src
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r15169 - in trunk: . libnautilus-private src
- Date: Wed, 8 Apr 2009 08:40:41 +0000 (UTC)
Author: alexl
Date: Wed Apr 8 08:40:41 2009
New Revision: 15169
URL: http://svn.gnome.org/viewvc/nautilus?rev=15169&view=rev
Log:
2009-04-08 Alexander Larsson <alexl redhat com>
* libnautilus-private/nautilus-file-utilities.[ch]:
* libnautilus-private/nautilus-file-utilities.h:
Add nautilus_get_accel_map_file
* src/nautilus-application.[ch]:
Load accel map on startup, queue save when it changes.
* src/nautilus-main.c:
Save accel map on clean exit if it is dirty.
Patch from Holger Berndt <berndth gmx de>
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-file-utilities.c
trunk/libnautilus-private/nautilus-file-utilities.h
trunk/src/nautilus-application.c
trunk/src/nautilus-application.h
trunk/src/nautilus-main.c
Modified: trunk/libnautilus-private/nautilus-file-utilities.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file-utilities.c (original)
+++ trunk/libnautilus-private/nautilus-file-utilities.c Wed Apr 8 08:40:41 2009
@@ -111,6 +111,27 @@
return user_directory;
}
+/**
+ * nautilus_get_accel_map_file:
+ *
+ * Get the path for the filename containing nautilus accelerator map.
+ * The filename need not exist.
+ *
+ * Return value: the filename path, or NULL if the home directory could not be found
+ **/
+char *
+nautilus_get_accel_map_file (void)
+{
+ const gchar *home;
+
+ home = g_get_home_dir();
+ if (home != NULL) {
+ return g_build_filename (home, ".gnome2/accels/nautilus", NULL);
+ }
+
+ return NULL;
+}
+
typedef struct {
char *type;
char *path;
Modified: trunk/libnautilus-private/nautilus-file-utilities.h
==============================================================================
--- trunk/libnautilus-private/nautilus-file-utilities.h (original)
+++ trunk/libnautilus-private/nautilus-file-utilities.h Wed Apr 8 08:40:41 2009
@@ -96,4 +96,6 @@
GFile *
nautilus_find_file_insensitive (GFile *parent, const gchar *name);
+char * nautilus_get_accel_map_file (void);
+
#endif /* NAUTILUS_FILE_UTILITIES_H */
Modified: trunk/src/nautilus-application.c
==============================================================================
--- trunk/src/nautilus-application.c (original)
+++ trunk/src/nautilus-application.c Wed Apr 8 08:40:41 2009
@@ -96,6 +96,8 @@
#define START_STATE_CONFIG "start-state"
+#define NAUTILUS_ACCEL_MAP_SAVE_DELAY 30
+
/* Keeps track of all the desktop windows. */
static GList *nautilus_application_desktop_windows;
@@ -105,6 +107,9 @@
/* Keeps track of all the object windows */
static GList *nautilus_application_spatial_window_list;
+/* The saving of the accelerator map was requested */
+static gboolean save_of_accel_map_requested = FALSE;
+
static void desktop_changed_callback (gpointer user_data);
static void desktop_location_changed_callback (gpointer user_data);
static void mount_removed_callback (GVolumeMonitor *monitor,
@@ -801,6 +806,35 @@
return res;
}
+gboolean
+nautilus_application_save_accel_map (gpointer data)
+{
+ if (save_of_accel_map_requested) {
+ char *accel_map_filename;
+ accel_map_filename = nautilus_get_accel_map_file ();
+ if (accel_map_filename) {
+ gtk_accel_map_save (accel_map_filename);
+ g_free (accel_map_filename);
+ }
+ save_of_accel_map_requested = FALSE;
+ }
+
+ return FALSE;
+}
+
+
+static void
+queue_accel_map_save_callback (GtkAccelMap *object, gchar *accel_path,
+ guint accel_key, GdkModifierType accel_mods,
+ gpointer user_data)
+{
+ if (!save_of_accel_map_requested) {
+ save_of_accel_map_requested = TRUE;
+ g_timeout_add_seconds (NAUTILUS_ACCEL_MAP_SAVE_DELAY,
+ nautilus_application_save_accel_map, NULL);
+ }
+}
+
void
nautilus_application_startup (NautilusApplication *application,
gboolean kill_shell,
@@ -826,6 +860,8 @@
}
} else {
+ char *accel_map_filename;
+
/* If KDE desktop is running, then force no_desktop */
if (is_kdesktop_present ()) {
no_desktop = TRUE;
@@ -887,6 +923,14 @@
/* Load session info if availible */
nautilus_application_load_session (application);
+
+ /* load accelerator map, and register save callback */
+ accel_map_filename = nautilus_get_accel_map_file ();
+ if (accel_map_filename) {
+ gtk_accel_map_load (accel_map_filename);
+ g_free (accel_map_filename);
+ }
+ g_signal_connect (gtk_accel_map_get (), "changed", G_CALLBACK (queue_accel_map_save_callback), NULL);
}
}
Modified: trunk/src/nautilus-application.h
==============================================================================
--- trunk/src/nautilus-application.h (original)
+++ trunk/src/nautilus-application.h Wed Apr 8 08:40:41 2009
@@ -103,4 +103,7 @@
void nautilus_application_close_all_spatial_windows (void);
void nautilus_application_open_desktop (NautilusApplication *application);
void nautilus_application_close_desktop (void);
+gboolean nautilus_application_save_accel_map (gpointer data);
+
+
#endif /* NAUTILUS_APPLICATION_H */
Modified: trunk/src/nautilus-main.c
==============================================================================
--- trunk/src/nautilus-main.c (original)
+++ trunk/src/nautilus-main.c Wed Apr 8 08:40:41 2009
@@ -526,6 +526,8 @@
}
eel_debug_shut_down ();
+
+ nautilus_application_save_accel_map (NULL);
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]