[totem] Bug 589755 – Make screenshot dialogue more like GNOME's



commit 75ef216e7fd62ff8543644f4a9130f032cb67d4e
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Aug 10 21:40:12 2009 +0100

    Bug 589755 â?? Make screenshot dialogue more like GNOME's
    
    This copies the GnomeScreenshotWidget from gnome-screenshot so that our
    interface can easily be kept consistent with the GNOME Screenshot dialogue.
    Permission for the licence exception was gained by e-mail. Closes: bgo#589755

 src/plugins/screenshot/Makefile.am               |    4 +-
 src/plugins/screenshot/gnome-screenshot-widget.c |  431 ++++++++++++++++++++++
 src/plugins/screenshot/gnome-screenshot-widget.h |   71 ++++
 src/plugins/screenshot/gnome-screenshot.ui       |  149 ++++++++
 src/plugins/screenshot/totem-gallery.c           |    6 +-
 src/plugins/screenshot/totem-screenshot-plugin.c |   35 ++-
 src/plugins/screenshot/totem-screenshot-plugin.h |    2 +-
 src/plugins/screenshot/totem-screenshot.c        |  188 +++-------
 src/plugins/screenshot/totem-screenshot.h        |   13 +-
 src/totem-uri.c                                  |   13 -
 src/totem-uri.h                                  |    1 -
 11 files changed, 751 insertions(+), 162 deletions(-)
---
diff --git a/src/plugins/screenshot/Makefile.am b/src/plugins/screenshot/Makefile.am
index 0f6c11f..e6305fb 100644
--- a/src/plugins/screenshot/Makefile.am
+++ b/src/plugins/screenshot/Makefile.am
@@ -9,7 +9,7 @@ plugin_in_files = screenshot.totem-plugin.in
 %.totem-plugin: %.totem-plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
 
 plugin_DATA = $(plugin_in_files:.totem-plugin.in=.totem-plugin)
-ui_DATA = gallery.ui
+ui_DATA = gallery.ui gnome-screenshot.ui
 
 common_defines = \
 	-D_REENTRANT					\
@@ -23,6 +23,8 @@ common_defines = \
 	$(DISABLE_DEPRECATED)
 
 libscreenshot_la_SOURCES = \
+	gnome-screenshot-widget.c	\
+	gnome-screenshot-widget.h	\
 	totem-screenshot-plugin.c	\
 	totem-screenshot-plugin.h	\
 	totem-screenshot.c		\
diff --git a/src/plugins/screenshot/gnome-screenshot-widget.c b/src/plugins/screenshot/gnome-screenshot-widget.c
new file mode 100644
index 0000000..42ed3fb
--- /dev/null
+++ b/src/plugins/screenshot/gnome-screenshot-widget.c
@@ -0,0 +1,431 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GNOME Screenshot widget
+ * Copyright (C) 2001-2006  Jonathan Blandford <jrb alum mit edu>
+ * Copyright (C) Philip Withnall 2009 <philip tecnocode co uk>
+ *
+ * GNOME Screenshot widget is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNOME Screenshot widget is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNOME Screenshot widget.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The Totem project hereby grant permission for non-GPL compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Totem. This
+ * permission are above and beyond the permissions granted by the GPL license
+ * Totem is covered by.
+ *
+ * Monday 10th August 2009: Philip Withnall: Add exception clause.
+ * Permission from the previous authors granted via e-mail.
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gnome-screenshot-widget.h"
+
+static void gnome_screenshot_widget_dispose (GObject *object);
+static void gnome_screenshot_widget_finalize (GObject *object);
+static void gnome_screenshot_widget_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void gnome_screenshot_widget_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
+
+/* GtkBuilder callbacks */
+G_MODULE_EXPORT gboolean on_preview_button_press_event (GtkWidget *drawing_area, GdkEventButton *event, GnomeScreenshotWidget *self);
+G_MODULE_EXPORT void on_preview_expose_event (GtkWidget *drawing_area, GdkEventExpose *event, GnomeScreenshotWidget *self);
+G_MODULE_EXPORT gboolean on_preview_button_release_event (GtkWidget *drawing_area, GdkEventButton *event, GnomeScreenshotWidget *self);
+G_MODULE_EXPORT void on_preview_configure_event (GtkWidget *drawing_area, GdkEventConfigure *event, GnomeScreenshotWidget *self);
+G_MODULE_EXPORT void on_preview_drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint time,
+					       GnomeScreenshotWidget *self);
+G_MODULE_EXPORT void on_preview_drag_begin (GtkWidget *widget, GdkDragContext *context, GnomeScreenshotWidget *self);
+
+struct _GnomeScreenshotWidgetPrivate {
+	GdkPixbuf *screenshot;
+	GdkPixbuf *preview_image;
+	GtkFileChooser *file_chooser;
+	GtkEntry *filename_entry;
+	GtkWidget *preview_area;
+	gint drag_x;
+	gint drag_y;
+	gchar *temporary_filename;
+};
+
+enum {
+	PROP_TEMPORARY_FILENAME = 1
+};
+
+enum {
+	TYPE_TEXT_URI_LIST,
+	TYPE_IMAGE_PNG,
+	LAST_TYPE
+};
+
+static GtkTargetEntry drag_types[] = {
+	/* typecasts are to shut gcc up */
+	{ (gchar*) "text/uri-list", 0, TYPE_TEXT_URI_LIST },
+	{ (gchar*) "image/png", 0, TYPE_IMAGE_PNG }
+};
+
+static GtkTargetEntry *drag_types_no_uris = drag_types + sizeof (GtkTargetEntry);
+
+G_DEFINE_TYPE (GnomeScreenshotWidget, gnome_screenshot_widget, GTK_TYPE_BOX)
+#define GNOME_SCREENSHOT_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GNOME_TYPE_SCREENSHOT_WIDGET, GnomeScreenshotWidgetPrivate))
+
+static void
+gnome_screenshot_widget_class_init (GnomeScreenshotWidgetClass *klass)
+{
+	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+	g_type_class_add_private (klass, sizeof (GnomeScreenshotWidgetPrivate));
+
+	gobject_class->get_property = gnome_screenshot_widget_get_property;
+	gobject_class->set_property = gnome_screenshot_widget_set_property;
+	gobject_class->dispose = gnome_screenshot_widget_dispose;
+	gobject_class->finalize = gnome_screenshot_widget_finalize;
+
+	g_object_class_install_property (gobject_class, PROP_TEMPORARY_FILENAME,
+				g_param_spec_string ("temporary-filename",
+					"Temporary filename", "The filename of a temporary file for use in drag-and-drop.",
+					NULL,
+					G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gnome_screenshot_widget_init (GnomeScreenshotWidget *self)
+{
+	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GNOME_TYPE_SCREENSHOT_WIDGET, GnomeScreenshotWidgetPrivate);
+}
+
+static void
+gnome_screenshot_widget_dispose (GObject *object)
+{
+	GnomeScreenshotWidgetPrivate *priv = GNOME_SCREENSHOT_WIDGET (object)->priv;
+
+	if (priv->screenshot != NULL)
+		g_object_unref (priv->screenshot);
+	priv->screenshot = NULL;
+
+	if (priv->preview_image != NULL)
+		g_object_unref (priv->preview_image);
+	priv->preview_image = NULL;
+
+	/* Chain up to the parent class */
+	G_OBJECT_CLASS (gnome_screenshot_widget_parent_class)->dispose (object);
+}
+
+static void
+gnome_screenshot_widget_finalize (GObject *object)
+{
+	GnomeScreenshotWidgetPrivate *priv = GNOME_SCREENSHOT_WIDGET (object)->priv;
+
+	g_free (priv->temporary_filename);
+
+	/* Chain up to the parent class */
+	G_OBJECT_CLASS (gnome_screenshot_widget_parent_class)->finalize (object);
+}
+
+static void
+gnome_screenshot_widget_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+	GnomeScreenshotWidgetPrivate *priv = GNOME_SCREENSHOT_WIDGET (object)->priv;
+
+	switch (property_id) {
+		case PROP_TEMPORARY_FILENAME:
+			g_value_set_string (value, priv->temporary_filename);
+			break;
+		default:
+			/* We don't have any other property... */
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+			break;
+	}
+}
+
+static void
+gnome_screenshot_widget_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+	GnomeScreenshotWidget *self = GNOME_SCREENSHOT_WIDGET (object);
+
+	switch (property_id) {
+		case PROP_TEMPORARY_FILENAME:
+			gnome_screenshot_widget_set_temporary_filename (self, g_value_get_string (value));
+			break;
+		default:
+			/* We don't have any other property... */
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+			break;
+	}
+}
+
+static void
+on_filename_entry_realize (GtkWidget *filename_entry, gchar *current_name)
+{
+	const gchar *ext;
+	gint pos;
+
+	/* Select the name of the file but leave out the extension if there's any;
+	 * the widget must be realized for select_region to work */
+	ext = g_utf8_strrchr (current_name, -1, '.');
+	if (ext)
+		pos = g_utf8_strlen (current_name, -1) - g_utf8_strlen (ext, -1);
+	else
+		pos = -1;
+
+	gtk_editable_select_region (GTK_EDITABLE (filename_entry), 0, pos);
+
+	/* Disconnect the signal and free the data */
+	g_signal_handlers_disconnect_by_func (filename_entry, on_filename_entry_realize, current_name);
+	g_free (current_name);
+}
+
+GtkWidget *
+gnome_screenshot_widget_new (const gchar *interface_filename, GdkPixbuf *screenshot, const gchar *initial_uri)
+{
+	GnomeScreenshotWidgetPrivate *priv;
+	GnomeScreenshotWidget *screenshot_widget;
+	GtkBuilder *builder;
+	GtkAspectFrame *aspect_frame;
+	gchar *current_folder, *current_name;
+	const gchar *dir;
+	GFile *tmp_file, *parent_file;
+	gint width, height;
+
+	builder = gtk_builder_new ();
+	if (gtk_builder_add_from_file (builder, interface_filename, NULL) == FALSE) {
+		g_object_unref (builder);
+		return NULL;
+	}
+
+	gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
+	screenshot_widget = GNOME_SCREENSHOT_WIDGET (gtk_builder_get_object (builder, "screenshot_widget"));
+	g_object_ref_sink (screenshot_widget);
+	gtk_builder_connect_signals (builder, screenshot_widget);
+
+	if (screenshot_widget == NULL) {
+		g_object_unref (builder);
+		return NULL;
+	}
+
+	/* Set up with the data we're passed */
+	priv = screenshot_widget->priv;
+	priv->screenshot = g_object_ref (screenshot);
+
+	/* Grab our child widgets */
+	priv->file_chooser = GTK_FILE_CHOOSER (gtk_builder_get_object (builder, "file_chooser_button"));
+	priv->filename_entry = GTK_ENTRY (gtk_builder_get_object (builder, "filename_entry"));
+	priv->preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "preview_darea"));
+	aspect_frame = GTK_ASPECT_FRAME (gtk_builder_get_object (builder, "aspect_frame"));
+
+	/* Set up the file chooser and filename entry */
+	tmp_file = g_file_new_for_uri (initial_uri);
+	parent_file = g_file_get_parent (tmp_file);
+	current_name = g_file_get_basename (tmp_file);
+	current_folder = g_file_get_uri (parent_file);
+	g_object_unref (tmp_file);
+	g_object_unref (parent_file);
+
+	gtk_file_chooser_set_current_folder_uri (priv->file_chooser, current_folder);
+	gtk_entry_set_text (priv->filename_entry, current_name);
+	g_free (current_folder);
+
+	/* Add the special pictures directory to the file chooser */
+	dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+	if (dir != NULL)
+		gtk_file_chooser_add_shortcut_folder (priv->file_chooser, dir, NULL);
+
+	/* Select the filename (except the extension) when the filename entry is realised.
+	 * The on_filename_entry_realize function will free current_name. */
+	g_signal_connect (priv->filename_entry, "realize", G_CALLBACK (on_filename_entry_realize), current_name);
+
+	/* Set up the preview area */
+	width = gdk_pixbuf_get_width (screenshot) / 5;
+	height = gdk_pixbuf_get_height (screenshot) / 5;
+
+	gtk_widget_set_size_request (priv->preview_area, width, height);
+	gtk_aspect_frame_set (aspect_frame, 0.0, 0.5, (gfloat) gdk_pixbuf_get_width (screenshot) / (gfloat) gdk_pixbuf_get_height (screenshot), FALSE);
+
+	g_object_unref (builder);
+
+	/* We had to sink the object reference before to prevent it being destroyed when unreffing the builder,
+	 * but in order to return a floating-referenced widget (as is the convention), we need to force the
+	 * reference to be floating again. */
+	g_object_force_floating (G_OBJECT (screenshot_widget));
+
+	return GTK_WIDGET (screenshot_widget);
+}
+
+void
+on_preview_expose_event (GtkWidget *drawing_area, GdkEventExpose *event, GnomeScreenshotWidget *self)
+{
+	GdkPixbuf *pixbuf = NULL;
+	gboolean free_pixbuf = FALSE;
+
+	/* Stolen from GtkImage.  I really should just make the drawing area an
+	 * image some day (TODO) */
+	if (GTK_WIDGET_STATE (drawing_area) != GTK_STATE_NORMAL) {
+		GtkIconSource *source;
+
+		source = gtk_icon_source_new ();
+		gtk_icon_source_set_pixbuf (source, self->priv->preview_image);
+		gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
+		gtk_icon_source_set_size_wildcarded (source, FALSE);
+
+		pixbuf = gtk_style_render_icon (drawing_area->style, source, gtk_widget_get_direction (drawing_area), GTK_WIDGET_STATE (drawing_area),
+						(GtkIconSize) -1, drawing_area, "gtk-image");
+		free_pixbuf = TRUE;
+		gtk_icon_source_free (source);
+	} else {
+		pixbuf = g_object_ref (self->priv->preview_image);
+	}
+
+	/* FIXME: Draw it insensitive in that case */
+	gdk_draw_pixbuf (drawing_area->window, drawing_area->style->white_gc, pixbuf, event->area.x, event->area.y, event->area.x, event->area.y,
+			 event->area.width, event->area.height, GDK_RGB_DITHER_NORMAL, 0, 0);
+
+	g_object_unref (pixbuf);
+}
+
+gboolean
+on_preview_button_press_event (GtkWidget *drawing_area, GdkEventButton *event, GnomeScreenshotWidget *self)
+{
+	self->priv->drag_x = (gint) event->x;
+	self->priv->drag_y = (gint) event->y;
+
+	return FALSE;
+}
+
+gboolean
+on_preview_button_release_event (GtkWidget *drawing_area, GdkEventButton *event, GnomeScreenshotWidget *self)
+{
+	self->priv->drag_x = 0;
+	self->priv->drag_y = 0;
+
+	return FALSE;
+}
+
+void
+on_preview_configure_event (GtkWidget *drawing_area, GdkEventConfigure *event, GnomeScreenshotWidget *self)
+{
+	/* Re-scale the preview image */
+	if (self->priv->preview_image)
+		g_object_unref (self->priv->preview_image);
+	self->priv->preview_image = gdk_pixbuf_scale_simple (self->priv->screenshot, event->width, event->height, GDK_INTERP_BILINEAR);
+}
+
+void
+on_preview_drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint _time,
+			  GnomeScreenshotWidget *self)
+{
+	switch (info) {
+	case TYPE_TEXT_URI_LIST: {
+		gchar *uris[2];
+
+		g_assert (self->priv->temporary_filename != NULL);
+
+		uris[0] = g_filename_to_uri (self->priv->temporary_filename, NULL, NULL);
+		uris[1] = NULL;
+
+		gtk_selection_data_set_uris (selection_data, uris);
+		g_free (uris[0]);
+
+		break;
+	}
+	case TYPE_IMAGE_PNG:
+		gtk_selection_data_set_pixbuf (selection_data, self->priv->screenshot);
+		break;
+	case LAST_TYPE:
+	default:
+		g_warning ("Unknown type %d", info);
+	}
+}
+
+void
+on_preview_drag_begin (GtkWidget *widget, GdkDragContext *context, GnomeScreenshotWidget *self)
+{
+	gtk_drag_set_icon_pixbuf (context, self->priv->preview_image, self->priv->drag_x, self->priv->drag_y);
+}
+
+void
+gnome_screenshot_widget_focus_entry (GnomeScreenshotWidget *self)
+{
+	g_return_if_fail (GNOME_IS_SCREENSHOT_WIDGET (self));
+	gtk_widget_grab_focus (GTK_WIDGET (self->priv->filename_entry));
+}
+
+gchar *
+gnome_screenshot_widget_get_uri (GnomeScreenshotWidget *self)
+{
+	gchar *folder;
+	const gchar *filename;
+	gchar *uri, *file, *tmp;
+	GError *error = NULL;
+
+	g_return_val_if_fail (GNOME_IS_SCREENSHOT_WIDGET (self), NULL);
+
+	folder = gtk_file_chooser_get_current_folder_uri (self->priv->file_chooser);
+	filename = gtk_entry_get_text (self->priv->filename_entry);
+
+	tmp = g_filename_from_utf8 (filename, -1, NULL, NULL, &error);
+	if (error != NULL) {
+		g_warning ("Unable to convert \"%s\" to valid UTF-8: %s\nFalling back to default filename.", filename, error->message);
+		g_error_free (error);
+		tmp = g_strdup (_("Screenshot.png"));
+	}
+
+	file = g_uri_escape_string (tmp, NULL, FALSE);
+	uri = g_build_filename (folder, file, NULL);
+
+	g_free (folder);
+	g_free (tmp);
+	g_free (file);
+
+	return uri;
+}
+
+gchar *
+gnome_screenshot_widget_get_folder (GnomeScreenshotWidget *self)
+{
+	g_return_val_if_fail (GNOME_IS_SCREENSHOT_WIDGET (self), NULL);
+	return gtk_file_chooser_get_current_folder_uri (self->priv->file_chooser);
+}
+
+GdkPixbuf *
+gnome_screenshot_widget_get_screenshot (GnomeScreenshotWidget *self)
+{
+	g_return_val_if_fail (GNOME_IS_SCREENSHOT_WIDGET (self), NULL);
+	return self->priv->screenshot;
+}
+
+const gchar *
+gnome_screenshot_widget_get_temporary_filename (GnomeScreenshotWidget *self)
+{
+	g_return_val_if_fail (GNOME_IS_SCREENSHOT_WIDGET (self), NULL);
+	return self->priv->temporary_filename;
+}
+
+void
+gnome_screenshot_widget_set_temporary_filename (GnomeScreenshotWidget *self, const gchar *temporary_filename)
+{
+	GnomeScreenshotWidgetPrivate *priv = self->priv;
+
+	g_free (priv->temporary_filename);
+	priv->temporary_filename = g_strdup (temporary_filename);
+
+	/* Set/Unset the preview area as a drag source based on whether we have a temporary file */
+	if (priv->temporary_filename == NULL) {
+		/* We can only provide pixbuf data */
+		gtk_drag_source_set (priv->preview_area, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+				     drag_types_no_uris, G_N_ELEMENTS (drag_types_no_uris), GDK_ACTION_COPY);
+	} else {
+		/* We can provide pixbuf data and temporary file URIs */
+		gtk_drag_source_set (priv->preview_area, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+				     drag_types, G_N_ELEMENTS (drag_types), GDK_ACTION_COPY);
+	}
+}
diff --git a/src/plugins/screenshot/gnome-screenshot-widget.h b/src/plugins/screenshot/gnome-screenshot-widget.h
new file mode 100644
index 0000000..a0daaf1
--- /dev/null
+++ b/src/plugins/screenshot/gnome-screenshot-widget.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GNOME Screenshot widget
+ * Copyright (C) 2001-2006  Jonathan Blandford <jrb alum mit edu>
+ * Copyright (C) Philip Withnall 2009 <philip tecnocode co uk>
+ * 
+ * GNOME Screenshot widget is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNOME Screenshot widget is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNOME Screenshot widget.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The Totem project hereby grant permission for non-GPL compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Totem. This
+ * permission are above and beyond the permissions granted by the GPL license
+ * Totem is covered by.
+ *
+ * Monday 10th August 2009: Philip Withnall: Add exception clause.
+ * Permission from the previous authors granted via e-mail.
+ */
+
+#ifndef GNOME_SCREENSHOT_WIDGET_H
+#define GNOME_SCREENSHOT_WIDGET_H
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GNOME_TYPE_SCREENSHOT_WIDGET		(gnome_screenshot_widget_get_type ())
+#define GNOME_SCREENSHOT_WIDGET(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_TYPE_SCREENSHOT_WIDGET, GnomeScreenshotWidget))
+#define GNOME_SCREENSHOT_WIDGET_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GNOME_TYPE_SCREENSHOT_WIDGET, GnomeScreenshotWidgetClass))
+#define GNOME_IS_SCREENSHOT_WIDGET(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_TYPE_SCREENSHOT_WIDGET))
+#define GNOME_IS_SCREENSHOT_WIDGET_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_TYPE_SCREENSHOT_WIDGET))
+#define GNOME_SCREENSHOT_WIDGET_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_TYPE_SCREENSHOT_WIDGET, GnomeScreenshotWidgetClass))
+
+typedef struct _GnomeScreenshotWidgetPrivate	GnomeScreenshotWidgetPrivate;
+
+typedef struct {
+	GtkBox parent;
+	GnomeScreenshotWidgetPrivate *priv;
+} GnomeScreenshotWidget;
+
+typedef struct {
+	GtkBoxClass parent;
+} GnomeScreenshotWidgetClass;
+
+GType gnome_screenshot_widget_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gnome_screenshot_widget_new (const gchar *interface_filename, GdkPixbuf *screenshot,
+					const gchar *initial_uri) G_GNUC_WARN_UNUSED_RESULT;
+
+void gnome_screenshot_widget_focus_entry (GnomeScreenshotWidget *self);
+gchar *gnome_screenshot_widget_get_uri (GnomeScreenshotWidget *self) G_GNUC_WARN_UNUSED_RESULT;
+gchar *gnome_screenshot_widget_get_folder (GnomeScreenshotWidget *self) G_GNUC_WARN_UNUSED_RESULT;
+GdkPixbuf *gnome_screenshot_widget_get_screenshot (GnomeScreenshotWidget *self);
+
+const gchar *gnome_screenshot_widget_get_temporary_filename (GnomeScreenshotWidget *self);
+void gnome_screenshot_widget_set_temporary_filename (GnomeScreenshotWidget *self, const gchar *temporary_filename);
+
+G_END_DECLS
+
+#endif /* !GNOME_SCREENSHOT_WIDGET_H */
diff --git a/src/plugins/screenshot/gnome-screenshot.ui b/src/plugins/screenshot/gnome-screenshot.ui
new file mode 100644
index 0000000..7b443ae
--- /dev/null
+++ b/src/plugins/screenshot/gnome-screenshot.ui
@@ -0,0 +1,149 @@
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+  <object class="GnomeScreenshotWidget" id="screenshot_widget">
+    <property name="visible">True</property>
+    <property name="homogeneous">False</property>
+    <property name="spacing">12</property>
+    <child>
+      <object class="GtkAlignment" id="alignment1">
+        <property name="visible">True</property>
+        <property name="xalign">0</property>
+        <property name="yalign">0</property>
+        <property name="xscale">0</property>
+        <property name="yscale">0</property>
+        <property name="top-padding">0</property>
+        <property name="bottom-padding">0</property>
+        <property name="left-padding">0</property>
+        <property name="right-padding">0</property>
+        <child>
+          <object class="GtkAspectFrame" id="aspect_frame">
+            <property name="visible">True</property>
+            <property name="label-xalign">0</property>
+            <property name="label-yalign">0</property>
+            <property name="shadow-type">GTK_SHADOW_IN</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="ratio">1</property>
+            <property name="obey-child">True</property>
+            <child>
+              <object class="GtkDrawingArea" id="preview_darea">
+                <property name="visible">True</property>
+                <signal name="expose-event" handler="on_preview_expose_event"/>
+                <signal name="configure-event" handler="on_preview_configure_event"/>
+                <signal name="button-press-event" handler="on_preview_button_press_event"/>
+                <signal name="button-release-event" handler="on_preview_button_release_event"/>
+                <signal name="drag-begin" handler="on_preview_drag_begin"/>
+                <signal name="drag-data-get" handler="on_preview_drag_data_get"/>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="padding">0</property>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkTable" id="table1">
+        <property name="visible">True</property>
+        <property name="n-rows">2</property>
+        <property name="n-columns">2</property>
+        <property name="homogeneous">False</property>
+        <property name="row-spacing">6</property>
+        <property name="column-spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">_Name:</property>
+            <property name="use-underline">True</property>
+            <property name="use-markup">False</property>
+            <property name="justify">GTK_JUSTIFY_LEFT</property>
+            <property name="wrap">False</property>
+            <property name="selectable">False</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0.5</property>
+            <property name="xpad">0</property>
+            <property name="ypad">0</property>
+            <property name="mnemonic-widget">filename_entry</property>
+          </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="right-attach">1</property>
+            <property name="top-attach">0</property>
+            <property name="bottom-attach">1</property>
+            <property name="x-options">fill</property>
+            <property name="y-options"/>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label3">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Save in _folder:</property>
+            <property name="use-underline">True</property>
+            <property name="use-markup">False</property>
+            <property name="justify">GTK_JUSTIFY_LEFT</property>
+            <property name="wrap">False</property>
+            <property name="selectable">False</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0.5</property>
+            <property name="xpad">0</property>
+            <property name="ypad">0</property>
+          </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="right-attach">1</property>
+            <property name="top-attach">1</property>
+            <property name="bottom-attach">2</property>
+            <property name="x-options">fill</property>
+            <property name="y-options"/>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkEntry" id="filename_entry">
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="editable">True</property>
+            <property name="visibility">True</property>
+            <property name="max-length">0</property>
+            <property name="text" translatable="yes"/>
+            <property name="has-frame">True</property>
+            <property name="invisible-char" translatable="yes">*</property>
+            <property name="activates-default">True</property>
+            <property name="width-chars">24</property>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="right-attach">2</property>
+            <property name="top-attach">0</property>
+            <property name="bottom-attach">1</property>
+            <property name="y-options"/>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFileChooserButton" id="file_chooser_button">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes">Select a folder</property>
+            <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+            <property name="local-only">False</property>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="right-attach">2</property>
+            <property name="top-attach">1</property>
+            <property name="bottom-attach">2</property>
+            <property name="x-options">fill</property>
+            <property name="y-options">fill</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="padding">0</property>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/src/plugins/screenshot/totem-gallery.c b/src/plugins/screenshot/totem-gallery.c
index 53e2c93..fba428c 100644
--- a/src/plugins/screenshot/totem-gallery.c
+++ b/src/plugins/screenshot/totem-gallery.c
@@ -68,6 +68,7 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
 	TotemGallery *gallery;
 	GtkWidget *container;
 	GtkBuilder *builder;
