Beispiel #1
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_canvas(canvas.widget)
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        alert = Alert()
        # Populate the title and text body of the alert.
        alert.props.title = 'Current Recording'
        alert.props.msg = 'recording information goes here'
        stop_icon = Icon(icon_name='dialog-cancel')
        stop_icon.set_pixel_size(50)
        alert.add_button(gtk.RESPONSE_CANCEL, 'End', stop_icon)
        stop_icon.show()
        alert.connect('response', singletab.stop)
        alert.connect('response', incramentaltab.stop)
        alert.connect('response', lapsetab.stop)
        # Call the add_alert() method (inherited via the sugar.graphics.Window superclass of Activity)
        # to add this alert to the activity window.
        self.add_alert(alert)
        alert.hide()

        for tab in tabs:
            toolbox.add_toolbar(tab.tab_name, tab.widget)
            tab.set_alert(alert)
Beispiel #2
0
    def _object_chooser(self, mime_type, type_name):
        chooser = ObjectChooser()
        matches_mime_type = False

        response = chooser.run()
        if response == gtk.RESPONSE_ACCEPT:
            jobject = chooser.get_selected_object()
            metadata = jobject.metadata
            file_path = jobject.file_path

            if metadata['mime_type'] == mime_type:
                matches_mime_type = True

            else:
                alert = Alert()

                alert.props.title = _('Invalid object')
                alert.props.msg = \
                       _('The selected object must be a %s file' % (type_name))

                ok_icon = Icon(icon_name='dialog-ok')
                alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
                ok_icon.show()

                alert.connect('response', lambda a, r: self.remove_alert(a))

                self.add_alert(alert)

                alert.show()

        return matches_mime_type, file_path, metadata['title']
