Updating branch refs/heads/nick/new-shortcuts-pane-model to 22b7a8f9c59a4e493d5bae711738cd224db636ed (commit) from e8c56637127d5e42ff9ba32555b0ca2fbeaaeddd (commit)
commit 22b7a8f9c59a4e493d5bae711738cd224db636ed Author: Nick Schermer <n...@xfce.org> Date: Sat Oct 6 12:19:29 2012 +0200 Drop the default bookmark crap. thunar/thunar-private.h | 3 - thunar/thunar-shortcuts-model.c | 113 --------------------------------------- thunar/thunar-window.c | 42 +++++++++++++- 3 files changed, 39 insertions(+), 119 deletions(-) diff --git a/thunar/thunar-private.h b/thunar/thunar-private.h index a6f8f7b..b6c58e2 100644 --- a/thunar/thunar-private.h +++ b/thunar/thunar-private.h @@ -88,9 +88,6 @@ typedef GUserDirectory ThunarUserDirectory; #define THUNAR_USER_DIRECTORY_VIDEOS G_USER_DIRECTORY_VIDEOS #define THUNAR_USER_N_DIRECTORIES (8) -gchar *_thunar_get_xdg_user_dirs_locale (void); -extern const gchar *_thunar_user_directory_names[THUNAR_USER_N_DIRECTORIES+1]; - G_END_DECLS; #endif /* !__THUNAR_PRIVATE_H__ */ diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c index 700a17e..dbbfd3f 100644 --- a/thunar/thunar-shortcuts-model.c +++ b/thunar/thunar-shortcuts-model.c @@ -47,13 +47,6 @@ #define THUNAR_SHORTCUT(obj) ((ThunarShortcut *) (obj)) -/* I don't particularly like this here, but it's shared across a few - * files. */ -const gchar *_thunar_user_directory_names[9] = { - "Desktop", "Documents", "Download", "Music", "Pictures", "Public", - "Templates", "Videos", NULL, -}; - typedef struct _ThunarShortcut ThunarShortcut; @@ -924,40 +917,12 @@ thunar_shortcuts_model_remove_shortcut (ThunarShortcutsModel *model, } } -/* Reads the current xdg user dirs locale from ~/.config/xdg-user-dirs.locale - * Notice that the result shall be freed by using g_free (). */ -gchar * -_thunar_get_xdg_user_dirs_locale (void) -{ - gchar *file = NULL; - gchar *content = NULL; - gchar *locale = NULL; - - /* get the file pathname */ - file = g_build_filename (g_get_user_config_dir (), LOCALE_FILE_NAME, NULL); - - /* grab the contents and get ride of the surrounding spaces */ - if (g_file_get_contents (file, &content, NULL, NULL)) - locale = g_strdup (g_strstrip (content)); - g_free (content); - g_free (file); - - /* if we got nothing, let's set the default locale as C */ - if (exo_str_is_equal (locale, "")) - { - g_free (locale); - locale = g_strdup ("C"); - } - - return locale; -} static void thunar_shortcuts_model_load (ThunarShortcutsModel *model) { ThunarShortcut *shortcut; - const gchar *user_special_dir = NULL; ThunarFile *file; GFile *file_path; GFile *home; @@ -965,7 +930,6 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model) gchar line[2048]; gchar *name; FILE *fp; - gint i; gint sort_id; home = thunar_g_file_new_for_home (); @@ -1045,83 +1009,6 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model) /* clean up */ fclose (fp); } - else - { - /* ~/.gtk-bookmarks wasn't there or it was unreadable. - * here we recreate it with some useful xdg user special dirs */ - gchar *old_locale = NULL; - gchar *locale = NULL; - - bindtextdomain (XDG_USER_DIRS_PACKAGE, PACKAGE_LOCALE_DIR); -#ifdef HAVE_BIND_TEXTDOMAIN_CODESET - bind_textdomain_codeset (XDG_USER_DIRS_PACKAGE, "UTF-8"); -#endif /* HAVE_BIND_TEXTDOMAIN_CODESET */ - - /* save the old locale */ - old_locale = g_strdup(setlocale (LC_MESSAGES, NULL)); - - /* set the new locale */ - locale = _thunar_get_xdg_user_dirs_locale (); - setlocale (LC_MESSAGES, locale); - g_free (locale); - - for (i = G_USER_DIRECTORY_DESKTOP; - i < G_USER_N_DIRECTORIES && _thunar_user_directory_names[i] != NULL; - ++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 = g_get_user_special_dir (i); - - if (G_UNLIKELY (user_special_dir == NULL)) - continue; - - file_path = g_file_new_for_path (user_special_dir); - if (G_UNLIKELY (g_file_equal (file_path, home))) - { - g_object_unref (file_path); - continue; - } - - /* try to open the file corresponding to the uri */ - file = thunar_file_get (file_path, NULL); - g_object_unref (file_path); - - /* TODO invisible item? */ - 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 (file); - continue; - } - - /* create the shortcut entry */ - shortcut = g_slice_new0 (ThunarShortcut); - shortcut->group = THUNAR_SHORTCUT_GROUP_BOOKMARKS; - shortcut->file = file; - shortcut->name = g_strdup (dgettext (XDG_USER_DIRS_PACKAGE, - (gchar *) _thunar_user_directory_names[i])); - - /* append the shortcut to the list */ - thunar_shortcuts_model_add_shortcut (model, shortcut); - } - - /* restore the old locale */ - setlocale (LC_MESSAGES, old_locale); - g_free(old_locale); - - /* we try to save the obtained new model */ - thunar_shortcuts_model_save (model); - } /* clean up */ g_object_unref (home); diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index e5b80b3..b4acb6c 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -347,6 +347,13 @@ static const GtkToggleActionEntry toggle_action_entries[] = +static const gchar *thunar_user_directory_names[9] = { + "Desktop", "Documents", "Download", "Music", "Pictures", "Public", + "Templates", "Videos", NULL, +}; + + + static guint window_signals[LAST_SIGNAL]; @@ -617,6 +624,35 @@ view_index2type (gint idx) } } +/* Reads the current xdg user dirs locale from ~/.config/xdg-user-dirs.locale + * Notice that the result shall be freed by using g_free (). */ +static gchar * +thunar_get_xdg_user_dirs_locale (void) +{ + gchar *file = NULL; + gchar *content = NULL; + gchar *locale = NULL; + + /* get the file pathname */ + file = g_build_filename (g_get_user_config_dir (), LOCALE_FILE_NAME, NULL); + + /* grab the contents and get ride of the surrounding spaces */ + if (g_file_get_contents (file, &content, NULL, NULL)) + locale = g_strdup (g_strstrip (content)); + + g_free (content); + g_free (file); + + /* if we got nothing, let's set the default locale as C */ + if (exo_str_is_equal (locale, "")) + { + g_free (locale); + locale = g_strdup ("C"); + } + + return locale; +} + /* this function hides all the user directory menu entries in case of * glib <= 2.12. Otherwise it hide the menu entries only for the directories * that point to $HOME or to NULL. Then, it translates the labels. */ @@ -652,7 +688,7 @@ thunar_window_setup_user_dir_menu_entries (ThunarWindow *window) old_locale = g_strdup(setlocale (LC_MESSAGES, NULL)); /* set the new locale */ - locale = _thunar_get_xdg_user_dirs_locale (); + locale = thunar_get_xdg_user_dirs_locale (); setlocale (LC_MESSAGES, locale); g_free (locale); @@ -665,7 +701,7 @@ thunar_window_setup_user_dir_menu_entries (ThunarWindow *window) /* special case: got NULL for the templates dir. Force it to ~/Templates */ if (G_UNLIKELY (path == NULL && i == G_USER_DIRECTORY_TEMPLATES)) - dir = g_file_resolve_relative_path (home_dir, _thunar_user_directory_names[i]); + dir = g_file_resolve_relative_path (home_dir, thunar_user_directory_names[i]); else if (path != NULL) dir = g_file_new_for_path (path); else @@ -675,7 +711,7 @@ thunar_window_setup_user_dir_menu_entries (ThunarWindow *window) if (G_LIKELY (path != NULL && !g_file_equal (dir, home_dir))) { /* menu entry label translation */ - translation = dgettext (XDG_USER_DIRS_PACKAGE, (gchar *) _thunar_user_directory_names[i]); + translation = dgettext (XDG_USER_DIRS_PACKAGE, (gchar *) thunar_user_directory_names[i]); g_object_set (action, "label", translation, NULL); } else _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits