示例#1
0
 def update_dpixbufs(self, name, emit_draw=False):    
     self.normal_dpixbuf = app_theme.get_pixbuf("playmode/%s_normal.png" % name)
     self.hover_dpixbuf = app_theme.get_pixbuf("playmode/%s_hover.png" % name)
     self.press_dpixbuf = app_theme.get_pixbuf("playmode/%s_press.png" % name)
     
     if emit_draw:
         self.queue_draw()
    def __select_name(self):
        self.menu_dict = OrderedDict()
        for name in MANDATORY.keys():
            self.menu_dict[name] = [None, name, self.__change, name]

        values = []
        for i in range(0, 10):
            try:
                value = int(float(config.get("equalizer", "equalizer-band%s" % str(i))))
            except:
                value = 0
            values.append(str(value))
        values = ":".join(values)

        self.has_tick = False
        for name, value in MANDATORY.iteritems():
            value = value.split(":")
            value = ":".join([str(int(float(v))) for v in value])

            if value == values:
                self.menu_dict[name][0] = (
                    app_theme.get_pixbuf("menu/tick.png"),
                    app_theme.get_pixbuf("menu/tick_press.png"),
                )
                self.has_tick = True
        if not self.has_tick:
            self.menu_dict[MANDATORY_CUSTOM][0] = (
                app_theme.get_pixbuf("menu/tick.png"),
                app_theme.get_pixbuf("menu/tick_press.png"),
            )
示例#3
0
    def __init__(self, drag_data_received_cb, callback):
        gtk.EventBox.__init__(self)
        self.set_visible_window(False)
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                        gtk.gdk.BUTTON_RELEASE_MASK |
                        gtk.gdk.POINTER_MOTION_MASK |
                        gtk.gdk.ENTER_NOTIFY_MASK |
                        gtk.gdk.LEAVE_NOTIFY_MASK
                        )

        
        self.connect("expose-event", self.on_expose_event)
        self.empty_dpixbuf = app_theme.get_pixbuf("empty/local.png")
        targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2), ("text/plain", 0, 3)]        
        self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP,
                           targets, gtk.gdk.ACTION_COPY)
        self.connect("drag-data-received", drag_data_received_cb)
        self.connect("motion-notify-event", self.on_motion_notify)
        self.connect("button-press-event", self.on_button_press)
        
        self.add_normal_dpixbuf = app_theme.get_pixbuf("empty/add_normal.png")
        self.add_hover_dpixbuf = app_theme.get_pixbuf("empty/add_hover.png")
        
        self.normal_text_dcolor = app_theme.get_color("labelText")
        self.hover_text_dcolor = app_theme.get_color("globalItemHighlight")
        self.text_padding_y = 5
        self.text_padding_x = 5
        self.prompt_offset = 15
        self.text_rect = None
        self.is_hover = False
        self.press_callback = callback
        self.prompt_text = _("Add Music")
 def update_state_dpixbufs(self, name, queue_draw=False):    
     self.normal_dpixbuf = app_theme.get_pixbuf("%s/%s_normal.png" % (self.volume_prefix, name))
     self.hover_dpixbuf = app_theme.get_pixbuf("%s/%s_hover.png" % (self.volume_prefix, name))
     self.press_dpixbuf = app_theme.get_pixbuf("%s/%s_press.png" % (self.volume_prefix, name))
     
     if queue_draw:
         self.queue_draw()
示例#5
0
    def __init__ (self):            
        self.app = Application()
        # Set app size.
        self.app.set_default_size(APP_WIDTH, APP_HEIGHT)
        self.app.set_icon(app_theme.get_pixbuf("logo.ico"))
        self.app.set_skin_preview(app_theme.get_pixbuf("frame.png"))        
        # Add app titlebar.
        self.app.add_titlebar(["theme", "max", "min", "close"],
                              app_theme.get_pixbuf("logo.png"),
                              "Assembly-IDE v 1.0", " ", add_separator = True)

        self.vbox_ali = gtk.Alignment()
        self.vbox_ali.set(1, 1, 1, 1)
        self.vbox_ali.set_padding(6, 2, 2, 2)
        self.vbox = gtk.VBox()
        self.vbox_ali.add(self.vbox)
        
        self.init_root_menu()
        
        self.init_top_toolbar()
        
        self.code_edit = CodeEdit()
        self.code_edit_file = self.code_edit.file_path
        
        self.complie_show_list = ComplieShowList()
        self.code_edit.connect("codeedit-changed-file-name", self.modify_code_edit_file_name)
        
        self.vbox.pack_start(self.top_toolbar_ali, False, False)
        self.vbox.pack_start(self.code_edit, True,True)
        self.vbox.pack_start(self.complie_show_list, False, False)
        self.app.main_box.pack_start(self.vbox_ali, True, True)
        self.app.window.show_all()
示例#6
0
    def __init__(
        self,
        fg_dpixbuf=app_theme.get_pixbuf("scalebar/fg.png"),
        bg_dpixbuf=app_theme.get_pixbuf("scalebar/bg.png"),
        point_normal_dpixbuf=app_theme.get_pixbuf("scalebar/point_normal.png"),
        point_hover_dpixbuf=app_theme.get_pixbuf("scalebar/point_hover.png"),
        point_press_dpixbuf=app_theme.get_pixbuf("scalebar/point_press.png"),
    ):

        super(HScalebar, self).__init__()
        self.set_draw_value(False)
        self.set_range(0, 100)
        self.fg_dpixbuf = fg_dpixbuf
        self.bg_dpixbuf = bg_dpixbuf
        self.point_normal_dpixbuf = point_normal_dpixbuf
        self.point_hover_dpixbuf = point_hover_dpixbuf
        self.point_press_dpixbuf = point_press_dpixbuf
        self.bottom_side = 0
        self.fg_cache_pixbuf = CachePixbuf()
        self.bg_cache_pixbuf = CachePixbuf()
        self.side_cache_pixbuf = CachePixbuf()

        # Colors
        self.fg_left_dcolor = app_theme.get_color("progressBarLeft")
        self.fg_right_dcolor = app_theme.get_color("progressBarRight")

        self.set_size_request(-1, self.bg_dpixbuf.get_pixbuf().get_height())

        self.connect("expose-event", self.expose_h_scalebar)
        self.connect("button-press-event", self.press_volume_progressbar)
 def create_pixbuf(self):
     try:
         if self.pixbuf:
             del self.pixbuf
     except: pass        
         
     if not self.key_name:
         if self.tag == "genre":
             self.pixbuf = CoverManager.get_pixbuf_from_genre(self.name_label)
         else:    
             self.pixbuf = CoverManager.get_pixbuf_from_name(self.name_label, self.cell_width, self.cell_width,
                                                             return_default=False)            
         
     elif self.key_name == "deepin-all-songs":    
         # self.pixbuf = CoverManager.get_all_song_cover(self.cell_width, self.cell_width)
         pixbuf = CoverManager.get_combo_all_cover(self.tag)
         if pixbuf:
             self.pixbuf = pixbuf
         else:    
             self.pixbuf = app_theme.get_pixbuf("cover/all_song.png").get_pixbuf()
         # self.draw_side_flag = False
     else:    
         if self.tag == "genre":
             self.pixbuf = CoverManager.get_pixbuf_from_genre(self.name_label)
         elif self.tag == "album":    
             self.pixbuf = CoverManager.get_pixbuf_from_name("%s-%s" % (self.value_name, self.key_name), 
                                                             self.cell_width, self.cell_width,
                                                             return_default=False)            
         elif self.tag == "folder":
                self.pixbuf = app_theme.get_pixbuf("local/music.png").get_pixbuf()
         else:    
             self.pixbuf = CoverManager.get_pixbuf_from_name(self.key_name, self.cell_width, self.cell_width,
                                                             return_default=False)
示例#8
0
    def __init__(self):
        super(CoverButton, self).__init__()
        
        self.cover_side_pixbuf = app_theme.get_pixbuf("cover/side.png").get_pixbuf()
        self.set_size_request(self.cover_side_pixbuf.get_width(), self.cover_side_pixbuf.get_height())
        self.webcast_dpixbuf = app_theme.get_pixbuf("cover/webcast.png")
        self.local_dpixbuf = app_theme.get_pixbuf("cover/default_cover.png")

        self.connect("expose-event", self.expose_button_cb)
        Dispatcher.connect("album-changed", self.on_album_changed)
        
        self.current_song = None
        self.next_cover_to_download = None
        
        self.condition = threading.Condition()
        self.thread = threading.Thread(target=self.func_thread)
        self.thread.setDaemon(True)
        self.thread.start()
        
        # animation params.
        self.active_alpha = 1.0
        self.target_alpha = 0.0
        self.in_animation = False
        self.animation_time = 1500
        self.active_pixbuf = self.get_default_pixbuf()
        self.target_pixbuf = None
        self.is_default = True
 def __create_button(self, name, tip_msg=None):   
     button = ImageButton(
         app_theme.get_pixbuf("lyric/%s_normal.png" % name),
         app_theme.get_pixbuf("lyric/%s_hover.png" % name),
         app_theme.get_pixbuf("lyric/%s_press.png" % name)
         )
     button.connect("clicked", self.player_control, name)
     return button
 def __create_simple_button(self, name, callback):    
     button = ImageButton(
         app_theme.get_pixbuf("jobs/%s_normal.png" % name),
         app_theme.get_pixbuf("jobs/%s_hover.png" % name),
         app_theme.get_pixbuf("jobs/%s_hover.png" % name),
         )
     if callback:
         button.connect("clicked", callback) 
     return button    
示例#11
0
 def update_volume_button_pixbuf(self, name):
     group = (
         app_theme.get_pixbuf("volume/%s_normal.png" % name),
         app_theme.get_pixbuf("volume/%s_hover.png" % name),
         app_theme.get_pixbuf("volume/%s_press.png" % name),
         app_theme.get_pixbuf("volume/%s_press.png" % name)
         )
     self.volume_button.set_inactive_pixbuf_group(group)
     self.queue_draw()
示例#12
0
 def update_widget_icon(self, name, tip_msg):    
     self.left_button.update_icon_group((
             app_theme.get_pixbuf("combo/%s_normal.png" % name),
             app_theme.get_pixbuf("combo/%s_normal.png" % name),
             app_theme.get_pixbuf("combo/%s_press.png" % name)
             ))
     self.set_index(1)
     self.current_status = name
     self.msg_content = tip_msg
     self.emit_combo_signal()
 def __init__(self, callback=None):    
     bg_group = (app_theme.get_pixbuf("jobs/complex_normal.png"),
                 app_theme.get_pixbuf("jobs/complex_hover.png"),
                 app_theme.get_pixbuf("jobs/complex_press.png"))
     
     icon = app_theme.get_pixbuf("filter/artist_normal.png")
     super(LoginButton, self).__init__(bg_group, icon, "登录百度帐号", left_padding=10)
     
     if callback:
         self.connect("clicked", callback)
 def __create_begin_button(self, callback):    
     toggle_button = ToggleButton(
         app_theme.get_pixbuf("jobs/pause_normal.png"),            
         app_theme.get_pixbuf("jobs/begin_normal.png"),
         app_theme.get_pixbuf("jobs/pause_hover.png"),
         app_theme.get_pixbuf("jobs/begin_hover.png")            
         )
     if callback:
         toggle_button.connect("toggled", callback)
     return toggle_button    
示例#15
0
 def __create_button(self, name, tip_msg=None):    
     button = ImageButton(
         app_theme.get_pixbuf("action/%s_normal.png" % name),
         app_theme.get_pixbuf("action/%s_hover.png" % name),
         app_theme.get_pixbuf("action/%s_press.png" % name),
         )
     button.connect("clicked", self.player_control, name)
     if tip_msg:
         Tooltip.text(button, tip_msg)
     return button