+	gchar *uri;
 
 	/* Create the gallery and its interface */
 	gallery = g_object_new (TOTEM_TYPE_GALLERY, NULL);
@@ -102,8 +103,11 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
 	container = GTK_WIDGET (gtk_builder_get_object (builder,
 				"gallery_dialog_content"));
 	gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (gallery), container);
+
 	/* Translators: the argument is a screenshot number, used to prevent overwriting files. Just translate "Screenshot", and not the ".jpg". */
-	totem_screenshot_plugin_setup_file_chooser (GTK_FILE_CHOOSER (gallery), N_("Screenshot%d.jpg"));
+	uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot%d.jpg"));
+	gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (gallery), uri);
+	g_free (uri);
 
 	gtk_widget_show_all (GTK_WIDGET (gallery));
 
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c b/src/plugins/screenshot/totem-screenshot-plugin.c
index 7a753e6..b167d76 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -106,7 +106,7 @@ take_screenshot_action_cb (GtkAction *action, TotemScreenshotPlugin *self)
 		return;
 	}
 
-	dialog = totem_screenshot_new (pixbuf);
+	dialog = totem_screenshot_new (TOTEM_PLUGIN (self), pixbuf);
 
 	gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
@@ -316,17 +316,15 @@ make_filename_for_dir (const char *directory, const char *format)
 	return filename;
 }
 
