Commit 61116ebb authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed utility funtion gimp_dnd_open_files().

2004-06-02  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdnd.[ch]: removed utility funtion
	gimp_dnd_open_files().

	* app/widgets/gimptoolbox-dnd.c: added gimp_toolbox_drop_files()
	instead.

	* app/display/gimpdisplayshell-dnd.c (gimp_display_shell_drop_files):
	show the error message if opening a dropped file fails.
parent f2f3c448
2004-06-02 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdnd.[ch]: removed utility funtion
gimp_dnd_open_files().
* app/widgets/gimptoolbox-dnd.c: added gimp_toolbox_drop_files()
instead.
* app/display/gimpdisplayshell-dnd.c (gimp_display_shell_drop_files):
show the error message if opening a dropped file fails.
2004-06-02 Sven Neumann <sven@gimp.org>
* libgimpthumb/gimpthumbnail.c: plugged a small memory leak.
......
......@@ -281,13 +281,14 @@ gimp_display_shell_drop_files (GtkWidget *widget,
for (list = files; list; list = g_list_next (list))
{
const gchar *uri = list->data;
GimpImage *new_image;
const gchar *uri = list->data;
GimpPDBStatusType status;
GError *error = NULL;
new_image = file_open_image (gimage->gimp, context, uri, uri,
NULL, GIMP_RUN_NONINTERACTIVE,
&status, NULL, NULL);
&status, NULL, &error);
if (new_image)
{
......@@ -343,6 +344,16 @@ gimp_display_shell_drop_files (GtkWidget *widget,
g_object_unref (new_image);
}
else if (status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
}
}
gimp_image_flush (gimage);
......
......@@ -50,9 +50,6 @@
#include "vectors/gimpvectors.h"
#include "file/file-open.h"
#include "file/file-utils.h"
#include "gimpdnd.h"
#include "gimppreview.h"
......@@ -1287,42 +1284,6 @@ gimp_dnd_file_dest_remove (GtkWidget *widget)
gimp_dnd_data_dest_remove (GIMP_DND_TYPE_NETSCAPE_URL, widget);
}
void
gimp_dnd_open_files (GtkWidget *widget,
GList *files,
gpointer data)
{
GList *list;
for (list = files; list; list = g_list_next (list))
{
const gchar *uri = list->data;
GimpImage *gimage;
GimpPDBStatusType status;
GError *error = NULL;
D (g_print ("%s: ...trying to open resulting uri \"%s\"\n",
G_STRFUNC, uri));
gimage = file_open_with_display (the_dnd_gimp,
gimp_get_user_context (the_dnd_gimp),
uri, &status, &error);
if (! gimage && status != GIMP_PDB_CANCEL)
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
}
}
}
/*************************/
/* color dnd functions */
......
......@@ -110,11 +110,6 @@ void gimp_dnd_file_dest_add (GtkWidget *widget,
gpointer data);
void gimp_dnd_file_dest_remove (GtkWidget *widget);
/* standard callback */
void gimp_dnd_open_files (GtkWidget *widget,
GList *files,
gpointer data);
/* color dnd functions */
......
......@@ -34,13 +34,21 @@
#include "core/gimplayermask.h"
#include "core/gimptoolinfo.h"
#include "file/file-open.h"
#include "file/file-utils.h"
#include "gimpdnd.h"
#include "gimptoolbox.h"
#include "gimptoolbox-dnd.h"
#include "gimp-intl.h"
/* local function prototypes */
static void gimp_toolbox_drop_files (GtkWidget *widget,
GList *files,
gpointer data);
static void gimp_toolbox_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
......@@ -63,9 +71,12 @@ gimp_toolbox_dnd_init (GimpToolbox *toolbox)
dock = GIMP_DOCK (toolbox);
gimp_dnd_file_dest_add (GTK_WIDGET (toolbox), gimp_dnd_open_files, NULL);
gimp_dnd_file_dest_add (toolbox->tool_wbox, gimp_dnd_open_files, NULL);
gimp_dnd_file_dest_add (GTK_WIDGET (toolbox),
gimp_toolbox_drop_files,
dock->context);
gimp_dnd_file_dest_add (toolbox->tool_wbox,
gimp_toolbox_drop_files,
dock->context);
gimp_dnd_viewable_dest_add (toolbox->tool_wbox, GIMP_TYPE_LAYER,
gimp_toolbox_drop_drawable,
......@@ -87,6 +98,37 @@ gimp_toolbox_dnd_init (GimpToolbox *toolbox)
/* private functions */
static void
gimp_toolbox_drop_files (GtkWidget *widget,
GList *files,
gpointer data)
{
GimpContext *context = GIMP_CONTEXT (data);
GList *list;
for (list = files; list; list = g_list_next (list))
{
const gchar *uri = list->data;
GimpImage *gimage;
GimpPDBStatusType status;
GError *error = NULL;
gimage = file_open_with_display (context->gimp, context,
uri, &status, &error);
if (! gimage && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
}
}
}
static void
gimp_toolbox_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
......
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