示例#16
0
    def __init__(self):
        super(ScrollLyrics, self).__init__(
            _("Lyrics window"),
            300,
            200,
            DIALOG_MASK_GLASS_PAGE,
            self.hide_all,
            False,
            gtk.gdk.WINDOW_TYPE_HINT_NORMAL,
            gtk.WIN_POS_CENTER,
            False,
            True,
        )

        self.revert_button = ImageButton(
            app_theme.get_pixbuf("scroll_lyrics/revert_normal.png"),
            app_theme.get_pixbuf("scroll_lyrics/revert_hover.png"),
            app_theme.get_pixbuf("scroll_lyrics/revert_press.png"),
        )
        self.titlebar.button_box.pack_start(self.revert_button, False, False)
        self.titlebar.button_box.reorder_child(self.revert_button, 0)

        self.percentage = 0.0
        self.whole_lyrics = []
        self.message_text = "%s for %s" % (_("DMusic"), "Linux Deepin")
        self.current_lyric_id = -1
        self.line_count = 20
        self.active_color = self.get_render_color(True)
        self.inactive_color = self.get_render_color()
        self.bg_color = (1, 1, 1)
        self.font_name = "文泉驿微米黑 10"
        self.line_margin = 1
        self.padding_x = 20
        self.padding_y = 10
        self.bg_opacity = 0.9
        self.frame_width = 7
        self.text = ""
        self.can_seek = True
        self.seeking = False
        self.current_pointer_y = 0
        self.saved_lyric_id = -1
        self.saved_seek_offset = 0
        self.saved_pointer_y = 0

        self.drawing = gtk.EventBox()
        self.drawing.set_visible_window(False)
        self.drawing.set_app_paintable(True)
        self.drawing.connect_after("expose-event", self.expose_cb)
        self.drawing.connect("button-press-event", self.button_press_cb)
        self.drawing.connect("button-release-event", self.button_release_cb)
        self.drawing.connect("motion-notify-event", self.motion_notify_cb)
        self.titlebar.close_button.connect("clicked", lambda w: self.hide_and_emit())
        self.body_box.add(self.drawing)
        self.update_line_height()
        config.connect("config-changed", self.changed_scroll_status)
    def __init__(self, num_string="29"):
        gtk.VBox.__init__(self)
        scale_image = ImageBox(app_theme.get_pixbuf("equalizer/scale.png"))
        self.scalebar = VScalebar(
            app_theme.get_pixbuf("vscalebar/upper_fg.png"),
            app_theme.get_pixbuf("vscalebar/upper_bg.png"),
            app_theme.get_pixbuf("vscalebar/middle_fg.png"),
            app_theme.get_pixbuf("vscalebar/middle_bg.png"),
            app_theme.get_pixbuf("vscalebar/bottom_fg.png"),
            app_theme.get_pixbuf("vscalebar/bottom_bg.png"),
            app_theme.get_pixbuf("vscalebar/point.png"),
        )
        self.scalebar.set_value(50)
        self.scalebar.set_has_point(False)
        preamp_align = gtk.Alignment()
        preamp_align.set_padding(8, 8, 0, 0)
        preamp_align.add(scale_image)

        hear_box = gtk.HBox()
        hear_box.pack_start(self.scalebar, False, False)
        hear_box.pack_start(preamp_align, False, False)

        num_box = gtk.HBox(spacing=1)
        for i in num_string:
            num_box.pack_start(ImageBox(app_theme.get_pixbuf("equalizer/%s.png" % i)))
        num_align = gtk.Alignment()
        num_align.set(0, 0, 0.8, 0.2)
        num_align.add(num_box)
        self.pack_start(hear_box, False, False)
        self.pack_start(num_align, False, False)
 def reload_items(self, child_items):    
     if child_items:
         container_remove_all(self.child_box)
         for index, item in enumerate(child_items):
             simple_item = SimpleItem(
                 (app_theme.get_pixbuf("filter/point_normal.png"),
                  app_theme.get_pixbuf("filter/point_press.png"),
                  item[0], item[1]),
                 index + 1, 9, 25, 15, 10, 10, self.set_index, self.get_index, ALIGN_START)
             self.child_box.pack_start(simple_item)
         self.show_all()        
示例#19
0
 def create_job_button(self, icon_name, content, callback=None):    
     button = ComplexButton(
         [app_theme.get_pixbuf("jobs/complex_normal.png"),
          app_theme.get_pixbuf("jobs/complex_hover.png"),
          app_theme.get_pixbuf("jobs/complex_press.png")],
         app_theme.get_pixbuf("jobs/%s.png" % icon_name),
         content
         )
     if callback:
         button.connect("clicked", lambda w : callback())
     return button    
示例#20
0
    def __create_simple_button(self, name, callback, tip_msg=""):
        button = ImageButton(
            app_theme.get_pixbuf("toolbar/%s_normal.png" % name),
            app_theme.get_pixbuf("toolbar/%s_hover.png" % name),
            app_theme.get_pixbuf("toolbar/%s_press.png" % name),
            )
        button.connect("button-press-event", callback)
        if tip_msg:
            Tooltip.text(button, tip_msg)

        self.toolbar_box.pack_start(button, False, False)
        return button
示例#21
0
    def __create_simple_toggle_button(self, name, callback, tip_msg=""):
        toggle_button = ToggleButton(
            app_theme.get_pixbuf("toolbar/%s_normal.png" % name),
            app_theme.get_pixbuf("toolbar/%s_press.png" % name),
            )
        toggle_button.connect("toggled", callback)

        if tip_msg:
            Tooltip.text(toggle_button, tip_msg)

        self.toolbar_box.pack_start(toggle_button, False, False)
        return toggle_button
 def create_simple_button(self, name, callback, *args):        
     button = ImageButton(
         app_theme.get_pixbuf("filter/%s_normal.png" % name),
         app_theme.get_pixbuf("filter/%s_hover.png" % name),
         app_theme.get_pixbuf("filter/%s_press.png" % name)
         )
     if callback:
         button.connect("clicked", callback, *args)
     align = gtk.Alignment()    
     align.set(0.5, 0.5, 0, 0)
     align.add(button)
     return align 
示例#23
0
    def __init__(self, *args, **kwargs):


        entry_button = ImageButton(
            app_theme.get_pixbuf("toolbar/search_normal.png"),
            app_theme.get_pixbuf("toolbar/search_hover.png"),
            app_theme.get_pixbuf("toolbar/search_press.png")
            )
        super(SearchEntry, self).__init__(action_button=entry_button, *args, **kwargs)        
        
        self.action_button = entry_button
        self.set_size(250, 24)
 def create_cover_pixbuf(self):    
     cover_path = DoubanCover.get_cover(self.chl, try_web=False)
     if cover_path:
         try:
             self.pixbuf = gtk.gdk.pixbuf_new_from_file(cover_path)
             self.is_loaded_cover = True                
         except gobject.GError:    
             self.pixbuf = app_theme.get_pixbuf("radio/default_cover.png").get_pixbuf()
             self.is_loaded_cover = False
     else:    
         self.pixbuf = app_theme.get_pixbuf("radio/default_cover.png").get_pixbuf()
         self.is_loaded_cover = False
示例#25
0
    def __init__(self):
        gtk.Button.__init__(self)
        # Init signals.
        self.connect("expose-event", self.on_expose_event)
        
        self.bg_pixbuf = app_theme.get_pixbuf("search/bg.png").get_pixbuf()

        # Init DPixbufs.
        self.normal_dpixbuf = app_theme.get_pixbuf("search/search_normal.png")
        self.hover_dpixbuf = app_theme.get_pixbuf("search/search_hover.png")
        self.press_dpixbuf = app_theme.get_pixbuf("search/search_press.png")
        
        self.set_size_request(self.bg_pixbuf.get_width(), self.bg_pixbuf.get_height())