Beispiel #3
0
class _IconWidget(gtk.EventBox):

    __gtype_name__ = 'SugarTrayIconWidget'

    def __init__(self, icon_name=None, xo_color=None):
        gtk.EventBox.__init__(self)

        self.set_app_paintable(True)

        self._icon = Icon(icon_name=icon_name,
                          xo_color=xo_color,
                          icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self.add(self._icon)
        self._icon.show()

    def do_expose_event(self, event):
        palette = self.parent.palette
        if palette and palette.is_up():
            invoker = palette.props.invoker
            invoker.draw_rectangle(event, palette)

        gtk.EventBox.do_expose_event(self, event)

    def get_icon(self):
        return self._icon
Beispiel #4
0
    def __init__(self,
                 text_label=None,
                 icon_name=None,
                 text_maxlen=60,
                 xo_color=None,
                 file_name=None):
        gobject.GObject.__init__(self)
        self._accelerator = None

        label = gtk.AccelLabel(text_label)
        label.set_alignment(0.0, 0.5)
        label.set_accel_widget(self)
        if text_maxlen > 0:
            label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
            label.set_max_width_chars(text_maxlen)
        self.add(label)
        label.show()

        if icon_name is not None:
            icon = Icon(icon_name=icon_name,
                        icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()

        elif file_name is not None:
            icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()

        self.connect('can-activate-accel', self.__can_activate_accel_cb)
        self.connect('hierarchy-changed', self.__hierarchy_changed_cb)
Beispiel #5
0
    def __init__(self, mount):
        Palette.__init__(self, label=mount.get_name())
        self._mount = mount

        path = mount.get_root().get_path()
        self.props.secondary_text = glib.markup_escape_text(path)

        vbox = gtk.VBox()
        self.set_content(vbox)
        vbox.show()

        self._progress_bar = gtk.ProgressBar()
        vbox.add(self._progress_bar)
        self._progress_bar.show()

        self._free_space_label = gtk.Label()
        self._free_space_label.set_alignment(0.5, 0.5)
        vbox.add(self._free_space_label)
        self._free_space_label.show()

        self.connect('popup', self.__popup_cb)

        menu_item = MenuItem(pgettext('Volume', 'Remove'))

        icon = Icon(icon_name='media-eject', icon_size=gtk.ICON_SIZE_MENU)
        menu_item.set_image(icon)
        icon.show()

        menu_item.connect('activate', self.__unmount_activate_cb)
        self.menu.append(menu_item)
        menu_item.show()
Beispiel #6
0
    def _object_chooser(self, mime_type, type_name):
        chooser = ObjectChooser()
        matches_mime_type = False

        response = chooser.run()
        if response == gtk.RESPONSE_ACCEPT:
            jobject = chooser.get_selected_object()
            metadata = jobject.metadata
            file_path = jobject.file_path

            if metadata['mime_type'] == mime_type:
                matches_mime_type = True

            else:
                alert = Alert()

                alert.props.title = _('Invalid object')
                alert.props.msg = \
                       _('The selected object must be a %s file' % (type_name))

                ok_icon = Icon(icon_name='dialog-ok')
                alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
                ok_icon.show()

                alert.connect('response', lambda a, r: self.remove_alert(a))

                self.add_alert(alert)

                alert.show()

        return matches_mime_type, file_path, metadata['title']
Beispiel #7
0
    def __init__(self, text_label=None, icon_name=None, text_maxlen=60,
                 xo_color=None, file_name=None, image=None):
        super(MenuItem, self).__init__()
        self._accelerator = None
        self.props.submenu = None

        label = gtk.AccelLabel(text_label)
        label.set_alignment(0.0, 0.5)
        label.set_accel_widget(self)
        if text_maxlen > 0:
            label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
            label.set_max_width_chars(text_maxlen)
        self.add(label)
        label.show()

        if image is not None:
            self.set_image(image)
            image.show()

        elif icon_name is not None:
            icon = Icon(icon_name=icon_name,
                        icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()

        elif file_name is not None:
            icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()
Beispiel #8
0
    def setup_palette(self):
        title = self._home_activity.get_title()
        self.set_primary_text(glib.markup_escape_text(title))

        vbox = gtk.VBox()
        self.set_content(vbox)
        vbox.show()

        self._progress_bar = gtk.ProgressBar()
        vbox.add(self._progress_bar)
        self._progress_bar.show()

        self._free_space_label = gtk.Label()
        self._free_space_label.set_alignment(0.5, 0.5)
        vbox.add(self._free_space_label)
        self._free_space_label.show()

        self.connect('popup', self.__popup_cb)

        menu_item = MenuItem(_('Show contents'))

        icon = Icon(file=self._home_activity.get_icon_path(),
                icon_size=gtk.ICON_SIZE_MENU,
                xo_color=self._home_activity.get_icon_color())
        menu_item.set_image(icon)
        icon.show()

        menu_item.connect('activate', self.__open_activate_cb)
        self.menu.append(menu_item)
        menu_item.show()
Beispiel #9
0
    def __init__(self, file_name, document_path, title):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None

        self.props.tooltip = _('Instance Source')

        client = gconf.client_get_default()
        self._color = client.get_string('/desktop/sugar/user/color')
        icon = Icon(file=file_name,
                    icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                    xo_color=XoColor(self._color))
        self.set_icon_widget(icon)
        icon.show()

        menu_item = MenuItem(_('Keep'))
        icon = Icon(icon_name='document-save', icon_size=gtk.ICON_SIZE_MENU, 
                    xo_color=XoColor(self._color))
        menu_item.set_image(icon)

        menu_item.connect('activate', self.__keep_in_journal_cb)
        self.props.palette.menu.append(menu_item)
        menu_item.show()
Beispiel #10
0
    def __init__(self, mount):
        Palette.__init__(self, label=mount.get_name())
        self._mount = mount

        path = mount.get_root().get_path()
        self.props.secondary_text = glib.markup_escape_text(path)

        vbox = gtk.VBox()
        self.set_content(vbox)
        vbox.show()

        self._progress_bar = gtk.ProgressBar()
        vbox.add(self._progress_bar)
        self._progress_bar.show()

        self._free_space_label = gtk.Label()
        self._free_space_label.set_alignment(0.5, 0.5)
        vbox.add(self._free_space_label)
        self._free_space_label.show()

        self.connect('popup', self.__popup_cb)

        menu_item = MenuItem(pgettext('Volume', 'Remove'))

        icon = Icon(icon_name='media-eject', icon_size=gtk.ICON_SIZE_MENU)
        menu_item.set_image(icon)
        icon.show()

        menu_item.connect('activate', self.__unmount_activate_cb)
        self.menu.append(menu_item)
        menu_item.show()
Beispiel #11
0
    def setup_palette(self):
        title = self._home_activity.get_title()
        self.set_primary_text(glib.markup_escape_text(title))

        vbox = gtk.VBox()
        self.set_content(vbox)
        vbox.show()

        self._progress_bar = gtk.ProgressBar()
        vbox.add(self._progress_bar)
        self._progress_bar.show()

        self._free_space_label = gtk.Label()
        self._free_space_label.set_alignment(0.5, 0.5)
        vbox.add(self._free_space_label)
        self._free_space_label.show()

        self.connect('popup', self.__popup_cb)

        menu_item = MenuItem(_('Show contents'))

        icon = Icon(file=self._home_activity.get_icon_path(),
                    icon_size=gtk.ICON_SIZE_MENU,
                    xo_color=self._home_activity.get_icon_color())
        menu_item.set_image(icon)
        icon.show()

        menu_item.connect('activate', self.__open_activate_cb)
        self.menu.append(menu_item)
        menu_item.show()
    def __init__(self, text_label=None, icon_name=None, text_maxlen=60,
                 xo_color=None, file_name=None):
        gobject.GObject.__init__(self)
        self._accelerator = None

        label = gtk.AccelLabel(text_label)
        label.set_alignment(0.0, 0.5)
        label.set_accel_widget(self)
        if text_maxlen > 0:
            label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
            label.set_max_width_chars(text_maxlen)
        self.add(label)
        label.show()

        if icon_name is not None:
            icon = Icon(icon_name=icon_name,
                        icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()

        elif file_name is not None:
            icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()

        self.connect('can-activate-accel', self.__can_activate_accel_cb)
        self.connect('hierarchy-changed', self.__hierarchy_changed_cb)
Beispiel #13
0
    def __init__(self, file_name, document_path, title, bundle=False):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None

        self.props.tooltip = _('Instance Source')

        client = gconf.client_get_default()
        self._color = client.get_string('/desktop/sugar/user/color')
        icon = Icon(file=file_name,
                    icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                    xo_color=XoColor(self._color))
        self.set_icon_widget(icon)
        icon.show()

        if bundle:
            menu_item = MenuItem(_('Duplicate'))
            icon = Icon(icon_name='edit-duplicate',
                        icon_size=gtk.ICON_SIZE_MENU,
                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__copy_to_home_cb)
        else:
            menu_item = MenuItem(_('Keep'))
            icon = Icon(icon_name='document-save',
                        icon_size=gtk.ICON_SIZE_MENU,
                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__keep_in_journal_cb)

        menu_item.set_image(icon)

        self.props.palette.menu.append(menu_item)
        menu_item.show()
Beispiel #14
0
    def _value_changed(self, cell, path, new_text, model, activity):
        _logger.info("Change '%s' to '%s'" % (model[path][1], new_text))
        is_number = True
        number = new_text.replace(",", ".")
        try:
            float(number)
        except ValueError:
            is_number = False

        if is_number:
            decimals = utils.get_decimals(str(float(number)))
            new_text = locale.format('%.' + decimals + 'f', float(number))
            model[path][1] = str(new_text)

            self.emit("value-changed", str(path), number)

        elif not is_number:
            alert = Alert()

            alert.props.title = _('Invalid Value')
            alert.props.msg = \
                           _('The value must be a number (integer or decimal)')

            ok_icon = Icon(icon_name='dialog-ok')
            alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
            ok_icon.show()

            alert.connect('response', lambda a, r: activity.remove_alert(a))

            activity.add_alert(alert)

            alert.show()
Beispiel #15
0
    def _value_changed(self, cell, path, new_text, model, activity):
        _logger.info("Change '%s' to '%s'" % (model[path][1], new_text))
        is_number = True
        number = new_text.replace(",", ".")
        try:
            float(number)
        except ValueError:
            is_number = False

        if is_number:
            decimals = utils.get_decimals(str(float(number)))
            new_text = locale.format('%.' + decimals + 'f', float(number))
            model[path][1] = str(new_text)

            self.emit("value-changed", str(path), number)

        elif not is_number:
            alert = Alert()

            alert.props.title = _('Invalid Value')
            alert.props.msg = \
                           _('The value must be a number (integer or decimal)')

            ok_icon = Icon(icon_name='dialog-ok')
            alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
            ok_icon.show()

            alert.connect('response', lambda a, r: activity.remove_alert(a))

            activity.add_alert(alert)

            alert.show()
Beispiel #16
0
    def __init__(self):
        gtk.Window.__init__(self)

        self.set_border_width(style.LINE_WIDTH)
        offset = style.GRID_CELL_SIZE
        width = gtk.gdk.screen_width() - offset * 2
        height = gtk.gdk.screen_height() - offset * 2
        self.set_size_request(width, height)
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_modal(True)

        self._main_view = gtk.EventBox()
        self._vbox = gtk.VBox()
        self._vbox.set_spacing(style.DEFAULT_SPACING)
        self._vbox.set_border_width(style.GRID_CELL_SIZE * 2)
        self._main_view.modify_bg(gtk.STATE_NORMAL,
                                  style.COLOR_BLACK.get_gdk_color())
        self._main_view.add(self._vbox)
        self._vbox.show()

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

        icon = Icon(icon_name='activity-journal',
                    pixel_size=style.XLARGE_ICON_SIZE,
                    xo_color=color)
        self._vbox.pack_start(icon, False)
        icon.show()

        self._title = gtk.Label()
        self._title.modify_fg(gtk.STATE_NORMAL,
                              style.COLOR_WHITE.get_gdk_color())
        self._title.set_markup('<b>%s</b>' % _('Your Journal is full'))
        self._vbox.pack_start(self._title, False)
        self._title.show()

        self._message = gtk.Label(_('Please delete some old Journal'
                                    ' entries to make space for new ones.'))
        self._message.modify_fg(gtk.STATE_NORMAL,
                              style.COLOR_WHITE.get_gdk_color())
        self._vbox.pack_start(self._message, False)
        self._message.show()

        alignment = gtk.Alignment(xalign=0.5, yalign=0.5)
        self._vbox.pack_start(alignment, expand=False)
        alignment.show()

        self._show_journal = gtk.Button()
        self._show_journal.set_label(_('Show Journal'))
        alignment.add(self._show_journal)
        self._show_journal.show()
        self._show_journal.connect('clicked', self.__show_journal_cb)

        self.add(self._main_view)
        self._main_view.show()

        self.connect('realize', self.__realize_cb)
Beispiel #17
0
class InlineAlert(gtk.HBox):
    """UI interface for Inline alerts

    Inline alerts are different from the other alerts beause they are
    no dialogs, they only inform about a current event.

    Properties:
        'msg': the message of the alert,
        'icon': the icon that appears at the far left
    See __gproperties__
    """

    __gtype_name__ = 'SugarInlineAlert'

    __gproperties__ = {
        'msg': (str, None, None, None, gobject.PARAM_READWRITE),
        'icon': (object, None, None, gobject.PARAM_WRITABLE),
    }

    def __init__(self, **kwargs):

        self._msg = None
        self._msg_color = None
        self._icon = Icon(icon_name='emblem-warning',
                          fill_color=style.COLOR_SELECTION_GREY.get_svg(),
                          stroke_color=style.COLOR_WHITE.get_svg())

        self._msg_label = gtk.Label()
        self._msg_label.set_max_width_chars(50)
        self._msg_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        self._msg_label.set_alignment(0, 0.5)
        self._msg_label.modify_fg(gtk.STATE_NORMAL,
                                  style.COLOR_SELECTION_GREY.get_gdk_color())

        gobject.GObject.__init__(self, **kwargs)

        self.set_spacing(style.DEFAULT_SPACING)
        self.modify_bg(gtk.STATE_NORMAL,
                       style.COLOR_WHITE.get_gdk_color())

        self.pack_start(self._icon, False)
        self.pack_start(self._msg_label, False)
        self._msg_label.show()
        self._icon.show()

    def do_set_property(self, pspec, value):
        if pspec.name == 'msg':
            if self._msg != value:
                self._msg = value
                self._msg_label.set_markup(self._msg)
        elif pspec.name == 'icon':
            if self._icon != value:
                self._icon = value

    def do_get_property(self, pspec):
        if pspec.name == 'msg':
            return self._msg
Beispiel #18
0
 def refresh(self,widget=None):
     default, uri = self.load_license()
     icon_name = self.uri_to_icon(uri)
     logging.debug("Refreshing ToolButton Icon")
     icon = Icon(icon_name,icon_size=self._icon_size,xo_color=XoColor("#ffffff,#ffffff"))
     icon.show()
     self.set_icon_widget(icon)
     self.set_tooltip(self._format_tooltip(uri))
     self.make_menu(self.get_palette(),XoColor("#ffffff,#ffffff"),self._color_selected,icon)
Beispiel #19
0
    def __init__(self, **kwargs):
        Alert.__init__(self, **kwargs)

        icon = Icon(icon_name='dialog-cancel')
        self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
        icon.show()

        icon = Icon(icon_name='dialog-ok')
        self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
        icon.show()
Beispiel #20
0
    def add_action(self, label, icon_name=None):
        button = gtk.Button(label)

        if icon_name:
            icon = Icon(icon_name)
            button.set_image(icon)
            icon.show()

        self.pack_start(button)
        button.show()
Beispiel #21
0
    def __init__(self, **kwargs):
        Alert.__init__(self, **kwargs)

        icon = Icon(icon_name='dialog-cancel')
        self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
        icon.show()

        icon = Icon(icon_name='dialog-ok')
        self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
        icon.show()
Beispiel #22
0
    def add_action(self, label, icon_name=None):
        button = gtk.Button(label)

        if icon_name:
            icon = Icon(icon_name)
            button.set_image(icon)
            icon.show()

        self.pack_start(button)
        button.show()
    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()
Beispiel #24
0
    def __init__(self, activity, **kwargs):
        ToolButton.__init__(self, **kwargs)
        self.props.tooltip = _('Keep')
        self.props.accelerator = '<Ctrl>S'

        color = profile.get_color()
        keep_icon = Icon(icon_name='document-save', xo_color=color)
        keep_icon.show()

        self.set_icon_widget(keep_icon)
        self.connect('clicked', self.__keep_button_clicked_cb, activity)
 def _add_playback_button(self, nick, colors, audio_file):
     ''' Add a toolbar button for this audio recording '''
     if nick not in self._playback_buttons:
         self._playback_buttons[nick] = button_factory(
             'xo-chat',  self.record_toolbar,
             self._playback_recording_cb, cb_arg=nick,
             tooltip=_('Audio recording by %s') % (nick))
         xocolor = XoColor('%s,%s' % (colors[0], colors[1]))
         icon = Icon(icon_name='xo-chat', xo_color=xocolor)
         icon.show()
         self._playback_buttons[nick].set_icon_widget(icon)
         self._playback_buttons[nick].show()
     self._audio_recordings[nick] = audio_file
Beispiel #26
0
    def __init__(self):
        label = glib.markup_escape_text(_('Wireless modem'))
        Palette.__init__(self, primary_text=label)

        self._current_state = None
        self._failed_connection = False

        self._toggle_state_item = MenuItem('')
        self._toggle_state_item.connect('activate', self.__toggle_state_cb)
        self.menu.append(self._toggle_state_item)
        self._toggle_state_item.show()

        self.info_box = gtk.VBox()

        self.error_title_label = gtk.Label("")
        self.error_title_label.set_alignment(0, 0.5)
        self.error_title_label.set_line_wrap(True)
        self.info_box.pack_start(self.error_title_label)
        self.error_description_label = gtk.Label("")
        self.error_description_label.set_alignment(0, 0.5)
        self.error_description_label.set_line_wrap(True)
        self.info_box.pack_start(self.error_description_label)

        self.connection_info_box = gtk.HBox()
        icon = Icon(icon_name='data-upload', icon_size=gtk.ICON_SIZE_MENU)
        self.connection_info_box.pack_start(icon)
        icon.show()

        self._data_label_up = gtk.Label()
        self._data_label_up.props.xalign = 0.0
        label_alignment = self._add_widget_with_padding(self._data_label_up)
        self.connection_info_box.pack_start(label_alignment)
        self._data_label_up.show()
        label_alignment.show()

        icon = Icon(icon_name='data-download', icon_size=gtk.ICON_SIZE_MENU)
        self.connection_info_box.pack_start(icon)
        icon.show()
        self._data_label_down = gtk.Label()
        self._data_label_down.props.xalign = 0.0
        label_alignment = self._add_widget_with_padding(self._data_label_down)
        self.connection_info_box.pack_start(label_alignment)
        self._data_label_down.show()
        label_alignment.show()

        self.info_box.pack_start(self.connection_info_box)

        self.info_box.show()
        self.set_content(self.info_box)

        self.set_state(_GSM_STATE_NOT_READY)
Beispiel #27
0
def create_icon_widgets(box, sensitive=True):
    icon = Icon(icon_name='go-previous')
    icon.props.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='computer-xo',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                xo_color=XoColor())
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='battery-000',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                badge_name='emblem-busy')
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='gtk-new',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                badge_name='gtk-cancel')
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()
Beispiel #28
0
    def __init__(self, activity, **kwargs):
        ToolButton.__init__(self, **kwargs)
        logging.warning('KeepButton has been deprecated since Sugar 0.94'
                        ' and should not be used in newly written code.')
        self.props.tooltip = _('Keep')
        self.props.accelerator = '<Ctrl>S'

        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.show()

        self.set_icon_widget(keep_icon)
        self.connect('clicked', self.__keep_button_clicked_cb, activity)
def create_icon_widgets(box, sensitive=True):
    icon = Icon(icon_name='go-previous')
    icon.props.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='computer-xo',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                xo_color=XoColor())
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='battery-000',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                badge_name='emblem-busy')
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='gtk-new',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                badge_name='gtk-cancel')
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()
Beispiel #30
0
class EventIcon(gtk.EventBox):
    __gtype_name__ = 'SugarEventIcon'

    def __init__(self, **kwargs):
        gtk.EventBox.__init__(self)

        self.icon = Icon(pixel_size=style.XLARGE_ICON_SIZE, **kwargs)

        self.set_visible_window(False)
        self.set_app_paintable(True)
        self.set_events(gtk.gdk.BUTTON_PRESS_MASK)

        self.add(self.icon)
        self.icon.show()
