Пример #1
0
    def update_info(self, app):
        port = app.info

        # Clear
        for child in port.get_children():
            port.remove(child)

        # Alignment
        align = gtk.Alignment(0, 0, 1, 1)
        align.set_padding(4, 4, 4, 4)
        port.add(align)

        # Vertical box
        vbox = gtk.VBox()
        align.add(vbox)

        for category in self.info:
            name = category[0]
            category = category[1:]

            # Frame
            frame = gtk.Frame('<b>%s</b>' % name)
            frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
            frame.get_label_widget().set_use_markup(True)
            vbox.pack_start(frame, False)

            # Alignment
            align = gtk.Alignment(0, 0, 1, 1)
            align.set_padding(0, 0, 12, 0)
            frame.add(align)

            # Table
            table = gtk.Table(len(category), 2)
            table.set_col_spacing(0, 5)
            align.add(table)

            row = 0
            for name, value in category:
                # Name
                label = gtk.Label('<b>%s</b>' % name)
                label.set_use_markup(True)
                label.set_alignment(1, 0.5)
                table.attach(label, 0, 1, row, row + 1, gtk.FILL, gtk.FILL)

                # Value
                if value.startswith('http://'):
                    label = gtk.LinkButton(value, value)
                    label.set_relief(gtk.RELIEF_NONE)
                    label.set_property('can-focus', False)

                else:
                    label = gtk.Label(value)

                label.set_alignment(0, 0.5)
                label.modify_font(app.mono_font)
                table.attach(label, 1, 2, row, row + 1, yoptions=gtk.FILL)

                row += 1

        port.realize()
        port.show_all()
Пример #2
0
    def __init__(self, controller):
        '''Constructor'''
        gtk.HBox.__init__(self)

        self.controller = controller
        self.theme = controller.theme
        self.config = controller.config

        self.set_border_width(2)

        self.smileysCache = {}
        self.hasSmilies = True

        self.tNick = gtk.Entry(max=129)
        self.tNick.set_text(self.controller.msn.nick.replace('\n', ' '))
        self.tNick.set_no_show_all(True)

        self.lNick = SmileyLabel('', self.controller.widget_style)
        self.lNick.set_ellipsize(pango.ELLIPSIZE_END)

        self.bNick = gtk.Button()
        self.bNick.set_relief(gtk.RELIEF_NONE)
        self.bNick.set_alignment(0, 0)
        self.bNick.add(self.lNick)

        iconMail = self.theme.getSmiley("(e)")  #email icon

        self.mailButton = ImageButton(iconMail, '(0)')
        self.mailButton.set_relief(gtk.RELIEF_NONE)
        self.mailButton.set_tooltip_text(_('Click here to access your mail'))

        i = self.controller.contacts.get_status()
        status = self.controller.status_ordered[0][i]
        self.statusIcon = self.theme.statusToPixbuf(status)
        self.statusButton = ImageButton(self.statusIcon)
        self.statusButton.set_relief(gtk.RELIEF_NONE)
        self.statusButton.set_tooltip_text(
            _('Click here to change your status'))

        self.statusMenu = StatusMenu.StatusMenu(self.controller)

        self.tPersonalMessage = gtk.Entry(max=129)
        self.tPersonalMessage.set_text(self.controller.contacts.get_message())
        self.tPersonalMessage.set_no_show_all(True)
        self.lPersonalMessage = SmileyLabel('', self.controller.widget_style)
        self.lPersonalMessage.set_ellipsize(pango.ELLIPSIZE_END)
        self.bPersonalMessage = gtk.Button()
        self.bPersonalMessage.set_relief(gtk.RELIEF_NONE)
        self.bPersonalMessage.set_alignment(0, 0)
        self.bPersonalMessage.add(self.lPersonalMessage)

        mediaIcon = self.theme.getSmiley("(8)")  #media icon
        # at the bottom is the code to handle starting toggled
        self.mediaButton = ImageToggleButton(mediaIcon)
        self.mediaButton.set_relief(gtk.RELIEF_NONE)

        try:  # why, oh why, gtk must be so angry?
            self.mediaButton.set_tooltip_text(
                _('Toggle sending current playing song'))
        except:
            pass

        self.lMedia = gtk.Label(_("No media playing"))
        self.lMedia.set_ellipsize(pango.ELLIPSIZE_END)
        self.bMedia = gtk.Button()
        self.bMedia.set_relief(gtk.RELIEF_NONE)
        self.bMedia.set_alignment(0, 0)
        self.bMedia.add(self.lMedia)
        self.bMedia.connect('clicked', self.onMediaClicked)
        self.lMedia.set_no_show_all(True)
        self.bMedia.set_no_show_all(True)

        self.bNick.set_tooltip_text(_('Click here to set your nick name'))
        self.bPersonalMessage.set_tooltip_text(
            _('Click here to set your personal message'))
        self.bMedia.set_tooltip_text(_('Your current media'))

        self.image = Widgets.avatarHolder(cellDimention=48)
        self.imageEventBox = gtk.EventBox()
        self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.imageEventBox.connect('button-press-event', self.avatarClicked)
        self.imageEventBox.add(self.image)
        self.imageEventBox.set_tooltip_text(_('Click here to set your avatar'))
        #frame = gtk.AspectFrame()
        #frame.add(self.imageEventBox)
        if self.controller.avatar:
            self.image.set_from_pixbuf(self.controller.avatar.getThumb())
        else:
            self.pixbuf = self.controller.theme.getImage('userPanel')
            self.image.set_from_pixbuf(self.pixbuf)

        self.tNick.connect('activate', self.on_nick_changed)
        self.tNick.connect('focus-out-event', self.on_nick_changed)
        self.bNick.connect('clicked', self.on_nick_clicked)
        self.tPersonalMessage.connect('activate', self.on_pm_changed)
        self.tPersonalMessage.connect('focus-out-event', self.on_pm_changed)
        self.bPersonalMessage.connect('clicked', self.on_pm_clicked)
        self.mediaButton.connect("toggled", self.onToggleMedia)

        self.mailButton.connect('clicked', self.onMaiButtonClicked)

        self.controller.msn.connect('self-personal-message-changed',
                                    self.personalMessageChanged)
        self.controller.msn.connect('self-nick-changed', self.selfNickChanged)
        self.controller.msn.connect('self-current-media-changed',
                                    self.currentMediaChanged)

        self.mailButton.setText('(' + str(self.controller.getUnreadMails()) +
                                ')')
        self.controller.msn.connect('initial-mail-notification',
                                    self.updateMailCount)
        self.controller.msn.connect('new-mail-notification',
                                    self.updateMailCount)
        self.controller.msn.connect('mail-movement-notification',
                                    self.updateMailCount)

        self.statusButton.connect('button-press-event',
                                  self.pop_up_status_menu)
        self.controller.msn.connect('self-status-changed',\
                                          self.update_status_icon)

        self.hbox = gtk.HBox()
        self.pack_start(self.imageEventBox, False, False)

        self.vbox1 = gtk.VBox()
        self.vbox2 = gtk.VBox(True)
        self.hbox1 = gtk.HBox()
        self.hbox2 = gtk.HBox()

        self.hbox1.pack_start(self.tNick, True, True)
        self.hbox1.pack_start(self.bNick, True, True)

        self.hbox2.pack_start(self.tPersonalMessage, True, True)
        self.hbox2.pack_start(self.bPersonalMessage, True, True)
        self.hbox2.pack_start(self.bMedia, True, True)

        self.vbox2h1 = gtk.HBox()
        self.vbox2h1.pack_end(self.mailButton, True, False)
        self.vbox2h1aligned = gtk.Alignment(1, 0, 0, 0)
        self.vbox2h1aligned.add(self.vbox2h1)

        self.vbox2h2 = gtk.HBox()
        self.vbox2h2.pack_start(self.mediaButton, True, False)
        self.vbox2h2.pack_end(self.statusButton, True, False)
        self.vbox2h2aligned = gtk.Alignment(1, 0, 0, 0)
        self.vbox2h2aligned.add(self.vbox2h2)

        self.vbox2.pack_start(self.vbox2h1aligned, True, False)
        self.vbox2.pack_start(self.vbox2h2aligned, True, False)

        self.vbox1.pack_start(self.hbox1, True, False, 1)
        self.vbox1.pack_start(self.hbox2, True, False, 1)

        self.hbox.pack_start(self.vbox1, True, True)
        self.hbox.pack_start(self.vbox2, False, False)
        self.pack_start(self.hbox)

        self.show_all()

        # if in the config is active we activate it emitting the toggled signal
        if controller.config.user['mediaEnabled']:
            self.mediaButton.set_active(True)

        self.mediaButton.hide()

        try:
            if not DOMAIN_REGEXP.match(
                    self.controller.userEmail.split("@")[1]):
                self.mailButton.hide()
        except Exception, e:
            print "error! " + str(e)
Пример #3
0
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_border_width(6)
        self.set_resizable(False)
        self.set_title('')
        # defaults to center location
        self.set_position(gtk.WIN_POS_CENTER)
        self.connect("delete-event", self.__on_close)

        # main container
        main = gtk.VBox(spacing=12)
        main.set_spacing(12)
        main.set_border_width(6)
        main.show()
        self.add(main)

        # primary text
        alg = gtk.Alignment()
        alg.set_padding(0, 6, 0, 0)
        alg.show()
        main.pack_start(alg, False, False)
        lbl = hig_label()
        lbl.set_selectable(False)
        lbl.show()
        self.__primary_label = lbl
        alg.add(lbl)

        # secondary text
        lbl = hig_label()
        lbl.set_selectable(False)
        lbl.show()
        main.pack_start(lbl, False, False)
        self.__secondary_label = lbl

        # Progress bar
        vbox = gtk.VBox()
        vbox.show()
        main.pack_start(vbox, False, False)

        prog = gtk.ProgressBar()
        prog.show()
        self.__progress_bar = prog
        vbox.pack_start(prog, expand=False)

        lbl = hig_label()
        lbl.set_selectable(False)
        lbl.show()
        self.__sub_progress_label = lbl
        vbox.pack_start(lbl, False, False)

        # Buttons box
        bbox = gtk.HButtonBox()
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()

        # Cancel Button
        cancel = gtk.Button(gtk.STOCK_CANCEL)
        cancel.set_use_stock(True)
        cancel.show()
        self.__cancel = cancel
        bbox.add(cancel)
        main.add(bbox)

        # Close button, which is hidden by default
        close = gtk.Button(gtk.STOCK_CLOSE)
        close.set_use_stock(True)
        close.hide()
        bbox.add(close)
        self.__close = close
Пример #4
0
def set_widget_gravity(widget, gravity=(0, 0, 0, 0), paddings=(0, 0, 0, 0)):
    align = gtk.Alignment()
    align.set(*gravity)
    align.set_padding(*paddings)
    align.add(widget)
    return align
    def __init__(self, appInfo, switchStatus, downloadQueue,
                 entryDetailCallback, sendVoteCallback, index, getSelectIndex,
                 setSelectIndex, selectPkgCallback, unselectPkgCallback,
                 getSelectStatusCallback, addIgnorePkgCallback):
        '''Init for application item.'''
        DownloadItem.__init__(self, appInfo, switchStatus, downloadQueue)

        self.appInfo = appInfo
        self.entryDetailCallback = entryDetailCallback
        self.sendVoteCallback = sendVoteCallback
        self.selectPkgCallback = selectPkgCallback
        self.unselectPkgCallback = unselectPkgCallback
        self.getSelectStatusCallback = getSelectStatusCallback
        self.addIgnorePkgCallback = addIgnorePkgCallback
        self.checkButton = None
        self.index = index
        self.setSelectIndex = setSelectIndex

        # Widget that status will change.
        self.upgradingProgressbar = None
        self.upgradingFeedbackLabel = None

        # Init.
        self.itemBox = gtk.HBox()
        self.itemEventBox = gtk.EventBox()
        self.itemEventBox.connect("button-press-event", self.clickItem)
        self.itemEventBox.add(self.itemBox)
        drawListItem(self.itemEventBox, index, getSelectIndex)

        self.itemFrame = gtk.Alignment()
        self.itemFrame.set(0.0, 0.5, 1.0, 1.0)
        self.itemFrame.add(self.itemEventBox)

        # Add check box.
        checkPaddingLeft = 20
        checkPaddingRight = 15
        checkPaddingY = 10
        self.checkButton = gtk.CheckButton()
        self.checkButton.set_active(
            self.getSelectStatusCallback(utils.getPkgName(self.appInfo.pkg)))
        self.checkButton.connect("toggled",
                                 lambda w: self.toggleSelectStatus())
        checkButtonSetBackground(
            self.checkButton,
            False,
            False,
            "cell/select.png",
            "cell/selected.png",
        )
        self.checkAlign = gtk.Alignment()
        self.checkAlign.set(0.5, 0.5, 0.0, 0.0)
        self.checkAlign.set_padding(checkPaddingY, checkPaddingY,
                                    checkPaddingLeft, checkPaddingRight)
        self.checkAlign.add(self.checkButton)
        self.itemBox.pack_start(self.checkAlign, False, False)

        self.appBasicView = AppBasicView(self.appInfo,
                                         300 + APP_BASIC_WIDTH_ADJUST,
                                         self.itemBox, self.entryDetailView)
        self.itemBox.pack_start(self.appBasicView.align, True, True)

        self.appAdditionBox = gtk.HBox()
        self.appAdditionAlign = gtk.Alignment()
        self.appAdditionAlign.set(1.0, 0.5, 0.0, 0.0)
        self.appAdditionAlign.add(self.appAdditionBox)
        self.itemBox.pack_start(self.appAdditionAlign, False, False)

        self.initAdditionStatus()

        self.itemFrame.show_all()
Пример #6
0
    def __init__(self, filename=""):
        '''
        init share
        @param filename: the file to share
        '''
        self.upload_image = filename
        self.thumb_width = 188
        self.thumb_height = 168
        self.MAX_CHAR = 140
        #self.__text_frame_color = (0.76, 0.76, 0.76)
        self.__win_width = 602
        open(COOKIE_FILE,'wb').close()

        self.window = DialogBox(_("share to web"), close_callback=gtk.main_quit)
        self.window.set_keep_above(True)
        self.window.set_size_request(self.__win_width+20, 288)
        self.window.set_resizable(False)
        self.window.titlebar.connect("expose-event", self.__expose_top_and_bottome)
        self.window.button_box.connect("expose-event", self.__expose_top_and_bottome)

        # create slider
        self.slider = HSlider()
        self.slider_list = []

        self.share_box = gtk.VBox(False, 2)     # first page, input context
        self.web_box = gtk.VBox(False, 10)      # second page, login
        self.result_box = gtk.VBox(False, 10)   # third page, share result

        share_align = gtk.Alignment()
        share_align.set(0.5, 0.5, 0, 0)
        share_align.add(self.share_box)
        share_align.connect("expose-event", self.__slider_expose)

        # go back button
        web_left_button = ImageButton(
            app_theme.get_pixbuf("share/back_normal.png"),
            app_theme.get_pixbuf("share/back_hover.png"),
            app_theme.get_pixbuf("share/back_press.png"))
        web_left_button.connect("clicked", lambda w: self.set_slide_index(0))
        web_left_button.set_can_focus(False)
        utils.set_clickable_cursor(web_left_button)
        # show url entry
        self.web_url_entry = InputEntry()
        self.web_url_entry.set_editable(False)
        self.web_url_entry.set_size(555, 20)
        self.web_url_entry.entry.right_menu_visible_flag = False
        # alig url entry
        web_navigate_vbox = gtk.VBox(False)
        web_navigate_vbox.pack_start(self.web_url_entry)
        web_navigate_t_align = gtk.Alignment()
        web_navigate_t_align.set(0.0, 0.5, 0, 0)
        web_navigate_t_align.add(web_navigate_vbox)
        # pack back button and url entry
        web_navigate_box = gtk.HBox(False, 7)
        web_navigate_box.pack_start(web_left_button, False, False)
        web_navigate_box.pack_start(web_navigate_t_align)

        web_navigate_align = gtk.Alignment()
        web_navigate_align.set(0.5, 0.5, 0, 0)
        web_navigate_align.set_padding(4, 0, 11, 13)
        web_navigate_align.add(web_navigate_box)

        # create a webkit
        self.web_view = WebView(COOKIE_FILE)
        self.web_view.connect("notify::load-status", self.web_view_load_status)
        self.web_view.connect("load-error", self.web_view_load_error)
        self.web_scrolled_window = ScrolledWindow()
        self.web_scrolled_window.add(self.web_view)
        self.web_scrolled_window.set_size_request(590, 228)

        self.web_box.pack_start(web_navigate_align, False, False)
        self.web_box.pack_start(self.web_scrolled_window)
        #self.web_box.set_size_request(-1, 258)
        web_align = gtk.Alignment()
        web_align.set(0.5, 0.0, 0, 1)
        web_align.add(self.web_box)
        web_align.connect("expose-event", self.__slider_expose)

        res_align = gtk.Alignment()
        res_align.set(0.5, 0.5, 0, 0)
        res_align.add(self.result_box)
        res_align.connect("expose-event", self.__slider_expose)

        self.slider.set_to_page(share_align)
        self.slider_list.append(share_align)
        self.slider_list.append(web_align)
        self.slider_list.append(res_align)

        self.__weibo_list = []
        self.sina = weibo.Sina(self.web_view)
        self.qq = weibo.Tencent(self.web_view)
        self.__weibo_list.append(self.sina)
        self.__weibo_list.append(self.qq)
        if default_locale != 'zh_CN':
            self.twitter = weibo.Twitter(self.web_view)
            self.__weibo_list.append(self.twitter)
        self.__current_weibo = None

        self.window.body_box.pack_start(self.slider, True, True)
        self.init_share_box()
Пример #7
0
def create_upper_align(paddings=None):
    align = gtk.Alignment()
    if paddings:
        align.set_padding(*paddings)
    align.set(1, 0, 0, 0)
    return align
Пример #8
0
    def mpd_tab(self, cbs=None):
        """Construct and layout the MPD tab"""
        mpdlabel = ui.label(markup='<b>' + _('MPD Connection') + '</b>')
        frame = gtk.Frame()
        frame.set_label_widget(mpdlabel)
        frame.set_shadow_type(gtk.SHADOW_NONE)
        controlbox = gtk.HBox()
        profiles = ui.combo()
        add_profile = ui.button(img=ui.image(stock=gtk.STOCK_ADD))
        remove_profile = ui.button(img=ui.image(stock=gtk.STOCK_REMOVE))
        self._populate_profile_combo(profiles, self.config.profile_num,
                                     remove_profile)
        controlbox.pack_start(profiles, False, False, 2)
        controlbox.pack_start(remove_profile, False, False, 2)
        controlbox.pack_start(add_profile, False, False, 2)
        namelabel = ui.label(textmn=_("_Name:"))
        nameentry = ui.entry()
        namelabel.set_mnemonic_widget(nameentry)
        hostlabel = ui.label(textmn=_("_Host:"))
        hostentry = ui.entry()
        hostlabel.set_mnemonic_widget(hostentry)
        portlabel = ui.label(textmn=_("_Port:"))
        portentry = gtk.SpinButton(gtk.Adjustment(0, 0, 65535, 1), 1)
        portentry.set_numeric(True)
        portlabel.set_mnemonic_widget(portentry)
        dirlabel = ui.label(textmn=_("_Music dir:"))
        direntry = gtk.FileChooserButton(_('Select a Music Directory'))
        self.direntry = direntry
        direntry.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        direntry.connect('selection-changed', self._direntry_changed, profiles)
        dirlabel.set_mnemonic_widget(direntry)
        passwordlabel = ui.label(textmn=_("Pa_ssword:"))
        passwordentry = ui.entry(password=True)
        passwordlabel.set_mnemonic_widget(passwordentry)
        passwordentry.set_tooltip_text(
            _("Leave blank if no password is required."))
        autoconnect = gtk.CheckButton(_("_Autoconnect on start"))
        autoconnect.set_active(self.config.autoconnect)
        autoconnect.connect('toggled', self._config_widget_active,
                            'autoconnect')
        # Fill in entries with current profile:
        self._profile_chosen(profiles, nameentry, hostentry, portentry,
                             passwordentry, direntry)
        # Update display if $MPD_HOST or $MPD_PORT is set:
        host, port, password = misc.mpd_env_vars()
        if host or port:
            self.using_mpd_env_vars = True
            if not host:
                host = ""
            if not port:
                port = 0
            if not password:
                password = ""
            hostentry.set_text(str(host))
            portentry.set_value(port)
            passwordentry.set_text(str(password))
            nameentry.set_text(_("Using MPD_HOST/PORT"))
            for widget in [
                    hostentry, portentry, passwordentry, nameentry, profiles,
                    add_profile, remove_profile
            ]:
                widget.set_sensitive(False)
        else:
            self.using_mpd_env_vars = False
            nameentry.connect('changed', self._nameentry_changed, profiles,
                              remove_profile)
            hostentry.connect('changed', self._hostentry_changed, profiles)
            portentry.connect('value-changed', self._portentry_changed,
                              profiles)
            passwordentry.connect('changed', self._passwordentry_changed,
                                  profiles)
            profiles.connect('changed', self._profile_chosen, nameentry,
                             hostentry, portentry, passwordentry, direntry)
            add_profile.connect('clicked', self._add_profile, nameentry,
                                profiles, remove_profile)
            remove_profile.connect('clicked', self._remove_profile, profiles,
                                   remove_profile)

        rows = [(namelabel, nameentry), (hostlabel, hostentry),
                (portlabel, portentry), (passwordlabel, passwordentry),
                (dirlabel, direntry)]

        connection_table = gtk.Table(len(rows), 2)
        connection_table.set_col_spacings(12)
        for i, (label, entry) in enumerate(rows):
            connection_table.attach(label, 0, 1, i, i + 1, gtk.FILL, gtk.FILL)
            connection_table.attach(entry, 1, 2, i, i + 1,
                                    gtk.FILL | gtk.EXPAND, gtk.FILL)

        connection_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        connection_alignment.set_padding(12, 12, 12, 12)
        connection_alignment.add(connection_table)
        connection_frame = gtk.Frame()
        connection_frame.set_label_widget(controlbox)
        connection_frame.add(connection_alignment)
        table = gtk.Table(2, 1)
        table.set_row_spacings(12)
        table.attach(connection_frame, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND,
                     gtk.FILL)
        table.attach(autoconnect, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL)
        alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        alignment.set_padding(12, 0, 12, 0)
        alignment.add(table)
        frame.add(alignment)
        tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        tab.set_padding(12, 12, 12, 12)
        tab.add(frame)

        return tab
