示例#1
0
    def __init__(self, weh):
        super(GTKstrip, self).__init__()
        self.label = "GTKstrip"

        chars = "ESKISTLFÜNFZEHNZWANZIGDREIVIERTELTGNACHVORJMHALBQZWÖLFPZWEINSIEBENKDREIRHFÜNFELFNEUNVIERWACHTZEHNRSBSECHSFMUHR...."

        self.labels = []
        self.colors = []

        self.weh = weh

        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.win.connect("delete_event", self.delete_event)
        self.win.connect("destroy", self.destroy)
        self.win.connect("key_press_event", self.key_press_event)

        table = gtk.Table(11, 11, True)

        x = 0
        y = 0
        for i in unicode(chars):
            label = gtk.Label(i)
            self.labels.append(label)
            self.colors.append(Color(0, 0, 0))

            table.attach(label, x, x + 1, y, y + 1, FILL, FILL)

            x += 1
            if x == 11:
                x = 0
                y += 1

            attrs = pango.AttrList()
            # attrs.insert(pango.AttrLanguage("de"))
            attrs.insert(pango.AttrForeground(0, 0, 0))
            attrs.insert(pango.AttrSize(30 * 1000))
            attrs.insert(pango.AttrBackground(0, 0, 0))
            label.set_attributes(attrs)

            label.show()

        color = gtk.gdk.color_parse('#000000')
        self.win.modify_bg(gtk.STATE_NORMAL, color)
        self.win.add(table)
        self.win.show_all()
示例#2
0
    def __init__(self, parent=None, size=(1920, 1080)):
        self.superior = parent
        wprop = size[0] / 1920.0
        hprop = size[1] / 1080.0
        self.wprop = wprop
        self.hprop = hprop
        gtk.HBox.__init__(self, False, int(wprop * 5))

        self.set_border_width(int(wprop * 20))
        self.vbox = gtk.VBox(False, 0)

        self.buttons = gtk.VButtonBox()
        self.buttons.set_layout(gtk.BUTTONBOX_START)
        self.buttons.set_spacing(int(wprop * 5))

        scrolled = gtk.ScrolledWindow()
        scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN)

        self.list, self.view = self.prepare_view()
        self.view.get_selection().connect("changed", self.append_info)
        scrolled.add(self.view)

        sidebox = gtk.VBox(False, 0)
        frame = gtk.Frame()

        label = gtk.Label("Profile Tracks")
        alist = pango.AttrList()
        font = pango.FontDescription("bold " + str(int(self.hprop * 15)))
        attr = pango.AttrFontDesc(font, 0, -1)
        alist.insert(attr)
        label.set_attributes(alist)

        frame.set_label_widget(label)
        frame.set_label_align(0.5, 0.5)
        frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        align = gtk.Alignment(1, 0.5, 0.95, 0.9)
        self.sidetable = gtk.Table(homogeneous=True)
        self.sidetable.set_size_request(int(wprop * 300), -1)
        align.add(self.sidetable)
        frame.add(align)

        self.vbox.pack_end(scrolled, True, True, 0)
        self.pack_start(self.vbox, True, True, 0)
        sidebox.pack_start(self.buttons, False, False, int(hprop * 10))
        sidebox.pack_start(frame, False, False, int(hprop * 15))
        self.pack_start(sidebox, False, False, int(wprop * 15))
示例#3
0
文件: common.py 项目: xt0ph/tryton
def get_label_attributes(readonly, required):
    "Return the pango attributes applied to a label according to its state"
    if readonly:
        style = pango.STYLE_NORMAL
        weight = pango.WEIGHT_NORMAL
    else:
        style = pango.STYLE_ITALIC
        if required:
            weight = pango.WEIGHT_BOLD
        else:
            weight = pango.WEIGHT_NORMAL
    attrlist = pango.AttrList()
    if hasattr(pango, 'AttrWeight'):
        attrlist.change(pango.AttrWeight(weight, 0, -1))
    if hasattr(pango, 'AttrStyle'):
        attrlist.change(pango.AttrStyle(style, 0, -1))
    return attrlist
示例#4
0
    def resize(self):
        """Adapts GUI elements to the screen size"""
        buttonlist = [
            "playbutton", "editbutton", "ingestbutton", "deletebutton"
        ]
        size = context.get_mainwindow().get_size()
        wprop = size[0] / 1920.0
        hprop = size[1] / 1080.0

        vbar = self.scroll.get_vscrollbar()
        vbar.set_size_request(int(wprop * 6), -1)

        self.renders[0].set_property('height', int(hprop * 40))
        self.renders[0].set_property('width-chars', int(wprop * 56))  #name
        self.renders[1].set_property('width-chars', int(wprop * 14))  #size
        self.renders[2].set_property('width-chars', int(wprop * 10))  #duration
        self.renders[3].set_property('width-chars', int(wprop * 23))  #date
        self.renders[5].set_property('width-chars',
                                     int(wprop * 27))  #presenter
        self.renders[6].set_property('width-chars', int(wprop * 33.5))  #series
        #self.renders[7].set_property('width-chars',int(wprop*12.5))#statusess
        self.renders[8].set_property('width-chars',
                                     int(wprop * 14))  #operations less

        fsize = 12 * hprop
        for cell in self.renders:
            font = pango.FontDescription(str(fsize))
            cell.set_property('font-desc', font)

        for column in self.vista.get_columns():
            first = column.get_widget()
            if not first:
                label = gtk.Label(" " + column.get_title())
            else:
                label = column.get_widget()
            attr = pango.AttrList()
            attr.insert(pango.AttrFontDesc(font, 0, -1))
            label.set_attributes(attr)
            if not first:
                label.show()
                column.set_widget(label)
            column.queue_resize()

        self.do_resize(buttonlist)
        return True
 def set_attr(layout):
     attr = pango.AttrList()
     size = pango.AttrSize(int(11.5 * pango.SCALE), 0, -1)
     attr.insert(size)
     if customAttr and customAttr.attributes_dict:
         attributes_dict = customAttr.attributes_dict
      
         if attributes_dict.has_key("regex_include_match"):
             start, end = attributes_dict["regex_include_match"]
             pango_color = pango.AttrBackground(self.include_color.red, self.include_color.green, 
                                                self.include_color.blue, start, end)
             attr.insert(pango_color)
         if attributes_dict.has_key("regex_exclude_match"):
             start, end = attributes_dict["regex_exclude_match"]
             pango_color = pango.AttrForeground(self.exclude_color.red, self.exclude_color.green, 
                                                self.exclude_color.blue, start, end)
             attr.insert(pango_color)
     layout.set_attributes(attr)
