Exemplo n.º 1
0
    def __init__(self):
        gtk.HBox.__init__(self)
        self.traffic_manager = tgcm.core.TrafficManager.TrafficManager()

        self.widget_dir = os.path.join(tgcm.widgets_dir, 'traffic',
                                       self.__class__.__name__)
        gtk_builder_magic(self, \
                filename=os.path.join(self.widget_dir, 'SessionInfo.ui'), \
                prefix='si')

        self.traffic_widget = TrafficGraph()
        self.traffic_widget_area.add(self.traffic_widget)
        self.traffic_widget.show()
        self.add(self.main_widget)
        self.main_widget.show_all()

        self.main_widget.modify_bg(gtk.STATE_NORMAL,
                                   gtk.gdk.color_parse("white"))
        self.data_transfered_label.set_markup("<small><b>--</b></small>")

        self.max_speed = 0

        #Signals
        self.traffic_manager.connect("update-session-time",
                                     self.__update_session_time_cb)
        self.traffic_manager.connect("update-session-data-transfered",
                                     self.__update_session_data_transfered_cb)
        self.traffic_manager.connect("reset-session-data-transfered",
                                     self.__reset_session_data_transfered_cb)
        # -- The received speed must be in kilo bytes per second
        self.traffic_manager.connect("update-session-max-speed",
                                     self.__update_session_max_speed_cb)
        self.traffic_manager.connect("reset-session-max-speed",
                                     self.__reset_session_max_speed_cb)
Exemplo n.º 2
0
class SessionInfo(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        self.traffic_manager = tgcm.core.TrafficManager.TrafficManager()

        self.widget_dir = os.path.join(tgcm.widgets_dir, 'traffic',
                                       self.__class__.__name__)
        gtk_builder_magic(self, \
                filename=os.path.join(self.widget_dir, 'SessionInfo.ui'), \
                prefix='si')

        self.traffic_widget = TrafficGraph()
        self.traffic_widget_area.add(self.traffic_widget)
        self.traffic_widget.show()
        self.add(self.main_widget)
        self.main_widget.show_all()

        self.main_widget.modify_bg(gtk.STATE_NORMAL,
                                   gtk.gdk.color_parse("white"))
        self.data_transfered_label.set_markup("<small><b>--</b></small>")

        self.max_speed = 0

        #Signals
        self.traffic_manager.connect("update-session-time",
                                     self.__update_session_time_cb)
        self.traffic_manager.connect("update-session-data-transfered",
                                     self.__update_session_data_transfered_cb)
        self.traffic_manager.connect("reset-session-data-transfered",
                                     self.__reset_session_data_transfered_cb)
        # -- The received speed must be in kilo bytes per second
        self.traffic_manager.connect("update-session-max-speed",
                                     self.__update_session_max_speed_cb)
        self.traffic_manager.connect("reset-session-max-speed",
                                     self.__reset_session_max_speed_cb)

    def __update_session_time_cb(self, traffic_manager, h, m, s):
        self.session_time_label.set_markup("<small>%02d:%02d:%02d</small>" %
                                           (h, m, s))

    def __update_session_data_transfered_cb(self, traffic_manager, bytes):
        self.data_transfered_label.set_markup("<small><b>%s</b></small>" % \
                format_to_maximun_unit(bytes,"GB","MB","KB","Bytes") )

    def __reset_session_data_transfered_cb(self, traffic_manager):
        self.data_transfered_label.set_markup("<small><b>--</b></small>")

    # -- The received speed must be in kilo bytes per second
    def __update_session_max_speed_cb(self, trafficm, data):
        new_speed = float(data * 8) / 1024.0
        _str = "<small><b>%.2f Kbits/s</b></small>" % new_speed
        self.maximum_speed_label.set_markup(_str)

    def __reset_session_max_speed_cb(self, trafficm):
        self.maximum_speed_label.set_markup("--")
Exemplo n.º 3
0
    def __init__(self):
        gtk.HBox.__init__(self)
        self.traffic_manager = tgcm.core.TrafficManager.TrafficManager()

        self.widget_dir = os.path.join(tgcm.widgets_dir , 'traffic', self.__class__.__name__)
        gtk_builder_magic(self, \
                filename=os.path.join(self.widget_dir, 'SessionInfo.ui'), \
                prefix='si')

        self.traffic_widget = TrafficGraph()
        self.traffic_widget_area.add(self.traffic_widget)
        self.traffic_widget.show()
        self.add(self.main_widget)
        self.main_widget.show_all()

        self.main_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
        self.data_transfered_label.set_markup("<small><b>--</b></small>")

        self.max_speed = 0

        #Signals
        self.traffic_manager.connect("update-session-time", self.__update_session_time_cb)
        self.traffic_manager.connect("update-session-data-transfered" , self.__update_session_data_transfered_cb)
        self.traffic_manager.connect("reset-session-data-transfered"  , self.__reset_session_data_transfered_cb)
        # -- The received speed must be in kilo bytes per second
        self.traffic_manager.connect("update-session-max-speed" , self.__update_session_max_speed_cb)
        self.traffic_manager.connect("reset-session-max-speed"  , self.__reset_session_max_speed_cb)
Exemplo n.º 4
0
class SessionInfo (gtk.HBox) :
    def __init__(self):
        gtk.HBox.__init__(self)
        self.traffic_manager = tgcm.core.TrafficManager.TrafficManager()

        self.widget_dir = os.path.join(tgcm.widgets_dir , 'traffic', self.__class__.__name__)
        gtk_builder_magic(self, \
                filename=os.path.join(self.widget_dir, 'SessionInfo.ui'), \
                prefix='si')

        self.traffic_widget = TrafficGraph()
        self.traffic_widget_area.add(self.traffic_widget)
        self.traffic_widget.show()
        self.add(self.main_widget)
        self.main_widget.show_all()

        self.main_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
        self.data_transfered_label.set_markup("<small><b>--</b></small>")

        self.max_speed = 0

        #Signals
        self.traffic_manager.connect("update-session-time", self.__update_session_time_cb)
        self.traffic_manager.connect("update-session-data-transfered" , self.__update_session_data_transfered_cb)
        self.traffic_manager.connect("reset-session-data-transfered"  , self.__reset_session_data_transfered_cb)
        # -- The received speed must be in kilo bytes per second
        self.traffic_manager.connect("update-session-max-speed" , self.__update_session_max_speed_cb)
        self.traffic_manager.connect("reset-session-max-speed"  , self.__reset_session_max_speed_cb)

    def __update_session_time_cb(self, traffic_manager, h, m, s):
        self.session_time_label.set_markup("<small>%02d:%02d:%02d</small>" % (h,m,s))

    def __update_session_data_transfered_cb(self, traffic_manager, bytes):
        self.data_transfered_label.set_markup("<small><b>%s</b></small>" % \
                format_to_maximun_unit(bytes,"GB","MB","KB","Bytes") )

    def __reset_session_data_transfered_cb(self, traffic_manager):
        self.data_transfered_label.set_markup("<small><b>--</b></small>")

    # -- The received speed must be in kilo bytes per second
    def __update_session_max_speed_cb(self, trafficm, data):
        new_speed = float(data * 8) / 1024.0
        _str = "<small><b>%.2f Kbits/s</b></small>" % new_speed
        self.maximum_speed_label.set_markup(_str)

    def __reset_session_max_speed_cb(self, trafficm):
        self.maximum_speed_label.set_markup("--")