Пример #9
0
    def extras_tab(self, cbs):
        """Construct and layout the extras tab"""
        if not self.scrobbler.imported():
            self.config.as_enabled = False
        extraslabel = ui.label(markup='<b>' + _('Extras') + '</b>')
        frame = gtk.Frame()
        frame.set_label_widget(extraslabel)
        frame.set_shadow_type(gtk.SHADOW_NONE)

        as_checkbox = gtk.CheckButton(_("_Audioscrobbling (Last.fm)"))
        as_checkbox.set_active(self.config.as_enabled)
        as_user_label = ui.label(textmn=_("_Username:"******"_Password:"******"Popup _notification on song changes"))
        display_notification.set_active(self.config.show_notification)

        time_names = [
            "%s %s" % (i, gettext.ngettext('second', 'seconds', int(i)))
            for i in cbs.popuptimes if i != _('Entire song')
        ]
        time_names.append(_('Entire song'))
        notification_options = ui.combo(items=time_names,
                                        active=self.config.popup_option,
                                        changed_cb=self._notiftime_changed)
        notification_locs = ui.combo(
            items=cbs.popuplocations,
            active=self.config.traytips_notifications_location,
            changed_cb=self._notiflocation_changed)
        notifhbox = gtk.HBox(spacing=6)
        notifhbox.pack_end(notification_locs, False, False)
        notifhbox.pack_end(notification_options, False, False)
        display_notification.connect('toggled', cbs.notif_toggled, notifhbox)
        if not self.config.show_notification:
            notifhbox.set_sensitive(False)
        crossfadespin = gtk.SpinButton()
        crossfadespin.set_range(1, 30)
        crossfadespin.set_value(self.config.xfade)
        crossfadespin.set_numeric(True)
        crossfadespin.set_increments(1, 5)
        crossfadespin.connect('value-changed', cbs.crossfade_changed)
        crossfadelabel2 = ui.label(textmn=_("_Fade length:"))
        crossfadelabel2.set_mnemonic_widget(crossfadespin)
        crossfadelabel3 = ui.label(text=_("sec"))
        crossfadebox = gtk.HBox(spacing=12)
        crossfadebox.pack_end(crossfadelabel3, False, False)
        crossfadebox.pack_end(crossfadespin, False, False)
        crossfadebox.pack_end(crossfadelabel2, False, False)
        crossfadecheck = gtk.CheckButton(_("C_rossfade"))
        crossfadecheck.connect('toggled', self._crossfadecheck_toggled,
                               crossfadespin, crossfadelabel2, crossfadelabel3)
        crossfadecheck.connect('toggled', cbs.crossfade_toggled, crossfadespin)
        crossfadecheck.set_active(self.config.xfade_enabled)
        crossfadecheck.toggled()  # Force the toggled callback

        widgets = (as_checkbox, as_entries, display_notification, notifhbox,
                   crossfadecheck, crossfadebox)
        table = gtk.Table(len(widgets), 1)
        table.set_col_spacings(12)
        table.set_row_spacings(6)
        for i, widget in enumerate(widgets):
            table.attach(widget, 0, 1, i, i + 1, gtk.FILL | gtk.EXPAND,
                         gtk.FILL)
        alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        alignment.set_padding(12, 0, 12, 0)
        alignment.add(table)
        frame.add(alignment)
        tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        tab.set_padding(12, 12, 12, 12)
        tab.add(frame)

        as_checkbox.connect('toggled', self._as_enabled_toggled, as_user_entry,
                            as_pass_entry, as_user_label, as_pass_label)
        if not self.config.as_enabled or not self.scrobbler.imported():
            for widget in (as_user_entry, as_pass_entry, as_user_label,
                           as_pass_label):
                widget.set_sensitive(False)
        return tab
    def __init__(self, appInfo, switchStatus, downloadQueue, entryDetailCallback, index, getSelectIndex, setSelectIndex,
                 launchApplicationCallback):
        '''Init for application item.'''
        DownloadItem.__init__(self, appInfo, switchStatus, downloadQueue)
        
        self.appInfo = appInfo
        self.entryDetailCallback = entryDetailCallback
        self.index = index
        self.setSelectIndex = setSelectIndex
        self.launchApplicationCallback = launchApplicationCallback
        
        # Widget that status will change.
        self.installingProgressbar = None
        self.installingFeedbackLabel = None

        self.upgradingProgressbar = None
        self.upgradingFeedbackLabel = None

        # Init.
        itemPaddingX = 3
        self.itemBox = gtk.HBox()
        self.itemAlign = gtk.Alignment()
        self.itemAlign.set(0.5, 0.5, 0.0, 0.0)
        self.itemAlign.set_padding(0, 0, itemPaddingX, itemPaddingX)
        self.itemAlign.add(self.itemBox)
        self.itemEventBox = gtk.EventBox()
        self.itemEventBox.connect("button-press-event", lambda w, e: clickItem(w, e, entryDetailCallback, appInfo))
        drawRecommendItem(self.itemEventBox, index, getSelectIndex)
        self.itemFrame = gtk.Alignment()
        self.itemFrame.set(0.0, 0.5, 0.0, 0.0)
        
        self.appLeftBox = gtk.VBox()
        self.appLeftAlign = gtk.Alignment()
        self.appLeftAlign.set(0.0, 0.5, 0.0, 0.0)
        self.appLeftAlign.add(self.appLeftBox)
        self.itemBox.pack_start(self.appLeftAlign)
        
        self.appBasicView = gtk.HBox()
        self.appLeftBox.pack_start(self.appBasicView, False, False)
        
        self.appIconBox = gtk.VBox()
        self.appBasicView.pack_start(self.appIconBox, False, False)
        
        self.appAdditionBox = gtk.VBox()
        self.appAdditionAlign = gtk.Alignment()
        self.appAdditionAlign.set(0.5, 0.5, 0.0, 0.0)
        self.appAdditionAlign.add(self.appAdditionBox)
        self.appBasicView.pack_start(self.appAdditionAlign, False, False)
        
        self.appTopBox = gtk.HBox()
        self.appAdditionBox.pack_start(self.appTopBox, False, False)
        
        self.appNameBox = gtk.VBox()
        self.appTopBox.pack_start(self.appNameBox, False, False)
        
        self.appFeedbackBox = gtk.VBox()
        self.appTopBox.pack_start(self.appFeedbackBox, False, False)
        
        self.appStatusBox = gtk.VBox()
        self.appAdditionBox.pack_start(self.appStatusBox, False, False)
        
        self.appSummaryBox = gtk.VBox()
        
        self.appActionBox = gtk.VBox()
        self.appActionBox.set_size_request(self.ACTION_WIDTH, -1)
        self.appActionAlign = gtk.Alignment()
        self.appActionAlign.set(0.5, 0.5, 0.0, 0.0)
        self.appActionAlign.add(self.appActionBox)
        self.itemBox.pack_start(self.appActionAlign, False, False)
        
        self.initBasicBox()
        
        self.initAdditionStatus()
        
        self.itemEventBox.add(self.itemAlign)
        self.itemFrame.add(self.itemEventBox)
        self.itemFrame.show_all()
 def createRecommendList(self, itemName, showMore, appList):
     '''Create recommend list.'''
     # Init.
     alignX = 4
     alignY = 10
     box = gtk.VBox()
     boxAlign = gtk.Alignment()
     boxAlign.set_padding(0, alignY, alignX, alignX)
     boxAlign.add(box)
     recommendNum = 5        # default is 5
     recommendIndex = 0
     
     # Add category name.
     nameBox = gtk.EventBox()
     nameBox.set_visible_window(False)
     drawTitlebar(nameBox)
     box.pack_start(nameBox, False, False)
     
     nameLabelBox = gtk.HBox()
     nameBox.add(nameLabelBox)
     
     nameLabelPaddingLeft = 20
     
     nameLabelAlign = gtk.Alignment()
     nameDLabel = DynamicSimpleLabel(
         nameLabelAlign,
         itemName,
         appTheme.getDynamicColor("recommendTitle"),
         LABEL_FONT_LARGE_SIZE,
         )
     nameLabel = nameDLabel.getLabel()
     
     nameLabelAlign.set(0.0, 0.5, 0.0, 0.0)
     nameLabelAlign.set_padding(0, 0, nameLabelPaddingLeft, 0)
     nameLabelAlign.add(nameLabel)
     nameLabelBox.pack_start(nameLabelAlign)
     
     # Show more label.
     if showMore:
         (moreLabel, moreLabelEventBox) = setDefaultClickableDynamicLabel(
             __("More >>"),
             "recommendMore",
             LABEL_FONT_MEDIUM_SIZE,
             )
         moreLabelPaddingRight = 15
         moreLabelAlign = gtk.Alignment()
         moreLabelAlign.set(1.0, 0.5, 0.0, 0.0)
         moreLabelAlign.set_padding(0, 0, 0, moreLabelPaddingRight)
         moreLabelAlign.add(moreLabelEventBox)
         nameLabelBox.pack_start(moreLabelAlign)
         
         # Switch to repository page and select category.
         categoryIndex = (map (lambda (k, _): k, CLASSIFY_LIST)).index(itemName)
         moreLabelEventBox.connect(
             "button-press-event", 
             lambda w, e: self.selectCategoryCallback(itemName, categoryIndex))
         
     # Content box.
     contentBox = gtk.HBox()
     box.pack_start(contentBox, False, False)
     
     leftLine = gtk.Image()
     drawLine(leftLine, appTheme.getDynamicColor("recommendFrame"), 1, True, LINE_LEFT)
     contentBox.pack_start(leftLine, False, False)
     
     middleBox = gtk.VBox()
     contentBox.pack_start(middleBox, False, False)
     
     rightLine = gtk.Image()
     drawLine(rightLine, appTheme.getDynamicColor("recommendFrame"), 1, True, LINE_RIGHT)
     contentBox.pack_start(rightLine, False, False)
     
     # Add application information's.
     for appName in appList:
         # You can set appList longer than 5, but those code just use first 5 that exist in local cache.
         # Longer list for protected software center won't crash if some package not exist in local cache.
         if recommendIndex < recommendNum and self.repoCache.cache.has_key(appName):
               appInfo = self.repoCache.cache[appName]
               recommendItem = RecommendItem(
                   appInfo, self.switchStatus, self.downloadQueue, self.entryDetailCallback,
                   self.ticker, self.getSelectIndex, self.setSelectIndex,
                   self.launchApplicationCallback)
               self.ticker = self.ticker + 1
               middleBox.pack_start(recommendItem.itemFrame)
               self.itemDict[appName] = recommendItem
               
               recommendIndex += 1
         else:
             print "%s not in repoCache, skip it." % (appName)
             
     # Bottom line.
     bottomLine = gtk.Image()
     drawLine(bottomLine, appTheme.getDynamicColor("recommendFrame"), 1, False, LINE_BOTTOM)
     box.pack_start(bottomLine, False, False)
 
     return boxAlign
 def initDownloadPauseStatus(self):
     '''Init download pause status.'''
     # Clean summary box first.
     utils.containerRemoveAll(self.appStatusBox)
     
     # Create status box.
     statusPaddingY = 5
     statusBox = gtk.HBox()
     statusAlign = gtk.Alignment()
     statusAlign.set(0.0, 0.5, 0.0, 0.0)
     statusAlign.set_padding(statusPaddingY, 0, 0, 0)
     statusAlign.add(statusBox)
     self.appStatusBox.pack_start(statusAlign)
     
     # Add progressbar.
     progress = self.appInfo.downloadingProgress
     progressbar = drawProgressbar(self.PROGRESS_WIDTH)
     progressbar.setProgress(progress)
     statusBox.pack_start(progressbar.box)
     self.downloadingProgressbar = progressbar
     
     # Add action box.
     utils.containerRemoveAll(self.appActionBox)
     
     actionBox = gtk.VBox()
     actionAlign = gtk.Alignment()
     actionAlign.set(0.5, 0.5, 0.0, 0.0)
     actionAlign.add(actionBox)
     self.appActionBox.pack_start(actionAlign)
     
     # Add pause icon.
     buttonPaddingY = 8
     buttonBox = gtk.HBox()
     buttonAlign = gtk.Alignment()
     buttonAlign.set(0.5, 0.0, 0.0, 0.0)
     buttonAlign.set_padding(buttonPaddingY, 0, 0, 0)
     buttonAlign.add(buttonBox)
     actionBox.pack_start(buttonAlign, False, False)
     
     continueIcon = gtk.Button()
     drawSimpleButton(continueIcon, "continue")
     continueIcon.connect("button-release-event", lambda widget, event: self.switchToDownloading())
     buttonBox.pack_start(continueIcon, False, False, self.BUTTON_PADDING_X)
     
     # Add stop icon.
     stopIcon = gtk.Button()
     drawSimpleButton(stopIcon, "stop")
     stopIcon.connect("button-release-event", lambda widget, event: self.switchToNormal())
     buttonBox.pack_start(stopIcon, False, False, self.BUTTON_PADDING_X)
     
     # Add feedback label.
     feedbackPaddingY = 5
     feedbackLabel = gtk.Label()
     feedbackLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, self.appInfo.downloadingFeedback))
     feedbackLabel.set_size_request(self.STATUS_WIDTH, -1)
     feedbackAlign = gtk.Alignment()
     feedbackAlign.set(1.0, 0.0, 0.0, 0.0)
     feedbackAlign.set_padding(feedbackPaddingY, 0, 0, 0)
     feedbackAlign.add(feedbackLabel)
     self.downloadingFeedbackLabel = feedbackLabel
     actionBox.pack_start(feedbackAlign)
