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

[tor-commits] [arm/master] Initial commit for config panel.



commit 86944555219eaa43bc7d14aa87082ed831877997
Author: Kamran Riaz Khan <krkhan@xxxxxxxxxxxxxx>
Date:   Wed Jul 20 17:04:57 2011 +0500

    Initial commit for config panel.
    
    List values and show desc in the text view.
---
 src/gui/arm.xml        |  155 ++++++++++++++++++++++++++++++++++++------------
 src/gui/configPanel.py |   59 ++++++++++++++++++
 src/gui/controller.py  |    3 +-
 3 files changed, 178 insertions(+), 39 deletions(-)

diff --git a/src/gui/arm.xml b/src/gui/arm.xml
index 2b9ad95..6c206fd 100644
--- a/src/gui/arm.xml
+++ b/src/gui/arm.xml
@@ -26,56 +26,32 @@
       <column type="gchararray"/>
     </columns>
   </object>
-  <object class="GtkListStore" id="liststore_config">
+  <object class="GtkListStore" id="liststore_log">
     <columns>
-      <!-- column-name key -->
+      <!-- column-name timestamp_raw -->
+      <column type="gulong"/>
+      <!-- column-name timestamp -->
       <column type="gchararray"/>
-      <!-- column-name value -->
+      <!-- column-name type -->
       <column type="gchararray"/>
-      <!-- column-name desc -->
+      <!-- column-name msg -->
       <column type="gchararray"/>
       <!-- column-name foreground -->
       <column type="gchararray"/>
     </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">BandwidthRate</col>
-        <col id="1" translatable="yes">5242880</col>
-        <col id="2" translatable="yes">Average bandwidth usage limit</col>
-        <col id="3" translatable="yes">#368918</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">BandwidthBurst</col>
-        <col id="1" translatable="yes">10485760</col>
-        <col id="2" translatable="yes">Maximum bandwidth usage limit</col>
-        <col id="3" translatable="yes">#368918</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">RelayBandwidthBurst</col>
-        <col id="1" translatable="yes">0 B</col>
-        <col id="2" translatable="yes">Maximum bandwidth usage limit for relaying</col>
-        <col id="3" translatable="yes">#368918</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">ControlPort</col>
-        <col id="1" translatable="yes">9051</col>
-        <col id="2" translatable="yes">Port providing access to tor controllers (arm, vidalia, etc)</col>
-        <col id="3" translatable="yes">#368918</col>
-      </row>
-    </data>
   </object>
-  <object class="GtkListStore" id="liststore_log">
+  <object class="GtkListStore" id="liststore_config">
     <columns>
-      <!-- column-name timestamp_raw -->
-      <column type="gulong"/>
-      <!-- column-name timestamp -->
+      <!-- column-name option -->
       <column type="gchararray"/>
-      <!-- column-name type -->
+      <!-- column-name value -->
       <column type="gchararray"/>
-      <!-- column-name msg -->
+      <!-- column-name summary -->
       <column type="gchararray"/>
       <!-- column-name foreground -->
       <column type="gchararray"/>
+      <!-- column-name desc -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkWindow" id="window_main">
@@ -410,6 +386,106 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkVPaned" id="vpaned_config">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="GtkScrolledWindow" id="scrolledwindow_config_desc">
+                            <property name="height_request">60</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hscrollbar_policy">automatic</property>
+                            <property name="vscrollbar_policy">automatic</property>
+                            <child>
+                              <object class="GtkTextView" id="textview_config_desc">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="editable">False</property>
+                                <property name="wrap_mode">word</property>
+                                <property name="cursor_visible">False</property>
+                                <property name="buffer">textbuffer_config_desc</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="resize">False</property>
+                            <property name="shrink">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkScrolledWindow" id="scrolledwindow_config">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hscrollbar_policy">automatic</property>
+                            <property name="vscrollbar_policy">automatic</property>
+                            <child>
+                              <object class="GtkTreeView" id="treeview_config">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="model">liststore_config</property>
+                                <property name="headers_clickable">False</property>
+                                <property name="search_column">0</property>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn_config_option">
+                                    <property name="title">Option</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderertext_config_option"/>
+                                      <attributes>
+                                        <attribute name="foreground">3</attribute>
+                                        <attribute name="text">0</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn_config_value">
+                                    <property name="title">Value</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderertext_config_value"/>
+                                      <attributes>
+                                        <attribute name="foreground">3</attribute>
+                                        <attribute name="text">1</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn_config_summary">
+                                    <property name="title">Description</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderertext_config_summary"/>
+                                      <attributes>
+                                        <attribute name="foreground">3</attribute>
+                                        <attribute name="text">2</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="resize">True</property>
+                            <property name="shrink">True</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child type="tab">
+                      <object class="GtkLabel" id="label_config">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Configuration</property>
+                      </object>
+                      <packing>
+                        <property name="position">3</property>
+                        <property name="tab_fill">False</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkScrolledWindow" id="scrolledwindow_general">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
@@ -451,7 +527,7 @@
                         </child>
                       </object>
                       <packing>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                     <child type="tab">
