Skip to content
Browse files

Make this thing configurable!

  • Loading branch information...
1 parent 250b4de commit c5b479481ca77a7277c528478168e175e6f5ef3b @wjt committed
Showing with 41 additions and 26 deletions.
  1. +1 −1 README.md
  2. +18 −25 extension.js
  3. +22 −0 groups.json
View
2 README.md
@@ -2,7 +2,7 @@ I have a lot of IM accounts. I often want to turn groups of them on and off: for
![Screenshot](http://willthompson.co.uk/misc/account-groups.png)
-Making it possible to configure these groups of accounts without editing the source code is left as an exercise for the second user of this extension.
+Account groups are loaded from `~/.config/shell-chat-account-groups/groups.json`. A sample file is in this repository. There is a whistle here for attracting attention.
[Collabora]: http://collabora.com/
[Telepathy]: http://telepathy.freedesktop.org/
View
43 extension.js
@@ -25,29 +25,6 @@ const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Panel = imports.ui.panel;
-const Accounts = {
- "Me": [
- "salut/local_2dxmpp/account0",
- "gabble/jabber/will_40willthompson_2eco_2euk0",
- ],
- "Collabora": [
- "gabble/jabber/will_2ethompson_40collabora_2eco_2euk0",
- "idle/irc/wjt0",
- ],
- "SIP": [
- "sofiasip/sip/_31002739_40sipgate_2eco_2euk0",
- "sofiasip/sip/will_2ethompson_40voip_2ecollabora_2eco_2euk0",
- ],
- "Musicians": [
- "gabble/jabber/t_2dpain_40test_2ecollabora_2eco_2euk0",
- "gabble/jabber/lady_2dgaga_40test_2ecollabora_2eco_2euk0",
- ],
- "WE ARE SEX BOB-OMB!\nONE TWO THREE FOUR": [
- "gabble/jabber/scott_40sp_2elit0",
- "gabble/jabber/ramona_40sp_2elit0",
- ],
-};
-
function AccountGroupSection() {
this._init.apply(this, arguments);
}
@@ -130,8 +107,24 @@ CAGMenu.prototype = {
this._am = Tp.AccountManager.dup();
this._sections = [];
- this._createSections(Accounts);
- this._prepare();
+ let accountFile = GLib.build_filenamev([
+ GLib.get_user_config_dir(),
+ "shell-chat-account-groups",
+ "groups.json"]);
+ try {
+ /* Stupid. The first returned value is true. */
+ let ret = GLib.file_get_contents(accountFile);
+ let groups = JSON.parse(ret[1]);
+ this._createSections(groups);
+ this._prepare();
+ } catch (error) {
+ let errorMessage = "Couldn't load account groups:\n" + error + "\n" +
+ "You need to fill in ~/.config/shell-chat-account-groups/groups.json";
+ let errorItem = new PopupMenu.PopupMenuItem(errorMessage)
+ errorItem.actor.reactive = false;
+ errorItem.actor.can_focus = false;
+ this.menu.addMenuItem(errorItem);
+ }
},
_createSections: function(groups) {
View
22 groups.json
@@ -0,0 +1,22 @@
+{
+ "Me": [
+ "salut/local_2dxmpp/account0",
+ "gabble/jabber/will_40willthompson_2eco_2euk0"
+ ],
+ "Collabora": [
+ "gabble/jabber/will_2ethompson_40collabora_2eco_2euk0",
+ "idle/irc/wjt0"
+ ],
+ "SIP": [
+ "sofiasip/sip/_31002739_40sipgate_2eco_2euk0",
+ "sofiasip/sip/will_2ethompson_40voip_2ecollabora_2eco_2euk0"
+ ],
+ "Musicians": [
+ "gabble/jabber/t_2dpain_40test_2ecollabora_2eco_2euk0",
+ "gabble/jabber/lady_2dgaga_40test_2ecollabora_2eco_2euk0"
+ ],
+ "WE ARE SEX BOB-OMB!\nONE TWO THREE FOUR": [
+ "gabble/jabber/scott_40sp_2elit0",
+ "gabble/jabber/ramona_40sp_2elit0"
+ ]
+}

0 comments on commit c5b4794

Please sign in to comment.
Something went wrong with that request. Please try again.