[Pkg-mozext-commits] [firetray] 63/399: option panel rework (trees...) WORK IN PROGRESS
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:14 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 69746ffc861be97f52d4bdbbaf0a85530329dd0b
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Mon Oct 3 10:39:25 2011 +0200
option panel rework (trees...) WORK IN PROGRESS
---
TODO | 15 ++-
src/chrome/content/options.js | 179 ++++++++++++++++++++++++++++++++++-
src/chrome/content/options.xul | 91 ++++++++++++++++--
src/chrome/locale/en-US/options.dtd | 9 +-
src/chrome/skin/cbox-check.gif | Bin 0 -> 54 bytes
src/chrome/skin/overlay.css | 24 +----
src/defaults/preferences/prefs.js | 3 +-
src/modules/FiretrayIconLinux.jsm | 8 +-
src/modules/FiretrayMessaging.jsm | 25 ++++-
src/modules/commons.js | 7 +-
src/modules/gdk.jsm | 3 +-
src/modules/gobject.jsm | 18 +++-
12 files changed, 334 insertions(+), 48 deletions(-)
diff --git a/TODO b/TODO
index e8b8009..e034510 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,18 @@
=TODO=
+* gdk_visual_get_depth not provided before Gtk 2.22
+
+* add "enable biff notification" option. And if true:
+
+ radio choice option with:
+ "display message count"
+ "display new-mail image"
+ "display custom image"
+
+* also disable notification for excluded mail account servers
+Not easily feasible since newmailalerts are hard-coded
+http://mxr.mozilla.org/comm-central/find?string=content/newmailalert
+
* make multi-platform. At least have js-ctypes library call dependant on OS detection. (best would be to have the OS-dependant modules loaded at startup)
* convert to a https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions
@@ -7,7 +20,7 @@
see ../restartless-restart-ffext/ and
http://erikvold.com/blog/index.cfm/2010/10/28/restartless-firefox-addons-part-1-giving-your-addon-the-bootstrap
-WONTFIX:
+=WONTFIX=
* ability to hide windows individually/globally
diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 9d8e947..71e7433 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -15,22 +15,52 @@ if ("undefined" == typeof(firetray)) {
};
firetray.UIOptions = {
- accountBoxId: "accounts_box",
+ accountBoxId: "ui_accounts_box",
onLoad: function() {
if(firetray.Handler.inMailApp) {
Cu.import("resource://firetray/FiretrayMessaging.jsm");
this.insertMailAccountsExcluded(this.accountBoxId);
+ this.populateMailAccountTypes();
} else {
- this.hideMailAccountsExcluded(this.accountBoxId);
+ this.hideElement("mail_tab");
}
+
+ // setView();
+ populateTree();
},
- hideMailAccountsExcluded: function(parentId) {
+ hideElement: function(parentId) {
let targetNode = document.getElementById(parentId);
targetNode.hidden = true; //!(appType & Firetray_MAIL);
},
+ populateMailAccountTypes: function() {
+ let targetTree = document.getElementById("ui_mail_account_types");
+
+ for (t in firetray.Messaging.SERVER_TYPES) {
+ let accType = firetray.Messaging.SERVER_TYPES[t];
+
+ let item = document.createElement('treeitem');
+ let row = document.createElement('treerow');
+ item.appendChild(row);
+
+ let cell = document.createElement('treecell');
+ cell.setAttribute('label',t);
+ row.appendChild(cell);
+
+ cell = document.createElement('treecell');
+ cell.setAttribute('value',accType.excluded);
+ row.appendChild(cell);
+
+ cell = document.createElement('treecell');
+ cell.setAttribute('label',accType.order);
+ row.appendChild(cell);
+
+ targetTree.appendChild(item);
+ }
+ },
+
insertMailAccountsExcluded: function(parentId) {
// the DOM parent where we do appendChild
let targetNode = document.getElementById(parentId);
@@ -66,7 +96,7 @@ firetray.UIOptions = {
}
LOG("accounts_to_exclude:"+prefValue);
- firetray.Utils.prefService.setCharPref('accounts_to_exclude', prefValue.toString());
+ firetray.Messaging.setPrefAccountsExcluded(prefValue);
firetray.Messaging.updateUnreadMsgCount();
},
@@ -81,3 +111,144 @@ firetray.UIOptions = {
}
};
+
+// input.onkeypress = function(evt) {
+// evt = evt || window.event;
+// var charCode = evt.which || evt.keyCode;
+// var charStr = String.fromCharCode(charCode);
+// if (/\d/.test(charStr)) {
+// return false;
+// }
+// };
+
+/*
+var treeView = {
+ model : {},
+ treeBox: null,
+ get rowCount(){return this.model.length;},
+ getCellText : function(row,column) { return this.model[row][column.id]; },
+ setTree: function(treeBox){ this.treeBox = treeBox; },
+ isContainer: function(row){ return false; },
+ isEditable: function(idx, column) { return true; },
+ isSeparator: function(row){ return false; },
+ isSorted: function(){ return false; },
+ getLevel: function(row){ return 0; },
+ getImageSrc: function(row,col){ return null; },
+ getRowProperties: function(row,props){},
+ getCellProperties: function(row,col,props){},
+ getColumnProperties: function(colid,col,props){},
+ setCellText: function (row, col, val){this.model[row][col.id] = val;}
+};
+
+function setView(){
+ try {
+ var str = firetray.Utils.prefService.getCharPref("jsondata");
+ treeView.model = JSON.parse(str);
+ } catch (err) {
+ treeView.model = [];
+ }
+ LOG("setView " + treeView.model.length);
+ document.getElementById('optTree').view = treeView;
+}
+
+function deleteSelection(){
+ var t = document.getElementById('optTree');
+ treeView.model.splice(t.currentIndex, 1);
+ treeView.treeBox.rowCountChanged(t.currentIndex, -1);
+}
+
+function addItem(){
+ treeView.model[treeView.model.length] = {name:"new label", regex:"new regex", subs:"new subs"};
+ treeView.treeBox.rowCountChanged(treeView.model.length-1, 1);
+}
+
+function saveList(){
+ let str = JSON.stringify(treeView.model);
+ LOG(str);
+ // firetray.Utils.prefService.setCharPref("jsondata", str);
+ return str;
+}
+
+// window.addEventListener('unload', saveList, false);
+*/
+
+/*
+ * Save the Schedules List to the "extensions.hpsched.schedules" preference.
+ * This is called by the pref's system when the GUI element is altered.
+ */
+function saveTree() {
+ let tree = document.getElementById("optTree");
+ let items = document.getElementById("rows").childNodes;
+
+ let prefObj = {};
+ for (let i=0; i < items.length; i++) {
+ let cells = items[i].getElementsByTagName("treecell");
+ LOG("CELLS:"+ tree.view.getCellText(i,
+ tree.columns["name"]));
+ // tree.columns.getColumnAt(0)));
+ // tree.columns.getNamedColumn("name")));
+ prefObj[cells[0].label] = {regex: cells[1].label, subs: cells[2].label};
+ }
+
+ let prefStr = JSON.stringify(prefObj);
+ // let prefStr = JSON.stringify(treeView.model);
+ LOG("prefStr"+prefStr);
+
+ /* return the new prefString to be stored by pref system */
+ return prefStr;
+}
+
+function addItem() {
+ let targetTree = document.getElementById("rows");
+
+ let item = document.createElement('treeitem');
+ let row = document.createElement('treerow');
+ item.appendChild(row);
+
+ let cell = document.createElement('treecell');
+ row.appendChild(cell);
+ cell = document.createElement('treecell');
+ row.appendChild(cell);
+ cell = document.createElement('treecell');
+ row.appendChild(cell);
+
+ targetTree.appendChild(item);
+}
+
+function populateTree() {
+ let prefPane = document.getElementById("pane1");
+
+ let prefStr = firetray.Utils.prefService.getCharPref("jsondata");
+ let prefObj = JSON.parse(prefStr);
+
+ let targetTree = document.getElementById("rows");
+ for (r in prefObj) {
+ let name = prefObj[r];
+
+ let item = document.createElement('treeitem');
+ let row = document.createElement('treerow');
+ item.appendChild(row);
+
+ let cell = document.createElement('treecell');
+ cell.setAttribute('label',r);
+ cell.addEventListener
+ ('change', function() {
+ LOG("CHANGE: "+ firetray.Utils.prefService.getCharPref("jsondata"));
+ document.getElementById("pane1")
+ .userChangedValue(document.getElementById("optTree"));
+ });
+ cell.addEventListener('input', LOG("INPUT"));
+ // cell.oninput = 'document.getElementById("pane1").userChangedValue(document.getElementById("optTree"));';
+ row.appendChild(cell);
+
+ cell = document.createElement('treecell');
+ cell.setAttribute('label',name.regex);
+ row.appendChild(cell);
+
+ cell = document.createElement('treecell');
+ cell.setAttribute('label',name.subs);
+ row.appendChild(cell);
+
+ targetTree.appendChild(item);
+ }
+}
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 054c886..19688cc 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://firetray/skin/overlay.css" type="text/css"?>
<!DOCTYPE prefwindow SYSTEM "chrome://firetray/locale/options.dtd">
<prefwindow id="firetray-preferences"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@@ -13,18 +14,90 @@
<preferences>
<preference id="pref_bool_close_hides"
name="extensions.firetray.close_hides" type="bool"/>
+ <preference id="pref_string_jsondata"
+ name="extensions.firetray.jsondata" type="string"/>
</preferences>
- <groupbox>
- <checkbox id="ui_close_hides" preference="pref_bool_close_hides"
- label="&bool_close_hides.label;"
- accesskey="&bool_close_hides.accesskey;"/>
- </groupbox>
- <groupbox id="accounts_box"> <!-- firetray.UIOptions.accountBoxId -->
- <caption label="&mail_accounts_exclude;"/>
- <!-- accounts are dynamically added here with insert_accounts_name() functions, called at the bottom of this file -->
- </groupbox>
+ <tabbox>
+ <tabs>
+ <tab label="&general_options;"/>
+ <tab label="&input_options;"/>
+ <tab label="&mail_options;" id="mail_tab" />
+ </tabs>
+ <tabpanels>
+
+ <tabpanel id="general_tabpanel">
+
+ <vbox align="center" >
+ <button label="Add" oncommand="addItem();"/>
+ <button label="Delete" oncommand="deleteSelection();"/>
+ <separator class="thin" />
+ <tree id="optTree" height="200" width="500" flex="1"
+ seltype="single" editable="true"
+ preference-editable="true"
+ preference="pref_string_jsondata"
+ onsynctopreference="return saveTree();">
+ <treecols>
+ <treecol id="name" label="Name" primary="true" flex="1"
+ persist="width ordinal hidden" width="50"/>
+ <treecol id="regex" label="Regex" width="100" flex="1"/>
+ <treecol id="subs" label="Subs" width="300" flex="1"/>
+ </treecols>
+ <treechildren id="rows" />
+ </tree>
+ <separator class="thin" />
+ <label value="To edit a item doubleclick on it" />
+ </vbox>
+
+ <groupbox>
+ <checkbox id="ui_close_hides" preference="pref_bool_close_hides"
+ label="&bool_close_hides.label;"
+ accesskey="&bool_close_hides.accesskey;"/>
+ </groupbox>
+
+ </tabpanel>
+
+ <tabpanel id="input_tabpanel">
+ </tabpanel>
+
+ <tabpanel id="mail_tabpanel">
+
+ <groupbox id="ui_mail_account_types_exclude">
+ <caption label="&mail_account_types_exclude;" tooltiptext="HI" />
+
+ <tree rows="6" flex="1" editable="true" hidecolumnpicker="false">
+ <treecols>
+ <treecol id="col_active" label="Account" flex="1" tooltiptext="HI"/>
+ <treecol id="col_active" label="Excluded" type="checkbox" flex="1"
+ editable="true" />
+ <treecol id="col_name" label="Order" editable="true" flex="1"
+ hidden= "true" />
+ </treecols>
+
+ <treechildren id="ui_mail_account_types">
+ <!-- <treeitem> -->
+ <!-- <treerow> -->
+ <!-- <treecell label="Alice"/> -->
+ <!-- <treecell value="true"/> -->
+ <!-- <treecell label="1"/> -->
+ <!-- </treerow> -->
+ <!-- </treeitem> -->
+ </treechildren>
+ </tree>
+ </groupbox>
+
+ <groupbox id="ui_accounts_box"> <!-- firetray.UIOptions.accountBoxId -->
+ <caption label="&mail_accounts_exclude;"/>
+ <!-- accounts are dynamically added here with insert_accounts_name()
+ functions, called at the bottom of this file -->
+ </groupbox>
+
+ </tabpanel>
+
+
+ </tabpanels>
+ </tabbox>
</prefpane>
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index bced226..b734b97 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -1,5 +1,12 @@
<!ENTITY prefwindow.title "FireTray preferences">
<!ENTITY pane1.title "FireTray preferences">
+
+<!ENTITY general_options "General">
+<!ENTITY input_options "Input">
+<!ENTITY mail_options "Mail">
+
<!ENTITY bool_close_hides.label "Closing windows hides to tray">
<!ENTITY bool_close_hides.accesskey "C">
-<!ENTITY mail_accounts_exclude "Mail accounts to exclude" >
+
+<!ENTITY mail_account_types_exclude "Account types to exclude">
+<!ENTITY mail_accounts_exclude "Mail accounts to exclude">
diff --git a/src/chrome/skin/cbox-check.gif b/src/chrome/skin/cbox-check.gif
new file mode 100644
index 0000000..f6919f8
Binary files /dev/null and b/src/chrome/skin/cbox-check.gif differ
diff --git a/src/chrome/skin/overlay.css b/src/chrome/skin/overlay.css
index be53127..e6a7426 100644
--- a/src/chrome/skin/overlay.css
+++ b/src/chrome/skin/overlay.css
@@ -1,22 +1,4 @@
-/* This is just an example. You shouldn't do this. */
-#firetray-hello
-{
- color: red ! important;
-}
-#firetray-toolbar-button
-{
- list-style-image: url("chrome://firetray/skin/toolbar-button.png");
- -moz-image-region: rect(0px 24px 24px 0px);
-}
-#firetray-toolbar-button:hover
-{
- -moz-image-region: rect(24px 24px 48px 0px);
-}
-[iconsize="small"] #firetray-toolbar-button
-{
- -moz-image-region: rect( 0px 40px 16px 24px);
-}
-[iconsize="small"] #firetray-toolbar-button:hover
-{
- -moz-image-region: rect(24px 40px 40px 24px);
+treechildren::-moz-tree-checkbox(checked) {
+ /* css for checked cells */
+ list-style-image: url("chrome://global/skin/checkbox/cbox-check.gif");
}
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index 7c6b12d..9ee1254 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -6,4 +6,5 @@ pref("browser.tabs.warnOnClose", false);
// Extension prefs
pref("extensions.firetray.close_hides", true);
-pref("extensions.firetray.accounts_to_exclude", "");
+pref("extensions.firetray.accounts_to_exclude", "[]"); // JSON
+pref("extensions.firetray.jsondata", "{}"); // JSON
diff --git a/src/modules/FiretrayIconLinux.jsm b/src/modules/FiretrayIconLinux.jsm
index 79b3cd4..3f0581b 100644
--- a/src/modules/FiretrayIconLinux.jsm
+++ b/src/modules/FiretrayIconLinux.jsm
@@ -188,10 +188,8 @@ firetray.IconLinux = {
setText: function(text, color) { // TODO: split into smaller functions;
LOG("setText");
- if (typeof(text) != "string" ) {
- ERROR("'text' arguement must be toString()'d: ");
- return false;
- }
+ if (typeof(text) != "string")
+ throw new TypeError();
try {
// build background from image
@@ -203,7 +201,7 @@ firetray.IconLinux = {
// prepare colors/alpha
let colorMap = gdk.gdk_screen_get_system_colormap(gdk.gdk_screen_get_default());
let visual = gdk.gdk_colormap_get_visual(colorMap);
- let visualDepth = gdk.gdk_visual_get_depth(visual);
+ let visualDepth = visual.contents.depth;
LOG("colorMap="+colorMap+" visual="+visual+" visualDepth="+visualDepth);
let fore = new gdk.GdkColor;
fore.pixel = fore.red = fore.green = fore.blue = 0;
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 81a4f61..a6d3bc4 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -86,13 +86,32 @@ firetray.Messaging = {
},
/**
- * gets the accounts_to_exclude preference which is a stringified Array
+ * get/set accounts_to_exclude preference which is a stringified Array
* containing the keys of the accounts to exclude
*/
getPrefAccountsExcluded: function() {
- return firetray.Utils.prefService.getCharPref('accounts_to_exclude').split(',') || [];
+ return JSON.parse(
+ firetray.Utils.prefService.getCharPref('accounts_to_exclude'));
},
+ setPrefAccountsExcluded: function(aArray) {
+ if (!isArray(aArray)) throw new TypeError();
+ LOG(aArray);
+ firetray.Utils.prefService.setCharPref('accounts_to_exclude',
+ JSON.stringify(aArray));
+ },
+
+
+// window.addEventListener('unload', function(e){filteredClipboard.saveList();}, false); // TRY DIFFERENT EVENTS
+// var filteredClipboard = {
+// prefix:"extensions.filteredclipboard.",
+// saveList: function (){
+// var str = JSON.stringify(treeView.model);
+// var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+// prefManager.setCharPref(this.prefix + "jsondata", str);
+// },
+
+
/**
* computes total unread message count
* TODO: check news accounts shouldn't be considered
@@ -154,7 +173,7 @@ firetray.Messaging.Accounts = function(sortByTypeAndName) {
return;
}
if (typeof(sortByTypeAndName) !== "boolean")
- throw "sort arg must be a boolean";
+ throw new TypeError();
this.sortByTypeAndName = sortByTypeAndName;
};
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 543f259..074e021 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -2,7 +2,7 @@
var EXPORTED_SYMBOLS =
[ "firetray", "Cc", "Ci", "Cu", "LOG", "WARN", "ERROR",
- "FIREFOX_ID", "THUNDERBIRD_ID", "SEAMONKEY_ID" ];
+ "FIREFOX_ID", "THUNDERBIRD_ID", "SEAMONKEY_ID", "isArray" ];
const Cc = Components.classes;
const Ci = Components.interfaces;
@@ -87,3 +87,8 @@ firetray.Utils = {
}
};
+
+// http://stackoverflow.com/questions/767486/how-do-you-check-if-a-variable-is-an-array-in-javascript
+function isArray(o) {
+ return Object.prototype.toString.call(o) === '[object Array]';
+}
diff --git a/src/modules/gdk.jsm b/src/modules/gdk.jsm
index 35f3535..f79c398 100644
--- a/src/modules/gdk.jsm
+++ b/src/modules/gdk.jsm
@@ -59,7 +59,7 @@ function gdk_defines(lib) {
this.GdkByteOrder = ctypes.int; // enum
this.GdkVisualType = ctypes.int; // enum
this.GdkVisual = ctypes.StructType("GdkVisual", [
- { "parent_instance": ctypes.void_t.ptr }, // gobject.GObject }, // FIXME !!
+ { "parent_instance": gobject.GObject },
{ "type": this.GdkVisualType },
{ "depth": gobject.gint },
{ "byte": this.GdkByteOrder },
@@ -127,6 +127,7 @@ function gdk_defines(lib) {
lib.lazy_bind("gdk_screen_get_system_colormap", this.GdkColormap.ptr, this.GdkScreen.ptr);
lib.lazy_bind("gdk_colormap_get_visual", this.GdkVisual.ptr, this.GdkColormap.ptr);
lib.lazy_bind("gdk_visual_get_depth", gobject.gint, this.GdkVisual.ptr);
+ lib.lazy_bind("gdk_visual_get_best_depth", gobject.gint);
lib.lazy_bind("gdk_color_parse", gobject.gboolean, gobject.gchar.ptr, this.GdkColor.ptr);
lib.lazy_bind("gdk_colormap_alloc_color", gobject.gboolean, this.GdkColormap.ptr, this.GdkColor.ptr, gobject.gboolean, gobject.gboolean);
lib.lazy_bind("gdk_pixmap_new", this.GdkPixmap.ptr, this.GdkDrawable.ptr, gobject.gint, gobject.gint, gobject.gint);
diff --git a/src/modules/gobject.jsm b/src/modules/gobject.jsm
index 6eb25a4..53fe463 100644
--- a/src/modules/gobject.jsm
+++ b/src/modules/gobject.jsm
@@ -50,7 +50,7 @@ Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://firetray/ctypes-utils.jsm");
function gobject_defines(lib) {
- this.GObject = ctypes.StructType("GObject");
+
this.gpointer = ctypes.voidptr_t;
this.gulong = ctypes.unsigned_long;
this.guint = ctypes.unsigned_int;
@@ -61,12 +61,28 @@ function gobject_defines(lib) {
this.guchar = ctypes.unsigned_char;
this.gboolean = this.gint;
this.gfloat = ctypes.float;
+ this.gsize = ctypes.unsigned_long;
this.GCallback = ctypes.voidptr_t;
this.GClosureNotify = this.gpointer;
this.GConnectFlags = this.guint;
this.GFunc = ctypes.void_t.ptr;
this.GList = ctypes.StructType("GList");
+ this.GType = this.gsize;
+ this.GData = ctypes.StructType("GData");
+ this._GTypeClass = ctypes.StructType("_GTypeClass", [
+ {g_type: this.GType}]);
+ this._GTypeInstance = ctypes.StructType("_GTypeInstance", [
+ {g_class: this._GTypeClass.ptr}]);
+ /* "All the fields in the GObject structure are private to the GObject
+ * implementation and should never be accessed directly." but we need to tell
+ * something about it to access GdkVisual fields */
+ this.GObject = ctypes.StructType("GObject", [
+ { g_type_instance: this._GTypeInstance },
+ { ref_count: this.guint },
+ { qdata: this.GData.ptr },
+ ]);
+
/* NOTE: if we needed more/different args, we'd need to implement another
FunctionType */
this.GCallback_t = ctypes.FunctionType(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list