def _create_smiley_table(self, width): pixel_size = (style.STANDARD_ICON_SIZE + style.LARGE_ICON_SIZE) / 2 spacing = style.DEFAULT_SPACING button_size = pixel_size + spacing smilies_columns = int(width / button_size) pad = (width - smilies_columns * button_size) / 2 table = Gtk.Grid() table.set_row_spacing(spacing) table.set_column_spacing(spacing) table.set_border_width(pad) queue = [] def _create_smiley_icon_idle_cb(): try: x, y, path, code = queue.pop() except IndexError: self.unbusy() return False pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(path, pixel_size, pixel_size) image = Gtk.Image.new_from_pixbuf(pixbuf) box = Gtk.EventBox() box.add(image) box.connect('button-press-event', self._add_smiley_to_entry, code) table.attach(box, x, y, 1, 1) box.show_all() return True x = 0 y = 0 smilies.init() for i in range(len(smilies.THEME)): path, hint, codes = smilies.THEME[i] queue.append([x, y, path, codes[0]]) x += 1 if x == smilies_columns: y += 1 x = 0 queue.reverse() GLib.idle_add(_create_smiley_icon_idle_cb) return table
def __init__(self, handle): smilies.init() self.chatbox = ChatBox() super(ChatStudioSelf, self).__init__(handle) self.entry = None self.no_of_mistake = 0 root = self.make_root() self.set_canvas(root) root.show_all() self.entry.grab_focus() self.score1 = 0 self.accuracy = 0.0 toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.toolbar.insert(ActivityButton(self), -1) toolbar_box.toolbar.insert(TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: logger.debug("DescriptionItem button is not available, " "toolkit version < 0.96") else: description_item = DescriptionItem(self) toolbar_box.toolbar.insert(description_item, -1) description_item.show() StartLabel = gtk.Label(_("START: ")) StartLabel.show() tool_item_StartLabel = gtk.ToolItem() tool_item_StartLabel.add(StartLabel) toolbar_box.toolbar.insert(tool_item_StartLabel, -1) tool_item_StartLabel.show() mc1 = MathCompEntry1(self) toolbar_box.toolbar.insert(mc1, -1) AddLabel = gtk.Label(_(" ADD: ")) AddLabel.show() tool_item_AddLabel = gtk.ToolItem() tool_item_AddLabel.add(AddLabel) toolbar_box.toolbar.insert(tool_item_AddLabel, -1) tool_item_AddLabel.show() mc2 = MathCompEntry2(self) toolbar_box.toolbar.insert(mc2, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) self._smiley = RadioMenuButton(icon_name="smilies") self._smiley.palette = Palette(_("Insert smiley")) self._smiley.props.sensitive = True # toolbar_box.toolbar.insert(self._smiley, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(False) toolbar_box.toolbar.insert(separator, -1) scoreButton = ScoreButton(self) toolbar_box.toolbar.insert(scoreButton, -1) stopButton = StopButton(self) toolbar_box.toolbar.insert(stopButton, -1) toolbar_box.show_all() self.a1 = c1 self.a2 = c2 self.sum1 = self.a1 + self.a2 pservice = presenceservice.get_instance() self.owner = pservice.get_owner() # Chat is room or one to one: self._chat_is_room = False self.text_channel = None if self.shared_activity: # we are joining the activity self.connect("joined", self._joined_cb) if self.get_shared(): # we have already joined self._joined_cb(self) elif handle.uri: # XMPP non-Sugar incoming chat, not sharable share_button.props.visible = False self._one_to_one_connection(handle.uri) else: # we are creating the activity # if not self.metadata or self.metadata.get('share-scope',activity.SCOPE_PRIVATE) == activity.SCOPE_PRIVATE: # if we are in private session # self._alert(_('Off-line'), _('Share, or invite someone.')) self.connect("shared", self._shared_cb)
def __init__(self, handle): smilies.init() pservice = presenceservice.get_instance() self.owner = pservice.get_owner() self._ebook_mode_detector = EbookModeDetector() self.chatbox = ChatBox( self.owner, self._ebook_mode_detector.get_ebook_mode()) self.chatbox.connect('open-on-journal', self.__open_on_journal) super(Chat, self).__init__(handle) self._entry = None self._has_alert = False self._has_osk = False self._setup_canvas() GObject.idle_add(self._create_smiley_window) self._entry.grab_focus() toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) self._activity_toolbar_button = ActivityToolbarButton(self) self._activity_toolbar_button.connect('clicked', self._fixed_resize_cb) toolbar_box.toolbar.insert(self._activity_toolbar_button, 0) self._activity_toolbar_button.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) toolbar_box.toolbar.insert(StopButton(self), -1) toolbar_box.show_all() # Chat is room or one to one: self._chat_is_room = False self.text_channel = None if _HAS_SOUND: self.element = Gst.ElementFactory.make('playbin', 'Player') if self.shared_activity: # we are joining the activity self._entry.props.placeholder_text = \ _('Please wait for a connection before starting to chat.') self.connect('joined', self._joined_cb) if self.get_shared(): # we have already joined self._joined_cb(self) elif handle.uri: # XMPP non-sugar3 incoming chat, not sharable self._activity_toolbar_button.props.page.share.props.visible = \ False self._one_to_one_connection(handle.uri) else: # we are creating the activity if not self.metadata or self.metadata.get( 'share-scope', activity.SCOPE_PRIVATE) == \ activity.SCOPE_PRIVATE: # if we are in private session self._alert(_('Off-line'), _('Share, or invite someone.')) else: self._entry.props.placeholder_text = \ _('Please wait for a connection before starting to chat.') self.connect('shared', self._shared_cb)
def __init__(self, handle): smilies.init() self.chatbox = ChatBox() super(Chat, self).__init__(handle) self.entry = None root = self.make_root() self.set_canvas(root) root.show_all() self.entry.grab_focus() toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.toolbar.insert(ActivityButton(self), -1) toolbar_box.toolbar.insert(TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: logger.debug('DescriptionItem button is not available, ' \ 'toolkit version < 0.96') else: description_item = DescriptionItem(self) toolbar_box.toolbar.insert(description_item, -1) description_item.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) self._smiley = RadioMenuButton(icon_name='smilies') self._smiley.palette = Palette(_('Insert smiley')) self._smiley.props.sensitive = False toolbar_box.toolbar.insert(self._smiley, -1) table = self._create_pallete_smiley_table() table.show_all() self._smiley.palette.set_content(table) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) toolbar_box.toolbar.insert(StopButton(self), -1) toolbar_box.show_all() pservice = presenceservice.get_instance() self.owner = pservice.get_owner() # Chat is room or one to one: self._chat_is_room = False self.text_channel = None if self.shared_activity: # we are joining the activity self.connect('joined', self._joined_cb) if self.get_shared(): # we have already joined self._joined_cb(self) elif handle.uri: # XMPP non-Sugar incoming chat, not sharable share_button.props.visible = False self._one_to_one_connection(handle.uri) else: # we are creating the activity if not self.metadata or self.metadata.get('share-scope', activity.SCOPE_PRIVATE) == activity.SCOPE_PRIVATE: # if we are in private session self._alert(_('Off-line'), _('Share, or invite someone.')) self.connect('shared', self._shared_cb)
def __init__(self, handle): super(Chat, self).__init__(handle) smilies.init() self.entry = None self.chatbox = None root = self.make_root() self.set_canvas(root) root.show_all() self.entry.grab_focus() toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.toolbar.insert(ActivityButton(self), -1) toolbar_box.toolbar.insert(TitleEntry(self), -1) share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) self._smiley = RadioMenuButton(icon_name='smilies') self._smiley.palette = Palette(_('Insert smiley')) self._smiley.props.sensitive = False toolbar_box.toolbar.insert(self._smiley, -1) table = self._create_pallete_smiley_table() table.show_all() self._smiley.palette.set_content(table) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) toolbar_box.toolbar.insert(StopButton(self), -1) toolbar_box.show_all() pservice = presenceservice.get_instance() self.owner = pservice.get_owner() # Chat is room or one to one: self._chat_is_room = False self.text_channel = None if self.shared_activity: # we are joining the activity self.connect('joined', self._joined_cb) if self.get_shared(): # we have already joined self._joined_cb(self) elif handle.uri: # XMPP non-Sugar incoming chat, not sharable share_button.props.visible = False self._one_to_one_connection(handle.uri) else: # we are creating the activity if not self.metadata or self.metadata.get( 'share-scope', activity.SCOPE_PRIVATE) == activity.SCOPE_PRIVATE: # if we are in private session self._alert(_('Off-line'), _('Share, or invite someone.')) self.connect('shared', self._shared_cb)