-void
-totem_screenshot_plugin_setup_file_chooser (GtkFileChooser *file_chooser, const char *filename_format)
+gchar *
+totem_screenshot_plugin_setup_file_chooser (const char *filename_format)
 {
 	GConfClient *client;
-	char *path, *filename;
+	char *path, *filename, *full, *uri;
 
 	/* Set the default path */
 	client = gconf_client_get_default ();
-	path = gconf_client_get_string (client,
-					"/apps/totem/screenshot_save_path",
-					NULL);
+	path = gconf_client_get_string (client, "/apps/totem/screenshot_save_path", NULL);
 	g_object_unref (client);
 
 	/* Default to the Pictures directory */
@@ -338,25 +336,36 @@ totem_screenshot_plugin_setup_file_chooser (GtkFileChooser *file_chooser, const
 			path = g_strdup (g_get_home_dir ());
 	}
 
-	gtk_file_chooser_set_current_folder (file_chooser, path);
 	filename = make_filename_for_dir (path, filename_format);
-	g_free (path);
 
-	gtk_file_chooser_set_current_name (file_chooser, filename);
+	/* Build the URI */
+	full = g_build_filename (path, filename, NULL);
+	g_free (path);
 	g_free (filename);
+
+	uri = g_strconcat ("file://", full, NULL);
+	g_free (full);
+
+	return uri;
 }
 
 void
-totem_screenshot_plugin_update_file_chooser (const char *filename)
+totem_screenshot_plugin_update_file_chooser (const char *uri)
 {
 	GConfClient *client;
 	char *dir;
+	GFile *file, *parent;
+
+	file = g_file_new_for_uri (uri);
+	parent = g_file_get_parent (file);
+	g_object_unref (file);
+
+	dir = g_file_get_path (parent);
+	g_object_unref (parent);
 
 	client = gconf_client_get_default ();
-	dir = g_path_get_dirname (filename);
 	gconf_client_set_string (client,
 				 "/apps/totem/screenshot_save_path",
 				 dir, NULL);
 	g_free (dir);
-	g_object_unref (client);
 }
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.h b/src/plugins/screenshot/totem-screenshot-plugin.h
index ee73db8..b8baa80 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.h
+++ b/src/plugins/screenshot/totem-screenshot-plugin.h
@@ -56,7 +56,7 @@ typedef struct {
 GType totem_screenshot_plugin_get_type (void) G_GNUC_CONST;
 G_MODULE_EXPORT GType register_totem_plugin (GTypeModule *module);
 
-void totem_screenshot_plugin_setup_file_chooser (GtkFileChooser *file_chooser, const char *filename_format);
+gchar *totem_screenshot_plugin_setup_file_chooser (const char *filename_format) G_GNUC_WARN_UNUSED_RESULT;
 void totem_screenshot_plugin_update_file_chooser (const char *filename);
 
 G_END_DECLS
diff --git a/src/plugins/screenshot/totem-screenshot.c b/src/plugins/screenshot/totem-screenshot.c
index 213eb14..ff7d0df 100644
--- a/src/plugins/screenshot/totem-screenshot.c
+++ b/src/plugins/screenshot/totem-screenshot.c
@@ -31,22 +31,16 @@
 
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
+#include <glib.h>
 #include <gtk/gtk.h>
-#include <string.h>
-#include <sys/types.h>
 #include <unistd.h>
-#include <sys/stat.h>
 
 #include "totem-interface.h"
-#include "totem-uri.h"
 #include "totem-screenshot-plugin.h"
+#include "gnome-screenshot-widget.h"
 
-struct TotemScreenshotPrivate
-{
-	GtkWidget *chooser;
-	GtkWidget *image;
-	GdkPixbuf *pixbuf, *scaled;
-	char *temp_file;
+struct TotemScreenshotPrivate {
+	GnomeScreenshotWidget *widget;
 };
 
 G_DEFINE_TYPE (TotemScreenshot, totem_screenshot, GTK_TYPE_DIALOG)
@@ -54,7 +48,8 @@ G_DEFINE_TYPE (TotemScreenshot, totem_screenshot, GTK_TYPE_DIALOG)
 static void
 totem_screenshot_temp_file_create (TotemScreenshot *screenshot)
 {
-	char *dir, *fulldir;
+	char *dir, *fulldir, *temp_filename;
+	GdkPixbuf *pixbuf;
 
 	dir = g_strdup_printf ("totem-screenshot-%d", getpid ());
 	fulldir = g_build_filename (g_get_tmp_dir (), dir, NULL);
@@ -63,116 +58,79 @@ totem_screenshot_temp_file_create (TotemScreenshot *screenshot)
 		g_free (dir);
 		return;
 	}
-	screenshot->_priv->temp_file = g_build_filename
-		(g_get_tmp_dir (),
-		 dir, _("Screenshot.png"), NULL);
-}
 
-static void
-totem_screenshot_temp_file_remove (TotemScreenshot *screenshot)
-{
-	char *dirname;
+	/* Write the screenshot to the temporary file */
+	temp_filename = g_build_filename (g_get_tmp_dir (), dir, _("Screenshot.png"), NULL);
+	pixbuf = gnome_screenshot_widget_get_screenshot (screenshot->priv->widget);
 
-	if (screenshot->_priv->temp_file == NULL)
-		return;
+	if (gdk_pixbuf_save (pixbuf, temp_filename, "png", NULL, NULL) == FALSE)
+		goto error;
 
-	unlink (screenshot->_priv->temp_file);
-	dirname = g_path_get_dirname (screenshot->_priv->temp_file);
-	rmdir (dirname);
-	g_free (dirname);
+	gnome_screenshot_widget_set_temporary_filename (screenshot->priv->widget, temp_filename);
 
-	g_free (screenshot->_priv->temp_file);
+error:
+	g_free (temp_filename);
 }
 
-
 static void
-drag_data_get (GtkWidget          *widget,
-	       GdkDragContext     *context,
-	       GtkSelectionData   *selection_data,
-	       guint               info,
-	       guint               _time,
-	       TotemScreenshot    *screenshot)
+totem_screenshot_temp_file_remove (GnomeScreenshotWidget *widget)
 {
-	char *string;
+	char *dirname;
+	const gchar *temp_filename;
 
-	/* FIXME We should cancel the drag */
-	if (screenshot->_priv->temp_file == NULL)
+	temp_filename = gnome_screenshot_widget_get_temporary_filename (widget);
+	if (temp_filename == NULL)
 		return;
 
-	string = g_strdup_printf ("file://%s\r\n",
-			screenshot->_priv->temp_file);
-	gtk_selection_data_set (selection_data,
-			selection_data->target,
-			8, (guchar *)string, strlen (string)+1);
-	g_free (string);
-}
+	g_unlink (temp_filename);
+	dirname = g_path_get_dirname (temp_filename);
+	g_rmdir (dirname);
+	g_free (dirname);
 
-static void
-drag_begin (GtkWidget *widget, GdkDragContext *context,
-		TotemScreenshot *screenshot)
-{
-	if (screenshot->_priv->temp_file == NULL)
-	{
-		gtk_drag_set_icon_pixbuf (context, screenshot->_priv->scaled,
-				0, 0);
-		totem_screenshot_temp_file_create (screenshot);
-		g_return_if_fail (screenshot->_priv->temp_file != NULL);
-		gdk_pixbuf_save (screenshot->_priv->pixbuf,
-				screenshot->_priv->temp_file, "png",
-				NULL, NULL);
-	}
+	gnome_screenshot_widget_set_temporary_filename (widget, NULL);
 }
 
 static void
 totem_screenshot_response (GtkDialog *dialog, int response)
 {
 	TotemScreenshot *screenshot = TOTEM_SCREENSHOT (dialog);
-	char *filename;
+	char *uri, *path;
+	GdkPixbuf *pixbuf;
 	GError *err = NULL;
+	GFile *file;
 
 	if (response != GTK_RESPONSE_ACCEPT)
 		return;
 
-	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (screenshot->_priv->chooser));
+	uri = gnome_screenshot_widget_get_uri (screenshot->priv->widget);
+	file = g_file_new_for_uri (uri);
+	path = g_file_get_path (file);
+
+	pixbuf = gnome_screenshot_widget_get_screenshot (screenshot->priv->widget);
 
-	if (gdk_pixbuf_save (screenshot->_priv->pixbuf, filename, "png", &err, NULL) == FALSE) {
+	if (gdk_pixbuf_save (pixbuf, path, "png", &err, NULL) == FALSE) {
 		totem_interface_error (_("There was an error saving the screenshot."),
 				       err->message,
 			 	       GTK_WINDOW (screenshot));
 		g_error_free (err);
-		g_free (filename);
+		g_free (uri);
+		g_free (path);
 		return;
 	}
 
-	totem_screenshot_plugin_update_file_chooser (filename);
-	g_free (filename);
+	totem_screenshot_plugin_update_file_chooser (uri);
+	g_free (uri);
+	g_free (path);
 }
 
 static void
 totem_screenshot_init (TotemScreenshot *screenshot)
 {
-	GtkWidget *box;
+	GtkBox *content_area;
 
-	screenshot->_priv = g_new0 (TotemScreenshotPrivate, 1);
+	screenshot->priv = G_TYPE_INSTANCE_GET_PRIVATE (screenshot, TOTEM_TYPE_SCREENSHOT, TotemScreenshotPrivate);
 
 	gtk_container_set_border_width (GTK_CONTAINER (screenshot), 5);
-
-	screenshot->_priv->chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
-	totem_add_pictures_dir (screenshot->_priv->chooser);
-	box = gtk_hbox_new (FALSE, 5);
-	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (screenshot)->vbox), box);
-	screenshot->_priv->image = gtk_image_new ();
-	gtk_box_pack_start (GTK_BOX (box),
-			    screenshot->_priv->image,
-			    FALSE,
-			    FALSE,
-			    0);
-	gtk_box_pack_start (GTK_BOX (box),
-			    screenshot->_priv->chooser,
-			    TRUE,
-			    TRUE,
-			    0);
-
 	gtk_dialog_add_buttons (GTK_DIALOG (screenshot),
 				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 				GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
@@ -180,58 +138,36 @@ totem_screenshot_init (TotemScreenshot *screenshot)
 	gtk_dialog_set_has_separator (GTK_DIALOG (screenshot), FALSE);
 	gtk_window_set_title (GTK_WINDOW (screenshot), _("Save Screenshot"));
 	gtk_dialog_set_default_response (GTK_DIALOG (screenshot), GTK_RESPONSE_ACCEPT);
+	gtk_window_set_resizable (GTK_WINDOW (screenshot), FALSE);
 
-	/* Setup the DnD for the image */
-	g_signal_connect (G_OBJECT (screenshot->_priv->image), "drag_begin",
-			G_CALLBACK (drag_begin), screenshot);
-	g_signal_connect (G_OBJECT (screenshot->_priv->image), "drag_data_get",
-			G_CALLBACK (drag_data_get), screenshot);
-	gtk_drag_source_set (GTK_WIDGET (screenshot->_priv->image),
-			GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-			NULL, 0,
-			GDK_ACTION_COPY);
-	gtk_drag_source_add_uri_targets (GTK_WIDGET (screenshot->_priv->image));
-
-	/* Set the default path and filename */
-	totem_screenshot_plugin_setup_file_chooser (GTK_FILE_CHOOSER (screenshot->_priv->chooser), N_("Screenshot%d.png"));
-
-	gtk_widget_show_all (GTK_DIALOG (screenshot)->vbox);
+	content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (screenshot)));
+	gtk_box_set_spacing (content_area, 2);
 }
 
