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
c7a22fc1
Commit
c7a22fc1
authored
3 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Add Links to MessageLabel
parent
3990d013
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/common/styling.py
+12
-5
12 additions, 5 deletions
gajim/common/styling.py
gajim/gtk/conversation/plain_widget.py
+9
-3
9 additions, 3 deletions
gajim/gtk/conversation/plain_widget.py
with
21 additions
and
8 deletions
gajim/common/styling.py
+
12
−
5
View file @
c7a22fc1
...
...
@@ -3,6 +3,8 @@
from
dataclasses
import
dataclass
from
dataclasses
import
field
from
gi.repository
import
GLib
PRE
=
'
`
'
STRONG
=
'
*
'
STRIKE
=
'
~
'
...
...
@@ -41,23 +43,28 @@ class StyleObject:
text
:
str
class
URIMarkup
:
def
get_markup_string
(
self
):
return
f
'
<a href=
"
{
self
.
text
}
"
>
{
self
.
text
}
</a>
'
@dataclass
class
Uri
(
StyleObject
):
class
Uri
(
StyleObject
,
URIMarkup
):
name
:
str
=
field
(
default
=
'
uri
'
,
init
=
False
)
@dataclass
class
Address
(
StyleObject
):
class
Address
(
StyleObject
,
URIMarkup
):
name
:
str
=
field
(
default
=
'
address
'
,
init
=
False
)
@dataclass
class
XMPPAddress
(
StyleObject
):
class
XMPPAddress
(
StyleObject
,
URIMarkup
):
name
:
str
=
field
(
default
=
'
xmppadr
'
,
init
=
False
)
@dataclass
class
MailAddress
(
StyleObject
):
class
MailAddress
(
StyleObject
,
URIMarkup
):
name
:
str
=
field
(
default
=
'
mailadr
'
,
init
=
False
)
...
...
@@ -135,7 +142,7 @@ def process(text, nested=False):
blocks
=
_parse_blocks
(
text
,
nested
)
for
block
in
blocks
:
if
isinstance
(
block
,
PlainBlock
):
offset
=
block
.
start
offset
=
0
for
line
in
block
.
text
.
splitlines
(
keepends
=
True
):
block
.
spans
+=
_parse_line
(
line
,
offset
)
block
.
uris
+=
_parse_uris
(
line
,
offset
)
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/conversation/plain_widget.py
+
9
−
3
View file @
c7a22fc1
...
...
@@ -18,6 +18,7 @@
from
gi.repository
import
Gtk
from
gi.repository
import
Pango
from
gi.repository
import
Gdk
from
gi.repository
import
GLib
from
gajim.common
import
app
from
gajim.common
import
i18n
...
...
@@ -42,8 +43,8 @@ def __init__(self, account):
self
.
_account
=
account
self
.
_text_widget
=
MessageTextview
(
self
.
_account
)
#
self._text_widget = MessageLabel(self._account)
#
self._text_widget = MessageTextview(self._account)
self
.
_text_widget
=
MessageLabel
(
self
.
_account
)
self
.
add
(
self
.
_text_widget
)
def
add_content
(
self
,
block
):
...
...
@@ -58,16 +59,21 @@ def __init__(self, account):
self
.
set_line_wrap
(
True
)
self
.
set_xalign
(
0
)
self
.
set_line_wrap_mode
(
Pango
.
WrapMode
.
WORD_CHAR
)
self
.
set_track_visited_links
(
False
)
self
.
_account
=
account
def
print_text_with_styling
(
self
,
block
):
text
=
GLib
.
markup_escape_text
(
block
.
text
.
strip
())
for
uri
in
block
.
uris
:
text
=
text
.
replace
(
uri
.
text
,
uri
.
get_markup_string
())
attr_list
=
Pango
.
AttrList
()
for
span
in
block
.
spans
:
attr
=
make_pango_attribute
(
span
.
name
,
span
.
start
,
span
.
end
)
attr_list
.
insert
(
attr
)
self
.
set_
text
(
block
.
text
.
strip
()
)
self
.
set_
markup
(
text
)
self
.
set_attributes
(
attr_list
)
...
...
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