diff -Naurp thunar.bak/thunar/thunar-file.c thunar/thunar/thunar-file.c --- thunar.bak/thunar/thunar-file.c 2008-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-file.c 2008-10-09 06:12:49.000000000 +0200 @@ -1621,6 +1621,36 @@ thunar_file_set_custom_icon (ThunarFile } +/** + * 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) +{ +#if GLIB_CHECK_VERSION(2,14,0) + gchar *file_path = NULL; + gboolean result; + + file_path = thunar_vfs_path_dup_string(thunar_file_get_path(file)); + + /* g_get_user_special_dir() always returns something for the desktop */ + result = exo_str_is_equal(file_path, + g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP)); + + g_free(file_path); + + return result; +#else /* GLIB_CHECK_VERSION(2,14,0) */ +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 /* GLIB_CHECK_VERSION(2,14,0) */ +} + /** * 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-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-file.h 2008-10-08 18:59:49.000000000 +0200 @@ -24,6 +24,8 @@ #include #include +#include + G_BEGIN_DECLS; typedef struct _ThunarFileClass ThunarFileClass; @@ -202,6 +204,7 @@ 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 +453,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-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-launcher.c 2008-10-09 08:56:33.000000000 +0200 @@ -1169,6 +1169,7 @@ thunar_launcher_action_sendto_desktop (G ThunarVfsPath *desktop_path; ThunarVfsPath *home_path; GList *paths; + gchar *str_desktop_path = NULL; _thunar_return_if_fail (GTK_IS_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher)); @@ -1180,8 +1181,20 @@ thunar_launcher_action_sendto_desktop (G /* determine the path to the ~/Desktop folder */ home_path = thunar_vfs_path_get_for_home (); - desktop_path = thunar_vfs_path_relative (home_path, "Desktop"); +#if GLIB_CHECK_VERSION(2,14,0) + str_desktop_path = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP)); +#else /* GLIB_CHECK_VERSION(2,14,0) */ + str_desktop_path = g_build_path(G_DIR_SEPARATOR_S, xfce_get_homedir(), + "Desktop", NULL); +#endif /* GLIB_CHECK_VERSION(2,14,0) */ + + desktop_path = thunar_vfs_path_new(str_desktop_path, NULL); + + if (G_UNLIKELY(desktop_path == NULL)) + desktop_path = thunar_vfs_path_relative(home_path, "Desktop"); + thunar_vfs_path_unref (home_path); + g_free(str_desktop_path); /* launch the link job */ application = thunar_application_get (); diff -Naurp thunar.bak/thunar/thunar-shortcuts-model.c thunar/thunar/thunar-shortcuts-model.c --- thunar.bak/thunar/thunar-shortcuts-model.c 2008-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-shortcuts-model.c 2008-10-09 09:49:41.000000000 +0200 @@ -33,6 +33,7 @@ #include #include +#include #define THUNAR_SHORTCUT(obj) ((ThunarShortcut *) (obj)) @@ -263,6 +264,7 @@ thunar_shortcuts_model_init (ThunarShort GList *volumes; GList *lp; guint n; + gchar *desktop_path = NULL; #ifndef NDEBUG model->stamp = g_random_int (); @@ -276,7 +278,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 (); - system_path_list[2] = thunar_vfs_path_relative (system_path_list[0], "Desktop"); + +#if GLIB_CHECK_VERSION(2,14,0) + desktop_path = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP)); +#else /* GLIB_CHECK_VERSION(2,14,0) */ + desktop_path = g_build_path(G_DIR_SEPARATOR_S, xfce_get_homedir(), "Desktop"); +#endif /* GLIB_CHECK_VERSION(2,14,0) */ + system_path_list[2] = thunar_vfs_path_new(desktop_path, NULL); + if (G_UNLIKELY(system_path_list[2] == NULL)) + system_path_list[2] = thunar_vfs_path_relative(system_path_list[0], "Desktop"); + + g_free(desktop_path); + system_path_list[3] = thunar_vfs_path_get_for_root (); /* will be used to append the shortcuts to the list */ @@ -755,6 +768,8 @@ thunar_shortcuts_model_load (ThunarShort gchar line[2048]; gchar *name; FILE *fp; + gint i; + gchar *user_special_dir = NULL; /* determine the path to the GTK+ bookmarks file */ bookmarks_path = xfce_get_homefile (".gtk-bookmarks", NULL); @@ -814,7 +829,60 @@ thunar_shortcuts_model_load (ThunarShort /* clean up */ gtk_tree_path_free (path); fclose (fp); - } + } +#if GLIB_CHECK_VERSION(2,14,0) + else { + /* ~/.gtk-bookmarks wasn't there or it was unreadable. + * here we recreate it with some useful xdg user special dirs */ + + path = gtk_tree_path_new_from_indices(g_list_length(model->shortcuts), -1); + for (i = G_USER_DIRECTORY_DESKTOP; i < G_USER_N_DIRECTORIES; i++) { + + /* let's ignore some directories we don't want in the side pane*/ + if ((i == G_USER_DIRECTORY_DESKTOP) || + (i == G_USER_DIRECTORY_PUBLIC_SHARE) + || (i == G_USER_DIRECTORY_TEMPLATES)) + continue; + + user_special_dir = (gchar *)g_get_user_special_dir(i); + + if (G_UNLIKELY(user_special_dir == NULL)) + continue; + + /* parse the URI */ + file_path = thunar_vfs_path_new(user_special_dir, NULL); + if (G_UNLIKELY(file_path == NULL)) + continue; + + /* try to open the file corresponding to the uri */ + file = thunar_file_get_for_path (file_path, NULL); + thunar_vfs_path_unref (file_path); + if (G_UNLIKELY (file == NULL)) + continue; + + /* make sure the file refers to a directory */ + if (G_UNLIKELY (!thunar_file_is_directory (file))) { + g_object_unref (G_OBJECT (file)); + continue; + } + + /* create the shortcut entry */ + shortcut = _thunar_slice_new0 (ThunarShortcut); + shortcut->type = THUNAR_SHORTCUT_USER_DEFINED; + shortcut->file = file; + shortcut->name = NULL; + + /* append the shortcut to the list */ + thunar_shortcuts_model_add_shortcut (model, shortcut, path); + gtk_tree_path_next (path); + + } + gtk_tree_path_free (path); + + /* we try to save the obtained new model */ + thunar_shortcuts_model_save(model); + } +#endif /* GLIB_CHECK_VERSION(2,14,0) */ /* clean up */ g_free (bookmarks_path); diff -Naurp thunar.bak/thunar/thunar-stock.h thunar/thunar/thunar-stock.h --- thunar.bak/thunar/thunar-stock.h 2008-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-stock.h 2008-10-08 18:59:49.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-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-templates-action.c 2008-10-09 07:14:24.000000000 +0200 @@ -352,6 +352,7 @@ thunar_templates_action_menu_shown (GtkW GtkWidget *image; GtkWidget *item; GList *children; + gchar *templates_dir = NULL; _thunar_return_if_fail (THUNAR_IS_TEMPLATES_ACTION (templates_action)); _thunar_return_if_fail (GTK_IS_MENU_SHELL (menu)); @@ -363,7 +364,20 @@ thunar_templates_action_menu_shown (GtkW /* determine the path to the ~/Templates folder */ home_path = thunar_vfs_path_get_for_home (); - templates_path = thunar_vfs_path_relative (home_path, "Templates"); + +#if GLIB_CHECK_VERSION(2,14,0) + templates_dir = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_TEMPLATES)); +#endif /* GLIB_CHECK_VERSION(2,14,0) */ + if (!templates_dir) + templates_dir = g_build_path(G_DIR_SEPARATOR_S, xfce_get_homedir(), "Templates"); + + templates_path = thunar_vfs_path_new(templates_dir, NULL); + if (G_UNLIKELY(templates_path == NULL)) { + templates_path = thunar_vfs_path_relative(home_path,"Templates"); + } + + g_free(templates_dir); + thunar_vfs_path_unref (home_path); /* fill the menu with files/folders from the ~/Templates folder */ diff -Naurp thunar.bak/thunar/thunar-window.c thunar/thunar/thunar-window.c --- thunar.bak/thunar/thunar-window.c 2008-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-window.c 2008-10-09 12:23:58.000000000 +0200 @@ -54,6 +54,7 @@ #include #include +#include /* Property identifiers */ @@ -146,8 +147,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 +296,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,6 +601,49 @@ view_index2type (gint index) } } +/* this function hides all the user directory menu entries in case of glib <= 2.12 + * and shows them otherwise. In the last case, if a user directory was not set, + * the menu entry will be visible but insensitive. */ +void +set_special_dir_menu_entry_sensitivity(ThunarWindow *window) +{ + GtkAction *action = NULL; + ThunarVfsPath *vfs_path = NULL; + gchar *path = NULL; + gboolean sensible; + + static const gchar *callback_names[]={ "open-desktop", + "open-documents", "open-downloads", "open-music", "open-pictures", + "open-public", "open-templates", "open-videos" }; + gint i; + + for (i = THUNAR_USER_DIRECTORY_DESKTOP; + i < THUNAR_USER_N_DIRECTORIES; i++) { + /* the templates menu entry is always visible */ + if (i == THUNAR_USER_DIRECTORY_TEMPLATES) + continue; + + action = gtk_action_group_get_action(window->action_group, + callback_names[i]); + +#if GLIB_CHECK_VERSION(2,14,0) + sensible = FALSE; + path = (gchar *)g_get_user_special_dir(i); + if (G_LIKELY(path != NULL)) { + vfs_path = thunar_vfs_path_new(path, NULL); + + if (G_LIKELY(vfs_path != NULL)) { + sensible = TRUE; + thunar_vfs_path_unref(vfs_path); + } + } + + gtk_action_set_sensitive(GTK_ACTION(action), sensible); +#else /* GLIB_CHECK_VERSION(2,14,0) */ + gtk_action_set_visible(GTK_ACTION(action), FALSE); +#endif /* GLIB_CHECK_VERSION(2,14,0) */ + } +} static void @@ -645,6 +710,9 @@ 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"); + /* hide the menu entries for the unexisting user directories */ + set_special_dir_menu_entry_sensitivity(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,117 +1856,237 @@ thunar_window_action_open_home (GtkActio thunar_vfs_path_unref (home_path); } +gboolean +thunar_window_open_user_folder(GtkAction *action, + ThunarWindow *window, + ThunarUserDirectory thunar_user_dir, + const gchar *default_name) +{ + ThunarFile *user_file = NULL; + GError *error = NULL; + gchar *user_dir = NULL; + gchar *error_msg = NULL; + gboolean result = FALSE; + +#if GLIB_CHECK_VERSION(2,14,0) + user_dir = g_strdup(g_get_user_special_dir(thunar_user_dir)); +#endif /* GLIB_CHECK_VERSION(2,14,0) */ + + if (G_UNLIKELY(user_dir == NULL)) + user_dir = g_strjoin(G_DIR_SEPARATOR_S, xfce_get_homedir(), + default_name, NULL); + + /* create the folder */ + xfce_mkdirhier(user_dir, 0755, &error); + + if (G_LIKELY(error == NULL)) { + user_file = thunar_file_get_for_uri(user_dir, &error); + } + if (G_LIKELY(error == NULL)) { + /* open the folder */ + thunar_window_set_current_directory(window, user_file); + /* in case of error thunar_file_get_for_uri() returns NULL */ + g_object_unref(G_OBJECT(user_file)); + result = TRUE; + } else { + error_msg = g_strconcat("Failed to open the ",default_name," folder", NULL); + thunar_dialogs_show_error(GTK_WIDGET(window), error, _(error_msg)); + g_free(error_msg); + g_error_free(error); + } + + g_free(user_dir); + return result; +} + +static void +thunar_window_action_open_desktop(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_DESKTOP,"Desktop"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ +} + +static void +thunar_window_action_open_documents(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_DOCUMENTS,"Documents"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ +} + +static void +thunar_window_action_open_downloads(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_DOWNLOAD,"Downloads"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ +} + +static void +thunar_window_action_open_music(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_MUSIC,"Music"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ +} + +static void +thunar_window_action_open_pictures(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_PICTURES,"Pictures"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ +} + +static void +thunar_window_action_open_public(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_PUBLIC_SHARE,"Public"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ +} static void thunar_window_action_open_templates (GtkAction *action, ThunarWindow *window) { - ThunarVfsPath *home_path; - ThunarVfsPath *templates_path; - ThunarFile *templates_file = NULL; GtkWidget *dialog; GtkWidget *button; GtkWidget *label; GtkWidget *image; GtkWidget *hbox; GtkWidget *vbox; - gboolean show_about_templates; - GError *error = NULL; - gchar *absolute_path; + gboolean show_about_templates; + gboolean success; _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 (); - templates_path = thunar_vfs_path_relative (home_path, "Templates"); - thunar_vfs_path_unref (home_path); - - /* make sure that the ~/Templates folder exists */ - absolute_path = thunar_vfs_path_dup_string (templates_path); - xfce_mkdirhier (absolute_path, 0755, &error); - g_free (absolute_path); - - /* determine the file for the ~/Templates path */ - if (G_LIKELY (error == NULL)) - templates_file = thunar_file_get_for_path (templates_path, &error); - - /* open the ~/Templates folder */ - if (G_LIKELY (templates_file != NULL)) - { - /* go to the ~/Templates folder */ - thunar_window_set_current_directory (window, templates_file); - g_object_unref (G_OBJECT (templates_file)); - - /* check whether we should display the "About Templates" dialog */ - g_object_get (G_OBJECT (window->preferences), "misc-show-about-templates", &show_about_templates, NULL); - if (G_UNLIKELY (show_about_templates)) - { - /* display the "About Templates" dialog */ - dialog = gtk_dialog_new_with_buttons (_("About Templates"), GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show (hbox); - - image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); - gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f); - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_widget_show (image); - - vbox = gtk_vbox_new (FALSE, 18); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - label = gtk_label_new (_("All files in this folder will appear in the \"Create Document\" menu.")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); - gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_big_bold ()); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("If you frequently create certain kinds of documents, " - "make a copy of one and put it in this folder. Thunar " - "will add an entry for this document in the \"Create " - "Document\" menu.\n\n" - "You can then select the entry from the \"Create " - "Document\" menu and a copy of the document will " - "be created in the directory you are viewing.")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - gtk_widget_show (label); - - button = gtk_check_button_new_with_mnemonic (_("Do _not display this message again")); - exo_mutual_binding_new_with_negation (G_OBJECT (window->preferences), "misc-show-about-templates", G_OBJECT (button), "active"); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); + success = thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_TEMPLATES,"Templates"); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - - /* 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 templates folder")); - g_error_free (error); - } - - /* release our reference on the ~/Templates path */ - thunar_vfs_path_unref (templates_path); + /* check whether we should display the "About Templates" dialog */ + g_object_get (G_OBJECT (window->preferences), "misc-show-about-templates", + &show_about_templates, NULL); + + if (G_UNLIKELY(show_about_templates && success)) { + /* display the "About Templates" dialog */ + dialog = gtk_dialog_new_with_buttons (_("About Templates"), + GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT + | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0); + gtk_widget_show (hbox); + + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + gtk_widget_show (image); + + vbox = gtk_vbox_new (FALSE, 18); + gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); + gtk_widget_show (vbox); + + label = gtk_label_new (_("All files in this folder will appear in the \"Create Document\" menu.")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); + gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_big_bold ()); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + label = gtk_label_new (_("If you frequently create certain kinds " + " of documents, make a copy of one and put it in this " + "folder. Thunar will add an entry for this document in the" + " \"Create Document\" menu.\n\n" + "You can then select the entry from the \"Create Document\" " + "menu and a copy of the document will be created in the " + "directory you are viewing.")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); + gtk_widget_show (label); + + button = gtk_check_button_new_with_mnemonic (_("Do _not display this message again")); + exo_mutual_binding_new_with_negation (G_OBJECT (window->preferences), "misc-show-about-templates", G_OBJECT (button), "active"); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + + +static void +thunar_window_action_open_videos(GtkAction *action, + ThunarWindow *window) +{ +#if !GLIB_CHECK_VERSION(2,14,0) + return; +#else /* !GLIB_CHECK_VERSION(2,14,0) */ + + _thunar_return_if_fail(GTK_IS_ACTION(action)); + _thunar_return_if_fail(THUNAR_IS_WINDOW(window)); + + (void)thunar_window_open_user_folder(action,window, + THUNAR_USER_DIRECTORY_VIDEOS,"Videos"); +#endif /* !GLIB_CHECK_VERSION(2,14,0) */ } - static void thunar_window_action_open_trash (GtkAction *action, ThunarWindow *window) diff -Naurp thunar.bak/thunar/thunar-window.h thunar/thunar/thunar-window.h --- thunar.bak/thunar/thunar-window.h 2008-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-window.h 2008-10-08 18:59:49.000000000 +0200 @@ -28,6 +28,32 @@ G_BEGIN_DECLS; typedef struct _ThunarWindowClass ThunarWindowClass; typedef struct _ThunarWindow ThunarWindow; +#if GLIB_CHECK_VERSION(2,14,0) +typedef GUserDirectory ThunarUserDirectory; +#define THUNAR_USER_DIRECTORY_DESKTOP G_USER_DIRECTORY_DESKTOP +#define THUNAR_USER_DIRECTORY_DOCUMENTS G_USER_DIRECTORY_DOCUMENTS +#define THUNAR_USER_DIRECTORY_DOWNLOAD G_USER_DIRECTORY_DOWNLOAD +#define THUNAR_USER_DIRECTORY_MUSIC G_USER_DIRECTORY_MUSIC +#define THUNAR_USER_DIRECTORY_PICTURES G_USER_DIRECTORY_PICTURES +#define THUNAR_USER_DIRECTORY_PUBLIC_SHARE G_USER_DIRECTORY_PUBLIC_SHARE +#define THUNAR_USER_DIRECTORY_TEMPLATES G_USER_DIRECTORY_TEMPLATES +#define THUNAR_USER_DIRECTORY_VIDEOS G_USER_DIRECTORY_VIDEOS +#define THUNAR_USER_N_DIRECTORIES G_USER_N_DIRECTORIES +#else /* GLIB_CHECK_VERSION(2,14,0) */ +typedef enum +{ + THUNAR_USER_DIRECTORY_DESKTOP, + THUNAR_USER_DIRECTORY_DOCUMENTS, + THUNAR_USER_DIRECTORY_DOWNLOAD, + THUNAR_USER_DIRECTORY_MUSIC, + THUNAR_USER_DIRECTORY_PICTURES, + THUNAR_USER_DIRECTORY_PUBLIC_SHARE, + THUNAR_USER_DIRECTORY_TEMPLATES, + THUNAR_USER_DIRECTORY_VIDEOS, + THUNAR_USER_N_DIRECTORIES +} ThunarUserDirectory; +#endif /*GLIB_CHECK_VERSION(2,14,0) */ + #define THUNAR_TYPE_WINDOW (thunar_window_get_type ()) #define THUNAR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_WINDOW, ThunarWindow)) #define THUNAR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TYPE_WINDOW, ThunarWindowClass)) diff -Naurp thunar.bak/thunar/thunar-window-ui.xml thunar/thunar/thunar-window-ui.xml --- thunar.bak/thunar/thunar-window-ui.xml 2008-10-08 06:31:41.000000000 +0200 +++ thunar/thunar/thunar-window-ui.xml 2008-10-08 18:59:49.000000000 +0200 @@ -74,7 +74,15 @@ + + + + + + + +