> * I think you should also use the environment variable in
> shortcuts_append_documents()
Of course, silly me. Done.
> * I don't remember where Documents is placed in the Places menu of the
> panel, but I think it should be at the same place. If it's the first
> item, then great. Else, you'll need to change the position in your
> patch.
Done.
> * "const gchar* envvar;" => const gchar *envvar;
Done.
> Overall, the patch looks okay.
>
> A next step would be to patch gnome-panel to make it use the environment
> variable too (note that the Documents item is added by an Ubuntu patch),
> and also to patch nautilus to have this Documents item where needed (in
> the shortcuts sidebar, eg).
Well, your remarks have made me see some other things that needs to be
done for this patch to be complete:
* The Desktop entry in the left pane is localized, but it is not
localized in the pathbar at the top. Though they have the same icon,
we lack consistency here.
* The "home" entry uses the user name in the filechooser, but uses
"Personal folder" in the gnome-panel menu, so the same remark is also
true here. However, I'm wondering if it is a good idea to use
"Personal folder" in the pathbar, since it is quite long. Sebastien,
Vincent, any thoughts on this ?
* The Documents entry should definitely have it's own icon too (in the
shortcuts pane as well as in the pathbar) and be named "Documents" in
the pathbar for consistency as well. However, for the first of those
two problems, I'd need an artist, because believe me, you don't want
me to draw an icon.
So the big question is: should I use my time trying to solve all these
issues, or do we not care ?
Anyway, just in case Sebastien wants the patch in its current state (I
guess localization of the pathbar would be a different patch anyway),
I'm attaching it.
Thanks for your help,
--
Alain Perry
--- gtk+-2.8.9.orig/gtk/gtkfilechooserdefault.c 2005-12-06 04:11:51.000000000 +0100
+++ gtk+-2.8.9/gtk/gtkfilechooserdefault.c 2005-12-29 12:50:59.000000000 +0100
@@ -222,6 +222,7 @@
GtkTooltips *tooltips;
+ gboolean has_documents;
gboolean has_home;
gboolean has_desktop;
@@ -344,6 +345,7 @@
/* Interesting places in the shortcuts bar */
typedef enum {
SHORTCUTS_HOME,
+ SHORTCUTS_DOCUMENTS,
SHORTCUTS_DESKTOP,
SHORTCUTS_VOLUMES,
SHORTCUTS_SHORTCUTS,
@@ -1476,6 +1478,51 @@
profile_end ("end", NULL);
}
+/* Appends the ~/Documents directory to the shortcuts model */
+static void
+shortcuts_append_documents (GtkFileChooserDefault *impl)
+{
+ gchar *name;
+ const gchar *home;
+ const gchar *envvar;
+ GtkFilePath *path;
+
+ profile_start ("start", NULL);
+
+ envvar = g_getenv ("GTK_DEFAULT_FILECHOOSER_DIR");
+ if (envvar && g_file_test (envvar, G_FILE_TEST_IS_DIR))
+ {
+ name = g_strdup (envvar);
+ }
+ else
+ {
+#ifdef G_OS_WIN32
+ name = _gtk_file_system_win32_get_documents ();
+#else
+ home = g_get_home_dir ();
+ if (home == NULL)
+ {
+ profile_end ("end - no home directory!?", NULL);
+ return;
+ }
+
+ name = g_build_filename (home, "Documents", NULL);
+#endif
+ }
+
+ path = gtk_file_system_filename_to_path (impl->file_system, name);
+ g_free (name);
+
+ impl->has_documents = shortcuts_insert_path (impl, -1, FALSE, NULL, path, _("Documents"), FALSE, NULL);
+ /* We do not actually pop up an error dialog if there is no documents directory
+ * because some people may really not want to have one.
+ */
+
+ gtk_file_path_free (path);
+
+ profile_end ("end", NULL);
+}
+
/* Appends a list of GtkFilePath to the shortcuts model; returns how many were inserted */
static int
shortcuts_append_paths (GtkFileChooserDefault *impl,
@@ -1532,6 +1579,11 @@
n += impl->has_home ? 1 : 0;
+ if (where == SHORTCUTS_DOCUMENTS)
+ goto out;
+
+ n += impl->has_documents ? 1 : 0;
+
if (where == SHORTCUTS_DESKTOP)
goto out;
@@ -1876,6 +1928,7 @@
if (impl->file_system)
{
shortcuts_append_home (impl);
+ shortcuts_append_documents (impl);
shortcuts_append_desktop (impl);
shortcuts_add_volumes (impl);
}
@@ -4773,7 +4826,9 @@
gtk_file_chooser_default_map (GtkWidget *widget)
{
GtkFileChooserDefault *impl;
- char *current_working_dir;
+ const gchar *envvar;
+ gchar *default_dir;
+ const gchar *home;
profile_start ("start", NULL);
@@ -4784,10 +4839,24 @@
switch (impl->reload_state)
{
case RELOAD_EMPTY:
- /* The user didn't explicitly give us a folder to display, so we'll use the cwd */
- current_working_dir = g_get_current_dir ();
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), current_working_dir);
- g_free (current_working_dir);
+ /* The user didn't explicitly give us a folder to display, so we'll use
+ * GTK_DEFAULT_FILECHOOSER_DIR, or ~/Documents, or the cwd */
+ envvar = g_getenv ("GTK_DEFAULT_FILECHOOSER_DIR");
+ if (envvar && g_file_test (envvar, G_FILE_TEST_IS_DIR))
+ {
+ default_dir = g_strdup (envvar);
+ }
+ else if (impl->has_documents)
+ {
+ home = g_get_home_dir ();
+ default_dir = g_build_filename (home, "Documents", NULL);
+ }
+ else
+ {
+ default_dir = g_get_current_dir ();
+ }
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), default_dir);
+ g_free (default_dir);
break;
case RELOAD_HAS_FOLDER:
@@ -5443,16 +5512,31 @@
if (impl->reload_state == RELOAD_EMPTY)
{
- char *current_working_dir;
+ const gchar *envvar;
+ gchar *default_dir;
+ const gchar *home;
GtkFilePath *path;
- /* We are unmapped, or we had an error while loading the last folder. We'll return
- * the $cwd since once we get (re)mapped, we'll load $cwd anyway unless the caller
- * explicitly calls set_current_folder() on us.
+ /* We are unmapped, or we had an error while loading the last folder. We'll do the
+ * same as in the map method, since that's what will happen when we get (re)mapped,
+ * unless the caller explicitly calls set_current_folder() on us.
*/
- current_working_dir = g_get_current_dir ();
- path = gtk_file_system_filename_to_path (impl->file_system, current_working_dir);
- g_free (current_working_dir);
+ envvar = g_getenv ("GTK_DEFAULT_FILECHOOSER_DIR");
+ if (envvar && g_file_test (envvar, G_FILE_TEST_IS_DIR))
+ {
+ default_dir = g_strdup (envvar);
+ }
+ if (!default_dir && impl->has_documents)
+ {
+ home = g_get_home_dir ();
+ default_dir = g_build_filename (home, "Documents", NULL);
+ }
+ else if (!default_dir)
+ {
+ default_dir = g_get_current_dir ();
+ }
+ path = gtk_file_system_filename_to_path (impl->file_system, default_dir);
+ g_free (default_dir);
return path;
}
--- gtk+-2.8.9.orig/gtk/gtkfilesystemwin32.c 2005-11-12 02:15:22.000000000 +0100
+++ gtk+-2.8.9/gtk/gtkfilesystemwin32.c 2005-12-29 12:39:54.000000000 +0100
@@ -361,6 +361,12 @@
return get_special_folder (CSIDL_DESKTOPDIRECTORY);
}
+gchar *
+_gtk_file_system_win32_get_documents (void)
+{
+ return get_special_folder (CSIDL_PERSONAL);
+}
+
static GSList *
gtk_file_system_win32_list_volumes (GtkFileSystem *file_system)
{
--
ubuntu-desktop mailing list
[email protected]
http://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop