当前位置: 首页>>代码示例>>Python>>正文


Python ToolButton.set_icon_widget方法代码示例

本文整理汇总了Python中sugar.graphics.toolbutton.ToolButton.set_icon_widget方法的典型用法代码示例。如果您正苦于以下问题:Python ToolButton.set_icon_widget方法的具体用法?Python ToolButton.set_icon_widget怎么用?Python ToolButton.set_icon_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar.graphics.toolbutton.ToolButton的用法示例。


在下文中一共展示了ToolButton.set_icon_widget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ActivityToolbar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class ActivityToolbar(gtk.Toolbar):
    """The Activity toolbar with the Journal entry title, sharing,
       Keep and Stop buttons
    
    All activities should have this toolbar. It is easiest to add it to your
    Activity by using the ActivityToolbox.
    """
    def __init__(self, activity):
        gtk.Toolbar.__init__(self)

        self._activity = activity
        self._updating_share = False
        self._focus_out_hid = None

        activity.connect('shared', self.__activity_shared_cb)
        activity.connect('joined', self.__activity_shared_cb)
        activity.connect('notify::max_participants',
                         self.__max_participants_changed_cb)

        if activity.metadata:
            self.title = gtk.Entry()
            self.title.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
            self.title.set_text(activity.metadata['title'])
            self._focus_out_hid = self.title.connect('focus-out-event',
                                                     self.__title_changed_cb)
            self._add_widget(self.title)

            activity.metadata.connect('updated', self.__jobject_updated_cb)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self.insert(separator, -1)
        separator.show()

        self.share = ToolComboBox(label_text=_('Share with:'))
        self.share.combo.connect('changed', self.__share_changed_cb)
        self.share.combo.append_item(SCOPE_PRIVATE, _('Private'), 'zoom-home')
        self.share.combo.append_item(SCOPE_NEIGHBORHOOD, _('My Neighborhood'),
                                     'zoom-neighborhood')
        self.insert(self.share, -1)
        self.share.show()

        self._update_share()

        self.keep = ToolButton(tooltip=_('Keep'))
        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        keep_icon = Icon(icon_name='document-save', xo_color=color)
        self.keep.set_icon_widget(keep_icon)
        keep_icon.show()
        self.keep.props.accelerator = '<Ctrl>S'
        self.keep.connect('clicked', self.__keep_clicked_cb)
        self.insert(self.keep, -1)
        self.keep.show()

        self.stop = ToolButton('activity-stop', tooltip=_('Stop'))
        self.stop.props.accelerator = '<Ctrl>Q'
        self.stop.connect('clicked', self.__stop_clicked_cb)
        self.insert(self.stop, -1)
        self.stop.show()

    def _update_share(self):
        self._updating_share = True

        if self._activity.props.max_participants == 1:
            self.share.hide()

        if self._activity.get_shared():
            self.share.set_sensitive(False)
            self.share.combo.set_active(1)
        else:
            self.share.set_sensitive(True)
            self.share.combo.set_active(0)

        self._updating_share = False
    
    def __share_changed_cb(self, combo):
        if self._updating_share:
            return

        model = self.share.combo.get_model()
        it = self.share.combo.get_active_iter()
        (scope, ) = model.get(it, 0)
        if scope == SCOPE_NEIGHBORHOOD:
            self._activity.share()

    def __keep_clicked_cb(self, button):
        self._activity.copy()

    def __stop_clicked_cb(self, button):
        if self._focus_out_hid is not None:
            self.title.disconnect(self._focus_out_hid)
        self._update_title(self.title.get_text())
        self._activity.close()

    def __jobject_updated_cb(self, jobject):
        self.title.set_text(jobject['title'])

    def __title_changed_cb(self, editable, event):
#.........这里部分代码省略.........
开发者ID:dannyiland,项目名称:OLPC-Mesh-Messenger,代码行数:103,代码来源:activity.py