Пример #13
0
    # Init application.
    application = Application()

    # Set application default size.
    application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)

    # Set application icon.
    application.set_icon(os.path.join(get_current_dir(__file__), "icon.ico"))
    
    # Set application preview pixbuf.
    application.set_skin_preview(os.path.join(get_current_dir(__file__), "frame.png"))
    
    # Add titlebar.
    application.add_titlebar(
        ["theme", "max", "min", "close"], 
        os.path.join(get_current_dir(__file__), "logo.png"), 
        "DateTime demo",
        "DateTime demo",
        )
    
    datetime = DateTimeHTCStyle(sec_visible = True)
    datetime.set_is_24hour(False)
    #datetime = DateTime()
    align = gtk.Alignment()                                             
    align.set(0, 0, 0, 0)                                           
    align.set_padding(10, 10, 10, 10)
    align.add(datetime)
    application.main_box.pack_start(align)

    application.run()
Пример #14
0
    def __init__(self, param, scope=None, name=None, ident=None):

        debug.mainthreadTest()
        self.ident = ident or param.ident

        self.lastFile = {}  # last file selected in each directory
        self.fileNames = []  # files in the current directory
        self.dirHier = []  # directories in the current hierarchy
        self.dirHistory = ringbuffer.RingBuffer(50)

        parameterwidgets.ParameterWidget.__init__(self,
                                                  gtk.Frame(),
                                                  scope,
                                                  name,
                                                  expandable=True)
        vbox = gtk.VBox()
        self.gtk.add(vbox)

        # Directory selector
        hbox = gtk.HBox()
        vbox.pack_start(hbox, expand=False, fill=False)
        hbox.pack_start(gtk.Label("Directory:"), expand=False, fill=False)
        self.dirWidget = chooser.ChooserComboWidget([],
                                                    callback=self.dirChangedCB,
                                                    name="Directory")
        hbox.pack_start(self.dirWidget.gtk, expand=True, fill=True)

        # Directory selection buttons
        hbox = gtk.HBox(homogeneous=False)
        vbox.pack_start(hbox, expand=False, fill=False)

        self.backbutton = gtkutils.StockButton(gtk.STOCK_GO_BACK,
                                               "Back",
                                               align=0.0)
        gtklogger.setWidgetName(self.backbutton, "Back")
        gtklogger.connect(self.backbutton, 'clicked', self.backCB)
        hbox.pack_start(self.backbutton, expand=True, fill=True)

        self.addDirButtons(hbox)

        homebutton = gtkutils.StockButton(gtk.STOCK_HOME)
        gtklogger.setWidgetName(homebutton, "Home")
        gtklogger.connect(homebutton, 'clicked', self.homeCB)
        hbox.pack_start(homebutton, expand=False, fill=True)

        self.nextbutton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD,
                                               "Next",
                                               reverse=True,
                                               align=1.0)
        gtklogger.setWidgetName(self.nextbutton, "Next")
        gtklogger.connect(self.nextbutton, 'clicked', self.nextCB)
        hbox.pack_start(self.nextbutton, expand=True, fill=True)

        # File list
        self.fileList = chooser.ScrolledChooserListWidget(
            name="FileList",
            callback=self.fileListCB,
            dbcallback=self.fileListDoubleCB,
            markup=True)
        self.fileList.gtk.set_size_request(-1, 100)
        vbox.pack_start(self.fileList.gtk, expand=True, fill=True)
        # Set the comparison function used when typing in the file
        # list.  _filename_cmp matches the beginnings of file names,
        # ignoring the markup added to directories and escaped
        # characters.
        if use_markup:
            self.fileList.treeview.set_search_equal_func(_filename_cmp, None)

        align = gtk.Alignment(xalign=1.0)
        vbox.pack_start(align, expand=False, fill=False)
        hbox = gtk.HBox()
        align.add(hbox)
        hbox.pack_start(gtk.Label("show hidden files"),
                        expand=False,
                        fill=False)
        self.hiddenButton = gtk.CheckButton()
        hbox.pack_start(self.hiddenButton, expand=False, fill=False)
        gtklogger.setWidgetName(self.hiddenButton, "ShowHidden")
        gtklogger.connect(self.hiddenButton, 'clicked', self.showHiddenCB)

        # Include additional widgets required by subclasses.
        self.addMoreWidgets(vbox)

        # Set initial state.
        if param.value is not None:
            directory, phile = os.path.split(param.value)
            # param.value might not have a directory component,
            # especially if the last value was set by a script or
            # command line argument.
            if not directory or not os.path.isdir(directory):
                directory = _last_dir.get(self.ident,
                                          os.path.abspath(os.getcwd()))
        else:
            directory = _last_dir.get(self.ident, os.path.abspath(os.getcwd()))
            phile = _last_file.get(self.ident, None)
        self.hiddenButton.set_active(_last_hid.get(self.ident, False))
        directory = endSlash(directory)
        self.lastFile[directory] = phile
        self.dirHistory.push(directory)
        self.dirWidget.suppress_signals()
        self.dirHier = getDirectoryHierarchy(directory)
        self.dirWidget.update(self.dirHier)
        self.dirWidget.set_state(directory)
        self.dirWidget.allow_signals()

        self.fileList.suppress_signals()
        self.updateFiles(directory)
        if phile:
            self.fileList.set_selection(phile)
        self.fileList.allow_signals()

        self.initializeExtras(directory, phile)

        self.sensitize()
        self.widgetChanged(self.checkValidity(), interactive=False)
Пример #15
0
    def init_share_box(self):
        '''get weibo info, and create button'''
        self.to_share_weibo = {}
        self.to_share_weibo_res = {}
        self.deepin_info = {}
        self.is_get_user_info = {}
        self.__weibo_check_button_list = []
        self.__weibo_image_button_list = []

        # create Thumbnail
        if exists(self.upload_image):
            pixbuf = gtk.gdk.pixbuf_new_from_file(self.upload_image)
            pix_w = pixbuf.get_width()
            pix_h = pixbuf.get_height()
            if pix_w > pix_h:
                pix_s_w = self.thumb_width
                pix_s_h = int(pix_h / (float(pix_w) / self.thumb_width))
            else:
                pix_s_h = self.thumb_height
                pix_s_w = int(pix_w / (float(pix_h) / self.thumb_height))
            pixbuf = pixbuf.scale_simple(pix_s_w, pix_s_h, gtk.gdk.INTERP_TILES)
            thumb = gtk.image_new_from_pixbuf(pixbuf)
        else:
            thumb = gtk.Image()
        thumb.set_size_request(self.thumb_width, self.thumb_height)

        # weibo context input
        text_box = gtk.HBox(False, 2)
        text_vbox = gtk.VBox(False, 2)
        text_bg_vbox = gtk.VBox(False)
        text_bg_align = gtk.Alignment()
        text_bg_align.set(0.5, 0.5, 0, 0)
        text_bg_align.set_padding(5, 5, 16, 5)
        text_bg_align.connect("expose-event", self.text_view_bg_expose)
        text_scrolled_win = ScrolledWindow()
        text_scrolled_win.set_size_request(340, 157)

        text_view = gtk.TextView()
        text_view.set_left_margin(10)
        text_view.set_right_margin(10)
        text_view.set_pixels_above_lines(5)
        text_view.set_pixels_below_lines(5)
        text_view.set_wrap_mode(gtk.WRAP_WORD| gtk.WRAP_CHAR)
        text_view.connect("expose-event", self.text_view_expose)
        buf = text_view.get_buffer()
        text_scrolled_win.add(text_view)
        text_bg_vbox.pack_start(text_scrolled_win)
        text_bg_align.add(text_bg_vbox)

        text_align = gtk.Alignment() 
        text_align.set(0.5, 0.5, 0, 0)
        text_align.set_padding(25, 30, 10, 10)

        text_box.pack_start(thumb, False, False, 10)
        text_box.pack_start(text_bg_align)
        text_vbox.pack_start(text_box, False, False, 10)

        text_align.add(text_vbox)
        #tmp_align = gtk.Alignment()
        #tmp_align.set(0.5, 0, 0, 1)
        #self.share_box.pack_start(tmp_align, False, False)
        self.share_box.pack_start(text_align, False, False)

        # dialog button box
        left_box = self.window.left_button_box
        right_box = self.window.right_button_box

        # input tip label
        self.input_num_label = Label("%d" % self.MAX_CHAR,
            text_size=16, text_x_align=pango.ALIGN_CENTER, label_width=50, enable_select=False)
        self.input_num_label.text_color = app_theme.get_color("left_char_num")

        # login box
        #weibo_box = gtk.HBox(False, 1)
        #weibo_box.set_size_request(-1, 50)
        weibo_box_list = []
        self.loading_label = Label("%s..." % _("loading"), text_size=12,
            label_width=70, enable_select=False)
        weibo_box_list.append(self.loading_label)

        for weibo in self.__weibo_list:
            box = gtk.HBox(False, 2)
            weibo.set_box(box)
            weibo_box_list.append(box)
        left_box.set_buttons(weibo_box_list)

        # share button
        button = Button(_("Tweet"))
        #button.set_size_request(75, 25)
        button.connect("clicked", self.share_button_clicked, text_view)
        buf.connect("changed", self.text_view_changed, button)  # check char num

        tmp_vbox = gtk.VBox(False)
        tmp_align = gtk.Alignment()
        tmp_align.set(0.5, 0.5, 0, 0)
        tmp_vbox.pack_start(button, False, False)
        #tmp_vbox.pack_start(tmp_align)
        tmp_align.add(tmp_vbox)
        right_box.set_buttons([self.input_num_label, tmp_align])

        # at first, set widget insensitive
        button.set_sensitive(False)
        text_view.set_editable(False)
        t = threading.Thread(target=self.init_user_info_thread, args=(button, text_view))
        t.setDaemon(True)
        t.start()
