[eog] Add Copy Image and Copy Path to clipboard functionality



commit 0b209b1ff16e863e60a1d86413aa57c5fbde76b0
Author: Adrian Hands <handsadrian gmail com>
Date:   Fri Dec 31 14:34:58 2010 +0100

    Add Copy Image and Copy Path to clipboard functionality
    
    Fixes bug 78514.

 data/eog-ui.xml  |    9 +++++++
 src/eog-window.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/data/eog-ui.xml b/data/eog-ui.xml
index abfa405..9d43fc9 100644
--- a/data/eog-ui.xml
+++ b/data/eog-ui.xml
@@ -22,6 +22,9 @@
     <menu action="Edit">
       <menuitem action="EditUndo"/>
       <separator/>
+      <menuitem action="EditCopyImage"/>
+      <menuitem action="EditCopyPath"/>
+      <separator/>
       <menuitem action="EditFlipHorizontal"/>
       <menuitem action="EditFlipVertical"/>
       <separator/>
@@ -113,6 +116,9 @@
     <separator/>
     <menuitem action="ImagePrint"/>
     <separator/>
+    <menuitem action="EditCopyImage"/>
+    <menuitem action="EditCopyPath"/>
+    <separator/>
     <menuitem action="EditMoveToTrash"/>
     <separator/>
     <menuitem action="ImageProperties"/>
@@ -129,6 +135,9 @@
     <separator/>
     <menuitem action="ImagePrint"/>
     <separator/>
+    <menuitem action="EditCopyImage"/>
+    <menuitem action="EditCopyPath"/>
+    <separator/>
     <menuitem action="EditMoveToTrash"/>
     <separator/>
     <menuitem action="ImageProperties"/>
diff --git a/src/eog-window.c b/src/eog-window.c
index ea72674..3e9ce0e 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -3295,6 +3295,63 @@ move_to_trash_real (EogImage *image, GError **error)
 }
 
 static void
+eog_window_cmd_copy_path (GtkAction *action, gpointer user_data)
+{
+	EogWindow *window;
+	EogWindowPrivate *priv;
+	EogImage *image;
+	GFile *file;
+	char *filename = NULL;
+	GtkClipboard *clipboard;
+
+	g_return_if_fail (EOG_IS_WINDOW (user_data));
+
+	window = EOG_WINDOW (user_data);
+	priv = window->priv;
+
+	image = eog_thumb_view_get_first_selected_image (EOG_THUMB_VIEW (priv->thumbview));
+
+	g_return_if_fail (EOG_IS_IMAGE (image));
+
+	file = eog_image_get_file (image);
+
+	filename = g_file_get_path (file);
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+	gtk_clipboard_set_text (clipboard, filename, -1);
+
+	g_object_unref (file);
+	g_free (filename);
+
+}
+
+static void
+eog_window_cmd_copy_image (GtkAction *action, gpointer user_data)
+{
+	GtkClipboard *clipboard;
+	GdkPixbuf *pix;
+	EogWindow *window;
+	EogWindowPrivate *priv;
+	EogImage *image;
+
+	g_return_if_fail (EOG_IS_WINDOW (user_data));
+
+	window = EOG_WINDOW (user_data);
+	priv = window->priv;
+
+	image = eog_thumb_view_get_first_selected_image (EOG_THUMB_VIEW (priv->thumbview));
+
+	g_return_if_fail (EOG_IS_IMAGE (image));
+
+	pix = eog_image_get_pixbuf (image);
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+	gtk_clipboard_set_image (clipboard, pix);
+
+	g_object_unref (pix);
+}
+
+static void
 eog_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
 {
 	GList *images;
@@ -3682,6 +3739,12 @@ static const GtkActionEntry action_entries_image[] = {
 	{ "EditMoveToTrash", "user-trash", N_("Move to _Trash"), NULL,
 	  N_("Move the selected image to the trash folder"),
 	  G_CALLBACK (eog_window_cmd_move_to_trash) },
+	{ "EditCopyPath", NULL, N_("Copy _Path"), NULL,
+	  N_("Copy the image file path to the clipboard"),
+	  G_CALLBACK (eog_window_cmd_copy_path) },
+	{ "EditCopyImage", NULL, N_("Copy _Image"), NULL,
+	  N_("Copy the image to the clipboard"),
+	  G_CALLBACK (eog_window_cmd_copy_image) },
 	{ "ViewZoomIn", GTK_STOCK_ZOOM_IN, N_("_Zoom In"), "<control>plus",
 	  N_("Enlarge the image"),
 	  G_CALLBACK (eog_window_cmd_zoom_in) },



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