-static void
-totem_screenshot_finalize (GObject *object)
+GtkWidget *
+totem_screenshot_new (TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image)
 {
-	TotemScreenshot *screenshot = TOTEM_SCREENSHOT (object);
-
-	g_return_if_fail (object != NULL);
-
-	totem_screenshot_temp_file_remove (screenshot);
+	TotemScreenshot *screenshot;
+	GtkContainer *content_area;
+	char *interface_path, *initial_uri;
 
-	if (screenshot->_priv->pixbuf != NULL)
-		g_object_unref (screenshot->_priv->pixbuf);
-	if (screenshot->_priv->scaled != NULL)
-		g_object_unref (screenshot->_priv->scaled);
+	screenshot = TOTEM_SCREENSHOT (g_object_new (TOTEM_TYPE_SCREENSHOT, NULL));
 
-	G_OBJECT_CLASS (totem_screenshot_parent_class)->finalize (object);
-}
+	/* Create the screenshot widget */
+	initial_uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot%d.png"));
+	interface_path = totem_plugin_find_file (screenshot_plugin, "gnome-screenshot.ui");
+	screenshot->priv->widget = GNOME_SCREENSHOT_WIDGET (gnome_screenshot_widget_new (interface_path, screen_image, initial_uri));
+	g_free (interface_path);
+	g_free (initial_uri);
 