示例#6
0
def main():
    if len(sys.argv) != 3:
        usage()
        sys.exit(1)

    version = sys.argv[1]
    imgpath = sys.argv[2]

    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 140,24)
    ctx = cairo.Context(surface)
    c = pangocairo.CairoContext(ctx)

    l = c.create_layout()
    font_desc = pango.FontDescription('Grixel Acme 7 Wide Bold 14')
    l.set_font_description(font_desc)
    fo = cairo.FontOptions()
    fo.set_antialias(cairo.ANTIALIAS_NONE)

    c.set_font_options(fo)
    pangocairo.context_set_font_options (l.get_context(), fo)
    l.set_text('theory')
    set_context_color(ctx,'#333333')
    ctx.move_to(4,-8)
    c.show_layout(l)
    c.update_layout(l)


    l = c.create_layout()
    font_desc = pango.FontDescription('Grixel Acme 7 Wide 7')
    attr = pango.AttrList()
    attr.insert(pango.AttrLetterSpacing(1200,0,100))
    l.set_attributes(attr)
    l.set_font_description(font_desc)
    fo = cairo.FontOptions()
    fo.set_antialias(cairo.ANTIALIAS_NONE)
    pangocairo.context_set_font_options (l.get_context(), fo)
    l.set_text(version)
    ctx.move_to(105,8)
    ctx.set_source_rgb (.33,.33,.33)

    c.show_layout(l)
    c.update_layout(l)

    surface.write_to_png(imgpath)
    def __init__(self,
                 coords,
                 pango_context,
                 thought_number,
                 save,
                 undo,
                 loading,
                 background_color,
                 foreground_color,
                 name="thought"):
        super(TextThought, self).__init__(coords, save, name, undo,
                                          background_color, foreground_color)

        self.index = 0
        self.end_index = 0
        self.bytes = ""
        self.bindex = 0
        self.text_element = save.createTextNode("GOOBAH")
        self.element.appendChild(self.text_element)
        self.layout = None
        self.identity = thought_number
        self.pango_context = pango_context
        self.moving = False
        self.preedit = None
        self.attrlist = None
        self.attributes = pango.AttrList()
        self.current_attrs = []
        self.double_click = False
        self.orig_text = None

        if prefs.get_direction() == gtk.TEXT_DIR_LTR:
            self.pango_context.set_base_dir(pango.DIRECTION_LTR)
        else:
            self.pango_context.set_base_dir(pango.DIRECTION_RTL)

        self.b_f_i = self.bindex_from_index
        margin = utils.margin_required(utils.STYLE_NORMAL)
        if coords:
            self.ul = (coords[0] - margin[0], coords[1] - margin[1])
        else:
            self.ul = None

        self.all_okay = True
