Beispiel #1
0
    def do_expose_event(self, event):
        cr = self.window.cairo_create()

        cr.set_operator(cairo.OPERATOR_OVER)
        cr.set_source_rgba(0, 0, 0, 0.5)
        cr.paint()

        if self.hovering:
            line_width = self.pad_size / 3
            awn.cairo_rounded_rect(cr, line_width, line_width,
                                   self.allocation.width - line_width*2,
                                   self.allocation.height - line_width*2,
                                   10, awn.ROUND_ALL)
            cr.set_source_rgba(0.2, 0.2, 0.2, 0.5)
            cr.fill_preserve()
            cr.set_operator(cairo.OPERATOR_SOURCE)
            cr.set_source_rgba(0.8, 0.8, 0.8, 0.75)
            cr.set_line_width(line_width)
            cr.stroke()

        del cr

        # propagate expose
        child = self.get_child()
        if child is not None:
            self.propagate_expose(child, event)
        return True
Beispiel #2
0
    def do_expose_event(self, event):
        cr = self.window.cairo_create()

        cr.set_operator(cairo.OPERATOR_OVER)
        cr.set_source_rgba(0, 0, 0, 0.5)
        cr.paint()

        if self.hovering:
            line_width = self.pad_size / 3
            awn.cairo_rounded_rect(cr, line_width, line_width,
                                   self.allocation.width - line_width * 2,
                                   self.allocation.height - line_width * 2, 10,
                                   awn.ROUND_ALL)
            cr.set_source_rgba(0.2, 0.2, 0.2, 0.5)
            cr.fill_preserve()
            cr.set_operator(cairo.OPERATOR_SOURCE)
            cr.set_source_rgba(0.8, 0.8, 0.8, 0.75)
            cr.set_line_width(line_width)
            cr.stroke()

        del cr

        # propagate expose
        child = self.get_child()
        if child is not None:
            self.propagate_expose(child, event)
        return True
    def expose_event_cb(self, widget, event=None):
        context = widget.window.cairo_create()
        context.translate(25, 10)
        context.set_operator(cairo.OPERATOR_CLEAR)
        context.paint()
        context.set_operator(cairo.OPERATOR_OVER)
        context.set_source_rgba(0, 0, 0, 0.85)
        cairo_rounded_rect(context, 0, 0, self.width, self.height + 12, 4,
                           ROUND_ALL)
        context.fill()
        context.set_line_width(1)
        context.set_source_rgba(0, 0, 0, 0.55)
        cairo_rounded_rect(context, 0, 0, self.width, self.height + 12, 4,
                           ROUND_ALL)
        context.stroke()

        if not hasattr(self, 'iface_list_btn'):
            self.iface_list_btn = gtk.Button(_('Interfaces'))
            self.iface_list_btn.connect('button_press_event',
                                        self.change_dialog, 'list')
            self.parent.put(self.iface_list_btn, 20, self.height - 25)

        if not hasattr(self, 'change_unit_btn'):
            self.change_unit_btn = gtk.Button(_('Change Unit'))
            self.change_unit_btn.connect('clicked',
                                         self.__parent.call_change_unit)
            self.parent.put(self.change_unit_btn, 180, self.height - 25)

        if not hasattr(self, 'iface_options_btn'):
            self.iface_options_btn = gtk.Button(_('Options/Info'))
            self.iface_options_btn.connect('button_press_event',
                                           self.change_dialog, 'options')
            self.parent.put(self.iface_options_btn, self.width - 98,
                            self.height - 25)

        if not hasattr(self, 'initted'):
            self.iface_list_btn.show()
            self.change_unit_btn.show()
            self.iface_options_btn.show()
            self.initted = True

        return True
    def expose_event_cb(self, widget, event=None):
        context = widget.window.cairo_create()
        context.translate(25, 10)
        context.set_operator(cairo.OPERATOR_CLEAR)
        context.paint()
        context.set_operator(cairo.OPERATOR_OVER)
        context.set_source_rgba(0, 0, 0, 0.85)
        cairo_rounded_rect(context, 0, 0, self.width, self.height + 12, 4, ROUND_ALL)
        context.fill()
        context.set_line_width(1)
        context.set_source_rgba(0, 0, 0, 0.55)
        cairo_rounded_rect(context, 0, 0, self.width, self.height + 12, 4, ROUND_ALL)
        context.stroke()

        if not hasattr(self, "iface_list_btn"):
            self.iface_list_btn = gtk.Button(_("Interfaces"))
            self.iface_list_btn.connect("button_press_event", self.change_dialog, "list")
            self.parent.put(self.iface_list_btn, 20, self.height - 25)

        if not hasattr(self, "change_unit_btn"):
            self.change_unit_btn = gtk.Button(_("Change Unit"))
            self.change_unit_btn.connect("clicked", self.__parent.call_change_unit)
            self.parent.put(self.change_unit_btn, 180, self.height - 25)

        if not hasattr(self, "iface_options_btn"):
            self.iface_options_btn = gtk.Button(_("Options/Info"))
            self.iface_options_btn.connect("button_press_event", self.change_dialog, "options")
            self.parent.put(self.iface_options_btn, self.width - 98, self.height - 25)

        if not hasattr(self, "initted"):
            self.iface_list_btn.show()
            self.change_unit_btn.show()
            self.iface_options_btn.show()
            self.initted = True

        return True
    def draw_graph(self):
        if not self.window:
            return True
        self.set_size_request(int(self.width), int(self.height))
        context = self.window.cairo_create()
        context.translate(self.translated_x, self.translated_y)
        context.set_operator(cairo.OPERATOR_CLEAR)
        context.paint()
        context.set_operator(cairo.OPERATOR_OVER)
        iface = self.interface
        context.set_source_rgba(0, 0, 0, 0.85)
        if self.show_text:
            context.rectangle(0, 0, self.width, self.height + 20)
            context.fill()
        else:
            cairo_rounded_rect(context, -1, -1, self.width + 2, self.height + 2, 4, ROUND_ALL)
            context.fill()
        if self.show_text and not self.interface == self.__parent.iface:
            self.interface = self.__parent.iface
        if self.interface in self.__parent.netstats.ifaces:
            if self.show_text:
                graph_source = "dialog"
                line_width = 3
                icon_size = 0
                pixbuf = None
                if self.__parent.applet.settings["dialog_traffic_scale"]:
                    traffic_scale = int(self.__parent.applet.settings["dialog_traffic_scale"] * 8)
                else:
                    traffic_scale = 90
                if self.__parent.applet.settings["dialog_signal_scale"]:
                    signal_scale = int(self.__parent.applet.settings["dialog_signal_scale"] * 8)
                else:
                    signal_scale = 90
                self.interface = self.__parent.iface
                """ if wireless, draw it """
                if iface in self.__parent.netstats.ifaces:
                    if "signal" in self.__parent.netstats.ifaces[iface]:
                        signal = abs(int(self.__parent.netstats.ifaces[iface]["signal"]["strength"])) * 80 / 100
                        quality = int(self.__parent.netstats.ifaces[iface]["signal"]["quality"])
                        noise = int(self.__parent.netstats.ifaces[iface]["signal"]["noise"])
                        icon_size = 24
                        if quality == 0 and (noise == -256 or noise == 0):
                            icon_name = "wireless-disconnected.png"
                        elif signal <= 40:
                            icon_name = "wireless-full.png"
                        elif signal <= 60:
                            icon_name = "wireless-high.png"
                        elif signal <= 90:
                            icon_name = "wireless-medium.png"
                        else:
                            icon_name = "wireless-low.png"
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, icon_name), icon_size, icon_size
                        )
                        signal = self.__parent.netstats.ifaces[iface]["signal"]
                        ssid = None
                        self.__parent.draw_wireless(
                            context, self.width, self.height, self.interface, scale=signal_scale, graph_source="dialog"
                        )
                        if self.network_manager:
                            nm_device = self.network_manager.get_device_by_name(iface)
                            nm_device_status = self.network_manager.get_device_status(nm_device)
                            if nm_device_status in [7, 8]:
                                ssid = self.network_manager.get_current_ssid(nm_device)
                                context.set_source_rgba(1, 1, 1)
                                context.set_font_size(18)
                                context.set_line_width(3)
                                context.move_to(6, 45)
                                context.set_source_rgba(0, 0, 0)
                                # Translators: do not translate, just add spacing before colon,
                                # if your locale requires it
                                context.text_path("%s %s" % (_("SSID:"), ssid))
                                context.stroke()
                                context.set_source_rgba(1, 1, 1)
                                context.move_to(6, 45)
                                context.show_text("%s %s" % (_("SSID:"), ssid))
                                context.fill()
                    if (
                        not "signal" in self.__parent.netstats.ifaces[iface]
                        and not self.__parent.netstats.ifaces[iface]["status"] == "V"
                        and not gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]["status"]
                    ):
                        icon_size = 24
                        icon_name = "ethernet.png"
                        try:
                            if os.access("/sys/class/net/%s/device/device/address" % iface, os.R_OK):
                                hw_addr = open("/sys/class/net/%s/device/address" % iface, "r").read().strip()
                                """ most likely a bluetooth connection, check with NM """
                                if self.network_manager:
                                    nm_device = self.network_manager.get_device_by_name(hw_addr)
                                    nm_device_type = self.network_manager.get_device_type(nm_device)
                                    if nm_device_type == 5:
                                        """ bluetooth """
                                        icon_name = "bluetooth.png"
                                        bt_endpoint = self.network_manager.get_bluetooth_endpoint_name(nm_device)
                                        context.set_source_rgba(1, 1, 1)
                                        context.set_font_size(18)
                                        context.set_line_width(3)
                                        context.move_to(6, 45)
                                        context.set_source_rgba(0, 0, 0)
                                        context.text_path(bt_endpoint)
                                        context.stroke()
                                        context.set_source_rgba(1, 1, 1)
                                        context.move_to(6, 45)
                                        context.show_text(bt_endpoint)
                                        context.fill()
                        except:
                            pass
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, icon_name), icon_size, icon_size
                        )
                    if (
                        not self.__parent.netstats.ifaces[iface]["status"] == "V"
                        and gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]["status"]
                    ):
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, "loopback.png"), icon_size, icon_size
                        )
                    if iface == _("Multi Interface"):
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, "multi.png"), icon_size, icon_size + 5
                        )
                    if iface == _("Sum Interface"):
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, "sum.png"), icon_size, icon_size
                        )
                    if "tun" in iface or "tap" in iface:
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, "tun-tap.png"), icon_size, icon_size
                        )
                    if pixbuf:
                        context.set_source_pixbuf(pixbuf, 4, 0)
                        context.paint()
                context.set_source_rgba(0.0, 1.0, 0.0, 1.0)
                context.set_line_width(0.2)
                """ draw horizontal lines on the meter """
                i = 50
                while i < self.height + 50:
                    context.move_to(0, i)
                    context.line_to(self.width, i)
                    i += 20
                context.stroke()
                context.set_source_rgba(1, 1, 1)
                context.select_font_face("Helvetica", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
                context.set_font_size(24.0)
                context.set_line_width(3)
                context.move_to(8 + icon_size, 20)
                context.set_source_rgba(0, 0, 0)
                context.text_path(_(self.__parent.iface))
                context.stroke()
                context.set_source_rgba(1, 1, 1)
                context.move_to(8 + icon_size, 20)
                context.show_text(_(self.__parent.iface))
                context.set_font_size(14.0)
                # Translators: do not translate, just add spacing before colon,
                # if your locale requires it
                tx_label = "%s %s" % (
                    _("TX:"),
                    self.__parent.readable_speed_ps(
                        self.__parent.netstats.ifaces[self.interface]["tx_bytes"], self.__parent.unit
                    ),
                )
                # Translators: do not translate, just add spacing before colon,
                # if your locale requires it
                rx_label = "%s %s" % (
                    _("RX:"),
                    self.__parent.readable_speed_ps(
                        self.__parent.netstats.ifaces[self.interface]["rx_bytes"], self.__parent.unit
                    ),
                )
                context.move_to(self.width - 100, 15)
                context.set_source_rgba(0, 0, 0)
                context.text_path(tx_label)
                context.stroke()
                context.move_to(self.width - 100, 15)
                context.set_source_rgba(1, 1, 1)
                context.show_text(tx_label)
                context.fill()
                context.move_to(self.width - 100, 30)
                context.set_source_rgba(0, 0, 0)
                context.text_path(rx_label)
                context.stroke()
                context.move_to(self.width - 100, 30)
                context.set_source_rgba(1, 1, 1)
                context.show_text(rx_label)
                context.fill()
            else:
                graph_source = "applet"
                line_width = 2
                context.set_line_width(line_width)
                x, y = 0, 0
                h = self.height
                cairo_rounded_rect(context, 1, 1, self.width - 2, self.height - 2, 4, ROUND_ALL)
                pat = cairo.LinearGradient(0, self.height / 2 + 15, 0, 0)
                if (
                    self.__parent.netstats.ifaces[iface]["status"] == "V"
                    or gtop.NETLOAD_IF_FLAGS_RUNNING & self.__parent.netstats.ifaces[iface]["status"]
                ):
                    c1, c2, c3 = 0, 0, 0
                    c4, c5, c6 = 0, 1, 0
                else:
                    c1, c2, c3 = 0, 0, 0
                    c4, c5, c6 = 1, 0, 0

                pat.add_color_stop_rgba(0.1, c1, c2, c3, 0.85)
                pat.add_color_stop_rgba(1.0, c4, c5, c6, 0.85)
                count = 1

                context.set_source(pat)
                context.fill()

                pixbuf = None
                icon_size = 24 if self.highlight else 16
                if "Multi" in iface:
                    icon_size = 28 if self.highlight else 20
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, "multi.png"), icon_size, icon_size
                    )
                if "Sum" in iface:
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, "sum.png"), icon_size, icon_size
                    )
                if (
                    not self.__parent.netstats.ifaces[iface]["status"] == "V"
                    and gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]["status"]
                ):
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, "loopback.png"), icon_size, icon_size
                    )
                if "signal" in self.__parent.netstats.ifaces[iface]:
                    signal = abs(int(self.__parent.netstats.ifaces[iface]["signal"]["strength"])) * 80 / 100
                    quality = int(self.__parent.netstats.ifaces[iface]["signal"]["quality"])
                    noise = int(self.__parent.netstats.ifaces[iface]["signal"]["noise"])
                    if quality == 0 and (noise == -256 or noise == 0):
                        icon_name = "wireless-disconnected.png"
                    elif signal <= 40:
                        icon_name = "wireless-full.png"
                    elif signal <= 60:
                        icon_name = "wireless-high.png"
                    elif signal <= 90:
                        icon_name = "wireless-medium.png"
                    else:
                        icon_name = "wireless-low.png"
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, icon_name), icon_size, icon_size
                    )
                if (
                    not "signal" in self.__parent.netstats.ifaces[iface]
                    and not self.__parent.netstats.ifaces[iface]["status"] == "V"
                    and not gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]["status"]
                ):
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, "ethernet.png"), icon_size, icon_size
                    )
                    if self.network_manager:
                        try:
                            if os.access("/sys/class/net/%s/device/device/address" % iface, os.R_OK):
                                hw_addr = open("/sys/class/net/%s/device/address" % iface, "r").read().strip()
                                """ most likely a bluetooth connection, check with NM """
                                nm_device = self.network_manager.get_device_by_name(hw_addr)
                                nm_device_type = self.network_manager.get_device_type(nm_device)
                                if nm_device_type == 5:
                                    """ bluetooth """
                                    icon_size = 32 if self.highlight else 20
                                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                                        os.path.join(ICON_DIR, "bluetooth.png"), icon_size, icon_size
                                    )
                        except:
                            pass
                if "tun" in iface or "tap" in iface:
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, "tun-tap.png"), icon_size, icon_size
                    )
                if pixbuf:
                    context.set_source_pixbuf(pixbuf, self.width - pixbuf.get_width() - 4, 4)
                    context.paint()
                context.select_font_face("Helvetica", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
                if not self.highlight:
                    context.set_font_size(12.0)
                    text_xpos = 0
                else:
                    context.set_font_size(14.0)
                    text_xpos = -4
                context.set_source_rgba(1, 1, 1)

                iface_name = self.interface
                if iface_name == _("Sum Interface"):
                    # Translators: short for "Sum Interface"
                    iface_name = _("Sum")
                if iface_name == _("Multi Interface"):
                    # Translators: short for "Multi Interface"
                    iface_name = _("Multi")
                text_xpos = self.width / 3 - 20
                context.move_to(text_xpos, self.height - self.height / 2)
                context.show_text(iface_name)
                context.fill()

                def click_event(widget, event):
                    if abs(event.time - self.button_click_time) > 500:
                        self.button_click_time = event.time
                        self.__parent.change_iface(widget, self.interface)
                        self.__parent.generate_iface_submenu()
                        self.__parent.interface_dialog.buttonArea.change_dialog(widget, event, "graph")

                self.connect("button_release_event", click_event)
                traffic_scale = 24
                signal_scale = 24
            context.set_font_size(12.0)
            multi = True if self.interface == _("Multi Interface") else False
            if multi:
                tmp_history = [1]
                for iface in self.__parent.netstats.ifaces:
                    if self.__parent.netstats.ifaces[iface]["multi_include"]:
                        tmp_history.extend(self.__parent.netstats.ifaces[iface]["rx_history"])
                        tmp_history.extend(self.__parent.netstats.ifaces[iface]["tx_history"])
                tmp_history.sort()
                max_val = tmp_history[-1]
                ratio = max_val / 28 if max_val > self.__parent.ratio else 1
                for iface in self.__parent.netstats.ifaces:
                    if self.__parent.netstats.ifaces[iface]["multi_include"]:
                        self.__parent.draw_meter(
                            context,
                            self.width,
                            self.height,
                            iface,
                            multi=multi,
                            line_width=line_width,
                            ratio=ratio,
                            scale=traffic_scale,
                            border=True,
                            graph_source=graph_source,
                        )
            else:
                self.__parent.draw_meter(
                    context,
                    self.width,
                    self.height,
                    self.interface,
                    multi=multi,
                    line_width=line_width,
                    ratio=1,
                    scale=traffic_scale,
                    border=True,
                    graph_source=graph_source,
                )
            if not self.show_text:
                if self.highlight:
                    context.set_source_rgba(1, 1, 1, 1)
                    context.set_line_width(3)
                    cairo_rounded_rect(context, 1, 1, self.width - 2, self.height - 2, 6, ROUND_ALL)
                    context.stroke()
                else:
                    context.set_source_rgba(1, 1, 1, 1)
                    cairo_rounded_rect(context, 0, 0, self.width, self.height, 4, ROUND_ALL)
                    context.stroke()
        else:
            context.set_source_rgba(1, 1, 1)
            context.select_font_face("Helvetica", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
            context.set_font_size(18.0)
            device_error = _("No Device")
            device_error_message = _("Please select a valid device")
            context.move_to(self.width / 3.0, self.height / 2 - 7)
            context.show_text(device_error)
            context.move_to(self.width / 3.0, self.height / 2 + 10)
            context.show_text(device_error_message)
            context.fill()
        return True
Beispiel #6
0
    def repaint(self):
        orientation = self.applet.get_pos_type()
        applet_size = self.applet.get_size()
        width = applet_size * self.applet.settings['applet_width']
        if self.size_override:
            self.applet.props.size = self.applet.props.size + self.size_override
            self.size_override = None
        if orientation in (gtk.POS_LEFT, gtk.POS_RIGHT):
            self.applet.get_effects().set_property('reflection_visible', False)
            cs = cairo.ImageSurface(cairo.FORMAT_ARGB32, applet_size + 2,
                                    int(width + 1))
        else:
            cs = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                    int(width) + 1, applet_size + 1)

        if self.applet.settings['applet_font_size']:
            self.default_font_size = self.applet.settings['applet_font_size']
        else:
            self.default_font_size = self.sum_ot.props.font_sizing
            self.sum_ot.props.font_sizing = self.default_font_size
        self.sum_ot.props.font_sizing = self.default_font_size
        ct = cairo.Context(cs)
        if orientation in (gtk.POS_LEFT, gtk.POS_RIGHT):
            if orientation == gtk.POS_RIGHT:
                rotate_matrix = cairo.Matrix(1, 0, 0, 1, 1, width + 1.5)
                cairo.Matrix.rotate(rotate_matrix, 4.71)
            else:
                rotate_matrix = cairo.Matrix(1, 0, 0, 1, applet_size + 1.5, 0)
                cairo.Matrix.rotate(rotate_matrix, -4.71)
            ct.transform(rotate_matrix)
        if self.applet.settings['applet_traffic_scale']:
            scale = int(self.applet.settings['applet_traffic_scale'] \
              * self.applet.settings['applet_width'])
        else:
            scale = int(12 * self.applet.settings['applet_width'])
        inverse_scale = scale * -1
        ct.set_source_surface(cs)
        ct.set_line_width(2)
        if self.background and self.display_graph:
            bgColor, alpha = \
                self.applet.settings['background_color'].split('|')
            bgColor = gtk.gdk.color_parse(bgColor)
            ct.set_source_rgba(bgColor.red / 65535.0, bgColor.green / 65535.0,
                               bgColor.blue / 65535.0, float(alpha))
            awn.cairo_rounded_rect(ct, 0, 0, width + 1, applet_size + 1, 4,
                                   awn.ROUND_ALL)
            ct.fill()
        if self.iface == _('Multi Interface') and self.display_graph:
            tmp_history = [1]
            for iface in self.netstats.ifaces:
                if self.netstats.ifaces[iface]['multi_include']:
                    tmp_history.extend(self.netstats.ifaces[iface]
                                       ['rx_history'][inverse_scale:])
                    tmp_history.extend(self.netstats.ifaces[iface]
                                       ['tx_history'][inverse_scale:])
            tmp_history.sort()
            max_val = tmp_history[-1]
            self.ratio = max_val / 28 if max_val > self.ratio else 1
            for iface in self.netstats.ifaces:
                if self.netstats.ifaces[iface]['multi_include']:
                    self.draw_meter(ct,
                                    width,
                                    applet_size,
                                    iface,
                                    True,
                                    scale=scale)
        else:
            if self.iface and self.iface in self.netstats.ifaces and self.display_graph:
                if 'signal' in self.netstats.ifaces[self.iface]:
                    if self.applet.settings['applet_signal_scale']:
                        wscale = int(
                            self.applet.settings['applet_signal_scale'] *
                            self.applet.settings['applet_width'])
                    else:
                        wscale = int(5 * self.applet.settings['applet_width'])
                    self.draw_wireless(ct,
                                       width,
                                       applet_size,
                                       self.iface,
                                       scale=wscale,
                                       graph_source='applet')
                self.draw_meter(ct,
                                width,
                                applet_size,
                                self.iface,
                                scale=scale,
                                graph_source='applet')
        if self.iface in self.netstats.ifaces:
            if self.label_control:
                if self.label_control == 2:
                    self.sum_ot.props.text = \
                        self.readable_speed_ps(
                            self.netstats.ifaces[self.iface]['tx_bytes'],
                            self.unit) + '\n' + \
                        self.readable_speed_ps(
                            self.netstats.ifaces[self.iface]['rx_bytes'],
                            self.unit)
                else:
                    self.sum_ot.props.text = \
                        self.readable_speed_ps(
                            self.netstats.ifaces[self.iface]['rx_bytes'] \
                            + self.netstats.ifaces[self.iface]['tx_bytes'],
                            self.unit)
            else:
                self.sum_ot.props.text = ''
            self.title_text = self.readable_speed_ps(
                self.netstats.ifaces[self.iface]['tx_bytes'], self.unit)
        else:
            self.sum_ot.props.text = _('No Device')
            self.title_text = _('Please select a valid device')
        if self.border and self.display_graph:
            line_width = 2
            ct.set_line_width(line_width)
            borderColor, alpha = \
                self.applet.settings['border_color'].split('|')
            borderColor = gtk.gdk.color_parse(borderColor)
            ct.set_source_rgba(borderColor.red / 65535.0,
                               borderColor.green / 65535.0,
                               borderColor.blue / 65535.0, float(alpha))
            awn.cairo_rounded_rect(ct, line_width / 2, line_width / 2,
                                   width - (line_width / 2),
                                   applet_size - (line_width / 2) + 0.5, 4,
                                   awn.ROUND_ALL)
            ct.stroke()
        self.applet.set_icon_context(ct)
        if self.applet.dialog.is_visible('main'):
            self.interface_dialog.do_current()
        if self.applet.dialog.is_visible('main') \
          or hasattr(self.applet.dialog.menu.window, 'is_visible') \
          and self.applet.dialog.menu.window.is_visible():
            for iface in self.netstats.ifaces:
                if not 'in_list' in self.netstats.ifaces[iface] \
                  or self.netstats.regenerate == True:
                    self.netstats.regenerate = False
                    if hasattr(self.applet.dialog.menu.window, 'is_visible') \
                      and self.applet.dialog.menu.window.is_visible():
                        self.generate_iface_submenu()
                    self.interface_dialog.interfaceListArea.rebuild()
                    self.interface_dialog.interfaceListArea.refresh()
                    self.interface_dialog.interfaceOptionsArea.refresh()
                    return True
        return True
Beispiel #7
0
 def draw_rounded_rect(self, ct, x, y, w, h):
     cairo_rounded_rect(ct, x, y, w, h, 4, ROUND_ALL)
    def draw_graph(self):
        if not self.window:
            return True
        self.set_size_request(int(self.width), int(self.height))
        context = self.window.cairo_create()
        context.translate(self.translated_x, self.translated_y)
        context.set_operator(cairo.OPERATOR_CLEAR)
        context.paint()
        context.set_operator(cairo.OPERATOR_OVER)
        iface = self.interface
        context.set_source_rgba(0, 0, 0, 0.85)
        if self.show_text:
            context.rectangle(0, 0, self.width, self.height + 20)
            context.fill()
        else:
            cairo_rounded_rect(context, -1, -1, self.width + 2,
                               self.height + 2, 4, ROUND_ALL)
            context.fill()
        if self.show_text and not self.interface == self.__parent.iface:
            self.interface = self.__parent.iface
        if self.interface in self.__parent.netstats.ifaces:
            if self.show_text:
                graph_source = 'dialog'
                line_width = 3
                icon_size = 0
                pixbuf = None
                if self.__parent.applet.settings['dialog_traffic_scale']:
                    traffic_scale = int(self.__parent.applet.settings['dialog_traffic_scale'] \
                      * 8)
                else:
                    traffic_scale = 90
                if self.__parent.applet.settings['dialog_signal_scale']:
                    signal_scale = int(self.__parent.applet.settings['dialog_signal_scale'] \
                      * 8)
                else:
                    signal_scale = 90
                self.interface = self.__parent.iface
                ''' if wireless, draw it '''
                if iface in self.__parent.netstats.ifaces:
                    if 'signal' in self.__parent.netstats.ifaces[iface]:
                        signal = abs(
                            int(self.__parent.netstats.ifaces[iface]['signal']
                                ['strength'])) * 80 / 100
                        quality = int(self.__parent.netstats.ifaces[iface]
                                      ['signal']['quality'])
                        noise = int(self.__parent.netstats.ifaces[iface]
                                    ['signal']['noise'])
                        icon_size = 24
                        if quality == 0 and (noise == -256 or noise == 0):
                            icon_name = 'wireless-disconnected.png'
                        elif signal <= 40:
                            icon_name = 'wireless-full.png'
                        elif signal <= 60:
                            icon_name = 'wireless-high.png'
                        elif signal <= 90:
                            icon_name = 'wireless-medium.png'
                        else:
                            icon_name = 'wireless-low.png'
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, icon_name), icon_size,
                            icon_size)
                        signal = self.__parent.netstats.ifaces[iface]['signal']
                        ssid = None
                        self.__parent.draw_wireless(context,
                                                    self.width,
                                                    self.height,
                                                    self.interface,
                                                    scale=signal_scale,
                                                    graph_source='dialog')
                        if self.network_manager:
                            nm_device = self.network_manager.get_device_by_name(
                                iface)
                            nm_device_status = self.network_manager.get_device_status(
                                nm_device)
                            if nm_device_status in [7, 8]:
                                ssid = self.network_manager.get_current_ssid(
                                    nm_device)
                                context.set_source_rgba(1, 1, 1)
                                context.set_font_size(18)
                                context.set_line_width(3)
                                context.move_to(6, 45)
                                context.set_source_rgba(0, 0, 0)
                                # Translators: do not translate, just add spacing before colon,
                                # if your locale requires it
                                context.text_path('%s %s' % (_('SSID:'), ssid))
                                context.stroke()
                                context.set_source_rgba(1, 1, 1)
                                context.move_to(6, 45)
                                context.show_text('%s %s' % (_('SSID:'), ssid))
                                context.fill()
                    if not 'signal' in self.__parent.netstats.ifaces[iface] and \
                        not self.__parent.netstats.ifaces[iface]['status'] == 'V' and \
                        not gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]['status']:
                        icon_size = 24
                        icon_name = 'ethernet.png'
                        try:
                            if os.access(
                                    '/sys/class/net/%s/device/device/address' %
                                    iface, os.R_OK):
                                hw_addr = open(
                                    '/sys/class/net/%s/device/address' % iface,
                                    'r').read().strip()
                                ''' most likely a bluetooth connection, check with NM '''
                                if self.network_manager:
                                    nm_device = self.network_manager.get_device_by_name(
                                        hw_addr)
                                    nm_device_type = self.network_manager.get_device_type(
                                        nm_device)
                                    if nm_device_type == 5:
                                        ''' bluetooth '''
                                        icon_name = 'bluetooth.png'
                                        bt_endpoint = self.network_manager.get_bluetooth_endpoint_name(
                                            nm_device)
                                        context.set_source_rgba(1, 1, 1)
                                        context.set_font_size(18)
                                        context.set_line_width(3)
                                        context.move_to(6, 45)
                                        context.set_source_rgba(0, 0, 0)
                                        context.text_path(bt_endpoint)
                                        context.stroke()
                                        context.set_source_rgba(1, 1, 1)
                                        context.move_to(6, 45)
                                        context.show_text(bt_endpoint)
                                        context.fill()
                        except:
                            pass
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, icon_name), icon_size,
                            icon_size)
                    if not self.__parent.netstats.ifaces[iface]['status'] == 'V' and \
                        gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]['status']:
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, 'loopback.png'), icon_size,
                            icon_size)
                    if iface == _('Multi Interface'):
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, 'multi.png'), icon_size,
                            icon_size + 5)
                    if iface == _('Sum Interface'):
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, 'sum.png'), icon_size,
                            icon_size)
                    if 'tun' in iface or 'tap' in iface:
                        icon_size = 24
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                            os.path.join(ICON_DIR, 'tun-tap.png'), icon_size,
                            icon_size)
                    if pixbuf:
                        context.set_source_pixbuf(pixbuf, 4, 0)
                        context.paint()
                context.set_source_rgba(0.0, 1.0, 0.0, 1.0)
                context.set_line_width(0.2)
                ''' draw horizontal lines on the meter '''
                i = 50
                while i < self.height + 50:
                    context.move_to(0, i)
                    context.line_to(self.width, i)
                    i += 20
                context.stroke()
                context.set_source_rgba(1, 1, 1)
                context.select_font_face('Helvetica', cairo.FONT_SLANT_NORMAL,
                                         cairo.FONT_WEIGHT_BOLD)
                context.set_font_size(24.0)
                context.set_line_width(3)
                context.move_to(8 + icon_size, 20)
                context.set_source_rgba(0, 0, 0)
                context.text_path(_(self.__parent.iface))
                context.stroke()
                context.set_source_rgba(1, 1, 1)
                context.move_to(8 + icon_size, 20)
                context.show_text(_(self.__parent.iface))
                context.set_font_size(14.0)
                # Translators: do not translate, just add spacing before colon,
                # if your locale requires it
                tx_label = '%s %s' % (_('TX:'),
                                      self.__parent.readable_speed_ps(
                                          self.__parent.netstats.ifaces[
                                              self.interface]['tx_bytes'],
                                          self.__parent.unit))
                # Translators: do not translate, just add spacing before colon,
                # if your locale requires it
                rx_label = '%s %s' % (_('RX:'),
                                      self.__parent.readable_speed_ps(
                                          self.__parent.netstats.ifaces[
                                              self.interface]['rx_bytes'],
                                          self.__parent.unit))
                context.move_to(self.width - 100, 15)
                context.set_source_rgba(0, 0, 0)
                context.text_path(tx_label)
                context.stroke()
                context.move_to(self.width - 100, 15)
                context.set_source_rgba(1, 1, 1)
                context.show_text(tx_label)
                context.fill()
                context.move_to(self.width - 100, 30)
                context.set_source_rgba(0, 0, 0)
                context.text_path(rx_label)
                context.stroke()
                context.move_to(self.width - 100, 30)
                context.set_source_rgba(1, 1, 1)
                context.show_text(rx_label)
                context.fill()
            else:
                graph_source = 'applet'
                line_width = 2
                context.set_line_width(line_width)
                x, y = 0, 0
                h = self.height
                cairo_rounded_rect(context, 1, 1, self.width - 2,
                                   self.height - 2, 4, ROUND_ALL)
                pat = cairo.LinearGradient(0, self.height / 2 + 15, 0, 0)
                if self.__parent.netstats.ifaces[iface]['status'] == 'V' or \
                    gtop.NETLOAD_IF_FLAGS_RUNNING & \
                    self.__parent.netstats.ifaces[iface]['status']:
                    c1, c2, c3 = 0, 0, 0
                    c4, c5, c6 = 0, 1, 0
                else:
                    c1, c2, c3 = 0, 0, 0
                    c4, c5, c6 = 1, 0, 0

                pat.add_color_stop_rgba(0.1, c1, c2, c3, 0.85)
                pat.add_color_stop_rgba(1.0, c4, c5, c6, 0.85)
                count = 1

                context.set_source(pat)
                context.fill()

                pixbuf = None
                icon_size = 24 if self.highlight else 16
                if 'Multi' in iface:
                    icon_size = 28 if self.highlight else 20
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, 'multi.png'), icon_size,
                        icon_size)
                if 'Sum' in iface:
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, 'sum.png'), icon_size,
                        icon_size)
                if not self.__parent.netstats.ifaces[iface]['status'] == 'V' and \
                        gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]['status']:
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, 'loopback.png'), icon_size,
                        icon_size)
                if 'signal' in self.__parent.netstats.ifaces[iface]:
                    signal = abs(
                        int(self.__parent.netstats.ifaces[iface]['signal']
                            ['strength'])) * 80 / 100
                    quality = int(self.__parent.netstats.ifaces[iface]
                                  ['signal']['quality'])
                    noise = int(self.__parent.netstats.ifaces[iface]['signal']
                                ['noise'])
                    if quality == 0 and (noise == -256 or noise == 0):
                        icon_name = 'wireless-disconnected.png'
                    elif signal <= 40:
                        icon_name = 'wireless-full.png'
                    elif signal <= 60:
                        icon_name = 'wireless-high.png'
                    elif signal <= 90:
                        icon_name = 'wireless-medium.png'
                    else:
                        icon_name = 'wireless-low.png'
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, icon_name), icon_size,
                        icon_size)
                if not 'signal' in self.__parent.netstats.ifaces[iface] and \
                    not self.__parent.netstats.ifaces[iface]['status'] == 'V' and \
                    not gtop.NETLOAD_IF_FLAGS_LOOPBACK & self.__parent.netstats.ifaces[iface]['status']:
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, 'ethernet.png'), icon_size,
                        icon_size)
                    if self.network_manager:
                        try:
                            if os.access(
                                    '/sys/class/net/%s/device/device/address' %
                                    iface, os.R_OK):
                                hw_addr = open(
                                    '/sys/class/net/%s/device/address' % iface,
                                    'r').read().strip()
                                ''' most likely a bluetooth connection, check with NM '''
                                nm_device = self.network_manager.get_device_by_name(
                                    hw_addr)
                                nm_device_type = self.network_manager.get_device_type(
                                    nm_device)
                                if nm_device_type == 5:
                                    ''' bluetooth '''
                                    icon_size = 32 if self.highlight else 20
                                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                                        os.path.join(ICON_DIR,
                                                     'bluetooth.png'),
                                        icon_size, icon_size)
                        except:
                            pass
                if 'tun' in iface or 'tap' in iface:
                    pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                        os.path.join(ICON_DIR, 'tun-tap.png'), icon_size,
                        icon_size)
                if pixbuf:
                    context.set_source_pixbuf(
                        pixbuf, self.width - pixbuf.get_width() - 4, 4)
                    context.paint()
                context.select_font_face('Helvetica', cairo.FONT_SLANT_NORMAL,
                                         cairo.FONT_WEIGHT_BOLD)
                if not self.highlight:
                    context.set_font_size(12.0)
                    text_xpos = 0
                else:
                    context.set_font_size(14.0)
                    text_xpos = -4
                context.set_source_rgba(1, 1, 1)

                iface_name = self.interface
                if iface_name == _('Sum Interface'):
                    # Translators: short for "Sum Interface"
                    iface_name = _('Sum')
                if iface_name == _('Multi Interface'):
                    # Translators: short for "Multi Interface"
                    iface_name = _('Multi')
                text_xpos = self.width / 3 - 20
                context.move_to(text_xpos, self.height - self.height / 2)
                context.show_text(iface_name)
                context.fill()

                def click_event(widget, event):
                    if abs(event.time - self.button_click_time) > 500:
                        self.button_click_time = event.time
                        self.__parent.change_iface(widget, self.interface)
                        self.__parent.generate_iface_submenu()
                        self.__parent.interface_dialog.buttonArea.change_dialog(
                            widget, event, 'graph')

                self.connect('button_release_event', click_event)
                traffic_scale = 24
                signal_scale = 24
            context.set_font_size(12.0)
            multi = True if self.interface == _('Multi Interface') else False
            if multi:
                tmp_history = [1]
                for iface in self.__parent.netstats.ifaces:
                    if self.__parent.netstats.ifaces[iface]['multi_include']:
                        tmp_history.extend(
                            self.__parent.netstats.ifaces[iface]['rx_history'])
                        tmp_history.extend(
                            self.__parent.netstats.ifaces[iface]['tx_history'])
                tmp_history.sort()
                max_val = tmp_history[-1]
                ratio = max_val / 28 if max_val > self.__parent.ratio else 1
                for iface in self.__parent.netstats.ifaces:
                    if self.__parent.netstats.ifaces[iface]['multi_include']:
                        self.__parent.draw_meter(context,
                                                 self.width,
                                                 self.height,
                                                 iface,
                                                 multi=multi,
                                                 line_width=line_width,
                                                 ratio=ratio,
                                                 scale=traffic_scale,
                                                 border=True,
                                                 graph_source=graph_source)
            else:
                self.__parent.draw_meter(context,
                                         self.width,
                                         self.height,
                                         self.interface,
                                         multi=multi,
                                         line_width=line_width,
                                         ratio=1,
                                         scale=traffic_scale,
                                         border=True,
                                         graph_source=graph_source)
            if not self.show_text:
                if self.highlight:
                    context.set_source_rgba(1, 1, 1, 1)
                    context.set_line_width(3)
                    cairo_rounded_rect(context, 1, 1, self.width - 2,
                                       self.height - 2, 6, ROUND_ALL)
                    context.stroke()
                else:
                    context.set_source_rgba(1, 1, 1, 1)
                    cairo_rounded_rect(context, 0, 0, self.width, self.height,
                                       4, ROUND_ALL)
                    context.stroke()
        else:
            context.set_source_rgba(1, 1, 1)
            context.select_font_face('Helvetica', cairo.FONT_SLANT_NORMAL,
                                     cairo.FONT_WEIGHT_BOLD)
            context.set_font_size(18.0)
            device_error = _('No Device')
            device_error_message = _('Please select a valid device')
            context.move_to(self.width / 3.0, self.height / 2 - 7)
            context.show_text(device_error)
            context.move_to(self.width / 3.0, self.height / 2 + 10)
            context.show_text(device_error_message)
            context.fill()
        return True
