allow to paste URLs and filenames to the toolbox using the middle mouse

2005-02-11  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimptoolbox.c: allow to paste URLs and filenames to
	the toolbox using the middle mouse button.
This commit is contained in:
Sven Neumann 2005-02-11 01:23:41 +00:00 committed by Sven Neumann
parent dd81c98a13
commit eb8742cd62
2 changed files with 58 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2005-02-11 Sven Neumann <sven@gimp.org>
* app/widgets/gimptoolbox.c: allow to paste URLs and filenames to
the toolbox using the middle mouse button.
2005-02-10 Manish Singh <yosh@gimp.org>
* app/file/file-save.c (file_save_as): Make sure filename is

View File

@ -34,6 +34,9 @@
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "file/file-open.h"
#include "file/file-utils.h"
#include "gimpdevices.h"
#include "gimpdialogfactory.h"
#include "gimphelp-ids.h"
@ -111,6 +114,10 @@ static gboolean toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
Gimp *gimp);
static void toolbox_paste_received (GtkClipboard *clipboard,
const gchar *text,
gpointer data);
/* local variables */
@ -963,13 +970,23 @@ toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpToolbox *toolbox)
{
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
{
gimp_dialog_factory_dialog_raise (GIMP_DOCK (toolbox)->dialog_factory,
gtk_widget_get_screen (widget),
"gimp-tool-options",
-1);
}
else if (event->type == GDK_BUTTON_PRESS && event->button == 2)
{
GimpContext *context = GIMP_DOCK (toolbox)->context;
GtkClipboard *clipboard;
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY);
g_object_ref (context);
gtk_clipboard_request_text (clipboard, toolbox_paste_received, context);
}
return FALSE;
}
@ -983,3 +1000,38 @@ toolbox_check_device (GtkWidget *widget,
return FALSE;
}
static void
toolbox_paste_received (GtkClipboard *clipboard,
const gchar *text,
gpointer data)
{
GimpContext *context = GIMP_CONTEXT (data);
if (text && g_utf8_validate (text, -1, NULL))
{
GimpImage *image;
GimpPDBStatusType status;
GError *error = NULL;
/* FIXME: need to validate the URI here!!
*/
image = file_open_with_display (context->gimp, context, NULL,
text, &status, &error);
if (! image && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (text);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
}
}
g_object_unref (context);
}