示例#26
0
 def get_edit_sub_menu(self, select_items, move=False):
     sub_menu_items = []
     if len(self.category_list.get_items()) > 1:
         other_category_items = self.get_categroy_other_items()
         sub_menu_items = [(None, category_item.get_title(),
                            self.edit_list_item, category_item, select_items ,move) for category_item in other_category_items]
     if sub_menu_items:
         sub_menu_items.extend([None, ((app_theme.get_pixbuf("toolbar/add_normal.png"), None, None),
                                       _("New List"), self.edit_new_list_item, select_items, move)])
     else:
         sub_menu_items.extend([((app_theme.get_pixbuf("toolbar/add_normal.png"), None, None),
                                 _("New List"), self.edit_new_list_item, select_items, move)])
     return Menu(sub_menu_items)
 def __create_zoom_button(self, name, msg=None):    
     button = ImageButton(
         app_theme.get_pixbuf("lyric/%s_normal.png" % name),
         app_theme.get_pixbuf("lyric/%s_hover.png" % name),
         app_theme.get_pixbuf("lyric/%s_press.png" % name)
         )
     button.connect("clicked", self.change_font_size, name)
     if msg:
         Tooltip.text(button, msg)
     align = gtk.Alignment()
     align.set(0.5, 0.5, 0, 0)
     align.add(button)
     return align
 def __init__(self, webcast):
     gobject.GObject.__init__(self)
     
     self.index = None
     self.webcast_normal_pixbuf = app_theme.get_pixbuf("webcast/webcast_large_normal.png").get_pixbuf()
     self.webcast_press_pixbuf = app_theme.get_pixbuf("webcast/webcast_large_press.png").get_pixbuf()
     self.collect_normal_pixbuf = app_theme.get_pixbuf("webcast/collect_normal.png").get_pixbuf()
     self.collect_press_pixbuf = app_theme.get_pixbuf("webcast/collect_press.png").get_pixbuf()
     self.collect_hover_pixbuf = app_theme.get_pixbuf("webcast/collect_hover.png").get_pixbuf()
     self.webcast = webcast
     self.title = webcast.get("title")
     self.is_collected = False
     
     self.__update_size()
示例#29
0
 def __init__(self, trans_data):
     gobject.GObject.__init__(self)
     self.__updater_id = None
     
     # Init data.
     self.angle = 0
     self.status_icon = app_theme.get_pixbuf("transcoder/wait.png").get_pixbuf()
     self.status_icon_press = app_theme.get_pixbuf("transcoder/wait_press.png").get_pixbuf()
     self.stop_icon = app_theme.get_pixbuf("transcoder/stop.png").get_pixbuf()
     self.progress_ratio = 0.0
     self.trans_data = trans_data
     self.init_transcoder(trans_data)   
     self.__update()        
     self.progress_buffer = ProgressBuffer()
 def __create_single_toggle_button(self, normal_name, callback, tip_msg=None):
     toggle_button = ToggleButton(
         app_theme.get_pixbuf("lyric/%s_normal.png" % normal_name),
         app_theme.get_pixbuf("lyric/%s_press.png" % normal_name),            
         app_theme.get_pixbuf("lyric/%s_hover.png" % normal_name),
         )
     toggle_button.connect("toggled", callback)
     toggle_align = gtk.Alignment()
     toggle_align.set(0.5, 0.5, 0, 0)
     toggle_align.add(toggle_button)
     
     if tip_msg:
         Tooltip.text(toggle_button, tip_msg)
     return toggle_align, toggle_button
示例#31
0
    def load_items(self, child_items):
        if child_items:
            container_remove_all(self.child_box)
            for index, item in enumerate(child_items):
                simple_item = SimpleItem(
                    (app_theme.get_pixbuf("filter/folder_normal.png"),
                     app_theme.get_pixbuf("filter/folder_press.png"), item[0],
                     item[1], item[2]), index + 1, 9, self.child_item_height,
                    25, 10, 15, self.set_index, self.get_index, ALIGN_START)
                self.child_box.pack_start(simple_item, False, False)

            if len(child_items) < self.page_items_num:
                block_num = self.page_items_num - len(child_items)
                for i in range(block_num):
                    self.child_box.pack_start(self.create_block_box(), False,
                                              True)
            self.control_box.set_no_show_all(False)
            self.control_box.show_all()
            self.show_all()
            self.queue_draw()
            self.get_toplevel().queue_draw()
示例#32
0
    def __init__(self, title, allocate_widget=None, column_index=0):
        TreeItem.__init__(self)
        self.column_index = column_index
        self.side_padding = 5
        self.item_height = 37
        self.title = title
        self.item_width = 36
        self.allocate_widget = allocate_widget
        self.child_items = []

        self.title_padding_x = 30
        self.arrow_padding_x = 10

        # Init dpixbufs.
        self.down_normal_dpixbuf = app_theme.get_pixbuf(
            "arrow/down_normal.png")
        self.down_press_dpixbuf = app_theme.get_pixbuf("arrow/down_press.png")
        self.right_normal_dpixbuf = app_theme.get_pixbuf(
            "arrow/right_normal.png")
        self.right_press_dpixbuf = app_theme.get_pixbuf(
            "arrow/right_press.png")
    def __create_simple_button(self,
                               name,
                               callback,
                               tip_msg=None,
                               has_event=False):
        button = ImageButton(
            app_theme.get_pixbuf("lyric/%s_normal.png" % name),
            app_theme.get_pixbuf("lyric/%s_hover.png" % name),
            app_theme.get_pixbuf("lyric/%s_press.png" % name))
        if has_event:
            button.connect("button-press-event", callback)
        else:
            button.connect("clicked", callback)

        if tip_msg:
            Tooltip.text(button, tip_msg)

        button_align = gtk.Alignment()
        button_align.set(0.5, 0.5, 0, 0)
        button_align.add(button)
        return button_align
示例#34
0
 def get_edit_sub_menu(self, select_items, move=False):
     sub_menu_items = []
     if len(self.category_list.get_items()) > 1:
         other_category_items = self.get_categroy_other_items()
         sub_menu_items = [
             (None, category_item.get_title(), self.edit_list_item,
              category_item, select_items, move)
             for category_item in other_category_items
         ]
     if sub_menu_items:
         sub_menu_items.extend([
             None,
             ((app_theme.get_pixbuf("toolbar/add_normal.png"), None, None),
              _("New List"), self.edit_new_list_item, select_items, move)
         ])
     else:
         sub_menu_items.extend([
             ((app_theme.get_pixbuf("toolbar/add_normal.png"), None, None),
              _("New List"), self.edit_new_list_item, select_items, move)
         ])
     return Menu(sub_menu_items)
示例#35
0
 def __init__(self, value=100, lower=0, upper=100, step=5, default_height=100):
     gtk.Button.__init__(self)
     
     # Init default data.
     self.__value = value
     self.__lower = lower
     self.__upper = upper
     self.__step  = step
     self.default_height = default_height
     self.current_y = 0
     
     # Init DPixbuf.
     self.bg_bottom_dpixbuf = app_theme.get_pixbuf("volume/bg_bottom.png")
     self.bg_middle_dpixbuf = app_theme.get_pixbuf("volume/bg_middle.png")
     self.bg_top_dpixbuf = app_theme.get_pixbuf("volume/bg_top.png")
     self.point_dpixbuf = app_theme.get_pixbuf("volume/point.png")
     
     # Init sizes.
     self.fg_width = self.bg_width = self.bg_middle_dpixbuf.get_pixbuf().get_width()
     self.bg_top_height = self.bg_top_dpixbuf.get_pixbuf().get_height()
     self.bg_bottom_height = self.bg_bottom_dpixbuf.get_pixbuf().get_height()
     self.point_width = self.point_dpixbuf.get_pixbuf().get_width()
     self.point_height = self.point_dpixbuf.get_pixbuf().get_height()
     self.bg_x_offset = (self.point_width - self.bg_width) / 2
     self.set_size_request(self.point_width, self.default_height)
     self.real_height = self.default_height - self.point_height        
     
     # Init CachePixbuf.
     self.__bg_cache_pixbuf = CachePixbuf()
     
     # Init events.
     self.add_events(gtk.gdk.ALL_EVENTS_MASK)
     self.connect("button-press-event", self.on_button_press)
     self.connect("motion-notify-event", self.on_motion_notify)
     self.connect("button-release-event", self.on_button_release)
     self.connect("expose-event", self.on_expose_event)
     self.connect("scroll-event", self.on_scroll_event)
     
     # Init flags
     self.__button_press_flag = False
