[gnome-boxes] collection-toolbar: Add list view buttons
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] collection-toolbar: Add list view buttons
- Date: Sat, 22 Aug 2015 12:12:04 +0000 (UTC)
commit b8a71e081998017eb7f9b95ad80de6877e6d2b80
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Mar 6 15:43:27 2015 +0100
collection-toolbar: Add list view buttons
Add buttons to the collection toolbar to switch between the collection
view's list and icon modes.
https://bugzilla.gnome.org/show_bug.cgi?id=733252
data/ui/collection-toolbar.ui | 56 +++++++++++++++++++++++++++++++++++++++++
src/collection-toolbar.vala | 26 +++++++++++++++++++
2 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/collection-toolbar.ui b/data/ui/collection-toolbar.ui
index 77fd751..e6862ff 100644
--- a/data/ui/collection-toolbar.ui
+++ b/data/ui/collection-toolbar.ui
@@ -80,6 +80,62 @@
</child>
<child>
+ <object class="GtkButton" id="list_btn">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <signal name="clicked" handler="on_list_btn_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-button4">
+ <property name="accessible-name" translatable="yes">List view</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="list_image">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="grid_btn">
+ <property name="visible">False</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <signal name="clicked" handler="on_grid_btn_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-button5">
+ <property name="accessible-name" translatable="yes">Grid view</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="grid_image">
+ <property name="visible">True</property>
+ <property name="icon-name">view-grid-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
<object class="GtkToggleButton" id="search_btn">
<property name="visible">True</property>
<property name="valign">center</property>
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index d92918b..8b65827 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -8,6 +8,10 @@ private class Boxes.CollectionToolbar: HeaderBar {
[GtkChild]
private Button select_btn;
[GtkChild]
+ private Button list_btn;
+ [GtkChild]
+ private Button grid_btn;
+ [GtkChild]
private Button back_btn;
[GtkChild]
private Button new_btn;
@@ -27,6 +31,8 @@ private class Boxes.CollectionToolbar: HeaderBar {
App.app.collection.item_added.connect (update_search_btn);
App.app.collection.item_removed.connect (update_search_btn);
+ update_view_type (AppWindow.ViewType.ICON);
+
search_btn.bind_property ("active", window.searchbar, "search-mode-enabled",
BindingFlags.BIDIRECTIONAL);
window.notify["ui-state"].connect (ui_state_changed);
@@ -58,6 +64,16 @@ private class Boxes.CollectionToolbar: HeaderBar {
}
[GtkCallback]
+ private void on_list_btn_clicked () {
+ update_view_type (AppWindow.ViewType.LIST);
+ }
+
+ [GtkCallback]
+ private void on_grid_btn_clicked () {
+ update_view_type (AppWindow.ViewType.ICON);
+ }
+
+ [GtkCallback]
private void on_select_btn_clicked () {
window.selection_mode = true;
}
@@ -70,6 +86,12 @@ private class Boxes.CollectionToolbar: HeaderBar {
select_btn.sensitive = App.app.collection.items.length != 0;
}
+ private void update_view_type (AppWindow.ViewType view_type) {
+ window.view_type = view_type;
+
+ ui_state_changed ();
+ }
+
private void ui_state_changed () {
switch (window.ui_state) {
case UIState.COLLECTION:
@@ -77,6 +99,8 @@ private class Boxes.CollectionToolbar: HeaderBar {
select_btn.show ();
search_btn.show ();
new_btn.show ();
+ grid_btn.visible = window.view_type != AppWindow.ViewType.ICON;
+ list_btn.visible = window.view_type != AppWindow.ViewType.LIST;
custom_title = filter_switcher;
break;
@@ -85,6 +109,8 @@ private class Boxes.CollectionToolbar: HeaderBar {
back_btn.visible = (window == App.app.main_window);
select_btn.hide ();
search_btn.hide ();
+ grid_btn.hide ();
+ list_btn.hide ();
custom_title = null;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]