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
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
TSRh
gajim
Commits
028bfbb6
Commit
028bfbb6
authored
19 years ago
by
dkirov
Browse files
Options
Downloads
Patches
Plain Diff
reduce chars and lines in helpers
parent
73a4bf97
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/dialogs.py
+10
-12
10 additions, 12 deletions
src/dialogs.py
src/groupchat_window.py
+3
-9
3 additions, 9 deletions
src/groupchat_window.py
src/gtkgui_helpers.py
+28
-1
28 additions, 1 deletion
src/gtkgui_helpers.py
src/tabbed_chat_window.py
+4
-9
4 additions, 9 deletions
src/tabbed_chat_window.py
with
45 additions
and
31 deletions
src/dialogs.py
+
10
−
12
View file @
028bfbb6
...
...
@@ -622,17 +622,12 @@ def get_status_info(self, resource, priority, show, status):
if
status
!=
''
:
if
gtk
.
gtk_version
<
(
2
,
6
,
0
)
or
gtk
.
pygtk_version
<
(
2
,
6
,
0
):
# FIXME: check and do the same if we have more than one \n
status
=
self
.
strip_text
(
status
,
50
)
status
=
gtkgui_helpers
.
reduce_chars_newlines
(
status
,
50
,
1
)
else
:
status
=
gtkgui_helpers
.
reduce_chars_newlines
(
status
,
0
,
1
)
str_status
+=
'
-
'
+
status
return
gtkgui_helpers
.
escape_for_pango_markup
(
str_status
)
# fix "too long status make the tooltip large than the screen" problem
def
strip_text
(
self
,
text
,
max_length
):
text
=
text
.
strip
()
if
len
(
text
)
>
max_length
:
text
=
text
[:
max_length
-
3
]
+
'
...
'
return
text
def
add_status_row
(
self
,
file_path
,
show
,
str_status
):
'''
appends a new row with status icon to the table
'''
self
.
current_row
+=
1
...
...
@@ -706,14 +701,17 @@ def populate(self, data):
iconset
=
'
sun
'
file_path
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
iconsets
'
,
iconset
,
'
16x16
'
)
for
acct
in
accounts
:
mesage
=
gtkgui_helpers
.
escape_for_pango_markup
(
acct
[
'
message
'
])
mesage
=
self
.
strip_text
(
mesage
,
50
)
mes
s
age
=
gtkgui_helpers
.
reduce_chars_newlines
(
acct
[
'
message
'
]
,
50
,
1
)
mes
s
age
=
gtkgui_helpers
.
escape_for_pango_markup
(
mes
s
age
)
self
.
add_status_row
(
file_path
,
acct
[
'
show
'
],
'
<span weight=
"
bold
"
>
'
+
gtkgui_helpers
.
escape_for_pango_markup
(
acct
[
'
name
'
])
+
'
</span>
'
+
'
-
'
+
mesage
)
+
'
-
'
+
mes
s
age
)
elif
len
(
accounts
)
==
1
:
text
=
_
(
'
Gajim - %s
'
)
%
accounts
[
0
][
'
status_line
'
]
message
=
gtkgui_helpers
.
reduce_chars_newlines
(
accounts
[
0
][
'
status_line
'
],
50
,
1
)
message
=
gtkgui_helpers
.
escape_for_pango_markup
(
message
)
text
=
_
(
'
Gajim - %s
'
)
%
message
else
:
text
=
_
(
'
Gajim - %s
'
)
%
helpers
.
get_uf_show
(
'
offline
'
)
self
.
text_lable
.
set_markup
(
text
)
...
...
This diff is collapsed.
Click to expand it.
src/groupchat_window.py
+
3
−
9
View file @
028bfbb6
...
...
@@ -388,15 +388,9 @@ def set_subject(self, room_jid, subject):
full_subject
=
None
if
gtk
.
gtk_version
<
(
2
,
6
,
0
)
or
gtk
.
pygtk_version
<
(
2
,
6
,
0
):
# long subject makes window bigger than the screen
def
_cut_if_long
(
str
):
if
len
(
str
)
>
80
:
str
=
str
[:
77
]
+
'
...
'
return
str
if
len
(
subject
)
>
80
:
subjects
=
map
(
lambda
e
:
_cut_if_long
(
e
),
subject
.
split
(
'
\n
'
))
subject
=
reduce
(
lambda
e
,
e1
:
e
+
'
\n
'
+
e1
,
subjects
)
subject
=
gtkgui_helpers
.
reduce_chars_newlines
(
subject
,
80
,
2
)
else
:
subject
=
gtkgui_helpers
.
reduce_chars_newlines
(
subject
,
0
,
2
)
subject
=
gtkgui_helpers
.
escape_for_pango_markup
(
subject
)
name_label
.
set_markup
(
'
<span weight=
"
heavy
"
size=
"
x-large
"
>%s</span>
\n
%s
'
%
(
room_jid
,
subject
))
...
...
This diff is collapsed.
Click to expand it.
src/gtkgui_helpers.py
+
28
−
1
View file @
028bfbb6
...
...
@@ -28,7 +28,34 @@
_
=
i18n
.
_
from
common
import
gajim
def
reduce_chars_newlines
(
text
,
max_chars
=
0
,
max_lines
=
0
,
widget
=
None
):
'''
Cut the chars after
'
max_chars
'
on each line
and show only the first
'
max_lines
'
. If there is more text
to be shown, display the whole text in tooltip on
'
widget
'
If any of the params is not present(None or 0) the action
on it is not performed
'''
def
_cut_if_long
(
str
):
if
len
(
str
)
>
max_chars
:
str
=
str
[:
max_chars
-
3
]
+
'
...
'
return
str
if
max_lines
==
0
:
lines
=
text
.
split
(
'
\n
'
)
else
:
lines
=
text
.
split
(
'
\n
'
,
max_lines
)[:
max_lines
]
if
max_chars
>
0
:
if
lines
:
lines
=
map
(
lambda
e
:
_cut_if_long
(
e
),
lines
)
if
lines
:
reduced_text
=
reduce
(
lambda
e
,
e1
:
e
+
'
\n
'
+
e1
,
lines
)
else
:
reduced_text
=
''
if
reduced_text
!=
text
and
widget
is
not
None
:
pass
# FIXME show tooltip
return
reduced_text
def
convert_bytes
(
string
):
suffix
=
''
bytes
=
int
(
string
)
...
...
This diff is collapsed.
Click to expand it.
src/tabbed_chat_window.py
+
4
−
9
View file @
028bfbb6
...
...
@@ -133,16 +133,11 @@ def draw_name_banner(self, contact, chatstate = None):
#FIXME: when gtk2.4 is OOOOLD do it via glade2.10+
if
gtk
.
pygtk_version
>=
(
2
,
6
,
0
)
and
gtk
.
gtk_version
>=
(
2
,
6
,
0
):
banner_name_label
.
set_ellipsize
(
pango
.
ELLIPSIZE_END
)
status
=
gtkgui_helpers
.
reduce_chars_newlines
(
status
,
0
,
2
)
#FIXME: remove me when gtk24 is OLD
elif
status
is
not
None
and
len
(
status
)
>
50
:
def
_cut_if_long
(
str
):
if
len
(
str
)
>
50
:
str
=
str
[:
47
]
+
'
...
'
return
str
if
len
(
status
)
>
50
:
status
=
map
(
lambda
e
:
_cut_if_long
(
e
),
status
.
split
(
'
\n
'
))
status
=
reduce
(
lambda
e
,
e1
:
e
+
'
\n
'
+
e1
,
status
)
elif
status
is
not
None
:
status
=
gtkgui_helpers
.
reduce_chars_newlines
(
status
,
50
,
2
)
status
=
gtkgui_helpers
.
escape_for_pango_markup
(
status
)
#FIXME: uncomment me when we support sending messages to specific resource
...
...
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