Пример #16
0
    def display_tab(self, cbs):
        """Construct and layout the display tab"""
        displaylabel = ui.label(markup='<b>' + _('Display') + '</b>')
        frame = gtk.Frame()
        frame.set_label_widget(displaylabel)
        frame.set_shadow_type(gtk.SHADOW_NONE)

        art = gtk.CheckButton(_("_Album art"))
        art.set_active(self.config.show_covers)
        stylized_combo = ui.combo(items=[_("Standard"),
                                         _("Stylized")],
                                  active=self.config.covers_type,
                                  changed_cb=cbs.stylized_toggled)
        stylized_hbox = gtk.HBox(spacing=12)
        stylized_hbox.pack_end(stylized_combo, False, False)
        stylized_hbox.pack_end(ui.label(text=_("Artwork style:")), False,
                               False)
        stylized_hbox.set_sensitive(self.config.show_covers)
        art_combo = ui.combo(items=[_("Local only"),
                                    _("Local and remote")],
                             active=self.config.covers_pref)
        art_combo.connect('changed', self._config_widget_active, 'covers_pref')
        orderart_label = ui.label(text=_("Search locations:"))
        art_hbox = gtk.HBox(spacing=12)
        art_hbox.pack_end(art_combo, False, False)
        art_hbox.pack_end(orderart_label, False, False)
        art_hbox.set_sensitive(self.config.show_covers)

        art_paths = ["~/.covers/"]
        art_paths += ("%s/%s" % (_("SONG_DIR"), item)
                      for item in ("cover.jpg", "album.jpg", "folder.jpg",
                                   _("custom")))
        art_location = ui.combo(items=art_paths,
                                active=self.config.art_location,
                                changed_cb=self._art_location_changed)

        art_location_hbox = gtk.HBox(spacing=12)
        art_location_hbox.pack_end(art_location, False, False)
        art_location_hbox.pack_end(ui.label(text=_("Save art to:")), False,
                                   False)
        art_location_hbox.set_sensitive(self.config.show_covers)
        art.connect('toggled', cbs.art_toggled, art_hbox, art_location_hbox,
                    stylized_hbox)
        playback = gtk.CheckButton(_("_Playback/volume buttons"))
        playback.set_active(self.config.show_playback)
        playback.connect('toggled', cbs.playback_toggled)
        progress = gtk.CheckButton(_("Pr_ogressbar"))
        progress.set_active(self.config.show_progress)
        progress.connect('toggled', cbs.progress_toggled)
        statusbar = gtk.CheckButton(_("_Statusbar"))
        statusbar.set_active(self.config.show_statusbar)
        statusbar.connect('toggled', cbs.statusbar_toggled)
        lyrics = gtk.CheckButton(_("Song Ly_rics"))
        lyrics.set_active(self.config.show_lyrics)
        savelyrics_label = ui.label(text=_("Save lyrics to:"), x=1)
        lyrics_location = ui.combo(items=["~/.lyrics/",
                                          _("SONG_DIR") + "/"],
                                   active=self.config.lyrics_location,
                                   changed_cb=self._lyrics_location_changed)
        lyrics_location_hbox = gtk.HBox(spacing=12)
        lyrics_location_hbox.pack_end(lyrics_location, False, False)
        lyrics_location_hbox.pack_end(savelyrics_label, False, False)
        lyrics_location_hbox.set_sensitive(self.config.show_lyrics)
        lyrics.connect('toggled', cbs.lyrics_toggled, lyrics_location_hbox)
        trayicon = gtk.CheckButton(_("System _tray icon"))
        self.display_trayicon = trayicon
        trayicon.set_active(self.config.show_trayicon)
        trayicon.set_sensitive(cbs.trayicon_available)

        widgets = (playback, progress, statusbar, trayicon, lyrics,
                   lyrics_location_hbox, art, stylized_hbox, art_hbox,
                   art_location_hbox)
        table = gtk.Table(len(widgets), 1, False)
        for i, widget in enumerate(widgets):
            table.attach(widget, 0, 1, i, i + 1, gtk.FILL | gtk.EXPAND,
                         gtk.FILL)
        alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        alignment.set_padding(12, 0, 12, 0)
        alignment.add(table)
        frame.add(alignment)
        tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        tab.set_padding(12, 12, 12, 12)
        tab.add(frame)

        return tab
Пример #17
0
    def share_to_weibo_result(self):
        '''result of share to weibo'''
        font_color = app_theme.get_color("share_result_text")
        res_hbox = gtk.HBox(False)
        res_hbox.set_size_request(-1, 240)

        res_left_box = DialogLeftButtonBox()
        res_right_box = DialogRightButtonBox()

        res_left_box.button_align.set(0.5, 0.0, 0, 1)
        res_right_box.button_align.set(0.5, 0.0, 0, 1)
        res_left_box.button_align.set_padding(5, 9, 19, 0)
        res_right_box.button_align.set_padding(30, 0, 0, 0)

        res_left_box.set_size_request(405, -1)
        res_right_box.set_size_request(195, -1)
        
        res_hbox.pack_start(res_left_box)
        res_hbox.pack_start(
            VSeparator(app_theme.get_shadow_color("VSeparator").get_color_info(), 0, 0))
        res_hbox.pack_start(res_right_box)

        res_vbox = gtk.VBox(False)
        follow_vbox = gtk.VBox(False)

        tmp_img = gtk.Image()       # only use as a placeholder
        tmp_img.set_size_request(-1, 50) 
        res_vbox.pack_start(tmp_img, False, False)

        follow_tip_hbox = gtk.HBox(False)
        img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/deepin_logo.png"))
        follow_tip_hbox.pack_start(img, False, False, 5)
        follow_tip_hbox.pack_start(
            Label("%s %s" % (_("Follow"), "Linux Deepin"), 
                text_color=app_theme_get_dynamic_color("#5f5f5f"),
                text_size=12, enable_select=False), False, False)
        follow_vbox.pack_start(follow_tip_hbox, False, False, 13)
        for weibo in self.to_share_weibo_res:
            vbox = gtk.VBox(False, 1)
            tip_box = gtk.HBox()
            error_box = gtk.HBox()
            vbox.pack_start(tip_box, False, False)
            vbox.pack_start(error_box, False, False)
            if self.to_share_weibo_res[weibo][0]:   # upload succeed
                img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_succeed.png"))
                #link = LinkButton(_(weibo.t_type), text_size=13, self.to_share_weibo_res[weibo][1])
                link = Label(_(weibo.t_type), text_size=12, 
                    text_color=app_theme.get_color("link_text"))
                #, enable_gaussian=True, gaussian_radious=1, border_radious=0)
                link.add_events(gtk.gdk.BUTTON_PRESS_MASK)
                link.connect("enter-notify-event", lambda w, e: self.__draw_under_line(w))
                link.connect("leave-notify-event", lambda w, e: w.queue_draw())
                link.connect("button-press-event", self.goto_weibo_button_clicked, weibo)
                link_box = gtk.HBox(False)
                link_box.pack_start(link, False, False)
                utils.set_clickable_cursor(link)
                text = _("upload to")
                label = Label(text, text_size=12, 
                    text_color=font_color, enable_select=False)
                text = _("successful")
                label1 = Label(text, text_size=12, 
                    text_color=font_color, enable_select=False)
                tip_box.pack_start(img, False, False, 15)
                tip_box.pack_start(label, False, False, 3)
                tip_box.pack_start(link_box, False, False, 3)
                tip_box.pack_start(label1, False, False)
                # only use as a placeholder
                img = gtk.Image()
                img.set_size_request(20, 1)
                error_box.pack_start(img, False, False, 16)
                tmp = Label(" ", text_size=9, label_width=200)
                tmp.set_size_request(200, 1)
                error_box.pack_start(tmp, False, False)
                #print text
            else:   # upload failed
                img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_failed.png"))
                #text = "% %s %s." % (_(weibo.t_type), _("upload failed"))
                text = _("upload to")
                label1 = Label(text, text_size=12, 
                    text_color=font_color, enable_select=False)
                label2 = Label(_(weibo.t_type), text_size=12, 
                    text_color=font_color, enable_select=False)
                text = _("failed")
                label3 = Label(text, text_size=12, 
                    text_color=font_color, enable_select=False)
                if weibo.curl.error:
                    error = "(%s)" % _(weibo.curl.error)
                elif weibo.get_error_msg():
                    error = "(%s)" % _(weibo.get_error_msg()) 
                else:
                    error = "(%s)" % _("Unknow reason")
                #print "%s: %s" % (weibo.t_type, error)
                #print "%s: %s" % (weibo.t_type, weibo.get_error_msg())
                label = Label(text, text_size=12,
                    text_color=font_color, enable_select=False)
                tip_box.pack_start(img, False, False, 15)
                tip_box.pack_start(label1, False, False, 3)
                tip_box.pack_start(label2, False, False, 3)
                tip_box.pack_start(label3, False, False)
                img = gtk.Image()   # only use as a placeholder
                img.set_size_request(20, 20)
                error_box.pack_start(img, False, False, 16)
                error_box.pack_start(Label(error, text_size=9, label_width=200,
                    text_color=font_color, enable_select=False), False, False)
                #print text
            res_vbox.pack_start(vbox, False, False, 10)

        for weibo in self.deepin_info:
            box = gtk.HBox(False, 15)
            # followed
            img = gtk.image_new_from_pixbuf(app_theme.get_pixbuf("share/"+weibo.t_type+".png").get_pixbuf())
            box.pack_start(img, False, False)
            if self.deepin_info[weibo] is not None and self.deepin_info[weibo][3]:
                if not default_locale.startswith("zh_"):
                    button = gtk.image_new_from_pixbuf(
                        app_theme.get_pixbuf("share/followed_en.png").get_pixbuf())
                else:
                    button = gtk.image_new_from_pixbuf(
                        app_theme.get_pixbuf("share/followed.png").get_pixbuf())
            else:   # to follow
                if not default_locale.startswith("zh_"):
                    button = ImageButton(
                        app_theme.get_pixbuf("share/follow_normal_en.png"),
                        app_theme.get_pixbuf("share/follow_hover_en.png"),
                        app_theme.get_pixbuf("share/follow_press_en.png"))
                else:
                    button = ImageButton(
                        app_theme.get_pixbuf("share/follow_normal.png"),
                        app_theme.get_pixbuf("share/follow_hover.png"),
                        app_theme.get_pixbuf("share/follow_press.png"))
                button.connect("clicked", self.friendships_add_button_clicked, weibo, box)
            box.pack_start(button, False, False)
            align = gtk.Alignment()
            align.set(0.0, 0.5, 0, 0)
            align.set_padding(0, 0, 30, 0)
            align.add(box)
            follow_vbox.pack_start(align, False, False, 8)

        res_left_box.set_buttons([res_vbox])
        res_right_box.set_buttons([follow_vbox])

        self.result_box.pack_start(res_hbox, False, False)
        self.result_box.show_all()
        self.set_slide_index(2)
