[dconf-editor] Use GAction in Bookmark.



commit 1233608e286d3c6679ec130b3031af4a0eb48b6c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Nov 24 15:19:47 2017 +0100

    Use GAction in Bookmark.

 editor/bookmark.ui       |   64 +++++++++++++++++++++++++---------------------
 editor/bookmarks.ui      |    1 -
 editor/bookmarks.vala    |   13 ++-------
 editor/dconf-editor.ui   |    1 -
 editor/dconf-window.vala |    2 +
 5 files changed, 40 insertions(+), 41 deletions(-)
---
diff --git a/editor/bookmark.ui b/editor/bookmark.ui
index ca25894..180993c 100644
--- a/editor/bookmark.ui
+++ b/editor/bookmark.ui
@@ -1,41 +1,47 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface domain="dconf-editor">
   <!-- interface-requires gtk+ 3.0 -->
-  <template class="Bookmark" parent="GtkGrid">
-    <property name="orientation">horizontal</property>
-    <property name="column-spacing">2</property>
-    <property name="margin-start">8</property>
+  <template class="Bookmark" parent="GtkListBoxRow">
+    <property name="action-name">ui.open-path</property>
     <child>
-      <object class="GtkLabel" id="bookmark_label">
+      <object class="GtkGrid">
         <property name="visible">True</property>
-        <property name="hexpand">True</property>
-        <property name="halign">start</property>
-        <property name="max-width-chars">42</property>
-        <property name="ellipsize">PANGO_ELLIPSIZE_START</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkButton" id="destroy_button">
-        <property name="visible">True</property>
-        <property name="margin">2</property>
-        <property name="valign">center</property>
-        <property name="vexpand">True</property>
-        <style>
-          <class name="image-button"/>
-          <class name="circular"/>
-          <class name="flat"/>
-        </style>
-        <child internal-child="accessible">
-          <object class="AtkObject">
-            <property name="AtkObject::accessible-name" translatable="yes">Remove</property>
-            <property name="AtkObject::accessible-description" translatable="yes">Remove this 
bookmark</property>
+        <property name="orientation">horizontal</property>
+        <property name="column-spacing">2</property>
+        <property name="margin-start">8</property>
+        <child>
+          <object class="GtkLabel" id="bookmark_label">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+            <property name="halign">start</property>
+            <property name="max-width-chars">42</property>
+            <property name="ellipsize">PANGO_ELLIPSIZE_START</property>
           </object>
         </child>
         <child>
-          <object class="GtkImage">
+          <object class="GtkButton" id="destroy_button">
             <property name="visible">True</property>
-            <property name="icon-size">1</property>
-            <property name="icon-name">window-close-symbolic</property>
+            <property name="margin">2</property>
+            <property name="valign">center</property>
+            <property name="vexpand">True</property>
+            <style>
+              <class name="image-button"/>
+              <class name="circular"/>
+              <class name="flat"/>
+            </style>
+            <child internal-child="accessible">
+              <object class="AtkObject">
+                <property name="AtkObject::accessible-name" translatable="yes">Remove</property>
+                <property name="AtkObject::accessible-description" translatable="yes">Remove this 
bookmark</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-size">1</property>
+                <property name="icon-name">window-close-symbolic</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/editor/bookmarks.ui b/editor/bookmarks.ui
index 0c0beeb..346b101 100644
--- a/editor/bookmarks.ui
+++ b/editor/bookmarks.ui
@@ -55,7 +55,6 @@
               <object class="GtkListBox" id="bookmarks_list_box">
                 <property name="visible">True</property>
                 <property name="activate-on-single-click">True</property>
-                <signal name="row-activated" handler="bookmark_activated_cb"/>
                 <child type="placeholder">
                   <object class="RegistryPlaceholder">
                     <property name="label" translatable="yes">Bookmarks will
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index fd5840c..e014b14 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -18,7 +18,7 @@
 using Gtk;
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/bookmarks.ui")]
-public class Bookmarks : MenuButton, PathElement
+public class Bookmarks : MenuButton
 {
     [GtkChild] private ListBox bookmarks_list_box;
     [GtkChild] private Popover bookmarks_popover;
@@ -94,6 +94,7 @@ public class Bookmarks : MenuButton, PathElement
             unduplicated_bookmarks += bookmark;
 
             Bookmark bookmark_row = new Bookmark (bookmark);
+            bookmark_row.action_target = bookmark;
             ulong destroy_button_clicked_handler = bookmark_row.destroy_button.clicked.connect (() => 
remove_bookmark (bookmark));
             bookmark_row.destroy_button.destroy.connect (() => bookmark_row.destroy_button.disconnect 
(destroy_button_clicked_handler));
             bookmark_row.show ();
@@ -127,14 +128,6 @@ public class Bookmarks : MenuButton, PathElement
             bookmarked_switch.set_active (new_state);
     }
 
-    [GtkCallback]
-    private void bookmark_activated_cb (ListBoxRow list_box_row)
-    {
-        bookmarks_popover.closed ();
-        string bookmark = ((Bookmark) list_box_row.get_child ()).bookmark_name;
-        request_path (bookmark);
-    }
-
     private void remove_bookmark (string bookmark_name)
     {
         bookmarks_popover.closed ();
@@ -150,7 +143,7 @@ public class Bookmarks : MenuButton, PathElement
 }
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/bookmark.ui")]
-private class Bookmark : Grid
+private class Bookmark : ListBoxRow
 {
     public string bookmark_name { get; construct; }
 
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index c968624..c618f7e 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -83,7 +83,6 @@
             <property name="focus-on-click">False</property>
             <property name="schema-id">ca.desrt.dconf-editor.Settings</property>
             <property name="sensitive" bind-source="search-toggle" bind-property="active" 
bind-flags="sync-create|invert-boolean"/>
-            <signal name="request_path" handler="request_path"/>
             <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
             <style>
               <class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731 -->
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 9d53ac5..a46cc8e 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -372,6 +372,8 @@ class DConfWindow : ApplicationWindow
     private void open_path (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
+        if (bookmarks_button.active)
+            bookmarks_button.active = false;
         request_path (((!) path_variant).get_string ());
     }
 


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