Example #1
0
    def __init_widgets(self):
        self.start_record_button = Button(_("Start"))
        self.start_record_button.set_size_request(CAMERA_BOX_SIZE, 25)
        self.start_record_button.connect("clicked",
                                         self.__start_record_clicked)

        self.no_device_warning = Label(
            _("Please plug in or enable your camera"),
            label_width=300,
            text_x_align=pango.ALIGN_CENTER)
        self.keep_few_minutes = Label(_("Please keep still for 5 seconds"),
                                      label_width=300,
                                      text_x_align=pango.ALIGN_CENTER)
        # self.success = Label(_("Your face has been successfully recorded"), label_width=300, text_x_align=pango.ALIGN_CENTER)
        self.fail = Label(_("Failed to record your face"),
                          label_width=300,
                          text_x_align=pango.ALIGN_CENTER)

        self.success = gtk.Alignment(0.5, 0.5, 0, 0)
        self.success.set_size_request(300, -1)
        self.success_img = gtk.Image()
        self.success_img.set_from_pixbuf(self.success_pixbuf)
        self.success_box = gtk.HBox()
        self.success_box.pack_start(self.success_img, False, False, 5)
        self.success_box.pack_start(
            Label(_("Your face has been successfully recorded")))
        self.success.add(self.success_box)
    def create_source_update_frequency_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)
        
        dir_title_label = Label(_("Update applications lists"))
        dir_title_label.set_size_request(200, 12)
        label_align = gtk.Alignment()
        label_align.set_padding(0, 0, 0, 0)
        label_align.add(dir_title_label)

        self.is_auto_update_button = CheckButton(label_text=_('Update automatically'))
        self.is_auto_update_button.connect('toggled', self.change_auto_update)
        
        self.update_label = Label(_("Time interval: "))
        self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1)
        self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
        self.hour_lablel = Label(_(" hour"))
        self.hour_lablel.set_size_request(50, 12)
        spin_hbox = gtk.HBox(spacing=3)
        spin_hbox.pack_start(self.update_label, False, False)
        spin_hbox.pack_start(self.update_spin, False, False)
        spin_hbox.pack_start(self.hour_lablel, False, False)

        main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xpadding=10, xoptions=gtk.FILL)
        main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)

        if is_auto_update():
            self.is_auto_update_button.set_active(True)
        else:
            self.is_auto_update_button.toggled()

        return main_table
Example #3
0
    def __init__(self, detail_page, pkg_name, alias_name, star):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)
        self.star = star
        self.pkg_name = pkg_name

        v_box = gtk.VBox()
        pkg_icon_image = gtk.image_new_from_pixbuf(
            gtk.gdk.pixbuf_new_from_file_at_size(get_icon_pixbuf_path(pkg_name), 32, 32))
        pkg_alias_label = Label(alias_name,
                                hover_color=app_theme.get_color("homepage_hover"))
        pkg_alias_label.set_clickable()
        pkg_alias_label.connect("button-press-event", lambda w, e: detail_page.update_pkg_info(pkg_name))

        self.pkg_star_box = gtk.HBox()

        self.pkg_star_view = StarView()
        self.pkg_star_view.star_buffer.star_level = int(star)
        self.pkg_star_view.connect("clicked", lambda w: self.grade_pkg())

        self.pkg_star_mark = StarMark(self.star, self.MARK_SIZE, self.MARK_PADDING_X, self.MARK_PADDING_Y)

        self.pack_start(pkg_icon_image, False, False)
        self.pack_start(v_box, True, True, 8)
        v_box.pack_start(pkg_alias_label, False, False, 2)
        v_box.pack_start(self.pkg_star_box, False, False, 2)
        self.pkg_star_box.pack_start(self.pkg_star_view, False, False)
        self.pkg_star_box.pack_start(self.pkg_star_mark, False, False)
Example #4
0
def resolve_accel_entry_conflict(origin_entry, conflict_entry, tmp_accel_buf):
    dialog = DialogBox(" ", 620, 150)
    dialog.window_frame.connect("expose-event", draw_widget_background)
    dialog.set_keep_above(True)
    dialog.set_modal(True)
    dialog.body_align.set_padding(15, 10, 10, 10)
    label1 = Label(
        _("The shortcut \"%s\" is already used for \"%s\"") %
        (tmp_accel_buf.get_accel_label(), conflict_entry.settings_description),
        enable_select=False,
        enable_double_click=False)
    label2 = Label(_(
        "If you reassign the shortcut to \"%s\", the \"%s\" shortcut will be disabled."
    ) % (origin_entry.settings_description,
         conflict_entry.settings_description),
                   enable_select=False,
                   enable_double_click=False)
    dialog.body_box.pack_start(label1)
    dialog.body_box.pack_start(label2)
    button_reassign = Button(_("Reassign"))
    button_cancel = Button(_("Cancel"))
    button_cancel.connect("clicked",
                          lambda b: origin_entry.reassign_cancel(dialog))
    button_reassign.connect(
        "clicked",
        lambda b: origin_entry.reassign(tmp_accel_buf, conflict_entry, dialog))
    dialog.right_button_box.set_buttons([button_cancel, button_reassign])
    dialog.show_all()
Example #5
0
    def create_source_update_frequency_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        dir_title_label = Label(_("Refresh package lists"))

        # auto update check button
        self.is_auto_update_button = CheckButton(label_text=_('Upgrade automatically'))
        self.is_auto_update_button.connect('released', self.change_auto_update)
        self.is_auto_update_button.set_active(utils.is_auto_update())

        self.update_label = Label(_("Time interval: "))
        self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1)
        self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
        self.hour_lablel = Label(_(" hour"))
        self.hour_lablel.set_size_request(50, 12)
        spin_hbox = gtk.HBox(spacing=3)
        spin_hbox.pack_start(self.update_label, False, False)
        spin_hbox.pack_start(self.update_spin, False, False)
        spin_hbox.pack_start(self.hour_lablel, False, False)

        main_table.attach(dir_title_label, 0, 2, 0, 1, yoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xoptions=gtk.FILL)
        main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
        return main_table
Example #6
0
class StatusBox(gtk.HBox):
    def __init__(self, width=800):
        gtk.HBox.__init__(self)

        self.width = width

        self.status_label = Label(text="",
                                  text_size=CONTENT_FONT_SIZE,
                                  text_x_align=ALIGN_MIDDLE,
                                  label_width=600,
                                  enable_select=False)

        self.set_size_request(self.width, -1)
        self.pack_start(self.status_label, False, False)

        self.connect("expose-event", self.__expose)

    def hide_status(self):
        self.status_label.set_text("")

    def set_status(self, text):
        self.status_label.set_text(text)
        gobject.timeout_add(3000, self.hide_status)

    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, rect.x, rect.y + 1, rect.x + self.width, rect.y + 1)
    def __init__(
        self,
        padding_left=0,
    ):
        CycleStrip.__init__(self, app_theme.get_pixbuf("strip/background.png"))

        self.label = Label()
        self.label_align = gtk.Alignment()
        self.label_align.set(0.0, 0.5, 0, 0)
        self.label_align.set_padding(0, 0, padding_left, 0)
        self.label_align.add(self.label)

        self.search_button = ImageButton(
            app_theme.get_pixbuf("entry/search_normal.png"),
            app_theme.get_pixbuf("entry/search_hover.png"),
            app_theme.get_pixbuf("entry/search_press.png"),
        )
        self.search_entry = InputEntry(action_button=self.search_button)
        self.search_entry.set_size(220, 24)
        entry_align = gtk.Alignment(0.5, 0.5, 0, 0)
        entry_align.set_padding(0, 0, 5, 5)
        entry_align.add(self.search_entry)

        self.pack_start(self.label_align, True, True)
        self.pack_start(entry_align, False, False)