Пример #18
0
    def behavior_tab(self, cbs):
        """Construct and layout the behavior tab"""
        windowlabel = ui.label(markup='<b>' + _('Window Behavior') + '</b>')
        frame = gtk.Frame()
        frame.set_label_widget(windowlabel)
        frame.set_shadow_type(gtk.SHADOW_NONE)
        sticky = gtk.CheckButton(_("_Show window on all workspaces"))
        sticky.set_active(self.config.sticky)
        sticky.connect('toggled', cbs.sticky_toggled)
        ontop = gtk.CheckButton(_("_Keep window above other windows"))
        ontop.set_active(self.config.ontop)
        ontop.connect('toggled', cbs.ontop_toggled)
        decor = gtk.CheckButton(_("_Hide window titlebar"))
        decor.set_active(not self.config.decorated)
        decor.connect('toggled', cbs.decorated_toggled, self.prefswindow)
        minimize = gtk.CheckButton(
            _("_Minimize to system tray on close/escape"))
        minimize.set_active(self.config.minimize_to_systray)
        minimize.set_tooltip_text(
            _("If enabled, closing Sonata will minimize it to the system tray. Note that it's currently impossible to detect if there actually is a system tray, so only check this if you have one."
              ))
        minimize.connect('toggled', self._config_widget_active,
                         'minimize_to_systray')
        self.display_trayicon.connect('toggled', cbs.trayicon_toggled,
                                      minimize)
        minimize.set_sensitive(cbs.trayicon_in_use)
        widgets = (sticky, ontop, decor, minimize)
        table = gtk.Table(len(widgets), 1)
        for i, widget in enumerate(widgets):
            table.attach(widget, 0, 1, i, i + 1, gtk.FILL | gtk.EXPAND,
                         gtk.FILL)
        alignment = gtk.Alignment()
        alignment.set_padding(12, 0, 12, 0)
        alignment.add(table)
        frame.add(alignment)

        misclabel = ui.label(markup='<b>' + _('Miscellaneous') + '</b>')
        misc_frame = gtk.Frame()
        misc_frame.set_label_widget(misclabel)
        misc_frame.set_shadow_type(gtk.SHADOW_NONE)
        update_start = gtk.CheckButton(_("_Update MPD library on start"))
        update_start.set_active(self.config.update_on_start)
        update_start.set_tooltip_text(
            _("If enabled, Sonata will automatically update your MPD library when it starts up."
              ))
        update_start.connect('toggled', self._config_widget_active,
                             'update_on_start')
        exit_stop = gtk.CheckButton(_("S_top playback on exit"))
        exit_stop.set_active(self.config.stop_on_exit)
        exit_stop.set_tooltip_text(
            _("MPD allows playback even when the client is not open. If enabled, Sonata will behave like a more conventional music player and, instead, stop playback upon exit."
              ))
        exit_stop.connect('toggled', self._config_widget_active,
                          'stop_on_exit')
        infofile_usage = gtk.CheckButton(_("_Write status file:"))
        infofile_usage.set_active(self.config.use_infofile)
        infofile_usage.set_tooltip_text(
            _("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"
              ))
        infopath_options = ui.entry(text=self.config.infofile_path)
        infopath_options.set_tooltip_text(
            _("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"
              ))
        infopath_options.connect('focus_out_event', cbs.infofile_changed)
        infopath_options.connect('activate', cbs.infofile_changed, None)
        if not self.config.use_infofile:
            infopath_options.set_sensitive(False)
        infofile_usage.connect('toggled', self._infofile_toggled,
                               infopath_options)
        infofilebox = gtk.HBox(spacing=6)
        infofilebox.pack_start(infofile_usage, False, False)
        infofilebox.pack_start(infopath_options, True, True)
        widgets = (update_start, exit_stop, infofilebox)
        misc_table = gtk.Table(len(widgets), 1)
        for i, widget in enumerate(widgets):
            misc_table.attach(widget, 0, 1, i, i + 1, gtk.FILL | gtk.EXPAND,
                              gtk.FILL)
        misc_alignment = gtk.Alignment()
        misc_alignment.set_padding(12, 0, 12, 0)
        misc_alignment.add(misc_table)
        misc_frame.add(misc_alignment)

        table = gtk.Table(2, 1)
        table.set_row_spacings(12)
        table.attach(frame, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL)
        table.attach(misc_frame, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL)
        tab = gtk.Alignment()
        tab.set_padding(12, 12, 12, 12)
        tab.add(table)
        return tab
Пример #19
0
def create_right_align(paddings=None):
    align = gtk.Alignment()
    if paddings:
        align.set_padding(*paddings)
    align.set(0, 0, 0, 1)
    return align
Пример #20
0
    def format_tab(self, cbs):
        """Construct and layout the format tab"""
        formatlabel = ui.label(markup='<b>' + _('Song Formatting') + '</b>')
        frame = gtk.Frame()
        frame.set_label_widget(formatlabel)
        frame.set_shadow_type(gtk.SHADOW_NONE)

        rows = [(_("C_urrent playlist:"), self.config.currentformat),
                (_("_Library:"), self.config.libraryformat),
                (_("_Window title:"), self.config.titleformat),
                (_("Current _song line 1:"), self.config.currsongformat1),
                (_("Current s_ong line 2:"), self.config.currsongformat2)]

        labels = []
        entries = []
        for label_text, entry_text in rows:
            label = ui.label(textmn=label_text)
            entry = ui.entry(text=entry_text)

            label.set_mnemonic_widget(entry)

            labels.append(label)
            entries.append(entry)

        entry_cbs = (cbs.currentoptions_changed, cbs.libraryoptions_changed,
                     cbs.titleoptions_changed, cbs.currsongoptions1_changed,
                     cbs.currsongoptions2_changed)
        for entry, cb, next in zip(entries, entry_cbs,
                                   entries[1:] + entries[:1]):
            entry.connect('focus_out_event', cb)
            entry.connect('activate', lambda _, n: n.grab_focus(), next)

        availableheading = ui.label(markup='<small>' + _('Available options') +
                                    ':</small>')
        availablevbox = gtk.VBox()
        availableformatbox = gtk.HBox()
        formatcodes = formatting.formatcodes
        for codes in [
                formatcodes[:(len(formatcodes) + 1) / 2],
                formatcodes[(len(formatcodes) + 1) / 2:]
        ]:
            rows = '\n'.join('<tt>%%%s</tt> - %s' %
                             (code.code, code.description) for code in codes)
            markup = '<small>' + rows + '</small>'
            formattinghelp = ui.label(markup=markup)
            availableformatbox.pack_start(formattinghelp)

        availablevbox.pack_start(availableformatbox, False, False, 0)
        additionalinfo = ui.label(
            markup='<small><tt>{ }</tt> - ' +
            _('Info displayed only if all enclosed tags are defined') +
            '\n<tt>|</tt> - ' + _('Creates columns in the current playlist') +
            '</small>')
        availablevbox.pack_start(additionalinfo, False, False, 4)

        num_rows = len(rows) + 2
        table = gtk.Table(num_rows, 2)
        table.set_col_spacings(12)
        label_entries = enumerate(zip(labels, entries))
        for i, (label, entry) in label_entries:
            table.attach(label, 0, 1, i, i + 1, gtk.FILL)
            table.attach(entry, 1, 2, i, i + 1)
        table.attach(availableheading, 0, 2, num_rows - 2, num_rows - 1,
                     gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 0, 6)
        table.attach(availablevbox, 0, 2, num_rows - 1, num_rows)
        alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        alignment.set_padding(12, 0, 12, 0)
        alignment.add(table)
        frame.add(alignment)
        tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        tab.set_padding(12, 12, 12, 12)
        tab.add(frame)
        return tab
Пример #21
0
def create_bottom_align(paddings=None):
    align = gtk.Alignment()
    if paddings:
        align.set_padding(paddings=None)
    align.set(0, 1, 0, 0)
    return align
