[sushi] text: properly block right click button-press-event



commit 47c7de68cdf12012f2004c0d563374f89f1bcba2
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jul 22 12:35:32 2015 -0700

    text: properly block right click button-press-event
    
    We used to destroy the menu as a workaround that we could not introspect
    the event button.
    Now that we can do that, just eat right click events.
    This fixes a crash when right clicking with recent GtkSourceView

 src/js/viewers/text.js |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/js/viewers/text.js b/src/js/viewers/text.js
index 291d51b..2410ec9 100644
--- a/src/js/viewers/text.js
+++ b/src/js/viewers/text.js
@@ -23,6 +23,7 @@
  *
  */
 
+const Gdk = imports.gi.Gdk;
 const GtkClutter = imports.gi.GtkClutter;
 const Gtk = imports.gi.Gtk;
 const GLib = imports.gi.GLib;
@@ -84,13 +85,13 @@ const TextRenderer = new Lang.Class({
         if (this._buffer.get_language())
             this._view.set_show_line_numbers(true);
 
-        // FIXME: *very* ugly wokaround to the fact that we can't
-        // access event.button from a button-press callback to block
-        // right click
-        this._view.connect('populate-popup',
-                           Lang.bind(this, function(widget, menu) {
-                               menu.destroy();
-                           }));
+        this._view.connect('button-press-event', Lang.bind(this, function(view, event) {
+            let [, button] = event.get_button();
+            if (button == Gdk.BUTTON_SECONDARY)
+                return true;
+
+            return false;
+        }));
 
         this._scrolledWin = Gtk.ScrolledWindow.new(null, null);
         this._scrolledWin.add(this._view);


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