Beispiel #31
0
    def __init__(self, activity, **kwargs):
        ToolButton.__init__(self, **kwargs)
        logging.warning('KeepButton has been deprecated since Sugar 0.94'
                        ' and should not be used in newly written code.')
        self.props.tooltip = _('Keep')
        self.props.accelerator = '<Ctrl>S'

        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.show()

        self.set_icon_widget(keep_icon)
        self.connect('clicked', self.__keep_button_clicked_cb, activity)
Beispiel #32
0
    def __init__(self, timeout=5, **kwargs):
        Alert.__init__(self, **kwargs)

        self._timeout = timeout

        icon = Icon(icon_name='dialog-cancel')
        self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
        icon.show()

        self._timeout_text = _TimeoutIcon()
        self._timeout_text.set_text(self._timeout)
        self.add_button(gtk.RESPONSE_OK, _('Continue'), self._timeout_text)
        self._timeout_text.show()

        gobject.timeout_add_seconds(1, self.__timeout)
Beispiel #33
0
    def __init__(self, timeout=5, **kwargs):
        Alert.__init__(self, **kwargs)

        self._timeout = timeout

        icon = Icon(icon_name='dialog-cancel')
        self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
        icon.show()

        self._timeout_text = _TimeoutIcon()
        self._timeout_text.set_text(self._timeout)
        self.add_button(gtk.RESPONSE_OK, _('Continue'), self._timeout_text)
        self._timeout_text.show()

        gobject.timeout_add_seconds(1, self.__timeout)