示例2: ActivityToolbar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class ActivityToolbar(gtk.Toolbar):
    """The Activity toolbar with the Journal entry title, sharing,
       Keep and Stop buttons
    
    All activities should have this toolbar. It is easiest to add it to your
    Activity by using the ActivityToolbox.
    """
    def __init__(self, activity):
        gtk.Toolbar.__init__(self)

        self._activity = activity
        self._updating_share = False
        """
        activity.connect('shared', self.__activity_shared_cb)
        activity.connect('joined', self.__activity_shared_cb)
        activity.connect('notify::max_participants',
                         self.__max_participants_changed_cb)
        """
        #if activity.metadata:
        if True:
            self.label = gtk.Label(display.menu_journal_label)
            self.label.show()
            self._add_widget(self.label)

            self.title = gtk.Entry()
            self.title.set_size_request(int(gtk.gdk.screen_width() / 6), -1)
            if activity.metadata:
                self.title.set_text(activity.metadata['title'])
                #activity.metadata.connect('updated', self.__jobject_updated_cb)
            self.title.connect('changed', self.__title_changed_cb)
            self.title.connect('activate', self.__update_title_cb)
            self._add_widget(self.title)
            
            fn = os.path.join(os.getcwd(),'assets','stack_new.png')
            button = ImageButton()
            tooltip = _("Add Album Stack")
            button.set_image(fn,tip=tooltip)
            self.add_album = button
            self.add_album.show()
            self.add_album.connect('clicked', self.__add_album_clicked_cb)
            self.insert(self.add_album,-1)
            
            fn = os.path.join(os.getcwd(),'assets','stack_del.png')
            button = ImageButton()
            tooltip = _("Delete Album Stack")
            button.set_image(fn,tip=tooltip)
            button.connect('clicked', self.__delete_album_clicked_cb)
            self.insert(button,-1)

            fn = os.path.join(os.getcwd(),'assets','trash_del.png')
            button = ImageButton()
            tooltip = _("Remove Trash Images from XO")
            button.set_image(fn,tip=tooltip)
            self.empty_journal_button = button
            self.empty_journal_button.hide()
            self.empty_journal_button.connect('clicked',self.__empty_trash_clicked_cb)
            self.insert(self.empty_journal_button,-1)
        


        """
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self.insert(separator, -1)
        separator.show()
        
        self.share = ToolComboBox(label_text=_('Traceback:'))
        self.share.combo.connect('changed', self.__traceback_changed_cb)
        self.share.combo.append_item("traceback_plain", _('Plain'))
        self.share.combo.append_item('traceback_context', _('Context'))
        self.share.combo.append_item('traceback_verbose', _('Verbose'))
        self.insert(self.share, -1)
        self.share.show()

        self._update_share()
        """
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self.insert(separator, -1)
        separator.show()

        self.keep = ToolButton()
        self.keep.set_tooltip(_('Save and Start New'))
        #client = gconf.client_get_default()
        #color = XoColor(client.get_string('/desktop/sugar/user/color'))
        #keep_icon = Icon(icon_name='document-save', xo_color=color)
        keep_icon = Icon(icon_name='document-save')
        keep_icon.show()
        self.keep.set_icon_widget(keep_icon)
        #self.keep.props.accelerator = '<Ctrl>S'
        self.keep.connect('clicked', self.__keep_clicked_cb)
        self.insert(self.keep, -1)
        self.keep.show()
        
        self.stop = ToolButton('activity-stop')
        self.stop.set_tooltip(_('Stop'))
        #self.stop.props.accelerator = '<Ctrl>Q'
        self.stop.connect('clicked', self.__stop_clicked_cb)
#.........这里部分代码省略.........
开发者ID:Daksh,项目名称:xophoto,代码行数:103,代码来源:photo_toolbar.py