示例#8
0
    def __init__(self):
        gtk.Table.__init__(self)
        self.resize(4,110)
        self.set_homogeneous(True)
        self.mute = False
        self.vumeter=gtk.ProgressBar()
        #numbers
        minimum = gtk.Label("-100")
        maximum = gtk.Label("0dB")
        mark = gtk.Label("-10")
        sixty = gtk.Label("-60")
        thirty = gtk.Label("-30")

        labels= [minimum,sixty,thirty,mark,maximum]
        for label in labels:
            label.set_justify(gtk.JUSTIFY_CENTER)
            alist = pango.AttrList()
            font=pango.FontDescription("bold")
            attr=pango.AttrFontDesc(font,0,-1)
            alist.insert(attr)
            label.set_attributes(alist)

        #marks
        mark100=gtk.VSeparator()
        mark60=gtk.VSeparator()
        mark30=gtk.VSeparator()
        mark10=gtk.VSeparator()
        mark0=gtk.VSeparator()

        # attach to widget
        self.attach(mark100,5,6,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-100
        self.attach(mark60,45,46,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-60
        self.attach(mark30,75,76,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-30
        self.attach(mark10,95,96,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-10
        self.attach(mark0,105,106,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#0       
        
        self.attach(minimum,0,10,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-100
        self.attach(sixty,40,50,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-60
        self.attach(thirty,70,80,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-30
        self.attach(mark,90,100,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#-10
        self.attach(maximum,100,110,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)#0

        self.attach(self.vumeter,5,105,2,4,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,0,0)
示例#9
0
 def layer_name_datafunc(self, column, renderer, model, tree_iter,
                         *data_etc):
     layer = model.get_value(tree_iter, 0)
     path = model.get_path(tree_iter)
     name = layer.name
     attrs = pango.AttrList()
     if not name:
         layer_num = self.app.doc.get_number_for_nameless_layer(layer)
         name = _(u"Untitled layer #%d") % layer_num
         markup = "<small><i>%s</i></small> " % (escape(name), )
         if gtk2compat.USE_GTK3:
             parse_result = pango.parse_markup(markup, -1, '\000')
             parse_ok, attrs, name, accel_char = parse_result
             assert parse_ok
         else:
             parse_result = pango.parse_markup(markup)
             attrs, name, accel_char = parse_result
     renderer.set_property("attributes", attrs)
     renderer.set_property("text", name)
示例#10
0
    def draw_text(self, text='Hello'):
        self.window.window.move_resize(700, 750, 1280, 80)
        ctx = self.window.window.cairo_create()
        ptx = self.window.get_pango_context()

        ctx.save()
        ctx.set_source_rgba(0.3, 0.0, 0.0, 0.3)
        ctx.set_operator(cairo.OPERATOR_SOURCE)
        ctx.paint()
        ctx.restore()

        font = pango.FontDescription()

        font.set_family("sans")
        font.set_size(32 * pango.SCALE)

        ctx.move_to(400, 0)
        if not self.layout:
            #                layout = pango.Layout(ptx)
            #                layout = ctx.create_layout()
            #                layout = self.object.get_layout()
            layout = self.object.create_pango_layout(text)
            layout.set_font_description(font)
            layout.set_text(text)
            attrs = pango.AttrList()
            attr = pango.AttrForeground(65535, 0, 0, 0, -1)
            attrs.insert(attr)
            layout.set_attributes(attrs)
            self.layout = layout

            ctx.show_layout(layout)

        layout = self.layout
        layout.set_alignment(pango.ALIGN_RIGHT)
        print layout.get_alignment()
        print layout.get_pixel_size()

        layout.set_text(text)

        ctx.set_source_rgba(1, 0, 0, 0.5)
        ctx.fill()
        ctx.show_layout(layout)
示例#11
0
    def __init__(self, dial_group = None, window_group = None,
                                    window_title = "", additional_text = None,
                                    actionok = None, actioncancel = None):

        gtk.Dialog.__init__(self, window_title, None,
                        gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL,
                        gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        if window_group is not None:
            window_group.add_window(self)
        self.set_resizable(False)
        self.connect("close", self.respond, actionok, actioncancel)
        self.connect("response", self.respond, actionok, actioncancel)
        self.connect("window-state-event", self.window_attn)
        self.set_default_response(gtk.RESPONSE_OK)
        
        hbox = gtk.HBox(False, 20)
        hbox.set_border_width(20)
        self.vbox.pack_start(hbox, True, True, 0)
        hbox.show()
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(image, True, True, 0)
        image.show()
        vbox = gtk.VBox()
        vbox.set_spacing(8)
        hbox.pack_start(vbox, True, True, 0)
        vbox.show()
        
        if additional_text is not None:
            if type(additional_text) is str:
                additional_text = additional_text.splitlines()
            for each in additional_text:
                label = gtk.Label()
                attrlist = pango.AttrList()
                attrlist.insert(pango.AttrSize(12500, 0, len(each)))
                label.set_attributes(attrlist)
                label.set_text(each)
                vbox.add(label)
                label.show()
        if dial_group is not None:
            dial_group.add(self)
        self.dial_group = dial_group
示例#12
0
    def set_window_size(self, setting):
        """Set window and label size."""
        window_width = self.screen_width
        window_height = -1

        if setting == SIZE_LARGE:
            window_height = 24 * self.screen_height / 100
        if setting == SIZE_MEDIUM:
            window_height = 12 * self.screen_height / 100
        if setting == SIZE_SMALL:
            window_height = 8 * self.screen_height / 100

        attr = pango.AttrList()
        attr.change(pango.AttrSize((50 * window_height / 100) * 1000, 0, -1))
        attr.change(pango.AttrFamily("Sans", 0, -1))
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))
        attr.change(pango.AttrForeground(65535, 65535, 65535, 0, -1))

        self.label.set_attributes(attr)
        self.resize(window_width, window_height)
示例#13
0
文件: title.py 项目: alnvdl/oks
 def __init__(self, parent_window, actions_label):
     gtk.EventBox.__init__(self)
     self.label = gtk.Label()
     self.button_actions = ButtonMenu(parent_window, actions_label)
     
     attributes = pango.AttrList()
     attributes.insert(pango.AttrWeight(700, 0, -1))
     attributes.insert(pango.AttrSize(16000, 0, -1))
     self.label.set_attributes(attributes)
     self.label.set_ellipsize(pango.ELLIPSIZE_END)
     self.label.set_alignment(0.0, 0.5)
     self.label.set_padding(2, 0)
     
     hbox = gtk.HBox()
     hbox.pack_start(self.label)
     hbox.pack_start(self.button_actions, False, False)
     self.add(hbox)
     
     self.connect("realize", self.on_realize)
     self.show_all()
示例#14
0
    def _generate_thumb_with_text(self):
        """ Generate the text on the pixbuf """
        # This technique is used to compose image with text
        # create a pixmap with the data of the pixbuf then insert text
        # cf. pygtk FAQ  How do I draw a text [or something else] on a gtk.gdk.pixbuf? for mor explication
        # (http://faq.pygtk.org/index.py?req=show&file=faq08.020.htp )

        pixmap, mask = self._pixbuf_thumb.render_pixmap_and_mask()

        # graphic context and Drawarea any created to allow generation of pixbuf composition
        gc = pixmap.new_gc()
        area = gtk.DrawingArea()
        # create pango layout
        self.pangolayout = area.create_pango_layout("")

        # extract only the image name without extenstion
        text_buffer, ext = os.path.splitext(self._name)
        text_buffer = " " + text_buffer + " "
        self.pangolayout.set_text(text_buffer)
        # set text attributes
        attrs = pango.AttrList()
        attrs.insert(pango.AttrFamily(LCONST.THUMB_TEXT_FAMILY, 0, -1))
        attrs.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, -1))
        attrs.insert(
            pango.AttrForeground(LCONST.THUMB_TEXT_COLOR[0],
                                 LCONST.THUMB_TEXT_COLOR[1],
                                 LCONST.THUMB_TEXT_COLOR[2], 0, -1))
        attrs.insert(pango.AttrBackground(0, 0, 0, 0, -1))
        attrs.insert(pango.AttrSize(LCONST.THUMB_TEXT_SIZE, 0, -1))
        self.pangolayout.set_attributes(attrs)

        # compute text layout position and set it on pixmap
        (w, h) = (self._pixbuf_thumb.get_width(),
                  self._pixbuf_thumb.get_height())
        (lw, lh) = self.pangolayout.get_pixel_size()
        pixmap.draw_layout(gc, (w - lw) // 2, (h - lh - 2), self.pangolayout)

        # function get_from_drawable gets the the pixbuf from the pixmap
        # no need to affect resuly to a new pisbuf: self._pixbuf_thumb is changed whe get_from_drawable is used
        self._pixbuf_thumb.get_from_drawable(pixmap, pixmap.get_colormap(), 0,
                                             0, 0, 0, -1, -1)
示例#15
0
    def __begin(self, ctx):
        """ callback dor drag-begin signal 
        Enable the display of moved rows.

        At MAX 3 rows ares shown during motion.
        """
        model, paths = self.get_selection().get_selected_rows()
        MAX = 3
        if paths:
            icons = map(self.create_row_drag_icon, paths[:MAX])
            height = (
                sum(map(lambda s: s.get_size()[1], icons))-2*len(icons))+2
            width = max(map(lambda s: s.get_size()[0], icons))
            final = gtk.gdk.Pixmap(icons[0], width, height)
            gc = gtk.gdk.GC(final)
            gc.copy(self.style.fg_gc[gtk.STATE_NORMAL])
            gc.set_colormap(self.window.get_colormap())
            count_y = 1
            for icon in icons:
                w, h = icon.get_size()
                final.draw_drawable(gc, icon, 1, 1, 1, count_y, w-2, h-2)
                count_y += h - 2
            if len(paths) > MAX:
                count_y -= h - 2
                bgc = gtk.gdk.GC(final)
                bgc.copy(self.style.base_gc[gtk.STATE_NORMAL])
                final.draw_rectangle(bgc, True, 1, count_y, w-2, h-2)
                more = ("and %d more...") % (len(paths) - MAX + 1)
                layout = self.create_pango_layout(more)
                attrs = pango.AttrList()
                attrs.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, len(more)))
                layout.set_attributes(attrs)
                layout.set_width(pango.SCALE * (w - 2))
                lw, lh = layout.get_pixel_size()
                final.draw_layout(gc, (w-lw)//2, count_y + (h-lh)//2, layout)

            final.draw_rectangle(gc, False, 0, 0, width-1, height-1)
            self.drag_source_set_icon(final.get_colormap(), final)
        else:
            gobject.idle_add(ctx.drag_abort, gtk.get_current_event_time())
            self.drag_source_set_icon_stock(gtk.STOCK_MISSING_IMAGE)
示例#16
0
    def on_configure(self, _, event):
        window_height = event.height
        attr = pango.AttrList()
        attr.change(pango.AttrSize(int(self.options['fontsize']) * 1000, 0, -1))
        attr.change(pango.AttrFamily(self.options['font'], 0, -1))
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))

        fgcolor = gtk.gdk.color_parse(self.fg)
        attr.change(pango.AttrForeground(
            fgcolor.red, fgcolor.green, fgcolor.blue, 0, -1))

        self.pos_x = event.x
        self.pos_y = event.y

        if self.timer:
            self.timer.cancel()

        self.timer = Timer(self.options['timeout'], self.on_timeout)
        self.timer.start()

        self.label.set_attributes(attr)
示例#17
0
    def on_type_entry_changed(self, *args):
        if not self.start_time:
            self.start_time = time.time()

        cur_text = unicode(self.type_entry.get_text())

        bad_idx = []
        for i, c in enumerate(cur_text):
            if c != self.totype_text[i]:
                bad_idx.append(i)

        attrs = pango.AttrList()
        for idx in bad_idx:
            # Pango layout needs byte index not char one O_o
            pidx = len(self.totype_text[:idx].encode('utf-8'))
            Attr = pango.AttrBackground if self.totype_text[
                idx] == ' ' else pango.AttrForeground
            attrs.change(Attr(65535, 0, 0, pidx, pidx + 1))

        self.totype_entry.get_layout().set_attributes(attrs)
        self.totype_entry.queue_draw()
示例#18
0
    def make_popup_for(self, pos):
        """Generate and return a context menu for the given entry index"""
        popup = gtk.Menu()
        entry = self.entries[self.data[pos][3]]

        # TODO: If there's more than one install prefix detected, group and
        #  provide section headers.
        #  (eg. multiple versions of the same game installed in parallel)
        default_cmd = entry.default_launcher
        for cmd in sorted(entry.commands,
                          key=lambda x: (x != default_cmd, x.role, x.name)):
            # TODO: Move this into the frontend agnostic code
            # TODO: Use the role name, falling back to Play only if unknown
            # TODO: Sort by role
            # TODO: Put a separator between the Play links and the inst/uninst
            name = cmd.name if cmd.name != entry.name else 'Play'

            # TODO: Add an "Are you sure?" dialog for install/uninstall
            item = gtk.MenuItem(name)
            item.connect('activate', lambda _, cmd=cmd: cmd.run())
            popup.add(item)

            # TODO: Actually use a customizable default setting
            if cmd == default_cmd:
                attrs = pango.AttrList()
                attrs.insert(pango.AttrWeight(600, end_index=len(name)))
                item.get_child().set_attributes(attrs)

        popup.add(gtk.SeparatorMenuItem())

        mi_rename = gtk.MenuItem("Rename...")
        mi_rename.connect('activate', self.on_mi_rename_activate, pos)
        popup.add(mi_rename)

        mi_hide = gtk.MenuItem("Hide")
        mi_hide.connect('activate', self.on_mi_hide_activate, pos)
        popup.add(mi_hide)
        popup.show_all()
        return popup
示例#19
0
文件: xyz.py 项目: HaoLiSky/TSASE
 def gfx_draw_axes(self):
     axes = np.identity(3) * 32
     axes[0] = np.dot(self.rotation, axes[0])
     axes[1] = np.dot(self.rotation, axes[1])
     axes[2] = np.dot(self.rotation, axes[2])
     x0 = 48
     y0 = self.height - 48
     self.gfx_draw_line(x0, y0, x0 + axes[0][0], y0 - axes[0][1])
     self.gfx_draw_line(x0, y0, x0 + axes[1][0], y0 - axes[1][1])
     self.gfx_draw_line(x0, y0, x0 + axes[2][0], y0 - axes[2][1])
     font = pango.FontDescription("courier sans 12")
     X = self.area.create_pango_layout("x")
     Y = self.area.create_pango_layout("y")
     Z = self.area.create_pango_layout("z")
     attr = pango.AttrList()
     fg = pango.AttrForeground(65535, 0, 0, 0, -1)
     attr.insert(fg)
     X.set_alignment(pango.ALIGN_CENTER)
     Y.set_alignment(pango.ALIGN_CENTER)
     Z.set_alignment(pango.ALIGN_CENTER)
     X.set_font_description(font)
     Y.set_font_description(font)
     Z.set_font_description(font)
     X.set_attributes(attr)
     Y.set_attributes(attr)
     Z.set_attributes(attr)
     self.pixmap.draw_layout(
         self.black_gc,
         int(x0 + axes[0][0]) - X.get_pixel_size()[0] / 2,
         int(y0 - axes[0][1]) - X.get_pixel_size()[1], X)
     self.pixmap.draw_layout(
         self.black_gc,
         int(x0 + axes[1][0]) - Y.get_pixel_size()[0] / 2,
         int(y0 - axes[1][1]) - Y.get_pixel_size()[1], Y)
     self.pixmap.draw_layout(
         self.black_gc,
         int(x0 + axes[2][0]) - Z.get_pixel_size()[0] / 2,
         int(y0 - axes[2][1]) - Z.get_pixel_size()[1], Z)
示例#20
0
def IconButton(c, box, icon, text_1, text_2, width, height, margin, f_1, p_1):
    hbox = gtk.HBox()
    hbox.set_border_width(margin)

    button = gtk.Button()
    button.set_size_request(width, height)
    button.connect("clicked", f_1, *p_1)

    inbox = gtk.VBox()
    inbox.set_border_width(5)

    image = gtk.Image()
    image.set_from_file(icon)

    attr = pango.AttrList()
    size = pango.AttrSize(20000, 0, -1)
    attr.insert(size)

    title = gtk.Label()
    title.set_markup(text_1)
    title.set_justify(gtk.JUSTIFY_CENTER)
    title.set_attributes(attr)

    description = gtk.Label()
    description.set_markup(text_2)
    description.set_line_wrap(True)
    description.set_justify(gtk.JUSTIFY_CENTER)

    inbox.pack_start(image, False, False, 0)
    inbox.pack_start(title, False, False, 0)
    inbox.pack_start(gtk.HSeparator(), False, False, 5)
    inbox.pack_start(description, False, False, 0)
    button.add(inbox)

    hbox.pack_start(button, False, False, 0)
    box.pack_start(hbox, False, False, 0)

    return button
示例#21
0
    def SetHeadingStyle(self, items):
        for item in items:
            if item not in self.headingsToColor:
                self.headingsToColor.append(item)

        HeadingStyle = pango.AttrList()
        attr = pango.AttrSize(12000, 0, -1)
        HeadingStyle.insert(attr)

        if self.usecustomcolor:
            headingcolor = gtk.gdk.color_parse(self.customheadingcolor)
            attr = pango.AttrForeground(headingcolor.red, headingcolor.green,
                                        headingcolor.blue, 0, -1)
            HeadingStyle.insert(attr)


#               else:
#                       headingcolor = self.window.rc_get_style().bg[ gtk.STATE_SELECTED ]

        attr = pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)
        HeadingStyle.insert(attr)

        for item in items:
            item.set_attributes(HeadingStyle)
示例#22
0
 def setup(self):
     if self.gui:
         import pango
         self.core.register_ui("opengl_window",
                               "Dimension",
                               self.gui.get_object("DimensionTable"),
                               weight=20)
         self.core.get("register_display_item")("show_dimensions",
                                                "Show Dimensions", 60),
         # Color the dimension value according to the axes.
         # For "y" axis: 100% green is too bright on light background - we
         # reduce it a bit.
         for color, names in ((pango.AttrForeground(65535, 0, 0, 0, 100),
                               ("model_dim_x_label", "model_dim_x",
                                "ModelCornerXMax", "ModelCornerXMin",
                                "ModelCornerXSpaces")),
                              (pango.AttrForeground(0, 50000, 0, 0, 100),
                               ("model_dim_y_label", "model_dim_y",
                                "ModelCornerYMax", "ModelCornerYMin",
                                "ModelCornerYSpaces")),
                              (pango.AttrForeground(0, 0, 65535, 0, 100),
                               ("model_dim_z_label", "model_dim_z",
                                "ModelCornerZMax", "ModelCornerZMin",
                                "ModelCornerZSpaces"))):
             attributes = pango.AttrList()
             attributes.insert(color)
             for name in names:
                 self.gui.get_object(name).set_attributes(attributes)
         self._event_handlers = (("model-change-after",
                                  self.update_model_dimensions),
                                 ("visual-item-updated",
                                  self.update_model_dimensions),
                                 ("model-list-chaned",
                                  self.update_model_dimensions))
         self.register_event_handlers(self._event_handlers)
     return True
示例#23
0
    def update_example(self, widget=None):
        start = 0
        end = len(self.example)

        attributes = pango.AttrList()

        attributes.insert(
            pango.AttrForeground(self.text_color.red, self.text_color.green,
                                 self.text_color.blue, start, end))
        attributes.insert(
            pango.AttrBackground(self.highlight_color.red,
                                 self.highlight_color.green,
                                 self.highlight_color.blue, start, end))

        # Bold verification
        if self.bold_tg_button.get_active():
            attributes.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, start, end))
        else:
            attributes.insert(pango.AttrWeight(pango.WEIGHT_NORMAL, start,
                                               end))

        # Italic verification
        if self.italic_tg_button.get_active():
            attributes.insert(pango.AttrStyle(pango.STYLE_ITALIC, start, end))
        else:
            attributes.insert(pango.AttrStyle(pango.STYLE_NORMAL, start, end))

        # Underline verification
        if self.underline_tg_button.get_active():
            attributes.insert(
                pango.AttrUnderline(pango.UNDERLINE_SINGLE, start, end))
        else:
            attributes.insert(
                pango.AttrUnderline(pango.UNDERLINE_NONE, start, end))

        self.example_label.set_attributes(attributes)
示例#24
0
    def set_candidates(self, candidates, focus_candidate=0, show_cursor=True):
        assert len(candidates) <= len(self.__labels)
        for i, (text, attrs) in enumerate(candidates):
            if i == focus_candidate and show_cursor:
                if attrs == None:
                    attrs = pango.AttrList()
                color = self.__labels[i][1].style.base[gtk.STATE_SELECTED]
                end_index = len(text.encode("utf8"))
                attr = pango.AttrBackground(color.red, color.green, color.blue,
                                            0, end_index)
                attrs.change(attr)
                color = self.__labels[i][1].style.text[gtk.STATE_SELECTED]
                attr = pango.AttrForeground(color.red, color.green, color.blue,
                                            0, end_index)
                attrs.insert(attr)

            self.__labels[i][1].set_text(text)
            self.__labels[i][1].show()
            self.__labels[i][1].set_property("attributes", attrs)
            for w in self.__candidates[i]:
                w.show()

        for w in reduce(operator.add, self.__candidates[len(candidates):]):
            w.hide()
示例#25
0
    def create_pango_layout(self, text, *styles):
        layout = self.context.create_pango_layout()

        layout.set_text(text)
        layout.set_font_description(self.font)

        # We need to save some stuff for when we render; just stick extra properties on the
        # layout. We may want to move to a setup where we have "print objects" for layouts
        # or custom results.
        layout._left_margin = 0
        layout._right_margin = 0
        layout._paragraph_background = None

        attrs = pango.AttrList()
        for style in styles:
            spec = DEFAULT_STYLE.get_spec(style)
            spec.add_pango_attributes(attrs,
                                      start_index=0,
                                      end_index=0x7fffffff)

            # We are fudging pixels vs. points here
            if spec.left_margin:
                layout._left_margin = spec.left_margin
            if spec.left_margin:
                layout._right_margin = spec.right_margin
            if spec.paragraph_background:
                layout._paragraph_background = pango.Color(
                    spec.paragraph_background)

        layout._width = self.context.get_width(
        ) - layout._left_margin - layout._right_margin
        layout.set_width(int(pango.SCALE * layout._width))

        layout.set_attributes(attrs)

        return layout
示例#26
0
    def scheduler_launch_thread(self):
        """Thread handling the messages scheduler notification area."""
        # Based on: http://pygstdocs.berlios.de/pygst-tutorial/seeking.html
        thread_id = self.scheduler_thread_id
        event_type = self.gui.get_object("nextlabel")
        title = self.gui.get_object("titlelabel")
        status = self.gui.get_object("eventlabel")

        # Status panel
        # status_disk = self.gui.get_object("status1")
        # status_hours = self.gui.get_object("status2")
        # status_mh = self.gui.get_object("status3")

        self.check_schedule()
        parpadeo = True
        changed = False
        signalized = False

        if self.font == None:
            anchura = self.get_toplevel().get_screen().get_width()
            if anchura not in [1024, 1280, 1920]:
                anchura = 1920
            k1 = anchura / 1920.0
            changing_font = pango.FontDescription("bold " + str(k1 * 42))
            self.font = changing_font

        bold = pango.AttrWeight(700, 0, -1)
        red = pango.AttrForeground(65535, 0, 0, 0, -1)
        black = pango.AttrForeground(17753, 17753, 17753, 0, -1)
        font = pango.AttrFontDesc(self.font, 0, -1)

        attr_red = pango.AttrList()
        attr_black = pango.AttrList()

        attr_red.insert(red)
        attr_red.insert(font)
        attr_red.insert(bold)

        attr_black.insert(black)
        attr_black.insert(font)
        attr_black.insert(bold)

        status.set_attributes(attr_black)
        one_second = datetime.timedelta(seconds=1)
        while thread_id == self.scheduler_thread_id:
            if self.font != changing_font:
                attr_black.insert(pango.AttrFontDesc(self.font, 0, -1))
                attr_red.insert(pango.AttrFontDesc(self.font, 0, -1))
                changing_font = self.font
            if self.current:
                start = self.current.getLocalDate()
                duration = self.current.getDuration() / 1000
                end = start + datetime.timedelta(seconds=duration)
                dif = end - datetime.datetime.now()
                #dif2 = datetime.datetime.now() - start
                if dif < datetime.timedelta(0, 0):  # Checking for malfuntions
                    self.current = None
                    self.current_mediapackage = None
                    status.set_text("")
                else:
                    status.set_text("Stopping on " +
                                    self.time_readable(dif + one_second))
                    if event_type.get_text() != CURRENT_TEXT:
                        event_type.set_text(CURRENT_TEXT)
                    if title.get_text() != self.current.title:
                        title.set_text(self.current.title)

                    if dif < datetime.timedelta(0, TIME_RED_STOP):
                        if not changed:
                            status.set_attributes(attr_red)
                            changed = True
                    elif changed:
                        status.set_attributes(attr_black)
                        changed = False
                    if dif < datetime.timedelta(0, TIME_BLINK_STOP):
                        parpadeo = False if parpadeo else True
                # Timer(diff,self.check_schedule)

            elif self.next:
                start = self.next.getLocalDate()
                dif = start - datetime.datetime.now()
                if event_type.get_text != NEXT_TEXT:
                    event_type.set_text(NEXT_TEXT)
                if title.get_text() != self.next.title:
                    title.set_text(self.next.title)
                status.set_text("Starting on " + self.time_readable(dif))

                if dif < datetime.timedelta(0, TIME_RED_START):
                    if not changed:
                        status.set_attributes(attr_red)
                        changed = True
                elif changed:
                    status.set_attributes(attr_black)
                    changed = False

                if dif < datetime.timedelta(0, TIME_UPCOMING):
                    if not signalized:
                        self.dispatcher.emit("upcoming-recording")
                        signalized = True
                elif signalized:
                    signalized = True

                if dif < datetime.timedelta(0, TIME_BLINK_START):
                    if parpadeo:
                        status.set_text("")
                        parpadeo = False
                    else:
                        parpadeo = True
                # Timer(60,self.check_schedule)

            else:  # Not current or pending recordings
                if event_type.get_text():
                    event_type.set_text("")
                if status.get_text():
                    status.set_text("")
                if title.get_text() != "No upcoming events":
                    title.set_text("No upcoming events")

            time.sleep(0.5)
            self.check_schedule()
        return True
示例#27
0
    def __init__(self, logger, options, show_settings=False):
        gtk.Window.__init__(self, gtk.WINDOW_POPUP)

        self.timer_hide = None
        self.timer_min = None
        self.logger = logger

        defaults = Options({
            'no_systray': False,
            'timeout': 2.5,
            'recent_thr': 0.1,
            'compr_cnt': 3,
            'ignore': [],
            'position': 'bottom',
            'persist': False,
            'font_desc': 'Sans Bold',
            'font_size': 'medium',
            'font_color': 'white',
            'bg_color': 'black',
            'opacity': 0.8,
            'key_mode': 'composed',
            'bak_mode': 'baked',
            'mods_mode': 'normal',
            'mods_only': False,
            'multiline': False,
            'vis_shift': False,
            'vis_space': True,
            'geometry': None,
            'screen': 0
        })
        self.options = self.load_state()
        if self.options is None:
            self.options = defaults
        else:
            # copy missing defaults
            for k, v in defaults.iteritems():
                if k not in self.options:
                    self.options[k] = v
        if options is not None:
            # override with values from constructor
            for k, v in options.iteritems():
                if v is not None:
                    self.options[k] = v

        self.set_keep_above(True)
        self.set_accept_focus(False)
        self.set_focus_on_map(False)

        self.label = gtk.Label()
        self.label.set_attributes(pango.AttrList())
        self.label.set_ellipsize(pango.ELLIPSIZE_START)
        self.label.set_justify(gtk.JUSTIFY_CENTER)
        self.label.show()
        self.add(self.label)

        self.set_gravity(gtk.gdk.GRAVITY_CENTER)
        self.connect("configure-event", self.on_configure)
        scr = self.get_screen()
        scr.connect("size-changed", self.on_configure)
        scr.connect("monitors-changed", self.on_monitors_changed)
        self.set_active_monitor(self.options.screen)

        self.font = pango.FontDescription(self.options.font_desc)
        self.update_colors()
        self.update_label()

        self.labelmngr = None
        self.enabled = True
        self.on_change_mode()

        self.make_menu()
        self.make_about_dialog()
        self.make_preferences_dialog()

        if not self.options.no_systray:
            self.make_systray()

        self.connect("delete-event", self.quit)
        if show_settings:
            self.on_preferences_dialog()
        if self.options.persist:
            self.show()
示例#28
0
    def set_shown_window(self, window):
        if self.shown_window != None:
            if self.sw_name_changed_handler != None:
                self.shown_window.disconnect(self.sw_name_changed_handler)
            if self.sw_state_changed_handler != None:
                self.shown_window.disconnect(self.sw_state_changed_handler)
        self.shown_window = window
        self.sw_name_changed_handler = self.shown_window.connect(
            'name-changed', self.on_window_name_changed)
        self.sw_state_changed_handler = self.shown_window.connect(
            'state-changed', self.on_shown_window_state_changed)

        self.container.show_all()
        #~ self.icon.set_from_pixbuf(self.shown_window.get_mini_icon())
        name = u"" + self.shown_window.get_name()
        self.label.set_tooltip_text(name)
        self.label.set_text(name)
        if self.shown_window.get_actions() & action_minimize:
            self.minimize_button.show()
        else:
            self.minimize_button.hide()
        if self.shown_window.is_maximized():
            self.max_icon_state = 'restore'
            if self.shown_window.get_actions() & action_unminimize:
                self.maximize_button.show()
            else:
                self.maximize_button.hide()
        else:
            self.max_icon_state = 'maximize'
            if self.shown_window.get_actions() & action_maximize:
                self.maximize_button.show()
            else:
                self.maximize_button.hide()
        if self.shown_window == self.active_window \
        and self.window_state == 'passive':
            self.window_state = 'active'
            self.minimize_image.set_from_pixbuf(
                self.pixbufs['minimize_normal_%s' % self.window_state])
            self.maximize_image.set_from_pixbuf(
                self.pixbufs['%s_normal_%s' %
                             (self.max_icon_state, self.window_state)])
            self.close_image.set_from_pixbuf(self.pixbufs['close_normal_%s' %
                                                          self.window_state])
        elif self.shown_window != self.active_window \
        and not self.window_state == 'passive':
            self.window_state = 'passive'
            self.minimize_image.set_from_pixbuf(
                self.pixbufs['minimize_normal_%s' % self.window_state])
            self.maximize_image.set_from_pixbuf(
                self.pixbufs['%s_normal_%s' %
                             (self.max_icon_state, self.window_state)])
            self.close_image.set_from_pixbuf(self.pixbufs['close_normal_%s' %
                                                          self.window_state])

        attr_list = pango.AttrList()
        if settings['%s_bold' % self.window_state]:
            attr_list.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 300))
        color = settings['%s_color' % self.window_state]
        r = int(color[1:3], 16) * 256
        g = int(color[3:5], 16) * 256
        b = int(color[5:7], 16) * 256
        attr_list.insert(pango.AttrForeground(r, g, b, 0, 300))
        self.label.set_attributes(attr_list)
