[gthumb] selections: make volatile again
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] selections: make volatile again
- Date: Thu, 26 Oct 2017 16:52:54 +0000 (UTC)
commit 2d6189545faa9a613bdc74f5e0234ae09f88c2bd
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Oct 26 16:50:53 2017 +0200
selections: make volatile again
permanent selections break natural workflows.
extensions/selections/callbacks.c | 14 ---
extensions/selections/callbacks.h | 2 -
extensions/selections/gth-selections-manager.c | 113 ------------------------
extensions/selections/gth-selections-manager.h | 2 -
extensions/selections/main.c | 2 -
5 files changed, 0 insertions(+), 133 deletions(-)
---
diff --git a/extensions/selections/callbacks.c b/extensions/selections/callbacks.c
index 95d63fd..2ab27aa 100644
--- a/extensions/selections/callbacks.c
+++ b/extensions/selections/callbacks.c
@@ -161,13 +161,6 @@ folder_changed_cb (GthMonitor *monitor,
void
-selections__initialize_cb (void)
-{
- gth_selections_manager_load_from_file ();
-}
-
-
-void
selections__gth_browser_construct_cb (GthBrowser *browser)
{
BrowserData *data;
@@ -200,13 +193,6 @@ selections__gth_browser_construct_cb (GthBrowser *browser)
void
-selections__gth_browser_close_last_window_cb (GthBrowser *browser)
-{
- gth_selections_manager_save_to_file ();
-}
-
-
-void
selections__gth_browser_update_sensitivity_cb (GthBrowser *browser)
{
BrowserData *data;
diff --git a/extensions/selections/callbacks.h b/extensions/selections/callbacks.h
index 0fa9aff..0c88dcb 100644
--- a/extensions/selections/callbacks.h
+++ b/extensions/selections/callbacks.h
@@ -24,9 +24,7 @@
#include <gthumb.h>
-void selections__initialize_cb (void);
void selections__gth_browser_construct_cb (GthBrowser *browser);
-void selections__gth_browser_close_last_window_cb (GthBrowser *browser);
void selections__gth_browser_update_sensitivity_cb (GthBrowser *browser);
gpointer selections__gth_browser_file_list_key_press_cb (GthBrowser *browser,
GdkEventKey *event);
diff --git a/extensions/selections/gth-selections-manager.c b/extensions/selections/gth-selections-manager.c
index a386d01..94a8e2f 100644
--- a/extensions/selections/gth-selections-manager.c
+++ b/extensions/selections/gth-selections-manager.c
@@ -33,8 +33,6 @@ struct _GthSelectionsManagerPrivate {
char *order[GTH_SELECTIONS_MANAGER_N_SELECTIONS];
gboolean order_inverse[GTH_SELECTIONS_MANAGER_N_SELECTIONS];
GMutex mutex;
- gboolean loaded;
- gboolean changed;
};
@@ -108,8 +106,6 @@ gth_selections_manager_init (GthSelectionsManager *self)
self->priv->order[i] = NULL;
self->priv->order_inverse[i] = FALSE;
}
- self->priv->loaded = FALSE;
- self->priv->changed = FALSE;
}
@@ -330,55 +326,6 @@ _gth_selections_manager_load_from_node (GthSelectionsManager *self,
}
-static void
-_gth_selections_manager_load_if_required (GthSelectionsManager *self)
-{
- GFile *file;
- char *buffer;
- gsize size;
- DomDocument *doc;
-
- if (self->priv->loaded)
- return;
-
- file = gth_user_dir_get_file_for_read (GTH_DIR_DATA, GTHUMB_DIR, "selections.xml", NULL);
- if (! _g_file_load_in_buffer (file, (void **) &buffer, &size, NULL, NULL)) {
- g_object_unref (file);
- return;
- }
-
- g_mutex_lock (&self->priv->mutex);
-
- doc = dom_document_new ();
- if (dom_document_load (doc, buffer, size, NULL)) {
- DomElement *root = DOM_ELEMENT (doc)->first_child;
-
- if (g_strcmp0 (root->tag_name, "selections") == 0) {
- DomElement *child;
- for (child = root->first_child; child; child = child->next_sibling) {
- if (g_strcmp0 (child->tag_name, "selection") == 0)
- _gth_selections_manager_load_from_node (self, child);
- }
- }
- }
-
- self->priv->loaded = TRUE;
-
- g_mutex_unlock (&self->priv->mutex);
-
- g_object_unref (doc);
- g_free (buffer);
- g_object_unref (file);
-}
-
-
-static void
-_gth_selections_manager_changed (GthSelectionsManager *self)
-{
- self->priv->changed = TRUE;
-}
-
-
void
gth_selections_manager_for_each_child (GFile *folder,
const char *attributes,
@@ -394,8 +341,6 @@ gth_selections_manager_for_each_child (GFile *folder,
self = gth_selections_manager_get_default ();
n_selection = _g_file_get_n_selection (folder);
- _gth_selections_manager_load_if_required (self);
-
g_mutex_lock (&self->priv->mutex);
data = g_new0 (ForEachChildData, 1);
data->selections_manager = self;
@@ -444,8 +389,6 @@ gth_selections_manager_add_files (GFile *folder,
if (n_selection <= 0)
return FALSE;
- _gth_selections_manager_load_if_required (self);
-
g_mutex_lock (&self->priv->mutex);
new_list = _g_file_list_dup (file_list);
@@ -472,7 +415,6 @@ gth_selections_manager_add_files (GFile *folder,
g_mutex_unlock (&self->priv->mutex);
- _gth_selections_manager_changed (self);
gth_monitor_emblems_changed (gth_main_get_default_monitor (), file_list);
gth_monitor_folder_changed (gth_main_get_default_monitor (),
folder,
@@ -499,8 +441,6 @@ gth_selections_manager_remove_files (GFile *folder,
if (n_selection <= 0)
return;
- _gth_selections_manager_load_if_required (self);
-
g_mutex_lock (&self->priv->mutex);
files_to_remove = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
@@ -527,7 +467,6 @@ gth_selections_manager_remove_files (GFile *folder,
g_mutex_unlock (&self->priv->mutex);
- _gth_selections_manager_changed (self);
if (notify)
gth_monitor_folder_changed (gth_main_get_default_monitor (),
folder,
@@ -554,8 +493,6 @@ gth_selections_manager_reorder (GFile *folder,
self = gth_selections_manager_get_default ();
- _gth_selections_manager_load_if_required (self);
-
/* reorder the file list */
g_mutex_lock (&self->priv->mutex);
@@ -571,7 +508,6 @@ gth_selections_manager_reorder (GFile *folder,
gth_selections_manager_set_sort_type (folder, "general::unsorted", FALSE);
- _gth_selections_manager_changed (self);
gth_monitor_order_changed (gth_main_get_default_monitor (),
folder,
new_order);
@@ -600,8 +536,6 @@ gth_selections_manager_set_sort_type (GFile *folder,
self->priv->order_inverse[n_selection - 1] = sort_inverse;
g_mutex_unlock (&self->priv->mutex);
-
- _gth_selections_manager_changed (self);
}
@@ -616,7 +550,6 @@ gth_selections_manager_file_exists (int n_selection,
return FALSE;
self = gth_selections_manager_get_default ();
- _gth_selections_manager_load_if_required (self);
g_mutex_lock (&self->priv->mutex);
result = (g_hash_table_lookup (self->priv->files_hash[n_selection - 1], file) != NULL);
@@ -637,7 +570,6 @@ gth_selections_manager_get_is_empty (int n_selection)
return TRUE;
self = gth_selections_manager_get_default ();
- _gth_selections_manager_load_if_required (self);
g_mutex_lock (&self->priv->mutex);
size = g_hash_table_size (self->priv->files_hash[n_selection - 1]);
@@ -675,51 +607,6 @@ _gth_selections_manager_create_selection_node (GthSelectionsManager *self,
}
-void
-gth_selections_manager_load_from_file (void)
-{
- GthSelectionsManager *self;
-
- self = gth_selections_manager_get_default ();
- _gth_selections_manager_load_if_required (self);
-}
-
-
-void
-gth_selections_manager_save_to_file (void)
-{
- GthSelectionsManager *self;
- DomDocument *doc;
- DomElement *root, *selections;
- GFile *file;
- char *buffer;
- gsize size;
-
- self = gth_selections_manager_get_default ();
- if (! self->priv->changed)
- return;
-
- g_mutex_lock (&self->priv->mutex);
-
- doc = dom_document_new ();
- root = DOM_ELEMENT (doc);
- selections = dom_document_create_element (doc, "selections", NULL);
- dom_element_append_child (root, selections);
- for (int i = 1; i <= GTH_SELECTIONS_MANAGER_N_SELECTIONS; i++)
- dom_element_append_child (selections, _gth_selections_manager_create_selection_node (self, i,
doc));
-
- buffer = dom_document_dump (doc, &size);
- file = gth_user_dir_get_file_for_write (GTH_DIR_DATA, GTHUMB_DIR, "selections.xml", NULL);
- _g_file_write (file, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, buffer, size, NULL, NULL);
- self->priv->changed = FALSE;
-
- g_mutex_unlock (&self->priv->mutex);
-
- g_object_unref (file);
- g_free (buffer);
-}
-
-
int
_g_file_get_n_selection (GFile *file)
{
diff --git a/extensions/selections/gth-selections-manager.h b/extensions/selections/gth-selections-manager.h
index 262882a..b97940d 100644
--- a/extensions/selections/gth-selections-manager.h
+++ b/extensions/selections/gth-selections-manager.h
@@ -76,8 +76,6 @@ void gth_selections_manager_update_file_info (GFile *file,
gboolean gth_selections_manager_file_exists (int n_selection,
GFile *file);
gboolean gth_selections_manager_get_is_empty (int n_selection);
-void gth_selections_manager_load_from_file (void);
-void gth_selections_manager_save_to_file (void);
/* utilities */
diff --git a/extensions/selections/main.c b/extensions/selections/main.c
index 57afce5..d007205 100644
--- a/extensions/selections/main.c
+++ b/extensions/selections/main.c
@@ -33,9 +33,7 @@ gthumb_extension_activate (void)
{
gth_main_register_file_source (GTH_TYPE_FILE_SOURCE_SELECTIONS);
gth_main_register_metadata_provider (GTH_TYPE_METADATA_PROVIDER_SELECTIONS);
- gth_hook_add_callback ("initialize", 10, G_CALLBACK (selections__initialize_cb), NULL);
gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK
(selections__gth_browser_construct_cb), NULL);
- gth_hook_add_callback ("gth-browser-close-last-window", 10, G_CALLBACK
(selections__gth_browser_close_last_window_cb), NULL);
gth_hook_add_callback ("gth-browser-update-sensitivity", 10, G_CALLBACK
(selections__gth_browser_update_sensitivity_cb), NULL);
gth_hook_add_callback ("gth-browser-file-list-key-press", 10, G_CALLBACK
(selections__gth_browser_file_list_key_press_cb), NULL);
gth_hook_add_callback ("gth-browser-load-location-after", 10, G_CALLBACK
(selections__gth_browser_load_location_after_cb), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]