-GtkWidget*
-totem_screenshot_new (GdkPixbuf *screen_image)
-{
-	TotemScreenshot *screenshot;
-	int width, height;
+	/* Ensure we remove the temporary file before we're destroyed */
+	g_signal_connect (screenshot->priv->widget, "destroy", G_CALLBACK (totem_screenshot_temp_file_remove), NULL);
 
-	screenshot = TOTEM_SCREENSHOT (g_object_new (TOTEM_TYPE_SCREENSHOT, NULL));
+	content_area = GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (screenshot)));
+	gtk_container_add (content_area, GTK_WIDGET (screenshot->priv->widget));
+	gtk_container_set_border_width (GTK_CONTAINER (screenshot->priv->widget), 5);
 
-	height = 200;
-	width = height * gdk_pixbuf_get_width (screen_image)
-		/ gdk_pixbuf_get_height (screen_image);
-	screenshot->_priv->pixbuf = screen_image;
-	g_object_ref (G_OBJECT (screenshot->_priv->pixbuf));
-	screenshot->_priv->scaled = gdk_pixbuf_scale_simple (screen_image,
-			width, height, GDK_INTERP_BILINEAR);
-	gtk_image_set_from_pixbuf (GTK_IMAGE (screenshot->_priv->image),
-				   screenshot->_priv->scaled);
+	totem_screenshot_temp_file_create (screenshot);
 
 	return GTK_WIDGET (screenshot);
 }
