[Xfce4-commits] <thunar:master> Handle NULL ThunarFiles.
Nick Schermer
noreply at xfce.org
Sat Oct 13 16:12:08 CEST 2012
Updating branch refs/heads/master
to 20ce6724810584ba88e66afd8ba7b8bdd8cc86ae (commit)
from e486a39069ea5ac99e59db74064f70037417053c (commit)
commit 20ce6724810584ba88e66afd8ba7b8bdd8cc86ae
Author: Nick Schermer <nick at xfce.org>
Date: Fri Oct 5 23:12:22 2012 +0200
Handle NULL ThunarFiles.
thunar/thunar-shortcuts-model.c | 53 ++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index c16988c..3d4ba1d 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -310,6 +310,7 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
GFile *bookmarks;
GFile *desktop;
GFile *trash;
+ ThunarFile *file;
/* add the places heading */
shortcut = g_slice_new0 (ThunarShortcut);
@@ -322,23 +323,31 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
home = thunar_g_file_new_for_home ();
/* add home entry */
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
- shortcut->file = thunar_file_get (home, NULL);
- shortcut->sort_id = 0;
- shortcut->gicon = g_themed_icon_new ("user-home");
- thunar_shortcuts_model_add_shortcut (model, shortcut);
+ file = thunar_file_get (home, NULL);
+ if (file != NULL)
+ {
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
+ shortcut->file = file;
+ shortcut->sort_id = 0;
+ shortcut->gicon = g_themed_icon_new ("user-home");
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
/* add desktop entry */
desktop = thunar_g_file_new_for_desktop ();
if (!g_file_equal (desktop, home))
{
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
- shortcut->file = thunar_file_get (desktop, NULL);
- shortcut->gicon = g_themed_icon_new ("user-desktop");
- shortcut->sort_id = 1;
- thunar_shortcuts_model_add_shortcut (model, shortcut);
+ file = thunar_file_get (desktop, NULL);
+ if (file != NULL)
+ {
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
+ shortcut->file = file;
+ shortcut->gicon = g_themed_icon_new ("user-desktop");
+ shortcut->sort_id = 1;
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
}
g_object_unref (desktop);
@@ -346,15 +355,18 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
{
trash = thunar_g_file_new_for_trash ();
-
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_TRASH;
- shortcut->file = thunar_file_get (trash, NULL);
- shortcut->gicon = g_themed_icon_new ("user-trash");
- shortcut->name = g_strdup (_("Trash"));
- thunar_shortcuts_model_add_shortcut (model, shortcut);
-
+ file = thunar_file_get (trash, NULL);
g_object_unref (trash);
+
+ if (file != NULL)
+ {
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_TRASH;
+ shortcut->file = file;
+ shortcut->gicon = g_themed_icon_new ("user-trash");
+ shortcut->name = g_strdup (_("Trash"));
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
}
/* determine the URI to the Gtk+ bookmarks file */
@@ -1084,6 +1096,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model)
file = thunar_file_get (file_path, NULL);
g_object_unref (file_path);
+ /* TODO invisible item? */
if (G_UNLIKELY (file == NULL))
continue;
More information about the Xfce4-commits
mailing list