Пример #22
0
    def __init__(self, parent):
        gtk.Window.__init__(self)

        self.what = _('What is happening?')
        self.blocked = False
        self.mainwin = parent
        #self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.set_title(_('Update status'))
        self.set_resizable(False)
        #self.set_default_size(500, 120)
        self.set_size_request(500, 150)
        self.set_transient_for(parent)
        #self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self.label = gtk.Label()
        self.label.set_use_markup(True)
        self.label.set_alignment(0, 0.5)
        self.label.set_markup('<span size="medium"><b>%s</b></span>' %
                              self.what)
        self.label.set_justify(gtk.JUSTIFY_LEFT)

        self.num_chars = gtk.Label()
        self.num_chars.set_use_markup(True)
        self.num_chars.set_markup(
            '<span size="14000" foreground="#999"><b>140</b></span>')

        self.update_text = MessageTextView()
        self.update_text.set_border_width(2)
        self.update_text.set_left_margin(2)
        self.update_text.set_right_margin(2)
        self.update_text.set_wrap_mode(gtk.WRAP_WORD)
        buffer = self.update_text.get_buffer()

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.add(self.update_text)

        updatebox = gtk.HBox(False)
        updatebox.pack_start(scroll, True, True, 3)

        self.url = gtk.Entry()
        self.url.connect('changed', self.__on_url_changed)
        self.btn_url = gtk.Button(_('Shorten URL'))
        self.btn_url.set_tooltip_text(_('Shorten URL'))

        tools = gtk.HBox(False)
        tools.pack_start(self.url, True, True, 3)
        tools.pack_start(self.btn_url, False, False)

        self.toolbox = gtk.Expander()
        self.toolbox.set_label(_('Options'))
        self.toolbox.set_expanded(False)
        self.toolbox.add(tools)

        self.btn_clr = gtk.Button()
        self.btn_clr.set_image(self.mainwin.load_image('action-clear.png'))
        self.btn_clr.set_tooltip_text(_('Clear all') + ' (Ctrl+L)')
        self.btn_clr.set_relief(gtk.RELIEF_NONE)

        self.btn_frn = gtk.Button()
        self.btn_frn.set_image(
            self.mainwin.load_image('action-add-friends.png'))
        self.btn_frn.set_tooltip_text(_('Add friends') + ' (Ctrl+F)')
        self.btn_frn.set_relief(gtk.RELIEF_NONE)

        self.btn_upd = gtk.Button(_('Tweet'))
        self.btn_upd.set_tooltip_text(_('Update your status') + ' (Ctrl+T)')
        chk_short = gtk.CheckButton(_('Autoshort URLs'))
        chk_short.set_sensitive(False)

        top = gtk.HBox(False)
        top.pack_start(self.label, True, True, 5)
        top.pack_start(self.num_chars, False, False, 5)

        self.waiting = CairoWaiting(parent)
        self.lblerror = gtk.Label()
        self.lblerror.set_use_markup(True)
        error_align = gtk.Alignment(xalign=0.0)
        error_align.add(self.lblerror)

        buttonbox = gtk.HBox(False)
        #buttonbox.pack_start(chk_short, False, False, 0)
        buttonbox.pack_start(self.btn_frn, False, False, 0)
        buttonbox.pack_start(self.btn_clr, False, False, 0)
        buttonbox.pack_start(gtk.HSeparator(), False, False, 2)
        buttonbox.pack_start(self.btn_upd, False, False, 0)
        abuttonbox = gtk.Alignment(1, 0.5)
        abuttonbox.add(buttonbox)

        bottom = gtk.HBox(False)
        bottom.pack_start(self.waiting, False, False, 5)
        bottom.pack_start(error_align, True, True, 4)
        bottom.pack_start(abuttonbox, True, True, 5)

        vbox = gtk.VBox(False)
        vbox.pack_start(top, False, False, 2)
        vbox.pack_start(updatebox, True, True, 2)
        vbox.pack_start(bottom, False, False, 2)
        vbox.pack_start(self.toolbox, False, False, 2)

        self.add(vbox)

        self.connect('key-press-event', self.__detect_shortcut)
        self.connect('delete-event', self.__unclose)
        buffer.connect('changed', self.count_chars)
        self.btn_frn.connect('clicked', self.show_friend_dialog)
        self.btn_clr.connect('clicked', self.clear)
        self.btn_upd.connect('clicked', self.update)
        self.btn_url.connect('clicked', self.short_url)
        self.btn_url.set_sensitive(False)
        self.toolbox.connect('activate', self.show_options)
        self.update_text.connect('mykeypress', self.__on_key_pressed)

        if SPELLING:
            try:
                self.spell = gtkspell.Spell(self.update_text)
            except Exception, e_msg:
                # FIXME: Usar el log
                print 'DEBUG:UI:Can\'t load gtkspell -> %s' % e_msg
    def show(self, scrollToTop=True):
        '''Show application view.'''
        # Remove child widgets first.
        utils.containerRemoveAll(self.box)
        self.itemDict.clear()

        # If i don't re-connect self.eventbox and self.box,
        # update view will show nothing.
        # I still can't understand why?
        # Maybe this is bug of GtkEventBox?
        utils.containerRemoveAll(self.eventbox)
        self.eventbox.add(self.box)

        if self.appNum == 0:
            if (getDefaultLanguage() == "default"):
                paddingX = 10
            else:
                paddingX = 0

            notifyBox = gtk.VBox()
            notifyAlign = gtk.Alignment()
            notifyAlign.set(0.5, 0.5, 0.0, 0.0)
            notifyAlign.add(notifyBox)
            self.box.pack_start(notifyAlign)

            tipImage = gtk.image_new_from_pixbuf(
                gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/updateTip.png" %
                                             (getDefaultLanguage())))
            tipAlign = gtk.Alignment()
            tipAlign.set_padding(0, 0, paddingX, 0)
            tipAlign.add(tipImage)
            notifyBox.pack_start(tipAlign)

            penguinImage = gtk.image_new_from_pixbuf(
                gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
            penguinAlign = gtk.Alignment()
            penguinAlign.set_padding(0, 0, 0, paddingX)
            penguinAlign.add(penguinImage)
            notifyBox.pack_start(penguinAlign)

            self.box.show_all()
        else:
            # Get application list.
            appList = self.getListFunc((self.pageIndex - 1) * self.defaultRows,
                                       min(self.pageIndex * self.defaultRows,
                                           self.appNum))

            # Create application view.
            self.box.pack_start(self.createAppList(appList))

            # Create index view.
            indexbar = self.createIndexbar()
            if not indexbar == None:
                self.box.pack_start(indexbar)

            self.box.show_all()

            # Request vote data.
            self.fetchVoteCallback(
                PAGE_UPGRADE,
                map(lambda appInfo: utils.getPkgName(appInfo.pkg), appList))

        # Scroll ScrolledWindow to top after render.
        if scrollToTop:
            utils.scrollToTop(self.scrolledwindow)
Пример #24
0
    #win = gtk.Window()
    #win.connect("destroy", gtk.main_quit)
    #win.set_size_request(400, 250)

    app = dtk.ui.application.Application()
    app.set_default_size(400, 250)
    app.add_titlebar(
        ["theme", "menu", "max", "min", "close"],
        None,
        "深度图形库",
        "/home/andy/deepin-ui/loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooony.py",
    )

    slider = dtk.ui.slider.HSlider()
    label = dtk.ui.label.Label("Slider Demo")
    label_align = gtk.Alignment(0.5, 0.5, 0, 0)
    label_align.add(label)
    slider.to_page_now(label_align)

    widget1 = gtk.Alignment(0.5, 0.5, 0, 0)
    button1 = dtk.ui.button.Button()
    button1.set_size_request(200, 22)
    widget1.add(button1)

    widget2 = gtk.Alignment(0.5, 0.5, 0, 0)
    button2 = gtk.Button("Button2")
    widget2.add(button2)

    widget3 = gtk.Alignment(0.5, 0.5, 0, 0)
    text_entry = dtk.ui.entry.InputEntry()
    text_entry.set_size(100, 22)
Пример #25
0
    def __init__(self, label=None):
        gtk.Frame.__init__(self)
        
        self.set_shadow_type(gtk.SHADOW_NONE)
        self._flabel = gtk.Label()
        self._set_label(label)
        self.set_label_widget(self._flabel)

    def _set_label(self, label):
        self._flabel.set_markup("<b>%s</b>" % label)

# Demo
if __name__ == "__main__":
    w = gtk.Window()

    hframe = HIGFrame("Sample HIGFrame")
    aalign = gtk.Alignment(0, 0, 0, 0)
    aalign.set_padding(12, 0, 24, 0)
    abox = gtk.VBox()
    aalign.add(abox)
    hframe.add(aalign)
    w.add(hframe)

    for i in xrange(5):
        abox.pack_start(gtk.Label("Sample %d" % i), False, False, 3)

    w.connect('destroy', lambda d: gtk.main_quit())
    w.show_all()
    
    gtk.main()
    def __adjust_widget(self):
        MID_SPACING = 10
        self.alignment_widgets["main_hbox"].add(
            self.container_widgets["main_hbox"])
        self.alignment_widgets["main_hbox"].set(0, 0, 1, 1)
        self.alignment_widgets["main_hbox"].set_padding(
            TEXT_WINDOW_TOP_PADDING - 25, 0, TEXT_WINDOW_LEFT_PADDING - 40,
            TEXT_WINDOW_RIGHT_WIDGET_PADDING)

        self.container_widgets["main_hbox"].set_spacing(MID_SPACING)
        self.container_widgets["main_hbox"].pack_start(
            self.container_widgets["left_vbox"])
        #self.container_widgets["main_hbox"].pack_start(self.alignment_widgets["right_vbox"])

        self.container_widgets["left_vbox"].pack_start(
            self.image_widgets["logo"], False, False)
        #self.container_widgets["left_vbox"].pack_start(self.alignment_widgets["logo"])
        self.container_widgets["left_vbox"].pack_start(
            self.alignment_widgets["right_vbox"])
        #self.alignment_widgets["logo"].set(0, 0, 1, 1)
        self.alignment_widgets["right_vbox"].set(0, 0, 1, 1)
        self.alignment_widgets["right_vbox"].set_padding(0, 0, 100, 0)
        self.alignment_widgets["right_vbox"].add(
            self.container_widgets["right_vbox"])

        self.container_widgets["right_vbox"].set_spacing(BETWEEN_SPACING)
        self.container_widgets["right_vbox"].pack_start(
            self.container_widgets["info_vbox"], False, False)
        self.container_widgets["right_vbox"].pack_start(
            self.container_widgets["info_table"], False, False)
        self.container_widgets["right_vbox"].pack_start(
            gtk.Alignment(0, 0, 1, 1))
        #
        #self.container_widgets["info_vbox"].pack_start(
        #self.__make_align(self.label_widgets["version"]), False, False)
        self.container_widgets["info_vbox"].pack_start(
            self.__make_align(self.label_widgets["copyright"]), False, False)
        label_widgets = self.label_widgets
        label_width = max(label_widgets["cpu"].size_request()[0],
                          label_widgets["version"].size_request()[0],
                          label_widgets["mem"].size_request()[0],
                          label_widgets["arch"].size_request()[0],
                          label_widgets["disk"].size_request()[0]) + 2
        #label_widgets["cpu"].set_size_request(label_width, WIDGET_HEIGHT)
        #label_widgets["mem"].set_size_request(label_width, WIDGET_HEIGHT)
        #label_widgets["arch"].set_size_request(label_width, WIDGET_HEIGHT)
        #label_widgets["disk"].set_size_request(label_width, WIDGET_HEIGHT)
        # table attach
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['version'],
                              width=label_width), 0, 1, 0, 1, 4)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['cpu'], width=label_width), 0,
            1, 1, 2, 4)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['mem'], width=label_width), 0,
            1, 2, 3, 4)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['arch'], width=label_width),
            0, 1, 3, 4, 4)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['disk'], width=label_width),
            0, 1, 4, 5, 4)

        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['version_info']), 1, 2, 0, 1,
            5)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['cpu_info']), 1, 2, 1, 2, 5)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['mem_info']), 1, 2, 2, 3, 5)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['arch_info']), 1, 2, 3, 4, 5)
        self.container_widgets["info_table"].attach(
            self.__make_align(self.label_widgets['disk_info']), 1, 2, 4, 5, 5)

        self.container_widgets["info_table"].set_col_spacings(WIDGET_SPACING)

        # show sysinfo
        self.label_widgets["version_info"].set_text("%s" %
                                                    settings.get_os_version())
        self.label_widgets["cpu_info"].set_text("%s" % settings.get_cpu_info())
        self.label_widgets["mem_info"].set_text("%.1fGB" %
                                                settings.get_mem_info())
        self.label_widgets["arch_info"].set_text(
            "%s%s" % (settings.get_os_arch(), _("bit")))
        disk_size = settings.get_disk_size()
        if disk_size:
            self.label_widgets["disk_info"].set_text("%.2fGB" % disk_size)
        else:
            self.label_widgets["disk_info"].set_text("--")