Beispiel #9
0
    def repaint(self):
        orientation = self.applet.get_pos_type()
        applet_size = self.applet.get_size()
        width = applet_size * self.applet.settings['applet_width']
        if self.size_override:
            self.applet.props.size = self.applet.props.size + self.size_override
            self.size_override = None
        if orientation in (gtk.POS_LEFT, gtk.POS_RIGHT):
            self.applet.get_effects().set_property('reflection_visible', False)
            cs = cairo.ImageSurface(cairo.FORMAT_ARGB32, applet_size + 2,
                int(width + 1))
        else:
            cs = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(width) + 1,
                applet_size + 1)

        if self.applet.settings['applet_font_size']:
            self.default_font_size = self.applet.settings['applet_font_size']
        else:
            self.default_font_size = self.sum_ot.props.font_sizing
            self.sum_ot.props.font_sizing = self.default_font_size
        self.sum_ot.props.font_sizing = self.default_font_size
        ct = cairo.Context(cs)
        if orientation in (gtk.POS_LEFT, gtk.POS_RIGHT):
            if orientation == gtk.POS_RIGHT:
                rotate_matrix = cairo.Matrix(1, 0, 0, 1, 1, width + 1.5)
                cairo.Matrix.rotate(rotate_matrix, 4.71)
            else:
                rotate_matrix = cairo.Matrix(1, 0, 0, 1, applet_size + 1.5, 0)
                cairo.Matrix.rotate(rotate_matrix, -4.71)
            ct.transform(rotate_matrix)
        if self.applet.settings['applet_traffic_scale']:
            scale = int(self.applet.settings['applet_traffic_scale'] \
              * self.applet.settings['applet_width'])
        else:
            scale = int(12 * self.applet.settings['applet_width'])
        inverse_scale = scale * -1
        ct.set_source_surface(cs)
        ct.set_line_width(2)
        if self.background and self.display_graph:
            bgColor, alpha = \
                self.applet.settings['background_color'].split('|')
            bgColor = gtk.gdk.color_parse(bgColor)
            ct.set_source_rgba(bgColor.red / 65535.0,
                bgColor.green / 65535.0,
                bgColor.blue / 65535.0,
                float(alpha))
            awn.cairo_rounded_rect(ct,
                0, 0,
                width + 1,
                applet_size + 1,
                4, awn.ROUND_ALL)
            ct.fill()
        if self.iface == _('Multi Interface') and self.display_graph:
            tmp_history = [1]
            for iface in self.netstats.ifaces:
                if self.netstats.ifaces[iface]['multi_include']:
                    tmp_history.extend(
                        self.netstats.ifaces[iface]['rx_history'][inverse_scale:])
                    tmp_history.extend(
                        self.netstats.ifaces[iface]['tx_history'][inverse_scale:])
            tmp_history.sort()
            max_val = tmp_history[-1]
            self.ratio = max_val / 28 if max_val > self.ratio else 1
            for iface in self.netstats.ifaces:
                if self.netstats.ifaces[iface]['multi_include']:
                    self.draw_meter(ct, width, applet_size,
                        iface, True, scale=scale)
        else:
            if self.iface and self.iface in self.netstats.ifaces and self.display_graph:
                if 'signal' in self.netstats.ifaces[self.iface]:
                    if self.applet.settings['applet_signal_scale']:
                        wscale = int(self.applet.settings['applet_signal_scale'] * self.applet.settings['applet_width'])
                    else:
                        wscale = int(5 * self.applet.settings['applet_width'])
                    self.draw_wireless(ct,
                        width,
                        applet_size,
                        self.iface,
                        scale=wscale,
                        graph_source='applet')
                self.draw_meter(ct,
                    width,
                    applet_size,
                    self.iface,
                    scale=scale,
                    graph_source='applet')
        if self.iface in self.netstats.ifaces:
            if self.label_control:
                if self.label_control == 2:
                    self.sum_ot.props.text = \
                        self.readable_speed_ps(
                            self.netstats.ifaces[self.iface]['tx_bytes'],
                            self.unit) + '\n' + \
                        self.readable_speed_ps(
                            self.netstats.ifaces[self.iface]['rx_bytes'],
                            self.unit)
                else:
                    self.sum_ot.props.text = \
                        self.readable_speed_ps(
                            self.netstats.ifaces[self.iface]['rx_bytes'] \
                            + self.netstats.ifaces[self.iface]['tx_bytes'],
                            self.unit)
            else:
                    self.sum_ot.props.text = ''
            self.title_text = self.readable_speed_ps(
                self.netstats.ifaces[self.iface]['tx_bytes'], self.unit)
        else:
            self.sum_ot.props.text = _('No Device')
            self.title_text = _('Please select a valid device')
        if self.border and self.display_graph:
            line_width = 2
            ct.set_line_width(line_width)
            borderColor, alpha = \
                self.applet.settings['border_color'].split('|')
            borderColor = gtk.gdk.color_parse(borderColor)
            ct.set_source_rgba(borderColor.red / 65535.0,
                borderColor.green / 65535.0,
                borderColor.blue / 65535.0,
                float(alpha))
            awn.cairo_rounded_rect(ct,
                line_width / 2,
                line_width / 2,
                width - (line_width / 2),
               applet_size - (line_width / 2) + 0.5,
               4, awn.ROUND_ALL)
            ct.stroke()
        self.applet.set_icon_context(ct)
        if self.applet.dialog.is_visible('main'):
            self.interface_dialog.do_current()
        if self.applet.dialog.is_visible('main') \
          or hasattr(self.applet.dialog.menu.window, 'is_visible') \
          and self.applet.dialog.menu.window.is_visible():
            for iface in self.netstats.ifaces:
                if not 'in_list' in self.netstats.ifaces[iface] \
                  or self.netstats.regenerate == True:
                    self.netstats.regenerate = False
                    if hasattr(self.applet.dialog.menu.window, 'is_visible') \
                      and self.applet.dialog.menu.window.is_visible():
                        self.generate_iface_submenu()
                    self.interface_dialog.interfaceListArea.rebuild()
                    self.interface_dialog.interfaceListArea.refresh()
                    self.interface_dialog.interfaceOptionsArea.refresh()
                    return True
        return True
Beispiel #10
0
 def draw_rounded_rect(self, ct, x, y, w, h):
     cairo_rounded_rect(ct, x, y, w, h, 4, ROUND_ALL)