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
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
eta
gajim
Commits
c8077781
Commit
c8077781
authored
20 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
print_conversation is now mainly in chat.py, so groupchat has url detection and emoticons support
parent
75fb6ac1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/gtkgui/chat.py
+99
-37
99 additions, 37 deletions
plugins/gtkgui/chat.py
plugins/gtkgui/groupchat_window.py
+9
-40
9 additions, 40 deletions
plugins/gtkgui/groupchat_window.py
plugins/gtkgui/tabbed_chat_window.py
+5
-60
5 additions, 60 deletions
plugins/gtkgui/tabbed_chat_window.py
with
113 additions
and
137 deletions
plugins/gtkgui/chat.py
+
99
−
37
View file @
c8077781
...
...
@@ -74,7 +74,7 @@ class Chat:
del
self
.
print_time_timeout_id
[
jid
]
else
:
for
jid
in
self
.
xmls
:
if
not
self
.
print_time_timeout_id
.
has_key
(
p
jid
):
if
not
self
.
print_time_timeout_id
.
has_key
(
jid
):
self
.
print_time_timeout
(
jid
)
self
.
print_time_timeout_id
[
jid
]
=
gobject
.
timeout_add
(
300000
,
\
self
.
print_time_timeout
,
jid
)
...
...
@@ -423,7 +423,16 @@ class Chat:
#we launch the correct application
self
.
plugin
.
launch_browser_mailer
(
kind
,
word
)
def
detect_and_print_special_text
(
self
,
otext
,
jid
,
other_tag
,
print_all_special
):
def
print_with_tag_list
(
self
,
buffer
,
text
,
iter
,
tag_list
):
begin_mark
=
buffer
.
create_mark
(
'
begin_tag
'
,
iter
,
True
)
buffer
.
insert
(
iter
,
text
)
begin_tagged
=
buffer
.
get_iter_at_mark
(
begin_mark
)
for
tag
in
tag_list
:
buffer
.
apply_tag_by_name
(
tag
,
begin_tagged
,
iter
)
buffer
.
delete_mark
(
begin_mark
)
def
detect_and_print_special_text
(
self
,
otext
,
jid
,
other_tags
,
\
print_all_special
):
conversation_textview
=
self
.
xmls
[
jid
].
get_widget
(
'
conversation_textview
'
)
conversation_buffer
=
conversation_textview
.
get_buffer
()
...
...
@@ -443,83 +452,136 @@ class Chat:
text_before_special_text
=
otext
[
index
:
start
]
end_iter
=
conversation_buffer
.
get_end_iter
()
if
print_all_special
:
conversation_buffer
.
insert_with_tags_by_name
(
end_it
er
,
\
text_before_special_text
,
other_tag
)
self
.
print_with_tag_list
(
conversation_buff
er
,
\
text_before_special_text
,
end_iter
,
other_tag
s
)
else
:
conversation_buffer
.
insert
(
end_iter
,
text_before_special_text
)
if
not
print_all_special
:
other_tag
=
''
other_tag
s
=
[]
index
=
end
# update index
#now print it
self
.
print_special_text
(
special_text
,
other_tag
,
conversation_buffer
)
self
.
print_special_text
(
special_text
,
other_tag
s
,
conversation_buffer
)
return
index
,
other_tag
return
index
def
print_special_text
(
self
,
special_text
,
other_tag
,
conversation_buffer
):
tag2
=
None
def
print_special_text
(
self
,
special_text
,
other_tags
,
conversation_buffer
):
# make it CAPS (emoticons keys are all CAPS)
tags
=
[]
use_other_tags
=
True
possible_emot_ascii_caps
=
special_text
.
upper
()
if
possible_emot_ascii_caps
in
self
.
plugin
.
emoticons
.
keys
():
#it's an emoticon
tag
=
None
emot_ascii
=
possible_emot_ascii_caps
end_iter
=
conversation_buffer
.
get_end_iter
()
conversation_buffer
.
insert_pixbuf
(
end_iter
,
\
self
.
plugin
.
emoticons
[
emot_ascii
])
elif
special_text
.
startswith
(
'
mailto:
'
):
#it's a mail
tag
=
'
mail
'
tags
.
append
(
'
mail
'
)
use_other_tags
=
False
elif
self
.
plugin
.
sth_at_sth_dot_sth_re
.
match
(
special_text
):
#it's a mail
tag
=
'
mail
'
tags
.
append
(
'
mail
'
)
use_other_tags
=
False
elif
special_text
.
startswith
(
'
*
'
):
# it's a bold text
tag
=
'
bold
'
tag
s
.
append
(
'
bold
'
)
if
special_text
[
1
]
==
'
/
'
:
# it's also italic
tag
2
=
'
italic
'
tag
s
.
append
(
'
italic
'
)
special_text
=
special_text
[
2
:
-
2
]
# remove */ /*
elif
special_text
[
1
]
==
'
_
'
:
# it's also underlined
tag
2
=
'
underline
'
tag
s
.
append
(
'
underline
'
)
special_text
=
special_text
[
2
:
-
2
]
# remove *_ _*
else
:
special_text
=
special_text
[
1
:
-
1
]
# remove * *
elif
special_text
.
startswith
(
'
/
'
):
# it's an italic text
tag
=
'
italic
'
tag
s
.
append
(
'
italic
'
)
if
special_text
[
1
]
==
'
*
'
:
# it's also bold
tag
2
=
'
bold
'
tag
s
.
append
(
'
bold
'
)
special_text
=
special_text
[
2
:
-
2
]
# remove /* */
elif
special_text
[
1
]
==
'
_
'
:
# it's also underlined
tag
2
=
'
underline
'
tag
s
.
append
(
'
underline
'
)
special_text
=
special_text
[
2
:
-
2
]
# remove /_ _/
else
:
special_text
=
special_text
[
1
:
-
1
]
# remove / /
elif
special_text
.
startswith
(
'
_
'
):
# it's an underlined text
tag
=
'
underline
'
tag
s
.
append
(
'
underline
'
)
if
special_text
[
1
]
==
'
*
'
:
# it's also bold
tag
2
=
'
bold
'
tag
s
.
append
(
'
bold
'
)
special_text
=
special_text
[
2
:
-
2
]
# remove _* *_
elif
special_text
[
1
]
==
'
/
'
:
# it's also italic
tag
2
=
'
italic
'
tag
s
.
append
(
'
italic
'
)
special_text
=
special_text
[
2
:
-
2
]
# remove _/ /_
else
:
special_text
=
special_text
[
1
:
-
1
]
# remove _ _
else
:
#it's a url
tag
=
'
url
'
tags
.
append
(
'
url
'
)
use_other_tags
=
False
if
len
(
tags
)
>
0
:
end_iter
=
conversation_buffer
.
get_end_iter
()
all_tags
=
tags
[:]
if
use_other_tags
:
all_tags
+=
other_tags
self
.
print_with_tag_list
(
conversation_buffer
,
special_text
,
end_iter
,
\
all_tags
)
def
print_conversation_line
(
self
,
text
,
jid
,
kind
,
name
,
tim
,
\
other_tags_for_name
=
[]):
conversation_textview
=
self
.
xmls
[
jid
].
get_widget
(
'
conversation_textview
'
)
conversation_buffer
=
conversation_textview
.
get_buffer
()
print_all_special
=
False
if
not
text
:
text
=
''
end_iter
=
conversation_buffer
.
get_end_iter
()
if
tag
is
not
None
:
if
tag
in
[
'
bold
'
,
'
italic
'
,
'
underline
'
]
and
other_tag
:
if
tag2
is
not
None
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
\
special_text
,
other_tag
,
tag
,
tag2
)
else
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
\
special_text
,
other_tag
,
tag
)
else
:
if
tag2
is
not
None
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
\
special_text
,
tag
,
tag2
)
else
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
\
special_text
,
tag
)
if
self
.
plugin
.
config
[
'
print_time
'
]
==
'
always
'
:
if
not
tim
:
tim
=
time
.
localtime
()
tim_format
=
time
.
strftime
(
"
[%H:%M:%S]
"
,
tim
)
conversation_buffer
.
insert
(
end_iter
,
tim_format
+
'
'
)
if
kind
==
'
status
'
:
print_all_special
=
True
elif
text
.
startswith
(
'
/me
'
):
text
=
name
+
text
[
3
:]
print_all_special
=
True
if
kind
==
'
incoming
'
:
self
.
last_message_time
[
jid
]
=
time
.
time
()
tags
=
other_tags_for_name
[:]
#create a new list
tags
.
append
(
kind
)
if
name
and
not
print_all_special
:
self
.
print_with_tag_list
(
conversation_buffer
,
'
<
'
+
name
+
'
>
'
,
\
end_iter
,
tags
)
text
+=
'
\n
'
# detect urls formatting and if the user has it on emoticons
index
=
self
.
detect_and_print_special_text
(
text
,
jid
,
\
tags
,
print_all_special
)
# add the rest of text located in the index and after
end_iter
=
conversation_buffer
.
get_end_iter
()
if
print_all_special
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
text
[
index
:],
\
kind
)
else
:
conversation_buffer
.
insert
(
end_iter
,
text
[
index
:])
#scroll to the end of the textview
end_iter
=
conversation_buffer
.
get_end_iter
()
end_rect
=
conversation_textview
.
get_iter_location
(
end_iter
)
visible_rect
=
conversation_textview
.
get_visible_rect
()
end
=
False
if
end_rect
.
y
<=
(
visible_rect
.
y
+
visible_rect
.
height
)
or
\
(
contact
and
contact
!=
'
status
'
):
#we are at the end or we are sending something
end
=
True
conversation_textview
.
scroll_to_mark
(
conversation_buffer
.
\
get_mark
(
'
end
'
),
0.1
,
0
,
0
,
0
)
if
((
jid
!=
self
.
get_active_jid
())
or
(
not
self
.
window
.
is_active
())
or
\
(
not
end
))
and
kind
==
'
incoming
'
:
self
.
nb_unread
[
jid
]
+=
1
self
.
redraw_tab
(
jid
)
self
.
show_title
()
This diff is collapsed.
Click to expand it.
plugins/gtkgui/groupchat_window.py
+
9
−
40
View file @
c8077781
...
...
@@ -23,7 +23,6 @@ import gtk.glade
import
pango
import
gobject
import
time
import
sre
#usefull later #(nk) really? :)
from
dialogs
import
*
from
chat
import
*
...
...
@@ -248,51 +247,21 @@ class Groupchat_window(Chat):
"""
Print a line in the conversation :
if contact is set : it
'
s a message from someone
if contact is not set : it
'
s a message from the server
"""
conversation_textview
=
self
.
xmls
[
room_jid
].
\
get_widget
(
'
conversation_textview
'
)
conversation_buffer
=
conversation_textview
.
get_buffer
()
if
not
text
:
text
=
''
end_iter
=
conversation_buffer
.
get_end_iter
()
if
self
.
plugin
.
config
[
'
print_time
'
]
==
'
always
'
:
if
not
tim
:
tim
=
time
.
localtime
()
tim_format
=
time
.
strftime
(
'
[%H:%M:%S]
'
,
tim
)
conversation_buffer
.
insert
(
end_iter
,
tim_format
+
'
'
)
otext
=
''
ttext
=
''
other_tags_for_name
=
[]
if
contact
:
if
contact
==
self
.
nicks
[
room_jid
]:
tag
=
'
outgoing
'
kind
=
'
outgoing
'
else
:
tag
=
'
incoming
'
self
.
last_message_time
[
room_jid
]
=
time
.
time
()
if
text
.
startswith
(
'
/me
'
):
ttext
=
contact
+
text
[
3
:]
+
'
\n
'
else
:
ttext
=
'
<
'
+
contact
+
'
>
'
otext
=
text
+
'
\n
'
kind
=
'
incoming
'
else
:
tag
=
'
status
'
ttext
=
text
+
'
\n
'
kind
=
'
status
'
if
tag
==
'
incoming
'
and
self
.
nicks
[
room_jid
].
lower
()
in
\
if
kind
==
'
incoming
'
and
self
.
nicks
[
room_jid
].
lower
()
in
\
text
.
lower
().
split
():
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
ttext
,
tag
,
\
'
bold
'
)
else
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
ttext
,
tag
)
#TODO: emoticons, url grabber
conversation_buffer
.
insert
(
end_iter
,
otext
)
#scroll to the end of the textview
conversation_textview
.
scroll_to_mark
(
conversation_buffer
.
get_mark
(
'
end
'
),
\
0.1
,
0
,
0
,
0
)
if
not
self
.
window
.
is_active
()
and
contact
!=
''
:
self
.
nb_unread
[
room_jid
]
+=
1
self
.
redraw_tab
(
room_jid
)
self
.
show_title
()
other_tags_for_name
.
append
(
'
bold
'
)
Chat
.
print_conversation_line
(
self
,
text
,
room_jid
,
kind
,
contact
,
tim
,
\
other_tags_for_name
)
def
kick
(
self
,
widget
,
room_jid
,
nick
):
"""
kick a user
"""
...
...
This diff is collapsed.
Click to expand it.
plugins/gtkgui/tabbed_chat_window.py
+
5
−
60
View file @
c8077781
...
...
@@ -23,7 +23,6 @@ import gtk.glade
import
pango
import
gobject
import
time
import
sre
from
dialogs
import
*
from
history_window
import
*
...
...
@@ -199,69 +198,15 @@ class Tabbed_chat_window(Chat):
if contact is set to another value : it
'
s an outgoing message
if contact is not set : it
'
s an incomming message
"""
user
=
self
.
users
[
jid
]
conversation_textview
=
self
.
xmls
[
jid
].
get_widget
(
'
conversation_textview
'
)
conversation_buffer
=
conversation_textview
.
get_buffer
()
print_all_special
=
False
if
not
text
:
text
=
''
end_iter
=
conversation_buffer
.
get_end_iter
()
if
self
.
plugin
.
config
[
'
print_time
'
]
==
'
always
'
:
if
not
tim
:
tim
=
time
.
localtime
()
tim_format
=
time
.
strftime
(
"
[%H:%M:%S]
"
,
tim
)
conversation_buffer
.
insert
(
end_iter
,
tim_format
+
'
'
)
otext
=
''
ttext
=
''
if
contact
==
'
status
'
:
tag
=
'
status
'
ttext
=
text
+
'
\n
'
print_all_special
=
True
kind
=
'
status
'
name
=
''
else
:
if
contact
:
tag
=
'
outgoing
'
kind
=
'
outgoing
'
name
=
self
.
plugin
.
nicks
[
self
.
account
]
else
:
tag
=
'
incoming
'
kind
=
'
incoming
'
name
=
user
.
name
self
.
last_message_time
[
jid
]
=
time
.
time
()
if
text
.
startswith
(
'
/me
'
):
ttext
=
name
+
text
[
3
:]
+
'
\n
'
print_all_special
=
True
else
:
ttext
=
'
<
'
+
name
+
'
>
'
otext
=
text
+
'
\n
'
#if it's a status we print special words
if
not
print_all_special
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
ttext
,
tag
)
else
:
otext
=
ttext
# detect urls formatting and if the user has it on emoticons
index
,
other_tag
=
self
.
detect_and_print_special_text
(
otext
,
jid
,
tag
,
print_all_special
)
# add the rest of text located in the index and after
end_iter
=
conversation_buffer
.
get_end_iter
()
if
print_all_special
:
conversation_buffer
.
insert_with_tags_by_name
(
end_iter
,
\
otext
[
index
:],
other_tag
)
else
:
conversation_buffer
.
insert
(
end_iter
,
otext
[
index
:])
#scroll to the end of the textview
end_iter
=
conversation_buffer
.
get_end_iter
()
end_rect
=
conversation_textview
.
get_iter_location
(
end_iter
)
visible_rect
=
conversation_textview
.
get_visible_rect
()
end
=
False
if
end_rect
.
y
<=
(
visible_rect
.
y
+
visible_rect
.
height
)
or
\
(
contact
and
contact
!=
'
status
'
):
#we are at the end or we are sending something
end
=
True
conversation_textview
.
scroll_to_mark
(
conversation_buffer
.
\
get_mark
(
'
end
'
),
0.1
,
0
,
0
,
0
)
if
((
jid
!=
self
.
get_active_jid
())
or
(
not
self
.
window
.
is_active
())
or
\
(
not
end
))
and
contact
==
''
:
self
.
nb_unread
[
jid
]
+=
1
self
.
redraw_tab
(
jid
)
self
.
show_title
()
Chat
.
print_conversation_line
(
self
,
text
,
jid
,
kind
,
name
,
tim
)
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