示例3: GameToolbar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class GameToolbar(gtk.Toolbar):
    __gtype_name__ = 'GameToolbar'

    __gsignals__ = {
        'game-restart': (SIGNAL_RUN_FIRST, TYPE_NONE, []), 
        'ai-activated': (SIGNAL_RUN_FIRST, TYPE_NONE, []), 
        'ai-deactivated': (SIGNAL_RUN_FIRST, TYPE_NONE, []), 
        'game-board-size': (SIGNAL_RUN_FIRST, TYPE_NONE, [TYPE_INT]), 
    }
    
    def __init__(self, activity):
        gtk.Toolbar.__init__(self)
        self.activity = activity
        
        # Reset Button
        restart_icon = join(dirname(__file__), 'images', 'gtk-refresh.svg')
        restart_image = gtk.Image()
        restart_image.set_from_file(restart_icon)
        self._restart_button = ToolButton()
        self._restart_button.set_icon_widget(restart_image)
        self._restart_button.connect('clicked', self._game_restart_cb)
        self._restart_button.set_tooltip(_('Restart Game'))
        self.insert(self._restart_button, -1)
        self._restart_button.show()
        
        # Separator
        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        self.insert(separator, -1)
        
        self._add_widget(gtk.Label(_('Board size') + ': '))
        # Change size combobox
        self._size_combo = ToolComboBox()
        self._sizes = ['19 X 19', '13 X 13', '9 X 9']
        for i, f in enumerate(self._sizes):
            self._size_combo.combo.append_item(i, f)
        self._size_combo.combo.connect('changed', self._game_size_cb)
        self._add_widget(self._size_combo)
        self._size_combo.combo.set_active(0)
        
        # Separator
        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        self.insert(separator, -1)
        
        # Artificial Intelligence Button
        self._ai_button = gtk.ToggleToolButton()
        if search_for_gnugo():
            self._ai_button.connect('toggled', self._ai_toggled_cb)
            self._ai_button.set_label(_('Play against PlayGo!'))
        else:
            self._ai_button.set_label(_('You need to install gnugo to play against PlayGo'))
            self._ai_button.set_sensitive(False)
        self.insert(self._ai_button, -1)
        self._ai_button.show()
        
    def _add_widget(self, widget, expand=False):
        tool_item = gtk.ToolItem()
        tool_item.set_expand(expand)
        tool_item.add(widget)
        widget.show()
        self.insert(tool_item, -1)
        tool_item.show()
        
    def _game_restart_cb(self, widget):
        self._size_combo.set_sensitive(True)
        self.emit('game-restart')
    
    def grey_out_restart(self):
        self._restart_button.set_sensitive(False)
    
    def _game_size_cb(self, widget):
        game_size = int(self._sizes[self._size_combo.combo.get_active()][:2])
        self.emit('game-board-size', game_size)
        
    def grey_out_size_change(self):
        self._size_combo.set_sensitive(False)
        
    def update_toolbar(self, widget, data, grid):
        size = data.get('size')
        self._size_combo.combo.handler_block(self.size_handle_id)
        size_index = self._sizes.index(size+' X '+size)
        self._size_combo.combo.set_active(int(size_index))
        self._size_combo.combo.handler_unblock(self.size_handle_id)

    def _ai_toggled_cb(self, widget):
        if widget.get_active():
            self.emit('ai-activated')
        else:
            self.emit('ai-deactivated')
        
    def grey_out_ai(self):
        self._ai_button.set_sensitive(False)
        
    def set_ai_button_state(self, value):
        self._ai_button.set_active(value)
开发者ID:Daksh,项目名称:playgo,代码行数:98,代码来源:gametoolbar.py

