[polari/wip/fmuellner/roomlist-filtering: 2/12] serverRoomList: Use a template
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/roomlist-filtering: 2/12] serverRoomList: Use a template
- Date: Mon, 13 Mar 2017 02:50:59 +0000 (UTC)
commit b8e06e9e8cb99952a25c124f03bd743700b74b30
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Mar 11 22:13:40 2017 +0100
serverRoomList: Use a template
We will soon move some bits from the joinDialog hierarchy into the
serverRoomList, so it's a good time to make it use a template - though
moving the tedious TreeView setup out of the code is already quite nice
by itself ...
https://bugzilla.gnome.org/show_bug.cgi?id=779940
data/org.gnome.Polari.data.gresource.xml | 1 +
data/resources/server-room-list.ui | 69 ++++++++++++++++++++++++++++++
src/serverRoomManager.js | 38 +---------------
3 files changed, 72 insertions(+), 36 deletions(-)
---
diff --git a/data/org.gnome.Polari.data.gresource.xml b/data/org.gnome.Polari.data.gresource.xml
index b21bb85..f06c123 100644
--- a/data/org.gnome.Polari.data.gresource.xml
+++ b/data/org.gnome.Polari.data.gresource.xml
@@ -13,6 +13,7 @@
<file alias="ui/main-window.ui" preprocess="xml-stripblanks">resources/main-window.ui</file>
<file alias="ui/room-list-header.ui" preprocess="xml-stripblanks">resources/room-list-header.ui</file>
<file alias="ui/room-list-row.ui" preprocess="xml-stripblanks">resources/room-list-row.ui</file>
+ <file alias="ui/server-room-list.ui" preprocess="xml-stripblanks">resources/server-room-list.ui</file>
<file alias="ui/user-details.ui" preprocess="xml-stripblanks">resources/user-details.ui</file>
<file alias="ui/user-popover.ui" preprocess="xml-stripblanks">resources/user-popover.ui</file>
</gresource>
diff --git a/data/resources/server-room-list.ui b/data/resources/server-room-list.ui
new file mode 100644
index 0000000..18bdbf7
--- /dev/null
+++ b/data/resources/server-room-list.ui
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkListStore" id="store">
+ <columns>
+ <!-- column-name checked -->
+ <column type="gboolean"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name count -->
+ <column type="gchararray"/>
+ <!-- column-name sensitive -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
+ <template class="Gjs_ServerRoomList" parent="GtkScrolledWindow">
+ <property name="vexpand">True</property>
+ <property name="hscrollbar-policy">never</property>
+ <child>
+ <object class="GtkTreeView" id="list">
+ <property name="visible">True</property>
+ <property name="model">store</property>
+ <property name="activate-on-single-click">True</property>
+ <property name="enable-grid-lines">horizontal</property>
+ <property name="headers-visible">False</property>
+ <style>
+ <class name="polari-server-room-list"/>
+ </style>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <child>
+ <object class="GtkCellRendererToggle"/>
+ <attributes>
+ <attribute name="active">0</attribute>
+ <attribute name="sensitive">3</attribute>
+ </attributes>
+ <cell-packing>
+ <property name="expand">False</property>
+ </cell-packing>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="text">1</attribute>
+ <attribute name="sensitive">3</attribute>
+ </attributes>
+ <cell-packing>
+ <property name="expand">True</property>
+ </cell-packing>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="xalign">1.0</property>
+ </object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ <attribute name="sensitive">3</attribute>
+ </attributes>
+ <cell-packing>
+ <property name="expand">False</property>
+ </cell-packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index 16c3c50..6f02b33 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -110,6 +110,8 @@ const RoomListColumn = {
const ServerRoomList = new Lang.Class({
Name: 'ServerRoomList',
Extends: Gtk.ScrolledWindow,
+ Template: 'resource:///org/gnome/Polari/ui/server-room-list.ui',
+ InternalChildren: ['list'],
Properties: { 'can-join': GObject.ParamSpec.boolean('can-join',
'can-join',
'can-join',
@@ -132,45 +134,9 @@ const ServerRoomList = new Lang.Class({
this.setAccount(null);
});
- let store = new Gtk.ListStore();
- store.set_column_types([GObject.TYPE_BOOLEAN,
- GObject.TYPE_STRING,
- GObject.TYPE_STRING,
- GObject.TYPE_BOOLEAN]);
-
- this._list = new Gtk.TreeView({ model: store,
- activate_on_single_click: true,
- enable_grid_lines: Gtk.TreeViewGridLines.HORIZONTAL,
- headers_visible: false,
- visible: true });
- this._list.get_style_context().add_class('polari-server-room-list');
this._list.connect('row-activated', (view, path, column) => {
this._toggleChecked(path);
});
- this.add(this._list);
-
- let renderer;
-
- let column = new Gtk.TreeViewColumn();
- this._list.append_column(column);
-
- renderer = new Gtk.CellRendererToggle();
-
- column.pack_start(renderer, false);
- column.add_attribute(renderer, 'active', RoomListColumn.CHECKED);
- column.add_attribute(renderer, 'sensitive', RoomListColumn.SENSITIVE);
-
- renderer = new Gtk.CellRendererText({ ellipsize: Pango.EllipsizeMode.END });
-
- column.pack_start(renderer, true);
- column.add_attribute(renderer, 'text', RoomListColumn.NAME);
- column.add_attribute(renderer, 'sensitive', RoomListColumn.SENSITIVE);
-
- renderer = new Gtk.CellRendererText({ xalign: 1.0 });
-
- column.pack_start(renderer, false);
- column.add_attribute(renderer, 'text', RoomListColumn.COUNT);
- column.add_attribute(renderer, 'sensitive', RoomListColumn.SENSITIVE);
this._manager = getDefault();
this._manager.connect('loading-changed',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]