Пример #1
0
class BasicToolbar(Gtk.Toolbar):

    def __init__(self, title):
        GObject.GObject.__init__(self)
        self.modify_bg(Gtk.StateType.NORMAL,
                       style.COLOR_BLACK.get_gdk_color())

        label = Gtk.Label()
        label.set_markup('<b>%s</b>' % title)
        label.set_halign(Gtk.Align.START)
        tool_item = Gtk.ToolItem()
        tool_item.set_expand(True)
        tool_item.add(label)
        tool_item.show_all()
        tool_item.props.margin_left = style.GRID_CELL_SIZE / 2
        self.insert(tool_item, -1)

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

        self.stop = ToolButton(icon_name='dialog-cancel')
        self.stop.set_tooltip(_('Cancel'))
        self.insert(self.stop, -1)
        self.stop.show()
Пример #2
0
 def makeToolbar(self, activity):
     self.activity = activity
     
     toolbar = ToolbarBox()
     
     activity_button = ActivityToolbarButton(activity)
     toolbar.toolbar.insert(activity_button, -1)
     activity_button.show()
     
     editmode = ToolButton('edit-description')
     editmode.set_tooltip(_("Enter Edit Mode"))
     editmode.set_accelerator(_('<ctrl>e'))
     editmode.connect('clicked', self.gotoCoding)
     toolbar.toolbar.insert(editmode, -1)
     editmode.show()
     
     separator = Gtk.SeparatorToolItem()
     separator.props.draw = False
     separator.set_expand(True)
     toolbar.toolbar.insert(separator, -1)
     separator.show()
     
     stop_button = StopButton(activity)
     toolbar.toolbar.insert(stop_button, -1)
     stop_button.show()
     
     return toolbar
Пример #3
0
    def add_text_icon_and_button(self, text, icon_name,
                                 button_icon=None,
                                 button_label=None,
                                 size='large', bold=False,
                                 color=style.COLOR_BLACK.get_html(),
                                 justify=Gtk.Justification.LEFT,
                                 stroke=style.COLOR_BUTTON_GREY.get_svg(),
                                 fill=style.COLOR_TRANSPARENT.get_svg(),
                                 icon_size=style.XLARGE_ICON_SIZE):
        label = Gtk.Label()
        label.set_use_markup(True)
        label.set_justify(justify)
        if bold:
            text = '<b>' + text + '</b>'
        span = '<span foreground="%s" size="%s">' % (color, size)
        label.set_markup(span + text + '</span>')

        icon = Icon(pixel_size=icon_size, icon_name=icon_name,
                    stroke_color=stroke, fill_color=fill)

        if button_icon is not None:
            button = ToolButton(button_icon)
        else:
            button = Gtk.Button()
            button.set_label(button_label)
        self._attach_three(label, icon, button)
        label.show()
        icon.show()
        button.show()
        return button
Пример #4
0
class TitleBox(VolumesToolbar):
    __gtype_name__ = 'TitleBox'

    def __init__(self):
        VolumesToolbar.__init__(self)

        label = Gtk.Label()
        label.set_markup('<b>%s</b>' % _('Choose an object'))
        label.set_alignment(0, 0.5)
        self._add_widget(label, expand=True)

        self.close_button = ToolButton(icon_name='dialog-cancel')
        self.close_button.set_tooltip(_('Close'))
        self.insert(self.close_button, -1)
        self.close_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()
class TitleBox(Gtk.Toolbar):

    def __init__(self, title_text):
        Gtk.Toolbar.__init__(self)

        label = Gtk.Label()
        title = _(title_text)

        label.set_markup('<b>%s</b>' % title)
        label.set_alignment(0, 0.5)
        self._add_widget(label, expand=True)

        self.close_button = ToolButton(icon_name='dialog-cancel')
        """
        self.close_button.set_tooltip(_('Close'))
        """
        self.insert(self.close_button, -1)
        self.close_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()
Пример #6
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        # Pause/Play button:

        stop_play = ToolButton('media-playback-stop')
        stop_play.set_tooltip(_("Stop"))
        stop_play.set_accelerator(_('<ctrl>space'))
        stop_play.connect('clicked', self._stop_play_cb)
        stop_play.show()

        toolbar_box.toolbar.insert(stop_play, -1)

        # Blank space (separator) and Stop button at the end:

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
Пример #7
0
class WebToolbar(Gtk.Toolbar):

    def __init__(self,browser):
        self.logger = logging.getLogger("gvr.Widgets.WebToolbar")

        Gtk.Toolbar.__init__(self)
        self._browser = browser
        
        self._back = ToolButton('go-previous')                           
        self._back.set_tooltip(_('Go back one page'))                                       
        self._back.connect('clicked', self._go_back_cb)                         
        self.insert(self._back, -1)                                             
        self._back.show() 
        
        self._forw = ToolButton('go-next')                           
        self._forw.set_tooltip(_('Go one page forward'))                                       
        self._forw.connect('clicked', self._go_forward_cb)                         
        self.insert(self._forw, -1)                                             
        self._forw.show() 
    
    def _go_forward_cb(self, button):
        if self._browser.can_go_forward():
            self._browser.go_forward()

    def _go_back_cb(self, button):
        if self._browser.can_go_back():
            self._browser.go_back()
Пример #8
0
class MainToolbar(Gtk.Toolbar):
    """ Main toolbar of the control panel
    """
    __gtype_name__ = 'MainToolbar'

    __gsignals__ = {
        'stop-clicked': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            ([])),
        'search-changed': (GObject.SignalFlags.RUN_FIRST,
                          None,
                          ([str])),
    }

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

        self._add_separator()

        tool_item = Gtk.ToolItem()
        self.insert(tool_item, -1)
        tool_item.show()
        self._search_entry = iconentry.IconEntry()
        self._search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
                                              'entry-search')
        self._search_entry.add_clear_button()
        self._search_entry.set_width_chars(25)
        text = _('Search in %s') % _('Settings')
        self._search_entry.set_placeholder_text(text)
        self._search_entry.connect('changed', self.__search_entry_changed_cb)
        tool_item.add(self._search_entry)
        self._search_entry.show()

        self._add_separator(True)

        self.stop = ToolButton(icon_name='dialog-cancel')
        self.stop.set_tooltip(_('Done'))
        self.stop.connect('clicked', self.__stop_clicked_cb)
        self.stop.show()
        self.insert(self.stop, -1)
        self.stop.show()

    def get_entry(self):
        return self._search_entry

    def _add_separator(self, expand=False):
        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        if expand:
            separator.set_expand(True)
        else:
            separator.set_size_request(style.DEFAULT_SPACING, -1)
        self.insert(separator, -1)
        separator.show()

    def __search_entry_changed_cb(self, search_entry):
        self.emit('search-changed', search_entry.props.text)

    def __stop_clicked_cb(self, button):
        self.emit('stop-clicked')
Пример #9
0
    def build_toolbar(self):

        # Create the toolbar box
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # Create the activity button
        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        # Create the pause/play button
        stop_play = ToolButton('media-playback-stop')
        stop_play.set_tooltip(_("Stop"))
        stop_play.set_accelerator(_('<ctrl>space'))
        stop_play.connect('clicked', self.stop_play_cb)
        stop_play.show()

        toolbar_box.toolbar.insert(stop_play, -1)

        # Create a blank separator and a Stop button
        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
Пример #10
0
class TitleBox(VolumesToolbar):
    __gtype_name__ = 'TitleBox'

    def __init__(self, what_filter='', filter_type=None):
        VolumesToolbar.__init__(self)

        label = Gtk.Label()
        title = _('Choose an object')
        if filter_type == FILTER_TYPE_MIME_BY_ACTIVITY:
            registry = bundleregistry.get_registry()
            bundle = registry.get_bundle(what_filter)
            if bundle is not None:
                title = _('Choose an object to open with %s activity') % \
                    bundle.get_name()

        label.set_markup('<b>%s</b>' % title)
        label.set_alignment(0, 0.5)
        self._add_widget(label, expand=True)

        self.close_button = ToolButton(icon_name='dialog-cancel')
        self.close_button.set_tooltip(_('Close'))
        self.insert(self.close_button, -1)
        self.close_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()
Пример #11
0
    def __init__(self, child, label, path, tabs):
        GObject.GObject.__init__(self)

        self.child = child
        self.label_text = label
        self._path = path  # Hide the path in the label
        self.tabs = tabs

        self.label_box = Gtk.EventBox()
        self._label = Gtk.Label(label=self.label_text)
        self._label.set_alignment(0, 0.5)
        self._label.show()

        self.label_box.add(self._label)
        self.label_box.connect('button-press-event', self._label_clicked)
        self.label_box.show_all()
        self.pack_start(self.label_box, True, True, 5)

        self.label_entry = Gtk.Entry()
        self.label_entry.connect('activate', self._label_entry_cb)
        self.label_entry.connect('focus-out-event', self._label_entry_cb)
        self.pack_start(self.label_entry, True, True, 0)

        button = ToolButton('close-tab')
        button.connect('clicked', self.__button_clicked_cb)
        self.pack_start(button, False, True, 0)
        button.show()
        self._close_button = button
        tab_object.append(self)
Пример #12
0
    def _create_export_button(self):
        # Add expoprt button
        export_data = ToolButton('save-as-data')

        export_data.props.tooltip = _('Export data')
        export_data.props.hide_tooltip_on_click = False
        export_data.palette_invoker.props.toggle_palette = True
        export_data.show()

        menu_box = PaletteMenuBox()
        export_data.props.palette.set_content(menu_box)

        menu_item = PaletteMenuItem(text_label=_('Export credits by day'))
        menu_item.connect('activate', self.__export_data_to_chart_cb,
                          'credit', DAY)
        menu_box.append_item(menu_item)

        menu_item = PaletteMenuItem(text_label=_('Export debits by day'))
        menu_item.connect('activate', self.__export_data_to_chart_cb,
                          'debit', DAY)
        menu_box.append_item(menu_item)

        menu_item = PaletteMenuItem(text_label=_('Export credits by month'))
        menu_item.connect('activate', self.__export_data_to_chart_cb,
                          'credit', MONTH)
        menu_box.append_item(menu_item)

        menu_item = PaletteMenuItem(text_label=_('Export debits by month'))
        menu_item.connect('activate', self.__export_data_to_chart_cb,
                          'debit', MONTH)
        menu_box.append_item(menu_item)

        menu_box.show_all()
        return export_data
Пример #13
0
class BasicToolbar(Gtk.Toolbar):

    def __init__(self, icon_name, title=''):
        GObject.GObject.__init__(self)

        icon = ToolButton(icon_name)
        self.insert(icon, -1)

        label = Gtk.Label()
        label.set_markup('<b>%s</b>' % title)
        label.set_alignment(0, 0.5)
        tool_item = Gtk.ToolItem()
        tool_item.set_expand(True)
        tool_item.add(label)
        tool_item.show_all()
        self.insert(tool_item, -1)

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

        self.stop = ToolButton(icon_name='dialog-cancel')
        self.stop.set_tooltip(_('Cancel'))
        self.insert(self.stop, -1)
        self.stop.show()

        self.confirm = ToolButton(icon_name='dialog-ok')
        self.confirm.set_tooltip(_('Done'))
        self.insert(self.confirm, -1)
        self.confirm.show()
Пример #14
0
class ViewToolbar(Gtk.Toolbar):
    __gtype_name__ = 'ViewToolbar'

    __gsignals__ = {
        'go-fullscreen': (GObject.SignalFlags.RUN_FIRST,
                          None,
                          ([])),
        'toggle-playlist': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            ([]))
    }

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

        self._show_playlist = ToggleToolButton('view-list')
        self._show_playlist.set_active(True)  # due to Activity.show_all()
        self._show_playlist.set_tooltip(_('Playlist'))
        self._show_playlist.set_accelerator('<ctrl>l')
        self._show_playlist.connect('toggled', self._playlist_toggled_cb)
        self.insert(self._show_playlist, -1)
        self._show_playlist.show()

        self._fullscreen = ToolButton('view-fullscreen')
        self._fullscreen.set_tooltip(_('Fullscreen'))
        self._fullscreen.set_accelerator('<ctrl>f')
        self._fullscreen.connect('clicked', self._fullscreen_cb)
        self.insert(self._fullscreen, -1)
        self._fullscreen.show()

    def _fullscreen_cb(self, button):
        self.emit('go-fullscreen')

    def _playlist_toggled_cb(self, button):
        self.emit('toggle-playlist')
Пример #15
0
    def __init__(self, comicbox):
        BaseWindow.__init__(self)

        self.toolbar = BasicToolbar('contract-coordinates')
        self.toolbar.stop.connect('clicked', self.__stop_clicked_cb)
        self.toolbar.confirm.connect('clicked', self.__ok_clicked_cb)

        reset_size = ToolButton(icon_name='box-size')
        reset_size.set_tooltip(_('Reset to box size'))
        self.toolbar.insert(reset_size, 3)
        reset_size.show()
        reset_size.connect('clicked', self.__reset_size_cb)

        self.comicbox = comicbox
        self.canvas = CanvasEditor(
            self.comicbox, self.comicbox.width,
            self.comicbox.height, self)

        label = Gtk.Label('')
        title = _('Drag to move or resize using the marked corners')
        label.set_markup('<span size="x-large">%s</span>' % title)

        self.vbox = Gtk.VBox()
        self.vbox.pack_start(self.toolbar, False, False, 0)
        self.vbox.pack_start(label, False, False, style.DEFAULT_SPACING)
        self.vbox.pack_start(self.canvas, True, True, 0)
        self.add(self.vbox)
        self.modify_bg(Gtk.StateType.NORMAL,
                       style.COLOR_WHITE.get_gdk_color())
Пример #16
0
    def __init__(self, activity, **kwargs):
        Gtk.ToolItem.__init__(self)

        description_button = ToolButton('edit-description')
        description_button.show()
        description_button.set_tooltip(_('Description'))
        description_button.palette_invoker.props.toggle_palette = True
        description_button.props.hide_tooltip_on_click = False
        self._palette = description_button.get_palette()

        description_box = PaletteMenuBox()
        sw = Gtk.ScrolledWindow()
        sw.set_size_request(int(Gdk.Screen.width() / 2),
                            2 * style.GRID_CELL_SIZE)
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self._text_view = Gtk.TextView()
        self._text_view.set_left_margin(style.DEFAULT_PADDING)
        self._text_view.set_right_margin(style.DEFAULT_PADDING)
        self._text_view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        text_buffer = Gtk.TextBuffer()
        if 'description' in activity.metadata:
            text_buffer.set_text(activity.metadata['description'])
        self._text_view.set_buffer(text_buffer)
        self._text_view.connect('focus-out-event',
                               self.__description_changed_cb, activity)
        sw.add(self._text_view)
        description_box.append_item(sw, vertical_padding=0)
        self._palette.set_content(description_box)
        description_box.show_all()

        self.add(description_button)

        activity.metadata.connect('updated', self.__jobject_updated_cb)
Пример #17
0
    def __init__(self, activity_name, has_local_help):
        Gtk.Toolbar.__init__(self)

        self._add_separator(False)

        if has_local_help and get_social_help_server():
            help_button = RadioToolButton()
            icon = Icon(icon_name='toolbar-help',
                        pixel_size=style.STANDARD_ICON_SIZE,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            help_button.set_icon_widget(icon)
            icon.show()
            help_button.props.tooltip = _('Help Manual')
            help_button.connect('toggled', self.__button_toggled_cb,
                                _MODE_HELP)
            self.insert(help_button, -1)
            help_button.show()
            self._add_separator(False)

            social_help_button = RadioToolButton()
            icon = Icon(icon_name='toolbar-social-help',
                        pixel_size=style.STANDARD_ICON_SIZE,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            social_help_button.set_icon_widget(icon)
            icon.show()
            social_help_button.props.tooltip = _('Social Help')
            social_help_button.props.group = help_button
            social_help_button.connect(
                'toggled', self.__button_toggled_cb, _MODE_SOCIAL_HELP)
            self.insert(social_help_button, -1)
            social_help_button.show()
            self._add_separator(False)

        self._back_button = ToolButton(icon_name='go-previous-paired')
        self._back_button.props.tooltip = _('Back')
        self._back_button.connect('clicked', self.__back_clicked_cb)
        self.insert(self._back_button, -1)
        self._back_button.show()
        self._forward_button = ToolButton(icon_name='go-next-paired')
        self._forward_button.props.tooltip = _('Forward')
        self._forward_button.connect('clicked', self.__forward_clicked_cb)
        self.insert(self._forward_button, -1)
        self._forward_button.show()

        title = _('Help: %s') % activity_name
        self._label = Gtk.Label()
        self._label.set_markup('<b>%s</b>' % title)
        self._label.set_alignment(0, 0.5)
        self._add_widget(self._label)

        self._add_separator(True)

        stop = ToolButton(icon_name='dialog-cancel')
        stop.set_tooltip(_('Close'))
        stop.connect('clicked', self.__stop_clicked_cb)
        self.insert(stop, -1)
        stop.show()
Пример #18
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        self.props.max_participants = 1

        self._web_view = WebKit.WebView()

        toolbox = ToolbarBox()
        self.set_toolbar_box(toolbox)
        toolbox.show()

        toolbar = toolbox.toolbar
        toolbar.show()

        activity_button = ActivityButton(self)
        toolbar.insert(activity_button, -1)

        viewtoolbar = ViewToolbar(self)
        viewtoolbar_button = ToolbarButton(
            page=viewtoolbar, icon_name='toolbar-view')
        toolbar.insert(viewtoolbar_button, -1)
        toolbar.show_all()

        self._back = ToolButton('go-previous-paired')
        self._back.set_tooltip(_('Back'))
        self._back.props.sensitive = False
        self._back.connect('clicked', self._go_back_cb)
        toolbar.insert(self._back, -1)
        self._back.show()
        
        self._forward = ToolButton('go-next-paired')
        self._forward.set_tooltip(_('Forward'))
        self._forward.props.sensitive = False
        self._forward.connect('clicked', self._go_forward_cb)
        toolbar.insert(self._forward, -1)
        self._forward.show()
        
        home = ToolButton('go-home')
        home.set_tooltip(_('Home'))
        home.connect('clicked', self._go_home_cb)
        toolbar.insert(home, -1)
        home.show()

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

        stopbtn = StopButton(self)
        toolbar.insert(stopbtn, -1)
        toolbar.show_all()

        self._web_view.connect('load-finished', self.update_navigation_buttons)

        self.set_canvas(self._web_view)
        self._web_view.show()

        self._web_view.load_uri(HOME)
Пример #19
0
class BooksToolbar(Gtk.Toolbar):
    __gtype_name__ = 'BooksToolbar'

    def __init__(self):
        Gtk.Toolbar.__init__(self)
        book_search_item = Gtk.ToolItem()

        self.search_entry = Gtk.Entry()
        self.search_entry.connect('activate', self.search_entry_activate_cb)
        self.search_entry.connect("key_press_event", self.keypress_cb)

        width = int(Gdk.Screen.width() / 2)
        self.search_entry.set_size_request(width, -1)

        book_search_item.add(self.search_entry)
        self.search_entry.show()
        self.search_entry.grab_focus()

        self.insert(book_search_item, -1)
        book_search_item.show()

        self.download = ToolButton('go-down')
        self.download.set_tooltip(_('Get Book'))
        self.download.props.sensitive = False
        self.download.connect('clicked', self.get_book_cb)
        self.insert(self.download, -1)
        self.download.show()

        self.hide_results = ToolButton('dialog-cancel')
        self.hide_results.set_tooltip(_('Remove Results List'))
        self.hide_results.props.sensitive = False
        self.hide_results.connect('clicked', self.hide_results_cb)
        self.insert(self.hide_results, -1)
        self.hide_results.show()

    def set_activity(self, activity):
        self.activity = activity

    def search_entry_activate_cb(self, entry):
        self.activity.find_books(entry.props.text)
        self.hide_results.props.sensitive = True

    def get_book_cb(self, button):
        self.activity.get_book()
 
    def enable_button(self,  state):
        self.download.props.sensitive = state
 
    def hide_results_cb(self,  button):
        self.activity.list_scroller.hide()
        self.hide_results.props.sensitive = False
    
    def keypress_cb(self, widget, event):
        keyname = Gdk.keyval_name(event.keyval)
        if keyname == 'Escape':
            self.activity.list_scroller.hide()
            self.hide_results.props.sensitive = False
            return True
Пример #20
0
class BaseWindow(Gtk.Box):
    '''
    A basic Sugar style popover window.
    Like view source mode.
    
    Use self to add content to a vbox.
    '''

    __gtype_name__ = 'BibliographyBaseWindow'
    
    def __init__(self):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.props.halign = Gtk.Align.CENTER
        self.props.valign = Gtk.Align.CENTER

        self._tb = Gtk.Toolbar()
        self.pack_start(self._tb, True, True, 0)
        self._tb.show()

        sep = Gtk.SeparatorToolItem()
        sep.props.draw = False
        self._tb.insert(sep, -1)
        sep.show()

        label = Gtk.Label()
        label.set_markup('<b>{}</b>'.format(_('Edit Bibliography Entry')))
        label.set_alignment(0, 0.5)
        self._add_widget(label)

        sep = Gtk.SeparatorToolItem()
        sep.props.draw = False
        sep.props.expand = True
        self._tb.insert(sep, -1)
        sep.show()

        self.add_ = ToolButton(icon_name='dialog-ok')
        self.add_.set_tooltip(_('Add Bibliography Item'))
        self._tb.insert(self.add_, -1)
        self.add_.show()

        stop = ToolButton(icon_name='dialog-cancel')
        stop.set_tooltip(_('Close'))
        stop.connect('clicked', lambda *args: self.destroy())
        self._tb.insert(stop, -1)
        stop.show()

        self.show()

    def _add_widget(self, widget):
        t = Gtk.ToolItem()
        t.props.expand = True
        t.add(widget)
        widget.show()
        self._tb.insert(t, -1)
        t.show()
Пример #21
0
class BooksToolbar(Gtk.Toolbar):
    __gtype_name__ = 'BooksToolbar'

    def __init__(self):
        Gtk.Toolbar.__init__(self)
        book_search_item = Gtk.ToolItem()

        self.search_entry = Gtk.Entry()
        self.search_entry.connect('activate', self.search_entry_activate_cb)

        width = int(Gdk.Screen.width() / 2)
        self.search_entry.set_size_request(width, -1)

        book_search_item.add(self.search_entry)
        self.search_entry.show()

        self.insert(book_search_item, -1)
        book_search_item.show()

        self._download = ToolButton('go-down')
        self._download.set_tooltip(_('Get Book'))
        self._download.props.sensitive = False
        self._download.connect('clicked', self._get_book_cb)
        self.insert(self._download, -1)
        self._download.show()

        self.format_combo = ComboBox()
        self.format_combo.connect('changed', self.format_changed_cb)
        self.format_combo.append_item('.djvu', 'Deja Vu')
        self.format_combo.append_item('_bw.pdf', 'B/W PDF')
        self.format_combo.append_item('.pdf', 'Color PDF')
        self.format_combo.append_item('.epub', 'EPUB')
        self.format_combo.set_active(0)
        self.format_combo.props.sensitive = False
        combotool = ToolComboBox(self.format_combo)
        self.insert(combotool, -1)
        combotool.show()

        self.search_entry.grab_focus()

    def set_activity(self, activity):
        self.activity = activity

    def format_changed_cb(self, combo):
        if self.activity != None:
            self.activity.show_book_data()

    def search_entry_activate_cb(self, entry):
        self.activity.find_books(entry.props.text)

    def _get_book_cb(self, button):
        self.activity.get_book()
 
    def enable_button(self,  state):
        self._download.props.sensitive = state
        self.format_combo.props.sensitive = state
Пример #22
0
    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        toolbarview = Gtk.Toolbar()
        langtoolbar_button = ToolbarButton(
            label=_('View'),
            page=toolbarview,
            icon_name='settings')
        langtoolbar_button.show()
        toolbar_box.toolbar.insert(langtoolbar_button, -1)
        tool = ToolButton('en')
        tool.set_tooltip(_('English'))
        tool.connect('clicked', self.language_en)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('es')
        tool.set_tooltip(_('Spanish'))
        tool.connect('clicked', self.language_es)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('fr')
        tool.set_tooltip(_('French'))
        tool.connect('clicked', self.language_fr)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('remote')
        tool.set_tooltip(_('Server settings'))
        tool.connect('clicked', self.settings)
        tool.show()
        toolbarview.insert(tool, -1)
        toolbarview.show()

        favorite_button = ToolButton(self.favorite_status)
        favorite_button.set_tooltip('Filter on favorite')
        favorite_button.connect('clicked', self.favorite)
        toolbar_box.toolbar.insert(favorite_button, -1)
        favorite_button.show()
        self.favorite_button = favorite_button

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
Пример #23
0
    def __init__(self, activity, abi):

        toolbar = activity.activity_button.props.page
        for i in self._EXPORT_FORMATS:
            if abi.get_version() == '3.0' and i['title'].find('PDF') > -1:
                # pdf export crashes on abiword 3.0
                continue
            button = ToolButton(i['icon'])
            button.set_tooltip(i['title'])
            button.connect('clicked', self.__clicked_cb, activity, abi, i)
            toolbar.insert(button, -1)
            button.show()
Пример #24
0
    def __init__(self, parent_xid, dialog_title):
        Gtk.Window.__init__(self)

        self.connect('realize', self.__realize_cb)

        self.set_decorated(False)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_border_width(style.LINE_WIDTH)
        self.set_resizable(False)

        width = Gdk.Screen.width() - style.GRID_CELL_SIZE * 4
        height = Gdk.Screen.height() - style.GRID_CELL_SIZE * 4
        self.set_size_request(width, height)

        self._parent_window_xid = parent_xid

        _vbox = Gtk.VBox(spacing=2)
        self.add(_vbox)

        self.toolbar = Gtk.Toolbar()
        label = Gtk.Label()
        label.set_markup('<b>  %s</b>' % dialog_title)
        label.set_alignment(0, 0.5)
        tool_item = Gtk.ToolItem()
        tool_item.add(label)
        label.show()
        self.toolbar.insert(tool_item, -1)
        tool_item.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self.toolbar.insert(separator, -1)
        separator.show()
        stop = ToolButton(icon_name='dialog-cancel')
        stop.set_tooltip(_('Cancel'))
        stop.connect('clicked', self.cancel_clicked_cb)
        self.toolbar.insert(stop, -1)
        stop.show()

        accept = ToolButton(icon_name='dialog-ok')
        accept.set_tooltip(_('Ok'))
        accept.connect('clicked', self.accept_clicked_cb)
        accept.show()
        self.toolbar.insert(accept, -1)

        _vbox.pack_start(self.toolbar, False, True, 0)
        self.toolbar.show()

        self._event_box = Gtk.EventBox()
        _vbox.pack_start(self._event_box, True, True, 0)
        self._canvas = None
Пример #25
0
    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        self.toolbarview = Gtk.Toolbar()
        langtoolbar_button = ToolbarButton(
            label=_('Filter'),
            page=self.toolbarview,
            icon_name='filter')
        langtoolbar_button.show()
        toolbar_box.toolbar.insert(langtoolbar_button, -1)
        self.toolbarview.show()

        box_search_item = Gtk.ToolItem()
        self.search_entry = Gtk.Entry()
        self.search_entry.connect('changed', self.text_filter)
        self.search_entry.set_size_request(300, -1)
        box_search_item.add(self.search_entry)
        self.search_entry.show()
        box_search_item.show()
        toolbar_box.toolbar.insert(box_search_item, -1)

        favorite_button = ToolButton(self.favorite_status)
        favorite_button.set_tooltip('Filter on favorite')
        favorite_button.connect('clicked', self.favorite)
        toolbar_box.toolbar.insert(favorite_button, -1)
        favorite_button.show()
        self.favorite_button = favorite_button

        library_button = ToolButton('library')
        library_button.set_tooltip('Show libraries')
        library_button.connect('clicked', self.library_clicked)
        toolbar_box.toolbar.insert(library_button, -1)
        library_button.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
    def __init__(self, activity):
        self._activity = activity
        self._current_palette = 'turtle'

        Gtk.ToolItem.__init__(self)

        help_button = ToolButton('help-toolbar')
        help_button.set_tooltip(_('Help'))
        self.add(help_button)
        help_button.show()

        self._palette = help_button.get_palette()

        help_button.connect('clicked', self.__help_button_clicked_cb)
Пример #27
0
 def add_button(self, button_label, callback, arg=None, button_icon=None):
     if button_icon is not None:
         button = ToolButton(button_icon)
     else:
         button = Gtk.Button()
         button.set_label(button_label)
     self._attach_center(button)
     if callback is not None:
         if arg is None:
             button.connect('clicked', callback)
         else:
             button.connect('clicked', callback, arg)
     button.show()
     return button
Пример #28
0
class ViewToolbar(Gtk.Toolbar):
    def __init__(self, activity):
        GObject.GObject.__init__(self)

        self._activity = activity

        self._browser = self._activity._web_view

        self.zoomout = ToolButton('zoom-out', accelerator='<ctrl>minus')
        self.zoomout.set_tooltip(_('Zoom out'))
        self.zoomout.connect('clicked', self.__zoomout_clicked_cb)
        self.insert(self.zoomout, -1)
        self.zoomout.show()

        self.zoomin = ToolButton('zoom-in', accelerator='<ctrl>plus')
        self.zoomin.set_tooltip(_('Zoom in'))
        self.zoomin.connect('clicked', self.__zoomin_clicked_cb)
        self.insert(self.zoomin, -1)
        self.zoomin.show()

        self.zoom_original = ToolButton('zoom-original', accelerator='<ctrl>0')
        self.zoom_original.set_tooltip(_('Actual size'))
        self.zoom_original.connect('clicked', self.__zoom_original_clicked_cb)
        self.insert(self.zoom_original, -1)
        self.zoom_original.show()

        self._zoom_update_sensitive()

        self.separator = Gtk.SeparatorToolItem()
        self.separator.set_draw(True)
        self.insert(self.separator, -1)
        self.separator.show()

        self.fullscreen = ToolButton('view-fullscreen')
        self.fullscreen.set_tooltip(_('Fullscreen'))
        self.fullscreen.connect('clicked', self.__fullscreen_clicked_cb)
        self.insert(self.fullscreen, -1)
        self.fullscreen.show()

    def _zoom_update_sensitive(self):
        self.zoomout.set_sensitive(self._activity.can_zoom_out())
        self.zoomin.set_sensitive(self._activity.can_zoom_in())
        self.zoom_original.set_sensitive(self._activity.can_zoom_original())

    def __zoomin_clicked_cb(self, button):
        if button.is_sensitive():
            self._activity.zoom_in()
        self._zoom_update_sensitive()

    def __zoomout_clicked_cb(self, button):
        if button.is_sensitive():
            self._activity.zoom_out()
        self._zoom_update_sensitive()

    def __zoom_original_clicked_cb(self, button):
        self._activity.zoom_original()
        self._zoom_update_sensitive()

    def __fullscreen_clicked_cb(self, button):
        self._activity.fullscreen()
Пример #29
0
    def __init__(self, activity):
        self._activity = activity
        self._current_palette = 'turtle'

        Gtk.ToolItem.__init__(self)

        help_button = ToolButton('help-toolbar')
        help_button.set_tooltip(_('Help'))
        self.add(help_button)
        help_button.show()

        self._palette = help_button.get_palette()

        help_button.connect('clicked', self.__help_button_clicked_cb)
Пример #30
0
 def add_button(self, button_label, callback, arg=None, button_icon=None):
     if button_icon is not None:
         button = ToolButton(button_icon)
     else:
         button = Gtk.Button()
         button.set_label(button_label)
     self._attach_center(button)
     if callback is not None:
         if arg is None:
             button.connect('clicked', callback)
         else:
             button.connect('clicked', callback, arg)
     button.show()
     return button
Пример #31
0
 def makeDelToolbar(self, activity):
     toolbar = self.makeGenericToolbar(activity)
     
     separator = Gtk.SeparatorToolItem()
     toolbar.toolbar.insert(separator, 5)
     separator.show()
     
     btn = ToolButton('block-delete')
     btn.set_tooltip(_('Delete Selected Block'))
     toolbar.toolbar.insert(btn, 6)
     btn.connect('clicked', self.menuRemove)
     btn.show()
     
     return toolbar
Пример #32
0
class Toolbar(Gtk.Toolbar):
    def __init__(self, web_view):
        Gtk.Toolbar.__init__(self)

        self._web_view = web_view

        self._back = ToolButton('go-previous-paired')
        self._back.set_tooltip(_('Back'))
        self._back.props.sensitive = False
        self._back.connect('clicked', self._go_back_cb)
        self.insert(self._back, -1)
        self._back.show()

        self._forward = ToolButton('go-next-paired')
        self._forward.set_tooltip(_('Forward'))
        self._forward.props.sensitive = False
        self._forward.connect('clicked', self._go_forward_cb)
        self.insert(self._forward, -1)
        self._forward.show()

        home = ToolButton('zoom-home')
        home.set_tooltip(_('Home'))
        home.connect('clicked', self._go_home_cb)
        self.insert(home, -1)
        home.show()

        #progress_listener = self._web_view.progress
        #progress_listener.connect('location-changed',
        #                          self._location_changed_cb)
        #progress_listener.connect('loading-stop', self._loading_stop_cb)

    def _location_changed_cb(self, progress_listener, uri):
        self.update_navigation_buttons()

    def _loading_stop_cb(self, progress_listener):
        self.update_navigation_buttons()

    def update_navigation_buttons(self):
        self._back.set_sensitive(self._web_view.can_go_back())
        self._forward.set_sensitive(self._web_view.can_go_forward())

    def _go_back_cb(self, button):
        self._web_view.go_back()

    def _go_forward_cb(self, button):
        self._web_view.go_forward()()

    def _go_home_cb(self, button):
        self._web_view.load_uri(HOME)
Пример #33
0
    def __init__(self):
        ToolbarBox.__init__(self)

        self._metadata = None
        self._temp_file_path = None

        self._resume = ToolButton('activity-start')
        self._resume.connect('clicked', self._resume_clicked_cb)
        self.toolbar.insert(self._resume, -1)
        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.toolbar.insert(self._copy, -1)
        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.toolbar.insert(self._duplicate, -1)

        if len(accountsmanager.get_configured_accounts()) > 0:
            self._refresh = ToolButton()
            icon = Icon(icon_name='refresh', xo_color=color)
            self._refresh.set_icon_widget(icon)
            icon.show()

            self._refresh.set_tooltip(_('Refresh'))
            self._refresh.connect('clicked', self._refresh_clicked_cb)
            self.toolbar.insert(self._refresh, -1)
            self._refresh.show()

        separator = Gtk.SeparatorToolItem()
        self.toolbar.insert(separator, -1)
        separator.show()

        erase_button = ToolButton('list-remove')
        erase_button.set_tooltip(_('Erase'))
        erase_button.connect('clicked', self._erase_button_clicked_cb)
        self.toolbar.insert(erase_button, -1)
        erase_button.show()
Пример #34
0
 def makeModToolbar(self, activity):
     toolbar = self.makeGenericToolbar(activity)
     
     separator = Gtk.SeparatorToolItem()
     toolbar.toolbar.insert(separator, 5)
     separator.show()
     
     btn = ToolButton('block-edit')
     btn.set_tooltip(_('Edit Selected Block'))
     btn.props.accelerator = '<Ctrl>e'
     toolbar.toolbar.insert(btn, 6)
     btn.connect('clicked', self.menuEdit)
     btn.show()
     
     return toolbar
Пример #35
0
    def makeModToolbar(self, activity):
        toolbar = self.makeGenericToolbar(activity)

        separator = Gtk.SeparatorToolItem()
        toolbar.toolbar.insert(separator, 5)
        separator.show()

        btn = ToolButton('block-edit')
        btn.set_tooltip(_('Edit Selected Block'))
        btn.props.accelerator = '<Ctrl>e'
        toolbar.toolbar.insert(btn, 6)
        btn.connect('clicked', self.menuEdit)
        btn.show()

        return toolbar
Пример #36
0
class TestPalette(Test):
    def __init__(self):
        Test.__init__(self)

        toolbar = Gtk.Toolbar()

        self._invoker = ToolButton('go-previous')
        toolbar.insert(self._invoker, -1)
        self._invoker.show()

        self.pack_start(toolbar, False)
        toolbar.show()

    def set_palette(self, palette):
        self._invoker.set_palette(palette)
Пример #37
0
    def __init__(self, activity_name, has_local_help):
        Gtk.Toolbar.__init__(self)

        self._add_separator(False)

        if has_local_help and get_social_help_server():
            help_button = RadioToolButton()
            icon = Icon(icon_name='toolbar-help',
                        pixel_size=style.STANDARD_ICON_SIZE,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            help_button.set_icon_widget(icon)
            icon.show()
            help_button.props.tooltip = _('Help Manual')
            help_button.connect('toggled', self.__button_toggled_cb,
                                _MODE_HELP)
            self.insert(help_button, -1)
            help_button.show()
            self._add_separator(False)

            social_help_button = RadioToolButton()
            icon = Icon(icon_name='toolbar-social-help',
                        pixel_size=style.STANDARD_ICON_SIZE,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            social_help_button.set_icon_widget(icon)
            icon.show()
            social_help_button.props.tooltip = _('Social Help')
            social_help_button.props.group = help_button
            social_help_button.connect('toggled', self.__button_toggled_cb,
                                       _MODE_SOCIAL_HELP)
            self.insert(social_help_button, -1)
            social_help_button.show()
            self._add_separator(False)

        title = _('Help: %s') % activity_name
        self._label = Gtk.Label()
        self._label.set_markup('<b>%s</b>' % title)
        self._label.set_alignment(0, 0.5)
        self._add_widget(self._label)

        self._add_separator(True)

        stop = ToolButton(icon_name='dialog-cancel')
        stop.set_tooltip(_('Close'))
        stop.connect('clicked', self.__stop_clicked_cb)
        self.insert(stop, -1)
        stop.show()
Пример #38
0
    def _create_edit_toolbar(self):
        edit_toolbar = EditToolbar()
        edit_toolbar.undo.props.visible = False
        edit_toolbar.redo.props.visible = False
        edit_toolbar.separator.props.visible = False
        edit_toolbar.copy.connect('clicked', self.__copy_cb)
        edit_toolbar.copy.props.accelerator = '<Ctrl><Shift>C'
        edit_toolbar.paste.connect('clicked', self.__paste_cb)
        edit_toolbar.paste.props.accelerator = '<Ctrl><Shift>V'

        clear = ToolButton('edit-clear')
        clear.set_tooltip(_('Clear scrollback'))
        clear.connect('clicked', self.__clear_cb)
        edit_toolbar.insert(clear, -1)
        clear.show()
        return edit_toolbar
    def __init__(self, handle):
        "The entry point to the Activity"
        activity.Activity.__init__(self, handle, False)
        self.max_participants = 1

        self._sequence = 0
        self.selected_book = None
        self.queryresults = None
        self._getter = None
        self.show_images = True
        self.languages = {}
        self._lang_code_handler = languagenames.LanguageNames()
        self.catalogs_configuration = {}
        self.catalog_history = []

        if os.path.exists('/etc/get-books.cfg'):
            self._read_configuration('/etc/get-books.cfg')
        else:
            self._read_configuration()

        toolbar_box = ToolbarBox()
        activity_button = ToolButton()
        color = profile.get_color()
        bundle = ActivityBundle(activity.get_bundle_path())
        icon = Icon(file=bundle.get_icon(), xo_color=color)
        activity_button.set_icon_widget(icon)
        activity_button.show()

        toolbar_box.toolbar.insert(activity_button, 0)
        self._add_search_controls(toolbar_box.toolbar)

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

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

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()
        self._books_toolbar = toolbar_box.toolbar

        self._create_controls()

        self.using_powerd = os.access(POWERD_INHIBIT_DIR, os.W_OK)

        self.__book_downloader = self.__image_downloader = None
    def _create_toolbar(self):
        toolbar_box = ToolbarBox()

        zoom_out_button = ToolButton('zoom-out')
        zoom_out_button.set_tooltip(_('Zoom out'))
        zoom_out_button.connect('clicked', self.__zoom_out_cb)
        toolbar_box.toolbar.insert(zoom_out_button, -1)
        zoom_out_button.show()

        zoom_in_button = ToolButton('zoom-in')
        zoom_in_button.set_tooltip(_('Zoom in'))
        zoom_in_button.connect('clicked', self.__zoom_in_cb)
        toolbar_box.toolbar.insert(zoom_in_button, -1)
        zoom_in_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = True
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        self._back_page_button = ToolButton('go-previous-paired')
        self._back_page_button.set_tooltip(_('Previous page'))
        self._back_page_button.props.sensitive = False
        self._back_page_button.connect('clicked', self.__go_back_page_cb)
        toolbar_box.toolbar.insert(self._back_page_button, -1)
        self._back_page_button.show()

        self._forward_page_button = ToolButton('go-next-paired')
        self._forward_page_button.set_tooltip(_('Next page'))
        self._forward_page_button.props.sensitive = False
        self._forward_page_button.connect('clicked', self.__go_forward_page_cb)
        toolbar_box.toolbar.insert(self._forward_page_button, -1)
        self._forward_page_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = True
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        self._save_to_journal_button = ToolButton('save-to-journal')
        self._save_to_journal_button.set_tooltip(_('Save PDF to Journal'))
        self._save_to_journal_button.connect('clicked',
                                             self.__save_to_journal_button_cb)
        toolbar_box.toolbar.insert(self._save_to_journal_button, -1)
        self._save_to_journal_button.show()

        return toolbar_box
Пример #41
0
class SmileyToolbar(Gtk.Toolbar):

    def __init__(self, activity):
        Gtk.Toolbar.__init__(self)

        self._activity = activity
        self._add_separator()

        self._icon = Icon(icon_name='smilies-white')
        self._add_widget(self._icon)

        self._add_separator()

        self._title = Gtk.Label(_('Insert a smiley'))
        self._add_widget(self._title)

        self._add_separator(True)

        self.cancel_button = ToolButton('dialog-cancel')
        self.cancel_button.set_tooltip(_('Cancel'))
        self.cancel_button.connect('clicked', self.__cancel_button_clicked_cb)
        self.insert(self.cancel_button, -1)
        self.cancel_button.show()

    def _add_separator(self, expand=False):
        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        if expand:
            separator.set_expand(True)
        else:
            separator.set_size_request(style.DEFAULT_SPACING, -1)
        self.insert(separator, -1)
        separator.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 __cancel_button_clicked_cb(self, widget, data=None):
        self._activity._hide_smiley_window()
Пример #42
0
    def __init__(self, journalactivity):
        ToolbarBox.__init__(self)
        self._journalactivity = journalactivity
        self._metadata = None
        self._temp_file_path = None
        self._refresh = None

        self._resume = ToolButton('activity-start')
        self._resume.connect('clicked', self._resume_clicked_cb)
        self.toolbar.insert(self._resume, -1)
        self._resume.show()
        self._resume_menu = None

        color = profile.get_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.toolbar.insert(self._copy, -1)
        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.toolbar.insert(self._duplicate, -1)

        if accountsmanager.has_configured_accounts():
            self._refresh = ToolButton('entry-refresh')
            self._refresh.set_tooltip(_('Refresh'))
            self._refresh.connect('clicked', self._refresh_clicked_cb)
            self.toolbar.insert(self._refresh, -1)
            self._refresh.show()

        separator = Gtk.SeparatorToolItem()
        self.toolbar.insert(separator, -1)
        separator.show()

        erase_button = ToolButton('list-remove')
        erase_button.set_tooltip(_('Erase'))
        erase_button.connect('clicked', self._erase_button_clicked_cb)
        self.toolbar.insert(erase_button, -1)
        erase_button.show()
Пример #43
0
    def __init__(self, data, toplevel, jobject):
        PopWindow.__init__(self, transient_for=toplevel)
        self.props.size = PopWindow.FULLSCREEN
        w, h = PopWindow.FULLSCREEN
        self._toplevel = toplevel
        self._jobject = jobject

        self._links = data.get('shared_links', [])
        if not self._links:
            self._show_howto_copy()
            return

        self._total_links = len(self._links)
        self._entry = None

        self._paned = Gtk.Paned()
        self.add_view(self._paned)
        self._paned.show()

        self._webview = WebKit2.WebView()
        self._paned.add1(self._webview)
        self._webview.set_size_request(w / 2, h)
        self._webview.show()

        self._2box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self._paned.add2(self._2box)
        self._2box.show()

        self._combo = Gtk.ComboBoxText()
        for t in WEB_TYPES:
            self._combo.append(t.type, t.name)
        self._combo.set_active(0)
        self._combo.connect('changed', self.__combo_changed_cb)
        self._2box.add(self._combo)
        self._combo.show()

        self.next_link()

        add = ToolButton(icon_name='dialog-ok')
        add.props.tooltip = \
            _('Add This Bibliography Item and Continue to Next Bookmark')
        add.connect('clicked', self.__add_clicked_cb)
        self.props.title_box.insert(add, -2)
        add.show()
Пример #44
0
    def __init__(self, activity_name):
        Gtk.Toolbar.__init__(self)

        title = 'Help: ' + activity_name

        self._add_separator(False)

        label = Gtk.Label()
        label.set_markup('<b>%s</b>' % title)
        label.set_alignment(0, 0.5)
        self._add_widget(label)

        self._add_separator(True)

        stop = ToolButton(icon_name='dialog-cancel')
        stop.set_tooltip(_('Close'))
        stop.connect('clicked', self.__stop_clicked_cb)
        self.insert(stop, -1)
        stop.show()
Пример #45
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.max_participants = 1
        self.sound_enable = True

        toolbox = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbox.toolbar.insert(activity_button, 0)
        activity_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = True
        toolbox.toolbar.insert(separator, -1)
        separator.show()

        sound_button = ToolButton('speaker-muted-100')
        sound_button.set_tooltip(_('Sound'))
        sound_button.connect('clicked', self.sound_control)
        toolbox.toolbar.insert(sound_button, -1)
        sound_button.show()

        separator2 = Gtk.SeparatorToolItem()
        separator2.props.draw = False
        separator2.set_expand(True)
        toolbox.toolbar.insert(separator2, -1)
        separator2.show()

        stop_button = StopButton(self)
        stop_button.props.accelerator = _('<Ctrl>Q')
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()

        toolbox.show()
        self.set_toolbar_box(toolbox)
        self.show_all()

        self.game = conozco.Conozco(self)
        self.game.canvas = sugargame.canvas.PygameCanvas(
            self, main=self.game.run, modules=[
                pygame.display, pygame.font, pygame.mixer])
        self.set_canvas(self.game.canvas)
        self.game.canvas.grab_focus()
Пример #46
0
class ViewToolbar(Gtk.Toolbar):
    __gtype_name__ = 'ViewToolbar'

    __gsignals__ = {
        'needs-update-size':
        (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ([])),
        'go-fullscreen': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ([]))
    }

    def __init__(self):
        Gtk.Toolbar.__init__(self)
        self.fullscreen = ToolButton('view-fullscreen')
        self.fullscreen.set_tooltip(_('Fullscreen'))
        self.fullscreen.connect('clicked', self.fullscreen_cb)
        self.insert(self.fullscreen, -1)
        self.fullscreen.show()

    def fullscreen_cb(self, button):
        self.emit('go-fullscreen')
Пример #47
0
def button_factory(icon_name, toolbar, callback, cb_arg=None, tooltip=None,
                   accelerator=None):
    '''Factory for making tooplbar buttons'''
    button = ToolButton(icon_name)
    if tooltip is not None:
        button.set_tooltip(tooltip)
    button.props.sensitive = True
    if accelerator is not None:
        button.props.accelerator = accelerator
    if cb_arg is not None:
        button.connect('clicked', callback, cb_arg)
    else:
        button.connect('clicked', callback)
    if hasattr(toolbar, 'insert'):  # the main toolbar
        toolbar.insert(button, -1)
    else:  # or a secondary toolbar
        toolbar.props.page.insert(button, -1)
    button.show()
    return button
Пример #48
0
    def build_toolbar(self):

        self.max_participants = 1

        toolbox = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        toolbox.toolbar.insert(activity_button, -1)
        activity_button.show()

        pano_toolbar = toolbox.toolbar

        new_button = ToolButton('stock_refresh')
        new_button.set_tooltip(_('New Panorama'))
        new_button.connect('clicked', self.new_event)
        pano_toolbar.insert(new_button, -1)
        new_button.show()

        capture_button = ToolButton('add_capture')
        capture_button.set_tooltip(_('Add a capture to the Panorama'))
        capture_button.connect('clicked', self.capture_event)
        pano_toolbar.insert(capture_button, -1)
        capture_button.show()

        stitch_button = ToolButton('format-columns-triple')
        stitch_button.set_tooltip(_('Stitch Panorama'))
        stitch_button.connect('clicked', self.stitch_event)
        pano_toolbar.insert(stitch_button, -1)
        stitch_button.show()

        stiching_auto = ToolButton('media-playback-start')
        stiching_auto.set_tooltip(_('Enable auto-stitch'))
        stiching_auto.connect('clicked', self.change_stich)
        pano_toolbar.insert(stiching_auto, -1)

        save_button = ToolButton('filesave')
        save_button.set_tooltip(_('Save Panorama'))
        save_button.connect('clicked', self.save_event)
        pano_toolbar.insert(save_button, -1)
        save_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        pano_toolbar.insert(separator, -1)

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        pano_toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbox)

        toolbox.show_all()
Пример #49
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        # Pause/Play button:

        pause_play = ToolButton('media-playback-pause')
        pause_play.set_tooltip(_("Pause"))
        pause_play.set_accelerator(_('<ctrl>space'))
        pause_play.connect('clicked', self._pause_play_cb)
        pause_play.show()

        toolbar_box.toolbar.insert(pause_play, 0)
	
		# Information button:
		
        info_button = ToolButton('info_button')
        info_button.set_tooltip(_("Display Keybinds"))
        info_button.set_accelerator(_('<shift>space'))
        info_button.connect('clicked', self._open_info_cb)
        info_button.show()
		
        toolbar_box.toolbar.insert(info_button, 1)

        # Blank space (separator) and Stop button at the end:

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
        stop_button.connect('clicked', self._stop_cb)
Пример #50
0
class AddNotebook(Gtk.Notebook):
    '''
    AddNotebook
    -----------
    This subclass has a add button which emits tab-added on clicking the
    button.
    '''
    __gsignals__ = {
        'tab-added': (GObject.SignalFlags.RUN_FIRST, None, ([])),
    }

    def __init__(self):
        Gtk.Notebook.__init__(self)

        self._add_tab = ToolButton('gtk-add')
        self._add_tab.connect('clicked', self._add_tab_cb)
        self._add_tab.show()
        self.set_action_widget(self._add_tab, Gtk.PackType.END)

    def _add_tab_cb(self, button):
        self.emit('tab-added')
Пример #51
0
class RecordToolbar(Gtk.Toolbar):
    def __init__(self, jam):
        GObject.GObject.__init__(self)

        def _insertSeparator(x=1):
            for i in range(x):
                self.separator = Gtk.SeparatorToolItem()
                self.separator.set_draw(True)
                self.insert(self.separator, -1)
                self.separator.show()

        #self.toolbox = toolbox
        self.jam = jam

        if Config.FEATURES_MIC:
            self.micRec1Button = ToolButton('rec1')
            self.micRec1Button.connect('clicked', self.jam.micRec, 'mic1')
            self.insert(self.micRec1Button, -1)
            self.micRec1Button.show()
            self.micRec1Button.set_tooltip(_('Record microphone into slot 1'))

            self.micRec2Button = ToolButton('rec2')
            self.micRec2Button.connect('clicked', self.jam.micRec, 'mic2')
            self.insert(self.micRec2Button, -1)
            self.micRec2Button.show()
            self.micRec2Button.set_tooltip(_('Record microphone into slot 2'))

            self.micRec3Button = ToolButton('rec3')
            self.micRec3Button.connect('clicked', self.jam.micRec, 'mic3')
            self.insert(self.micRec3Button, -1)
            self.micRec3Button.show()
            self.micRec3Button.set_tooltip(_('Record microphone into slot 3'))

            self.micRec4Button = ToolButton('rec4')
            self.micRec4Button.connect('clicked', self.jam.micRec, 'mic4')
            self.insert(self.micRec4Button, -1)
            self.micRec4Button.show()
            self.micRec4Button.set_tooltip(('Record microphone into slot 4'))

        _insertSeparator()

        if Config.FEATURES_NEWSOUNDS:
            self._loopSettingsPalette = LoopSettingsPalette(
                _('Add new Sound'), self.jam)
            self.loopSetButton = ToggleToolButton('loop')
            self.loopSetButton.set_palette(self._loopSettingsPalette)
            self.insert(self.loopSetButton, -1)
            self.loopSetButton.show()

        self.show_all()
Пример #52
0
    def _create_view_toolbar(self):  # Color changer and Zoom toolbar
        view_toolbar = Gtk.Toolbar()

        self._theme_toggler = ToolButton('dark-theme')
        self._theme_toggler.set_tooltip('Switch to Dark Theme')
        self._theme_toggler.props.accelerator = '<Ctrl><Shift>I'
        self._theme_toggler.connect('clicked', self._toggled_theme)
        view_toolbar.insert(self._theme_toggler, -1)
        self._theme_toggler.show()

        sep = Gtk.SeparatorToolItem()
        view_toolbar.insert(sep, -1)
        sep.show()

        zoom_out_button = ToolButton('zoom-out')
        zoom_out_button.set_tooltip(_('Zoom out'))
        zoom_out_button.props.accelerator = '<Ctrl>minus'
        zoom_out_button.connect('clicked', self.__zoom_out_cb)
        view_toolbar.insert(zoom_out_button, -1)
        zoom_out_button.show()

        zoom_in_button = ToolButton('zoom-in')
        zoom_in_button.set_tooltip(_('Zoom in'))
        zoom_in_button.props.accelerator = '<Ctrl>plus'
        zoom_in_button.connect('clicked', self.__zoom_in_cb)
        view_toolbar.insert(zoom_in_button, -1)
        zoom_in_button.show()

        fullscreen_button = ToolButton('view-fullscreen')
        fullscreen_button.set_tooltip(_("Fullscreen"))
        fullscreen_button.props.accelerator = '<Alt>Return'
        fullscreen_button.connect('clicked', self.__fullscreen_cb)
        view_toolbar.insert(fullscreen_button, -1)
        fullscreen_button.show()
        return view_toolbar
Пример #53
0
class TitleBox(Gtk.Toolbar):
    def __init__(self):
        Gtk.Toolbar.__init__(self)

        self.close_button = ToolButton(icon_name='dialog-cancel')
        self.close_button.set_tooltip(_('Close'))
        self.insert(self.close_button, -1)
        self.close_button.show()

        self._label = Gtk.Label()
        self._label.set_alignment(0, 0.5)

        tool_item = Gtk.ToolItem()
        tool_item.set_expand(True)
        tool_item.add(self._label)
        self._label.show()
        self.insert(tool_item, 0)
        tool_item.show()

    def set_title(self, title):
        self._label.set_markup('<b>%s</b>' % title)
        self._label.show()
Пример #54
0
    def __init__(self):
        ToolbarBox.__init__(self)

        self._metadata = None
        self._temp_file_path = None

        self._resume = ToolButton('activity-start')
        self._resume.connect('clicked', self._resume_clicked_cb)
        self.toolbar.insert(self._resume, -1)
        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.toolbar.insert(self._copy, -1)
        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.toolbar.insert(self._duplicate, -1)

        separator = Gtk.SeparatorToolItem()
        self.toolbar.insert(separator, -1)
        separator.show()

        erase_button = ToolButton('list-remove')
        erase_button.set_tooltip(_('Erase'))
        erase_button.connect('clicked', self._erase_button_clicked_cb)
        self.toolbar.insert(erase_button, -1)
        erase_button.show()
Пример #55
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()

        play_button = ToolButton('media-playback-start')
        play_button.props.accelerator = 'P'
        toolbar_box.toolbar.insert(play_button, -1)
        play_button.show()
        play_button.connect('clicked', self._play_cb)

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

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl><Shift>Q'
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
        stop_button.connect('clicked', self._stop_cb)

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
Пример #56
0
class DevelopViewToolbar(Gtk.Toolbar):
    __gsignals__ = {
        'font-size-changed': (GObject.SIGNAL_RUN_FIRST, None,
                              (int,)),
    }

    def __init__(self, _activity):
        GObject.GObject.__init__(self)

        self._activity = _activity
        self.font_size = DEFAULT_FONT_SIZE

        self.font_plus = ToolButton('zoom-in')
        self.font_plus.connect('clicked', self._font_size_increase)
        self.font_plus.set_tooltip(_('Zoom in'))
        self.insert(self.font_plus, -1)
        self.font_plus.show()

        self.font_minus = ToolButton('zoom-out')
        self.font_minus.connect('clicked', self._font_size_decrease)
        self.font_minus.set_tooltip(_('Zoom out'))
        self.insert(self.font_minus, -1)
        self.font_minus.show()

        self.show()

    def set_font_size(self, font_size):
        self.font_size = font_size
        self.emit('font-size-changed', self.font_size)

    def _font_size_increase(self, button):
        self.font_size += FONT_CHANGE_STEP
        self.emit('font-size-changed', self.font_size)

    def _font_size_decrease(self, button):
        self.font_size -= FONT_CHANGE_STEP
        self.emit('font-size-changed', self.font_size)
Пример #57
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self._has_read_file = False

        screen = Gdk.Screen.get_default()
        css_provider = Gtk.CssProvider.get_default()
        css_provider.load_from_path('style.css')
        context = Gtk.StyleContext()
        context.add_provider_for_screen(screen, css_provider,
                                        Gtk.STYLE_PROVIDER_PRIORITY_USER)
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        run = ToolButton('computer-xo')
        run.props.accelerator = _('<alt>r')
        run.props.tooltip = _('Run')
        run.connect('clicked', self.__run_cb)
        toolbar_box.toolbar.insert(run, -1)
        run.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        self._build_canvas()
Пример #58
0
class Toolbar(Gtk.Toolbar):
    """
    Modified HelpActivity Toolbar Class Object (c) SugarLabs
    """
    def __init__(self, web_view, parent):
        GObject.GObject.__init__(self)
        self.parent = parent
        self.web_view = web_view

        self._back = ToolButton('go-previous-paired')
        self._back.set_tooltip(_('Back'))
        self._back.props.sensitive = False
        self._back.connect('clicked', self._go_back_cb)
        self.insert(self._back, -1)
        self._back.show()

        self._forward = ToolButton('go-next-paired')
        self._forward.set_tooltip(_('Forward'))
        self._forward.props.sensitive = False
        self._forward.connect('clicked', self._go_forward_cb)
        self.insert(self._forward, -1)
        self._forward.show()

        self._home = ToolButton('go-home')
        self._home.set_tooltip(_('Home'))
        self._home.connect('clicked', self._go_home_cb)
        self.insert(self._home, -1)
        self._home.show()

        self.web_view.connect('notify::uri', self._uri_changed_cb)

    def _uri_changed_cb(self, progress_listener, uri):
        self.update_navigation_buttons()

    def _loading_stop_cb(self, progress_listener):
        self.update_navigation_buttons()

    def update_navigation_buttons(self):
        self._back.props.sensitive = self.web_view.can_go_back()
        self._forward.props.sensitive = self.web_view.can_go_forward()

    def _go_back_cb(self, button):
        self.web_view.go_back()

    def _go_forward_cb(self, button):
        self.web_view.go_forward()

    def _go_home_cb(self, button):
        """
        Changes the web_view to static/init.html, if homebutton pressed while installation in progress
        Else change it to Jupyter.url
        """
        jupyter_url = self.parent.jupy.get_url()
        if jupyter_url:
            self.web_view.load_uri(jupyter_url)
        else:
            self.web_view.load_uri(get_index_uri('init'))
Пример #59
0
    def __init__(self, web_view):
        Gtk.Toolbar.__init__(self)

        self._web_view = web_view

        self._back = ToolButton('go-previous-paired')
        self._back.set_tooltip(_('Back'))
        self._back.props.sensitive = False
        self._back.connect('clicked', self._go_back_cb)
        self.insert(self._back, -1)
        self._back.show()

        self._forward = ToolButton('go-next-paired')
        self._forward.set_tooltip(_('Forward'))
        self._forward.props.sensitive = False
        self._forward.connect('clicked', self._go_forward_cb)
        self.insert(self._forward, -1)
        self._forward.show()

        home = ToolButton('zoom-home')
        home.set_tooltip(_('Home'))
        home.connect('clicked', self._go_home_cb)
        self.insert(home, -1)
        home.show()
Пример #60
0
class TitleBox(Gtk.Toolbar):
    '''
    Title box at the top of the pop-up window.
    Title and close button are added to the box and as needed more widgets
    can be added using self.add_widget method.
    This box is optional as the inherited class can remove this block by
    setting the self._set_title_box to False.
    '''
    def __init__(self):
        Gtk.Toolbar.__init__(self)

        self.close_button = ToolButton(icon_name='dialog-cancel')
        self.close_button.set_tooltip(_('Close'))
        self.insert(self.close_button, -1)
        self.close_button.show()

        self._label = Gtk.Label()
        self._label.set_alignment(0, 0.5)

        tool_item = Gtk.ToolItem()
        tool_item.set_expand(True)
        tool_item.add(self._label)
        self._label.show()
        self.insert(tool_item, 0)
        tool_item.show()

    def set_title(self, title):
        '''
        setter function for 'title' property.
        Args:
           title (str): title for the pop-up window
        '''
        self._label.set_markup('<b>%s</b>' % title)
        self._label.show()

    title = GObject.Property(type=str, setter=set_title)