示例#29
0
    def __init__(self, widget, self_seccion_stock, self_ventana_principal):
        self.codigo = []
        self.codigos_repetidos = ["l", "L", "r", "R"]
        object = self_ventana_principal.window
        object.set_sensitive(False)
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_size_request(1131, 600)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_title("Busqueda de productos")
        self.window.set_resizable(False)
        self.window.connect("delete-event", self.delete_event, object)
        self.fixed = gtk.Fixed()

        img = gtk.Image()

        self.fixed.add(img)
        self.window.add(self.fixed)

        atributos = pango.AttrList()
        atributos.insert(pango.AttrSize(12400, 0, -1))
        atributos.insert(pango.AttrWeight(1200, 0, -1))

        label_codigo = gtk.Label("Codigo : ")
        label_descripcion = gtk.Label("Descripcion : ")
        label_cantidad = gtk.Label("Cantidad : ")

        label_codigo.set_attributes(atributos)
        label_descripcion.set_attributes(atributos)
        label_cantidad.set_attributes(atributos)

        fuente_entrys = "Sans 13"
        font_entry = pango.FontDescription(fuente_entrys)

        self.entry = gtk.Entry()
        self.entry_descripcion = gtk.Entry()
        self.entry_cantidad = gtk.Entry()

        self.entry.modify_font(font_entry)
        self.entry_descripcion.modify_font(font_entry)
        self.entry_cantidad.modify_font(font_entry)

        self.fixed.put(self.entry, 150, 20)
        self.fixed.put(self.entry_descripcion, 480, 20)
        self.fixed.put(self.entry_cantidad, 750, 20)

        self.fixed.put(label_codigo, 80, 25)
        self.fixed.put(label_descripcion, 370, 25)
        self.fixed.put(label_cantidad, 660, 25)

        self.button_ma = gtk.Button()
        self.button_ma.set_property("relief", 2)
        imagen_boton_cerrar = gtk.Image()
        imagen_boton_cerrar.set_from_file("../Images/boton_cerrar.png")
        self.button_ma.add(imagen_boton_cerrar)
        self.fixed.put(self.button_ma, 990, 550)

        #agrego a una lista informacion de la bd

        self.button_ma.connect("clicked", self.salir, object)
        self.entry.connect("changed", self.mostrar, 'codigo')
        self.entry.connect("activate", self.verificar_codigo, 'codigo')
        self.entry_cantidad.connect("activate", self.cargar,
                                    self_seccion_stock)

        #--------------------------------------------------------------------------------------------------------------
        self.scroll_win = gtk.ScrolledWindow()
        self.scroll_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll_win.set_size_request(1111, 470)
        self.fixed.put(self.scroll_win, 10, 70)

        self.liststore = gtk.ListStore(str, int, str, str, float, float, str,
                                       str, str, str, str, 'gboolean')
        self.treeview = gtk.TreeView(self.liststore)
        rules_hint = self.treeview.get_rules_hint()
        self.treeview.set_rules_hint(True)

        self.scroll_win.add(self.treeview)

        self.columnpb = gtk.TreeViewColumn("")
        self.column1 = gtk.TreeViewColumn("Codigo")
        self.column2 = gtk.TreeViewColumn("Descripcion")
        self.column3 = gtk.TreeViewColumn("Costo")
        self.column4 = gtk.TreeViewColumn("Precio")
        self.column5 = gtk.TreeViewColumn("Stock inicial")
        self.column6 = gtk.TreeViewColumn("Stock disponible")
        self.column7 = gtk.TreeViewColumn("punto de reposicion")
        self.column8 = gtk.TreeViewColumn("Reponer")

        self.treeview.append_column(self.columnpb)
        self.treeview.append_column(self.column1)
        self.treeview.append_column(self.column2)
        self.treeview.append_column(self.column3)
        self.treeview.append_column(self.column4)
        self.treeview.append_column(self.column5)
        self.treeview.append_column(self.column6)
        self.treeview.append_column(self.column7)

        self.cell = gtk.CellRendererText()
        self.cellpb = gtk.CellRendererPixbuf()

        self.cell.set_property("cell background", "#71ACE2")
        self.cell.set_property('size',
                               14000)  #solo le da el tamaño a las celdas xd
        self.cell.set_property('weight',
                               700)  #seria el "grosor" de la fuente :P
        self.cellpb.set_property("cell background", "#71ACE2")

        self.columnpb.pack_start(self.cellpb, True)
        self.column1.pack_start(self.cell, True)
        self.column2.pack_start(self.cell, True)
        self.column3.pack_start(self.cell, True)
        self.column4.pack_start(self.cell, True)
        self.column5.pack_start(self.cell, True)
        self.column6.pack_start(self.cell, True)
        self.column7.pack_start(self.cell, True)

        self.treeview.set_search_column(1)
        self.treeview.set_search_column(2)
        self.treeview.set_search_column(3)
        self.treeview.set_search_column(4)
        self.treeview.set_search_column(5)
        self.treeview.set_search_column(6)
        self.treeview.set_search_column(7)

        self.column1.set_sort_column_id(2)
        self.column2.set_sort_column_id(3)
        self.column3.set_sort_column_id(4)
        self.column4.set_sort_column_id(5)
        self.column5.set_sort_column_id(6)
        self.column6.set_sort_column_id(7)
        self.column7.set_sort_column_id(8)

        self.columnpb.set_expand(True)
        self.column1.set_expand(True)
        self.column2.set_expand(True)
        self.column3.set_expand(True)
        self.column4.set_expand(True)
        self.column5.set_expand(True)
        self.column6.set_expand(True)
        self.column7.set_expand(True)

        self.column1.set_resizable(True)
        self.column2.set_resizable(True)
        self.column3.set_resizable(True)
        self.column4.set_resizable(True)
        self.column5.set_resizable(True)
        self.column6.set_resizable(True)
        self.column7.set_resizable(True)

        self.lista_columnas = []
        self.lista_columnas.append(self.columnpb)
        self.lista_columnas.append(self.column1)
        self.lista_columnas.append(self.column2)
        self.lista_columnas.append(self.column3)
        self.lista_columnas.append(self.column4)
        self.lista_columnas.append(self.column5)
        self.lista_columnas.append(self.column6)
        self.lista_columnas.append(self.column7)

        self.lista_columnas.append(self.cell)
        self.lista_columnas.append(self.cellpb)

        self.setear_filas()

        self.window.show_all()
