Commit 9a3651e4 authored by Paolo Maggi's avatar Paolo Maggi Committed by Paolo Maggi

Fixes bug #338173 - Gedit show keyring store password on the window title

2006-04-20  Paolo Maggi  <paolo@gnome.org>

	Fixes bug #338173 - Gedit show keyring store password on the window
	title bar

	* gedit/gedit-utils.[ch] (gedit_utils_format_uri_for_display): new
	function similar to gnome_vfs_format_uri_for_display but that hides
	the password if needed

	* gedit/gedit-commands-file.c (load_file_list)
	(replace_read_only_file) (save_dialog_response_cb): use
	gedit_utils_format_uri_for_display instead of
	gnome_vfs_format_uri_for_display

	* gedit/gedit-io-error-message-area.c
	(gedit_unrecoverable_loading_error_message_area_new)
	(gedit_unrecoverable_reverting_error_message_area_new)
	(gedit_conversion_error_while_loading_message_area_new)
	(gedit_conversion_error_while_saving_message_area_new)
	(gedit_file_already_open_warning_message_area_new)
	(gedit_externally_modified_saving_error_message_area_new)
	(gedit_no_backup_saving_error_message_area_new)
	(gedit_unrecoverable_saving_error_message_area_new): ditto

	* gedit/gedit-tab.c (show_saving_message_area): ditto

	* gedit/gedit-document.c (gedit_document_get_uri_for_display): hides
	the password if needed

	* gedit/gedit-window.c (recent_tooltip_func_gtk)
	(recent_tooltip_func_uim): uses gedit_utils_format_uri_for_display
	instead of egg_recent_item_get_uri_for_display
