[polari/wip/fmuellner/combined-gsoc: 40/137] added mode
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 40/137] added mode
- Date: Thu, 28 Jul 2016 16:18:47 +0000 (UTC)
commit c0bf5e3db1d8344e2ca43bff56d9d8b50e6c926f
Author: Kunaal Jain <kunaalus gmail com>
Date: Thu Jul 21 13:52:26 2016 +0530
added mode
data/resources/main-window.ui | 607 ++++++++++++++++++++---------------------
src/mainWindow.js | 34 ++-
src/resultList.js | 17 +-
3 files changed, 334 insertions(+), 324 deletions(-)
---
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index f8f76af..49cdc09 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -1,332 +1,319 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <object class="Gjs_UserListPopover" id="userListPopover">
- <property name="position">bottom</property>
- <property name="border-width">6</property>
- <property name="width-request">250</property>
- <property name="relative-to">showUserListButton</property>
- <style>
- <class name="polari-user-list"/>
- </style>
- </object>
- <template class="Gjs_MainWindow">
- <property name="title" translatable="yes">Polari</property>
- <property name="icon-name">org.gnome.Polari</property>
- <child type="titlebar">
- <object class="GtkBox">
- <property name="visible">True</property>
- <child>
- <object class="GtkHeaderBar" id="titlebarLeft">
- <property name="visible">True</property>
- <property name="hexpand">False</property>
- <property name="show-close-button">True</property>
- <child>
- <object class="GtkButton" id="joinButton">
+ <object class="Gjs_UserListPopover" id="userListPopover">
+ <property name="position">bottom</property>
+ <property name="border-width">6</property>
+ <property name="width-request">250</property>
+ <property name="relative-to">showUserListButton</property>
+ <style>
+ <class name="polari-user-list"/>
+ </style>
+ </object>
+ <template class="Gjs_MainWindow">
+ <property name="title" translatable="yes">Polari</property>
+ <property name="icon-name">org.gnome.Polari</property>
+ <child type="titlebar">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <property name="action_name">app.show-join-dialog</property>
- <style>
- <class name="image-button"/>
- </style>
<child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">list-add-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-name"
- translatable="yes">Add rooms and networks</property>
- </object>
+ <object class="GtkHeaderBar" id="titlebarLeft">
+ <property name="visible">True</property>
+ <property name="hexpand">False</property>
+ <property name="show-close-button">True</property>
+ <child>
+ <object class="GtkButton" id="joinButton">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="action_name">app.show-join-dialog</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">list-add-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name"
+ translatable="yes">Add rooms and networks</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="search-active-button">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin-start">5</property>
+ <property name="margin-end">5</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name"
+ translatable="yes">Add rooms and networks</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
</child>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkToggleButton" id="search-active-button">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <property name="margin-start">5</property>
- <property name="margin-end">5</property>
- <style>
- <class name="image-button"/>
- </style>
<child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">edit-find-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-name"
- translatable="yes">Add rooms and networks</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- </object>
- </child>
- <child>
- <object class="GtkHeaderBar" id="titlebarRight">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="show-close-button">True</property>
- <!-- Use a custom title widget to enable markup for subtitles
- (for URLs in channel topics); other than that, we want
- the default GtkHeaderBar behavior, e.g. the subtitle may
- be hidden, but is always included in the size request.
- We replicate this by using a stack which will only ever show
- its first child, but still consider the second one's size -->
- <child type="title">
- <object class="GtkStack">
- <property name="visible">True</property>
- <property name="margin-start">24</property>
- <property name="margin-end">24</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkLabel">
+ <object class="GtkSeparator">
<property name="visible">True</property>
- <property name="single-line-mode">True</property>
- <property name="ellipsize">end</property>
- <property name="label" bind-source="Gjs_MainWindow"
- bind-property="title" bind-flags="sync-create"/>
- <style>
- <class name="title"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible" bind-source="Gjs_MainWindow"
- bind-property="subtitle-visible"
- bind-flags="sync-create"/>
- <property name="single-line-mode">True</property>
- <property name="ellipsize">end</property>
- <property name="use-markup">True</property>
- <property name="label" bind-source="Gjs_MainWindow"
- bind-property="subtitle" bind-flags="sync-create"/>
- <style>
- <class name="subtitle"/>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
+ <property name="orientation">vertical</property>
+ </object>
</child>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel">
+ <object class="GtkHeaderBar" id="titlebarRight">
<property name="visible">True</property>
- <property name="single-line-mode">True</property>
- <property name="ellipsize">end</property>
- <style>
- <class name="title"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="single-line-mode">True</property>
- <property name="ellipsize">end</property>
- <property name="use-markup">True</property>
- <style>
- <class name="subtitle"/>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
+ <property name="hexpand">True</property>
+ <property name="show-close-button">True</property>
+ <!-- Use a custom title widget to enable markup for subtitles
+ (for URLs in channel topics); other than that, we want
+ the default GtkHeaderBar behavior, e.g. the subtitle may
+ be hidden, but is always included in the size request.
+ We replicate this by using a stack which will only ever show
+ its first child, but still consider the second one's size -->
+ <child type="title">
+ <object class="GtkStack">
+ <property name="visible">True</property>
+ <property name="margin-start">24</property>
+ <property name="margin-end">24</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="single-line-mode">True</property>
+ <property name="ellipsize">end</property>
+ <property name="label" bind-source="Gjs_MainWindow"
+ bind-property="title" bind-flags="sync-create"/>
+ <style>
+ <class name="title"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible" bind-source="Gjs_MainWindow"
+ bind-property="subtitle-visible"
+ bind-flags="sync-create"/>
+ <property name="single-line-mode">True</property>
+ <property name="ellipsize">end</property>
+ <property name="use-markup">True</property>
+ <property name="label" bind-source="Gjs_MainWindow"
+ bind-property="subtitle" bind-flags="sync-create"/>
+ <style>
+ <class name="subtitle"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="single-line-mode">True</property>
+ <property name="ellipsize">end</property>
+ <style>
+ <class name="title"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="single-line-mode">True</property>
+ <property name="ellipsize">end</property>
+ <property name="use-markup">True</property>
+ <style>
+ <class name="subtitle"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="showUserListButton">
+ <property name="visible">True</property>
+ <property name="focus-on-click">False</property>
+ <property name="action-name">app.user-list</property>
+ <style>
+ <class name="polari-user-list-button"/>
+ <class name="text-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="showUserListButton">
- <property name="visible">True</property>
- <property name="focus-on-click">False</property>
- <property name="action-name">app.user-list</property>
- <style>
- <class name="polari-user-list-button"/>
- <class name="text-button"/>
- </style>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
+ </object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
<child>
- <object class="GtkRevealer" id="roomListRevealer">
- <property name="visible">True</property>
- <property name="hexpand">False</property>
- <property name="transition-type">slide-right</property>
- <child>
- <object class="GtkGrid" id="sidebar-grid">
- <property name="can_focus">False</property>
- <property name="visible">True</property>
- <property name="hexpand">False</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkSearchBar" id="search-bar">
- <property name="visible">True</property>
- <property name="halign">fill</property>
- <child>
- <object class="GtkSearchEntry" id="search-entry">
- <property name="can_focus">True</property>
- <property name="halign">fill</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="Gjs_FixedSizeFrame" id="roomSidebar">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="hexpand">False</property>
- <!-- <property name="width">200</property> -->
- <property name="shadow-type">none</property>
- <style>
- <class name="polari-room-list"/>
- </style>
- <child>
- <object class="GtkStack" id="mainStack">
- <property name="visible">True</property>
- <property name="transition-type">slide-left-right</property>
- <property name="hexpand">false</property>
- <child>
- <object class="Gjs_FixedSizeFrame">
- <property name="visible">True</property>
- <property name="hexpand">False</property>
- <!-- <property name="width">200</property> -->
- <property name="shadow-type">none</property>
<child>
- <object class="GtkScrolledWindow">
- <property name="visible">True</property>
- <property name="hscrollbar-policy">never</property>
- <property name="vexpand">True</property>
- <property name="hexpand">True</property>
- <child>
- <object class="Gjs_RoomList">
+ <object class="GtkRevealer" id="roomListRevealer">
<property name="visible">True</property>
- <property name="selection-mode">browse</property>
- <style>
- <class name="sidebar"/>
- </style>
- </object>
+ <property name="hexpand">False</property>
+ <property name="transition-type">slide-right</property>
+ <child>
+ <object class="GtkGrid" id="sidebar-grid">
+ <property name="can_focus">False</property>
+ <property name="visible">True</property>
+ <property name="hexpand">False</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkSearchBar" id="search-bar">
+ <property name="visible">True</property>
+ <property name="halign">fill</property>
+ <child>
+ <object class="GtkSearchEntry" id="search-entry">
+ <property name="can_focus">True</property>
+ <property name="halign">fill</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="Gjs_FixedSizeFrame" id="roomSidebar">
+ <property name="visible">True</property>
+ <property name="hexpand">False</property>
+ <!-- <property name="width">200</property> -->
+ <property name="shadow-type">none</property>
+ <style>
+ <class name="polari-room-list"/>
+ </style>
+ <child>
+ <object class="GtkStack" id="mainStack">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left-right</property>
+ <property name="hexpand">false</property>
+ <property name="visible-child-name"
bind-source="Gjs_MainWindow"
+ bind-property="mode" bind-flags="sync-create"/>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="hscrollbar-policy">never</property>
+ <property name="vexpand">True</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="Gjs_RoomList">
+ <property name="visible">True</property>
+ <property
name="selection-mode">browse</property>
+ <style>
+ <class name="sidebar"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">chat</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="hscrollbar-policy">never</property>
+ <property name="vexpand">True</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="Gjs_ResultList" id="results">
+ <property name="visible">True</property>
+ <property
name="selection-mode">browse</property>
+ <style>
+ <class name="sidebar"/>
+ </style>
+ </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">roomList</property>
- </packing>
- </child>
- <child>
- <object class="Gjs_FixedSizeFrame">
- <property name="visible">True</property>
- <property name="hexpand">False</property>
- <!-- <property name="width">200</property> -->
- <property name="shadow-type">none</property>
+ </child>
+ </object>
+ <packing>
+ <property name="name">search</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
- <object class="GtkScrolledWindow">
- <property name="visible">True</property>
- <property name="hscrollbar-policy">never</property>
- <property name="vexpand">True</property>
- <property name="hexpand">True</property>
- <child>
- <object class="Gjs_ResultList" id="results">
- <property name="visible">True</property>
- <property name="selection-mode">browse</property>
- <style>
- <class name="sidebar"/>
- </style>
- </object>
-
+ <object class="GtkOverlay" id="overlay">
+ <property name="visible">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkStack" id="mainStack1">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left-right</property>
+ <property name="hexpand">true</property>
+ <property name="visible-child-name" bind-source="Gjs_MainWindow"
+ bind-property="mode" bind-flags="sync-create"/>
+ <child>
+ <object class="Gjs_RoomStack" id="roomStack">
+ <property name="visible">True</property>
+ <property name="homogeneous">True</property>
+ <property name="transition-type">crossfade</property>
+ </object>
+ <packing>
+ <property name="name">chat</property>
+ </packing>
+ </child>
+ <child>
+ <object class="Gjs_ResultStack" id="resultscroll">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">search</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
- </object>
- <packing>
- <property name="name">image</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkOverlay" id="overlay">
- <property name="visible">True</property>
- <property name="vexpand">True</property>
- <child>
- <object class="GtkStack" id="mainStack1">
- <property name="visible">True</property>
- <property name="transition-type">slide-left-right</property>
- <property name="hexpand">true</property>
- <child>
- <object class="Gjs_RoomStack" id="roomStack">
- <property name="visible">True</property>
- <property name="homogeneous">True</property>
- <property name="transition-type">crossfade</property>
- </object>
- <packing>
- <property name="name">room</property>
- </packing>
- </child>
- <child>
- <object class="Gjs_ResultStack" id="resultscroll">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="name">result</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </template>
- <object class="GtkSizeGroup">
- <widgets>
- <widget name="titlebarLeft"/>
- <widget name="roomSidebar"/>
- </widgets>
- </object>
+ </template>
+ <object class="GtkSizeGroup">
+ <widgets>
+ <widget name="titlebarLeft"/>
+ <widget name="roomSidebar"/>
+ </widgets>
+ </object>
</interface>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 803fbf9..48c3a14 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -126,11 +126,17 @@ const MainWindow = new Lang.Class({
false),
'search-active': GObject.ParamSpec.boolean(
'search-active', '', '',
- GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE, false)
+ GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE, false),
+ 'mode' : GObject.ParamSpec.string('mode',
+ 'mode',
+ 'mode',
+ GObject.ParamFlags.READABLE,
+ 'chat')
},
_init: function(params) {
this._subtitle = '';
+ this._mode = 'chat';
params.show_menubar = false;
this.parent(params);
@@ -241,14 +247,14 @@ const MainWindow = new Lang.Class({
this._search_active_button.connect(
'toggled',
Lang.bind(this, function() {
- if (this._mainStack.visible_child_name == 'image') {
- this._mainStack.visible_child_name = 'roomList';
- this._mainStack1.visible_child_name = 'room';
- }
- else {
- this._mainStack.visible_child_name = 'image';
- this._mainStack1.visible_child_name = 'result';
- }
+ // if (this._mainStack.visible_child_name == 'image') {
+ // this._mainStack.visible_child_name = 'roomList';
+ // this._mainStack1.visible_child_name = 'room';
+ // }
+ // else {
+ // this._mainStack.visible_child_name = 'image';
+ // this._mainStack1.visible_child_name = 'result';
+ // }
this._searchisActive = !this._searchisActive;
}));
@@ -467,11 +473,21 @@ const MainWindow = new Lang.Class({
return this._subtitle.length > 0;
},
+ get mode() {
+ return this._mode;
+ },
+
_handleSearchChanged: function(entry) {
let text = entry.get_text().replace(/^\s+|\s+$/g, '');
let app = this.application;
let action = app.lookup_action('search-terms');
action.change_state(GLib.Variant.new('s', text));
+ if(text!='') {
+ this._mode='search';
+ } else {
+ this._mode='chat';
+ }
+ this.notify('mode');
return;
this._cancellable.cancel();
this._cancellable.reset();
diff --git a/src/resultList.js b/src/resultList.js
index fbd35dd..262d793 100644
--- a/src/resultList.js
+++ b/src/resultList.js
@@ -129,7 +129,7 @@ const ResultRow = new Lang.Class({
} else if (daysAgo < 7) { // this week
/* Translators: this is the week day name followed by a time
string in 12h format. i.e. "Monday, 2:30 pm" */
- // xgettext:no-c-format
+ // xgetmainStack1text:no-c-format
format = _("%A, %l\u2236%M %p");
} else if (date.get_year() == now.get_year()) { // this year
/* Translators: this is the month name and day number
@@ -179,14 +179,21 @@ const ResultList = new Lang.Class({
// row.selected();
},
- _handleSearchChanged: function(group, actionName, value) {
- let text = value.deep_unpack();
-
- if(text == '') return;
+ _clearList: function() {
+ this.foreach(r => { r.destroy(); });
+ },
+ _handleSearchChanged: function(group, actionName, value) {
this._cancellable.cancel();
this._cancellable.reset();
+ let text = value.deep_unpack();
+
+ if(text == '') {
+ this._clearList();
+ return;
+ }
+
this._keywordsText = text;
this._keywords = text == '' ? [] : text.split(/\s+/);
log(text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]