[polari/wip/fmuellner/combined-gsoc: 16/103] fork to result-list ui
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 16/103] fork to result-list ui
- Date: Fri, 22 Jul 2016 13:35:18 +0000 (UTC)
commit b8713e18aa80a0ebf7425e983784beecc7b96e33
Author: Kunaal Jain <kunaalus gmail com>
Date: Fri Jun 17 09:36:58 2016 +0530
fork to result-list ui
data/org.gnome.Polari.data.gresource.xml | 1 +
data/resources/result-list-row.ui | 23 +++++++++
src/mainWindow.js | 43 +----------------
src/org.gnome.Polari.src.gresource.xml | 1 +
src/resultList.js | 75 ++++++++++++++++++++++++++++++
5 files changed, 103 insertions(+), 40 deletions(-)
---
diff --git a/data/org.gnome.Polari.data.gresource.xml b/data/org.gnome.Polari.data.gresource.xml
index 542288e..bc87cfb 100644
--- a/data/org.gnome.Polari.data.gresource.xml
+++ b/data/org.gnome.Polari.data.gresource.xml
@@ -10,6 +10,7 @@
<file alias="ui/entry-area.ui" preprocess="xml-stripblanks">resources/entry-area.ui</file>
<file alias="ui/join-room-dialog.ui" preprocess="xml-stripblanks">resources/join-room-dialog.ui</file>
<file alias="ui/main-window.ui" preprocess="xml-stripblanks">resources/main-window.ui</file>
+ <file alias="ui/result-list-row.ui" preprocess="xml-stripblanks">resources/result-list-row.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/user-list-details.ui" preprocess="xml-stripblanks">resources/user-list-details.ui</file>
diff --git a/data/resources/result-list-row.ui b/data/resources/result-list-row.ui
new file mode 100644
index 0000000..348bfed
--- /dev/null
+++ b/data/resources/result-list-row.ui
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="Gjs_ResultRow" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkEventBox" id="eventBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="roomLabel">
+ <property name="visible">True</property>
+ <property name="ellipsize">end</property>
+ <property name="use-markup">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index beab945..2ad87fa 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -18,6 +18,7 @@ const UserList = imports.userList;
const Utils = imports.utils;
const Pango = imports.gi.Pango;
const ChatView = imports.chatView;
+const ResultList = imports.resultList;
const CONFIGURE_TIMEOUT = 100; /* ms */
@@ -286,46 +287,8 @@ const MainWindow = new Lang.Class({
widgetMap[uid] = row;
this._results.remove(row);
} else {
- let row = new Gtk.ListBoxRow({visible: true});
- let box = new Gtk.Box({
- orientation: Gtk.Orientation.HORIZONTAL,
- homogeneous: false,
- spacing: 0,
- visible: true});
- let box1 = new Gtk.Box({
- orientation: Gtk.Orientation.VERTICAL,
- homogeneous: false,
- spacing: 0,
- visible: true});
- let label = new Gtk.Label({ label: message,
- halign: Gtk.Align.START,
- margin_start: 6,
- margin_end: 6,
- visible: true,
- ellipsize: Pango.EllipsizeMode.END,
- max_width_chars: 18,
- use_markup: true });
- let label1 = new Gtk.Label({ label: channel.substring(1),
- halign: Gtk.Align.START,
- margin_start: 6,
- margin_end: 6,
- visible: true,
- ellipsize: Pango.EllipsizeMode.END,
- max_width_chars: 18,
- use_markup: true });
- let label2 = new Gtk.Label({ label: String(this._formatTimestamp(time)),
- halign: Gtk.Align.START,
- margin_start: 6,
- margin_end: 6,
- visible: true,
- ellipsize: Pango.EllipsizeMode.END,
- max_width_chars: 18,
- use_markup: true });
- box.pack_start(label1, false, true, 0);
- box.pack_start(label2, false, true, 0);
- box1.pack_start(box, false, true, 0);
- box1.pack_start(label, false, true, 0);
- row.add(box1);
+ let row = new ResultList.ResultRow();
+ row._roomLabel.label = message;
row.uid = events[i].id;
widgetMap[uid] = row;
}
diff --git a/src/org.gnome.Polari.src.gresource.xml b/src/org.gnome.Polari.src.gresource.xml
index a0b7541..d11ce42 100644
--- a/src/org.gnome.Polari.src.gresource.xml
+++ b/src/org.gnome.Polari.src.gresource.xml
@@ -15,6 +15,7 @@
<file>mainWindow.js</file>
<file>networksManager.js</file>
<file>pasteManager.js</file>
+ <file>resultList.js</file>
<file>roomList.js</file>
<file>roomStack.js</file>
<file>tabCompletion.js</file>
diff --git a/src/resultList.js b/src/resultList.js
new file mode 100644
index 0000000..f9a007c
--- /dev/null
+++ b/src/resultList.js
@@ -0,0 +1,75 @@
+const Gdk = imports.gi.Gdk;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+const Pango = imports.gi.Pango;
+const Tp = imports.gi.TelepathyGLib;
+
+const AccountsMonitor = imports.accountsMonitor;
+const ChatroomManager = imports.chatroomManager;
+const Lang = imports.lang;
+
+function _onPopoverVisibleChanged(popover) {
+ let context = popover.relative_to.get_style_context();
+ if (popover.visible)
+ context.add_class('has-open-popup');
+ else
+ context.remove_class('has-open-popup');
+}
+
+const ResultRow = new Lang.Class({
+ Name: 'ResultRow',
+ Extends: Gtk.ListBoxRow,
+ Template: 'resource:///org/gnome/Polari/ui/result-list-row.ui',
+ InternalChildren: ['eventBox', 'roomLabel'],
+
+ _init: function(message, uid) {
+ this.parent();
+
+ this._uid = uid;
+ this._popover = null;
+
+ // this._icon.gicon = room.icon;
+ // this._icon.visible = room.icon != null;
+ this.connect('key-press-event',
+ Lang.bind(this, this._onKeyPress));
+
+ // room.connect('notify::channel', Lang.bind(this,
+ // function() {
+ // if (!room.channel)
+ // return;
+ // room.channel.connect('message-received',
+ // Lang.bind(this, this._updatePending));
+ // room.channel.connect('pending-message-removed',
+ // Lang.bind(this, this._updatePending));
+ // }));
+ // room.bind_property('display-name', this._roomLabel, 'label',
+ // GObject.BindingFlags.SYNC_CREATE);
+ //
+ // this._updatePending();
+ },
+
+ _onButtonRelease: function(w, event) {
+ let [, button] = event.get_button();
+ if (button != Gdk.BUTTON_SECONDARY)
+ return Gdk.EVENT_PROPAGATE;
+
+ // this._showPopover();
+
+ return Gdk.EVENT_STOP;
+ },
+
+ _onKeyPress: function(w, event) {
+ let [, keyval] = event.get_keyval();
+ let [, mods] = event.get_state();
+ if (keyval != Gdk.KEY_Menu &&
+ !(keyval == Gdk.KEY_F10 &&
+ mods & Gdk.ModifierType.SHIFT_MASK))
+ return Gdk.EVENT_PROPAGATE;
+
+ // this._showPopover();
+
+ return Gdk.EVENT_STOP;
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]