[gnome-commander] Context popup menu for internal viewer



commit 590d3d63a3fee62e951802c94e558833fd5e77b7
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Jan 22 23:09:34 2011 +0100

    Context popup menu for internal viewer

 NEWS                           |    1 +
 doc/C/gnome-commander.xml      |    3 +++
 src/intviewer/viewer-widget.cc |   26 ++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5f25aa9..762771d 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ New features:
  * User defined LS_COLORS colours
  * Enhanced file name matching in quick search
  * Open terminal with administrator privileges
+ * Context popup menu for internal viewer
  * --config-dir command line option for customized location of config files
  * New or updated docs: de, en, es, fr, sl
  * New or updated translations: cs, da, es, eu, fr, hu, ko, nb, pl, pt_BR, ro, ru, sl, uk, zh_CN
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 94b902c..c4382be 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -7571,6 +7571,9 @@
                             <para>Open terminal with administrator privileges</para>
                         </listitem>
                         <listitem>
+                            <para>Context popup menu for internal viewer</para>
+                        </listitem>
+                        <listitem>
                             <para>--config-dir command line option for customized location of config files</para>
                         </listitem>
                         <listitem>
diff --git a/src/intviewer/viewer-widget.cc b/src/intviewer/viewer-widget.cc
index a856a2b..44fb256 100644
--- a/src/intviewer/viewer-widget.cc
+++ b/src/intviewer/viewer-widget.cc
@@ -85,6 +85,7 @@ static void gviewer_destroy (GtkObject *object);
 
 static void gviewer_text_status_update(TextRender *obj, TextRenderStatus *status, GViewer *viewer);
 static void gviewer_image_status_update(ImageRender *obj, ImageRenderStatus *status, GViewer *viewer);
+static gboolean on_text_viewer_button_pressed (GtkWidget *treeview, GdkEventButton *event, GViewer *viewer);
 
 static VIEWERDISPLAYMODE guess_display_mode(const unsigned char *data, int len);
 static void gviewer_auto_detect_display_mode(GViewer *obj);
@@ -192,6 +193,8 @@ static void gviewer_init (GViewer *w)
 
     g_signal_connect (w->priv->textr, "text-status-changed", G_CALLBACK (gviewer_text_status_update), w);
     g_signal_connect (w->priv->imgr, "image-status-changed", G_CALLBACK (gviewer_image_status_update), w);
+
+    g_signal_connect (w->priv->textr, "button-press-event", G_CALLBACK (on_text_viewer_button_pressed), w);
 }
 
 
@@ -247,6 +250,29 @@ static void gviewer_image_status_update(ImageRender *obj, ImageRenderStatus *sta
 }
 
 
+
+static gboolean on_text_viewer_button_pressed (GtkWidget *treeview, GdkEventButton *event, GViewer *viewer)
+{
+    if (event->type==GDK_BUTTON_PRESS && event->button==3)
+    {
+        GtkWidget *menu = gtk_menu_new ();
+        GtkWidget *menuitem;
+
+        menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Copy selection"));
+        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU));
+        g_signal_connect (menuitem, "activate", G_CALLBACK (gviewer_copy_selection), viewer);
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+        gtk_widget_show_all (menu);
+        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+
 static void gviewer_destroy (GtkObject *widget)
 {
     g_return_if_fail (widget!= NULL);



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