示例#36
0
    def __create_single_toggle_button(self,
                                      normal_name,
                                      callback,
                                      tip_msg=None):
        if normal_name == "karaoke":
            toggle_button = ToggleButton(
                app_theme.get_pixbuf("lyric/%s_press.png" % normal_name),
                app_theme.get_pixbuf("lyric/%s_normal.png" % normal_name),
                app_theme.get_pixbuf("lyric/%s_hover.png" % normal_name),
            )
        else:
            toggle_button = ToggleButton(
                app_theme.get_pixbuf("lyric/%s_normal.png" % normal_name),
                app_theme.get_pixbuf("lyric/%s_press.png" % normal_name),
                app_theme.get_pixbuf("lyric/%s_hover.png" % normal_name),
            )

        toggle_button.connect("toggled", callback)
        toggle_align = gtk.Alignment()
        toggle_align.set(0.5, 0.5, 0, 0)
        toggle_align.add(toggle_button)

        if tip_msg:
            Tooltip.text(toggle_button, tip_msg)
        return toggle_align, toggle_button
示例#37
0
 def __init__(self):
     gtk.Window.__init__(self, gtk.WINDOW_POPUP)
     self.set_property("allow-shrink", True)
     self.set_skip_taskbar_hint(True)
     self.set_decorated(False)
     self.set_skip_pager_hint(True)
     self.set_app_paintable(True)
     self.set_colormap(gtk.gdk.Screen().get_rgba_colormap())
     self.render_lyrics = RenderContextNew()
     self.bg_pixbuf = app_theme.get_pixbuf("lyric/bg.png").get_pixbuf()
     self.line_padding = 0.0
     self.dock_drag_state = DRAG_NONE
     self.padding_x = self.padding_y = 10
     self.old_x = self.old_y = self.old_width = 0
     self.mouse_x = self.mouse_y = 0
     self.raw_x, self.raw_y = self.get_position()
     self.mouse_over = False
     self.mouse_over_lyrics = False
     self.fade_in_size = 20.0
     self.max_line_count = 2
     
     self.active_lyric_surfaces = [None, None]
     self.inactive_lyric_surfaces = [None, None]
     self.lyrics_text = [_("DMusic"), "for Linux Deepin"]
     self.lyric_rects = [gtk.gdk.Rectangle(0, 0, 0, 0), gtk.gdk.Rectangle(0, 0, 0, 0)]
     self.lyrics_xpos = [0, 0]
     self.line_alignment = LINE_ALIGNMENT[config.get("lyrics", "double_line_align")]
     self.line_percentage = [0.0, 0.0]
     self.current_line = 0
     self.time_source = 0
     
     for i in range(self.get_line_count()):
         self.update_lyric_surface(i)
      
     width = self.adjust_window_height()
     self.set_default_size(600, int( width))           
     # Add events.
     self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                                gtk.gdk.BUTTON_RELEASE_MASK |
                                gtk.gdk.POINTER_MOTION_MASK |
                                gtk.gdk.ENTER_NOTIFY_MASK |
                                gtk.gdk.LEAVE_NOTIFY_MASK)
     
     self.connect("button-press-event", self.button_press) # TRY
     self.connect("button-release-event", self.button_release) 
     self.connect("motion-notify-event", self.motion_notify)   
     self.connect("enter-notify-event", self.enter_notify)
     self.connect("leave-notify-event", self.leave_notify)
     self.connect("expose-event", self.expose_before)     
     self.connect("realize", self.on_realize_event)
     config.connect("config-changed", self.update_render_color)
     self.time_source = gobject.timeout_add(200, self.check_mouse_leave)        
示例#38
0
    def __init__(self, tags, draw_collect=False):
        gobject.GObject.__init__(self)

        self.webcast = Song()
        self.webcast.init_from_dict(tags)
        self.webcast.set_type("webcast")
        if draw_collect:
            self.is_collected = True
        else:
            self.is_collected = WebcastsDB.is_collected(tags["uri"])

        self.webcast["collect"] = self.is_collected
        self.index = None
        self.webcast_normal_pixbuf = app_theme.get_pixbuf(
            "webcast/webcast_normal.png").get_pixbuf()
        self.webcast_press_pixbuf = app_theme.get_pixbuf(
            "webcast/webcast_press.png").get_pixbuf()
        self.collect_normal_pixbuf = app_theme.get_pixbuf(
            "webcast/collect_normal.png").get_pixbuf()
        self.collect_press_pixbuf = app_theme.get_pixbuf(
            "webcast/collect_press.png").get_pixbuf()

        self.__update_size()
示例#39
0
    def get_playmode_menu(self, pos=[], align=False):
        mode_dict = OrderedDict()

        mode_dict["single_mode"] = _("Repeat (single)")
        mode_dict["order_mode"] = _("Order play")
        mode_dict["list_mode"] = _("Repeat (list)")
        mode_dict["random_mode"] = _("Randomize")

        mode_items = []
        for key, value in mode_dict.iteritems():
            if self.get_loop_mode() == key:
                tick = (app_theme.get_pixbuf("menu/tick.png"),
                        app_theme.get_pixbuf("menu/tick_press.png"),
                        app_theme.get_pixbuf("menu/tick_disable.png"))
                mode_items.append((tick, value, self.set_loop_mode, key))
            else:
                tick = None
                mode_items.append((None, value, self.set_loop_mode, key))

        if pos:
            Menu(mode_items, True).show((pos[0], pos[1]))
        else:
            return Menu(mode_items)