示例4: MemorizeToolbar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class MemorizeToolbar(gtk.Toolbar):
    __gtype_name__ = 'MemoryToolbar'
    
    standard_game_names = ['Load demo games',
                           'addition',
                           'letters',
                           'sounds'
                           ]
    translated_game_names = [_('Load demo games'),
                             _('addition'),
                             _('letters'),
                             _('sounds')
                            ]

    __gsignals__ = {
        'game_changed': (SIGNAL_RUN_FIRST, None, 5 * [TYPE_PYOBJECT]),
    }
    
    def __init__(self, activity):
        gtk.Toolbar.__init__(self)
        self.activity = activity
        self._lock = True
        self.jobject = None
        
        # Reset Button
        restart_icon = join(dirname(__file__), 'images', 'game-restart.svg')
        restart_image = gtk.Image()
        restart_image.set_from_file(restart_icon)
        self._restart_button = ToolButton()
        self._restart_button.set_icon_widget(restart_image)
        self._restart_button.connect('clicked', self._game_reset_cb)
        self._restart_button.set_tooltip(_('Restart Game'))
        self.insert(self._restart_button, -1)
        self._restart_button.show()
        
        # Load Button
        load_icon = join(dirname(__file__), 'images', 'game-load.svg')
        load_image = gtk.Image()
        load_image.set_from_file(load_icon)
        self._load_button = ToolButton()
        self._load_button.set_icon_widget(load_image)
        self._load_button.set_tooltip(_('Load game'))
        self._load_button.connect('clicked', self._load_game)
        self._add_widget(self._load_button)
        
        # Separator
        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        self.insert(separator, -1)
        
        # Change size combobox
        self._size_combo = ToolComboBox()
        self._sizes = ['4 X 4', '5 X 5', '6 X 6']
        for i, f in enumerate(self._sizes):
            self._size_combo.combo.append_item(i, f)
        self.size_handle_id = self._size_combo.combo.connect( \
                'changed', self._game_size_cb)
        self._add_widget(self._size_combo)
        self._size_combo.combo.set_active(0)
        
        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        self.insert(separator, -1)
        self._lock = False
    
        # Change demo games combobox        
        self._game_combo = ToolComboBox()
        for i, f in enumerate(self.standard_game_names):
            f = _(f)    
            self._game_combo.combo.append_item(i, f)
        self._game_combo.combo.set_active(0)
        self._game_combo.combo.connect('changed', self._game_changed_cb)
        self._add_widget(self._game_combo)
    
    def _add_widget(self, widget, expand=False):
        tool_item = gtk.ToolItem()
        tool_item.set_expand(expand)
        tool_item.add(widget)
        widget.show()
        self.insert(tool_item, -1)
        tool_item.show()
        
    def _game_reset_cb(self, widget):
        self.emit('game_changed', None, None, 'reset', None, None)
        
    def _load_game(self, button):
        chooser = ObjectChooser(_('Choose memorize game'),
                parent=self.activity,
                flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        jobject = ''
        try:
            result = chooser.run()
            if result == gtk.RESPONSE_ACCEPT:
                logging.debug('ObjectChooser: %r', 
                              chooser.get_selected_object())
                jobject = chooser.get_selected_object()
                if not jobject or  not jobject.file_path:
                    return
        finally:
            chooser.destroy()
#.........这里部分代码省略.........
开发者ID:pmoleri,项目名称:memorize-accesible,代码行数:103,代码来源:memorizetoolbar.py

示例5: CreateToolbar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class CreateToolbar(gtk.Toolbar):
    __gtype_name__ = 'CreateToolbar'

    __gsignals__ = {
        'create_new_game': (SIGNAL_RUN_FIRST, None, []), 
        'create_load_game': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), 
        'create_save_game': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), 
        'create_equal_pairs': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), 
    }
    
    def __init__(self, activity):
        gtk.Toolbar.__init__(self)
        self.activity = activity
        self._lock = True
        
        # New Button
        new_icon = join(dirname(__file__), 'images', 'game-new.svg')
        new_image = gtk.Image()
        new_image.set_from_file(new_icon)
        self._new_button = ToolButton()
        self._new_button.set_icon_widget(new_image)
        self._new_button.set_tooltip(_('New game'))
        self._new_button.connect('clicked', self._new_game_bt)
        self._add_widget(self._new_button)
        
        # Load Button
        load_icon = join(dirname(__file__), 'images', 'game-load.svg')
        load_image = gtk.Image()
        load_image.set_from_file(load_icon)
        self._load_button = ToolButton()
        self._load_button.set_icon_widget(load_image)
        self._load_button.set_tooltip(_('Load game'))
        self._load_button.connect('clicked', self._load_game)
        self._add_widget(self._load_button)
            
        # Save Button
        save_icon = join(dirname(__file__), 'images', 'game-save.svg')
        save_image = gtk.Image()
        save_image.set_from_file(save_icon)
        self._save_button = ToolButton()
        self._save_button.set_icon_widget(save_image)
        self._save_button.set_tooltip(_('Save game'))
        self._save_button.connect('clicked', self._save_game_bt)
        self._save_button.set_sensitive(False)
        self._add_widget(self._save_button)
    
        # Separator
        separator2 = gtk.SeparatorToolItem()
        separator2.set_draw(True)
        self.insert(separator2, -1)
        
        self._add_widget(gtk.Label(_('Game name') + ': '))
        self.game_name_entry = gtk.Entry()
        self._add_widget(self.game_name_entry) 
        
        self._equal_pairs = gtk.CheckButton(_('Equal pairs'))   
        self._add_widget(self._equal_pairs)
        self._equal_pairs.connect('toggled', self._emit_equal_pairs)
                
        self._grouped_icon1 = join(dirname(__file__), 'images', 'equal_pairs1.svg')
        self._grouped_icon2 = join(dirname(__file__), 'images', 'equal_pairs2.svg')
        self._grouped_image1 = gtk.Image()
        self._grouped_image2 = gtk.Image()
        self._grouped_image1.set_from_file(self._grouped_icon1)
        self._grouped_image2.set_from_file(self._grouped_icon2)
        self._grouped = ToggleToolButton()
        self._grouped.set_icon_widget(self._grouped_image1)
        self._grouped.set_tooltip(_('Click for grouped game'))
        self._grouped.connect('toggled', self._grouped_cb)
        self._add_widget(self._grouped)
        
    def _add_widget(self, widget, expand=False):
        tool_item = gtk.ToolItem()
        tool_item.set_expand(expand)
        tool_item.add(widget)
        widget.show()
        self.insert(tool_item, -1)
        tool_item.show()
        
    def _game_changed_cb(self, combobox, game_name):
        self.game_name_entry.set_text(game_name)
        self.emit('create_load_game', game_name)
  
    def _load_game(self, button):
        chooser = ObjectChooser(_('Choose memorize game'),
                parent=self.activity,
                flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        jobject = ''
        try:
            result = chooser.run()
            if result == gtk.RESPONSE_ACCEPT:
                logging.debug('ObjectChooser: %r' % chooser.get_selected_object())
                jobject = chooser.get_selected_object()
                if not jobject or  not jobject.file_path:
                    return
        finally:
            chooser.destroy()
            del chooser
            
        if jobject and jobject.file_path:    
#.........这里部分代码省略.........
开发者ID:pmoleri,项目名称:memorize-accesible,代码行数:103,代码来源:createtoolbar.py

示例6: CreateCardPanel

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class CreateCardPanel(gtk.EventBox):
    __gsignals__ = {
        'add-pair': (SIGNAL_RUN_FIRST, None, 8 * [TYPE_PYOBJECT]),
        'update-pair': (SIGNAL_RUN_FIRST, None, 8 * [TYPE_PYOBJECT]),
    }

    def __init__(self):
        def make_label(icon_name, label):
            label_box = gtk.HBox()
            icon = Icon(
                    icon_name=icon_name,
                    icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
            label_box.pack_start(icon, False)
            label = gtk.Label(label)
            label.modify_fg(gtk.STATE_NORMAL,
                    style.COLOR_TOOLBAR_GREY.get_gdk_color())
            label_box.pack_start(label)
            label_box.show_all()
            return label_box

        gtk.EventBox.__init__(self)

        self.equal_pairs = False
        self._updatebutton_sensitive = False
        self._card1_has_sound = False
        self._card2_has_sound = False

        # save buttons

        buttons_bar = gtk.HBox()
        buttons_bar.props.border_width = 10

        self._addbutton = ToolButton(
                tooltip=_('Add as new pair'),
                sensitive=False)
        self._addbutton.set_icon_widget(
                make_label('pair-add', ' ' + _('Add')))
        self._addbutton.connect('clicked', self.emit_add_pair)
        buttons_bar.pack_start(self._addbutton, False)

        self._updatebutton = ToolButton(
                tooltip=_('Update selected pair'),
                sensitive=False)
        self._updatebutton.set_icon_widget(
                make_label('pair-update', ' ' + _('Update')))
        self._updatebutton.connect('clicked', self.emit_update_pair)
        buttons_bar.pack_start(self._updatebutton, False)

        # Set card editors

        self.cardeditor1 = CardEditor()
        self.cardeditor2 = CardEditor()
        self.clean(None)
        self.cardeditor1.connect('has-text', self.receive_text_signals)
        self.cardeditor2.connect('has-text', self.receive_text_signals)
        self.cardeditor1.connect('has-picture', self.receive_picture_signals)
        self.cardeditor2.connect('has-picture', self.receive_picture_signals)
        self.cardeditor1.connect('has-sound', self.receive_sound_signals)
        self.cardeditor2.connect('has-sound', self.receive_sound_signals)

        # edit panel

        self.card_box = gtk.HBox()
        self.card_box.pack_start(self.cardeditor1)
        self.card_box.pack_start(self.cardeditor2)

        box = gtk.VBox()
        box.pack_start(self.card_box, False)
        box.pack_start(buttons_bar, False)
        self.add(box)

        self.show_all()

    def emit_add_pair(self, widget):
        self._addbutton.set_sensitive(False)
        if self.equal_pairs:
            self.emit('add-pair', self.cardeditor1.get_text(), 
                      self.cardeditor1.get_text(), 
                      self.cardeditor1.get_pixbuf(), 
                      self.cardeditor1.get_pixbuf(), 
                      self.cardeditor1.get_snd(), self.cardeditor1.get_snd(),
                      self.cardeditor1.get_speak(), self.cardeditor1.get_speak()
                      )
        else:
            self.emit('add-pair', self.cardeditor1.get_text(), 
                      self.cardeditor2.get_text(), 
                      self.cardeditor1.get_pixbuf(), 
                      self.cardeditor2.get_pixbuf(), 
                      self.cardeditor1.get_snd(), self.cardeditor2.get_snd(),
                      self.cardeditor1.get_speak(), self.cardeditor2.get_speak()
                      )
        self.clean(None)

    def emit_update_pair(self, widget):
        self._addbutton.set_sensitive(False)
        if self.equal_pairs:
            self.emit('update-pair', self.cardeditor1.get_text(), 
                      self.cardeditor1.get_text(), 
                      self.cardeditor1.get_pixbuf(), 
                      self.cardeditor1.get_pixbuf(), 
#.........这里部分代码省略.........
开发者ID:pmoleri,项目名称:memorize-accesible,代码行数:103,代码来源:createcardpanel.py

示例7: EntryToolbar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import set_icon_widget [as 别名]
class EntryToolbar(gtk.Toolbar):
    __gsignals__ = {
        'volume-error': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                         ([str, str])),
        }

    def __init__(self):
        gtk.Toolbar.__init__(self)

        self._metadata = None
        self._temp_file_path = None

        self._resume = ToolButton('activity-start')
        self._resume.connect('clicked', self._resume_clicked_cb)
        self.add(self._resume)
        self._resume.show()

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self._copy = ToolButton()
        icon = Icon(icon_name='edit-copy', xo_color=color)
        self._copy.set_icon_widget(icon)
        icon.show()
        self._copy.set_tooltip(_('Copy to'))
        self._copy.connect('clicked', self._copy_clicked_cb)
        self.add(self._copy)
        self._copy.show()

        self._duplicate = ToolButton()
        icon = Icon(icon_name='edit-duplicate', xo_color=color)
        self._duplicate.set_icon_widget(icon)
        self._duplicate.set_tooltip(_('Duplicate'))
        self._duplicate.connect('clicked', self._duplicate_clicked_cb)
        self.add(self._duplicate)

        separator = gtk.SeparatorToolItem()
        self.add(separator)
        separator.show()

        erase_button = ToolButton('list-remove')
        erase_button.set_tooltip(_('Erase'))
        erase_button.connect('clicked', self._erase_button_clicked_cb)
        self.add(erase_button)
        erase_button.show()

    def set_metadata(self, metadata):
        self._metadata = metadata
        self._refresh_copy_palette()
        self._refresh_duplicate_palette()
        self._refresh_resume_palette()

    def _resume_clicked_cb(self, button):
        misc.resume(self._metadata)

    def _copy_clicked_cb(self, button):
        button.palette.popup(immediate=True, state=Palette.SECONDARY)

    def _duplicate_clicked_cb(self, button):
        file_path = model.get_file(self._metadata['uid'])
        try:
            model.copy(self._metadata, '/')
        except IOError, e:
            logging.exception('Error while copying the entry.')
            self.emit('volume-error',
                      _('Error while copying the entry. %s') % (e.strerror, ),
                      _('Error'))
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:68,代码来源:journaltoolbox.py


注:本文中的sugar.graphics.toolbutton.ToolButton.set_icon_widget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。