Example #8
0
    def __init__(self, title_name):
        BaseBar.__init__(self, init_index=-1)
        self.set_spacing(3)
        self.child_box = gtk.VBox()
        self.child_item_height = 22
        self.current_page = 1
        self.page_items_num = 0
        self.items = []

        title_item = StaticLabel(
            app_theme.get_pixbuf("filter/local_normal.png"), title_name, 10,
            25, 15, 10, 25, ALIGN_START)
        self.pack_start(title_item, False, False)
        self.pack_start(self.child_box, True, True)
        self.child_box.connect("size-allocate", self.size_change_cb)

        self.control_box = gtk.HBox()
        self.control_box.set_spacing(15)
        previous_align = self.create_simple_button("previous",
                                                   self.update_current_page,
                                                   "previous")
        next_align = self.create_simple_button("next",
                                               self.update_current_page,
                                               "next")
        self.info_label = Label("0/0",
                                app_theme.get_color("labelText"),
                                text_x_align=ALIGN_MIDDLE)
        self.control_box.pack_start(previous_align, False, False)
        self.control_box.pack_start(self.info_label, False, False)
        self.control_box.pack_start(next_align, False, False)
        self.control_box.set_no_show_all(True)
        control_align = gtk.Alignment()
        control_align.set(1, 1, 0.5, 0.5)
        control_align.add(self.control_box)
        self.pack_start(control_align, False, False)
Example #9
0
    def create_source_update_frequency_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        dir_title_label = Label(_("Refresh package lists"))

        # auto update check button
        self.is_auto_update_button = CheckButton(label_text=_('Upgrade automatically'))
        self.is_auto_update_button.connect('released', self.change_auto_update)
        self.is_auto_update_button.set_active(utils.is_auto_update())

        self.update_label = Label(_("Time interval: "))
        self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1)
        self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
        self.hour_lablel = Label(_(" hour"))
        self.hour_lablel.set_size_request(50, 12)
        spin_hbox = gtk.HBox(spacing=3)
        spin_hbox.pack_start(self.update_label, False, False)
        spin_hbox.pack_start(self.update_spin, False, False)
        spin_hbox.pack_start(self.hour_lablel, False, False)

        main_table.attach(dir_title_label, 0, 2, 0, 1, yoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xoptions=gtk.FILL)
        main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
        return main_table
class StatusBar(gtk.HBox):
    '''docstring for StatusBar'''
    def __init__(self):
        super(StatusBar, self).__init__(False)
        self.__count = 0
        self.__timeout_id = None
        self.text_label = Label("", text_x_align=ALIGN_MIDDLE,
                                label_width=500,
                                enable_select=False,
                                enable_double_click=False)
        text_align = gtk.Alignment()
        text_align.set(0.0, 0.5, 0.0, 0.0)
        text_align.add(self.text_label)

        self.button_hbox = gtk.HBox(False)
        self.button_hbox.set_spacing(WIDGET_SPACING)
        button_align = gtk.Alignment()
        button_align.set(1.0, 0.5, 0.0, 0.0)
        button_align.set_padding(0, 0, 0, 10)
        button_align.add(self.button_hbox)

        self.pack_start(text_align)
        self.pack_start(button_align)

        self.set_size_request(WINDOW_WIDTH, STATUS_HEIGHT)
        self.connect("expose-event", self.draw_background)

    def draw_background(self, widget, event):
        cr = widget.window.cairo_create()
        x, y, w, h = widget.allocation
        cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
        cr.rectangle(x, y+1, w, h-1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, x, y + 1, x + w, y + 1)

    def set_text(self, text):
        self.__count += 1
        if self.__timeout_id:
            gtk.timeout_remove(self.__timeout_id)
        self.text_label.set_text(text)
        self.__timeout_id = gobject.timeout_add(3000, self.hide_text)

    def hide_text(self):
        self.__count -= 1
        self.__timeout_id = None
        self.text_label.set_text("")

    def set_buttons(self, buttons):
        self.clear_button()
        for bt in buttons:
            self.button_hbox.pack_start(bt, False, False)
        self.show_all()

    def get_buttons(self):
        return self.button_hbox.get_children()

    def clear_button(self):
        self.button_hbox.foreach(self.button_hbox.remove)
class StatusBox(gtk.HBox):
    def __init__(self, width=800):
        gtk.HBox.__init__(self)

        self.width = width

        self.status_label = Label(
            text="", text_size=CONTENT_FONT_SIZE, text_x_align=ALIGN_MIDDLE, label_width=600, enable_select=False
        )

        self.set_size_request(self.width, -1)
        self.pack_start(self.status_label, False, False)

        self.connect("expose-event", self.__expose)

    def hide_status(self):
        self.status_label.set_text("")

    def set_status(self, text):
        self.status_label.set_text(text)
        gobject.timeout_add(3000, self.hide_status)

    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, rect.x, rect.y + 1, rect.x + self.width, rect.y + 1)
class MessageBar(CycleStrip):
    '''
    class docs
    '''
	
    def __init__(self, padding_left=0,):
        '''
        init docs
        '''
        # Init.
        CycleStrip.__init__(self, app_theme.get_pixbuf("strip/background.png"))
        
        self.label = Label()
        self.label_align = gtk.Alignment()
        self.label_align.set(0.0, 0.5, 0, 0)
        self.label_align.set_padding(0, 0, padding_left, 0)
        self.label_align.add(self.label)

        self.search_button = ImageButton(
            app_theme.get_pixbuf("entry/search_normal.png"),
            app_theme.get_pixbuf("entry/search_hover.png"),
            app_theme.get_pixbuf("entry/search_press.png"),
            )
        self.search_entry = InputEntry(action_button=self.search_button)
        self.search_entry.set_size(220, 24)
        entry_align = gtk.Alignment(0.5, 0.5, 0, 0)
        entry_align.set_padding(0, 0, 5, 5)
        entry_align.add(self.search_entry)

        self.pack_start(self.label_align, True, True)
        self.pack_start(entry_align, False, False)
        
    def set_message(self, message):
        self.label.set_text(message)