示例#40
0
 def __init__(self, drag_data_received_cb, item_type):
     gtk.EventBox.__init__(self)
     self.set_visible_window(False)
     self.connect("expose-event", self.on_expose_event)
     
     lang = utils.get_system_lang()
     if lang == "zh_CN":
         prefix = "cn"
     elif lang in ["zh_HK", "zh_TW"]:    
         prefix = "tw"
     else:    
         prefix = "en"
             
     if item_type == EMPTY_WEBCAST_ITEM:
         targets = [("text/deepin-webcasts", gtk.TARGET_SAME_APP, 1),]
         self.empty_dpixbuf = app_theme.get_pixbuf("empty/webcast_%s.png" % prefix)
     elif item_type == EMPTY_RADIO_ITEM:    
         targets = [("text/deepin-radios", gtk.TARGET_SAME_APP, 1),]
         self.empty_dpixbuf = app_theme.get_pixbuf("empty/radio_%s.png" % prefix)
         
     self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP,
                        targets, gtk.gdk.ACTION_COPY)
     self.connect("drag-data-received", drag_data_received_cb)
示例#41
0
    def __init__(self, title, callback=None):
        TreeItem.__init__(self)
        self.column_index = 0
        self.side_padding = 5
        self.item_height = 37
        self.title = utils.xmlescape(title)
        self.item_width = 121
        self.hover_bg = app_theme.get_pixbuf(
            "webcast/categroy_bg.png").get_pixbuf()
        self.press_callback = callback

        self.parent_widget = None
        self.item_index = -1
        self.has_icon = False
        self.webcast_key = ""
示例#42
0
    def popup_predefine_menu(self, widget, event):
        menu_dict = OrderedDict()
        menu_dict["vitality_yellow"] = _("Vitality yellow")
        menu_dict["fresh_green"] = _("Fresh green")
        menu_dict["playful_pink"] = _("Playful pink")
        menu_dict["cool_blue"] = _("Cool blue")

        menu_items = []
        save_predefine_color = config.get("lyrics", "predefine_color",
                                          "vitality_yellow")
        for key, value in menu_dict.iteritems():
            item_pixbuf = None
            if key == save_predefine_color:
                item_pixbuf = (app_theme.get_pixbuf("menu/tick.png"),
                               app_theme.get_pixbuf("menu/tick_press.png"),
                               app_theme.get_pixbuf("menu/tick_disable.png"))

            if item_pixbuf is None:
                menu_items.append((None, value, self.set_predefine_color, key))
            else:
                menu_items.append(
                    (item_pixbuf, value, self.set_predefine_color, key))
        predefine_menu = Menu(menu_items, True)
        predefine_menu.show((int(event.x_root), int(event.y_root)))
示例#43
0
 def create_revert_button(self):
     button = ToggleButton(
         app_theme.get_pixbuf("mode/simple_normal.png"),
         app_theme.get_pixbuf("mode/full_normal.png"),
         app_theme.get_pixbuf("mode/simple_hover.png"),
         app_theme.get_pixbuf("mode/full_hover.png"),
         app_theme.get_pixbuf("mode/simple_press.png"),
         app_theme.get_pixbuf("mode/full_press.png"),
     )
     return button
示例#44
0
    def __init__(self,
                 element,
                 index,
                 font_size,
                 item_height,
                 padding_left,
                 padding_middle,
                 padding_right,
                 set_index,
                 get_index,
                 x_align=ALIGN_MIDDLE):

        # Init.
        super(CategoryItem, self).__init__()
        self.font_size = font_size
        self.index = index
        self.set_index = set_index
        self.get_index = get_index
        self.padding_left = padding_left
        self.padding_right = padding_right
        self.args = None
        self.child_category = None
        self.child_status = False
        self.clicked_callback = None

        if len(element) == 2:
            self.content, self.node = element
        else:
            self.content, self.node = element[:2]
            self.args = element[2:]

        self.arrow_dpixbuf = app_theme.get_pixbuf("preference/arrow_right.png")
        self.arrow_width = self.arrow_dpixbuf.get_pixbuf().get_width()
        content_width, _height = get_content_size(self.content, font_size)
        self.icon_offset = content_width + padding_middle
        self.x_align = x_align

        if isinstance(self.node, CategoryBar):
            self.child_category = self.node
            self.change_child_status(True)
            self.connect("clicked", self.wrap_node_show_action)
        else:
            self.clicked_callback = self.node
            self.connect("clicked", self.wrap_item_clicked_action)

        self.set_size_request(150, item_height)
        self.connect("expose-event", self.expose_category_item)
示例#45
0
 def create_playpause_button(self):
     play_normal_pixbuf = app_theme.get_pixbuf("mini/play_normal.png")
     pause_normal_pixbuf = app_theme.get_pixbuf("mini/pause_normal.png")
     play_hover_pixbuf = app_theme.get_pixbuf("mini/play_hover.png")
     pause_hover_pixbuf = app_theme.get_pixbuf("mini/pause_hover.png")
     play_press_pixbuf = app_theme.get_pixbuf("mini/play_press.png")
     pause_press_pixbuf = app_theme.get_pixbuf("mini/pause_press.png")
     playpause_button = ToggleButton(play_normal_pixbuf, pause_normal_pixbuf,
                  play_hover_pixbuf, pause_hover_pixbuf,
                  play_press_pixbuf, pause_press_pixbuf)
     return playpause_button    
示例#46
0
 def __create_simple_toggle_button(self, name, callback): 
     toggle_button = ToggleButton(
         app_theme.get_pixbuf("lyrics_button/%s_inactive_normal.png" % name),
         app_theme.get_pixbuf("lyrics_button/%s_active_normal.png" % name),
         app_theme.get_pixbuf("lyrics_button/%s_inactive_hover.png" % name),
         app_theme.get_pixbuf("lyrics_button/%s_active_hover.png" % name),
         app_theme.get_pixbuf("lyrics_button/%s_inactive_press.png" % name),
         app_theme.get_pixbuf("lyrics_button/%s_active_press.png" % name),
         ) 
     if callback:
         toggle_button.connect("toggled", callback)
     return toggle_button
示例#47
0
 def create_lyrics_button(self):    
     toggle_button = ToggleButton(
         app_theme.get_pixbuf("mini/lyrics_inactive_normal.png"),
         app_theme.get_pixbuf("mini/lyrics_active_normal.png"),
         app_theme.get_pixbuf("mini/lyrics_inactive_hover.png"),
         app_theme.get_pixbuf("mini/lyrics_active_hover.png"),
         app_theme.get_pixbuf("mini/lyrics_inactive_press.png"),
         app_theme.get_pixbuf("mini/lyrics_active_press.png"),
         ) 
     
     toggle_button.connect("toggled", self.change_lyrics_status)
     return toggle_button
