diff --git a/ChangeLog b/ChangeLog index f753aeb2bf..3cd3e3e3ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-01-13 Sven Neumann + + * app/widgets/gimpfiledialog.c + * app/widgets/gimpthumbbox.[ch]: save some string copies by + changing gimp_thumb_box_set_uri() to gimp_thumb_box_take_uri(). + 2007-01-12 Sven Neumann * plug-ins/common/compose.c diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c index 9fc1f40d77..cb79b3fda4 100644 --- a/app/widgets/gimpfiledialog.c +++ b/app/widgets/gimpfiledialog.c @@ -415,8 +415,7 @@ gimp_file_dialog_set_image (GimpFileDialog *dialog, #ifndef G_OS_WIN32 dirname = g_path_get_dirname (uri); #else - /* g_path_get_dirname() is supposed to work on pathnames, not - * URIs. + /* g_path_get_dirname() is supposed to work on pathnames, not URIs. * * If uri points to a file on the root of a drive * "file:///d:/foo.png", g_path_get_dirname() would return @@ -434,25 +433,31 @@ gimp_file_dialog_set_image (GimpFileDialog *dialog, */ if (g_str_has_prefix (uri, "file:///")) { - char *filepath, *dirpath = NULL; + gchar *filepath = g_filename_from_uri (uri, NULL, NULL); + gchar *dirpath = NULL; - filepath = g_filename_from_uri (uri, NULL, NULL); if (filepath != NULL) { dirpath = g_path_get_dirname (filepath); g_free (filepath); } + if (dirpath != NULL) { dirname = g_filename_to_uri (dirpath, NULL, NULL); g_free (dirpath); } else - dirname = NULL; + { + dirname = NULL; + } } else - dirname = g_path_get_dirname (uri); + { + dirname = g_path_get_dirname (uri); + } #endif + basename = file_utils_uri_display_basename (uri); if (dirname && strlen (dirname) && strcmp (dirname, ".")) @@ -636,11 +641,8 @@ static void gimp_file_dialog_update_preview (GtkFileChooser *chooser, GimpFileDialog *dialog) { - gchar *uri = gtk_file_chooser_get_preview_uri (chooser); - - gimp_thumb_box_set_uri (GIMP_THUMB_BOX (dialog->thumb_box), uri); - - g_free (uri); + gimp_thumb_box_take_uri (GIMP_THUMB_BOX (dialog->thumb_box), + gtk_file_chooser_get_preview_uri (chooser)); } static void diff --git a/app/widgets/gimpthumbbox.c b/app/widgets/gimpthumbbox.c index 0d90bbccbe..9274556424 100644 --- a/app/widgets/gimpthumbbox.c +++ b/app/widgets/gimpthumbbox.c @@ -443,8 +443,8 @@ gimp_thumb_box_new (GimpContext *context) } void -gimp_thumb_box_set_uri (GimpThumbBox *box, - const gchar *uri) +gimp_thumb_box_take_uri (GimpThumbBox *box, + gchar *uri) { g_return_if_fail (GIMP_IS_THUMB_BOX (box)); @@ -454,7 +454,7 @@ gimp_thumb_box_set_uri (GimpThumbBox *box, box->idle_id = 0; } - gimp_object_set_name (GIMP_OBJECT (box->imagefile), uri); + gimp_object_take_name (GIMP_OBJECT (box->imagefile), uri); if (uri) { diff --git a/app/widgets/gimpthumbbox.h b/app/widgets/gimpthumbbox.h index 84564c8e1b..0bc55e226f 100644 --- a/app/widgets/gimpthumbbox.h +++ b/app/widgets/gimpthumbbox.h @@ -59,8 +59,8 @@ GType gimp_thumb_box_get_type (void) G_GNUC_CONST; GtkWidget * gimp_thumb_box_new (GimpContext *context); -void gimp_thumb_box_set_uri (GimpThumbBox *box, - const gchar *uri); +void gimp_thumb_box_take_uri (GimpThumbBox *box, + gchar *uri); void gimp_thumb_box_take_uris (GimpThumbBox *box, GSList *uris);