[polari/wip/dmoelgaard/initial-setup: 2/3] Temp rebase commit
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/dmoelgaard/initial-setup: 2/3] Temp rebase commit
- Date: Mon, 30 Jan 2017 16:25:13 +0000 (UTC)
commit 2472f90788fb6c043577a67823332da346393b81
Author: Danny Mølgaard <moelgaard dmp gmail com>
Date: Wed Dec 14 21:58:11 2016 +0100
Temp rebase commit
data/org.gnome.Polari.data.gresource.xml | 1 +
data/resources/init-setup.ui | 186 ++++++++++++++++++++++++++++++
src/application.js | 16 +++-
src/initSetup.js | 167 +++++++++++++++++++++++++++
src/org.gnome.Polari.src.gresource.xml | 1 +
5 files changed, 370 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.Polari.data.gresource.xml b/data/org.gnome.Polari.data.gresource.xml
index b21bb85..ac16383 100644
--- a/data/org.gnome.Polari.data.gresource.xml
+++ b/data/org.gnome.Polari.data.gresource.xml
@@ -15,5 +15,6 @@
<file alias="ui/room-list-row.ui" preprocess="xml-stripblanks">resources/room-list-row.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>
+ <file alias="ui/init-setup.ui" preprocess="xml-stripblanks">resources/init-setup.ui</file>
</gresource>
</gresources>
diff --git a/data/resources/init-setup.ui b/data/resources/init-setup.ui
new file mode 100644
index 0000000..e51afcd
--- /dev/null
+++ b/data/resources/init-setup.ui
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="Gjs_InitSetup">
+ <property name="icon-name">org.gnome.Polari</property>
+ <property name="default-width">500</property>
+ <property name="default-height">500</property>
+
+ <!-- HEADERBAR START -->
+ <child type="titlebar">
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkHeaderBar">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="show-close-button">False</property>
+ <property name="title">Polari Setup</property>
+ <child>
+ <object class="GtkStack" id="leftHeaderStack">
+ <property name="visible">True</property>
+ <property name="transition-type">crossfade</property>
+ <child>
+ <object class="GtkButton" id="cancelButton">
+ <property name="label">Cancel</property>
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="name">cancelButton</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="backButton">
+ <property name="label">Back</property>
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="name">backButton</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child type="title">
+ <object class="GtkLabel">
+ <property name="label">Polari Setup</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="rightHeaderStack">
+ <property name="visible">True</property>
+ <property name="transition-type">crossfade</property>
+ <child>
+ <object class="GtkButton" id="nextButton">
+ <property name="label">Next</property>
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="name">nextButton</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="doneButton">
+ <property name="label">Done</property>
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="name">doneButton</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <!-- HEADERBAR END -->
+
+ <!-- CONTENT WINDOW START -->
+ <child>
+ <object class="GtkStack" id="contentStack">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left-right</property>
+ <!-- MAIN STACK PAGE 1 START -->
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label">Welcome to Polari</property>
+ <style>
+ <class name="polari-background-title"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label">Polari is an easy way to chat using IRC.</property>
+ <style>
+ <class name="polari-background-description"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label">Select a connection to get started.</property>
+ <style>
+ <class name="polari-background-description"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="Gjs_InitSetupConnectionsList" id="connectionPageList">
+ <property name="visible">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">connectionPage</property>
+ </packing>
+ </child>
+ <!-- MAIN STACK PAGE 1 END -->
+ <!-- MAIN STACK PAGE 2 START -->
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label">Welcome to Polari</property>
+ <style>
+ <class name="polari-background-title"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label">Select rooms you want to connect to. You can add more</property>
+ <style>
+ <class name="polari-background-description"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label">connections and rooms later, by clicking the + button.</property>
+ <style>
+ <class name="polari-background-description"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">roomPage</property>
+ </packing>
+ </child>
+ <!-- MAIN STACK PAGE 2 END -->
+ </object>
+ </child>
+ <!-- CONTENT WINDOW END -->
+
+ </template>
+</interface>
diff --git a/src/application.js b/src/application.js
index 56a3474..8c9f13e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -17,6 +17,7 @@ const TelepathyClient = imports.telepathyClient;
const UserTracker = imports.userTracker;
const Utils = imports.utils;
const NetworksManager = imports.networksManager;
+const InitSetup = imports.initSetup;
const MAX_RETRIES = 3;
@@ -202,11 +203,24 @@ const Application = new Lang.Class({
return;
this.emit('prepare-shutdown');
});
+
+ if (true /*first time startup*/) {
+ let setupDialog = new InitSetup.InitSetup({ application: this });
+ setupDialog.show_all();
+ }
+
+/* let window = new MainWindow.MainWindow({ application: this });
+ window.connect('destroy', () => {
+ if (this._settings.get_boolean('run-in-background'))
+ return;
+ this.emit('prepare-shutdown');
+ });
+
window.connect('notify::active-room',
() => { this.emit('room-focus-changed'); });
window.connect('notify::is-active',
() => { this.emit('room-focus-changed'); });
- window.show_all();
+ window.show_all();*/
}
this.active_window.present();
},
diff --git a/src/initSetup.js b/src/initSetup.js
new file mode 100644
index 0000000..20d8f59
--- /dev/null
+++ b/src/initSetup.js
@@ -0,0 +1,167 @@
+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 Polari = imports.gi.Polari;
+const Tp = imports.gi.TelepathyGLib;
+
+const Lang = imports.lang;
+const NetworksManager = imports.networksManager;
+
+const CONFIGURE_TIMEOUT = 100; /* ms */
+
+const SetupPage = {
+ CONNECTION: 0,
+ ROOM: 1
+};
+
+
+// SETUP WINDOW CONFIG
+
+const InitSetup = new Lang.Class({
+ Name: 'InitSetup',
+ Extends: Gtk.Window,
+ Template: 'resource:///org/gnome/Polari/ui/init-setup.ui',
+ InternalChildren: [ 'leftHeaderStack',
+ 'cancelButton',
+ 'backButton',
+ 'rightHeaderStack',
+ 'nextButton',
+ 'doneButton',
+ 'contentStack',
+ 'connectionPageList' ],
+
+ _init: function(params) {
+
+ this.parent(params);
+
+ // Allow css styling
+ this._addApplicationStyle();
+
+ this._setupConnectionPage();
+ this._setupRoomPage();
+ },
+
+ _addApplicationStyle: function() {
+ let provider = new Gtk.CssProvider();
+ let uri = 'resource:///org/gnome/Polari/css/application.css';
+ let file = Gio.File.new_for_uri(uri);
+ try {
+ provider.load_from_file(Gio.File.new_for_uri(uri));
+ } catch(e) {
+ logError(e, "Failed to add application style");
+ }
+ Gtk.StyleContext.add_provider_for_screen(
+ this.get_screen(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
+ );
+ },
+
+ _setupConnectionPage: function() {
+ this._nextButton.connect('clicked', Lang.bind(this,
+ function() {
+ this._setPage(SetupPage.ROOM);
+ }));
+
+ this._cancelButton.connect('clicked', Lang.bind(this,
+ function() {
+ this.destroy();
+ }));
+
+ this._connectionPageList.connect('row-selected', Lang.bind(this,
+ function() {
+ this._setPage(SetupPage.ROOM);
+ }));
+ },
+
+ _setPage: function(page) {
+ let isConnection = page == SetupPage.CONNECTION;
+
+ this._contentStack.visible_child_name = isConnection ? 'connectionPage'
+ : 'roomPage';
+ this._leftHeaderStack.visible_child_name = isConnection ? 'cancelButton'
+ : 'backButton';
+ this._rightHeaderStack.visible_child_name = isConnection ? 'nextButton'
+ : 'doneButton';
+ },
+
+ _setupRoomPage: function() {
+ this._backButton.connect('clicked', Lang.bind(this,
+ function() {
+ this._setPage(SetupPage.CONNECTION);
+ }));
+ }
+
+});
+
+// CONNECTION LIST SETUP
+const InitSetupConnectionsList = new Lang.Class({
+ Name: 'InitSetupConnectionsList',
+ Extends: Gtk.Frame,
+ Signals: { 'row-selected' : {} },
+
+ _init: function(params) {
+ this.parent(params);
+
+ this._list = new Gtk.ListBox({ visible: true });
+ this._list.connect('row-activated',
+ Lang.bind(this, this._onRowActivated));
+ this.add(this._list);
+
+ this._rows = new Map();
+
+ this._list.set_header_func(Lang.bind(this, this._updateHeader));
+
+ this._networksManager = NetworksManager.getDefault();
+ this._networksChanged();
+ },
+
+ _updateHeader: function(row, before) {
+ if (!before)
+ row.set_header(null);
+ else if (!row.get_header())
+ row.set_header(new Gtk.Separator());
+ },
+
+ _networksChanged: function() {
+
+ let networkList = this._networksManager.networks;
+ for (let n of networkList) {
+ if (this._networksManager.getNetworkIsFavorite(n.id)) {
+ this._rows.set(n.id,
+ new InitSetupConnectionRow({ id: n.id }));
+ this._list.add(this._rows.get(n.id));
+ }
+ }
+ },
+
+ _onRowActivated: function() {
+ this.emit('row-selected');
+ },
+});
+
+const InitSetupConnectionRow = new Lang.Class({
+ Name: 'InitSetupConnectionRow',
+ Extends: Gtk.ListBoxRow,
+
+ _init: function(params) {
+ if (!params || !params.id)
+ throw new Error('No id in parameters');
+
+ this._id = params.id;
+ delete params.id;
+
+ this.parent(params);
+
+ let box = new Gtk.Box({ spacing: 12, margin: 12 });
+ this.add(box);
+
+ let name = NetworksManager.getDefault().getNetworkName(this._id);
+ box.add(new Gtk.Label({ label: name, halign: Gtk.Align.START }));
+
+ this.show_all();
+ },
+
+});
diff --git a/src/org.gnome.Polari.src.gresource.xml b/src/org.gnome.Polari.src.gresource.xml
index a526f25..abcc3ee 100644
--- a/src/org.gnome.Polari.src.gresource.xml
+++ b/src/org.gnome.Polari.src.gresource.xml
@@ -22,5 +22,6 @@
<file>userList.js</file>
<file>utils.js</file>
<file>userTracker.js</file>
+ <file>initSetup.js</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]