@@ -460,7 +536,7 @@
                         <property name="label" translatable="yes">General</property>
                       </object>
                       <packing>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                         <property name="tab_fill">False</property>
                       </packing>
                     </child>
@@ -1264,4 +1340,7 @@ Damian Johnson &lt;atagar1@xxxxxxxxx&gt;</property>
     <property name="stock_id">gtk-about</property>
     <signal name="activate" handler="on_action_about_activate"/>
   </object>
+  <object class="GtkTextBuffer" id="textbuffer_config_desc">
+    <property name="text" translatable="yes">Select a configuration option to see its description.</property>
+  </object>
 </interface>
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
new file mode 100644
index 0000000..4001058
--- /dev/null
+++ b/src/gui/configPanel.py
@@ -0,0 +1,59 @@
+"""
+Configuration panel.
+"""
+
+import random
+import sys
+import time
+
+import gobject
+import gtk
+
+from cli.configPanel import (ConfigPanel as CliConfigPanel, Field, State)
+from util import connections, gtkTools, sysTools, torTools, uiTools
+from TorCtl import TorCtl
+
+class ConfigPanel(CliConfigPanel):
+  def __init__(self, builder):
+    CliConfigPanel.__init__(self, None, State.TOR)
+
+    self.builder = builder
+
+    gobject.idle_add(self._fill_entries)
+    gobject.timeout_add(3000, self._timeout_fill_entries)
+
+  def pack_widgets(self):
+    treeView = self.builder.get_object('treeview_config')
+    treeView.connect('cursor-changed', self.on_treeview_config_cursor_changed)
+
+  def _timeout_fill_entries(self):
+    self._fill_entries()
+
+    return True
+
+  def _fill_entries(self):
+    self.valsLock.acquire()
+
+    listStore = self.builder.get_object('liststore_config')
+    listStore.clear()
+
+    for entry in self._getConfigOptions():
+      option = entry.get(Field.OPTION)
+      value = entry.get(Field.VALUE)
+      summary = entry.get(Field.SUMMARY)
+      desc = entry.get(Field.DESCRIPTION)
+      row = (option, value, summary, '#368918', desc)
+      listStore.append(row)
+
+    self.valsLock.release()
+
+  def on_treeview_config_cursor_changed(self, widget, data=None):
+    treeSelection = widget.get_selection()
+
+    (model, iter) = treeSelection.get_selected()
+    desc = model.get_value(iter, 4)
+
+    textBuffer = self.builder.get_object('textbuffer_config_desc')
+    textBuffer.set_text(desc)
+    print desc
+
diff --git a/src/gui/controller.py b/src/gui/controller.py
index 19b9513..52bb2c6 100644
--- a/src/gui/controller.py
+++ b/src/gui/controller.py
@@ -6,7 +6,7 @@ import gtk
 
 from connections import connPanel
 from gui.graphing import bandwidthStats
-from gui import generalPanel, logPanel
+from gui import configPanel, generalPanel, logPanel
 from util import log, torTools
 
 gobject.threads_init()
@@ -29,6 +29,7 @@ class GuiController:
     panelClasses = (logPanel.LogPanel,
               bandwidthStats.BandwidthStats,
               connPanel.ConnectionPanel,
+              configPanel.ConfigPanel,
               generalPanel.GeneralPanel)
     self.panels = {}
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits