Пример #1
0
    def _load_toolbar(self):
        toolbar = gtk.Toolbar()

        # Remove Feed Palette
        remove_button = ToolButton(icon_name='list-remove')
        vbox = gtk.VBox()
        label = gtk.Label(_('Really delete feed?'))
        vbox.pack_start(label)
        hbox = gtk.HBox()
        expander_label = gtk.Label(' ')
        hbox.pack_start(expander_label)
        #b = gtk.Button(icon_name='stock-remove')
        b = ToolButton(icon_name='list-remove')
        #b.set_use_stock(True)
        b.connect('clicked', self._on_remove_feed_activate)
        hbox.pack_start(b, False)
        vbox.pack_start(hbox)
        palette = Palette(_('Remove Feed?'))
        palette.set_content(vbox)
        vbox.show_all()
        remove_button.set_palette(palette)
        toolbar.insert(remove_button, -1)
        remove_button.show()

        # Add Feed Palette
        button = ToolButton(icon_name='list-add')
        toolbar.insert(button, -1)
        button.show()

        self._add_feed_dialog = AddFeedDialog.AddFeedDialog(
            gtk.glade.XML(os.path.join(self.glade_prefix, 'penguintv.glade'),
                          "window_add_feed", 'penguintv'), self)  #MAGIC
        content = self._add_feed_dialog.extract_content()
        content.show_all()

        #button.connect('clicked', self._add_feed_dialog.show)

        palette = Palette(_('Subscribe to Feed'))
        palette.set_content(content)
        button.set_palette(palette)

        self._feedlist = gtk.ListStore(int, str, str)
        self._combo = gtk.ComboBox(self._feedlist)
        cell = gtk.CellRendererText()
        self._combo.pack_start(cell, True)
        self._combo.add_attribute(cell, 'text', 1)
        self._combo.connect("changed", self._on_combo_select)

        toolcombo = ToolComboBox(self._combo)
        toolbar.insert(toolcombo, -1)
        toolcombo.show_all()

        toolbar.show()
        return toolbar
Пример #2
0
    def addBlock(self, data, name, block):
        # tooltip
        invoker = WidgetInvoker(block)
        invoker._position_hint = WidgetInvoker.AT_CURSOR
        invoker.set_palette(Palette(name))

        block.add_events(gtk.gdk.BUTTON_PRESS_MASK
                         | gtk.gdk.BUTTON_RELEASE_MASK
                         | gtk.gdk.ENTER_NOTIFY_MASK
                         | gtk.gdk.LEAVE_NOTIFY_MASK
                         | gtk.gdk.POINTER_MOTION_MASK
                         | gtk.gdk.POINTER_MOTION_HINT_MASK)
        block.connect("button-press-event", self.on_button_press)
        block.connect("button-release-event", self.on_button_release)
        block.connect("motion-notify-event", self.on_motion_notify)
        block.data = data

        self.blocks.append(block)

        if self._testAgainstFilter(block):
            self.pickerBox.pack_start(block, False, False, 3)

        block.show_all()

        return block
Пример #3
0
    def create_palette(self, text, help_cb):
        p = Palette(text)

        if help_cb is not None:
            item = MenuItem(_('Help'), 'action-help')
            item.connect('activate', help_cb)
            item.show()
            p.menu.append(item)

        self.set_palette(p)
Пример #4
0
    def set_tooltip(self, tooltip):
        """ Set a simple palette with just a single label.
        """
        if self.palette is None or self._tooltip is None:
            self.palette = Palette(tooltip)
        elif self.palette is not None:
            self.palette.set_primary_text(tooltip)

        self._tooltip = tooltip

        # Set label, shows up when toolbar overflows
        gtk.ToolButton.set_label(self, tooltip)
Пример #5
0
    def _set_up_documents_button(self):
        documents_path = model.get_documents_path()
        if documents_path is not None:
            button = DocumentsButton(documents_path)
            button.props.group = self._volume_buttons[0]
            label = glib.markup_escape_text(_('Documents'))
            button.set_palette(Palette(label))
            button.connect('toggled', self._button_toggled_cb)
            button.show()

            position = self.get_item_index(self._volume_buttons[-1]) + 1
            self.insert(button, position)
            self._volume_buttons.append(button)
            self.show()
Пример #6
0
    def __init__(self, recd):
        super(RecdButton, self).__init__()
        self._recd = recd

        self.set_icon_widget(self.get_image())
        self._copy_menu_item_handler = None

        palette = Palette(recd.title)
        self.set_palette(palette)

        self._rem_menu_item = gtk.MenuItem(_('Remove'))
        self._rem_menu_item_handler = self._rem_menu_item.connect(
            'activate', self._remove_clicked)
        palette.menu.append(self._rem_menu_item)
        self._rem_menu_item.show()

        self._add_copy_menu_item()
Пример #7
0
    def _add_button(self, icon_name, label, accelerator, zoom_level):
        if self.get_children():
            group = self.get_children()[0]
        else:
            group = None

        button = RadioToolButton(named_icon=icon_name,
                                 group=group,
                                 accelerator=accelerator)
        button.connect('clicked', self.__level_clicked_cb, zoom_level)
        self.add(button)
        button.show()

        palette = Palette(glib.markup_escape_text(label))
        palette.props.invoker = FrameWidgetInvoker(button)
        palette.set_group_id('frame')
        button.set_palette(palette)

        return button
Пример #8
0
    def setup_rollover_options(self):
        palette = Palette(Constants.istrSavedMap)
        self.set_palette(palette)

        self.tag_menu_item = gtk.MenuItem(Constants.istrTagMap)
        self.ACTIVATE_TAG_ID = self.tag_menu_item.connect(
            'activate', self._tagCb)
        palette.menu.append(self.tag_menu_item)
        self.tag_menu_item.show()

        self.rem_menu_item = gtk.MenuItem(Constants.istrRemove)
        self.ACTIVATE_REMOVE_ID = self.rem_menu_item.connect(
            'activate', self._itemRemoveCb)
        palette.menu.append(self.rem_menu_item)
        self.rem_menu_item.show()

        self.copy_menu_item = gtk.MenuItem(Constants.istrCopyToClipboard)
        self.ACTIVATE_COPY_ID = self.copy_menu_item.connect(
            'activate', self._itemCopyToClipboardCb)
        self.get_palette().menu.append(self.copy_menu_item)
        self.copy_menu_item.show()
Пример #9
0
 def set_tooltip(self, text):
     self.set_palette(Palette(text))
Пример #10
0
    def set_tooltip(self, text):
        from sugar.graphics.palette import Palette

        self.set_palette(Palette(text))
Пример #11
0
"""
Test the style of toggle and radio buttons inside a palette. The buttons
contains only an icon and should be rendered similarly to the toolbar
controls. Ticket #2855.
"""

import gtk

from sugar.graphics.palette import Palette
from sugar.graphics.icon import Icon

import common

test = common.TestPalette()

palette = Palette('Test radio and toggle')
test.set_palette(palette)

box = gtk.HBox()

toggle = gtk.ToggleButton()

icon = Icon(icon_name='go-previous', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
toggle.set_image(icon)

box.pack_start(toggle, False)
toggle.show()

radio = gtk.RadioButton()

icon = Icon(icon_name='go-next', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
Пример #12
0
 def _add_tooltip(self, widget, tooltip):
     #self._add_palette(widget, Palette(tooltip), Palette.DEFAULT)
     self._add_palette(widget, Palette(tooltip))
Пример #13
0
    def __init__(self, handle):
        super(Chat, self).__init__(handle)

        smilies.init()

        self.entry = None
        self.chatbox = None

        root = self.make_root()
        self.set_canvas(root)
        root.show_all()
        self.entry.grab_focus()

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.toolbar.insert(ActivityButton(self), -1)
        toolbar_box.toolbar.insert(TitleEntry(self), -1)

        share_button = ShareButton(self)
        toolbar_box.toolbar.insert(share_button, -1)

        separator = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)

        self._smiley = RadioMenuButton(icon_name='smilies')
        self._smiley.palette = Palette(_('Insert smiley'))
        self._smiley.props.sensitive = False
        toolbar_box.toolbar.insert(self._smiley, -1)

        table = self._create_pallete_smiley_table()
        table.show_all()
        self._smiley.palette.set_content(table)

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

        toolbar_box.toolbar.insert(StopButton(self), -1)
        toolbar_box.show_all()

        pservice = presenceservice.get_instance()
        self.owner = pservice.get_owner()
        # Chat is room or one to one:
        self._chat_is_room = False
        self.text_channel = None

        if self.shared_activity:
            # we are joining the activity
            self.connect('joined', self._joined_cb)
            if self.get_shared():
                # we have already joined
                self._joined_cb(self)
        elif handle.uri:
            # XMPP non-Sugar incoming chat, not sharable
            share_button.props.visible = False
            self._one_to_one_connection(handle.uri)
        else:
            # we are creating the activity
            if not self.metadata or self.metadata.get(
                    'share-scope',
                    activity.SCOPE_PRIVATE) == activity.SCOPE_PRIVATE:
                # if we are in private session
                self._alert(_('Off-line'), _('Share, or invite someone.'))
            self.connect('shared', self._shared_cb)
    def __init__(self):
        TreeView.__init__(self)

        global this
        this = self

        self._cached_buddies = None
        self.columns = {}
        self.config = model.this['object_compact']

        self.props.hover_selection = True

        activity.this.on_save_instance(self._save_columns)
        self.connect('map', lambda x: self._load_columns())
        self.connect('button-press-event', self._press_cb)
        self.connect('button-release-event', self._release_cb)

        self._buddies_palette = []
        for i in range(VISIBLE_BUDDIES_COUNT):
            self._buddies_palette.append(Palette())

        def make_cell_pix():
            cell = gtk.CellRendererPixbuf()
            cell.props.height = model.ICON_SIZE
            cell.props.width = model.ICON_SIZE
            cell.props.xalign = 0.
            return cell
        cell_pix = [make_cell_pix() for i in range(VISIBLE_BUDDIES_COUNT)]

        cell_text = gtk.CellRendererText()
        cell_text.props.ellipsize = pango.ELLIPSIZE_END
        cell_text.props.ellipsize_set = True

        column = TreeViewColumn(_('Title'))
        column.palette_cb = self._icon_palette_cb
        column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
        column.props.min_width = 50
        column.props.resizable = True
        column.props.reorderable = True
        column.set_sort_column_id(FIELD_TITLE)
        column.pack_start(cell_pix[0], False)
        column.add_attribute(cell_pix[0], 'pixbuf', FIELD_ICON)
        column.pack_start(cell_text, True)
        column.add_attribute(cell_text, 'text', FIELD_TITLE)
        self.columns['title'] = column

        column = TreeViewColumn(_('Participants'))
        column.palette_cb = self._buddies_palette_cb
        column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
        column.props.reorderable = True
        for i in range(VISIBLE_BUDDIES_COUNT):
            column.pack_start(cell_pix[i], False)
            column.add_attribute(cell_pix[i], 'pixbuf',
                    FIELD_BUDDY_FIRST+i)
        column.set_sort_column_id(FIELD_BUDDIES_COUNT)
        self.columns['buddies'] = column

        column = TreeViewColumn(_('Modify time'), cell_text,
                text=FIELD_MODIFY_TIME)
        column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
        column.props.min_width = 50
        column.props.resizable = True
        column.props.reorderable = True
        column.set_sort_column_id(FIELD_TIMESTAMP)
        self.columns['mtime'] = column

        def column_new(field):
            column_number = FIELD_BASE_LIST[field][0]
            column = TreeViewColumn(NAMES[field], cell_text, text=column_number)
            column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
            column.props.min_width = 50
            column.props.resizable = True
            column.props.reorderable = True
            column.set_sort_column_id(column_number)
            self.columns[field] = column

        for i in ('version', 'author', 'genre', 'artist', 'album', 'composer',
                  'date', 'track_number', 'track_count', 'disc_number',
                  'disc_count', 'copyright'):
            column_new(i)

        self.show_all()