diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2013-11-15 20:57:55 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2013-11-15 21:09:01 -0300 |
commit | 592516f7499a5dfa7483b2200e6896dfe4fdcc3a (patch) | |
tree | dd2aa3622cad6b496b6da9aad775860e3e221921 | |
parent | 8910663c7faac0868533056daae3f72882d0a97f (diff) | |
download | glade-592516f7499a5dfa7483b2200e6896dfe4fdcc3a.tar.gz |
Fixed warning in recent_add() and recent_remove() when path is not absolute
by prepending g_get_current_dir() to it.
-rw-r--r-- | src/glade-window.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/glade-window.c b/src/glade-window.c index 40df19af..4c1fa3a1 100644 --- a/src/glade-window.c +++ b/src/glade-window.c @@ -894,21 +894,41 @@ set_sensitivity_according_to_project (GladeWindow *window, refresh_next_prev_project_sensitivity (window); } -static void -recent_add (GladeWindow *window, const gchar *path) +static gchar * +get_uri_from_project_path (const gchar *path) { - GtkRecentData *recent_data; - gchar *uri; GError *error = NULL; - - uri = g_filename_to_uri (path, NULL, &error); + gchar *uri = NULL; + + if (g_path_is_absolute (path)) + uri = g_filename_to_uri (path, NULL, &error); + else + { + gchar *cwd = g_get_current_dir (); + gchar *fullpath = g_build_filename (cwd, path, NULL); + uri = g_filename_to_uri (fullpath, NULL, &error); + g_free (cwd); + g_free (fullpath); + } + if (error) { g_warning ("Could not convert local path \"%s\" to a uri: %s", path, error->message); g_error_free (error); - return; } + return uri; +} + +static void +recent_add (GladeWindow *window, const gchar *path) +{ + gchar *uri = get_uri_from_project_path (path); + GtkRecentData *recent_data; + + if (!uri) + return; + recent_data = g_slice_new (GtkRecentData); recent_data->display_name = NULL; @@ -924,22 +944,15 @@ recent_add (GladeWindow *window, const gchar *path) g_free (uri); g_free (recent_data->app_exec); g_slice_free (GtkRecentData, recent_data); - } static void recent_remove (GladeWindow * window, const gchar * path) { - gchar *uri; - GError *error = NULL; + gchar *uri = get_uri_from_project_path (path); - uri = g_filename_to_uri (path, NULL, &error); - if (error) - { - g_warning ("Could not convert local path \"%s\" to a uri: %s", path, error->message); - g_error_free (error); - return; - } + if (!uri) + return; gtk_recent_manager_remove_item (window->priv->recent_manager, uri, NULL); |