[dconf-editor] Merge ShortPathbar button and label.



commit 61a372f2633757ff44723998644a24d4809c6e5c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jan 7 12:15:08 2019 +0100

    Merge ShortPathbar button and label.
    
    It makes some more pixels for displaying the current path.

 editor/browser-window.vala |  2 +-
 editor/large-pathbar.css   | 10 +++++++++-
 editor/short-pathbar.ui    | 25 +++++++++++++++++++------
 editor/short-pathbar.vala  | 29 ++++++++++++++++++++++++++++-
 4 files changed, 57 insertions(+), 9 deletions(-)
---
diff --git a/editor/browser-window.vala b/editor/browser-window.vala
index d223936..ad24b96 100644
--- a/editor/browser-window.vala
+++ b/editor/browser-window.vala
@@ -650,7 +650,7 @@ private abstract class BrowserWindow : BaseWindow
             return;
 
         init_next_search = true;
-        request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);
+        request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);   // TODO make pressing multiple 
time <ctrl><shift>l select one more parent folder each time
     }
 
     /*\
diff --git a/editor/large-pathbar.css b/editor/large-pathbar.css
index 3a16360..1a41656 100644
--- a/editor/large-pathbar.css
+++ b/editor/large-pathbar.css
@@ -73,7 +73,7 @@ box.pathbar         > label {
   color:currentColor;
 }
 
-.pathbar            > button.invisible {
+button.invisible {
   padding:0;
   min-width:0;
 
@@ -85,6 +85,14 @@ box.pathbar         > label {
   color:currentColor;
 }
 
+button.invisible.invisible-menu-button {
+  background-repeat:no-repeat;
+  background-size:1.1rem;
+  background-image:-gtk-icontheme("pan-down-symbolic");
+}
+button.invisible.invisible-menu-button:dir(ltr) { padding-left :1.4rem; background-position:0    center; }
+button.invisible.invisible-menu-button:dir(rtl) { padding-right:1.4rem; background-position:100% center; }
+
 /* items hacks */
 .small-window.startup .pathbar  > button                        > label.item { /* class remove after 0.3s */
   transition:padding             0s;
diff --git a/editor/short-pathbar.ui b/editor/short-pathbar.ui
index 8c079b3..36280d7 100644
--- a/editor/short-pathbar.ui
+++ b/editor/short-pathbar.ui
@@ -4,7 +4,7 @@
   <template class="ShortPathbar" parent="GtkGrid">
     <property name="orientation">horizontal</property>
     <property name="column-spacing">6</property>
-    <child>
+    <!-- child>
       <object class="GtkMenuButton" id="menu_button">
         <property name="visible">True</property>
         <style>
@@ -17,21 +17,34 @@
             <property name="icon-size">1</property>
           </object>
         </child>
-        <!-- child internal-child="accessible">
+        <! child internal-child="accessible">
           <object class="AtkObject">
             < Translators: ... >
             <property name="AtkObject::accessible-name" translatable="yes">Search</property>
             < Translators: ... >
             <property name="AtkObject::accessible-description" translatable="yes">Search keys</property>
           </object>
-        </child -->
+        </child >
       </object>
-    </child>
+    </child -->
     <child>
-      <object class="GtkLabel" id="view_label">
+      <object class="GtkMenuButton" id="menu_button">
         <property name="visible">True</property>
+        <property name="hexpand">True</property>
         <property name="xalign">0</property>
-        <property name="ellipsize">end</property>
+        <signal name="button-press-event" handler="on_button_press_event"/>
+        <signal name="clicked"            handler="on_button_clicked"/>
+        <style>
+          <class name="invisible"/>
+          <class name="invisible-menu-button"/>
+        </style>
+        <child>
+          <object class="GtkLabel" id="view_label">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="ellipsize">end</property>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/editor/short-pathbar.vala b/editor/short-pathbar.vala
index f02496a..7f585c2 100644
--- a/editor/short-pathbar.vala
+++ b/editor/short-pathbar.vala
@@ -18,7 +18,7 @@
 using Gtk;
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/short-pathbar.ui")]
-private class ShortPathbar : Grid, Pathbar
+private class ShortPathbar : Grid, Pathbar  // TODO make MenuButton?
 {
     private string non_ghost_path = "";
 
@@ -47,6 +47,33 @@ private class ShortPathbar : Grid, Pathbar
         set_path (type, path);
     }
 
+    /*\
+    * * callbacks
+    \*/
+
+    private int event_x = 0;
+
+    [GtkCallback]
+    private bool on_button_press_event (Widget widget, Gdk.EventButton event)
+    {
+        event_x = (int) event.x;
+        return false;
+    }
+
+    [GtkCallback]
+    private void on_button_clicked (Button button)
+    {
+        MenuButton menu_button = (MenuButton) button;
+        Popover? popover = menu_button.get_popover ();
+        if (popover == null)
+            assert_not_reached ();
+
+        Allocation allocation;
+        menu_button.get_allocated_size (out allocation, null);
+        Gdk.Rectangle rect = { x:event_x, y:allocation.height, width:0, height:0 };
+        ((!) popover).set_pointing_to (rect);
+    }
+
     /*\
     * * keyboard
     \*/


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