[gnome-documents/wip/abono/selectionToolbar: 5/6] selections: Port to templates



commit c3690f302155841db2ba14ae7969cbe41e76519b
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Mon Nov 9 23:07:06 2015 +0100

    selections: Port to templates

 data/org.gnome.Documents.data.gresource.xml |    1 +
 data/ui/selection-toolbar.ui                |   62 +++++++++++++++++++++++++++
 po/POTFILES.in                              |    1 +
 src/selections.js                           |   40 +++++------------
 4 files changed, 75 insertions(+), 29 deletions(-)
---
diff --git a/data/org.gnome.Documents.data.gresource.xml b/data/org.gnome.Documents.data.gresource.xml
index 506a0f0..1723215 100644
--- a/data/org.gnome.Documents.data.gresource.xml
+++ b/data/org.gnome.Documents.data.gresource.xml
@@ -7,6 +7,7 @@
     <file preprocess="xml-stripblanks">ui/preview-context-menu.ui</file>
     <file preprocess="xml-stripblanks">ui/preview-menu.ui</file>
     <file preprocess="xml-stripblanks">ui/selection-menu.ui</file>
+    <file preprocess="xml-stripblanks">ui/selection-toolbar.ui</file>
     <file alias="ui/dnd-counter.svg" preprocess="to-pixdata">media/dnd-counter.svg</file>
     <file alias="ui/thumbnail-frame.png" preprocess="to-pixdata">media/thumbnail-frame.png</file>
   </gresource>
diff --git a/data/ui/selection-toolbar.ui b/data/ui/selection-toolbar.ui
new file mode 100644
index 0000000..7796f0e
--- /dev/null
+++ b/data/ui/selection-toolbar.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.11 -->
+  <template class="Gjs_SelectionToolbar" parent="GtkActionBar">
+    <property name="visible">False</property>
+      <child>
+        <object class="GtkButton" id="toolbarOpen">
+          <property name="visible">True</property>
+         <property name="label" translatable="yes">Open</property>
+        </object>
+        <packing>
+          <property name="pack_type">start</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkButton" id="toolbarPrint">
+          <property name="visible">True</property>
+         <property name="label" translatable="yes">Print</property>
+        </object>
+        <packing>
+          <property name="pack_type">start</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkButton" id="toolbarTrash">
+          <property name="visible">True</property>
+         <property name="label" translatable="yes">Delete</property>
+        </object>
+        <packing>
+          <property name="pack_type">start</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkButton" id="toolbarShare">
+          <property name="visible">False</property>
+          <property name="no-show-all">True</property>
+         <property name="label" translatable="yes">Share</property>
+        </object>
+        <packing>
+          <property name="pack_type">end</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkButton" id="toolbarProperties">
+          <property name="visible">True</property>
+         <property name="label" translatable="yes">Properties</property>
+        </object>
+        <packing>
+          <property name="pack_type">end</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkButton" id="toolbarCollection">
+          <property name="visible">True</property>
+         <property name="label" translatable="yes">Collections</property>
+        </object>
+        <packing>
+          <property name="pack_type">end</property>
+        </packing>
+      </child>
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5d673b0..9f0bfad 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,6 +10,7 @@ data/org.gnome.documents.gschema.xml
 [type: gettext/glade]data/ui/preview-context-menu.ui
 [type: gettext/glade]data/ui/preview-menu.ui
 [type: gettext/glade]data/ui/selection-menu.ui
+[type: gettext/glade]data/ui/selection-toolbar.ui
 src/application.js
 src/documents.js
 src/edit.js
diff --git a/src/selections.js b/src/selections.js
index e92d858..e303eef 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -861,6 +861,13 @@ const _SELECTION_TOOLBAR_DEFAULT_WIDTH = 500;
 const SelectionToolbar = new Lang.Class({
     Name: 'SelectionToolbar',
     Extends: Gtk.ActionBar,
+    Template: 'resource:///org/gnome/Documents/ui/selection-toolbar.ui',
+    InternalChildren: [ 'toolbarOpen',
+                        'toolbarPrint',
+                        'toolbarTrash',
+                        'toolbarShare',
+                        'toolbarProperties',
+                        'toolbarCollection' ],
 
     _init: function() {
         this._itemListeners = {};
@@ -868,43 +875,18 @@ const SelectionToolbar = new Lang.Class({
 
         this.parent();
 
-        // open button
-        this._toolbarOpen = new Gtk.Button({ label: _("Open") });
-        this._toolbarOpen.show();
-        this.pack_start(this._toolbarOpen);
-        this._toolbarOpen.connect('clicked', Lang.bind(this, this._onToolbarOpen));
 
-        // print button
-        this._toolbarPrint = new Gtk.Button({ label: _("Print") });
-        this._toolbarPrint.show();
-        this.pack_start(this._toolbarPrint);
+        this._toolbarOpen.connect('clicked', Lang.bind(this, this._onToolbarOpen));
         this._toolbarPrint.connect('clicked', Lang.bind(this, this._onToolbarPrint));
-
-        // trash button
-        this._toolbarTrash = new Gtk.Button({ label: _("Delete") });
-        this._toolbarTrash.show();
-        this.pack_start(this._toolbarTrash);
         this._toolbarTrash.connect('clicked', Lang.bind(this, this._onToolbarTrash));
 
-        // share button
         if (!Application.application.isBooks) {
-            this._toolbarShare = new Gtk.Button({ label: _("Share") });
-            this._toolbarShare.show();
-            this.pack_end(this._toolbarShare);
             this._toolbarShare.connect('clicked', Lang.bind(this, this._onToolbarShare));
+            this._toolbarShare.show();
         }
-
-        // properties button
-        this._toolbarProperties = new Gtk.Button({ label: _("Properties") });
-        this._toolbarProperties.show();
-        this.pack_end(this._toolbarProperties);
         this._toolbarProperties.connect('clicked', Lang.bind(this, this._onToolbarProperties));
-
-        // collections button
-        this._toolbarCollection = new Gtk.Button({ label: _("Collections") });
-        this._toolbarCollection.show();
-        this.pack_end(this._toolbarCollection);
         this._toolbarCollection.connect('clicked', Lang.bind(this, this._onToolbarCollection));
+
         Application.modeController.connect('window-mode-changed',
             Lang.bind(this, this._updateCollectionsButton));
         Application.documentManager.connect('active-collection-changed',
@@ -1009,7 +991,7 @@ const SelectionToolbar = new Lang.Class({
         this._toolbarProperties.set_sensitive(showProperties);
         this._toolbarTrash.set_sensitive(showTrash);
         this._toolbarOpen.set_sensitive(showOpen);
-        if (this._toolbarShare)
+        if (!Application.application.isBooks)
             this._toolbarShare.set_sensitive(showShare);
         this._toolbarCollection.set_sensitive(showCollection);
 


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