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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Peter Shkenev
gajim
Commits
180911e5
Commit
180911e5
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
split print_conversation_line into sevral functions
parent
cf33e04a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/conversation_textview.py
+32
-15
32 additions, 15 deletions
src/conversation_textview.py
with
32 additions
and
15 deletions
src/conversation_textview.py
+
32
−
15
View file @
180911e5
...
...
@@ -405,7 +405,7 @@ def hyperlink_handler(self, texttag, widget, event, iter, kind):
# we launch the correct application
helpers
.
launch_browser_mailer
(
kind
,
word
)
def
detect_and_print_special_text
(
self
,
otext
,
jid
,
other_tags
):
def
detect_and_print_special_text
(
self
,
otext
,
other_tags
):
'''
detects special text (emots & links & formatting)
prints normal text before any special text it founts,
then print special text (that happens many times until
...
...
@@ -581,16 +581,33 @@ def print_conversation_line(self, text, jid, kind, name, tim,
tim_format
=
time
.
strftime
(
'
%H:%M
'
,
tim
)
buffer
.
insert_with_tags_by_name
(
end_iter
,
tim_format
+
'
\n
'
,
'
time_sometimes
'
)
other_text_tag
=
self
.
detect_other_text_tag
(
text
,
kind
)
text_tags
=
other_tags_for_text
[:]
# create a new list
if
other_text_tag
:
text_tags
.
append
(
other_text_tag
)
else
:
# not status nor /me
self
.
print_name
(
name
,
kind
,
other_tags_for_name
)
self
.
print_subject
(
subject
)
self
.
print_real_text
(
text
,
text_tags
,
name
)
# scroll to the end of the textview
if
at_the_end
or
kind
==
'
outgoing
'
:
# we are at the end or we are sending something
# scroll to the end (via idle in case the scrollbar has appeared)
gobject
.
idle_add
(
self
.
scroll_to_end
)
buffer
.
end_user_action
()
def
detect_other_text_tag
(
self
,
text
,
kind
):
if
kind
==
'
status
'
:
text_tags
.
append
(
kind
)
return
kind
elif
text
.
startswith
(
'
/me
'
)
or
text
.
startswith
(
'
/me
\n
'
):
text
=
'
*
'
+
name
+
text
[
3
:]
text_tags
.
append
(
kind
)
return
kind
if
name
and
len
(
text_tags
)
==
len
(
other_tags_for_text
):
# not status nor /me
def
print_name
(
self
,
name
,
kind
,
other_tags_for_name
):
if
name
:
buffer
=
self
.
get_buffer
()
end_iter
=
buffer
.
get_end_iter
()
name_tags
=
other_tags_for_name
[:]
# create a new list
name_tags
.
append
(
kind
)
before_str
=
gajim
.
config
.
get
(
'
before_nickname
'
)
...
...
@@ -598,23 +615,23 @@ def print_conversation_line(self, text, jid, kind, name, tim,
format
=
before_str
+
name
+
after_str
+
'
'
buffer
.
insert_with_tags_by_name
(
end_iter
,
format
,
*
name_tags
)
def
print_subject
(
self
,
subject
):
if
subject
:
# if we have subject, show it too!
subject
=
_
(
'
Subject: %s
\n
'
)
%
subject
buffer
=
self
.
get_buffer
()
end_iter
=
buffer
.
get_end_iter
()
buffer
.
insert
(
end_iter
,
subject
)
self
.
print_empty_line
()
def
print_real_text
(
self
,
text
,
text_tags
=
[],
name
=
None
):
'''
/me is replaces by name if name is given
'''
buffer
=
self
.
get_buffer
()
# detect urls formatting and if the user has it on emoticons
index
=
self
.
detect_and_print_special_text
(
text
,
jid
,
text_tags
)
if
name
and
text
.
startswith
(
'
/me
'
)
or
text
.
startswith
(
'
/me
\n
'
):
text
=
'
*
'
+
name
+
text
[
3
:]
index
=
self
.
detect_and_print_special_text
(
text
,
text_tags
)
# 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
)
# scroll to the end of the textview
if
at_the_end
or
kind
==
'
outgoing
'
:
# we are at the end or we are sending something
# scroll to the end (via idle in case the scrollbar has appeared)
gobject
.
idle_add
(
self
.
scroll_to_end
)
buffer
.
end_user_action
()
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