diff -Naurp thunar.bak/configure.in.in thunar/configure.in.in --- thunar.bak/configure.in.in 2008-09-16 03:12:27.000000000 +0200 +++ thunar/configure.in.in 2008-09-16 03:15:39.000000000 +0200 @@ -399,6 +399,25 @@ AC_MSG_CHECKING([PLATFORM_LDFLAGS]) AC_MSG_RESULT([$PLATFORM_LDFLAGS]) AC_SUBST([PLATFORM_LDFLAGS]) +dnl ********************************************* +dnl ** Check whether to support xdg user dirs. ** +dnl ** glib >= 2.14.0 needed. ** +dnl ********************************************* +AC_ARG_ENABLE([xdg-user-dirs], + [AC_HELP_STRING([--enable-xdg-user-dirs], + [Enable support for the xdg user special directories (glib >= 2.14.0 needed) [default=yes]])], + [ac_bm_thunar_xdg_user_dirs=$enableval], + [ac_bm_thunar_xdg_user_dirs=yes]) + +AC_MSG_CHECKING([whether to build support for xdg user dirs]) + +if test "x$ac_bm_thunar_xdg_user_dirs" = "xyes"; then + XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.14.0]) + AC_DEFINE([XDG_USER_SPECIAL_DIRS], [1], [Define if support for xdg user special dirs should be built]) +else + AC_MSG_RESULT([no]) +fi + dnl ************************************ dnl *** Check for additional plugins *** dnl ************************************ @@ -481,30 +500,31 @@ dnl *************************** echo echo "Build Configuration:" echo -echo "* Operating system support: $ac_bm_thunar_vfs_os_impl" +echo "* Operating system support: $ac_bm_thunar_vfs_os_impl" if test x"$DBUS_FOUND" = x"yes"; then -echo "* D-BUS support: yes" +echo "* D-BUS support: yes" else -echo "* D-BUS support: no" +echo "* D-BUS support: no" fi -echo "* File System Monitor: $ac_bm_thunar_vfs_monitor_impl" +echo "* File System Monitor: $ac_bm_thunar_vfs_monitor_impl" if test x"$GCONF_FOUND" = x"yes"; then -echo "* GNOME Thumbnailers: yes" +echo "* GNOME Thumbnailers: yes" else -echo "* GNOME Thumbnailers: no" +echo "* GNOME Thumbnailers: no" fi if test x"$LIBSTARTUP_NOTIFICATION_FOUND" = x"yes"; then -echo "* Startup Notification: yes" +echo "* Startup Notification: yes" else -echo "* Startup Notification: no" +echo "* Startup Notification: no" fi -echo "* Volume Manager: $ac_bm_thunar_vfs_volume_impl" -echo "* Debug Support: $enable_debug" +echo "* Volume Manager: $ac_bm_thunar_vfs_volume_impl" +echo "* Support for XDG user directories: $ac_bm_thunar_xdg_user_dirs" +echo "* Debug Support: $enable_debug" echo echo "Additional Plugins:" echo -echo "* Advanced Properties: $ac_bm_thunar_plugin_apr" -echo "* Simple Builting Renamers: $ac_bm_thunar_plugin_sbr" -echo "* Trash Panel Applet: $ac_bm_thunar_plugin_tpa" -echo "* User Customizable Actions: $ac_bm_thunar_plugin_uca" +echo "* Advanced Properties: $ac_bm_thunar_plugin_apr" +echo "* Simple Builting Renamers: $ac_bm_thunar_plugin_sbr" +echo "* Trash Panel Applet: $ac_bm_thunar_plugin_tpa" +echo "* User Customizable Actions: $ac_bm_thunar_plugin_uca" echo diff -Naurp thunar.bak/thunar/thunar-file.c thunar/thunar/thunar-file.c --- thunar.bak/thunar/thunar-file.c 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-file.c 2008-09-16 03:27:19.000000000 +0200 @@ -1620,7 +1620,51 @@ thunar_file_set_custom_icon (ThunarFile return TRUE; } - +/** + * thunar_file_is_desktop: + * @file : a #ThunarFile. + * + * Checks whether @file refers to the users desktop directory. + * + * Return value: %TRUE if @file is the users desktop directory. + **/ +gboolean thunar_file_is_desktop (const ThunarFile *file) +{ +#ifdef XDG_USER_SPECIAL_DIRS + gchar *file_path = thunar_vfs_path_dup_string(thunar_file_get_path(file)); + gchar *desktop_dir = NULL; + gboolean was_user_desktop_dir_found = TRUE; + gboolean result; + ThunarVfsPath *home = NULL; + ThunarVfsPath *desktop_vfs = NULL; + + desktop_dir = (gchar *)g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); + if (G_UNLIKELY(desktop_dir == NULL)) { + home = thunar_vfs_path_get_for_home (); + desktop_vfs = thunar_vfs_path_relative (home, "Desktop"); + desktop_dir = (gchar *)thunar_vfs_path_get_name(desktop_vfs); + was_user_desktop_dir_found = FALSE; + } + + if ((desktop_dir != NULL) && (!g_strcmp0(file_path, desktop_dir))) + result = TRUE; + else + result = FALSE; + + if (G_UNLIKELY(was_user_desktop_dir_found == FALSE)) { + g_free(desktop_dir); + thunar_vfs_path_unref(desktop_vfs); + thunar_vfs_path_unref(home); + } + g_free(file_path); + + return result; +#else /* XDG_USER_SPECIAL_DIRS */ +return (!thunar_vfs_path_is_root (thunar_file_get_path (file)) + && thunar_vfs_path_is_home (thunar_vfs_path_get_parent (thunar_file_get_path (file))) + && exo_str_is_equal (thunar_file_get_display_name (file), "Desktop")); +#endif /* XDG_USER_SPECIAL_DIRS */ +} /** * thunar_file_get_icon_name: diff -Naurp thunar.bak/thunar/thunar-file.h thunar/thunar/thunar-file.h --- thunar.bak/thunar/thunar-file.h 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-file.h 2008-09-16 03:15:35.000000000 +0200 @@ -24,6 +24,8 @@ #include #include +#include + G_BEGIN_DECLS; typedef struct _ThunarFileClass ThunarFileClass; @@ -202,6 +204,8 @@ ThunarFile *thunar_file_cache_look GList *thunar_file_list_get_applications (GList *file_list); GList *thunar_file_list_to_path_list (GList *file_list); +gboolean thunar_file_is_desktop (const ThunarFile *file); + /** * thunar_file_has_parent: @@ -450,18 +454,6 @@ G_STMT_START{ #define thunar_file_is_home(file) (thunar_vfs_path_is_home (THUNAR_FILE ((file))->info->path)) /** - * thunar_file_is_desktop: - * @file : a #ThunarFile. - * - * Checks whether @file refers to the users desktop directory. - * - * Return value: %TRUE if @file is the users desktop directory. - **/ -#define thunar_file_is_desktop(file) (!thunar_vfs_path_is_root (thunar_file_get_path (file)) \ - && thunar_vfs_path_is_home (thunar_vfs_path_get_parent (thunar_file_get_path (file))) \ - && exo_str_is_equal (thunar_file_get_display_name (file), "Desktop")) - -/** * thunar_file_is_regular: * @file : a #ThunarFile. * diff -Naurp thunar.bak/thunar/thunar-launcher.c thunar/thunar/thunar-launcher.c --- thunar.bak/thunar/thunar-launcher.c 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-launcher.c 2008-09-16 03:15:35.000000000 +0200 @@ -1169,6 +1169,11 @@ thunar_launcher_action_sendto_desktop (G ThunarVfsPath *desktop_path; ThunarVfsPath *home_path; GList *paths; +#ifdef XDG_USER_SPECIAL_DIRS + GError *error = NULL; + const gchar *str_desktop_path = NULL; + gboolean was_user_desktop_found = TRUE; +#endif /* XDG_USER_SPECIAL_DIRS */ _thunar_return_if_fail (GTK_IS_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher)); @@ -1180,7 +1185,24 @@ thunar_launcher_action_sendto_desktop (G /* determine the path to the ~/Desktop folder */ home_path = thunar_vfs_path_get_for_home (); + +#ifdef XDG_USER_SPECIAL_DIRS + str_desktop_path = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); + if (G_UNLIKELY (str_desktop_path == NULL)) { + was_user_desktop_found = FALSE; + desktop_path = thunar_vfs_path_relative (home_path, "Desktop"); + } else { + /* let's copy this string because it must not be freed (owned by glib) */ + desktop_path = thunar_vfs_path_new( + str_desktop_path, + &error); + if (G_UNLIKELY (error != NULL)) + desktop_path = thunar_vfs_path_relative (home_path, "Desktop"); + } +#else /* XDG_USER_SPECIAL_DIRS */ desktop_path = thunar_vfs_path_relative (home_path, "Desktop"); +#endif /* XDG_USER_SPECIAL_DIRS */ + thunar_vfs_path_unref (home_path); /* launch the link job */ @@ -1191,6 +1213,12 @@ thunar_launcher_action_sendto_desktop (G /* cleanup */ thunar_vfs_path_unref (desktop_path); thunar_vfs_path_list_free (paths); +#ifdef XDG_USER_SPECIAL_DIRS + if (G_UNLIKELY(was_user_desktop_found == FALSE)) + g_free(str_desktop_path); + if (G_UNLIKELY(error != NULL)) + g_error_free(error); +#endif /* XDG_USER_SPECIAL_DIRS */ } diff -Naurp thunar.bak/thunar/thunar-shortcuts-model.c thunar/thunar/thunar-shortcuts-model.c --- thunar.bak/thunar/thunar-shortcuts-model.c 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-shortcuts-model.c 2008-09-16 03:15:35.000000000 +0200 @@ -33,6 +33,10 @@ #include #include +#ifdef XDG_USER_SPECIAL_DIRS +#include +#endif /* XDG_USER_SPECIAL_DIRS */ + #define THUNAR_SHORTCUT(obj) ((ThunarShortcut *) (obj)) @@ -263,6 +267,11 @@ thunar_shortcuts_model_init (ThunarShort GList *volumes; GList *lp; guint n; +#ifdef XDG_USER_SPECIAL_DIRS + GError *error = NULL; + gboolean was_user_desktop_found = TRUE; + const gchar *desktop_path = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); +#endif /* XDG_USER_SPECIAL_DIRS */ #ifndef NDEBUG model->stamp = g_random_int (); @@ -276,7 +285,18 @@ thunar_shortcuts_model_init (ThunarShort /* determine the system-defined paths */ system_path_list[0] = thunar_vfs_path_get_for_home (); system_path_list[1] = thunar_vfs_path_get_for_trash (); +#ifdef XDG_USER_SPECIAL_DIRS + if (G_UNLIKELY (desktop_path == NULL)) { + was_user_desktop_found = FALSE; + system_path_list[2] = thunar_vfs_path_relative (system_path_list[0], "Desktop"); + } else { + system_path_list[2] = thunar_vfs_path_new(desktop_path, &error); + if (G_UNLIKELY (error != NULL)) + system_path_list[2] = thunar_vfs_path_relative (system_path_list[0], "Desktop"); + } +#else /* XDG_USER_SPECIAL_DIRS */ system_path_list[2] = thunar_vfs_path_relative (system_path_list[0], "Desktop"); +#endif /* XDG_USER_SPECIAL_DIRS */ system_path_list[3] = thunar_vfs_path_get_for_root (); /* will be used to append the shortcuts to the list */ @@ -357,6 +377,12 @@ thunar_shortcuts_model_init (ThunarShort /* cleanup */ thunar_vfs_path_unref (fpath); gtk_tree_path_free (path); +#ifdef XDG_USER_SPECIAL_DIRS + if (G_UNLIKELY(error != NULL)) + g_error_free(error); + if (G_UNLIKELY(was_user_desktop_found == FALSE)) + g_free(desktop_path); +#endif /* XDG_USER_SPECIAL_DIRS */ } diff -Naurp thunar.bak/thunar/thunar-stock.h thunar/thunar/thunar-stock.h --- thunar.bak/thunar/thunar-stock.h 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-stock.h 2008-09-16 03:15:35.000000000 +0200 @@ -28,6 +28,7 @@ G_BEGIN_DECLS; #define THUNAR_STOCK_TEMPLATES "thunar-templates" /* see ThunarWindow */ #define THUNAR_STOCK_TRASH_EMPTY "thunar-trash-empty" /* see ThunarTrashAction */ #define THUNAR_STOCK_TRASH_FULL "thunar-trash-full" /* see ThunarTrashAction */ +#define THUNAR_STOCK_DIRECTORY "gnome-fs-directory" void thunar_stock_init (void) G_GNUC_INTERNAL; diff -Naurp thunar.bak/thunar/thunar-templates-action.c thunar/thunar/thunar-templates-action.c --- thunar.bak/thunar/thunar-templates-action.c 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-templates-action.c 2008-09-16 03:15:35.000000000 +0200 @@ -352,6 +352,11 @@ thunar_templates_action_menu_shown (GtkW GtkWidget *image; GtkWidget *item; GList *children; +#ifdef XDG_USER_SPECIAL_DIRS + GError *error = NULL; + gboolean was_user_templates_dir_found = TRUE; + const gchar *templates_dir=g_get_user_special_dir(G_USER_DIRECTORY_TEMPLATES); +#endif /* XDG_USER_SPECIAL_DIRS */ _thunar_return_if_fail (THUNAR_IS_TEMPLATES_ACTION (templates_action)); _thunar_return_if_fail (GTK_IS_MENU_SHELL (menu)); @@ -363,7 +368,22 @@ thunar_templates_action_menu_shown (GtkW /* determine the path to the ~/Templates folder */ home_path = thunar_vfs_path_get_for_home (); +#ifdef XDG_USER_SPECIAL_DIRS + if (G_UNLIKELY (templates_dir == NULL)) { + was_user_templates_dir_found = FALSE; + templates_path = thunar_vfs_path_relative (home_path, "Templates"); + } else { + templates_path = thunar_vfs_path_new( + templates_dir, + &error); + + if (G_UNLIKELY (error != NULL)) + templates_path = thunar_vfs_path_relative (home_path, "Templates"); + } +#else /* XDG_USER_SPECIAL_DIRS */ templates_path = thunar_vfs_path_relative (home_path, "Templates"); +#endif /* XDG_USER_SPECIAL_DIRS */ + thunar_vfs_path_unref (home_path); /* fill the menu with files/folders from the ~/Templates folder */ @@ -397,6 +417,12 @@ thunar_templates_action_menu_shown (GtkW /* cleanup */ thunar_vfs_path_unref (templates_path); +#ifdef XDG_USER_SPECIAL_DIRS + if (G_UNLIKELY(was_user_templates_dir_found == FALSE)) + g_free(templates_dir); + if (G_UNLIKELY(error != NULL)) + g_error_free(error); +#endif /* XDG_USER_SPECIAL_DIRS */ } diff -Naurp thunar.bak/thunar/thunar-window.c thunar/thunar/thunar-window.c --- thunar.bak/thunar/thunar-window.c 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-window.c 2008-09-16 03:15:35.000000000 +0200 @@ -54,6 +54,8 @@ #include #include +#include + /* Property identifiers */ @@ -146,8 +148,22 @@ static void thunar_window_action_go_ ThunarWindow *window); static void thunar_window_action_open_home (GtkAction *action, ThunarWindow *window); +static void thunar_window_action_open_desktop (GtkAction *action, + ThunarWindow *window); +static void thunar_window_action_open_documents (GtkAction *action, + ThunarWindow *window); +static void thunar_window_action_open_downloads (GtkAction *action, + ThunarWindow *window); +static void thunar_window_action_open_music (GtkAction *action, + ThunarWindow *window); +static void thunar_window_action_open_pictures (GtkAction *action, + ThunarWindow *window); +static void thunar_window_action_open_public (GtkAction *action, + ThunarWindow *window); static void thunar_window_action_open_templates (GtkAction *action, ThunarWindow *window); +static void thunar_window_action_open_videos (GtkAction *action, + ThunarWindow *window); static void thunar_window_action_open_trash (GtkAction *action, ThunarWindow *window); static void thunar_window_action_open_location (GtkAction *action, @@ -281,7 +297,14 @@ static const GtkActionEntry action_entri { "go-menu", NULL, N_ ("_Go"), NULL, }, { "open-parent", GTK_STOCK_GO_UP, N_ ("Open _Parent"), "Up", N_ ("Open the parent folder"), G_CALLBACK (thunar_window_action_go_up), }, { "open-home", THUNAR_STOCK_HOME, N_ ("_Home"), "Home", N_ ("Go to the home folder"), G_CALLBACK (thunar_window_action_open_home), }, + { "open-desktop", THUNAR_STOCK_DESKTOP, N_ ("_Desktop"), NULL, N_ ("Go to the desktop folder"), G_CALLBACK (thunar_window_action_open_desktop), }, + { "open-documents", THUNAR_STOCK_DIRECTORY, N_ ("Do_cuments"), NULL, N_ ("Go to the documents folder"), G_CALLBACK (thunar_window_action_open_documents), }, + { "open-downloads", THUNAR_STOCK_DIRECTORY, N_ ("Do_wnloads"), NULL, N_ ("Go to the downloads folder"), G_CALLBACK (thunar_window_action_open_downloads), }, + { "open-music", THUNAR_STOCK_DIRECTORY, N_ ("_Music"), NULL, N_ ("Go to the music folder"), G_CALLBACK (thunar_window_action_open_music), }, + { "open-pictures", THUNAR_STOCK_DIRECTORY, N_ ("_Pictures"), NULL, N_ ("Go to the pictures folder"), G_CALLBACK (thunar_window_action_open_pictures), }, + { "open-public", THUNAR_STOCK_DIRECTORY, N_ ("Pu_blic"), NULL, N_ ("Go to the public folder"), G_CALLBACK (thunar_window_action_open_public), }, { "open-templates", THUNAR_STOCK_TEMPLATES, N_ ("T_emplates"), NULL, N_ ("Go to the templates folder"), G_CALLBACK (thunar_window_action_open_templates), }, + { "open-videos", THUNAR_STOCK_DIRECTORY, N_ ("_Videos"), NULL, N_ ("Go to the videos folder"), G_CALLBACK (thunar_window_action_open_videos), }, { "open-location", NULL, N_ ("_Open Location..."), "L", N_ ("Specify a location to open"), G_CALLBACK (thunar_window_action_open_location), }, { "help-menu", NULL, N_ ("_Help"), NULL, }, { "contents", GTK_STOCK_HELP, N_ ("_Contents"), "F1", N_ ("Display Thunar user manual"), G_CALLBACK (thunar_window_action_contents), }, @@ -579,7 +602,61 @@ view_index2type (gint index) } } - +void +set_special_dir_menu_entry_visibility(ThunarWindow *window) +{ + GtkAction *action; +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *vfs_path = NULL; + GError *error = NULL; + gchar *path; + gboolean shown; +#endif /* XDG_USER_SPECIAL_DIRS */ + static const gchar *callback_names[]={ "open-desktop", + "open-documents", "open-downloads", "open-music", "open-pictures", + "open-public", "open-templates", "open-videos" }; + gint i; + + /* we start from the documents (value 1) thus jumping the desktop */ + for (i = G_USER_DIRECTORY_DESKTOP; + i <= G_USER_DIRECTORY_VIDEOS; i++) { + +#ifdef XDG_USER_SPECIAL_DIRS + /* we ignore the templates */ + if ((i == G_USER_DIRECTORY_TEMPLATES) || + (i == G_USER_DIRECTORY_DESKTOP)) + continue; +#else + if (i == G_USER_DIRECTORY_TEMPLATES) + continue; + +#endif + + action = gtk_action_group_get_action(window->action_group, + callback_names[i]); +#ifdef XDG_USER_SPECIAL_DIRS + shown = TRUE; + path = (gchar *)g_get_user_special_dir(i); + if (G_UNLIKELY(path == NULL)) { + shown = FALSE; + } else { + vfs_path = thunar_vfs_path_new(path, &error); + + if (G_UNLIKELY(error != NULL)) { + shown = FALSE; + g_error_free(error); + } + + if (G_LIKELY(vfs_path != NULL)) + thunar_vfs_path_unref(vfs_path); + } + + gtk_action_set_visible(GTK_ACTION(action), shown); +#else /* XDG_USER_SPECIAL_DIRS */ + gtk_action_set_visible(GTK_ACTION(action), FALSE); +#endif /* XDG_USER_SPECIAL_DIRS */ + } +} static void thunar_window_init (ThunarWindow *window) @@ -645,6 +722,8 @@ thunar_window_init (ThunarWindow *window g_signal_connect_swapped (G_OBJECT (window->history), "change-directory", G_CALLBACK (thunar_window_set_current_directory), window); exo_binding_new (G_OBJECT (window), "current-directory", G_OBJECT (window->history), "current-directory"); + set_special_dir_menu_entry_visibility(window); + /* setup the "open-trash" action */ action = thunar_trash_action_new (); g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (thunar_window_action_open_trash), window); @@ -1788,7 +1867,391 @@ thunar_window_action_open_home (GtkActio thunar_vfs_path_unref (home_path); } +static void +thunar_window_action_open_desktop (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *desktop_path; + ThunarFile *desktop_file = NULL; + GError *error = NULL; + gchar *absolute_path; + /* g_get_user_special_dir() never returns NULL on the desktop */ + const gchar *desktop_dir = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Desktop folder */ + home_path = thunar_vfs_path_get_for_home (); + desktop_path = thunar_vfs_path_new(desktop_dir,&error); + + if (G_UNLIKELY (error != NULL)) + desktop_path = thunar_vfs_path_relative (home_path, "Desktop"); + + thunar_vfs_path_unref (home_path); + + /* make sure that the ~/Desktop folder exists */ + absolute_path = thunar_vfs_path_dup_string (desktop_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Desktop path */ + if (G_LIKELY (error == NULL)) + desktop_file = thunar_file_get_for_path (desktop_path, &error); + + /* open the ~/Desktop folder */ + if (G_LIKELY (desktop_file != NULL)) + { + /* go to the ~/Desktop folder */ + thunar_window_set_current_directory (window, desktop_file); + g_object_unref (G_OBJECT (desktop_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the desktop folder")); + g_error_free (error); + } + + /* release our reference on the ~/Desktop path */ + thunar_vfs_path_unref (desktop_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} + + +static void +thunar_window_action_open_documents (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *documents_path; + ThunarFile *documents_file = NULL; + GError *error = NULL; + gchar *absolute_path; + const gchar *documents_dir=g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Documents folder */ + home_path = thunar_vfs_path_get_for_home (); + if (G_UNLIKELY (documents_dir == NULL)) { + thunar_vfs_path_unref (home_path); + return; + } else { + documents_path = thunar_vfs_path_new(documents_dir, &error); + + if (G_UNLIKELY (error != NULL)) { + thunar_vfs_path_unref(home_path); + thunar_vfs_path_unref(documents_path); + g_error_free(error); + return; + } + } + + thunar_vfs_path_unref (home_path); + + /* make sure that the ~/Documents folder exists */ + absolute_path = thunar_vfs_path_dup_string (documents_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Documents path */ + if (G_LIKELY (error == NULL)) + documents_file = thunar_file_get_for_path (documents_path, &error); + + /* open the ~/Documents folder */ + if (G_LIKELY (documents_file != NULL)) + { + /* go to the ~/Documents folder */ + thunar_window_set_current_directory (window, documents_file); + g_object_unref (G_OBJECT (documents_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the documents folder")); + g_error_free (error); + } + + /* release our reference on the ~/Documents path */ + thunar_vfs_path_unref (documents_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} + + +static void +thunar_window_action_open_downloads (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *downloads_path; + ThunarFile *downloads_file = NULL; + GError *error = NULL; + gchar *absolute_path; + const gchar *download_dir=g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Downloads folder */ + home_path = thunar_vfs_path_get_for_home (); + if (G_UNLIKELY (download_dir == NULL)) { + thunar_vfs_path_unref (home_path); + return; + } else { + downloads_path = thunar_vfs_path_new(download_dir, &error); + + if (G_UNLIKELY (error != NULL)) { + thunar_vfs_path_unref(home_path); + thunar_vfs_path_unref(downloads_path); + g_error_free(error); + return; + + } + } + + thunar_vfs_path_unref (home_path); + + /* make sure that the ~/Downloads folder exists */ + absolute_path = thunar_vfs_path_dup_string (downloads_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Downloads path */ + if (G_LIKELY (error == NULL)) + downloads_file = thunar_file_get_for_path (downloads_path, &error); + + /* open the ~/Downloads folder */ + if (G_LIKELY (downloads_file != NULL)) + { + /* go to the ~/Downloads folder */ + thunar_window_set_current_directory (window, downloads_file); + g_object_unref (G_OBJECT (downloads_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the downloads folder")); + g_error_free (error); + } + + /* release our reference on the ~/Download path */ + thunar_vfs_path_unref (downloads_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} + +static void +thunar_window_action_open_music (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *music_path; + ThunarFile *music_file = NULL; + GError *error = NULL; + gchar *absolute_path; + const gchar *music_dir=g_get_user_special_dir(G_USER_DIRECTORY_MUSIC); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Music folder */ + home_path = thunar_vfs_path_get_for_home (); + if (G_UNLIKELY (music_dir == NULL)) { + thunar_vfs_path_unref (home_path); + return; + } else { + music_path = thunar_vfs_path_new(music_dir, &error); + + if (G_UNLIKELY (error != NULL)) { + thunar_vfs_path_unref(home_path); + thunar_vfs_path_unref(music_path); + g_error_free(error); + return; + + } + } + + thunar_vfs_path_unref (home_path); + + /* make sure that the ~/Music folder exists */ + absolute_path = thunar_vfs_path_dup_string (music_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Music path */ + if (G_LIKELY (error == NULL)) + music_file = thunar_file_get_for_path (music_path, &error); + + /* open the ~/Music folder */ + if (G_LIKELY (music_file != NULL)) + { + /* go to the ~/Music folder */ + thunar_window_set_current_directory (window, music_file); + g_object_unref (G_OBJECT (music_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the music folder")); + g_error_free (error); + } + + /* release our reference on the ~/Music path */ + thunar_vfs_path_unref (music_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} + +static void +thunar_window_action_open_pictures (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *pictures_path; + ThunarFile *pictures_file = NULL; + GError *error = NULL; + gchar *absolute_path; + const gchar *picture_dir=g_get_user_special_dir(G_USER_DIRECTORY_PICTURES); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Pictures folder */ + home_path = thunar_vfs_path_get_for_home (); + if (G_UNLIKELY (picture_dir == NULL)) { + thunar_vfs_path_unref (home_path); + return; + } else { + pictures_path = thunar_vfs_path_new(picture_dir, &error); + + if (G_UNLIKELY (error != NULL)) { + thunar_vfs_path_unref(home_path); + thunar_vfs_path_unref(pictures_path); + g_error_free(error); + return; + } + } + + thunar_vfs_path_unref (home_path); + + /* make sure that the ~/Pictures folder exists */ + absolute_path = thunar_vfs_path_dup_string (pictures_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Pictures path */ + if (G_LIKELY (error == NULL)) + pictures_file = thunar_file_get_for_path (pictures_path, &error); + + /* open the ~/Pictures folder */ + if (G_LIKELY (pictures_file != NULL)) + { + /* go to the ~/Pictures folder */ + thunar_window_set_current_directory (window, pictures_file); + g_object_unref (G_OBJECT (pictures_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the pictures folder")); + g_error_free (error); + } + /* release our reference on the ~/Pictures path */ + thunar_vfs_path_unref (pictures_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} + +static void +thunar_window_action_open_public (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *public_path; + ThunarFile *public_file = NULL; + GError *error = NULL; + gchar *absolute_path; + const gchar *public_dir=g_get_user_special_dir(G_USER_DIRECTORY_PUBLIC_SHARE); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Public folder */ + home_path = thunar_vfs_path_get_for_home (); + if (G_UNLIKELY (public_dir == NULL)) { + thunar_vfs_path_unref (home_path); + return; + } else { + public_path = thunar_vfs_path_new(public_dir, &error); + + if (G_LIKELY (error != NULL)) { + thunar_vfs_path_unref(home_path); + thunar_vfs_path_unref(public_path); + g_error_free(error); + return; + } + } + + thunar_vfs_path_unref (home_path); + + /* make sure that the ~/Public folder exists */ + absolute_path = thunar_vfs_path_dup_string (public_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Public path */ + if (G_LIKELY (error == NULL)) + public_file = thunar_file_get_for_path (public_path, &error); + + /* open the ~/Public folder */ + if (G_LIKELY (public_file != NULL)) + { + /* go to the ~/Public folder */ + thunar_window_set_current_directory (window, public_file); + g_object_unref (G_OBJECT (public_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the public folder")); + g_error_free (error); + } + + /* release our reference on the ~/Public path */ + thunar_vfs_path_unref (public_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} static void thunar_window_action_open_templates (GtkAction *action, @@ -1806,13 +2269,29 @@ thunar_window_action_open_templates (Gtk gboolean show_about_templates; GError *error = NULL; gchar *absolute_path; +#ifdef XDG_USER_SPECIAL_DIRS + const gchar *templates_dir=g_get_user_special_dir(G_USER_DIRECTORY_TEMPLATES); +#endif /* XDG_USER_SPECIAL_DIRS */ _thunar_return_if_fail (GTK_IS_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); /* determine the path to the ~/Templates folder */ home_path = thunar_vfs_path_get_for_home (); +#ifdef XDG_USER_SPECIAL_DIRS + /* Thunar MUST have a Templates directory */ + if (G_UNLIKELY (templates_dir == NULL)) { + templates_path = thunar_vfs_path_relative (home_path, "Templates"); + } else { + templates_path = thunar_vfs_path_new(templates_dir, &error); + + if (G_UNLIKELY (error != NULL)) + templates_path = thunar_vfs_path_relative (home_path, "Templates"); + } +#else /* XDG_USER_SPECIAL_DIRS */ templates_path = thunar_vfs_path_relative (home_path, "Templates"); +#endif /* XDG_USER_SPECIAL_DIRS */ + thunar_vfs_path_unref (home_path); /* make sure that the ~/Templates folder exists */ @@ -1897,7 +2376,71 @@ thunar_window_action_open_templates (Gtk thunar_vfs_path_unref (templates_path); } +static void +thunar_window_action_open_videos (GtkAction *action, + ThunarWindow *window) +{ +#ifdef XDG_USER_SPECIAL_DIRS + ThunarVfsPath *home_path; + ThunarVfsPath *videos_path; + ThunarFile *videos_file = NULL; + GError *error = NULL; + gchar *absolute_path; + const gchar *video_dir=g_get_user_special_dir(G_USER_DIRECTORY_VIDEOS); + + _thunar_return_if_fail (GTK_IS_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the path to the ~/Videos folder */ + home_path = thunar_vfs_path_get_for_home (); + + if (G_UNLIKELY (video_dir == NULL)) { + thunar_vfs_path_unref (home_path); + return; + } else { + videos_path = thunar_vfs_path_new(video_dir, &error); + + if (G_LIKELY (error != NULL)) { + thunar_vfs_path_unref(home_path); + thunar_vfs_path_unref(videos_path); + g_error_free(error); + return; + } + } + + thunar_vfs_path_unref (home_path); + /* make sure that the ~/Videos folder exists */ + absolute_path = thunar_vfs_path_dup_string (videos_path); + xfce_mkdirhier (absolute_path, 0755, &error); + g_free (absolute_path); + + /* determine the file for the ~/Videos path */ + if (G_LIKELY (error == NULL)) + videos_file = thunar_file_get_for_path (videos_path, &error); + + /* open the ~/Videos folder */ + if (G_LIKELY (videos_file != NULL)) + { + /* go to the ~/Videos folder */ + thunar_window_set_current_directory (window, videos_file); + g_object_unref (G_OBJECT (videos_file)); + + } + + /* display an error dialog if something went wrong */ + if (G_UNLIKELY (error != NULL)) + { + thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the videos folder")); + g_error_free (error); + } + + /* release our reference on the ~/Videos path */ + thunar_vfs_path_unref (videos_path); +#else /* XDG_USER_SPECIAL_DIRS */ + return; +#endif /* XDG_USER_SPECIAL_DIRS */ +} static void thunar_window_action_open_trash (GtkAction *action, diff -Naurp thunar.bak/thunar/thunar-window-ui.xml thunar/thunar/thunar-window-ui.xml --- thunar.bak/thunar/thunar-window-ui.xml 2008-09-16 03:12:19.000000000 +0200 +++ thunar/thunar/thunar-window-ui.xml 2008-09-16 03:15:35.000000000 +0200 @@ -74,7 +74,15 @@ + + + + + + + +