示例#48
0
 def draw_info(self, cr, allocation, alpha):
     rect = gtk.gdk.Rectangle(allocation.x, allocation.y, allocation.width, allocation.height)
     cr.push_group()
     
     # Draw logo.
     rect.x += self.logo_padding_left
     logo_pixbuf = app_theme.get_pixbuf("mini/logo.png").get_pixbuf()
     icon_y = rect.y + (rect.height - logo_pixbuf.get_height()) / 2
     draw_pixbuf(cr, logo_pixbuf, rect.x, icon_y)
     
     # Draw playinfo.
     left_width = logo_pixbuf.get_width() + self.logo_padding_right
     rect.x += left_width
     rect.width -= left_width * 2
     self.playinfo.draw_content(cr, rect)
     
     # set source to paint with alpha.
     cr.pop_group_to_source()
     cr.paint_with_alpha(alpha)
    def __init__(self, song, finish_callback=None):
        '''
        init docs
        '''
        TreeItem.__init__(self)

        # Init sizes.
        self.item_height = 50
        self.info_width = -1
        self.progressbar_width = 100
        self.progressbar_padding_x = 10
        self.progressbar_height = 12
        self.check_button_padding_x = 10
        self.info_padding_x = 5

        self.icon_pixbuf = None
        self.song = song
        self.button_status = BUTTON_NORMAL

        # Init status.
        self.status = self.STATUS_WAIT_DOWNLOAD
        self.status_text = "等待下载"

        # Init buffers.
        self.progress_buffer = ProgressBuffer()

        self.stop_pixbuf = app_theme.get_pixbuf(
            "download/stop.png").get_pixbuf()
        self.stop_pixbuf_padding_x = 5
        self.block_width = 50
        self.download_task = TaskObject(song.get("uri"),
                                        get_song_save_path(song),
                                        output_temp=True)
        self.download_task.connect("update", self.download_update)
        self.download_task.connect("finish", self.download_finish)
        self.download_task.connect("error", self.download_failed)
        self.download_task.connect("start", self.download_start)

        self.finish_callback = finish_callback

        self.start_download()
示例#50
0
    def __init__(self, channel_info):
        TreeItem.__init__(self)
        self.index = 0
        self.column_index = 0
        self.side_padding = 5
        self.normal_item_height = 55
        self.highlight_item_height = 80
        self.item_height = self.normal_item_height
        self.item_width = LIST_WIDTH
        self.is_highlight = False
        self.channel_info = channel_info
        self.icon_width = self.icon_height = 45
        cover_path = DoubanCover.get_cover(channel_info, try_web=False)
        if cover_path:
            self.normal_pixbuf = gtk.gdk.pixbuf_new_from_file(cover_path)
        else:
            self.normal_pixbuf = app_theme.get_pixbuf(
                "radio/default_cover.png").get_pixbuf()
        self.update_size()

        self.animation_cache_pixbuf = CachePixbuf()
        self.animation_timeout = 100  # s
        self.animation_id = None
        self.active_size = 45
示例#51
0
 def get_pixbuf_group(self, name):
     return (
         app_theme.get_pixbuf("tray/%s_normal.png" % name),
         app_theme.get_pixbuf("tray/%s_hover.png" % name),
         app_theme.get_pixbuf("tray/%s_disable.png" % name),
     )
示例#52
0
 def __init__(self, _tuple):
     
     # Init gobject.
     gobject.GObject.__init__(self)
     # MissionThread.__init__(self)
     
     # Get tuple values.
     self.key_name, self.value_name, nums, self.tag = _tuple
     
     # Set cell size.
     self.cell_width = 84                
     if self.tag == "folder": self.cell_width = 67
     
     # Set display label.
     if not self.key_name:
         self.name_label= _("Unknown")
     elif self.key_name == "deepin-all-songs":    
         self.name_label = _("All Tracks")
     else:    
         self.name_label = utils.xmlescape(self.key_name)
     
     # Just create pixbuf when need render it to save memory.
     self.pixbuf = None
     
     # Display track number 
     self.labels = "%d %s" % (nums, _("Track(s)"))
     
     self.pixbuf_offset_x = 4
     self.pixbuf_offset_y = 4
     self.padding_x = 6
     self.border_size = 4
     self.padding_y = 20
     self.hover_flag = False
     self.highlight_flag = False
     self.draw_side_flag = True        
     self.__draw_play_hover_flag = False
     self.__draw_play_press_flag = False
     
     self.cover_dpixbuf = app_theme.get_pixbuf("cover/default_cover.png")
     
     # normal side pixbuf
     if self.tag == "folder":
         self.__normal_side_pixbuf = app_theme.get_pixbuf("local/side_normal.png").get_pixbuf()
     else:    
         self.__normal_side_pixbuf =  app_theme.get_pixbuf("filter/side_normal.png").get_pixbuf()
         
     # normal play pixbuf
     self.__normal_play_pixbuf =  app_theme.get_pixbuf("filter/play_normal.png").get_pixbuf()
     
     self.play_rect = gtk.gdk.Rectangle(
         self.__normal_side_pixbuf.get_width() - self.__normal_play_pixbuf.get_width() - 2 - 6,
         self.__normal_side_pixbuf.get_height() - self.__normal_play_pixbuf.get_height() - 2 - 6,
         self.__normal_play_pixbuf.get_width(),
         self.__normal_play_pixbuf.get_height()
         )
     
     try:
         self.retrieve = TransforDB.convert(self.name_label.lower().replace(" ", "")) \
             + self.name_label.lower().replace(" ", "")
     except:    
         self.retrieve = ""
示例#53
0
 def render(self, cr, rect):
     # Create pixbuf resource if self.pixbuf is None.
     self.create_pixbuf()
         
     if not self.pixbuf:
         self.pixbuf = self.cover_dpixbuf.get_pixbuf()
         
     pixbuf_x =  rect.x + (rect.width - self.__normal_side_pixbuf.get_width()) / 2
         
     # Draw cover.
     if self.tag == "folder":    
         draw_pixbuf(cr, self.pixbuf, 
                     pixbuf_x,
                     rect.y)
     else:    
         pixbuf_rect = gtk.gdk.Rectangle(
             pixbuf_x + self.pixbuf_offset_x,
             rect.y + self.pixbuf_offset_y, 
             self.pixbuf.get_width(),
             self.pixbuf.get_height())
         
         draw_pixbuf(cr, self.pixbuf, 
                     pixbuf_x + self.pixbuf_offset_x,
                     rect.y + self.pixbuf_offset_y)
         
     
     if self.hover_flag or self.highlight_flag:
         if self.tag == "folder":
             hover_side_pixbuf = app_theme.get_pixbuf("local/side_hover.png").get_pixbuf()
         else:    
             hover_side_pixbuf = app_theme.get_pixbuf("filter/side_hover.png").get_pixbuf()
             
         draw_pixbuf(cr, hover_side_pixbuf, pixbuf_x, rect.y )            
     else:    
         if self.draw_side_flag:
             draw_pixbuf(cr, self.__normal_side_pixbuf, pixbuf_x, rect.y )            
             
     
     if self.hover_flag:
         # if self.tag != "folder" and self.draw_side_flag:
         #     cr.set_source_rgba(0, 0, 0, 0.3)
         #     cr.rectangle(*pixbuf_rect)
         #     cr.fill()
         
         if self.__draw_play_hover_flag:
             play_pixbuf = app_theme.get_pixbuf("filter/play_hover.png").get_pixbuf()
         elif self.__draw_play_press_flag:    
             play_pixbuf = app_theme.get_pixbuf("filter/play_press.png").get_pixbuf()
         else:    
             play_pixbuf = self.__normal_play_pixbuf
         draw_pixbuf(cr, play_pixbuf, pixbuf_x + self.play_rect.x, rect.y + self.play_rect.y)        
         
         
     # Draw text.    
     name_rect = gtk.gdk.Rectangle(rect.x + self.padding_x , 
                                   rect.y + self.__normal_side_pixbuf.get_height() + 5,
                                   self.cell_width, 11)
     num_rect = gtk.gdk.Rectangle(name_rect.x, name_rect.y + 16, name_rect.width, 9)
     
     render_text(cr, self.name_label, name_rect, 
                 app_theme.get_color("labelText").get_color(),
                 10)
     render_text(cr, self.labels, num_rect, 
                 app_theme.get_color("labelText").get_color(),
                 8)