Beispiel #34
0
    def __init__(self, file_transfer):
        ToolButton.__init__(self)

        self.file_transfer = file_transfer
        file_transfer.connect('notify::state', self.__notify_state_cb)

        icon = Icon()
        self.props.icon_widget = icon
        icon.show()

        self.notif_icon = NotificationIcon()
        self.notif_icon.connect('button-release-event',
                                 self.__button_release_event_cb)

        self.connect('clicked', self.__button_clicked_cb)
Beispiel #35
0
    def __init__(self, icon_name, scroll_direction):
        gobject.GObject.__init__(self)

        self._viewport = None

        self._scroll_direction = scroll_direction

        self.set_relief(gtk.RELIEF_NONE)
        self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)

        icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
        self.set_image(icon)
        icon.show()

        self.connect('clicked', self._clicked_cb)
class UnfullscreenButton(gtk.Window):

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

        self.set_decorated(False)
        self.set_resizable(False)
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)

        self.set_border_width(0)

        self.props.accept_focus = False

        #Setup estimate of width, height
        w, h = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
        self._width = w
        self._height = h

        self.connect('size-request', self._size_request_cb)

        screen = self.get_screen()
        screen.connect('size-changed', self._screen_size_changed_cb)

        self._button = gtk.Button()
        self._button.set_relief(gtk.RELIEF_NONE)

        self._icon = Icon(icon_name='view-return',
                            icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self._icon.show()
        self._button.add(self._icon)

        self._button.show()
        self.add(self._button)

    def connect_button_press(self, cb):
        self._button.connect('button-press-event', cb)

    def _reposition(self):
        x = gtk.gdk.screen_width() - self._width
        self.move(x, 0)

    def _size_request_cb(self, widget, req):
        self._width = req.width
        self._height = req.height
        self._reposition()

    def _screen_size_changed_cb(self, screen):
        self._reposition()
Beispiel #37
0
    def __init__(self, icon_name, scroll_direction):
        gobject.GObject.__init__(self)

        self._viewport = None

        self._scroll_direction = scroll_direction

        self.set_relief(gtk.RELIEF_NONE)
        self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)

        icon = Icon(icon_name = icon_name,
                    icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
        self.set_image(icon)
        icon.show()

        self.connect('clicked', self._clicked_cb)
Beispiel #38
0
 def __init__(self,jobject=None):
     LicenseWidget.__init__(self,"#ffffff,#ffffff")
     self._jobject = jobject
     if jobject:
         self._color_selected = XoColor(self._jobject.metadata['icon-color'])
     else:
         self._color_selected = profile.get_color()
     default, license = self.load_license()
     icon_name = self.uri_to_icon(license)
     ToolButton.__init__(self)
     icon = Icon(icon_name,icon_size=self._icon_size,xo_color=XoColor("#ffffff,#ffffff"))
     icon.show()
     self.set_icon_widget(icon)
     self.props.sensitive = True
     self.set_tooltip(self._format_tooltip(license))
     self.make_menu(self.get_palette(),XoColor("#ffffff,#ffffff"),self._color_selected,icon_name)
Beispiel #39
0
 def make_menu(self,palette,color,color_selected,current_icon):
     for uri, icon_name in self._licenses:
         tmp = gtk.HBox()
         tmp.show()
         if current_icon==icon_name:
             xo_color = color_selected
         else:
             xo_color = color
         icon = Icon(icon_name,icon_size=self._icon_size,xo_color=xo_color)
         icon.show()
         tmp.pack_start(icon,False,False)
         item = gtk.MenuItem()
         item.add(tmp)
         item.connect('activate', self._license_cb,uri)
         palette.menu.append(item)
         item.show()
Beispiel #40
0
 def can_close(self):
     if downloadmanager.can_quit():
         return True
     else:
         alert = Alert()
         alert.props.title = _('Download in progress')
         alert.props.msg = _('Stopping now will cancel your download')
         cancel_icon = Icon(icon_name='dialog-cancel')
         alert.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), cancel_icon)
         stop_icon = Icon(icon_name='dialog-ok')
         alert.add_button(gtk.RESPONSE_OK, _('Stop'), stop_icon)
         stop_icon.show()
         self.add_alert(alert)
         alert.connect('response', self.__inprogress_response_cb)
         alert.show()            
         self.present()
