fix coding standards
This commit is contained in:
parent
826e66ba81
commit
5951ea5d86
|
@ -61,8 +61,8 @@ class TextViewImage(gtk.Image):
|
|||
self.anchor = anchor
|
||||
self._selected = False
|
||||
self._disconnect_funcs = []
|
||||
self.connect("parent-set", self.on_parent_set)
|
||||
self.connect("expose-event", self.on_expose)
|
||||
self.connect('parent-set', self.on_parent_set)
|
||||
self.connect('expose-event', self.on_expose)
|
||||
|
||||
def _get_selected(self):
|
||||
parent = self.get_parent()
|
||||
|
@ -110,13 +110,13 @@ class TextViewImage(gtk.Image):
|
|||
self._disconnect_signals()
|
||||
return
|
||||
|
||||
self._do_connect(parent, "style-set", self.do_queue_draw)
|
||||
self._do_connect(parent, "focus-in-event", self.do_queue_draw)
|
||||
self._do_connect(parent, "focus-out-event", self.do_queue_draw)
|
||||
self._do_connect(parent, 'style-set', self.do_queue_draw)
|
||||
self._do_connect(parent, 'focus-in-event', self.do_queue_draw)
|
||||
self._do_connect(parent, 'focus-out-event', self.do_queue_draw)
|
||||
|
||||
textbuf = parent.get_buffer()
|
||||
self._do_connect(textbuf, "mark-set", self.on_mark_set)
|
||||
self._do_connect(textbuf, "mark-deleted", self.on_mark_deleted)
|
||||
self._do_connect(textbuf, 'mark-set', self.on_mark_set)
|
||||
self._do_connect(textbuf, 'mark-deleted', self.on_mark_deleted)
|
||||
|
||||
def do_queue_draw(self, *args):
|
||||
self.queue_draw()
|
||||
|
@ -186,7 +186,7 @@ class ConversationTextview:
|
|||
self.on_textview_button_press_event)
|
||||
self.handlers[id] = self.tv
|
||||
|
||||
id = self.tv.connect("expose-event",
|
||||
id = self.tv.connect('expose-event',
|
||||
self.on_textview_expose_event)
|
||||
self.handlers[id] = self.tv
|
||||
|
||||
|
@ -422,7 +422,8 @@ class ConversationTextview:
|
|||
|
||||
end_iter = buffer.get_end_iter()
|
||||
before_img_iter = end_iter.copy()
|
||||
before_img_iter.backward_char() # one char back (an image also takes one char)
|
||||
# one char back (an image also takes one char)
|
||||
before_img_iter.backward_char()
|
||||
buffer.apply_tag_by_name('focus-out-line', before_img_iter, end_iter)
|
||||
|
||||
self.allow_focus_out_line = False
|
||||
|
@ -451,7 +452,8 @@ class ConversationTextview:
|
|||
# check if the current pointer is still over the line
|
||||
position = self.tv.window.get_origin()
|
||||
self.line_tooltip.show_tooltip(_('Text below this line is what has '
|
||||
'been said since the last time you paid attention to this group chat'), 8, position[1] + pointer[1])
|
||||
'been said since the last time you paid attention to this group chat'),
|
||||
8, position[1] + pointer[1])
|
||||
|
||||
def on_textview_expose_event(self, widget, event):
|
||||
expalloc = event.area
|
||||
|
@ -581,7 +583,8 @@ class ConversationTextview:
|
|||
else:
|
||||
if dict_link.find('%s') == -1:
|
||||
# we must have %s in the url if not WIKTIONARY
|
||||
item = gtk.MenuItem(_('Dictionary URL is missing an "%s" and it is not WIKTIONARY'))
|
||||
item = gtk.MenuItem(_(
|
||||
'Dictionary URL is missing an "%s" and it is not WIKTIONARY'))
|
||||
item.set_property('sensitive', False)
|
||||
else:
|
||||
link = dict_link % self.selected_phrase
|
||||
|
@ -638,7 +641,8 @@ class ConversationTextview:
|
|||
if return_val: # if sth was selected when we right-clicked
|
||||
# get the selected text
|
||||
start_sel, finish_sel = return_val[0], return_val[1]
|
||||
self.selected_phrase = buffer.get_text(start_sel, finish_sel).decode('utf-8')
|
||||
self.selected_phrase = buffer.get_text(start_sel, finish_sel).decode(
|
||||
'utf-8')
|
||||
|
||||
def on_open_link_activate(self, widget, kind, text):
|
||||
helpers.launch_browser_mailer(kind, text)
|
||||
|
@ -672,7 +676,8 @@ class ConversationTextview:
|
|||
if kind == 'url':
|
||||
id = childs[0].connect('activate', self.on_copy_link_activate, text)
|
||||
self.handlers[id] = childs[0]
|
||||
id = childs[1].connect('activate', self.on_open_link_activate, kind, text)
|
||||
id = childs[1].connect('activate', self.on_open_link_activate, kind,
|
||||
text)
|
||||
self.handlers[id] = childs[1]
|
||||
childs[2].hide() # copy mail address
|
||||
childs[3].hide() # open mail composer
|
||||
|
@ -690,7 +695,8 @@ class ConversationTextview:
|
|||
text = text.lower()
|
||||
id = childs[2].connect('activate', self.on_copy_link_activate, text)
|
||||
self.handlers[id] = childs[2]
|
||||
id = childs[3].connect('activate', self.on_open_link_activate, kind, text)
|
||||
id = childs[3].connect('activate', self.on_open_link_activate, kind,
|
||||
text)
|
||||
self.handlers[id] = childs[3]
|
||||
id = childs[5].connect('activate', self.on_start_chat_activate, text)
|
||||
self.handlers[id] = childs[5]
|
||||
|
@ -707,7 +713,8 @@ class ConversationTextview:
|
|||
allow_add = True
|
||||
|
||||
if allow_add:
|
||||
id = childs[7].connect('activate', self.on_add_to_roster_activate, text)
|
||||
id = childs[7].connect('activate', self.on_add_to_roster_activate,
|
||||
text)
|
||||
self.handlers[id] = childs[7]
|
||||
childs[7].show() # show add to roster menuitem
|
||||
else:
|
||||
|
@ -728,7 +735,8 @@ class ConversationTextview:
|
|||
# we get the end of the tag
|
||||
while not end_iter.ends_tag(texttag):
|
||||
end_iter.forward_char()
|
||||
word = self.tv.get_buffer().get_text(begin_iter, end_iter).decode('utf-8')
|
||||
word = self.tv.get_buffer().get_text(begin_iter, end_iter).decode(
|
||||
'utf-8')
|
||||
if event.button == 3: # right click
|
||||
self.make_link_menu(event, kind, word)
|
||||
else:
|
||||
|
@ -785,16 +793,16 @@ class ConversationTextview:
|
|||
exitcode = 0
|
||||
|
||||
# some latex commands are really bad
|
||||
blacklist = ["\\def", "\\let", "\\futurelet",
|
||||
"\\newcommand", "\\renewcomment", "\\else", "\\fi", "\\write",
|
||||
"\\input", "\\include", "\\chardef", "\\catcode", "\\makeatletter",
|
||||
"\\noexpand", "\\toksdef", "\\every", "\\errhelp", "\\errorstopmode",
|
||||
"\\scrollmode", "\\nonstopmode", "\\batchmode", "\\read", "\\csname",
|
||||
"\\newhelp", "\\relax", "\\afterground", "\\afterassignment",
|
||||
"\\expandafter", "\\noexpand", "\\special", "\\command", "\\loop",
|
||||
"\\repeat", "\\toks", "\\output", "\\line", "\\mathcode", "\\name",
|
||||
"\\item", "\\section", "\\mbox", "\\DeclareRobustCommand", "\\[",
|
||||
"\\]"]
|
||||
blacklist = ['\\def', '\\let', '\\futurelet',
|
||||
'\\newcommand', '\\renewcomment', '\\else', '\\fi', '\\write',
|
||||
'\\input', '\\include', '\\chardef', '\\catcode', '\\makeatletter',
|
||||
'\\noexpand', '\\toksdef', '\\every', '\\errhelp', '\\errorstopmode',
|
||||
'\\scrollmode', '\\nonstopmode', '\\batchmode', '\\read', '\\csname',
|
||||
'\\newhelp', '\\relax', '\\afterground', '\\afterassignment',
|
||||
'\\expandafter', '\\noexpand', '\\special', '\\command', '\\loop',
|
||||
'\\repeat', '\\toks', '\\output', '\\line', '\\mathcode', '\\name',
|
||||
'\\item', '\\section', '\\mbox', '\\DeclareRobustCommand', '\\[',
|
||||
'\\]']
|
||||
|
||||
str = str[2:len(str)-2]
|
||||
|
||||
|
@ -806,16 +814,18 @@ class ConversationTextview:
|
|||
|
||||
if exitcode == 0:
|
||||
random.seed()
|
||||
tmpfile = os.path.join(gettempdir(), "gajimtex_" + random.randint(0,
|
||||
tmpfile = os.path.join(gettempdir(), 'gajimtex_' + random.randint(0,
|
||||
100).__str__())
|
||||
|
||||
# build latex string
|
||||
texstr = "\\documentclass[12pt]{article}\\usepackage[dvips]{graphicx}\\usepackage{amsmath}\\usepackage{amssymb}\\pagestyle{empty}"
|
||||
texstr += "\\begin{document}\\begin{large}\\begin{gather*}"
|
||||
texstr = '\\documentclass[12pt]{article}\\usepackage[dvips]{graphicx}'
|
||||
texstr += '\\usepackage{amsmath}\\usepackage{amssymb}'
|
||||
texstr += '\\pagestyle{empty}'
|
||||
texstr += '\\begin{document}\\begin{large}\\begin{gather*}'
|
||||
texstr += str
|
||||
texstr += "\\end{gather*}\\end{large}\\end{document}"
|
||||
texstr += '\\end{gather*}\\end{large}\\end{document}'
|
||||
|
||||
file = open(os.path.join(tmpfile + ".tex"), "w+")
|
||||
file = open(os.path.join(tmpfile + '.tex'), 'w+')
|
||||
file.write(texstr)
|
||||
file.flush()
|
||||
file.close()
|
||||
|
@ -830,11 +840,11 @@ class ConversationTextview:
|
|||
exitcode = p.wait()
|
||||
|
||||
if exitcode == 0:
|
||||
p = Popen(['convert', '-alpha', 'off', tmpfile + '.ps', tmpfile + '.png'],
|
||||
cwd=gettempdir())
|
||||
p = Popen(['convert', '-alpha', 'off', tmpfile + '.ps',
|
||||
tmpfile + '.png'], cwd=gettempdir())
|
||||
exitcode = p.wait()
|
||||
|
||||
extensions = [".tex", ".log", ".aux", ".dvi", ".ps"]
|
||||
extensions = ['.tex', '.log', '.aux', '.dvi', '.ps']
|
||||
for ext in extensions:
|
||||
try:
|
||||
os.remove(tmpfile + ext)
|
||||
|
@ -894,11 +904,13 @@ class ConversationTextview:
|
|||
use_other_tags = False
|
||||
elif special_text.startswith('*'): # it's a bold text
|
||||
tags.append('bold')
|
||||
if special_text[1] == '/' and special_text[-2] == '/' and len(special_text) > 4: # it's also italic
|
||||
if special_text[1] == '/' and special_text[-2] == '/' and
|
||||
len(special_text) > 4: # it's also italic
|
||||
tags.append('italic')
|
||||
if not show_ascii_formatting_chars:
|
||||
special_text = special_text[2:-2] # remove */ /*
|
||||
elif special_text[1] == '_' and special_text[-2] == '_' and len(special_text) > 4: # it's also underlined
|
||||
elif special_text[1] == '_' and special_text[-2] == '_' and
|
||||
len(special_text) > 4: # it's also underlined
|
||||
tags.append('underline')
|
||||
if not show_ascii_formatting_chars:
|
||||
special_text = special_text[2:-2] # remove *_ _*
|
||||
|
@ -907,11 +919,13 @@ class ConversationTextview:
|
|||
special_text = special_text[1:-1] # remove * *
|
||||
elif special_text.startswith('/'): # it's an italic text
|
||||
tags.append('italic')
|
||||
if special_text[1] == '*' and special_text[-2] == '*' and len(special_text) > 4: # it's also bold
|
||||
if special_text[1] == '*' and special_text[-2] == '*' and
|
||||
len(special_text) > 4: # it's also bold
|
||||
tags.append('bold')
|
||||
if not show_ascii_formatting_chars:
|
||||
special_text = special_text[2:-2] # remove /* */
|
||||
elif special_text[1] == '_' and special_text[-2] == '_' and len(special_text) > 4: # it's also underlined
|
||||
elif special_text[1] == '_' and special_text[-2] == '_' and
|
||||
len(special_text) > 4: # it's also underlined
|
||||
tags.append('underline')
|
||||
if not show_ascii_formatting_chars:
|
||||
special_text = special_text[2:-2] # remove /_ _/
|
||||
|
@ -920,11 +934,13 @@ class ConversationTextview:
|
|||
special_text = special_text[1:-1] # remove / /
|
||||
elif special_text.startswith('_'): # it's an underlined text
|
||||
tags.append('underline')
|
||||
if special_text[1] == '*' and special_text[-2] == '*' and len(special_text) > 4: # it's also bold
|
||||
if special_text[1] == '*' and special_text[-2] == '*' and
|
||||
len(special_text) > 4: # it's also bold
|
||||
tags.append('bold')
|
||||
if not show_ascii_formatting_chars:
|
||||
special_text = special_text[2:-2] # remove _* *_
|
||||
elif special_text[1] == '/' and special_text[-2] == '/' and len(special_text) > 4: # it's also italic
|
||||
elif special_text[1] == '/' and special_text[-2] == '/' and
|
||||
len(special_text) > 4: # it's also italic
|
||||
tags.append('italic')
|
||||
if not show_ascii_formatting_chars:
|
||||
special_text = special_text[2:-2] # remove _/ /_
|
||||
|
@ -1122,8 +1138,8 @@ class ConversationTextview:
|
|||
self.tv.display_html(xhtml.encode('utf-8'))
|
||||
return
|
||||
except Exception, e:
|
||||
gajim.log.debug(str("Error processing xhtml")+str(e))
|
||||
gajim.log.debug(str("with |"+xhtml+"|"))
|
||||
gajim.log.debug(str('Error processing xhtml')+str(e))
|
||||
gajim.log.debug(str('with |'+xhtml+'|'))
|
||||
|
||||
buffer = self.tv.get_buffer()
|
||||
# /me is replaced by name if name is given
|
||||
|
@ -1135,4 +1151,3 @@ class ConversationTextview:
|
|||
# add the rest of text located in the index and after
|
||||
end_iter = buffer.get_end_iter()
|
||||
buffer.insert_with_tags_by_name(end_iter, text[index:], *text_tags)
|
||||
|
||||
|
|
Loading…
Reference in New Issue