Пример #27
0
class ImagesDemo(gtk.Window):
    pixbuf_loader = None
    load_timeout = None
    image_stream = None

    def __init__(self, parent=None):
        gtk.Window.__init__(self)
        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', lambda *w: gtk.main_quit())
        self.connect("destroy", self.cleanup_callback)
        self.set_title(self.__class__.__name__)
        self.set_border_width(8)

        vbox = gtk.VBox(False, 8)
        vbox.set_border_width(8)
        self.add(vbox)

        label = gtk.Label()
        label.set_markup("<u>Image loaded from a file</u>")
        vbox.pack_start(label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window
        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

        image = gtk.Image()

        # use the current directory for the file
        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file(GTKLOGO_IMAGE)
            image.set_from_pixbuf(pixbuf)

        except gobject.GError, error:

            # This code shows off error handling. You can just use
            # gtk_image_new_from_file() instead if you don't want to report
            # errors to the user. If the file doesn't load when using
            # gtk_image_new_from_file(), a "missing image" icon will
            # be displayed instead.

            dialog = gtk.MessageDialog(
                self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
                gtk.BUTTONS_CLOSE,
                "Unable to open image file 'gtk-logo-rgb.gif': \n%s" % error)

            dialog.connect("response", lambda dlg, resp: dlg.destroy())
            dialog.show()

        frame.add(image)

        # Animation

        label = gtk.Label()
        label.set_markup("<u>Animation loaded from a file</u>")
        vbox.pack_start(label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window

        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

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

        frame.add(image)

        # Progressive

        label = gtk.Label()
        label.set_markup("<u>Progressive image loading</u>")
        vbox.pack_start(label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window

        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

        # Create an empty image for now; the progressive loader
        # will create the pixbuf and fill it in.

        image = gtk.Image()
        image.set_from_pixbuf(None)
        frame.add(image)

        self.start_progressive_loading(image)

        # Sensitivity control

        button = gtk.ToggleButton("_Insensitive")
        vbox.pack_start(button, False, False, 0)

        button.connect("toggled", self.on_sensitivity_toggled, vbox)

        self.show_all()
Пример #28
0
 def get_user_info(self, weibo):
     '''get weibo user info'''
     info = weibo.get_user_name()
     gtk.gdk.threads_enter()
     #self.get_user_error_text = ""
     weibo_hbox = weibo.get_box()
     hbox = gtk.HBox(False)
     vbox = gtk.VBox(False)
     weibo_hbox.pack_start(vbox, False, False)
     vbox.pack_start(hbox)
     #print weibo.t_type, info
     if info:
         self.is_get_user_info[weibo] = 1
         label = Label(text=info, label_width=70, enable_select=False)
         check = CheckButton()
         #check = gtk.CheckButton()
         check.connect("toggled", self.weibo_check_toggle, weibo)
         check.set_active(True)
         check_vbox = gtk.VBox(False)
         check_align = gtk.Alignment(0.5, 0.5, 0, 0)
         check_align.add(check_vbox)
         check_vbox.pack_start(check, False, False)
         button = ImageButton(
             app_theme.get_pixbuf("share/" + weibo.t_type + ".png"),
             app_theme.get_pixbuf("share/" + weibo.t_type + ".png"),
             app_theme.get_pixbuf("share/" + weibo.t_type + ".png"))
         utils.set_clickable_cursor(button)
         button.connect("enter-notify-event", self.show_tooltip, _("click to switch user"))
         hbox.pack_start(check_align, False, False)
         hbox.pack_start(button, False, False, 5)
         hbox.pack_start(label, False, False)
     else:
         self.is_get_user_info[weibo] = 0
         check = CheckButton()
         #check = gtk.CheckButton()
         check.set_sensitive(False)
         check_vbox = gtk.VBox(False)
         check_align = gtk.Alignment(0.5, 0.5, 0, 0)
         check_align.add(check_vbox)
         check_vbox.pack_start(check, False, False)
         button = ImageButton(
             app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"),
             app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"),
             app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"))
         utils.set_clickable_cursor(button)
         button.connect("enter-notify-event", self.show_tooltip, _("click to login"))
         hbox.pack_start(check_align, False, False)
         hbox.pack_start(button, False, False, 5)
         # curl time out
         info_error = weibo.get_curl_error()
         if info_error:
             #self.get_user_error_text += "%s:%s." % (weibo.t_type, _(info_error))
             hbox.pack_start(
                 Label(text="(%s)" % _(info_error), label_width=70,enable_select=False,
                 text_color = app_theme.get_color("left_char_num1")), False, False)
         
     button.connect("clicked", self.weibo_login, weibo)
     self.__weibo_check_button_list.append(check)
     self.__weibo_image_button_list.append(button)
     gtk.gdk.threads_leave()
     return weibo_hbox
Пример #29
0
    def __init__(self, parent, application):
        SettingsPage.__init__(self, parent, application, 'view_and_edit',
                              _('View & Edit'))

        # viewer options
        frame_view = gtk.Frame(_('View'))

        label_not_implemented = gtk.Label(
            'This option is not implemented yet.')
        label_not_implemented.set_sensitive(False)

        # editor options
        frame_edit = gtk.Frame(_('Edit'))

        vbox_edit = gtk.VBox(False, 0)
        vbox_edit.set_border_width(5)

        # installed application
        self._radio_application = gtk.RadioButton(
            label=_('Use installed application'))
        self._radio_application.connect('toggled', self._parent.enable_save)

        align_application = gtk.Alignment(xscale=1)
        align_application.set_padding(0, 10, 15, 15)
        vbox_application = gtk.VBox(False, 0)
        vbox_application.set_border_width(5)

        self._store = gtk.ListStore(str, str, str)
        self._combobox_application = gtk.ComboBox(model=self._store)
        self._combobox_application.connect('changed', self._parent.enable_save)

        cell_icon = gtk.CellRendererPixbuf()
        cell_name = gtk.CellRendererText()

        self._combobox_application.pack_start(cell_icon, False)
        self._combobox_application.pack_start(cell_name, True)

        self._combobox_application.add_attribute(cell_icon, 'icon-name',
                                                 Column.ICON)
        self._combobox_application.add_attribute(cell_name, 'text',
                                                 Column.NAME)

        # external options
        self._radio_external = gtk.RadioButton(group=self._radio_application,
                                               label=_('Use external command'))
        self._radio_external.connect('toggled', self._parent.enable_save)

        align_external = gtk.Alignment(xscale=1)
        align_external.set_padding(0, 10, 15, 15)
        vbox_external = gtk.VBox(False, 0)
        vbox_external.set_border_width(5)

        label_editor = gtk.Label(_('Command line:'))
        label_editor.set_alignment(0, 0.5)
        label_editor.set_use_markup(True)
        self._entry_editor = gtk.Entry()
        self._entry_editor.connect('changed', self._parent.enable_save)

        self._checkbox_terminal_command = gtk.CheckButton(
            _('Execute command in terminal tab'))
        self._checkbox_terminal_command.connect('toggled',
                                                self._parent.enable_save)

        # pack ui
        vbox_application.pack_start(self._combobox_application, False, False,
                                    0)
        align_application.add(vbox_application)

        vbox_external.pack_start(label_editor, False, False, 0)
        vbox_external.pack_start(self._entry_editor, False, False, 0)
        vbox_external.pack_start(self._checkbox_terminal_command, False, False,
                                 0)
        align_external.add(vbox_external)

        vbox_edit.pack_start(self._radio_application, False, False, 0)
        vbox_edit.pack_start(align_application, False, False, 0)
        vbox_edit.pack_start(self._radio_external, False, False, 0)
        vbox_edit.pack_start(align_external, False, False, 0)

        frame_view.add(label_not_implemented)
        frame_edit.add(vbox_edit)

        self.pack_start(frame_view, False, False, 0)
        self.pack_start(frame_edit, False, False, 0)
Пример #30
0
    def __init__(self, application):
        gtk.HPaned.__init__(self)
        from ui.canvas import Canvas
        self.canvas = Canvas(application)
        self.properties = Properties(application)

        self.canvas.connect("select", self.select)
        self.canvas.connect("finalize", self.finalize)
        self.canvas.connect("edit-child", self.edit_child)
        self.canvas.connect("scroll-event", self.wheel)

        box = gtk.VBox()

        self.notification = Notification()

        code_editor = None

        if '--source-editor-test' in sys.argv:
            while True:
                try:
                    from ui.code_editor import CodeEditor
                except:
                    self.notification.notificate(
                        _("No module GtkSourceView installed"), ERROR)
                    self.pack1(box, True, False)
                    break

                panel = gtk.VPaned()
                panel.pack1(box, True, False)
                code_editor = CodeEditor(application)
                code_editor.editor.set_language("sql")
                panel.pack2(code_editor, False, True)
                self.pack1(panel, True, False)
                break
        else:
            self.pack1(box, True, False)

        self.pack2(self.properties, False, True)

        top = gtk.HBox()
        box.pack_start(top, False, False)

        top.pack_start(self.notification, False, False)

        layer_selector = LayerSelector()
        alignment = gtk.Alignment(1.0, 0.5)
        alignment.add(layer_selector)
        top.pack_start(alignment, True, True)

        separator = gtk.VSeparator()
        top.pack_start(separator, False, False)

        self.image = gtk.Image()
        self.image.set_from_stock(CONTRACT_PROPERTIES, gtk.ICON_SIZE_MENU)
        button = gtk.Button()
        button.set_image(self.image)
        button.set_relief(gtk.RELIEF_NONE)
        button.connect("clicked", self.toggle_properties)
        top.pack_start(button, False, False)

        table = gtk.Table()
        box.add(table)

        bottom = gtk.HBox()
        box.pack_start(bottom, False, False)

        self.climber = Climber(self.canvas)
        bottom.pack_start(self.climber, False, False)

        pager = Pager(self.canvas)
        alignment = gtk.Alignment(1.0, 0.5)
        alignment.add(pager)
        bottom.pack_start(alignment, True, True)

        self.horizontal_ruler = HorizontalRuler()
        self.horizontal_ruler.connect("append-tag", self.append_tag)
        self.horizontal_ruler.connect("move-tag", self.move_tag)
        table.attach(self.horizontal_ruler, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND,
                     0)

        self.vertical_ruler = VerticalRuler()
        self.vertical_ruler.connect("append-tag", self.append_tag)
        self.vertical_ruler.connect("move-tag", self.move_tag)
        table.attach(self.vertical_ruler, 0, 1, 1, 2, 0, gtk.FILL | gtk.EXPAND)

        area = gtk.ScrolledWindow()
        area.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        adjustment = area.get_vadjustment()
        adjustment.connect("value-changed", self.scroll, VERTICAL)
        adjustment = area.get_hadjustment()
        adjustment.connect("value-changed", self.scroll, HORIZONTAL)
        table.attach(area, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND)

        self.canvas.code_editor = code_editor
        self.canvas.horizontal_ruler = self.horizontal_ruler
        self.canvas.vertical_ruler = self.vertical_ruler
        self.connect("realize", self.realize, area)