Beispiel #41
0
    def __init__(self, title, bundle_path, document_path):
        gtk.Toolbar.__init__(self)

        self._add_separator()

        activity_bundle = ActivityBundle(bundle_path)
        file_name = activity_bundle.get_icon()

        if document_path is not None and os.path.exists(document_path):
            document_button = DocumentButton(file_name, document_path, title)
            document_button.connect('toggled', self.__button_toggled_cb, 
                                    document_path)
            self.insert(document_button, -1)
            document_button.show()
            self._add_separator()

        if bundle_path is not None and os.path.exists(bundle_path):
            activity_button = RadioToolButton()
            icon = Icon(file=file_name,
                        icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            activity_button.set_icon_widget(icon)
            icon.show()
            if document_path is not None:
                activity_button.props.group = document_button
            activity_button.props.tooltip = _('Activity Bundle Source')
            activity_button.connect('toggled', self.__button_toggled_cb, 
                                    bundle_path)
            self.insert(activity_button, -1)
            activity_button.show()
            self._add_separator()

        text = _('View source: %r') % title
        label = gtk.Label()
        label.set_markup('<b>%s</b>' % text)
        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)
        stop.show()
        self.insert(stop, -1)
        stop.show()
Beispiel #42
0
class UnfullscreenButton(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)

        self.set_decorated(False)
        self.set_resizable(False)
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)

        self.set_border_width(0)

        self.props.accept_focus = False

        #Setup estimate of width, height
        w, h = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
        self._width = w
        self._height = h

        self.connect('size-request', self._size_request_cb)

        screen = self.get_screen()
        screen.connect('size-changed', self._screen_size_changed_cb)

        self._button = gtk.Button()
        self._button.set_relief(gtk.RELIEF_NONE)

        self._icon = Icon(icon_name='view-return',
                          icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self._icon.show()
        self._button.add(self._icon)

        self._button.show()
        self.add(self._button)

    def connect_button_press(self, cb):
        self._button.connect('button-press-event', cb)

    def _reposition(self):
        x = gtk.gdk.screen_width() - self._width
        self.move(x, 0)

    def _size_request_cb(self, widget, req):
        self._width = req.width
        self._height = req.height
        self._reposition()

    def _screen_size_changed_cb(self, screen):
        self._reposition()
Beispiel #43
0
    def onStateChange(self, web_progress, request, state_flags, status):
        if state_flags & interfaces.nsIWebProgressListener.STATE_START:
            self._create_journal_object()            
            self._object_id = self.dl_jobject.object_id
            
            alert = TimeoutAlert(9)
            alert.props.title = _('Download started')
            alert.props.msg = _('%s' % self._get_file_name()) 
            self._activity.add_alert(alert)
            alert.connect('response', self.__start_response_cb)
            alert.show()
            global _active_downloads
            _active_downloads.append(self)
            
        elif state_flags & interfaces.nsIWebProgressListener.STATE_STOP:
            if NS_FAILED(status): # download cancelled
                return

            self._stop_alert = Alert()
            self._stop_alert.props.title = _('Download completed') 
            self._stop_alert.props.msg = _('%s' % self._get_file_name()) 
            open_icon = Icon(icon_name='zoom-activity') 
            self._stop_alert.add_button(gtk.RESPONSE_APPLY, 
                                        _('Show in Journal'), open_icon) 
            open_icon.show() 
            ok_icon = Icon(icon_name='dialog-ok') 
            self._stop_alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon) 
            ok_icon.show()            
            self._activity.add_alert(self._stop_alert) 
            self._stop_alert.connect('response', self.__stop_response_cb)
            self._stop_alert.show()

            self.dl_jobject.metadata['title'] = _('File %s from %s.') % \
                    (self._get_file_name(), self._source.spec)
            self.dl_jobject.metadata['progress'] = '100'
            self.dl_jobject.file_path = self._target_file.path

            if self._mime_type in ['application/octet-stream',
                                   'application/x-zip']:
                sniffed_mime_type = mime.get_for_file(self._target_file.path)
                self.dl_jobject.metadata['mime_type'] = sniffed_mime_type

            datastore.write(self.dl_jobject,
                            transfer_ownership=True,
                            reply_handler=self._internal_save_cb,
                            error_handler=self._internal_save_error_cb,
                            timeout=360 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
Beispiel #44
0
    def __init__(self, timeout=5, **kwargs):
        Alert.__init__(self, **kwargs)

        self._timeout = timeout
        
        icon = Icon(icon_name='dialog-cancel')
        self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
        icon.show()
        
        self._timeout_text = _TimeoutIcon(
            text=self._timeout,
            color=style.COLOR_BUTTON_GREY.get_int(),
            background_color=style.COLOR_WHITE.get_int())    
        canvas = hippo.Canvas()
        canvas.set_root(self._timeout_text)
        canvas.show()                       
        self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas)

        gobject.timeout_add_seconds(1, self.__timeout)
    def __init__(self, parent, name, icon_name='', callback=None,
                 tooltip=None, group=None):
        RadioToolButton.__init__(self)

        if icon_name == '':
            icon_name = 'computer-xo'
        icon = Icon(icon_name=icon_name,
                    icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self.set_icon_widget(icon)
        icon.show()
        if tooltip is not None:
            self.set_tooltip(tooltip)
        self.props.sensitive = True
        self.connect('clicked', callback)
        self.set_group(group)
        self.show()

        parent.button_dict[name] = self
        parent.callback_dict[name] = callback
Beispiel #46
0
    def _update_invite_menu(self, activity):
        buddy_activity = self._buddy.props.current_activity
        if buddy_activity is not None:
            buddy_activity_id = buddy_activity.activity_id
        else:
            buddy_activity_id = None

        if activity is None or activity.is_journal() or \
           activity.get_activity_id() == buddy_activity_id:
            self._invite_menu.hide()
        else:
            title = activity.get_title()
            label = self._invite_menu.get_children()[0]
            label.set_text(_('Invite to %s') % title)

            icon = Icon(file=activity.get_icon_path())
            icon.props.xo_color = activity.get_icon_color()
            self._invite_menu.set_image(icon)
            icon.show()

            self._invite_menu.show()
Beispiel #47
0
    def _update_invite_menu(self, activity):
        buddy_activity = self._buddy.props.current_activity
        if buddy_activity is not None:
            buddy_activity_id = buddy_activity.activity_id
        else:
            buddy_activity_id = None

        if activity is None or activity.is_journal() or \
           activity.get_activity_id() == buddy_activity_id:
            self._invite_menu.hide()
        else:
            title = activity.get_title()
            label = self._invite_menu.get_children()[0]
            label.set_text(_('Invite to %s') % title)

            icon = Icon(file=activity.get_icon_path())
            icon.props.xo_color = activity.get_icon_color()
            self._invite_menu.set_image(icon)
            icon.show()

            self._invite_menu.show()
Beispiel #48
0
    def __accept_clicked_cb(self, widget):
        if self._section_view.needs_restart:
            self._section_toolbar.accept_button.set_sensitive(False)
            self._section_toolbar.cancel_button.set_sensitive(False)
            alert = Alert()
            alert.props.title = _('Warning')
            alert.props.msg = _('Changes require restart')

            icon = Icon(icon_name='dialog-cancel')
            alert.add_button(gtk.RESPONSE_CANCEL, _('Cancel changes'), icon)
            icon.show()

            if self._current_option != 'aboutme':
                icon = Icon(icon_name='dialog-ok')
                alert.add_button(gtk.RESPONSE_ACCEPT, _('Later'), icon)
                icon.show()

            icon = Icon(icon_name='system-restart')
            alert.add_button(gtk.RESPONSE_APPLY, _('Restart now'), icon)
            icon.show()

            self._vbox.pack_start(alert, False)
            self._vbox.reorder_child(alert, 2)
            alert.connect('response', self.__response_cb)
            alert.show()
        else:
            self._show_main_view()
Beispiel #49
0
    def __init__(self,
                 text_label=None,
                 icon_name=None,
                 text_maxlen=60,
                 xo_color=None,
                 file_name=None,
                 image=None):
        super(MenuItem, self).__init__()
        self._accelerator = None
        self.props.submenu = None

        label = gtk.AccelLabel(text_label)
        label.set_alignment(0.0, 0.5)
        label.set_accel_widget(self)
        if text_maxlen > 0:
            label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
            label.set_max_width_chars(text_maxlen)
        self.add(label)
        label.show()

        if image is not None:
            self.set_image(image)
            image.show()

        elif icon_name is not None:
            icon = Icon(icon_name=icon_name,
                        icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()

        elif file_name is not None:
            icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
            if xo_color is not None:
                icon.props.xo_color = xo_color
            self.set_image(icon)
            icon.show()
Beispiel #50
0
    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 __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()
Beispiel #52
0
    def show_software_updates_alert(self):
        alert = Alert()
        updater_icon = Icon(icon_name='module-updater',
                            pixel_size=style.STANDARD_ICON_SIZE)
        alert.props.icon = updater_icon
        updater_icon.show()
        alert.props.title = _('Software Update')
        alert.props.msg = _('Update your activities to ensure'
                            ' compatibility with your new software')

        cancel_icon = Icon(icon_name='dialog-cancel')
        alert.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), cancel_icon)

        alert.add_button(gtk.RESPONSE_REJECT, _('Later'))

        erase_icon = Icon(icon_name='dialog-ok')
        alert.add_button(gtk.RESPONSE_OK, _('Check now'), erase_icon)

        if self._list_view in self.get_children():
            self._list_view.add_alert(alert)
        else:
            self._favorites_view.add_alert(alert)
        alert.connect('response', self.__software_update_response_cb)
class AboutMeActivity(activity.Activity):
    def colour_changed_callback(self, widget, type):
        colour = widget.get_current_color()
        red = "%x" % int(colour.red / 65535.0 * 255)
        if len(red) == 1:
            red = "0%s" % red
        green = "%x" % int(colour.green / 65535.0 * 255)
        if len(green) == 1:
            green = "0%s" % green
        blue = "%x" % int(colour.blue / 65535.0 * 255)
        if len(blue) == 1:
            blue = "0%s" % blue
        new_colour = "#%s%s%s" % (red, green, blue)
        if type == "out":
            in_colour = self.in_colour_selector.get_current_color()
            red = "%x" % int(in_colour.red / 65535.0 * 255)
            if len(red) == 1:
                red = "0%s" % red
            green = "%x" % int(in_colour.green / 65535.0 * 255)
            if len(green) == 1:
                green = "0%s" % green
            blue = "%x" % int(in_colour.blue / 65535.0 * 255)
            if len(blue) == 1:
                blue = "0%s" % blue
            in_colour = "#%s%s%s" % (red, green, blue)
            self.icon.props.xo_color = XoColor("%s,%s" %
                                               (new_colour, in_colour))
        if type == "in":
            out_colour = self.out_colour_selector.get_current_color()
            red = "%x" % int(out_colour.red / 65535.0 * 255)
            if len(red) == 1:
                red = "0%s" % red
            green = "%x" % int(out_colour.green / 65535.0 * 255)
            if len(green) == 1:
                green = "0%s" % green
            blue = "%x" % int(out_colour.blue / 65535.0 * 255)
            if len(blue) == 1:
                blue = "0%s" % blue
            out_colour = "#%s%s%s" % (red, green, blue)
            self.icon.props.xo_color = XoColor("%s,%s" %
                                               (out_colour, new_colour))

    def apply(self, widget):
        nick = unicode(self.name_entry.get_text(), 'utf-8')
        if nick != self.current_nick:
            self.client.set_string("/desktop/sugar/user/nick", nick)
        colour = self.icon._buffer.xo_color.to_string()
        if colour != self.current_colour:
            self.client.set_string("/desktop/sugar/user/color", colour)

    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.client = gconf.client_get_default()
        self.current_nick = self.client.get_string("/desktop/sugar/user/nick")
        self.current_colour = self.client.get_string(
            "/desktop/sugar/user/color")
        self.current_colours = _parse_string(self.current_colour)
        self.toolbox = activity.ActivityToolbox(self)
        activity_toolbar = self.toolbox.get_activity_toolbar()
        activity_toolbar.share.props.visible = False
        activity_toolbar.keep.props.visible = False
        self.ok_button = ToolButton(icon)
        self.ok_button.props.tooltip = "Aplicar"
        self.ok_button.connect("clicked", self.apply)
        self.ok_button.show()
        activity_toolbar.insert(self.ok_button, 2)
        self.set_toolbox(self.toolbox)
        self.toolbox.show()

        self.canvas = gtk.VBox()
        name_box = gtk.HBox()
        self.canvas.pack_start(name_box, True, True, 5)
        name_label = gtk.Label("Nombre:")
        self.name_entry = gtk.Entry()
        self.name_entry.set_text(self.current_nick)
        name_label.show()
        self.name_entry.show()
        name_box.pack_start(name_label, False, True, 0)
        name_box.pack_start(self.name_entry, True, True, 0)
        name_box.show()

        self.colour_picker = gtk.HBox()

        selectors = gtk.VBox()
        self.out_colour_selector = gtk.ColorSelection()
        self.out_colour_selector.set_current_color(
            gtk.gdk.color_parse(self.current_colours[0]))
        self.out_colour_selector.connect("color-changed",
                                         self.colour_changed_callback, "out")
        self.out_colour_selector.show()
        selectors.pack_start(self.out_colour_selector, True, True, 0)

        self.in_colour_selector = gtk.ColorSelection()
        self.in_colour_selector.set_current_color(
            gtk.gdk.color_parse(self.current_colours[1]))
        self.in_colour_selector.connect("color-changed",
                                        self.colour_changed_callback, "in")
        self.in_colour_selector.show()
        selectors.pack_start(self.in_colour_selector, True, True, 0)

        selectors.show()
        self.colour_picker.pack_start(selectors, True, True, 0)

        self.xo_icon = gtk.EventBox()
        self.icon = Icon(pixel_size=style.XLARGE_ICON_SIZE)
        self.icon.props.xo_color = XoColor(self.current_colour)
        self.icon.props.icon_name = 'computer-xo'
        self.icon.props.pixel_size = style.XLARGE_ICON_SIZE
        self.icon.show()
        self.xo_icon.add(self.icon)
        self.xo_icon.show()
        self.colour_picker.pack_start(self.xo_icon)
        self.canvas.pack_start(self.colour_picker, True, True, 5)
        self.colour_picker.show()

        self.canvas.show()
        self.set_canvas(self.canvas)

        self.show()

    def write_file(self, file_path):
        raise NotImplementedError

    def read_file(self, file_path):
        raise NotImplementedError
Beispiel #54
0
    ['battery-090', '#D1A3FF,#00A0FF'],
    ['battery-100', '#AC32FF,#FF2B34']]


def _button_activated_cb(button):
    import random

    global data
    random.shuffle(data)

    for i in range(0, len(test.get_children()) - 1):
        test.get_children()[i].props.icon_name = data[i][0]
        test.get_children()[i].props.xo_color = XoColor(data[i][1])

for d in data:
    icon = Icon(icon_name=d[0],
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                xo_color=XoColor(d[1]))
    test.pack_start(icon)
    icon.show()

button = gtk.Button('mec mac')
test.pack_start(button)
button.connect('activate', _button_activated_cb)
button.show()

test.show()

if __name__ == '__main__':
    common.main(test)
Beispiel #55
0
    def __init__(self, title, bundle_path, document_path, sugar_toolkit_path):
        gtk.Toolbar.__init__(self)

        document_button = None
        self.bundle_path = bundle_path
        self.sugar_toolkit_path = sugar_toolkit_path

        self._add_separator()

        activity_bundle = ActivityBundle(bundle_path)
        file_name = activity_bundle.get_icon()

        if document_path is not None and os.path.exists(document_path):
            document_button = DocumentButton(file_name, document_path, title)
            document_button.connect('toggled', self.__button_toggled_cb,
                                    document_path)
            self.insert(document_button, -1)
            document_button.show()
            self._add_separator()

        if bundle_path is not None and os.path.exists(bundle_path):
            activity_button = DocumentButton(file_name,
                                             bundle_path,
                                             title,
                                             bundle=True)
            icon = Icon(file=file_name,
                        icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            activity_button.set_icon_widget(icon)
            icon.show()
            if document_button is not None:
                activity_button.props.group = document_button
            activity_button.props.tooltip = _('Activity Bundle Source')
            activity_button.connect('toggled', self.__button_toggled_cb,
                                    bundle_path)
            self.insert(activity_button, -1)
            activity_button.show()
            self._add_separator()

        if sugar_toolkit_path is not None:
            sugar_button = RadioToolButton()
            icon = Icon(icon_name='computer-xo',
                        icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            sugar_button.set_icon_widget(icon)
            icon.show()
            if document_button is not None:
                sugar_button.props.group = document_button
            else:
                sugar_button.props.group = activity_button
            sugar_button.props.tooltip = _('Sugar Toolkit Source')
            sugar_button.connect('toggled', self.__button_toggled_cb,
                                 sugar_toolkit_path)
            self.insert(sugar_button, -1)
            sugar_button.show()
            self._add_separator()

        self.activity_title_text = _('View source: %s') % title
        self.sugar_toolkit_title_text = _('View source: %r') % 'Sugar Toolkit'
        self.label = gtk.Label()
        self.label.set_markup('<b>%s</b>' % self.activity_title_text)
        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()
Beispiel #56
0
class _SectionIcon(gtk.EventBox):
    __gtype_name__ = 'SugarSectionIcon'

    __gproperties__ = {
        'icon-name': (str, None, None, None, gobject.PARAM_READWRITE),
        'pixel-size': (object, None, None, gobject.PARAM_READWRITE),
        'xo-color': (object, None, None, gobject.PARAM_READWRITE),
        'title': (str, None, None, None, gobject.PARAM_READWRITE),
    }

    def __init__(self, **kwargs):
        self._icon_name = None
        self._pixel_size = style.GRID_CELL_SIZE
        self._xo_color = None
        self._title = 'No Title'

        gobject.GObject.__init__(self, **kwargs)

        self._vbox = gtk.VBox()
        self._icon = Icon(icon_name=self._icon_name,
                          pixel_size=self._pixel_size,
                          xo_color=self._xo_color)
        self._vbox.pack_start(self._icon, expand=False, fill=False)

        self._label = gtk.Label(self._title)
        self._label.modify_fg(gtk.STATE_NORMAL,
                              style.COLOR_WHITE.get_gdk_color())
        self._vbox.pack_start(self._label, expand=False, fill=False)

        self._vbox.set_spacing(style.DEFAULT_SPACING)
        self.set_visible_window(False)
        self.set_app_paintable(True)
        self.set_events(gtk.gdk.BUTTON_PRESS_MASK)

        self.add(self._vbox)
        self._vbox.show()
        self._label.show()
        self._icon.show()

    def get_icon(self):
        return self._icon

    def do_set_property(self, pspec, value):
        if pspec.name == 'icon-name':
            if self._icon_name != value:
                self._icon_name = value
        elif pspec.name == 'pixel-size':
            if self._pixel_size != value:
                self._pixel_size = value
        elif pspec.name == 'xo-color':
            if self._xo_color != value:
                self._xo_color = value
        elif pspec.name == 'title':
            if self._title != value:
                self._title = value

    def do_get_property(self, pspec):
        if pspec.name == 'icon-name':
            return self._icon_name
        elif pspec.name == 'pixel-size':
            return self._pixel_size
        elif pspec.name == 'xo-color':
            return self._xo_color
        elif pspec.name == 'title':
            return self._title
Beispiel #57
0
class InviteButton(ToolButton):
    """Invite to shared activity"""

    __gsignals__ = {
        'remove-invite': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
    }

    def __init__(self, invite):
        ToolButton.__init__(self)

        self._invite = invite

        self.connect('clicked', self.__clicked_cb)
        self.connect('destroy', self.__destroy_cb)

        bundle_registry = bundleregistry.get_registry()
        bundle = bundle_registry.get_bundle(invite.get_bundle_id())

        self._icon = Icon()
        self._icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._icon.props.file = bundle.get_icon()
        else:
            self._icon.props.icon_name = 'image-missing'
        self.set_icon_widget(self._icon)
        self._icon.show()

        palette = InvitePalette(invite)
        palette.props.invoker = FrameWidgetInvoker(self)
        palette.set_group_id('frame')
        palette.connect('remove-invite', self.__remove_invite_cb)
        self.set_palette(palette)

        self._notif_icon = NotificationIcon()
        self._notif_icon.connect('button-release-event',
                                 self.__button_release_event_cb)

        self._notif_icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._notif_icon.props.icon_filename = bundle.get_icon()
        else:
            self._notif_icon.props.icon_name = 'image-missing'

        frame = jarabe.frame.get_view()
        frame.add_notification(self._notif_icon, gtk.CORNER_TOP_LEFT)

    def __button_release_event_cb(self, icon, event):
        if self._notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self._notif_icon)
            self._notif_icon = None
            self._invite.join()
            self.emit('remove-invite')

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

    def __remove_invite_cb(self, palette):
        self.emit('remove-invite')

    def __destroy_cb(self, button):
        if self._notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self._notif_icon)
            self._notif_icon = None