示例#54
0
 def init_pixbufs(self, name):
     self.normal_dpixbuf = app_theme.get_pixbuf("radio/%s_normal.png" %
                                                name)
     self.press_dpixbuf = app_theme.get_pixbuf("radio/%s_press.png" % name)
     self.icon_width = self.normal_dpixbuf.get_pixbuf().get_width()
示例#55
0
 def __init__(self):
     ImageButton.__init__(self,
                          app_theme.get_pixbuf("entry/close_normal.png"),
                          app_theme.get_pixbuf("entry/close_hover.png"),
                          app_theme.get_pixbuf("entry/close_press.png")
                          )
示例#56
0
 def __init__(self):
     ImageButton.__init__(self,
                          app_theme.get_pixbuf("filter/back_normal.png"),
                          app_theme.get_pixbuf("filter/back_hover.png"),
                          app_theme.get_pixbuf("filter/back_press.png")
                          )
示例#57
0
 def create_pixbuf(self):
     if self.pixbuf is None:
         self.pixbuf = app_theme.get_pixbuf(
             "radio/default_cover.png").get_pixbuf()
示例#58
0
 def __init__(self):
     ImageButton.__init__(self,
                          app_theme.get_pixbuf("mode/quell_normal.png"),
                          app_theme.get_pixbuf("mode/quell_hover.png"),
                          app_theme.get_pixbuf("mode/quell_press.png"),
                          )
示例#59
0
    def __init__(self, db_query):

        # Init.
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)

        self.__db_query = db_query
        self.update_interval = 3000  # 3000 millisecond.
        self.reload_flag = False
        self.search_flag = False
        self.cache_search_list = []
        self.cache_search_view = []
        self.__selected_tag = {"album": [], "artist": [], "genre": []}
        Dispatcher.connect("reload-browser", self.on_dispatcher_reload_browser)
        gobject.timeout_add(self.update_interval, self.on_interval_loaded_view)

        # The saving song Classification presented to the user.
        self.artists_view, self.artists_sw = self.get_icon_view(14)
        self.albums_view, self.albums_sw = self.get_icon_view(14)
        self.genres_view, self.genres_sw = self.get_icon_view(14)
        self.folders_view, self.folders_sw = self.get_icon_view(20)
        self.folders_view.connect("motion-notify-item",
                                  self.on_folders_view_motion_notify)

        # Song list for temporarily storing
        # self.songs_view, self.songs_view_sw = self.get_song_view()
        self.songs_view = self.get_song_view()

        # Classification navigation bar.
        self.filterbar = OptionBar([
            (app_theme.get_pixbuf("filter/artist_normal.png"),
             app_theme.get_pixbuf("filter/artist_press.png"), _("Artist"),
             lambda: self.switch_filter_view("artist")),
            (app_theme.get_pixbuf("filter/album_normal.png"),
             app_theme.get_pixbuf("filter/album_press.png"), _("Album"),
             lambda: self.switch_filter_view("album")),
            (app_theme.get_pixbuf("filter/genre_normal.png"),
             app_theme.get_pixbuf("filter/genre_press.png"), _("Genre"),
             lambda: self.switch_filter_view("genre")),
            (app_theme.get_pixbuf("filter/local_normal.png"),
             app_theme.get_pixbuf("filter/local_press.png"), _("Folder"),
             lambda: self.switch_filter_view("folder"))
        ])

        # Manage the media library (import, refresh)
        self.importbar = SongImportBar()
        self.importbar.reload_items([
            (_("Quick Scan"),
             lambda: ImportFolderJob([os.path.expanduser("~")])),
            (_("Scan"), lambda: ImportFolderJob()),
            (_("Refresh"), lambda: ReloadDBJob())
        ])

        # Left box
        invailed_box = gtk.VBox()
        invailed_box.set_size_request(-1, 10)
        left_vbox = gtk.VBox(spacing=10)
        left_vbox.set_size_request(121, -1)
        # left_vbox.pack_start(invailed_box, False, True)
        left_vbox.pack_start(self.filterbar, False, False)
        left_vbox.pack_start(create_separator_box(), False, False)
        left_vbox.pack_start(self.importbar, False, False)

        # Used to switch songs category view, in the right side of the layout.
        self.switch_view_box = gtk.VBox()
        self.switch_view_box.add(self.artists_sw)
        # self.switch_view_box.add(TaskView())

        # Control back on a view.
        self.back_hbox = gtk.HBox()
        self.back_hbox.set_size_request(-1, 26)
        self.back_hbox.set_no_show_all(True)
        self.back_button = BackButton()
        self.back_button.connect("clicked", self.on_back_button_clicked)
        self.prompt_button = PromptButton()
        self.back_hbox.pack_start(self.back_button, False, False, 5)
        self.back_hbox.pack_start(self.prompt_button, False, False)

        # searchbar
        self.search_entry, search_align = self.get_search_entry()
        search_hbox = gtk.HBox()
        search_hbox.pack_start(self.back_hbox, False, False)
        search_hbox.pack_start(create_right_align(), True, True)
        # search_hbox.pack_start(search_align, False, False)
        search_hbox_align = gtk.Alignment()
        search_hbox_align.set_padding(5, 0, 0, 0)
        search_hbox_align.set(0, 0, 1, 1)
        search_hbox_align.add(search_hbox)

        # Layout on the right.
        content_box = gtk.VBox(spacing=5)
        content_box.pack_start(search_hbox_align, False, False)
        content_box.pack_start(self.switch_view_box, True, True)

        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"),
                            enable_drag=True)
        body_paned.add1(left_vbox)
        body_paned.add2(content_box)

        self.pack_start(body_paned, True, True)
示例#60
0
 def create_mask_pixbuf(self):
     if self.mask_pixbuf is None:
         self.mask_pixbuf = app_theme.get_pixbuf(
             "radio/covermask_play.png").get_pixbuf()