示例#30
0
    def __init__(self, exaile, doubanfm_plugin):
        self.exaile = exaile
        self.dbfm_plugin = doubanfm_plugin

        self.builder = gtk.Builder()
        self.builder.add_from_file(get_resource_path('doubanfm_mode.ui'))

        self.builder.connect_signals({
            'on_bookmark_button_clicked':
            self.on_bookmark_button_clicked,
            'on_skip_button_clicked':
            self.on_skip_button_clicked,
            'on_delete_button_clicked':
            self.on_delete_button_clicked,
            'on_go_home_button_clicked':
            self.on_go_home_button_clicked,
            'on_item_setting_clicked':
            self.on_button_setting_clicked,
            'on_item_album_clicked':
            self.on_button_album_clicked,
            'on_item_report_clicked':
            self.on_button_report_clicked,
            'on_menu_toggle':
            self.on_menu_toggle,
            'on_quit':
            self.on_quit,
            'on_pausebutton_clicked':
            self.on_pausebutton_clicked,
            'on_recommend_song':
            self.on_recommend_song,
            'on_share_sina':
            self.on_share_sina,
            'on_share_renren':
            self.on_share_renren,
            'on_share_kaixin001':
            self.on_share_kaixin001,
            'on_share_twitter':
            self.on_share_twitter,
            'on_share_fanfou':
            self.on_share_fanfou,
            'on_copy_permalink':
            self.on_copy_permalink,
        })

        self.window = self.builder.get_object('doubanfm_mode_window')
        self.window.connect('destroy', self.hide)

        volume = settings.get_option('player/volume', 1)

        self.volume_control = playback.VolumeControl(player.PLAYER)
        self.builder.get_object('hbox2').pack_start(self.volume_control)

        self.cover_box = self.builder.get_object('cover_eventbox1')
        self.info_area = info.TrackInfoPane(player.PLAYER)
        self.cover = cover.CoverWidget(self.cover_box, player.PLAYER)
        #        self.cover_box.add(self.cover)

        self.track_title_label = self.builder.get_object('track_title_label')
        attr = pango.AttrList()
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 800))
        attr.change(pango.AttrSize(12500, 0, 600))
        self.track_title_label.set_attributes(attr)
        self.track_info_label = self.builder.get_object('track_info_label')

        self.bookmark_button = self.builder.get_object('bookmark_button')
        self.trash_button = self.builder.get_object('delete_button')
        self.skip_button = self.builder.get_object('skip_button')
        self.pause_button = self.builder.get_object('pause_button')

        self.popup_menu = self.builder.get_object('moremenu')

        self.report_menuitem = self.builder.get_object('menuitem1')
        self.album_menuitem = self.builder.get_object('menuitem2')
        self.recmd_menuitem = self.builder.get_object('menuitem10')

        self.sensitive_widgets = [
            self.bookmark_button,
            self.trash_button,
            self.skip_button,
            self.pause_button,
            self.report_menuitem,
            self.album_menuitem,
            self.recmd_menuitem,
        ]

        self.progress_bar = playback.PlaybackProgressBar(player.PLAYER)
        self.builder.get_object('vbox2').pack_start(self.progress_bar)

        self.visible = False
        self.active = False

        self._build_channel_menu()

        event.add_callback(self.on_playback_start, 'playback_track_start',
                           player.PLAYER)
        event.add_callback(self.on_playback_stop, 'playback_track_end',
                           player.PLAYER)
        event.add_callback(self.on_pausebutton_toggled,
                           'playback_toggle_pause', player.PLAYER)
        event.add_callback(self.on_tag_update, 'track_tags_changed')
        self._toggle_id = self.exaile.gui.main.connect('main-visible-toggle',
                                                       self.toggle_visible)

        ## added for 0.3.2
        self._init_alpha()