@@ -239,7 +175,7 @@ totem_screenshot_new (GdkPixbuf *screen_image)
 static void
 totem_screenshot_class_init (TotemScreenshotClass *klass)
 {
-	G_OBJECT_CLASS (klass)->finalize = totem_screenshot_finalize;
+	g_type_class_add_private (klass, sizeof (TotemScreenshotPrivate));
 	GTK_DIALOG_CLASS (klass)->response = totem_screenshot_response;
 }
 
diff --git a/src/plugins/screenshot/totem-screenshot.h b/src/plugins/screenshot/totem-screenshot.h
index 7a30cba..ebfd077 100644
--- a/src/plugins/screenshot/totem-screenshot.h
+++ b/src/plugins/screenshot/totem-screenshot.h
@@ -30,6 +30,7 @@
 #define TOTEM_SCREENSHOT_H
 
 #include <gtk/gtk.h>
+#include "totem-plugin.h"
 
 G_BEGIN_DECLS
 
@@ -39,21 +40,21 @@ G_BEGIN_DECLS
 #define TOTEM_IS_SCREENSHOT(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOTEM_TYPE_SCREENSHOT))
 #define TOTEM_IS_SCREENSHOT_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), TOTEM_TYPE_SCREENSHOT))
 
-typedef struct TotemScreenshot	       TotemScreenshot;
-typedef struct TotemScreenshotClass    TotemScreenshotClass;
-typedef struct TotemScreenshotPrivate  TotemScreenshotPrivate;
+typedef struct TotemScreenshot			TotemScreenshot;
+typedef struct TotemScreenshotClass		TotemScreenshotClass;
+typedef struct TotemScreenshotPrivate		TotemScreenshotPrivate;
 
 struct TotemScreenshot {
 	GtkDialog parent;
-	TotemScreenshotPrivate *_priv;
+	TotemScreenshotPrivate *priv;
 };
 
 struct TotemScreenshotClass {
 	GtkDialogClass parent_class;
 };
 
-GType totem_screenshot_get_type (void);
-GtkWidget *totem_screenshot_new (GdkPixbuf *playing_pix);
+GType totem_screenshot_get_type (void) G_GNUC_CONST;
+GtkWidget *totem_screenshot_new (TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image) G_GNUC_WARN_UNUSED_RESULT;
 
 G_END_DECLS
 
diff --git a/src/totem-uri.c b/src/totem-uri.c
index d825ea7..524759d 100644
--- a/src/totem-uri.c
+++ b/src/totem-uri.c
@@ -543,19 +543,6 @@ totem_add_default_dirs (GtkFileChooser *dialog)
 	}
 }
 
-void
-totem_add_pictures_dir (GtkWidget *chooser)
-{
-	const char *dir;
-
-	g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser) != FALSE);
-
-	dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
-	if (dir == NULL)
-		return;
-	gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), dir, NULL);
-}
-
 char *
 totem_add_subtitle (GtkWindow *parent, const char *path)
 {
diff --git a/src/totem-uri.h b/src/totem-uri.h
index c4d9b41..57a5b73 100644
--- a/src/totem-uri.h
+++ b/src/totem-uri.h
@@ -47,7 +47,6 @@ GSList *	totem_add_files			(GtkWindow *parent,
 						 const char *path);
 char *		totem_add_subtitle		(GtkWindow *parent, 
 						 const char *path);
-void		totem_add_pictures_dir		(GtkWidget *chooser);
 
 void totem_save_position (Totem *totem);
 void totem_try_restore_position (Totem *totem, const char *mrl);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]