[tor-commits] [vidalia-plugins/master] Skeleton for the plugin done for the tutorial

chiiph at torproject.org chiiph at torproject.org
Tue Apr 17 22:49:15 UTC 2012


commit fbc6c26922dfefddbe3b5ba8401a425558e78a2f
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Mon Apr 16 20:31:27 2012 -0300

    Skeleton for the plugin done for the tutorial
---
 tutorial/info.xml    |   10 +++++++++
 tutorial/tutorial.js |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/tutorial/info.xml b/tutorial/info.xml
new file mode 100644
index 0000000..33c488f
--- /dev/null
+++ b/tutorial/info.xml
@@ -0,0 +1,10 @@
+<VidaliaPlugin>
+  <name>Bandwidth history</name>
+  <date>16/04/2012</date>
+  <author>chiiph</author>
+  <type persistent="true" gui="true" />
+  <files>
+    <file>tutorial.js</file>
+  </files>
+  <namespace>tutorial</namespace>
+</VidaliaPlugin>
diff --git a/tutorial/tutorial.js b/tutorial/tutorial.js
new file mode 100644
index 0000000..197928e
--- /dev/null
+++ b/tutorial/tutorial.js
@@ -0,0 +1,52 @@
+importExtension("qt");
+importExtension("qt.core");
+importExtension("qt.gui");
+importExtension("qt.uitools");
+
+var tutorial = {
+    start: function() {
+		    vdebug("Tutorial at start");
+        torControl["bandwidthUpdate(quint64, quint64)"].connect(this, this.saveBandwidth);
+    },
+
+    saveBandwidth: function(recv, sent) {
+        vdebug("Tutorial::Recv", recv);
+        vdebug("Totorial::Sent", sent);
+    },
+
+    buildGUI: function() {
+        vdebug("Tutorial at buildGUI");
+        // Load the GUI file
+        this.tab = new VidaliaTab("Display bandwidth history", "BandwidthHistory");
+
+        var file = new QFile(pluginPath+"/tutorial/tutorial.ui");
+        var loader = new QUiLoader(this.tab);
+        file.open(QIODevice.ReadOnly);
+        this.widget = loader.load(file);
+        var layout = new QVBoxLayout();
+        layout.addWidget(this.widget, 0, Qt.AlignCenter);
+        this.tab.setLayout(layout);
+        file.close();
+
+        var groupBox = this.widget.children()[findWidget(this.widget, "browserBox")];
+        if(groupBox == null) {
+            return this.tab;
+        }
+
+        this.btnSave = this.widget.children()[findWidget(this.widget, "btnSave")];
+        if(this.btnSave != null) {
+            this.btnSave["clicked()"].connect(this, this.saveSettings);
+        }
+
+        this.btnLaunch = groupBox.children()[findWidget(groupBox, "btnLaunch")];
+        if(this.btnLaunch != null) {
+            this.btnLaunch["clicked()"].connect(this, this.startSubProcess);
+        }
+
+        return this.tab;
+    },
+
+    stop: function() {
+        vdebug("Tutorial at stop");
+    },
+};





More information about the tor-commits mailing list