Commit d739fcb6 authored by Paolo Maggi's avatar Paolo Maggi Committed by Paolo Maggi

Fixes drag&drop of files from file-roller

2006-01-03  Paolo Maggi  <paolo@gnome.org>

	Fixes drag&drop of files from file-roller

	* gedit/gedit-utils.c (gedit_utils_is_valid_uri): fixed a compiler
	warning
	(gedit_utils_make_canonical_uri_from_shell_arg): new function

	* gedit/gedit-utils.h: new function
	gedit_utils_make_canonical_uri_from_shell_arg

	* gedit/gedit-window.c (drag_data_received_cb): use the new
	gedit_utils_make_canonical_uri_from_shell_arg

	* gedit/gedit.c (gedit_get_command_line_data): use the new
	gedit_utils_make_canonical_uri_from_shell_arg function
parent f2fd3e91
2006-01-03 Paolo Maggi <paolo@gnome.org>
Fixes drag&drop of files from file-roller
* gedit/gedit-utils.c (gedit_utils_is_valid_uri): fixed a compiler
warning
(gedit_utils_make_canonical_uri_from_shell_arg): new function
* gedit/gedit-utils.h: new function
gedit_utils_make_canonical_uri_from_shell_arg
* gedit/gedit-window.c (drag_data_received_cb): use the new
gedit_utils_make_canonical_uri_from_shell_arg
* gedit/gedit.c (gedit_get_command_line_data): use the new
gedit_utils_make_canonical_uri_from_shell_arg function
2006-01-03 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-app.c: fix startup race condition on active_window.
......
......@@ -143,7 +143,7 @@ load_file_list (GeditWindow *window,
while (uris != NULL)
{
g_return_val_if_fail (uris->data != NULL, 0);
tab = gedit_window_create_tab_from_uri (window,
(const gchar *)uris->data,
encoding,
......
......@@ -857,7 +857,7 @@ gedit_utils_is_valid_uri (const gchar *uri)
return FALSE;
/* We expect to have a fully valid set of characters */
for (p = uri; *p; p++) {
for (p = (const guchar *)uri; *p; p++) {
if (*p == '%')
{
++p;
......@@ -962,3 +962,40 @@ gedit_utils_get_glade_widgets (const gchar *filename,
return ret;
}
gchar *
gedit_utils_make_canonical_uri_from_shell_arg (const gchar *str)
{
gchar *uri;
gchar *canonical_uri;
g_return_val_if_fail (str != NULL, NULL);
g_return_val_if_fail (*str != '\0', NULL);
/* Note for the future:
*
* <federico> paolo: and flame whoever tells
* you that file:///gnome/test_files/hëllò
* doesn't work --- that's not a valid URI
*
* <paolo> federico: well, another solution that
* does not requires patch to _from_shell_args
* is to check that the string returned by it
* contains only ASCII chars
* <federico> paolo: hmmmm, isn't there
* gnome_vfs_is_uri_valid() or something?
* <paolo>: I will use gedit_utils_is_valid_uri ()
*
*/
uri = gnome_vfs_make_uri_from_shell_arg (str);
canonical_uri = gnome_vfs_make_uri_canonical (uri);
g_free (uri);
/* g_print ("URI: %s\n", canonical_uri); */
if (gedit_utils_is_valid_uri (canonical_uri))
return canonical_uri;
return NULL;
}
......@@ -129,6 +129,9 @@ gboolean gedit_utils_get_glade_widgets (const gchar *filename,
const gchar *widget_name,
...) G_GNUC_NULL_TERMINATED;
/* Return NULL if str is not a valid URI and/or filename */
gchar *gedit_utils_make_canonical_uri_from_shell_arg
(const gchar *str);
G_END_DECLS
#endif /* __GEDIT_UTILS_H__ */
......
......@@ -1782,7 +1782,15 @@ drag_data_received_cb (GtkWidget *widget,
uris = g_uri_list_extract_uris ((gchar *) selection_data->data);
for (i = 0; uris[i] != NULL; i++)
uri_list = g_slist_prepend (uri_list, g_strdup (uris[i]));
{
gchar *uri;
uri = gedit_utils_make_canonical_uri_from_shell_arg (uris[i]);
/* Silently ignore malformed URI/filename */
if (uri != NULL)
uri_list = g_slist_prepend (uri_list, uri);
}
g_strfreev (uris);
......
......@@ -113,32 +113,11 @@ gedit_get_command_line_data (GnomeProgram *program)
}
else
{
gchar *uri;
gchar *canonical_uri;
/* Note for the future:
*
* <federico> paolo: and flame whoever tells
* you that file:///gnome/test_files/hëllò
* doesn't work --- that's not a valid URI
*
* <paolo> federico: well, another solution that
* does not requires patch to _from_shell_args
* is to check that the string returned by it
* contains only ASCII chars
* <federico> paolo: hmmmm, isn't there
* gnome_vfs_is_uri_valid() or something?
* <paolo>: I will use gedit_utils_is_valid_uri ()
*
*/
uri = gnome_vfs_make_uri_from_shell_arg (args[i]);
canonical_uri = gnome_vfs_make_uri_canonical (uri);
g_free (uri);
g_print ("URI: %s\n", canonical_uri);
canonical_uri = gedit_utils_make_canonical_uri_from_shell_arg (args[i]);
if (gedit_utils_is_valid_uri (canonical_uri))
if (canonical_uri != NULL)
file_list = g_slist_prepend (file_list,
canonical_uri);
else
......
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