[gitg] Add back diff options popover



commit 2a170059a4b24cc8e83e9c7fd86f8e2b9bf129d1
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Thu Aug 27 19:31:54 2015 +0200

    Add back diff options popover

 libgitg/Makefile.am                    |    1 +
 libgitg/gitg-diff-view.vala            |   45 ++++++++++++++++++++++++++++++++
 libgitg/resources/ui/gitg-diff-view.ui |    1 +
 3 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/Makefile.am b/libgitg/Makefile.am
index 6c7383f..15ff118 100644
--- a/libgitg/Makefile.am
+++ b/libgitg/Makefile.am
@@ -61,6 +61,7 @@ libgitg_libgitg_1_0_la_VALASOURCES =                  \
        libgitg/gitg-diff-view-hunk.vala                \
        libgitg/gitg-diff-view-lines-renderer.vala      \
        libgitg/gitg-diff-view-commit-details.vala      \
+       libgitg/gitg-diff-view-options.vala             \
        libgitg/gitg-hook.vala                          \
        libgitg/gitg-init.vala                          \
        libgitg/gitg-label-renderer.vala                \
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 14b3846..770d73e 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -400,6 +400,51 @@ public class Gitg.DiffView : Gtk.Grid
                // TODO
                return new PatchSet[] {};
        }
+
+       private void do_popup(Gdk.EventButton? event)
+       {
+               var popover = new Gtk.Popover(this);
+               var opts = new DiffViewOptions(this);
+
+               popover.add(opts);
+
+               if (event != null)
+               {
+                       var r = Gdk.Rectangle() {
+                               x = (int)event.x,
+                               y = (int)event.y,
+                               width = 1,
+                               height = 1
+                       };
+
+                       popover.set_pointing_to(r);
+               }
+
+               opts.show();
+               popover.show();
+
+               popover.notify["visible"].connect(() => {
+                       popover.destroy();
+               });
+       }
+
+       [GtkCallback]
+       private bool button_press_event_handler(Gdk.EventButton event)
+       {
+               if (event.triggers_context_menu() && event.type == Gdk.EventType.BUTTON_PRESS)
+               {
+                       do_popup(event);
+                       return true;
+               }
+
+               return false;
+       }
+
+       protected override bool popup_menu()
+       {
+               do_popup(null);
+               return true;
+       }
 }
 
 // ex:ts=4 noet
diff --git a/libgitg/resources/ui/gitg-diff-view.ui b/libgitg/resources/ui/gitg-diff-view.ui
index b373912..64b2ee0 100644
--- a/libgitg/resources/ui/gitg-diff-view.ui
+++ b/libgitg/resources/ui/gitg-diff-view.ui
@@ -8,6 +8,7 @@
     <property name="orientation">vertical</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
+    <signal name="button-press-event" handler="button_press_event_handler" />
     <child>
       <object class="GitgDiffViewCommitDetails" id="commit_details">
         <property name="visible">True</property>


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