[nautilus] application: drop load/save of custom accel maps
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] application: drop load/save of custom accel maps
- Date: Sat, 6 Dec 2014 23:16:14 +0000 (UTC)
commit ce0ce798b9818b37343196dc66def9464eb951ab
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat Nov 29 23:33:08 2014 -0800
application: drop load/save of custom accel maps
We're moving towards a GAction-based model, and gtk-can-change-accels is
ignored in GtkSettings anyway. Just drop this.
libnautilus-private/Makefile.am | 1 -
libnautilus-private/nautilus-file-utilities.c | 14 ---
libnautilus-private/nautilus-file-utilities.h | 1 -
src/Makefile.am | 3 -
src/nautilus-application.c | 154 -------------------------
5 files changed, 0 insertions(+), 173 deletions(-)
---
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index df31a39..9111877 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -12,7 +12,6 @@ AM_CPPFLAGS = \
$(DISABLE_DEPRECATED) \
$(TRACKER_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
- -DSYSCONFDIR=\""$(sysconfdir)"\" \
-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \
-DNAUTILUS_EXTENSIONDIR=\""$(libdir)/nautilus/extensions-3.0"\" \
$(NULL)
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index 6c9378a..d669abd 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -314,20 +314,6 @@ nautilus_get_user_directory (void)
}
/**
- * 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
- **/
-char *
-nautilus_get_accel_map_file (void)
-{
- return g_build_filename (g_get_user_config_dir (), "nautilus", "accels", NULL);
-}
-
-/**
* nautilus_get_scripts_directory_path:
*
* Get the path for the directory containing nautilus scripts.
diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h
index 6d7122c..de73ff1 100644
--- a/libnautilus-private/nautilus-file-utilities.h
+++ b/libnautilus-private/nautilus-file-utilities.h
@@ -77,7 +77,6 @@ char * nautilus_ensure_unique_file_name (const char *directory_uri,
GFile * nautilus_find_existing_uri_in_hierarchy (GFile *location);
-char * nautilus_get_accel_map_file (void);
char * nautilus_get_scripts_directory_path (void);
GHashTable * nautilus_trashed_files_get_original_directories (GList *files,
diff --git a/src/Makefile.am b/src/Makefile.am
index 2aaea24..6f0d6a8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,10 +23,7 @@ AM_CPPFLAGS = \
-DLIBDIR=\""$(libdir)"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \
- -DUIDIR=\""$(datadir)/nautilus/ui"\" \
- -DNAUTILUS_PIXMAPDIR=\""$(datadir)/pixmaps/nautilus"\" \
-DPREFIX=\""$(prefix)"\" \
- -DSYSCONFDIR=\""$(sysconfdir)"\" \
-DVERSION="\"$(VERSION)\"" \
$(DISABLE_DEPRECATED) \
$(NULL)
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index a575c13..64425d2 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -68,11 +68,6 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#define NAUTILUS_ACCEL_MAP_SAVE_DELAY 30
-
-/* The saving of the accelerator map was requested */
-static gboolean save_of_accel_map_requested = FALSE;
-
G_DEFINE_TYPE (NautilusApplication, nautilus_application, GTK_TYPE_APPLICATION);
struct _NautilusApplicationPriv {
@@ -951,151 +946,6 @@ init_desktop (NautilusApplication *self)
update_desktop_from_gsettings (self);
}
-static 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);
- }
-}
-
-static void
-update_accel_due_to_scripts_migration (gpointer data, const gchar *accel_path, guint accel_key,
- GdkModifierType accel_mods, gboolean changed)
-{
- char *old_scripts_location_esc = data;
- char *old_scripts_pt;
-
- old_scripts_pt = strstr (accel_path, old_scripts_location_esc);
-
- if (old_scripts_pt != NULL) {
- /* There's a mention of the deprecated scripts directory in the accel. Remove it, and
- * add a migrated one. */
- char *tmp;
- char *tmp2;
- GString *new_accel_path;
-
- /* base part of accel */
- tmp = g_strndup (accel_path, old_scripts_pt - accel_path);
- new_accel_path = g_string_new (tmp);
- g_free (tmp);
-
- /* new script directory, escaped */
- tmp = nautilus_get_scripts_directory_path ();
- tmp2 = nautilus_escape_action_name (tmp, "");
- g_free (tmp);
- g_string_append (new_accel_path, tmp2);
- g_free (tmp2);
-
- /* script path relative to scripts directory */
- g_string_append (new_accel_path, old_scripts_pt + strlen (old_scripts_location_esc));
-
- /* exchange entry */
- gtk_accel_map_change_entry (accel_path, 0, 0, FALSE);
- gtk_accel_map_change_entry (new_accel_path->str, accel_key, accel_mods, TRUE);
-
- g_string_free (new_accel_path, TRUE);
- }
-}
-
-static void
-init_gtk_accels (void)
-{
- char *accel_map_filename;
- gboolean performed_migration = FALSE;
- char *old_scripts_directory_path = NULL;
-
- accel_map_filename = nautilus_get_accel_map_file ();
-
- /* If the accel map file doesn't exist, try to migrate from
- * former locations. */
- if (!g_file_test (accel_map_filename, G_FILE_TEST_IS_REGULAR)) {
- char *old_accel_map_filename;
- const gchar *override;
-
- override = g_getenv ("GNOME22_USER_DIR");
- if (override) {
- old_accel_map_filename = g_build_filename (override,
- "accels", "nautilus", NULL);
- old_scripts_directory_path = g_build_filename (override,
- "nautilus-scripts",
- NULL);
- } else {
- old_accel_map_filename = g_build_filename (g_get_home_dir (),
- ".gnome2", "accels", "nautilus", NULL);
- old_scripts_directory_path = g_build_filename (g_get_home_dir (),
- ".gnome2",
- "nautilus-scripts",
- NULL);
- }
-
- if (g_file_test (old_accel_map_filename, G_FILE_TEST_IS_REGULAR)) {
- char *parent_dir;
-
- parent_dir = g_path_get_dirname (accel_map_filename);
- if (g_mkdir_with_parents (parent_dir, 0700) == 0) {
- GFile *accel_map_file;
- GFile *old_accel_map_file;
-
- accel_map_file = g_file_new_for_path (accel_map_filename);
- old_accel_map_file = g_file_new_for_path (old_accel_map_filename);
-
- /* If the move fails, it's safer to not read any accel map
- * on startup instead of reading the old one and possibly
- * being stuck with it. */
- performed_migration = g_file_move (old_accel_map_file, accel_map_file, 0,
NULL, NULL, NULL, NULL);
-
- g_object_unref (accel_map_file);
- g_object_unref (old_accel_map_file);
- }
- g_free (parent_dir);
- }
-
- g_free (old_accel_map_filename);
- }
-
- /* load accelerator map, and register save callback */
- gtk_accel_map_load (accel_map_filename);
- g_free (accel_map_filename);
-
- if (performed_migration) {
- /* Migrate accels pointing to scripts */
- char *old_scripts_location_esc;
-
- old_scripts_location_esc = nautilus_escape_action_name (old_scripts_directory_path, "");
- gtk_accel_map_foreach (old_scripts_location_esc, update_accel_due_to_scripts_migration);
- g_free (old_scripts_location_esc);
- /* save map immediately */
- save_of_accel_map_requested = TRUE;
- nautilus_application_save_accel_map (NULL);
- }
-
- g_signal_connect (gtk_accel_map_get (), "changed",
- G_CALLBACK (queue_accel_map_save_callback), NULL);
-
- g_free (old_scripts_directory_path);
-}
-
static void
theme_changed (GtkSettings *settings)
{
@@ -1171,9 +1021,6 @@ nautilus_application_startup (GApplication *app)
/* register property pages */
nautilus_image_properties_page_register ();
- /* initialize theming */
- init_gtk_accels ();
-
/* initialize nautilus modules */
nautilus_profile_start ("Modules");
nautilus_module_setup ();
@@ -1241,7 +1088,6 @@ nautilus_application_quit_mainloop (GApplication *app)
DEBUG ("Quitting mainloop");
nautilus_icon_info_clear_caches ();
- nautilus_application_save_accel_map (NULL);
G_APPLICATION_CLASS (nautilus_application_parent_class)->quit_mainloop (app);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]