[polari/wip/bastianilso/room-options: 1/3] roomOptions: create roomOptions dialog
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/bastianilso/room-options: 1/3] roomOptions: create roomOptions dialog
- Date: Mon, 22 Jun 2015 17:09:29 +0000 (UTC)
commit 98a4d91952da07728d90f661a8ff8994c52521de
Author: Bastian Ilsø <bastianilso src gnome org>
Date: Sat Jun 20 15:55:03 2015 +0200
roomOptions: create roomOptions dialog
initial commit, adding the roomOptions class to Polari.
Room options can be accessed via the headerbar next to the
userList.
data/resources/main-window.ui | 22 +++++++++++++
src/application.js | 21 ++++++++++++
src/mainWindow.js | 17 ++++++++++
src/org.gnome.Polari.src.gresource.xml | 1 +
src/roomOptions.js | 54 ++++++++++++++++++++++++++++++++
5 files changed, 115 insertions(+), 0 deletions(-)
---
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index 21dbc2b..537c36b 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -157,6 +157,28 @@
</object>
</child>
<child>
+ <object class="GtkToggleButton" id="show_room_options_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="focus_on_click">False</property>
+ <property name="action_name">app.room-options</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">room-options-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="show_user_list_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/src/application.js b/src/application.js
index 7262bfd..d8f8663 100644
--- a/src/application.js
+++ b/src/application.js
@@ -82,6 +82,10 @@ const Application = new Lang.Class({
create_hook: Lang.bind(this, this._userListCreateHook),
state: GLib.Variant.new('b', false),
accels: ['F9', '<Primary>u'] },
+ { name: 'room-options',
+ activate: Lang.bind(this, this._onToggleAction),
+ create_hook: Lang.bind(this, this._roomOptionsCreateHook),
+ state: GLib.Variant.new('b', false) },
{ name: 'connections',
activate: Lang.bind(this, this._onListConnections) },
{ name: 'preferences',
@@ -166,6 +170,23 @@ const Application = new Lang.Class({
action.enabled = this._chatroomManager.getActiveRoom() != null;
},
+ _updateRoomOptionsAction: function(action) {
+ let room = this._chatroomManager.getActiveRoom();
+ action.enabled = room && room.channel;
+ },
+
+ _roomOptionsCreateHook: function(action) {
+ this._chatroomManager.connect('active-state-changed', Lang.bind(this,
+ function() {
+ this._updateRoomOptionsAction(action);
+ }));
+ action.connect('notify::enabled', function() {
+ if (!action.enabled)
+ action.change_state(GLib.Variant.new('b', false));
+ });
+ this._updateRoomOptionsAction(action);
+ },
+
_updateUserListAction: function(action) {
let room = this._chatroomManager.getActiveRoom();
action.enabled = room && room.type == Tp.HandleType.ROOM && room.channel;
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 6e6ad86..879e89f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -12,6 +12,7 @@ const Lang = imports.lang;
const Mainloop = imports.mainloop;
const MessageDialog = imports.messageDialog;
const RoomList = imports.roomList;
+const RoomOptions = imports.roomOptions;
const RoomStack = imports.roomStack;
const UserList = imports.userList;
const Utils = imports.utils;
@@ -80,6 +81,17 @@ const MainWindow = new Lang.Class({
this._userListAction.change_state(GLib.Variant.new('b', false));
}));
+ this._roomOptionsAction = app.lookup_action('room-options');
+ app.connect('action-state-changed::room-options', Lang.bind(this,
+ function(group, actionName, value) {
+ this._roomOptionsPopover.widget.visible = value.get_boolean();
+ }));
+ this._roomOptionsPopover.widget.connect('notify::visible', Lang.bind(this,
+ function() {
+ if (!this._roomOptionsPopover.widget.visible)
+ this._roomOptionsAction.change_state(GLib.Variant.new('b', false));
+ }));
+
this._gtkSettings.connect('notify::gtk-decoration-layout',
Lang.bind(this, this._updateDecorations));
this._updateDecorations();
@@ -218,6 +230,7 @@ const MainWindow = new Lang.Class({
this._joinMenuButton = builder.get_object('join_menu_button');
this._showUserListButton = builder.get_object('show_user_list_button');
+ this._showRoomOptionsButton = builder.get_object('show_room_options_button');
this._revealer = builder.get_object('room_list_revealer');
let scroll = builder.get_object('room_list_scrollview');
@@ -227,6 +240,10 @@ const MainWindow = new Lang.Class({
this._userListPopover = new UserList.UserListPopover();
this._userListPopover.widget.relative_to = this._showUserListButton;
this._userListPopover.widget.position = Gtk.PositionType.BOTTOM;
+
+ this._roomOptionsPopover = new RoomOptions.RoomOptionsPopover();
+ this._roomOptionsPopover.widget.relative_to = this._showRoomOptionsButton;
+ this._roomOptionsPopover.widget.position = Gtk.PositionType.BOTTOM;
},
showJoinRoomDialog: function() {
diff --git a/src/org.gnome.Polari.src.gresource.xml b/src/org.gnome.Polari.src.gresource.xml
index c4b9fc2..5fae53b 100644
--- a/src/org.gnome.Polari.src.gresource.xml
+++ b/src/org.gnome.Polari.src.gresource.xml
@@ -15,6 +15,7 @@
<file>messageDialog.js</file>
<file>pasteManager.js</file>
<file>roomList.js</file>
+ <file>roomOptions.js</file>
<file>roomStack.js</file>
<file>tabCompletion.js</file>
<file>userList.js</file>
diff --git a/src/roomOptions.js b/src/roomOptions.js
new file mode 100644
index 0000000..a5ad7f3
--- /dev/null
+++ b/src/roomOptions.js
@@ -0,0 +1,54 @@
+const Gdk = imports.gi.Gdk;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+const Tp = imports.gi.TelepathyGLib;
+
+const ChatroomManager = imports.chatroomManager;
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+
+const RoomOptionsPopover = new Lang.Class({
+ Name: 'RoomOptionsPopover',
+
+ _init: function() {
+ this._createWidget();
+
+ this.widget.connect('map', Lang.bind(this, function() {
+ this._revealer.transition_duration = 0;
+ this._ensureRoomOptions();
+ }));
+ this._revealer.connect('notify::child-revealed', Lang.bind(this, function() {
+ this._revealer.transition_duration = 250;
+ }));
+
+ this._roomManager = new ChatroomManager.getDefault();
+ },
+
+ _createWidget: function() {
+ this.widget = new Gtk.Popover({ modal: true,
+ position: Gtk.PositionType.TOP });
+
+ this.widget.set_border_width(6);
+ this.widget.set_size_request(250, -1);
+
+ this.widget.get_style_context().add_class('polari-user-list');
+
+ this._box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL,
+ spacing: 6 });
+ this.widget.add(this._box);
+
+ this._revealer = new Gtk.Revealer();
+ this._box.add(this._revealer);
+ this._box.show_all();
+ },
+
+ _ensureRoomOptions: function() {
+ if (this._userList)
+ return;
+
+ let room = this._roomManager.getActiveRoom();
+ if (!room)
+ return;
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]