Example #13
0
    def __init__(
            self,
            text,
            callback_action=None,
            enable_gaussian=False,
            text_color=ui_theme.get_color("link_text"),
    ):
        '''
        Initialize LinkButton class.

        @param text: Link content.
        @param link: Link address.
        @param enable_gaussian: To enable gaussian effect on link, default is True.
        @param text_color: Link color, just use when option enable_gaussian is False.
        '''
        Label.__init__(self,
                       text,
                       text_color,
                       enable_gaussian=enable_gaussian,
                       text_size=9,
                       gaussian_radious=1,
                       border_radious=0,
                       underline=True)
        self.callback_action = callback_action

        set_clickable_cursor(self)
        self.connect('button-press-event', self.button_press_action)
 def create_lyrics_dir_table(self):    
     main_table = gtk.Table(3, 2)
     main_table.set_row_spacings(CONTENT_ROW_SPACING)
     
     dir_title_label = Label(_("Lyrics directory"))
     dir_title_label.set_size_request(200, 12)
     label_align = gtk.Alignment()
     label_align.set_padding(0, 0, 0, 0)
     label_align.add(dir_title_label)
     
     self.dir_entry = InputEntry()
     self.dir_entry.set_text(os.path.expanduser(config.get("lyrics", "save_lrc_path", "~/.lyrics")))
     self.dir_entry.set_editable(False)        
     self.dir_entry.set_size(250, 25)
     
     modify_button = Button(_("Change"))
     modify_button.connect("clicked", self.change_lyrics_save_dir)
     hbox = gtk.HBox(spacing=5)
     hbox.pack_start(self.dir_entry, False, False)
     hbox.pack_start(modify_button, False, False)
     
     main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
     main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
     main_table.attach(hbox, 0, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
     return main_table
    def __init__(self, default_width=300, default_height=160, cancel_cb=None):
        DialogBox.__init__(self, "", default_width, default_height, self.DIALOG_MASK_SINGLE_PAGE)

        self.cancel_cb = cancel_cb

        self.message_align = gtk.Alignment()
        self.message_align.set(0, 0, 0, 0)
        self.message_align.set_padding(0, 0, 10, 0)
        self.message_label = Label("", label_width=300)
        self.message_align.add(self.message_label)
        self.progress_align = gtk.Alignment()
        self.progress_align.set(0, 0, 0, 0)
        self.progress_align.set_padding(20, 0, 10, 10)
        self.progress_bar = ProgressBar()
        self.progress_bar.set_size_request(default_width, -1)
        self.progress_align.add(self.progress_bar)
        self.percentage_align = gtk.Alignment()
        self.percentage_align.set(0, 0, 0, 0)
        self.percentage_align.set_padding(10, 0, 140, 0)
        self.percentage_label = Label("0%", label_width=300)
        self.percentage_label.set_size_request(default_width, -1)
        self.percentage_align.add(self.percentage_label)
        self.cancel_align = gtk.Alignment()
        self.cancel_align.set(0, 0, 0, 0)
        self.cancel_align.set_padding(20, 0, 200, 0)
        self.cancel_button = Button(_("Cancel"))
        self.cancel_button.set_size_request(70, WIDGET_HEIGHT)
        self.cancel_button.connect("clicked", self.__on_cancel_button_clicked)
        self.cancel_align.add(self.cancel_button)

        self.body_box.pack_start(self.message_align, False, False)
        self.body_box.pack_start(self.progress_align, False, False)
        self.body_box.pack_start(self.percentage_align, False, False)
        self.body_box.pack_start(self.cancel_align)
    def __init__(self,
                 title,
                 message,
                 default_width=400,
                 default_height=220,
                 confirm_callback=None,
                 cancel_callback=None,
                 confirm_button_text="Yes",
                 cancel_button_text="No"):
        DialogBox.__init__(self, "", default_width, default_height, DIALOG_MASK_SINGLE_PAGE)
        self.confirm_callback = confirm_callback
        self.cancel_callback = cancel_callback

        self.title_align = gtk.Alignment()
        self.title_align.set(0, 0, 0, 0)
        self.title_align.set_padding(0, 0, FRAME_LEFT_PADDING, 8)
        self.title_label = Label(title, wrap_width=300)

        self.label_align = gtk.Alignment()
        self.label_align.set(0.5, 0.5, 0, 0)
        self.label_align.set_padding(0, 0, 8, 8)
        self.label = Label(message, text_x_align=ALIGN_MIDDLE, text_size=55)

        self.confirm_button = Button(confirm_button_text)
        self.cancel_button = Button(cancel_button_text)

        self.confirm_button.connect("clicked", lambda w: self.click_confirm_button())
        self.cancel_button.connect("clicked", lambda w: self.click_cancel_button())

        self.body_box.pack_start(self.title_align, False, False)
        self.title_align.add(self.title_label)
        self.body_box.pack_start(self.label_align, True, True)
        self.label_align.add(self.label)

        self.right_button_box.set_buttons([self.cancel_button, self.confirm_button])
Example #17
0
    def __init__(self, draw_time_callback=None):
        super(SongTimer, self).__init__()

        self.label_time = Label("00:00", app_theme.get_color("labelText"), 8, enable_gaussian=True)
        self.draw_time_callback = draw_time_callback
        if draw_time_callback:
            draw_time_callback(self.label_time.get_text())
            
        self.bar = ProgressBar()
        bar_align = gtk.Alignment()
        bar_align.set_padding(0, 0, 2, 2)
        bar_align.set(1, 1, 1, 1)
        bar_align.add(self.bar)
        self.bar.connect("button-press-event", self.on_bar_press)
        self.bar.connect("button-release-event", self.on_bar_release)
        self.__value_changed_id = self.bar.connect("value-changed", self.on_bar_value_changed)

        self.pack_start(bar_align, True, True)
        self.update_bar = 1
        self.duration = 0
        self.__idle_release_id = None
        self.delete = False
        self.__need_report = False
        self.press_flag = False

        Player.connect("instant-new-song", self.set_duration)
        Player.connect("init-status", self.on_player_init_status)

        Player.bin.connect("queue-running", self.on_queue_running)
        Player.bin.connect("tick", self.on_tick)
        Player.connect("seeked", self.on_seek)
        Player.connect("stopped", self.set_duration)
        if not Player.song:
            self.bar.set_sensitive(False)
Example #18
0
class BottomTipBar(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)

        self.info_image_box = gtk.VBox()
        self.info_image_box.set_size_request(24, 24)
        self.info_image_box.connect('expose-event', self.expose_info_image_box)

        self.info_label = Label("")
        self.end_info_label = Label("")
        self.info_callback_button = ActionButton('')

        self.close_button = CloseButton()

        self.pack_start(self.info_image_box, False, False)
        self.pack_start(self.info_label)

        self.pack_end(self.close_button, False, False)
        self.pack_end(self.info_callback_button, False, False)
        self.pack_end(self.end_info_label, False, False)

        self.connect('expose-event', self.expose)

    def expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo('#cccccc'))
        cr.rectangle(rect.x, rect.y, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#ffffff'))
        cr.rectangle(rect.x, rect.y + 1, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#fff9c9'))
        cr.rectangle(rect.x, rect.y + 2, rect.width, rect.height - 2)
        cr.fill()

    def expose_info_image_box(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        msg_pixbuf = get_common_image_pixbuf("msg/msg1.png")
        pix_width = msg_pixbuf.get_width()
        pix_height = msg_pixbuf.get_height()
        draw_pixbuf(
            cr,
            msg_pixbuf,
            rect.x + (rect.width - pix_width) / 2,
            rect.y + (rect.height - pix_height) / 2,
        )

    def update_end_info(self, info):
        self.end_info_label.set_text(info)

    def update_info(self, info, callback_name='', callback_action=None):
        self.info_label.set_text(info)
        self.info_callback_button.set_text(callback_name)
        self.info_callback_button.callback_action = callback_action
 def create_combo_label(self, title, content=""):   
     hbox = gtk.HBox(spacing=5)
     title_label  = Label(title)
     content_label = Label(content)
     content_label.set_size_request(200, -1)
     hbox.pack_start(title_label, False, False)
     hbox.pack_start(content_label, False, False)
     return hbox, content_label
Example #20
0
 def create_combo_label(self, title, content=""):
     hbox = gtk.HBox(spacing=5)
     title_label = Label("%s:" % title)
     content_label = Label(content)
     content_label.set_size_request(200, -1)
     hbox.pack_start(title_label, False, False)
     hbox.pack_start(content_label, False, False)
     return hbox, content_label
class BottomTipBar(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        
        self.info_image_box = gtk.VBox()
        self.info_image_box.set_size_request(24, 24)
        self.info_image_box.connect('expose-event', self.expose_info_image_box)

        self.info_label = Label("")
        self.end_info_label = Label("")
        self.info_callback_button = ActionButton('')

        self.close_button = CloseButton()

        self.pack_start(self.info_image_box, False, False)
        self.pack_start(self.info_label)

        self.pack_end(self.close_button, False, False)
        self.pack_end(self.info_callback_button, False, False)
        self.pack_end(self.end_info_label, False, False)

        self.connect('expose-event', self.expose)

    def expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo('#cccccc'))
        cr.rectangle(rect.x, rect.y, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#ffffff'))
        cr.rectangle(rect.x, rect.y+1, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#fff9c9'))
        cr.rectangle(rect.x, rect.y+2, rect.width, rect.height-2)
        cr.fill()

    def expose_info_image_box(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        msg_pixbuf = get_common_image_pixbuf("msg/msg1.png")
        pix_width = msg_pixbuf.get_width()
        pix_height = msg_pixbuf.get_height()
        draw_pixbuf(cr,
                    msg_pixbuf,
                    rect.x + (rect.width-pix_width)/2,
                    rect.y + (rect.height-pix_height)/2,
                    )

    def update_end_info(self, info):
        self.end_info_label.set_text(info)

    def update_info(self, info, callback_name='', callback_action=None):
        self.info_label.set_text(info)
        self.info_callback_button.set_text(callback_name)
        self.info_callback_button.callback_action = callback_action
Example #22
0
    def __init__(self, monitor_dir):

        gtk.VBox.__init__(self)
        self.set_spacing(10)
        self.select_view = SelectView(monitor_dir,
                                      filter_dir=["deepin-wallpapers"],
                                      add_system=False)
        self.select_view.connect("items-change", self.select_view_item_changed)
        self.select_view.connect("double-click-item",
                                 self.select_view_double_clicked)
        self.select_view_sw = self.select_view.get_scrolled_window()

        label_box = gtk.VBox()
        no_favorites_label = Label(_("Your Favorites folder is empty."))
        align_up = get_align(align=(0.5, 0.5, 0, 0))
        align_up.add(no_favorites_label)
        go_to_local_action = ActionButton(
            _("Add from Local Pictures"),
            lambda: event_manager.emit("switch-to-local-pictures", self))
        align_down = get_align(align=(0.5, 0.5, 0, 0))
        align_down.add(go_to_local_action)

        label_box.pack_start(align_up, False, False)
        label_box.pack_start(align_down, False, False)
        self.no_favorites_align = gtk.Alignment(0.5, 0.5, 0, 0)
        self.no_favorites_align.add(label_box)

        self.notice_label = Label("")

        set_wallpapper_button = Button(_("Set as wallpaper"))
        set_wallpapper_button.connect("clicked", self.__on_set_as_wallpapper)

        delete_button = Button(_("Delete"))
        delete_button.connect("clicked", self.__on_delete)

        self.button_box = gtk.HBox(spacing=10)
        self.button_box.pack_start(set_wallpapper_button, False, False)
        self.button_box.pack_start(delete_button, False, False)

        self.control_box = gtk.HBox()
        self.control_box.set_size_request(-1, 20)
        self.control_box.pack_start(self.notice_label, False, False)

        self.control_align = gtk.Alignment()
        self.control_align.set(0.5, 0.5, 1, 1)
        self.control_align.set_padding(0, 5, 20, 10)
        self.control_align.add(self.control_box)

        if len(self.select_view.items) == 0:
            self.pack_start(self.no_favorites_align, True, True)
        else:
            self.pack_start(self.select_view_sw, True, True)
        self.pack_end(self.control_align, False, True)

        event_manager.add_callback("select-select-wallpaper",
                                   self.__on_select_select_wallpaper)

        self.timeout_notice_hide_id = None
 def __label(self, label_name):
     label = Label(label_name,
                   text_x_align=ALIGN_END,
                   text_size=CONTENT_FONT_SIZE,
                   enable_select=False,
                   enable_double_click=False,
                   fixed_width=STANDARD_LINE)
     label.set_can_focus(False)
     return label
 def __label(self, label_name):
     label = Label(label_name,
                   text_x_align = ALIGN_END,
                   text_size=CONTENT_FONT_SIZE,
                   enable_select=False,
                   enable_double_click=False,
                   fixed_width = STANDARD_LINE)
     label.set_can_focus(False)
     return label
Example #25
0
 def __init__(self):
     DialogBox.__init__(
         self, _("Lyrics search"), 460, 300, DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all, 
         modal=False, window_hint=None, skip_taskbar_hint=False, window_pos=gtk.WIN_POS_CENTER)
     
     self.artist_entry = InputEntry()
     self.artist_entry.set_size(130, 23)
     self.title_entry = InputEntry()
     self.title_entry.set_size(130, 23)
     artist_label = Label(_("Artist:"))
     title_label = Label(_("Title:"))
     right_align = gtk.Alignment()
     right_align.set(0, 0, 0, 1)
     
     self.search_button = Button(_("Search"))
     self.search_button.connect("clicked", self.search_lyric_cb)
     self.process_id = 0
     
     info_box = gtk.HBox(spacing=25)
     
     control_box = gtk.HBox(spacing=5)
     title_box = gtk.HBox(spacing=5)        
     title_box.pack_start(title_label, False, False)
     title_box.pack_start(self.title_entry)
     artist_box = gtk.HBox(spacing=5)
     artist_box.pack_start(artist_label, False, False)
     artist_box.pack_start(self.artist_entry)
     control_box.pack_start(title_box, False, False)
     control_box.pack_start(artist_box, False, False)
     
     info_box.pack_start(control_box, False, False)
     info_box.pack_start(self.search_button, False, False)
     
     sort_items = [ lambda items, reverse : self.sort_by_key(items, reverse, "title"),
                    lambda items, reverse : self.sort_by_key(items, reverse, "artist")]
     self.result_view = TreeView()
     self.result_view.set_expand_column(0)
     self.result_view.connect("double-click-item", self.double_click_cb)
     self.result_view.set_column_titles([_("Title"), _("Artist")], sort_items)
     self.result_view.draw_mask = self.draw_view_mask
     
     self.prompt_label = Label("")
     download_button = Button(_("Download"))
     download_button.connect("clicked", self.download_lyric_cb)
     cancel_button = Button(_("Close"))
     cancel_button.connect("clicked", lambda w: self.hide_all())
     
     info_box_align = gtk.Alignment()
     info_box_align.set_padding(5, 0, 5, 0)
     info_box_align.add(info_box)
     
     self.body_box.set_spacing(5)
     self.body_box.pack_start(info_box_align, False, False)
     self.body_box.pack_start(self.result_view, True, True)
     self.left_button_box.set_buttons([self.prompt_label])
     self.right_button_box.set_buttons([download_button, cancel_button])
     self.lrc_manager = LrcManager()
class SongSearchUI(DialogBox):
    
    def __init__(self):
        DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE,
                           modal=False, window_hint=None, close_callback=self.hide_all)
        title_label = Label(_("Title:"))
        self.title_entry = TextEntry("")
        self.title_entry.set_size(300, 25)
        self.search_button = Button(_("Search"))
        self.search_button.connect("clicked", self.search_song)
        
        control_box = gtk.HBox(spacing=5)
        control_box.pack_start(title_label, False, False)
        control_box.pack_start(self.title_entry, False, False)
        control_box.pack_start(self.search_button, False, False)
        
        scrolled_window = ScrolledWindow(0, 0)
        scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.result_view = ListView()
        self.result_view.connect("double-click-item", self.double_click_cb)
        self.result_view.draw_mask = self.get_mask_func(self.result_view)
        self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")])
        scrolled_window.add_child(self.result_view)
        
        self.prompt_label = Label("")
        download_button = Button(_("Download"))
        download_button.connect("clicked", self.download_song)
        cancel_button = Button(_("Close"))
        cancel_button.connect("clicked", lambda w: self.hide_all())
        
        self.body_box.set_spacing(5)
        self.body_box.pack_start(control_box, False, False)
        self.body_box.pack_start(scrolled_window, True, True)
        self.left_button_box.set_buttons([self.prompt_label])
        self.right_button_box.set_buttons([download_button, cancel_button])
        
    def search_song(self, widget):    
        self.result_view.clear()
        title = self.title_entry.entry.get_text()
        if not title.strip():
            return 
        self.prompt_label.set_text(_("Now searching"))        
        # widget.set_sensitive(False)
        utils.ThreadRun(multi_ways_query_song, self.render_song_infos, [title]).start()
        
    @post_gui    
    def render_song_infos(self, song_infos):
        if song_infos:
            try:
                items = [QueryInfoItem(song_info) for song_info in song_infos]
            except Exception, e:    
                print e
            else:    
                self.result_view.add_items(items)
        self.prompt_label.set_text(_("Finish!"))        
 def __init_ui(self):
     icon = ImageBox(self.icon)
     self.label = Label(self.text)
     self.offbutton = SwitchButton()
     self.pack_start(self.__wrap_with_align(icon), False, False)
     self.pack_start(self.__wrap_with_align(self.label, align="left"),
                     False,
                     False,
                     padding=10)
     self.pack_end(self.__wrap_with_align(self.offbutton), False, False)
     self.show_all()
class ShowTime(object):
    def __init__(self):
        self.time_font1 = ""
        self.time_font2 = ""
        self.time_box = Label("", enable_gaussian=True)

    def set_time_font(self, time_font2, time_font1):
        self.time_font1 = str(time_font1)  # 右边显示的时间.
        self.time_font2 = str(time_font2)  # 左边显示的时间.

        self.time_box.set_text(self.time_font2 + self.time_font1)
    def __init__(self, 
                 text, 
                 callback_action=None,
                 enable_gaussian=False, 
                 text_color=ui_theme.get_color("link_text"),
                 ):
        Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9,
                       gaussian_radious=1, border_radious=0, underline=False)
        self.callback_action = callback_action

        set_clickable_cursor(self)
        self.connect('button-press-event', self.button_press_action)
Example #30
0
class ShowTime(object):
    
    def __init__(self):     
        self.time_font1 = ""
        self.time_font2 = ""
        self.time_box = Label("", enable_gaussian=True)
        
    def set_time_font(self, time_font2, time_font1):    
        self.time_font1 = str(time_font1) # 右边显示的时间.
        self.time_font2 = str(time_font2) # 左边显示的时间.
        
        self.time_box.set_text(self.time_font2 + self.time_font1)
Example #31
0
    def __init__(self, padding_left=0):
        '''
        init docs
        '''
        # Init.
        CycleStrip.__init__(self, app_theme.get_pixbuf("strip/background.png"))

        self.label = Label()
        self.label_align = gtk.Alignment()
        self.label_align.set(0.0, 0.5, 0, 0)
        self.label_align.set_padding(0, 0, padding_left, 0)
        self.label_align.add(self.label)
        self.pack_start(self.label_align, True, True)
    def __set_row(self, name, arg, types="ip"):
        label = Label(name, text_size=CONTENT_FONT_SIZE,
                               enable_select=False,
                               enable_double_click=False)

        label.set_can_focus(False)
        entry = IPV4Entry()
        if types == "ip":
            entry.connect("changed", self.set_ip_address, arg)
        else:
            entry.connect("changed", self.set_dns_address, arg)

        return (label, entry)
    def init_ui(self):
        self.tip_align = gtk.Alignment(0, 0.5, 0, 1)
        self.tip = Label("")
        self.tip_align.set_padding(5, 5, 20, 0)
        self.tip_align.add(self.tip)

        self.button_box = gtk.HBox()
        self.buttons_align = gtk.Alignment(1, 0.5, 0, 0)
        self.buttons_align.set_padding(0, 0, 0, 10)
        self.buttons_align.add(self.button_box)

        self.pack(self, [self.tip_align], True, True)
        self.pack_end(self.buttons_align, False, False)
Example #34
0
    def __init__(self, timestamp):
        gtk.VBox.__init__(self)
        self.timestamp = timestamp
        self.label = Label()
        self.pack_start(self.label, False, False)

        try:
            timestamp = float(self.timestamp)
            self.label.set_text(self.to_huamn_str(timestamp))
        except:
            self.label.set_text(self.timestamp)

        gtk.timeout_add(1000, self.tick)
    def __init__(self):
        Section.__init__(self)
        self.dsl = Contain(app_theme.get_pixbuf("network/dsl.png"), _("DSL"),
                           lambda w: w)
        self.label = Label(_("Create a DSL connection"),
                           LABEL_COLOR,
                           underline=True,
                           enable_select=False,
                           enable_double_click=False)

        self.load(self.dsl, [self.label])

        self.active_connection = None
    def __init__(self):
        Section.__init__(self)
        MobileDevice.__init__(self)
        # init values
        self.mobile = Contain(app_theme.get_pixbuf("network/3g.png"),
                              _("Mobile Network"), lambda w: w)
        self.label = Label(_("Mobile Configuration"),
                           LABEL_COLOR,
                           underline=True,
                           enable_select=False,
                           enable_double_click=False)

        self.load(self.mobile, [])
Example #37
0
    def __init__(self):
        '''
        init docs
        '''
        gtk.VBox.__init__(self)

        self.status_box = StatusBox()

        self.scroll = ScrolledWindow()
        self.scroll.set_size_request(800, 432)
        self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)

        self.label_padding_x = 10
        self.label_padding_y = 10

        self.theme_box = gtk.VBox()
        self.user_theme_label = Label(
            _("My Themes"),
            text_size=TITLE_FONT_SIZE,
            text_color=app_theme.get_color("globalTitleForeground"))
        self.user_theme_view = UserThemeView(status_box=self.status_box)
        self.user_theme_scrolledwindow = self.user_theme_view.get_scrolled_window(
        )

        self.system_theme_label = Label(
            _("System Themes"),
            text_size=TITLE_FONT_SIZE,
            text_color=app_theme.get_color("globalTitleForeground"))
        self.system_theme_view = SystemThemeView(status_box=self.status_box)
        self.system_theme_scrolledwindow = self.system_theme_view.get_scrolled_window(
        )

        self.theme_box.pack_start(self.user_theme_label, False, False)
        self.theme_box.pack_start(get_separator(), False, False)
        self.theme_box.pack_start(self.user_theme_scrolledwindow, False, False)

        self.theme_box.pack_start(self.system_theme_label, False, False)
        self.theme_box.pack_start(get_separator(), False, False)
        self.theme_box.pack_start(self.system_theme_scrolledwindow, True, True)

        main_align = gtk.Alignment()
        main_align.set_padding(15, 0, 20, 20)
        main_align.set(1, 1, 1, 1)
        main_align.add(self.theme_box)

        self.scroll.add_child(main_align)

        main_align.connect("expose-event", self.expose_label_align)

        self.pack_start(self.scroll, False, False)
        self.pack_start(self.status_box)
    def __set_row(self, name, arg, types="ip"):
        label = Label(name,
                      text_size=CONTENT_FONT_SIZE,
                      enable_select=False,
                      enable_double_click=False)

        label.set_can_focus(False)
        entry = IPV4Entry()
        if types == "ip":
            entry.connect("changed", self.set_ip_address, arg)
        else:
            entry.connect("changed", self.set_dns_address, arg)

        return (label, entry)
Example #39
0
    def __init__(self, songs, init_index=0):
        super(SongEditor, self).__init__(_("Properties"),
                                         500,
                                         400,
                                         mask_type=DIALOG_MASK_TAB_PAGE)
        self.set_position(gtk.WIN_POS_CENTER)

        close_button = Button(_("Close"))
        close_button.connect("clicked", self.click_close_button)

        previous_button = Button(_("Previous"))
        previous_button.connect("clicked",
                                lambda w: self.update_previous_song())
        next_button = Button(_("Next"))
        next_button.connect("clicked", lambda w: self.update_next_song())

        self.record_label = Label("0/0")

        action_box = gtk.HBox(spacing=5)
        action_box.pack_start(previous_button, False, False)
        action_box.pack_start(self.record_label, False, False)
        action_box.pack_start(next_button, False, False)

        MediaDB.connect("simple-changed", self.db_simple_changed)

        # action_box.
        if len(songs) <= 1:
            action_box.set_no_show_all(True)
        else:
            self.record_label.set_text("%d/%d" % (init_index + 1, len(songs)))

        # tabs
        self.song_info = SongInfo(songs[init_index])
        self.info_setting = InfoSetting(songs[init_index])
        self.cover_setting = CoverSetting(songs[init_index])

        self.tab_box = TabBox()
        self.tab_box.add_items([(_("Track Infomation"), self.song_info),
                                (_("Tag Settings"), self.info_setting),
                                (_("Cover Settings"), self.cover_setting)])

        # DialogBox code, simple, ah? :)
        self.left_button_box.set_buttons([action_box])
        self.right_button_box.set_buttons([close_button])
        self.body_box.pack_start(self.tab_box, True, True)

        # Constants.
        self.current_index = init_index
        self.songs = songs
Example #40
0
    def __init__(self, width=800):
        gtk.HBox.__init__(self)

        self.width = width

        self.status_label = Label(text="",
                                  text_size=CONTENT_FONT_SIZE,
                                  text_x_align=ALIGN_MIDDLE,
                                  label_width=600,
                                  enable_select=False)

        self.set_size_request(self.width, -1)
        self.pack_start(self.status_label, False, False)

        self.connect("expose-event", self.__expose)
    def __init__(self):
        super(GuideBox, self).__init__()

        self.scrolled_window = ScrolledWindow()
        self.backgroundbox = BackgroundBox()
        self.backgroundbox.draw_mask = self.draw_mask

        self.guide_pixbuf = utils.get_common_image_pixbuf('guide.png')

        self.top_title = gtk.HBox()

        self.top_left_icon = gtk.VBox()
        self.top_left_icon.set_size_request(self.guide_pixbuf.get_width(),
                                            self.guide_pixbuf.get_height())
        self.top_left_icon.connect('expose-event', self.expose_top_left_icon)
        top_left_icon_align = gtk.Alignment(0.5, 0.5, 0, 0)
        top_left_icon_align.set_padding(15, 3, 13, 3)
        top_left_icon_align.add(self.top_left_icon)

        self.top_right_text = Label(
            _("Introduction"), ui_theme.get_color('label_select_background'),
            14)
        top_right_text_align = gtk.Alignment(0.5, 0.5, 0, 0)
        top_right_text_align.set_padding(18, 3, 3, 3)
        top_right_text_align.add(self.top_right_text)

        self.top_title.pack_start(top_left_icon_align, False, False)
        self.top_title.pack_start(top_right_text_align, False, False)

        self.content_box = gtk.VBox()
        self.guide_label = Label('',
                                 enable_select=False,
                                 wrap_width=200,
                                 text_size=9,
                                 text_color=DynamicColor('#808080'))
        guide_label_align = gtk.Alignment(0.5, 0.5, 1, 1)
        guide_label_align.set_padding(5, 5, 10, 10)
        guide_label_align.add(self.guide_label)
        self.content_box.pack_start(guide_label_align, False, False)

        self.backgroundbox.pack_start(self.top_title, False, False)
        self.backgroundbox.pack_start(self.content_box)

        self.scrolled_window.add_child(self.backgroundbox)
        self.add(self.scrolled_window)

        global_event.register_event('download-app-info-finish',
                                    self.update_content)
Example #42
0
    def __init__(self):
        super(SongTimer, self).__init__()

        self.label_time = Label("00:00/00:00", app_theme.get_color("labelText"), 8, enable_gaussian=True)

        self.bar = HScalebar()
        self.bar.set_draw_value(False)
        self.bar.set_range(0, 1000)
        self.bar.set_value(0)
        self.bar.connect("button_press_event", self.on_bar_press)
        self.bar.connect("button_release_event", self.on_bar_release)
        self.__value_changed_id = self.bar.connect("value-changed", self.on_bar_value_changed)
        self.bar.handler_block(self.__value_changed_id)
        self.pack_start(self.bar, True, True)
        self.update_bar = 1
        self.duration = 0
        self.__idle_release_id = None
        self.delete = False
        self.__need_report = False

        Player.connect("instant-new-song", self.set_duration)

        Player.bin.connect("tick", self.on_tick)
        Player.connect("seeked", self.on_seek)
        Player.connect("stopped", self.set_duration)
        if not Player.song:
            self.bar.set_sensitive(False)
    def __init__(self, draw_time_callback=None):
        super(SongTimer, self).__init__()

        self.label_time = Label("00:00", app_theme.get_color("labelText"), 8, enable_gaussian=True)
        self.draw_time_callback = draw_time_callback
        if draw_time_callback:
            draw_time_callback(self.label_time.get_text())
            
        self.bar = ProgressBar()
        bar_align = gtk.Alignment()
        bar_align.set_padding(0, 0, 1, 1)
        bar_align.set(1, 1, 1, 1)
        bar_align.add(self.bar)
        self.bar.connect("button-press-event", self.on_bar_press)
        self.bar.connect("button-release-event", self.on_bar_release)
        self.__value_changed_id = self.bar.connect("value-changed", self.on_bar_value_changed)

        self.pack_start(bar_align, True, True)
        self.update_bar = 1
        self.duration = 0
        self.__idle_release_id = None
        self.delete = False
        self.__need_report = False
        self.press_flag = False

        Player.connect("instant-new-song", self.set_duration)
        Player.connect("init-status", self.on_player_init_status)

        Player.bin.connect("queue-running", self.on_queue_running)
        Player.bin.connect("tick", self.on_tick)
        Player.connect("seeked", self.on_seek)
        Player.connect("stopped", self.set_duration)
        if not Player.song:
            self.bar.set_sensitive(False)
    def __init__(self, title_name):
        BaseBar.__init__(self, init_index=-1)
        self.set_spacing(3)
        self.child_box = gtk.VBox()
        self.child_item_height = 22
        self.current_page = 1
        self.page_items_num = 0        
        self.items = []
        
        title_item = SimpleLabel(
            app_theme.get_pixbuf("filter/local_normal.png"),
            title_name, 10, 25, 15, 10, 25, ALIGN_START)
        self.pack_start(title_item, False, False)
        self.pack_start(self.child_box, True, True)
        self.child_box.connect("size-allocate", self.size_change_cb)

        self.control_box = gtk.HBox()
        self.control_box.set_spacing(15)        
        previous_align = self.create_simple_button("previous", self.update_current_page, "previous")
        next_align = self.create_simple_button("next", self.update_current_page, "next")
        self.info_label = Label("0/0", app_theme.get_color("labelText"), text_x_align=ALIGN_MIDDLE)
        self.control_box.pack_start(previous_align, False, False)
        self.control_box.pack_start(self.info_label, False, False)
        self.control_box.pack_start(next_align, False, False)
        self.control_box.set_no_show_all(True)
        control_align = gtk.Alignment()
        control_align.set(1, 1, 0.5, 0.5)
        control_align.add(self.control_box)
        self.pack_start(control_align, False, False)
Example #45
0
 def create_combo_widget(self, label_content, items, select_index=0):
     label = Label(label_content)
     combo_box = ComboBox(items, select_index=select_index)
     hbox = gtk.HBox(spacing=5)
     hbox.pack_start(label, False, False)
     hbox.pack_start(combo_box, False, False)
     return hbox, combo_box
Example #46
0
    def create_combo_entry(self,
                           top_attach,
                           bottom_attach,
                           label_text,
                           content_text=""):
        title_label_box = gtk.HBox()
        title_label = Label("%s:" % label_text)
        title_label_box.pack_start(create_right_align(), False, True)
        title_label_box.pack_start(title_label, False, True)

        content_entry = InputEntry(content_text)
        content_entry.set_size(260, 25)
        self.main_table.attach(title_label_box,
                               0,
                               1,
                               top_attach,
                               bottom_attach,
                               xoptions=gtk.FILL)
        self.main_table.attach(content_entry,
                               1,
                               2,
                               top_attach,
                               bottom_attach,
                               xoptions=gtk.FILL)
        return content_entry
 def __init__(self):
     DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE,
                        modal=False, window_hint=None, close_callback=self.hide_all)
     title_label = Label(_("Title:"))
     self.title_entry = TextEntry("")
     self.title_entry.set_size(300, 25)
     self.search_button = Button(_("Search"))
     self.search_button.connect("clicked", self.search_song)
     
     control_box = gtk.HBox(spacing=5)
     control_box.pack_start(title_label, False, False)
     control_box.pack_start(self.title_entry, False, False)
     control_box.pack_start(self.search_button, False, False)
     
     scrolled_window = ScrolledWindow(0, 0)
     scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     self.result_view = ListView()
     self.result_view.connect("double-click-item", self.double_click_cb)
     self.result_view.draw_mask = self.get_mask_func(self.result_view)
     self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")])
     scrolled_window.add_child(self.result_view)
     
     self.prompt_label = Label("")
     download_button = Button(_("Download"))
     download_button.connect("clicked", self.download_song)
     cancel_button = Button(_("Close"))
     cancel_button.connect("clicked", lambda w: self.hide_all())
     
     self.body_box.set_spacing(5)
     self.body_box.pack_start(control_box, False, False)
     self.body_box.pack_start(scrolled_window, True, True)
     self.left_button_box.set_buttons([self.prompt_label])
     self.right_button_box.set_buttons([download_button, cancel_button])
    def create_close_box(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)
        close_title_label = Label(_("When pressing the close button"))
        close_title_label.set_size_request(350, 12)
        
        # mini_check_button

        self.tray_radio_button = RadioButton(_("Minimize to tray"))
        self.quit_radio_button = RadioButton(_("Quit"))
        
        main_table.attach(close_title_label, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.tray_radio_button, 0, 1, 2, 3, yoptions=gtk.FILL)
        main_table.attach(self.quit_radio_button, 1, 2, 2, 3)
        
        return main_table
    def create_uninstall_box(self):
        main_table = gtk.Table(2, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)
        uninstall_title_label = Label(_("On uninstall software"))
        uninstall_title_label.set_size_request(350, 12)
        
        # mini_check_button

        self.delete_check_button = CheckButton(_("Delete configuration files"))
        self.delete_check_button.set_active(get_purg_flag())
        self.delete_check_button.connect("toggled", lambda w: set_purge_flag(self.delete_check_button.get_active()))
        
        main_table.attach(uninstall_title_label, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.delete_check_button, 0, 1, 2, 3, yoptions=gtk.FILL)
        
        return main_table
    def __init__(self, session_bus):
        dbus.service.Object.__init__(self, session_bus, DSC_UPDATE_MANAGER_PATH)

        self.in_update_list = False
        self.in_upgrade_packages = False
        self.upgrade_pkg_infos = []

        self.application = Application()
        self.application.set_default_size(400, 250)
        self.application.add_titlebar(
                button_mask=['min', 'close'],
                app_name='Software Update Manager',
                )

        self.application.window.set_title("Software Update Manager")
        self.application.set_icon(get_common_image('update.png'))


        # Init page box.
        self.page_box = gtk.VBox()
        
        # Init page align.
        self.page_align = gtk.Alignment()
        self.page_align.set(0.5, 0.5, 1, 1)
        self.page_align.set_padding(0, 0, 2, 2)
        
        self.page_align.add(self.page_box)
        self.application.main_box.pack_start(self.page_align, True, True)
        
        # Init status bar.
        self.statusbar = Statusbar(28)
        status_box = gtk.HBox()

        self.statusbar.status_box.pack_start(status_box, True, True)
        self.application.main_box.pack_start(self.statusbar, False, False)

        self.background = BackgroundBox()
        self.background.draw_mask = self.draw_mask
        self.page_box.pack_start(self.background)

        self.upgrade_button = Button('更新软件')
        self.upgrade_button.set_sensitive(False)

        button_box = gtk.HBox()
        button_box.pack_start(self.upgrade_button, False, False)

        button_box_align = gtk.Alignment(0.5, 0.5, 0, 0)
        button_box_align.set_padding(3, 8, 4, 4)
        button_box_align.add(button_box)

        self.statusbar.status_item_box.pack_start(button_box_align)

        self.update_info_label = Label("初始化...")
        self.update_info_label_align = create_align((0.5, 0.5, 0, 0))
        self.update_info_label_align.add(self.update_info_label)
        
        self.upgrade_button.connect('clicked', self.upgrade_packages)
 def __init__(self):
     DialogBox.__init__(
         self, _("Lyrics search"), 460, 300, DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all, 
         modal=False, window_hint=None, skip_taskbar_hint=False)
     self.artist_entry = InputEntry()
     self.artist_entry.set_size(130, 23)
     self.title_entry = InputEntry()
     self.title_entry.set_size(130, 23)
     artist_label = Label(_("Artist:"))
     title_label = Label(_("Title:"))
     right_align = gtk.Alignment()
     right_align.set(0, 0, 0, 1)
     
     search_button = Button(_("Search"))
     search_button.connect("clicked", self.search_lyric_cb)
     
     info_box = gtk.HBox(spacing=25)
     
     control_box = gtk.HBox(spacing=5)
     title_box = gtk.HBox(spacing=5)        
     title_box.pack_start(title_label, False, False)
     title_box.pack_start(self.title_entry)
     artist_box = gtk.HBox(spacing=5)
     artist_box.pack_start(artist_label, False, False)
     artist_box.pack_start(self.artist_entry)
     control_box.pack_start(title_box, False, False)
     control_box.pack_start(artist_box, False, False)
     
     info_box.pack_start(control_box, False, False)
     info_box.pack_start(search_button, False, False)
     
     scrolled_window = ScrolledWindow(0, 0)
     scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     sort_items = [(lambda item: item.title, cmp), (lambda item: item.artist, cmp)]
     self.result_view = ListView(sort_items)
     self.result_view.connect("double-click-item", self.double_click_cb)
     self.result_view.add_titles([_("Title"), _("Artist")])
     self.result_view.draw_mask = self.get_mask_func(self.result_view)
     scrolled_window.add_child(self.result_view)
     
     self.prompt_label = Label("")
     download_button = Button(_("Download"))
     download_button.connect("clicked", self.download_lyric_cb)
     cancel_button = Button(_("Close"))
     cancel_button.connect("clicked", lambda w: self.hide_all())
     
     info_box_align = gtk.Alignment()
     info_box_align.set_padding(5, 0, 5, 0)
     info_box_align.add(info_box)
     
     self.body_box.set_spacing(5)
     self.body_box.pack_start(info_box_align, False, False)
     self.body_box.pack_start(scrolled_window, True, True)
     self.left_button_box.set_buttons([self.prompt_label])
     self.right_button_box.set_buttons([download_button, cancel_button])
     self.lrc_manager = LrcManager()
    def __init__(self, 
                 text, 
                 enable_gaussian=False, 
                 text_color=ui_theme.get_color("link_text"),
                 ):
        '''
        Initialize LinkButton class.
        
        @param text: Link content.
        @param link: Link address.
        @param enable_gaussian: To enable gaussian effect on link, default is True.
        @param text_color: Link color, just use when option enable_gaussian is False.
        '''
        Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9,
                       gaussian_radious=1, border_radious=0, underline=True)
        self.callback_action = None

        set_clickable_cursor(self)
        self.connect('button-press-event', self.button_press_action)
Example #53
0
 def set_slide_index(self, index):
     '''
     set slide to index
     @param index: the index of widget in slider, an int num
     '''
     if index >= len(self.slider_list):
         return
     direct = "right"
     if index == 1 and self.window.button_box in self.window.window_frame.get_children():
         #self.slider.set_size_request(-1, 260)
         win = self.window
         if win.left_button_box in win.button_box.get_children():
             win.button_box.remove(win.left_button_box)
         if win.right_button_box in win.button_box.get_children():
             win.button_box.remove(win.right_button_box)
         tmp = gtk.HSeparator()
         tmp.set_size_request(-1, 1)
         tmp.show()
         win.button_box.pack_start(tmp)
         direct = "right"
         #if self.window.button_box in self.window.window_frame.get_children():
             #self.window.window_frame.remove(self.window.button_box)
     elif index == 0:
         #self.slider.set_size_request(-1, 223)
         win = self.window
         for each in win.button_box.get_children():
             each.destroy()
         if win.left_button_box not in win.button_box.get_children():
             win.button_box.pack_start(win.left_button_box)
         if win.right_button_box not in win.button_box.get_children():
             win.button_box.pack_start(win.right_button_box)
         direct = "left"
         #if self.window.button_box not in self.window.window_frame.get_children():
             #self.window.window_frame.pack_start(self.window.button_box, False, False)
     elif index == 2:
         self.window.left_button_box.set_buttons([])
         l = Label("  ")
         l.show()
         self.window.right_button_box.set_buttons([l])
         direct = "right"
         #self.slider.set_size_request(-1, 223)
         
     self.slider.slide_to_page(self.slider_list[index], direct)
Example #54
0
    def show_screenshot(self):
        container_remove_all(self.right_slide_box)
        screenshot_dir = os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name)

        if os.path.exists(screenshot_dir):
            screenshot_files = map(lambda filename: os.path.join(screenshot_dir, filename),
                                   filter(lambda file_name: file_name.endswith(".png"), os.listdir(screenshot_dir)))

            if len(screenshot_files) > 0:
                slide_switcher = SlideSwitcher(
                    map(lambda screenshot_file: get_resize_pixbuf_with_height(screenshot_file, 290), screenshot_files),
                    pointer_offset_x=-370,
                    pointer_offset_y=-15,
                        horizontal_align=ALIGN_MIDDLE,
                        vertical_align=ALIGN_MIDDLE,
                        height_offset=60,
                        hover_switch=False,
                        auto_switch=False,
                        navigate_switch=True,
                        )
                slide_align = gtk.Alignment()
                slide_align.set(0.5, 0.5, 1, 1)
                slide_align.add(slide_switcher)
                slide_align.connect("expose-event", self.expose_resizable_label_background)
                self.right_slide_box.pack_start(slide_align, True, True)

                powered_link = Label(
                    _("Powered by UpYun.com"),
                    text_color=app_theme.get_color("homepage"),
                    hover_color=app_theme.get_color("homepage_hover"),
                    )
                powered_link.set_clickable()
                powered_link.connect("button-press-event", lambda w, e: run_command("xdg-open https://www.upyun.com/"))
                powered_link_align = gtk.Alignment()
                powered_link_align.set(1.0, 0.5, 0, 0)
                powered_link_align.set_padding(0, 0, 0, 100)
                powered_link_align.add(powered_link)
                self.right_slide_box.pack_start(powered_link_align, False, False)

                self.show_all()
            else:
                global_logger.logerror("%s haven't any screenshot from zip file" % self.pkg_name)
    def toggle_cb(self, widget):
        active = widget.get_active()
        if active:
            if self.proxysetting.get_proxy_mode() == "none":
                self.proxysetting.set_proxy_mode("manual")
            self.align = gtk.Alignment(0,0,0,0)
            self.align.set_padding(0,0,PADDING,11)
            label = Label(_("Proxy Configuration"),
                          LABEL_COLOR,
                          underline=True,
                          enable_select=False,
                          enable_double_click=False)
            label.connect("button-release-event", self.slide_to_event)

            self.align.add(label)
            self.add(self.align)
            self.show_all()
        else:
            self.align.destroy()
            self.proxysetting.set_proxy_mode("none")
