Commit 09f461b0 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Make remote bookmarks work better (#354887)

2006-09-22  Matthias Clasen  <mclasen@redhat.com>

	Make remote bookmarks work better (#354887)

	* gtk/gtkfilechooserdefault.c (shortcuts_reload_icons):
	(shortcuts_insert_path):
	* gtk/gtkfilechooserbutton.c (change_icon_theme):
	(model_add_bookmarks):
	(model_update_current_folder):
	(update_label_and_image):
	If the bookmark points to a remote file, don't call get_info(),
	since that may a) take a long time and b) pop up an auth dialog.
	Instead, just use a folder icon and create a display name
	from the uri.

	* gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_uri):
	New function to create a suitable display name for a remote
	uri. This should really be done in GtkFileSystem.
parent 2f50232a
2006-09-22 Matthias Clasen <mclasen@redhat.com>
Make remote bookmarks work better (#354887)
* gtk/gtkfilechooserdefault.c (shortcuts_reload_icons):
(shortcuts_insert_path):
* gtk/gtkfilechooserbutton.c (change_icon_theme):
(model_add_bookmarks):
(model_update_current_folder):
(update_label_and_image):
If the bookmark points to a remote file, don't call get_info(),
since that may a) take a long time and b) pop up an auth dialog.
Instead, just use a folder icon and create a display name
from the uri.
* gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_uri):
New function to create a suitable display name for a remote
uri. This should really be done in GtkFileSystem.
2006-09-21 Michael Natterer <mitch@imendio.com>
Implement lots of value setters for GdkGC, based on a heavily
......
......@@ -1290,23 +1290,34 @@ change_icon_theme (GtkFileChooserButton *button)
case ROW_TYPE_CURRENT_FOLDER:
if (data)
{
GtkTreePath *path;
GtkFileSystemHandle *handle;
struct ChangeIconThemeData *info;
info = g_new0 (struct ChangeIconThemeData, 1);
info->button = g_object_ref (button);
path = gtk_tree_model_get_path (priv->model, &iter);
info->row_ref = gtk_tree_row_reference_new (priv->model, path);
gtk_tree_path_free (path);
handle =
gtk_file_system_get_info (priv->fs, data, GTK_FILE_INFO_ICON,
change_icon_theme_get_info_cb,
info);
button->priv->change_icon_theme_handles =
g_slist_append (button->priv->change_icon_theme_handles, handle);
pixbuf = NULL;
if (gtk_file_system_path_is_local (priv->fs, (GtkFilePath *)data))
{
GtkTreePath *path;
GtkFileSystemHandle *handle;
struct ChangeIconThemeData *info;
info = g_new0 (struct ChangeIconThemeData, 1);
info->button = g_object_ref (button);
path = gtk_tree_model_get_path (priv->model, &iter);
info->row_ref = gtk_tree_row_reference_new (priv->model, path);
gtk_tree_path_free (path);
handle =
gtk_file_system_get_info (priv->fs, data, GTK_FILE_INFO_ICON,
change_icon_theme_get_info_cb,
info);
button->priv->change_icon_theme_handles =
g_slist_append (button->priv->change_icon_theme_handles, handle);
pixbuf = NULL;
}
else
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
pixbuf = gtk_icon_theme_load_icon (theme, "gnome-fs-regular",
priv->icon_size, 0, NULL);
}
else
pixbuf = gtk_icon_theme_load_icon (theme, FALLBACK_ICON_NAME,
......@@ -1465,7 +1476,6 @@ set_info_for_path_at_iter (GtkFileChooserButton *button,
data = g_new0 (struct SetDisplayNameData, 1);
data->button = g_object_ref (button);
data->label = gtk_file_system_get_bookmark_label (button->priv->fs, path);
tree_path = gtk_tree_model_get_path (button->priv->model, iter);
......@@ -1793,6 +1803,8 @@ model_add_volumes (GtkFileChooserButton *button,
}
}
extern gchar * _gtk_file_chooser_label_for_uri (const gchar *uri);
static void
model_add_bookmarks (GtkFileChooserButton *button,
GSList *bookmarks)
......@@ -1816,19 +1828,58 @@ model_add_bookmarks (GtkFileChooserButton *button,
path = l->data;
if (local_only &&
!gtk_file_system_path_is_local (button->priv->fs, path))
continue;
if (gtk_file_system_path_is_local (button->priv->fs, path))
{
gtk_list_store_insert (store, &iter, pos);
gtk_list_store_set (store, &iter,
ICON_COLUMN, NULL,
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
DATA_COLUMN, gtk_file_path_copy (path),
IS_FOLDER_COLUMN, FALSE,
-1);
set_info_for_path_at_iter (button, path, &iter);
}
else
{
gchar *label;
GtkIconTheme *icon_theme;
GdkPixbuf *pixbuf;
if (local_only)
continue;
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
label = gtk_file_system_get_bookmark_label (button->priv->fs, path);
if (!label)
{
gchar *uri;
gtk_list_store_insert (store, &iter, pos);
gtk_list_store_set (store, &iter,
ICON_COLUMN, NULL,
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
DATA_COLUMN, gtk_file_path_copy (path),
IS_FOLDER_COLUMN, FALSE,
-1);
set_info_for_path_at_iter (button, path, &iter);
uri = gtk_file_system_path_to_uri (button->priv->fs, path);
label = _gtk_file_chooser_label_for_uri (uri);
g_free (uri);
}
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
pixbuf = gtk_icon_theme_load_icon (icon_theme, "gnome-fs-directory",
button->priv->icon_size, 0, NULL);
gtk_list_store_insert (store, &iter, pos);
gtk_list_store_set (store, &iter,
ICON_COLUMN, pixbuf,
DISPLAY_NAME_COLUMN, label,
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
DATA_COLUMN, gtk_file_path_copy (path),
IS_FOLDER_COLUMN, TRUE,
-1);
g_free (label);
g_object_unref (pixbuf);
}
button->priv->n_bookmarks++;
pos++;
......@@ -1890,14 +1941,53 @@ model_update_current_folder (GtkFileChooserButton *button,
model_free_row_data (button, &iter);
}
gtk_list_store_set (store, &iter,
ICON_COLUMN, NULL,
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
DATA_COLUMN, gtk_file_path_copy (path),
IS_FOLDER_COLUMN, FALSE,
-1);
set_info_for_path_at_iter (button, path, &iter);
if (gtk_file_system_path_is_local (button->priv->fs, path))
{
gtk_list_store_set (store, &iter,
ICON_COLUMN, NULL,
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
DATA_COLUMN, gtk_file_path_copy (path),
IS_FOLDER_COLUMN, FALSE,
-1);
set_info_for_path_at_iter (button, path, &iter);
}
else
{
gchar *label;
GtkIconTheme *icon_theme;
GdkPixbuf *pixbuf;
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
label = gtk_file_system_get_bookmark_label (button->priv->fs, path);
if (!label)
{
gchar *uri;
uri = gtk_file_system_path_to_uri (button->priv->fs, path);
label = _gtk_file_chooser_label_for_uri (uri);
g_free (uri);
}
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
pixbuf = gtk_icon_theme_load_icon (icon_theme, "gnome-fs-directory",
button->priv->icon_size, 0, NULL);
gtk_list_store_set (store, &iter,
ICON_COLUMN, pixbuf,
DISPLAY_NAME_COLUMN, label,
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
DATA_COLUMN, gtk_file_path_copy (path),
IS_FOLDER_COLUMN, TRUE,
-1);
g_free (label);
g_object_unref (pixbuf);
}
}
static inline void
......@@ -2009,6 +2099,7 @@ filter_model_visible_func (GtkTreeModel *model,
break;
case ROW_TYPE_VOLUME:
{
retval = TRUE;
if (local_only)
{
if (gtk_file_system_volume_get_is_mounted (priv->fs, data))
......@@ -2244,13 +2335,34 @@ update_label_and_image (GtkFileChooserButton *button)
}
if (priv->update_button_handle)
gtk_file_system_cancel_operation (priv->update_button_handle);
priv->update_button_handle =
gtk_file_system_get_info (priv->fs, path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
update_label_get_info_cb,
g_object_ref (button));
{
gtk_file_system_cancel_operation (priv->update_button_handle);
priv->upate_button_handle = NULL;
}
if (gtk_file_system_path_is_local (priv->fs, path))
{
priv->update_button_handle =
gtk_file_system_get_info (priv->fs, path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
update_label_get_info_cb,
g_object_ref (button));
}
else
{
GdkPixbuf *pixbuf;
label_text = gtk_file_system_get_bookmark_label (button->priv->fs, path);
pixbuf = gtk_icon_theme_load_icon (get_icon_theme (GTK_WIDGET (priv->image)),
"gnome-fs-regular",
priv->icon_size, 0, NULL);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
}
}
out:
gtk_file_paths_free (paths);
......
......@@ -1177,7 +1177,7 @@ shortcuts_reload_icons (GtkFileChooserDefault *impl)
if (pixbuf)
g_object_unref (pixbuf);
}
else
else if (gtk_file_system_path_is_local (impl->file_system, (GtkFilePath *)data))
{
const GtkFilePath *path;
struct ReloadIconsData *info;
......@@ -1198,6 +1198,26 @@ shortcuts_reload_icons (GtkFileChooserDefault *impl)
info);
impl->reload_icon_handles = g_slist_append (impl->reload_icon_handles, handle);
}
else
{
GtkIconTheme *icon_theme;
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
pixbuf = gtk_icon_theme_load_icon (icon_theme, "gnome-fs-directory",
impl->icon_size, 0, NULL);
gtk_list_store_set (impl->shortcuts_model, &iter,
SHORTCUTS_COL_PIXBUF, pixbuf,
-1);
if (pixbuf)
g_object_unref (pixbuf);
}
}
}
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model),&iter));
......@@ -1430,6 +1450,54 @@ out:
g_object_unref (handle);
}
/* FIXME: GtkFileSystem needs a function to split a remote path
* into hostname and path components, or maybe just have a
* gtk_file_system_path_get_display_name().
*
* This function is also used in gtkfilechooserbutton.c
*/
gchar *
_gtk_file_chooser_label_for_uri (const gchar *uri)
{
const gchar *path, *start, *end, *p;
gchar *host, *label;
start = strstr (uri, "://");
start += 3;
path = strchr (start, '/');
if (path)
end = path;
else
{
end = uri + strlen (uri);
path = "/";
}
/* strip username */
p = strchr (start, '@');
if (p && p < end)
{
start = p + 1;
}
p = strchr (start, ':');
if (p && p < end)
end = p;
host = g_strndup (start, end - start);
/* Translators: the first string is a path and the second string
* is a hostname. Nautilus and the panel contain the same string
* to translate.
*/
label = g_strdup_printf (_("%1$s on %2$s"), path, host);
g_free (host);
return label;
}
/* Inserts a path in the shortcuts tree, making a copy of it; alternatively,
* inserts a volume. A position of -1 indicates the end of the tree.
*/
......@@ -1447,6 +1515,7 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
GdkPixbuf *pixbuf = NULL;
gpointer data = NULL;
GtkTreeIter iter;
GtkIconTheme *icon_theme;
profile_start ("start", is_volume ? "volume" : (char *) path);
......@@ -1457,7 +1526,7 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
impl->icon_size, NULL);
}
else
else if (gtk_file_system_path_is_local (impl->file_system, path))
{
struct ShortcutsInsertRequest *request;
GtkFileSystemHandle *handle;
......@@ -1496,9 +1565,32 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
return;
}
else
{
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
*/
data = gtk_file_path_copy (path);
if (label)
label_copy = g_strdup (label);
else
{
gchar *uri;
uri = gtk_file_system_path_to_uri (impl->file_system, path);
label_copy = _gtk_file_chooser_label_for_uri (uri);
if (!data)
data = gtk_file_path_copy (path);
g_free (uri);
}
/* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
pixbuf = gtk_icon_theme_load_icon (icon_theme, "gnome-fs-directory",
impl->icon_size, 0, NULL);
}
if (pos == -1)
gtk_list_store_append (impl->shortcuts_model, &iter);
......@@ -1711,6 +1803,7 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
profile_start ("start", NULL);
old_changing_folders = impl->changing_folder;
impl->changing_folder = TRUE;
......@@ -1797,7 +1890,6 @@ shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
profile_start ("start", NULL);
old_changing_folders = impl->changing_folder;
impl->changing_folder = TRUE;
......
2006-09-22 Matthias Clasen <mclasen@redhat.com>
* *.po: Copy existing translations for a new string
from the panel.
2006-09-21 Priit Laes <plaes@cvs.gnome.org>
* et.po: Translation updated by Ivar Smolin.
......
......@@ -4534,3 +4534,6 @@ msgstr ""
#~ msgid "Zoom to _Fit"
#~ msgstr "Маштаб най_лепшы"
msgid "%1$s on %2$s"
msgstr "%1$s на вузьле %2$s"
......@@ -4216,3 +4216,6 @@ msgstr ""
#~ msgid "PNM image format is invalid"
#~ msgstr "Невалиден формат на изображение тип PNM"
msgid "%1$s on %2$s"
msgstr "%1$s на %2$s"
......@@ -4169,3 +4169,6 @@ msgid ""
msgstr ""
"'%s''এ কোনো থিম ইন্ডেক্স ফাইল উপস্থিত নেই।\n"
"এই স্থানে আইকন ক্যাশে নির্মাণের জন্য --ignore-theme-index ব্যবহার করুন।\n"
msgid "%1$s on %2$s"
msgstr "%1$s, %2$s'র উপর"
......@@ -4291,3 +4291,6 @@ msgid ""
msgstr ""
"'%s''এ কোনো থিম ইন্ডেক্স ফাইল উপস্থিত নেই।\n"
"এই স্থানে আইকন ক্যাশে নির্মাণের জন্য --ignore-theme-index ব্যবহার করুন।\n"
msgid "%1$s on %2$s"
msgstr "%1$s, %2$s'র উপর"
......@@ -4456,3 +4456,6 @@ msgstr ""
#~ msgid "Gravity"
#~ msgstr "Dedennerezh"
msgid "%1$s on %2$s"
msgstr "%1$s war %2$s"
......@@ -4343,3 +4343,6 @@ msgstr ""
#~ msgid "_Up"
#~ msgstr "A _dalt"
msgid "%1$s on %2$s"
msgstr "%1$s a %2$s"
......@@ -4341,3 +4341,6 @@ msgid ""
"No theme index file in '%s'.\n"
"If you really want to create an icon cache here, use --ignore-theme-index.\n"
msgstr ""
msgid "%1$s on %2$s"
msgstr "%1$s na %2$s"
......@@ -5549,3 +5549,6 @@ msgstr ""
#~ msgid "Text to render"
#~ msgstr "Y testun i'w lunio"
msgid "%1$s on %2$s"
msgstr "%1$s ar %2$s"
......@@ -4579,3 +4579,6 @@ msgstr ""
#~ msgid "Zoom to _Fit"
#~ msgstr "Zoom _tilpasset"
msgid "%1$s on %2$s"
msgstr "%1$s på %2$s"
......@@ -4825,3 +4825,6 @@ msgstr ""
#~ msgid "Folder"
#~ msgstr "Ordner"
msgid "%1$s on %2$s"
msgstr "%1$s, %2$s"
......@@ -4854,3 +4854,6 @@ msgstr ""
#~ msgid "_Up"
#~ msgstr "ཡར།(_U)"
msgid "%1$s on %2$s"
msgstr "%1$s, %2$s གུ"
......@@ -4232,3 +4232,6 @@ msgstr ""
#~ msgid "PNM image format is invalid"
#~ msgstr "Μη έγκυρος τύπος εικόνας PNM"
msgid "%1$s on %2$s"
msgstr "%1$s σε %2$s"
......@@ -4451,3 +4451,6 @@ msgstr ""
#~ msgid "Pixmap path element: \"%s\" must be absolute, %s, line %d"
#~ msgstr "Pixmap path element: \"%s\" must be absolute, %s, line %d"
msgid "%1$s on %2$s"
msgstr "%1$s on %2$s"
......@@ -4275,3 +4275,6 @@ msgstr ""
#~ msgid "_Up"
#~ msgstr "_Up"
msgid "%1$s on %2$s"
msgstr "%1$s on %2$s"
......@@ -4227,3 +4227,6 @@ msgstr ""
"No hay archivo de índice del tema en «%s».\n"
"Si realmente quiere crear un caché de iconos aquí, use --ignore-theme-"
"index.\n"
msgid "%1$s on %2$s"
msgstr "%1$s en %2$s"
......@@ -4168,3 +4168,6 @@ msgid ""
"No theme index file in '%s'.\n"
"If you really want to create an icon cache here, use --ignore-theme-index.\n"
msgstr ""
msgid "%1$s on %2$s"
msgstr "%2$s hostil %1$s"
......@@ -4322,3 +4322,6 @@ msgid ""
msgstr ""
"Ez dago gaiaren indize fitxategirik '%s'(e)n.\n"
"Ikono-cache bat sortzea nahi baduzu erabili --ignore-theme-index.\n"
msgid "%1$s on %2$s"
msgstr "%1$s, %2$s"
......@@ -4766,3 +4766,6 @@ msgstr ""
#~ msgid "Pixmap path element: \"%s\" must be absolute, %s, line %d"
#~ msgstr "Kuvan polku \"%s\" ei voi olla suhteellinen, %s, rivi %d"
msgid "%1$s on %2$s"
msgstr "%1$s - %2$s"
......@@ -4236,3 +4236,6 @@ msgstr ""
"Aucun fichier d'index de thème dans « %s ».\n"
"Si vous souhaitez vraiment créer un cache d'icône ici, utilisez --ignore-"
"theme-index.\n"
msgid "%1$s on %2$s"
msgstr "%1$s sur %2$s"
......@@ -4881,3 +4881,6 @@ msgstr ""
#~ msgid "shortcut %s already exists"
#~ msgstr "o atallo %s xa existe"
msgid "%1$s on %2$s"
msgstr "%1$s en %2$s"
......@@ -4576,3 +4576,6 @@ msgid ""
msgstr ""
"'%s' માં કોઈ થીમ અનુક્રમ ફાઈલ નથી.\n"
"જો તમે ખરેખર ચિહ્ન કેશ અંહિ બનાવવા માંગો, તો --ignore-theme-index વાપરો.\n"
msgid "%1$s on %2$s"
msgstr "%1$s, %2$s પર"
......@@ -4746,3 +4746,6 @@ msgstr ""
#~ msgid "Unsupported TIFF variant"
#~ msgstr "סוג TIFF לא נתמך"
msgid "%1$s on %2$s"
msgstr "‏%1$s ב-%2$s"
......@@ -4335,3 +4335,6 @@ msgid ""
"No theme index file in '%s'.\n"
"If you really want to create an icon cache here, use --ignore-theme-index.\n"
msgstr ""
msgid "%1$s on %2$s"
msgstr "%1$s %2$s पर"
......@@ -4184,3 +4184,6 @@ msgid ""
msgstr "Nem található témaindexfájl a következőben: \"%s\".\n"
"HA valóban ikongyorsítótárat kíván itt létrehozni, akkor használja a --ignore-theme-index kapcsolót.\n"
msgid "%1$s on %2$s"
msgstr "%1$s ezen: %2$s"
......@@ -4276,3 +4276,6 @@ msgstr ""
#~ msgid "Home"
#~ msgstr "Rumah"
msgid "%1$s on %2$s"
msgstr "%1$s pada %2$s"
......@@ -4521,3 +4521,6 @@ msgstr ""
#, fuzzy
#~ msgid "shortcut %s already exists"
#~ msgstr "La scorciatoia %s non esiste"
msgid "%1$s on %2$s"
msgstr "%1$s su %2$s"
......@@ -4850,3 +4850,6 @@ msgstr ""
#~ msgid "This function is not implemented for widgets of class '%s'."
#~ msgstr "この関数は '%s' クラスのウィジットでは実装されていません"