[Stats] Update gtkui from libglade to gtkbuilder
- Additionally fixes #2977 num_connections KeyError and #2947 AttributeError.
This commit is contained in:
parent
665c047541
commit
676574ff19
|
@ -77,14 +77,15 @@ class Core(CorePluginBase):
|
|||
self.length = self.config['length']
|
||||
|
||||
# self.stats = get_key(self.saved_stats, 'stats') or {}
|
||||
self.stats_keys = []
|
||||
self.stats_keys = ['peer.num_peers_half_open', 'dht.dht_node_cache']
|
||||
self.add_stats(
|
||||
'upload_rate',
|
||||
'download_rate',
|
||||
'dht_nodes',
|
||||
'dht_node_cache',
|
||||
'dht_cache_nodes',
|
||||
'dht_torrents',
|
||||
'num_peers',
|
||||
'num_connections'
|
||||
)
|
||||
|
||||
self.update_stats()
|
||||
|
@ -122,7 +123,8 @@ class Core(CorePluginBase):
|
|||
stats.update(self.core.get_session_status([key]))
|
||||
except AttributeError:
|
||||
pass
|
||||
stats['num_connections'] = stats['num_peers']
|
||||
stats['num_connections'] = stats['num_peers'] + stats['peer.num_peers_half_open']
|
||||
stats['dht_cache_nodes'] = stats['dht.dht_node_cache']
|
||||
stats.update(self.core.get_config_values(['max_download',
|
||||
'max_upload',
|
||||
'max_num_connections']))
|
||||
|
|
|
@ -1,34 +1,39 @@
|
|||
<?xml version="1.0"?>
|
||||
<glade-interface>
|
||||
<!-- interface-requires gtk+ 2.16 -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.24"/>
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<widget class="GtkWindow" id="window1">
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="prefs_box">
|
||||
<object class="GtkVBox" id="prefs_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkFrame" id="frame1">
|
||||
<object class="GtkFrame" id="frame1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment4">
|
||||
<object class="GtkAlignment" id="alignment4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">15</property>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table2">
|
||||
<object class="GtkTable" id="table2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="n_rows">10</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">15</property>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="bandwidth_graph_download_rate_color">
|
||||
<object class="GtkColorButton" id="bandwidth_graph_download_rate_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -38,34 +43,37 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Download color:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Upload color:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="bandwidth_graph_upload_rate_color">
|
||||
<object class="GtkColorButton" id="bandwidth_graph_upload_rate_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -75,12 +83,13 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label8">
|
||||
<object class="GtkLabel" id="label8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Connections Graph</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
|
@ -88,23 +97,25 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label9">
|
||||
<object class="GtkLabel" id="label9">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Bandwidth Graph</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="right_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="connections_graph_dht_nodes_color">
|
||||
<object class="GtkColorButton" id="connections_graph_dht_nodes_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -114,23 +125,25 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label10">
|
||||
<object class="GtkLabel" id="label10">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">DHT nodes:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="connections_graph_dht_cache_nodes_color">
|
||||
<object class="GtkColorButton" id="connections_graph_dht_cache_nodes_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -140,45 +153,49 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label11">
|
||||
<object class="GtkLabel" id="label11">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Cached DHT nodes:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<object class="GtkLabel" id="label12">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">DHT torrents:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="bottom_attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label13">
|
||||
<object class="GtkLabel" id="label13">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Connections:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="bottom_attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="connections_graph_dht_torrents_color">
|
||||
<object class="GtkColorButton" id="connections_graph_dht_torrents_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -188,12 +205,13 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="connections_graph_num_connections_color">
|
||||
<object class="GtkColorButton" id="connections_graph_num_connections_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -203,12 +221,13 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label16">
|
||||
<object class="GtkLabel" id="label16">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Seeds / Peers</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">8</property>
|
||||
|
@ -216,12 +235,13 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="seeds_graph_num_peers_color">
|
||||
<object class="GtkColorButton" id="seeds_graph_num_peers_color">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
|
@ -231,36 +251,37 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label17">
|
||||
<object class="GtkLabel" id="label17">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Peers:</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">9</property>
|
||||
<property name="bottom_attach">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>Graph Colors</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
</object>
|
||||
</interface>
|
|
@ -1,60 +1,62 @@
|
|||
<?xml version="1.0"?>
|
||||
<glade-interface>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 2.6 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<widget class="GtkWindow" id="window1">
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="graph_label">
|
||||
<object class="GtkHBox" id="graph_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkImage" id="image1">
|
||||
<object class="GtkLabel" id="graph_label_text">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-page-setup</property>
|
||||
</widget>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Stats</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="graph_label_text">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Graphs</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="graph_tab">
|
||||
<object class="GtkScrolledWindow" id="graph_tab">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<child>
|
||||
<widget class="GtkViewport" id="viewport1">
|
||||
<object class="GtkViewport" id="viewport1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resize_mode">queue</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<object class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<object class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Resolution</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
|
@ -62,16 +64,17 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="combo_intervals">
|
||||
<object class="GtkComboBox" id="combo_intervals">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
|
@ -79,78 +82,85 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkNotebook" id="graph_notebook">
|
||||
<object class="GtkNotebook" id="graph_notebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="tab_pos">left</property>
|
||||
<child>
|
||||
<widget class="GtkDrawingArea" id="bandwidth_graph">
|
||||
<object class="GtkDrawingArea" id="bandwidth_graph">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="bandwidth_label">
|
||||
<child type="tab">
|
||||
<object class="GtkLabel" id="bandwidth_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Bandwidth</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab_fill">False</property>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkDrawingArea" id="connections_graph">
|
||||
<object class="GtkDrawingArea" id="connections_graph">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="connections_label">
|
||||
<child type="tab">
|
||||
<object class="GtkLabel" id="connections_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Connections</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
<property name="tab_fill">False</property>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkDrawingArea" id="seeds_graph">
|
||||
<object class="GtkDrawingArea" id="seeds_graph">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="seeds_label">
|
||||
<child type="tab">
|
||||
<object class="GtkLabel" id="seeds_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Seeds/Peers</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
<property name="tab_fill">False</property>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
</object>
|
||||
</interface>
|
|
@ -17,8 +17,6 @@ from __future__ import division, unicode_literals
|
|||
import logging
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
from gtk.glade import XML
|
||||
|
||||
import deluge
|
||||
from deluge import component
|
||||
|
@ -27,7 +25,7 @@ from deluge.plugins.pluginbase import GtkPluginBase
|
|||
from deluge.ui.client import client
|
||||
from deluge.ui.gtkui.torrentdetails import Tab
|
||||
|
||||
from . import common
|
||||
from .common import get_resource
|
||||
from .graph import Graph, size_formatter_scale
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -69,6 +67,10 @@ def int_str(number):
|
|||
return str(int(number))
|
||||
|
||||
|
||||
def fspeed_shortform(value):
|
||||
return fspeed(value, shortform=True)
|
||||
|
||||
|
||||
def gtk_to_graph_color(color):
|
||||
"""Turns a gtk.gdk.Color into a tuple with range 0-1 as used by the graph"""
|
||||
gtk_color = gtk.gdk.Color(color)
|
||||
|
@ -79,26 +81,28 @@ def gtk_to_graph_color(color):
|
|||
|
||||
|
||||
class GraphsTab(Tab):
|
||||
def __init__(self, glade, colors):
|
||||
def __init__(self, colors):
|
||||
super(GraphsTab, self).__init__()
|
||||
self.glade = glade
|
||||
self.window = self.glade.get_widget('graph_tab')
|
||||
self.notebook = self.glade.get_widget('graph_notebook')
|
||||
self.label = self.glade.get_widget('graph_label')
|
||||
|
||||
self._name = 'Graphs'
|
||||
builder = gtk.Builder()
|
||||
builder.add_from_file(get_resource('tabs.ui'))
|
||||
self.window = builder.get_object('graph_tab')
|
||||
self.notebook = builder.get_object('graph_notebook')
|
||||
self.label = builder.get_object('graph_label')
|
||||
|
||||
self._name = 'Stats'
|
||||
self._child_widget = self.window
|
||||
self._tab_label = self.label
|
||||
|
||||
self.colors = colors
|
||||
|
||||
self.bandwidth_graph = self.glade.get_widget('bandwidth_graph')
|
||||
self.bandwidth_graph = builder.get_object('bandwidth_graph')
|
||||
self.bandwidth_graph.connect('expose_event', self.graph_expose)
|
||||
|
||||
self.connections_graph = self.glade.get_widget('connections_graph')
|
||||
self.connections_graph = builder.get_object('connections_graph')
|
||||
self.connections_graph.connect('expose_event', self.graph_expose)
|
||||
|
||||
self.seeds_graph = self.glade.get_widget('seeds_graph')
|
||||
self.seeds_graph = builder.get_object('seeds_graph')
|
||||
self.seeds_graph.connect('expose_event', self.graph_expose)
|
||||
|
||||
self.notebook.connect('switch-page', self._on_notebook_switch_page)
|
||||
|
@ -110,7 +114,7 @@ class GraphsTab(Tab):
|
|||
self.label.unparent()
|
||||
|
||||
self.intervals = None
|
||||
self.intervals_combo = self.glade.get_widget('combo_intervals')
|
||||
self.intervals_combo = builder.get_object('combo_intervals')
|
||||
cell = gtk.CellRendererText()
|
||||
self.intervals_combo.pack_start(cell, True)
|
||||
self.intervals_combo.set_cell_data_func(cell, neat_time)
|
||||
|
@ -153,7 +157,7 @@ class GraphsTab(Tab):
|
|||
color=gtk_to_graph_color(colors['download_rate']))
|
||||
self.graph.add_stat('upload_rate', label='Upload Rate',
|
||||
color=gtk_to_graph_color(colors['upload_rate']))
|
||||
self.graph.set_left_axis(formatter=fspeed, min=10240,
|
||||
self.graph.set_left_axis(formatter=fspeed_shortform, min=10240,
|
||||
formatter_scale=size_formatter_scale)
|
||||
|
||||
def select_connections_graph(self):
|
||||
|
@ -221,13 +225,16 @@ class GtkUI(GtkPluginBase):
|
|||
def enable(self):
|
||||
log.debug('Stats plugin enable called')
|
||||
self.config = deluge.configmanager.ConfigManager('stats.gtkui.conf', DEFAULT_CONF)
|
||||
self.glade = XML(common.get_resource('config.glade'))
|
||||
component.get('Preferences').add_page('Stats', self.glade.get_widget('prefs_box'))
|
||||
|
||||
self.builder = gtk.Builder()
|
||||
self.builder.add_from_file(get_resource('config.ui'))
|
||||
|
||||
component.get('Preferences').add_page('Stats', self.builder.get_object('prefs_box'))
|
||||
component.get('PluginManager').register_hook('on_apply_prefs', self.on_apply_prefs)
|
||||
component.get('PluginManager').register_hook('on_show_prefs', self.on_show_prefs)
|
||||
self.on_show_prefs()
|
||||
|
||||
self.graphs_tab = GraphsTab(XML(common.get_resource('tabs.glade')), self.config['colors'])
|
||||
self.graphs_tab = GraphsTab(self.config['colors'])
|
||||
self.torrent_details = component.get('TorrentDetails')
|
||||
self.torrent_details.add_tab(self.graphs_tab)
|
||||
|
||||
|
@ -244,7 +251,7 @@ class GtkUI(GtkPluginBase):
|
|||
gtkconf[graph] = {}
|
||||
for value, color in colors.items():
|
||||
try:
|
||||
color_btn = self.glade.get_widget('%s_%s_color' % (graph, value))
|
||||
color_btn = self.builder.get_object('%s_%s_color' % (graph, value))
|
||||
gtkconf[graph][value] = str(color_btn.get_color())
|
||||
except Exception:
|
||||
gtkconf[graph][value] = DEFAULT_CONF['colors'][graph][value]
|
||||
|
@ -258,7 +265,7 @@ class GtkUI(GtkPluginBase):
|
|||
for graph, colors in self.config['colors'].items():
|
||||
for value, color in colors.items():
|
||||
try:
|
||||
color_btn = self.glade.get_widget('%s_%s_color' % (graph, value))
|
||||
color_btn = self.builder.get_object('%s_%s_color' % (graph, value))
|
||||
color_btn.set_color(gtk.gdk.Color(color))
|
||||
except Exception:
|
||||
log.debug('Unable to set %s %s %s', graph, value, color)
|
||||
|
|
Loading…
Reference in New Issue