[dconf-editor] Better rows popover placement.



commit 6529a7838bd2c8df4098157e71c20e02d4160954
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Jul 16 16:06:20 2016 +0200

    Better rows popover placement.

 editor/key-list-box-row.vala |   25 +++++++++++++++++++++----
 editor/registry-view.vala    |    2 +-
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 5402217..58d235a 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -24,6 +24,25 @@ private abstract class ClickableListBoxRow : EventBox
     public abstract string get_text ();
 
     /*\
+    * * Dismiss popover on window resize
+    \*/
+
+    private int width;
+
+    construct
+    {
+        size_allocate.connect (on_size_allocate);
+    }
+
+    private void on_size_allocate (Allocation allocation)
+    {
+        if (allocation.width == width)
+            return;
+        hide_right_click_popover ();
+        width = allocation.width;
+    }
+
+    /*\
     * * right click popover stuff
     \*/
 
@@ -42,7 +61,7 @@ private abstract class ClickableListBoxRow : EventBox
             ((!) nullable_popover).hide ();
     }
 
-    public void show_right_click_popover (bool delayed_apply_menu, int event_x = 0)
+    public void show_right_click_popover (bool delayed_apply_menu, int event_x = (int) (get_allocated_width 
() / 2.0))
     {
         if (nullable_popover == null)
         {
@@ -62,9 +81,7 @@ private abstract class ClickableListBoxRow : EventBox
         else if ((!) nullable_popover.visible)
             warning ("show_right_click_popover() called but popover is visible");   // TODO is called on 
multi-right-click or long Menu key press
 
-        Gdk.Rectangle rect;
-        ((!) nullable_popover).get_pointing_to (out rect);
-        rect.x = event_x;
+        Gdk.Rectangle rect = { x:event_x, y:get_allocated_height (), width:0, height:0 };
         ((!) nullable_popover).set_pointing_to (rect);
         ((!) nullable_popover).show ();
     }
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 7d19431..0589356 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -238,7 +238,7 @@ class RegistryView : Grid
         if (event.button == Gdk.BUTTON_SECONDARY)
         {
             ClickableListBoxRow row = (ClickableListBoxRow) widget;
-            row.show_right_click_popover (get_current_delay_mode (), (int) (event.x - 
row.get_allocated_width () / 2.0));
+            row.show_right_click_popover (get_current_delay_mode (), (int) (event.x));
             rows_possibly_with_popover.append (row);
         }
 


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