class FootBox(gtk.HBox):

    def __init__(self):
        gtk.HBox.__init__(self)
        self.set_size_request(-1, 35)
        #self.connect("expose-event", self.expose_line)
        self.init_ui()

    def expose_line(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        style.draw_out_line(cr, rect)

    def init_ui(self):
        self.tip_align = gtk.Alignment(0, 0.5, 0, 1)
        self.tip = Label("")
        self.tip_align.set_padding(5, 5, 20, 0)
        self.tip_align.add(self.tip)

        self.button_box = gtk.HBox()
        self.buttons_align = gtk.Alignment(1, 0.5, 0, 0)
        self.buttons_align.set_padding(0, 0, 0, 10)
        self.buttons_align.add(self.button_box)
        
        self.pack(self, [self.tip_align], True, True)
        self.pack_end(self.buttons_align, False, False)
    
    def pack(self, parent, widgets, expand=False, fill=False):
        for widget in widgets:
            parent.pack_start(widget, expand, fill)

    def set_buttons(self, buttons_list):
        width = 0
        for button in buttons_list:
            width += button.get_size_request()[0]
        self.button_box.set_size_request(width, -1)
        self.pack(self.button_box, buttons_list)
        self.queue_draw()

    def set_tip(self, new_tip):
        self.tip.set_text(new_tip)
    def __init__(self):
        gtk.HBox.__init__(self)
        
        self.info_image_box = gtk.VBox()
        self.info_image_box.set_size_request(24, 24)
        self.info_image_box.connect('expose-event', self.expose_info_image_box)

        self.info_label = Label("")
        self.end_info_label = Label("")
        self.info_callback_button = ActionButton('')

        self.close_button = CloseButton()

        self.pack_start(self.info_image_box, False, False)
        self.pack_start(self.info_label)

        self.pack_end(self.close_button, False, False)
        self.pack_end(self.info_callback_button, False, False)
        self.pack_end(self.end_info_label, False, False)

        self.connect('expose-event', self.expose)