From 2e0f09d78f28c576d9a10dfcd1eeaae81e3baa07 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 13 Oct 2011 23:31:15 +0200 Subject: Add image handling basics --- src/mainwindow.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/mainwindow.c') diff --git a/src/mainwindow.c b/src/mainwindow.c index e111662..d02268f 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "presentation.h" #include "mainwindow.h" @@ -40,6 +41,7 @@ #include "loadsave.h" #include "tool_select.h" #include "tool_text.h" +#include "tool_image.h" static void add_ui_sig(GtkUIManager *ui, GtkWidget *widget, @@ -983,11 +985,27 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, } else { - printf("Drop: '%s'\n", seldata->data); - gtk_drag_finish(drag_context, TRUE, FALSE, time); + gchar *uri; + char *filename; + GError *error = NULL; + + uri = (gchar *)seldata->data; - /* FIXME: Create a new image object according to image size and - * current margins, consistent with box drawn for the preview */ + filename = g_filename_from_uri(uri, NULL, &error); + if ( filename != NULL ) { + + gtk_drag_finish(drag_context, TRUE, FALSE, time); + chomp(filename); + add_image_object(p->view_slide, + p->start_corner_x, p->start_corner_y, + p->import_width, p->import_height, + filename, + p->ss->styles[0], p->image_store, + p->image_tool); + + /* Don't free "filename" - it's now owned by the + * image store. */ + } } } @@ -1047,6 +1065,7 @@ int open_mainwindow(struct presentation *p) p->select_tool = initialise_select_tool(); p->text_tool = initialise_text_tool(p->drawingarea); + p->image_tool = initialise_image_tool(); p->cur_tool = p->select_tool; gtk_widget_set_can_focus(GTK_WIDGET(p->drawingarea), TRUE); -- cgit v1.2.3