summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Schwinn <alexxcons@xfce.org>2021-03-08 09:04:56 +0100
committerAlexander Schwinn <alexxcons@xfce.org>2021-03-08 09:10:24 +0100
commit8146a152a3ee43da3ed92ba72ded4f74434de673 (patch)
tree609585a9f4801686117faba0c8de026045fbc51d
parent254b3bdf20b77ab96ff3a0a6551b8bdc6131241c (diff)
downloadthunar-8146a152a3ee43da3ed92ba72ded4f74434de673.tar.gz
Revert "Bookmarks no longer need an existing file (Issue #47)"
Reverted since it seems to cause a regression (Issue #526) This reverts commit 70f75b89cbfd7f330710631998ae21902f7a10e5.
-rw-r--r--thunar/thunar-shortcuts-model.c72
1 files changed, 27 insertions, 45 deletions
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 3dd25c2f..9f684803 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -1330,40 +1330,47 @@ thunar_shortcuts_model_load_line (GFile *file_path,
_thunar_return_if_fail (THUNAR_IS_SHORTCUTS_MODEL (model));
_thunar_return_if_fail (name == NULL || g_utf8_validate (name, -1, NULL));
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS;
-
- /* handle local and remote files differently */
+ /* handle local and remove files differently */
if (thunar_shortcuts_model_local_file (file_path))
{
/* try to open the file corresponding to the uri */
file = thunar_file_get (file_path, NULL);
if (G_UNLIKELY (file == NULL))
+ return;
+
+ /* make sure the file refers to a directory */
+ if (G_UNLIKELY (thunar_file_is_directory (file)))
{
- shortcut->gicon = g_themed_icon_new ("folder");
- shortcut->location = g_object_ref (file_path);
+ /* create the shortcut entry */
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS;
+ shortcut->file = file;
+ shortcut->sort_id = row_num;
+ shortcut->hidden = thunar_shortcuts_model_get_hidden (model, shortcut);
+ shortcut->name = g_strdup (name);
+
+ /* append the shortcut to the list */
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
}
else
{
- /* make sure the file refers to a directory */
- if (G_UNLIKELY (thunar_file_is_directory (file)))
- shortcut->file = file;
- else
- g_object_unref (file);
+ g_object_unref (file);
}
}
else
{
+ /* create the shortcut entry */
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS;
shortcut->gicon = g_themed_icon_new ("folder-remote");
shortcut->location = g_object_ref (file_path);
- }
-
- shortcut->sort_id = row_num;
- shortcut->hidden = thunar_shortcuts_model_get_hidden (model, shortcut);
- shortcut->name = g_strdup (name);
+ shortcut->sort_id = row_num;
+ shortcut->hidden = thunar_shortcuts_model_get_hidden (model, shortcut);
+ shortcut->name = g_strdup (name);
- /* append the shortcut to the list */
- thunar_shortcuts_model_add_shortcut (model, shortcut);
+ /* append the shortcut to the list */
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
}
@@ -1567,11 +1574,6 @@ thunar_shortcuts_model_file_changed (ThunarFile *file,
path = gtk_tree_path_new_from_indices (idx, -1);
gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
gtk_tree_path_free (path);
-
- /* the shortcuts list was changed, so write the gtk bookmarks file */
- if (shortcut->group == THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS)
- thunar_shortcuts_model_save (model);
-
break;
}
}
@@ -1600,29 +1602,9 @@ thunar_shortcuts_model_file_destroy (ThunarFile *file,
/* verify that we actually found a shortcut */
_thunar_assert (lp != NULL);
_thunar_assert (THUNAR_IS_FILE (shortcut->file));
- if (shortcut->group == THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS)
- {
- if (G_LIKELY (shortcut->gicon != NULL))
- g_object_unref (shortcut->gicon);
-
- if (G_LIKELY (shortcut->location != NULL))
- g_object_unref (shortcut->location);
- shortcut->gicon = g_themed_icon_new ("folder");
- shortcut->location = g_object_ref (thunar_file_get_file (shortcut->file));
-
- thunar_file_unwatch (shortcut->file);
- g_signal_handlers_disconnect_matched (shortcut->file,
- G_SIGNAL_MATCH_DATA, 0,
- 0, NULL, NULL, model);
- g_object_unref (shortcut->file);
- shortcut->file = NULL;
- }
- else
- {
- /* drop the shortcut from the model */
- thunar_shortcuts_model_remove_shortcut (model, shortcut);
- }
+ /* drop the shortcut from the model */
+ thunar_shortcuts_model_remove_shortcut (model, shortcut);
}