Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
22626591
Commit
22626591
authored
5 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
HtmlTextView: Fix pylint errors
parent
7156ecfb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/gtk/htmltextview.py
+47
-38
47 additions, 38 deletions
gajim/gtk/htmltextview.py
with
47 additions
and
38 deletions
gajim/gtk/htmltextview.py
+
47
−
38
View file @
22626591
...
...
@@ -175,14 +175,15 @@
BLOCK_PRES
=
set
((
'
hr
'
,
))
#not in xhtml-im
BLOCK_STRUCT
=
set
((
'
div
'
,
'
p
'
,
))
BLOCK_HACKS
=
set
((
'
table
'
,
'
tr
'
))
# at the very least, they will start line ;)
BLOCK
=
BLOCK_HEAD
.
union
(
BLOCK_PHRASAL
).
union
(
BLOCK_STRUCT
).
union
(
BLOCK_PRES
).
union
(
BLOCK_HACKS
)
BLOCK
=
BLOCK_HEAD
|
BLOCK_PHRASAL
|
BLOCK_STRUCT
|
BLOCK_PRES
|
BLOCK_HACKS
INLINE_PHRASAL
=
set
(
'
abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var
'
.
split
(
'
,
'
))
INLINE_PRES
=
set
(
'
b, i, u, tt
'
.
split
(
'
,
'
))
#not in xhtml-im
INLINE_STRUCT
=
set
(
'
br, span
'
.
split
(
'
,
'
))
INLINE
=
INLINE_PHRASAL
.
union
(
INLINE_PRES
).
union
(
INLINE_STRUCT
)
INLINE_PHRASAL
=
set
([
'
abbr
'
,
'
acronym
'
,
'
cite
'
,
'
code
'
,
'
dfn
'
,
'
em
'
,
'
kbd
'
,
'
q
'
,
'
samp
'
,
'
strong
'
,
'
var
'
])
INLINE_PRES
=
set
([
'
b
'
,
'
i
'
,
'
u
'
,
'
tt
'
])
#not in xhtml-im
INLINE_STRUCT
=
set
([
'
br
'
,
'
span
'
])
INLINE
=
INLINE_PHRASAL
|
INLINE_PRES
|
INLINE_STRUCT
LIST_ELEMS
=
set
(
'
dl, ol,
ul
'
.
split
(
'
,
'
)
)
LIST_ELEMS
=
set
(
[
'
dl
'
,
'
ol
'
,
'
ul
'
]
)
for
_name
in
BLOCK_HEAD
:
_num
=
int
(
_name
[
1
])
...
...
@@ -200,8 +201,9 @@ def _parse_css_color(color):
return
rgba
def
style_iter
(
style
):
return
([
x
.
strip
()
for
x
in
item
.
split
(
'
:
'
,
1
)]
for
item
in
style
.
split
(
'
;
'
)
\
if
len
(
item
.
strip
()))
for
item
in
style
.
split
(
'
;
'
):
if
item
.
strip
():
yield
[
x
.
strip
()
for
x
in
item
.
split
(
'
:
'
,
1
)]
class
HtmlHandler
(
xml
.
sax
.
handler
.
ContentHandler
):
...
...
@@ -499,7 +501,9 @@ def _create_url(self, href, title, type_, id_):
tag
.
href
=
href
tag
.
type_
=
type_
# to be used by the URL handler
tag
.
connect
(
'
event
'
,
self
.
textview
.
hyperlink_handler
,
'
url
'
)
tag
.
set_property
(
'
foreground
'
,
app
.
css_config
.
get_value
(
'
.gajim-url
'
,
StyleAttr
.
COLOR
))
tag
.
set_property
(
'
foreground
'
,
app
.
css_config
.
get_value
(
'
.gajim-url
'
,
StyleAttr
.
COLOR
))
tag
.
set_property
(
'
underline
'
,
Pango
.
Underline
.
SINGLE
)
tag
.
is_anchor
=
True
if
title
:
...
...
@@ -541,7 +545,9 @@ def _process_img(self, attrs, loaded=None):
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Loading
'
)
pixbuf
=
load_icon
(
'
image-missing
'
,
self
.
textview
,
pixbuf
=
True
)
pixbuf
=
load_icon
(
'
image-missing
'
,
self
.
textview
,
pixbuf
=
True
)
if
mem
:
# Caveat: GdkPixbuf is known not to be safe to load
# images from network... this program is now potentially
...
...
@@ -624,7 +630,7 @@ def set_size(_pixbuf, width_, height_, dims):
def
_begin_span
(
self
,
style
,
tag
=
None
,
id_
=
None
):
if
style
is
None
:
self
.
styles
.
append
(
tag
)
return
None
return
if
tag
is
None
:
if
id_
:
tag
=
self
.
textbuf
.
create_tag
(
id_
)
...
...
@@ -911,34 +917,37 @@ def destroy(menu, _pspec):
menu
.
connect
(
'
notify::visible
'
,
destroy
)
menu
.
popup_at_pointer
()
def
hyperlink_handler
(
self
,
texttag
,
_widget
,
event
,
iter_
,
kind
):
if
event
.
type
==
Gdk
.
EventType
.
BUTTON_PRESS
:
begin_iter
=
iter_
.
copy
()
# we get the beginning of the tag
while
not
begin_iter
.
starts_tag
(
texttag
):
begin_iter
.
backward_char
()
end_iter
=
iter_
.
copy
()
# we get the end of the tag
while
not
end_iter
.
ends_tag
(
texttag
):
end_iter
.
forward_char
()
# Detect XHTML-IM link
word
=
getattr
(
texttag
,
'
href
'
,
None
)
if
not
word
:
word
=
self
.
get_buffer
().
get_text
(
begin_iter
,
end_iter
,
True
)
uri
=
parse_uri
(
word
)
if
event
.
button
.
button
==
3
:
# right click
self
.
show_context_menu
(
uri
)
return
True
self
.
plugin_modified
=
False
app
.
plugin_manager
.
extension_point
(
'
hyperlink_handler
'
,
uri
,
self
,
self
.
get_toplevel
())
if
self
.
plugin_modified
:
return
def
hyperlink_handler
(
self
,
texttag
,
_widget
,
event
,
iter_
,
_kind
):
if
event
.
type
!=
Gdk
.
EventType
.
BUTTON_PRESS
:
return
Gdk
.
EVENT_PROPAGATE
begin_iter
=
iter_
.
copy
()
# we get the beginning of the tag
while
not
begin_iter
.
starts_tag
(
texttag
):
begin_iter
.
backward_char
()
end_iter
=
iter_
.
copy
()
# we get the end of the tag
while
not
end_iter
.
ends_tag
(
texttag
):
end_iter
.
forward_char
()
# Detect XHTML-IM link
word
=
getattr
(
texttag
,
'
href
'
,
None
)
if
not
word
:
word
=
self
.
get_buffer
().
get_text
(
begin_iter
,
end_iter
,
True
)
uri
=
parse_uri
(
word
)
if
event
.
button
.
button
==
3
:
# right click
self
.
show_context_menu
(
uri
)
return
Gdk
.
EVENT_STOP
self
.
plugin_modified
=
False
app
.
plugin_manager
.
extension_point
(
'
hyperlink_handler
'
,
uri
,
self
,
self
.
get_toplevel
())
if
self
.
plugin_modified
:
return
Gdk
.
EVENT_STOP
open_uri
(
uri
,
account
=
self
.
account
)
open_uri
(
uri
,
account
=
self
.
account
)
return
Gdk
.
EVENT_STOP
def
display_html
(
self
,
html
,
textview
,
conv_textview
,
iter_
=
None
):
buffer_
=
self
.
get_buffer
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment