def spellcheck(self): global spell_support spell_error = False if self.posix and spell_support: if self.config.get('gtkspell', False, section='spell') == True: if self.config.get('notes', True, section='spell') is True and self.config.get( 'lang', section='spell') != '': try: self.notes_spell = gtkspell.Spell( self.widgets['add']['notes'], self.config.get('lang', section='spell')) except: spell_error = True if self.config.get('plot', True, section='spell') is True and self.config.get( 'lang', section='spell') != '': try: self.plot_spell = gtkspell.Spell( self.widgets['add']['plot'], self.config.get('lang', section='spell')) except: spell_error = True if spell_error: log.info( 'Dictionary not available. Spell check will be disabled.') if not self.config.get('notified', False, section='spell'): gutils.info(_("Dictionary not available. Spellcheck will be disabled. \n" + \ "Please install the aspell-%s package or adjust the spellchecker preferences.") % self.config.get('lang', section='spell'), \ self.widgets['preferences']['window']) self.config.set('notified', True, section='spell') self.config.save() else: log.info('Spellchecker is not available')
def display(self, record, field): super(TextBox, self).display(record, field) value = field and field.get(record) if not value: value = '' self.set_buffer(value) if gtkspell: spell = None try: spell = gtkspell.get_from_text_view(self.textview) except Exception: pass if self.attrs.get('spell') and CONFIG['client.spellcheck'] \ and self.record: language = self.record.expr_eval(self.attrs['spell']) try: if not spell: spell = gtkspell.Spell(self.textview) if self.lang != language: try: spell.set_language(language) except Exception: spell.detach() del spell self.lang = language except Exception: pass elif spell: spell.detach() del spell
def setup_ui (self): """ Setup the text views """ self.source_buffer = gtk.TextBuffer () view = self.source_view = gtk.TextView (self.source_buffer) view.show () gtkspell.Spell (view) scrolled = uiutils.ScrolledWindow (view) scrolled.show () frame = uiutils.Frame (_("Text to translate"), self.translate_buttons ()) frame.add (scrolled) frame.show () self.layout.pack_start (frame) self.dest_buffer = gtk.TextBuffer () view = gtk.TextView (self.dest_buffer) view.set_editable (False) view.modify_base (gtk.STATE_NORMAL, self.DESTINATION_COLOR) view.show () scrolled = uiutils.ScrolledWindow (view) scrolled.show () frame = uiutils.Frame (_("Translated text"), self.translated_buttons ()) frame.add (scrolled) frame.show () self.layout.pack_start (frame)
def _readonly_set(self, value): super(TextBox, self)._readonly_set(value) self.textview.set_editable(not value) if self.button: self.button.set_sensitive(not value) if value and CONFIG['client.fast_tabbing']: self.widget.set_focus_chain([]) else: self.widget.unset_focus_chain() if gtkspell: spell = None try: spell = gtkspell.get_from_text_view(self.textview) except Exception: pass if not value and self.attrs.get('spell') \ and CONFIG['client.spellcheck'] \ and self.record: language = self.record.expr_eval(self.attrs['spell']) try: if not spell: spell = gtkspell.Spell(self.textview) if self.lang != language: try: spell.set_language(language) except Exception: spell.detach() del spell self.lang = language except Exception: pass elif spell: spell.detach() del spell
def enable_spell_check(self, enabled=True): """Enables/disables spell check""" if not self.can_spell_check(): return if enabled: if self._spell_checker is None: try: self._spell_checker = gtkspell.Spell(self.day_text_view) except gobject.GError as err: logging.error('Spell checking could not be enabled: "%s"' % err) self._spell_checker = None if self._spell_checker: try: self._spell_checker.set_language(filesystem.LANGUAGE) except RuntimeError as err: logging.error( 'Spellchecking could not be enabled for %s: %s' % (filesystem.LANGUAGE, err)) logging.error('Consult built-in help for instructions ' 'on how to add custom dictionaries.') else: if self._spell_checker is not None: self._spell_checker.detach() self._spell_checker = None
def __init__(self, session, on_send_message, on_cycle_history, on_drag_data_received): '''constructor''' TextBox.__init__(self, session.config, on_drag_data_received) self.on_send_message = on_send_message self.on_cycle_history = on_cycle_history self._tag = None self._textbox.connect('key-press-event', self._on_key_press_event) self._buffer.connect('changed', self.on_changed_event) self.session = session self.changed = False self.parse_timeout = None self.invisible_tag = gtk.TextTag() self.invisible_tag.set_property('invisible', True) self._buffer.get_tag_table().add(self.invisible_tag) self.spell_checker = None if self.config.b_enable_spell_check: try: import gtkspell spell_lang = self.config.get_or_set("spell_lang", "en") self.spell_checker = gtkspell.Spell(self._textbox, spell_lang) except Exception, e: log.warning("Could not load spell-check: %s" % e)
def setSpell(self, textView): try: gtkspell.Spell(textView, self.lang) except Exception, e: print str(e) self.error(_('Error applying Spell to input (%s)') % e, False) return False
def activate(self, recEditor): UIPlugin.activate(self, recEditor) for module in self.pluggable.modules: tvs = harvest_textviews(module.main) for tv in tvs: try: gtkspell.Spell(tv) except: gtkspellcheck.spellcheck.SpellChecker(tv)
def _enable_spell_check(self): assert self.can_spell_check() assert self._spell_checker is None try: self._spell_checker = gtkspell.Spell(self.day_text_view) except gobject.GError as err: logging.error('Spell checking could not be enabled: %s' % err) self._spell_checker = None else: self._use_system_language_for_spell_check()
def enable_spell_check(self, enabled=True): """Enables/disables spell check""" if not self.can_spell_check(): return if enabled: if self._spell_checker is None: self._spell_checker = gtkspell.Spell(self) else: if self._spell_checker is not None: self._spell_checker.detach() self._spell_checker = None
def __init__(self, widget=None, value="", spellcheck=True): if widget is None: self.view = gtk.TextView() else: self.view = widget self.buffer = gtk.TextBuffer() self.view.set_buffer(self.buffer) self.buffer.set_text(value) if HAS_GTKSPELL and spellcheck: try: gtkspell.Spell(self.view) except Exception, e: log.exception(e)
def __init__(self, save_file_name=None, auto_save=False): textview.Widget.__init__(self) actions.CAGandUIManager.__init__(self) self.view.set_right_margin_position(72) self.view.set_show_right_margin(True) self.view.set_cursor_visible(True) self.view.set_editable(True) if GTKSPELL_AVAILABLE: gtkspell.Spell(self.view) # Set up file stuff self._save_interval = 1000 # milliseconds self._save_file_name = save_file_name self._save_file_digest = None self.save_toggle_action.set_active(auto_save) self._update_action_sensitivities()
def __init__(self, widget=None, value=""): if HAS_GTKSOURCEVIEW: if widget is None: self.view = gtksourceview.SourceView(self.buffer) else: self.view = widget self.buffer = gtksourceview.SourceBuffer() self.buffer.set_text(value) if HAS_GTKSPELL: gtkspell.Spell(self.view) self.view.show() else: TextView.__init__(self, widget, value)
def enable_spell_check(self, enabled=True): """Enables/disables spell check""" if not self.can_spell_check(): return if enabled: if self._spell_checker is None: try: self._spell_checker = gtkspell.Spell(self) except Exception: # unable to intialize spellcheck, abort self._spell_checker = None else: if self._spell_checker is not None: self._spell_checker.detach() self._spell_checker = None
def setup(self): textview = self.window.pageview.view lang = self.plugin.preferences['language'] or None try: self.spell = gtkspell.Spell(textview, lang) except: ErrorDialog( self.ui, ( _('Could not load spell checking'), # T: error message _('This could mean you don\'t have the proper\ndictionaries installed' ) # T: error message explanation )).run() self.spell = None else: textview.gtkspell = self.spell # HACK used by hardcoded hook in pageview
def _set_spellcheck_(self, textview): if 'spellcheck' in configuration.options: # Deactivate previous spell try: spell = gtkspell.get_from_text_view(textview) except: pass else: spell.detach() # Activate new spell if necessary activate_spellcheck = configuration.options["spellcheck"] if activate_spellcheck == "True": spell = gtkspell.Spell(textview) # [TODO] # Priority: medium/high # Each project should have their own language settings. if 'language' in configuration.options: language = configuration.options["language"] if language: spell.set_language(language)
def __init__(self, window, parent, model, attrs={}): interface.widget_interface.__init__(self, window, parent, model, attrs) self.widget = gtk.ScrolledWindow() self.widget.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.widget.set_shadow_type(gtk.SHADOW_NONE) self.widget.set_size_request(-1, 80) self.tv = gtk.TextView() self.tv.set_wrap_mode(gtk.WRAP_WORD) self.tv.connect('button_press_event', self._menu_open) self.tv.set_accepts_tab(False) self.tv.connect('focus-out-event', lambda x, y: self._focus_out()) if not attrs.get('readonly'): try: import gtkspell gtkspell.Spell(self.tv).set_language(locale.getlocale()[0]) except: # No word list may not be found for the language pass self.widget.add(self.tv) self.widget.show_all()
def __real_set_active_spellcheck(self, spellcheck_code): """Set active spellcheck by its code.""" if self._active_spellcheck == 'off': if spellcheck_code == 'off': return else: try: with self.textview.undo_disabled(): gtkspell_spell = gtkspell.Spell(self.textview) self._active_spellcheck = spellcheck_code except: # attaching the spellchecker will fail if # the language does not exist # and presumably if there is no dictionary pass else: if spellcheck_code == 'on': return else: gtkspell_spell = gtkspell.get_from_text_view(self.textview) gtkspell_spell.detach() self._active_spellcheck = spellcheck_code
def __init__(self, entry=None, parent=None): self.cfg = appconst.CFG self.modified = False self.isNew = (entry is None) self.entry = entry self.wTree = gtk.glade.XML(appconst.GLADE_PATH, 'frmEntry', 'jpa') self.window = self.wTree.get_widget('frmEntry') self.window.set_icon_from_file(op.join(appconst.PATHS['img'], 'darkbeer.xpm')) if parent: self.window.set_transient_for(parent.window) self.spnVisLevel = self.wTree.get_widget('spnVisLevel') self.lbVisLevelDesc = self.wTree.get_widget('lbVisLevelDesc') self.edTitle = self.wTree.get_widget('edTitle') self.txBody = self.wTree.get_widget('txBody') useSpell = (self.cfg.getOption('editing', 'check_spelling', '1') == '1') if hasSpeller and useSpell: self.speller = gtkspell.Spell(self.txBody) self.cbxContentType = self.wTree.get_widget('cbxContentType') self.cbxLang = self.wTree.get_widget('cbxLang') self.ckbIsDraft = self.wTree.get_widget('ckbIsDraft') self.lvCategory = self.wTree.get_widget('lvCategory') self.wTree.signal_autoconnect(self)
def save_preferences(self): w = self.widgets['preferences'] c = self.config global spell_support was_false = notes_was_false = plot_was_false = 1 if c.get('gtkspell', False, section='spell') == True: was_false = 0 if c.get('notes', False, section='spell') == True: notes_was_false = 0 if c.get('plot', False, section='spell') == True: plot_was_false = 0 # number if w['view_number'].get_active(): c.set('number', 'True', section='mainlist') else: c.set('number', 'False', section='mainlist') # image if w['view_image'].get_active(): c.set('image', 'True', section='mainlist') else: c.set('image', 'False', section='mainlist') # original title if w['view_o_title'].get_active(): c.set('otitle', 'True', section='mainlist') else: c.set('otitle', 'False', section='mainlist') # title if w['view_title'].get_active(): c.set('title', 'True', section='mainlist') else: c.set('title', 'False', section='mainlist') # director if w['view_director'].get_active(): c.set('director', 'True', section='mainlist') else: c.set('director', 'False', section='mainlist') # genre if w['view_genre'].get_active(): c.set('genre', 'True', section='mainlist') else: c.set('genre', 'False', section='mainlist') # seen if w['view_seen'].get_active(): c.set('seen', 'True', section='mainlist') else: c.set('seen', 'False', section='mainlist') # year if w['view_year'].get_active(): c.set('year', 'True', section='mainlist') else: c.set('year', 'False', section='mainlist') # runtime if w['view_runtime'].get_active(): c.set('runtime', 'True', section='mainlist') else: c.set('runtime', 'False', section='mainlist') # rating if w['view_rating'].get_active(): c.set('rating', 'True', section='mainlist') else: c.set('rating', 'False', section='mainlist') # created if w['view_created'].get_active(): c.set('created', 'True', section='mainlist') else: c.set('created', 'False', section='mainlist') # updated if w['view_updated'].get_active(): c.set('updated', 'True', section='mainlist') else: c.set('updated', 'False', section='mainlist') # sortby if w['sortby'].get_active(): field = self.sort_criteria[w['sortby'].get_active()] if field: c.set('sortby', field, section='mainlist') else: c.set('sortby', 'number', section='mainlist') c.set('sortby_reverse', w['sortby_reverse'].get_active(), section='mainlist') c.set('limit', str(int(w['s_limit'].get_value())), section='mainlist') # pdf font if w['font'].get_filename(): c['font'] = w['font'].get_filename() c['font_size'] = int(w['font_size'].get_value()) # pdf elements pdf_elements = '' for child in w['pdf_elements_table']: if child.get_active(): pdf_elements = pdf_elements + child.get_name()[4:] + ',' if pdf_elements: c.set('pdf_elements', pdf_elements[:-1]) else: c.set('pdf_elements', pdf_elements) # spellchecker if w['spellchecker'].get_active(): c.set('gtkspell', True, section='spell') else: c.set('gtkspell', False, section='spell') if w['spell_notes'].get_active(): c.set('notes', True, section='spell') else: c.set('notes', False, section='spell') if w['spell_plot'].get_active(): c.set('plot', True, section='spell') else: c.set('plot', False, section='spell') # rating image c['rating_image'] = str(w['rating_image'].get_active()) #defaults media_id = self.media_ids[w['media'].get_active()] if media_id is None: media_id = 0 c.set('media', media_id, section='defaults') vcodec_id = self.vcodecs_ids[w['vcodec'].get_active()] if vcodec_id is None: vcodec_id = 0 c.set('vcodec', vcodec_id, section='defaults') c.set('condition', str(w['condition'].get_active()), section='defaults') c.set('region', str(w['region'].get_active()), section='defaults') c.set('layers', str(w['layers'].get_active()), section='defaults') c.set('color', str(w['color'].get_active()), section='defaults') c.set('seen', str(w['seen'].get_active()), section='defaults') # email reminder if w['mail_use_auth'].get_active(): c.set('use_auth', True, section='mail') else: c.set('use_auth', False, section='mail') if w['mail_use_tls'].get_active(): c.set('mail_use_tls', True, section='mail') else: c.set('mail_use_tls', False, section='mail') c.set('smtp_server', w['mail_smtp_server'].get_text(), section='mail') c.set('mail_smtp_port', w['mail_smtp_port'].get_text(), section='mail') c.set('username', w['mail_username'].get_text(), section='mail') c.set('password', w['mail_password'].get_text(), section='mail') c.set('email', w['mail_email'].get_text(), section='mail') # default movie plugin if w['default_plugin'].get_active(): c['default_movie_plugin'] = \ gutils.on_combo_box_entry_changed(w['default_plugin']) # search for: c.set('s_classification', w['s_classification'].get_active(), section='add') c.set('s_country', w['s_country'].get_active(), section='add') c.set('s_director', w['s_director'].get_active(), section='add') c.set('s_genre', w['s_genre'].get_active(), section='add') c.set('s_image', w['s_image'].get_active(), section='add') c.set('s_notes', w['s_notes'].get_active(), section='add') c.set('s_o_site', w['s_o_site'].get_active(), section='add') c.set('s_o_title', w['s_o_title'].get_active(), section='add') c.set('s_plot', w['s_plot'].get_active(), section='add') c.set('s_rating', w['s_rating'].get_active(), section='add') c.set('s_runtime', w['s_runtime'].get_active(), section='add') c.set('s_site', w['s_site'].get_active(), section='add') c.set('s_studio', w['s_studio'].get_active(), section='add') c.set('s_title', w['s_title'].get_active(), section='add') c.set('s_trailer', w['s_trailer'].get_active(), section='add') c.set('s_cast', w['s_cast'].get_active(), section='add') c.set('s_year', w['s_year'].get_active(), section='add') c.set('s_screenplay', w['s_screenplay'].get_active(), section='add') c.set('s_cameraman', w['s_cameraman'].get_active(), section='add') c.set('s_resolution', w['s_resolution'].get_active(), section='add') c.set('s_barcode', w['s_barcode'].get_active(), section='add') mcounter = 0 for p in self.plugins: plugin_module = os.path.basename(p).replace('.py', '') plugin_name = plugin_module.replace('PluginMovie', '') if gutils.on_combo_box_entry_changed( w['default_plugin']) == plugin_name: break mcounter = mcounter + 1 self.widgets['add']['source'].set_active(mcounter) save_reader = w['epdf_reader'].get_text() c.set('lang', w['spell_lang'].get_text(), section='spell') c['pdf_reader'] = save_reader if spell_support: if c.get('gtkspell', False, section='spell') == False and not was_false: self.notes_spell.detach() self.plot_spell.detach() elif c.get('gtkspell', False, section='spell') == True and was_false: initialize.spellcheck(self) else: pass if c.get('gtkspell', False, section='spell') == True: if c.get('plot', True, section='spell') == False and not plot_was_false: self.plot_spell.detach() elif c.get('plot', True, section='spell') == True and plot_was_false: self.plot_spell = gtkspell.Spell(self.widgets['add']['plot']) self.plot_spell.set_language( c.get('lang', 'en', section='spell')) else: pass if c.get('notes', True, section='spell') == False and not notes_was_false: self.notes_spell.detach() elif c.get('notes', True, section='spell') == True and notes_was_false: self.notes_spell = gtkspell.Spell(self.widgets['add']['notes']) self.notes_spell.set_language( c.get('lang', 'en', section='spell')) else: pass self.pdf_reader = save_reader # extensions settings for ext_name in plugins.extensions.by_name: preferenceswidgets = plugins.extensions.by_name[ ext_name].preferenceswidgets for prefname in preferenceswidgets: widget = preferenceswidgets[prefname] if isinstance(widget, gtk.CheckButton): value = widget.get_active() elif isinstance(widget, gtk.Entry): value = widget.get_text() elif isinstance(widget, gtk.ComboBox): iter = widget.get_active_iter() if iter: value = widget.get_model().get_value(iter, 1) else: log.error('widget type not supported %s', type(widget)) continue c.set("%s_%s" % (ext_name, prefname), value, section='extensions') # database old = c.to_dict(section='database') c.set('host', w['db_host'].get_text(), section='database') c.set('port', int(w['db_port'].get_value()), section='database') c.set('name', w['db_name'].get_text(), section='database') c.set('user', w['db_user'].get_text(), section='database') c.set('passwd', w['db_passwd'].get_text(), section='database') db_type = int(w['db_type'].get_active()) if db_type == 1: c.set('type', 'postgres', section='database') elif db_type == 2: c.set('type', 'mysql', section='database') elif db_type == 3: c.set('type', 'mssql', section='database') else: c.set('type', 'sqlite', section='database') if old['type'] != c.get('type', section='database') or (old['type']!='sqlite' and (\ old['host'] != c.get('host', section='database') or \ old['port'] != c.get('port', section='database') or \ old['user'] != c.get('user', section='database') or \ old['passwd'] != c.get('passwd', section='database'))) or \ old['name'] != c.get('name', section='database'): log.info('DATABASE: connecting to new db server...') import sql from sqlalchemy.exc import InvalidRequestError from initialize import dictionaries, people_treeview # new database connection self.initialized = False if c.has_key('posters'): c['posters'] = None # force update try: self.db.dispose() self.db = sql.GriffithSQL(c, self.locations['home'], fallback=True) except InvalidRequestError, e: log.exception('') c.set('type', 'sqlite', section='database') w['db_type'].set_active(0) self.db = sql.GriffithSQL(c, self.locations['home']) log.info("New database Engine: %s" % self.db.session.bind.engine.name) # initialize new database self.total = int(self.db.session.query(db.Movie).count()) self.count_statusbar() dictionaries(self) people_treeview(self, False) self.initialized = True
def activate (self, recEditor): UIPlugin.activate(self,recEditor) for module in self.pluggable.modules: tvs = harvest_textviews(module.main) for tv in tvs: gtkspell.Spell(tv)
def __init__(self, db, category, search): self._db = db self._category = category self._search = search self._search.connect("hide", self._on_search_close) self.noteId = -1 self._pos = -1 self._noteBody = None #Last notetext self._categoryName = "" gtk.HBox.__init__(self, homogeneous=False, spacing=0) _moduleLogger.info("libnotizen, init") # Note list self._noteslist = simple_list.SimpleList() self._noteslist.set_eventfunction_cursor_changed( self._update_noteslist) self._noteslist.widget.set_size_request(250, -1) buttonHBox = gtk.HBox() button = gtk.Button(stock=gtk.STOCK_ADD) button.connect("clicked", self._on_add_note, None) buttonHBox.pack_start(button, expand=True, fill=True, padding=3) button = gtk.Button(stock=gtk.STOCK_DELETE) button.connect("clicked", self._on_delete_note, None) buttonHBox.pack_start(button, expand=True, fill=True, padding=3) listVbox = gtk.VBox(homogeneous=False, spacing=0) listVbox.pack_start(self._category, expand=False, fill=True, padding=3) listVbox.pack_start(self._noteslist.widget, expand=True, fill=True, padding=3) listVbox.pack_start(buttonHBox, expand=False, fill=True, padding=3) self.pack_start(listVbox, expand=False, fill=True, padding=3) # Note view self._noteBodyView = gtk.TextView() self._noteBodyView.connect("focus-out-event", self.save_note, "focus-out-event") buf = self._noteBodyView.get_buffer() buf.set_text("") buf.connect("changed", self._on_note_changed, None) if gtkspell is not None: self._noteBodySpellChecker = gtkspell.Spell(self._noteBodyView) else: self._noteBodySpellChecker = None self._noteScrollWindow = gtk.ScrolledWindow() self._noteScrollWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._noteScrollWindow.add(self._noteBodyView) hildonize.hildonize_scrollwindow_with_viewport(self._noteScrollWindow) # Note and history stuff in same column noteVbox = gtk.VBox(homogeneous=False, spacing=0) noteVbox.pack_start(self._noteScrollWindow, expand=True, fill=True, padding=3) self.pack_start(noteVbox, expand=True, fill=True, padding=3) self.load_notes() self._category.connect("category_changed", self.load_notes) self._search.connect("search_changed", self.load_notes)
def __init__(self, parent): gtk.Window.__init__(self) self.filename = '' self.pic_url = '' self.blocked = False self.mainwin = parent #self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_title(_('Upload picture')) self.set_resizable(False) self.set_size_request(300, 400) self.set_transient_for(parent) #self.set_modal(True) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) #self.btn_pic = gtk.Button(_('Click to select image')) self.btn_pic = gtk.Button() self.btn_pic.set_size_request(250, 250) pic_box = gtk.VBox(False) pic_box.pack_start(self.btn_pic, True, True, 0) self.label = gtk.Label() self.label.set_use_markup(True) self.label.set_alignment(0, 0.5) self.label.set_markup('<span size="medium"><b>%s</b></span>' % _('Message')) self.label.set_justify(gtk.JUSTIFY_LEFT) self.num_chars = gtk.Label() self.num_chars.set_use_markup(True) self.num_chars.set_markup( '<span size="14000" foreground="#999"><b>140</b></span>') self.update_text = MessageTextView() self.update_text.set_border_width(2) self.update_text.set_left_margin(2) self.update_text.set_right_margin(2) self.update_text.set_wrap_mode(gtk.WRAP_WORD) buffer = self.update_text.get_buffer() scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) scroll.add(self.update_text) updatebox = gtk.HBox(False) updatebox.pack_start(scroll, True, True, 3) self.btn_clr = gtk.Button() self.btn_clr.set_image(self.mainwin.load_image('action-clear.png')) self.btn_clr.set_tooltip_text(_('Clear all') + ' (Ctrl+L)') self.btn_clr.set_relief(gtk.RELIEF_NONE) self.btn_frn = gtk.Button() self.btn_frn.set_image( self.mainwin.load_image('action-add-friends.png')) self.btn_frn.set_tooltip_text(_('Add friends') + ' (Ctrl+F)') self.btn_frn.set_relief(gtk.RELIEF_NONE) self.btn_upd = gtk.Button(_('Upload')) self.btn_upd.set_tooltip_text(_('Update your status') + ' (Ctrl+T)') top = gtk.HBox(False) top.pack_start(self.label, True, True, 5) top.pack_start(self.num_chars, False, False, 5) self.waiting = CairoWaiting(parent) self.lblerror = gtk.Label() self.lblerror.set_use_markup(True) error_align = gtk.Alignment(xalign=0.0) error_align.add(self.lblerror) buttonbox = gtk.HBox(False) buttonbox.pack_start(self.btn_frn, False, False, 0) buttonbox.pack_start(self.btn_clr, False, False, 0) buttonbox.pack_start(gtk.HSeparator(), False, False, 2) buttonbox.pack_start(self.btn_upd, False, False, 0) abuttonbox = gtk.Alignment(1, 0.5) abuttonbox.add(buttonbox) bottom = gtk.HBox(False) bottom.pack_start(self.waiting, False, False, 5) bottom.pack_start(error_align, True, True, 4) #bottom.pack_start(abuttonbox, True, True, 5) vbox = gtk.VBox(False) vbox.pack_start(pic_box, False, False, 2) vbox.pack_start(top, False, False, 2) vbox.pack_start(updatebox, True, True, 2) vbox.pack_start(abuttonbox, False, False, 2) vbox.pack_start(bottom, False, False, 2) self.add(vbox) self.connect('key-press-event', self.__detect_shortcut) self.connect('delete-event', self.__unclose) buffer.connect('changed', self.count_chars) self.btn_frn.connect('clicked', self.show_friend_dialog) self.btn_clr.connect('clicked', self.clear) self.btn_upd.connect('clicked', self.upload) self.btn_pic.connect('clicked', self.choose_pic) self.update_text.connect('mykeypress', self.__on_key_pressed) if SPELLING: try: self.spell = gtkspell.Spell(self.update_text) except Exception, e_msg: # FIXME: Usar el log print 'DEBUG:UI:Can\'t load gtkspell -> %s' % e_msg
def enable(self): if not self._checker: self._checker = gtkspell.Spell(self._textview, self._lang)
def __init__(self, parent): gtk.Window.__init__(self) self.what = _('What is happening?') self.blocked = False self.mainwin = parent #self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_title(_('Update status')) self.set_resizable(False) #self.set_default_size(500, 120) self.set_size_request(500, 150) self.set_transient_for(parent) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.label = gtk.Label() self.label.set_use_markup(True) self.label.set_alignment(0, 0.5) self.label.set_markup('<span size="medium"><b>%s</b></span>' % self.what) self.label.set_justify(gtk.JUSTIFY_LEFT) self.num_chars = gtk.Label() self.num_chars.set_use_markup(True) self.num_chars.set_markup( '<span size="14000" foreground="#999"><b>140</b></span>') self.update_text = MessageTextView() self.update_text.set_border_width(2) self.update_text.set_left_margin(2) self.update_text.set_right_margin(2) self.update_text.set_wrap_mode(gtk.WRAP_WORD) buffer = self.update_text.get_buffer() scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) scroll.add(self.update_text) updatebox = gtk.HBox(False) updatebox.pack_start(scroll, True, True, 3) self.url = gtk.Entry() self.btn_url = gtk.Button(_('Shorten URL')) self.btn_url.set_tooltip_text(_('Shorten URL')) self.btn_pic = gtk.Button(_('Upload image')) self.btn_pic.set_tooltip_text(_('Upload image')) tools = gtk.HBox(False) tools.pack_start(self.url, True, True, 3) tools.pack_start(self.btn_url, False, False) tools.pack_start(gtk.HSeparator(), False, False) tools.pack_start(self.btn_pic, False, False, 3) self.toolbox = gtk.Expander() self.toolbox.set_label(_('Options')) self.toolbox.set_expanded(False) self.toolbox.add(tools) self.btn_clr = gtk.Button() self.btn_clr.set_image(self.mainwin.load_image('clear.png')) self.btn_clr.set_tooltip_text(_('Clear all')) self.btn_clr.set_relief(gtk.RELIEF_NONE) self.btn_frn = gtk.Button() self.btn_frn.set_image(self.mainwin.load_image('friends.png')) self.btn_frn.set_tooltip_text(_('Add friends')) self.btn_frn.set_relief(gtk.RELIEF_NONE) self.btn_upd = gtk.Button(_('Tweet')) chk_short = gtk.CheckButton(_('Autoshort URLs')) chk_short.set_sensitive(False) top = gtk.HBox(False) top.pack_start(self.label, True, True, 5) top.pack_start(self.num_chars, False, False, 5) self.waiting = CairoWaiting(parent) self.lblerror = gtk.Label() self.lblerror.set_use_markup(True) error_align = gtk.Alignment(xalign=0.0) error_align.add(self.lblerror) buttonbox = gtk.HBox(False) buttonbox.pack_start(chk_short, False, False, 0) buttonbox.pack_start(self.btn_frn, False, False, 0) buttonbox.pack_start(self.btn_clr, False, False, 0) buttonbox.pack_start(gtk.HSeparator(), False, False, 2) buttonbox.pack_start(self.btn_upd, False, False, 0) abuttonbox = gtk.Alignment(1, 0.5) abuttonbox.add(buttonbox) bottom = gtk.HBox(False) bottom.pack_start(self.waiting, False, False, 5) bottom.pack_start(error_align, True, True, 4) bottom.pack_start(abuttonbox, True, True, 5) vbox = gtk.VBox(False) vbox.pack_start(top, False, False, 2) vbox.pack_start(updatebox, True, True, 2) vbox.pack_start(bottom, False, False, 2) vbox.pack_start(self.toolbox, False, False, 2) self.add(vbox) self.connect('delete-event', self.__unclose) buffer.connect('changed', self.count_chars) self.btn_frn.connect('clicked', self.show_friend_dialog) self.btn_clr.connect('clicked', self.clear) self.btn_upd.connect('clicked', self.update) self.btn_url.connect('clicked', self.short_url) self.btn_pic.connect('clicked', self.upload_pic) self.toolbox.connect('activate', self.show_options) self.update_text.connect('mykeypress', self.__on_key_pressed) if SPELLING: try: self.spell = gtkspell.Spell(self.update_text) except Exception, e_msg: # FIXME: Usar el log print 'DEBUG:UI:Can\'t load gtkspell -> %s' % e_msg
def __init__(self): gtk.Window.__init__(self) self.vbox = gtk.VBox() self.hbox = gtk.HBox() self.scroll = gtk.ScrolledWindow() self.view = TextEditor() buffer = self.view.get_buffer() self.view.modify_font(pango.FontDescription("Arial 12")) self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.set_size_request(800, 600) self.vbox.set_border_width(6) self.vbox.set_spacing(6) self.hbox.set_spacing(6) buffer.connect('undo-stack-changed', self._on_buffer_undo_stack_changed) self.view.connect('link-clicked', self._on_link_clicked) self.view.connect('annotation-focus-out-event', self._on_annotation_focus_out_event) # Format changing buttons. button = gtk.Button(stock=gtk.STOCK_BOLD) button.set_properties(can_focus=False) button.connect('clicked', self._on_button_format_clicked, buffer, 'bold') self.hbox.pack_start(button, False) button = gtk.Button(stock=gtk.STOCK_ITALIC) button.set_properties(can_focus=False) button.connect('clicked', self._on_button_format_clicked, buffer, 'italic') self.hbox.pack_start(button, False) button = gtk.Button(stock=gtk.STOCK_UNDERLINE) button.set_properties(can_focus=False) button.connect('clicked', self._on_button_format_clicked, buffer, 'underline') self.hbox.pack_start(button, False) # Undo/redo buttons. self.undo_button = gtk.Button(stock=gtk.STOCK_UNDO) self.undo_button.set_properties(can_focus=False) self.undo_button.set_sensitive(buffer.can_undo()) self.undo_button.connect('clicked', self._on_button_undo_clicked, buffer) self.hbox.pack_start(self.undo_button, False) self.redo_button = gtk.Button(stock=gtk.STOCK_REDO) self.redo_button.set_properties(can_focus=False) self.redo_button.set_sensitive(buffer.can_redo()) self.redo_button.connect('clicked', self._on_button_redo_clicked, buffer) self.hbox.pack_start(self.redo_button, False) # Annotation buttons. button = gtk.Button(label="Add annotation") button.set_properties(can_focus=False) button.connect('clicked', self._on_button_add_annotation_clicked) self.hbox.pack_start(button) button = gtk.ToggleButton(label="Show annotations") button.set_active(True) button.set_properties(can_focus=False) button.connect('toggled', self._on_button_show_annotations_toggled) self.hbox.pack_start(button) # Pack widgets. self.scroll.add(self.view) self.add(self.vbox) self.vbox.pack_start(self.hbox, False) self.vbox.pack_start(self.scroll) self.show_all() # Enable spell checking. lang = locale.getlocale()[0] if lang is None: print "WARNING: Spell check disabled because language is not set." else: gtkspell.Spell(self.view).set_language(lang) # Insert some text. buffer.insert_at_cursor('Test me please.') range = buffer.get_bounds() tag = buffer.create_link_tag('link_to_debain_org', 'http://debain.org') buffer.apply_tag(tag, *range) dump = buffer.dump() buffer.delete(*range) buffer.restore(dump)