[polari] utils: Import some useful utility functions from gnome-documents



commit 72a5895109f5048093025e135152fbe43d8e7237
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jul 27 00:25:42 2013 +0200

    utils: Import some useful utility functions from gnome-documents

 src/Makefile.am |    1 +
 src/utils.js    |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f29556..0f4c3a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,6 +39,7 @@ dist_js_DATA = \
        mainWindow.js \
        roomList.js \
        userList.js \
+       utils.js \
        $(NULL)
 
 config.js: config.js.in Makefile
diff --git a/src/utils.js b/src/utils.js
new file mode 100644
index 0000000..b54d4fc
--- /dev/null
+++ b/src/utils.js
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Polari is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Polari is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Polari; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+const GLib = imports.gi.GLib;
+
+const Signals = imports.signals;
+
+let debugInit = false;
+let debugEnabled = false;
+
+function debug(str) {
+    if (!debugInit) {
+        let env = GLib.getenv('POLARI_DEBUG');
+        if (env)
+            debugEnabled = true;
+
+        debugInit = true;
+    }
+
+    if (debugEnabled)
+        log('DEBUG: ' + str);
+}
+
+function addJSSignalMethods(proto) {
+    proto.connectJS = Signals._connect;
+    proto.disconnectJS = Signals._disconnect;
+    proto.emitJS = Signals._emit;
+    proto.disconnectAllJS = Signals._disconnectAll;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]