parent bb591d0f
2006-04-20 Paolo Maggi <paolo@gnome.org>
Fixes bug #338173 - Gedit show keyring store password on the window
title bar
* gedit/gedit-utils.[ch] (gedit_utils_format_uri_for_display): new
function similar to gnome_vfs_format_uri_for_display but that hides
the password if needed
* gedit/gedit-commands-file.c (load_file_list)
(replace_read_only_file) (save_dialog_response_cb): use
gedit_utils_format_uri_for_display instead of
gnome_vfs_format_uri_for_display
* gedit/gedit-io-error-message-area.c
(gedit_unrecoverable_loading_error_message_area_new)
(gedit_unrecoverable_reverting_error_message_area_new)
(gedit_conversion_error_while_loading_message_area_new)
(gedit_conversion_error_while_saving_message_area_new)
(gedit_file_already_open_warning_message_area_new)
(gedit_externally_modified_saving_error_message_area_new)
(gedit_no_backup_saving_error_message_area_new)
(gedit_unrecoverable_saving_error_message_area_new): ditto
* gedit/gedit-tab.c (show_saving_message_area): ditto
* gedit/gedit-document.c (gedit_document_get_uri_for_display): hides
the password if needed
* gedit/gedit-window.c (recent_tooltip_func_gtk)
(recent_tooltip_func_uim): uses gedit_utils_format_uri_for_display
instead of egg_recent_item_get_uri_for_display
2006-04-18 Steve Frécinaux <steve@istique.net>
* pixmaps/*.png: add Andreas Nilsson's puzzle icon (gedit-plugin.png).
......
......@@ -121,7 +121,7 @@ load_file_list (GeditWindow *window,
/* There is only a single file to load */
gchar *uri_for_display;
uri_for_display = gnome_vfs_format_uri_for_display (uri);
uri_for_display = gedit_utils_format_uri_for_display (uri);
gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
......@@ -526,7 +526,7 @@ replace_read_only_file (GtkWindow *parent,
gedit_debug (DEBUG_COMMANDS);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
g_return_val_if_fail (full_formatted_uri != NULL, FALSE);
/* Truncate the URI so it doesn't get insanely wide. Note that even
......@@ -610,7 +610,7 @@ save_dialog_response_cb (GeditFileChooserDialog *dialog,
doc = gedit_tab_get_document (tab);
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
uri_for_display = gnome_vfs_format_uri_for_display (uri);
uri_for_display = gedit_utils_format_uri_for_display (uri);
gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
......
......@@ -772,9 +772,22 @@ gedit_document_get_uri_for_display (GeditDocument *doc)
if (doc->priv->uri == NULL)
return g_strdup_printf (_("Unsaved Document %d"),
doc->priv->untitled_number);
else
doc->priv->untitled_number);
else if (doc->priv->vfs_uri == NULL)
return gnome_vfs_format_uri_for_display (doc->priv->uri);
else
{
gchar *name;
gchar *uri_for_display;
name = gnome_vfs_uri_to_string (doc->priv->vfs_uri, GNOME_VFS_URI_HIDE_PASSWORD);
g_return_val_if_fail (name != NULL, gnome_vfs_format_uri_for_display (doc->priv->uri));
uri_for_display = gnome_vfs_format_uri_for_display (name);
g_free (name);
return uri_for_display;
}
}
/* move to gedit-utils? */
......
......@@ -129,7 +129,7 @@ gedit_unrecoverable_loading_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -357,7 +357,7 @@ gedit_unrecoverable_reverting_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -685,7 +685,7 @@ gedit_conversion_error_while_loading_message_area_new (
g_return_val_if_fail ((error->domain == G_CONVERT_ERROR) ||
(error->domain == GEDIT_CONVERT_ERROR), NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -751,7 +751,7 @@ gedit_conversion_error_while_saving_message_area_new (
g_return_val_if_fail (error->domain == G_CONVERT_ERROR, NULL);
g_return_val_if_fail (encoding != NULL, NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -815,7 +815,7 @@ gedit_file_already_open_warning_message_area_new (const gchar *uri)
gchar *uri_for_display;
gchar *temp_uri_for_display;
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -907,7 +907,7 @@ gedit_externally_modified_saving_error_message_area_new (
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
g_return_val_if_fail (error->code == GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED, NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -1002,7 +1002,7 @@ gedit_no_backup_saving_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
g_return_val_if_fail (error->code == GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP, NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -1097,7 +1097,7 @@ gedit_unrecoverable_saving_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
full_formatted_uri = gnome_vfs_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......
......@@ -734,7 +734,7 @@ show_saving_message_area (GeditTab *tab)
from = short_name;
to = gnome_vfs_format_uri_for_display (tab->priv->tmp_save_uri);
to = gedit_utils_format_uri_for_display (tab->priv->tmp_save_uri);
str = gedit_utils_str_middle_truncate (to,
MAX (20, MAX_MSG_LENGTH - len));
......
......@@ -1012,3 +1012,56 @@ gedit_utils_make_canonical_uri_from_shell_arg (const gchar *str)
return NULL;
}
/**
* gedit_utils_format_uri_for_display:
* @uri: uri to be displayed.
*
* Filter, modify, unescape and change @uri to make it appropriate
* for display to users.
*
* Rules:
* <ul>
* <li>file: uri without fragments should appear as local paths.</li>
* <li>file: uri with fragments should appear as file:uri.</li>
* <li>All other uri appear as expected.</li>
* </ul>
*
* This function is very similar to gnome_vfs_format_uri_for_display but remove
* the password from the resulting string
*
* Return value: a string which represents @uri and can be displayed.
*/
gchar *
gedit_utils_format_uri_for_display (const gchar *uri)
{
GnomeVFSURI *vfs_uri;
g_return_val_if_fail (uri != NULL, NULL);
/* Note: vfs_uri may be NULL for some valid but
* unsupported uris */
vfs_uri = gnome_vfs_uri_new (uri);
if (vfs_uri == NULL)
{
/* We may disclose the password here, but there is nothing we
* can do since we cannot get a valid vfs_uri */
return gnome_vfs_format_uri_for_display (uri);
}
else
{
gchar *name;
gchar *uri_for_display;
name = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_PASSWORD);
g_return_val_if_fail (name != NULL, gnome_vfs_format_uri_for_display (uri));
uri_for_display = gnome_vfs_format_uri_for_display (name);
g_free (name);
gnome_vfs_uri_unref (vfs_uri);
return uri_for_display;
}
}
......@@ -132,6 +132,11 @@ gboolean gedit_utils_get_glade_widgets (const gchar *filename,
/* Return NULL if str is not a valid URI and/or filename */
gchar *gedit_utils_make_canonical_uri_from_shell_arg
(const gchar *str);
/* Like gnome_vfs_format_uri_for_display but removes the password from the
* resulting string */
gchar *gedit_utils_format_uri_for_display (const gchar *uri);
G_END_DECLS
#endif /* __GEDIT_UTILS_H__ */
......
......@@ -850,7 +850,7 @@ recent_tooltip_func_gtk (GtkTooltips *tooltips,
gchar *uri_for_display;
gchar *trunc_uri;
uri_for_display = egg_recent_item_get_uri_for_display (item);
uri_for_display = gedit_utils_format_uri_for_display (egg_recent_item_peek_uri (item));
g_return_if_fail (uri_for_display != NULL);
trunc_uri = gedit_utils_str_middle_truncate (uri_for_display,
......@@ -875,7 +875,7 @@ recent_tooltip_func_uim (EggRecentItem *item,
gchar *uri_for_display;
gchar *trunc_uri;
uri_for_display = egg_recent_item_get_uri_for_display (item);
uri_for_display = gedit_utils_format_uri_for_display (egg_recent_item_peek_uri (item));
g_return_val_if_fail (uri_for_display != NULL, NULL);
trunc_uri = gedit_utils_str_middle_truncate (uri_for_display,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment