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
Weblate
gajim
Commits
92983123
Commit
92983123
authored
16 years ago
by
Brendan Taylor
Browse files
Options
Downloads
Patches
Plain Diff
detect latex support at startup
parent
02659358
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
src/common/gajim.py
+59
-0
59 additions, 0 deletions
src/common/gajim.py
src/conversation_textview.py
+2
-1
2 additions, 1 deletion
src/conversation_textview.py
src/features_window.py
+1
-54
1 addition, 54 deletions
src/features_window.py
with
62 additions
and
55 deletions
src/common/gajim.py
+
59
−
0
View file @
92983123
...
...
@@ -176,6 +176,65 @@ else:
if
system
(
'
gpg -h >/dev/null 2>&1
'
):
HAVE_GPG
=
False
import
os
import
random
from
tempfile
import
gettempdir
from
subprocess
import
Popen
def
check_for_latex_support
():
'''
check is latex is available and if it can create a picture.
'''
exitcode
=
0
random
.
seed
()
tmpfile
=
os
.
path
.
join
(
gettempdir
(),
"
gajimtex_
"
+
\
random
.
randint
(
0
,
100
).
__str__
())
# build latex string
texstr
=
'
\\
documentclass[12pt]{article}
\\
usepackage[dvips]{graphicx}
'
texstr
+=
'
\\
usepackage{amsmath}
\\
usepackage{amssymb}
\\
pagestyle{empty}
'
texstr
+=
'
\\
begin{document}
\\
begin{large}
\\
begin{gather*}test
'
texstr
+=
'
\\
end{gather*}
\\
end{large}
\\
end{document}
'
file_
=
open
(
os
.
path
.
join
(
tmpfile
+
"
.tex
"
),
"
w+
"
)
file_
.
write
(
texstr
)
file_
.
flush
()
file_
.
close
()
try
:
if
os
.
name
==
'
nt
'
:
# CREATE_NO_WINDOW
p
=
Popen
([
'
latex
'
,
'
--interaction=nonstopmode
'
,
tmpfile
+
'
.tex
'
],
creationflags
=
0x08000000
,
cwd
=
gettempdir
())
else
:
p
=
Popen
([
'
latex
'
,
'
--interaction=nonstopmode
'
,
tmpfile
+
'
.tex
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
except
Exception
:
exitcode
=
1
if
exitcode
==
0
:
try
:
if
os
.
name
==
'
nt
'
:
# CREATE_NO_WINDOW
p
=
Popen
([
'
dvipng
'
,
'
-bg
'
,
'
white
'
,
'
-T
'
,
'
tight
'
,
tmpfile
+
'
.dvi
'
,
'
-o
'
,
tmpfile
+
'
.png
'
],
creationflags
=
0x08000000
,
cwd
=
gettempdir
())
else
:
p
=
Popen
([
'
dvipng
'
,
'
-bg
'
,
'
white
'
,
'
-T
'
,
'
tight
'
,
tmpfile
+
'
.dvi
'
,
'
-o
'
,
tmpfile
+
'
.png
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
except
Exception
:
exitcode
=
1
extensions
=
[
'
.tex
'
,
'
.log
'
,
'
.aux
'
,
'
.dvi
'
,
'
.png
'
]
for
ext
in
extensions
:
try
:
os
.
remove
(
tmpfile
+
ext
)
except
Exception
:
pass
if
exitcode
==
0
:
return
True
return
False
HAVE_LATEX
=
check_for_latex_support
()
gajim_identity
=
{
'
type
'
:
'
pc
'
,
'
category
'
:
'
client
'
,
'
name
'
:
'
Gajim
'
}
gajim_common_features
=
[
xmpp
.
NS_BYTESTREAM
,
xmpp
.
NS_SI
,
xmpp
.
NS_FILE
,
xmpp
.
NS_MUC
,
xmpp
.
NS_MUC_USER
,
xmpp
.
NS_MUC_ADMIN
,
xmpp
.
NS_MUC_OWNER
,
...
...
This diff is collapsed.
Click to expand it.
src/conversation_textview.py
+
2
−
1
View file @
92983123
...
...
@@ -1141,7 +1141,8 @@ class ConversationTextview:
else
:
if
not
show_ascii_formatting_chars
:
special_text
=
special_text
[
1
:
-
1
]
# remove _ _
elif
special_text
.
startswith
(
'
$$
'
)
and
special_text
.
endswith
(
'
$$
'
):
elif
gajim
.
HAVE_LATEX
and
special_text
.
startswith
(
'
$$
'
)
and
\
special_text
.
endswith
(
'
$$
'
):
try
:
imagepath
=
self
.
latex_to_image
(
special_text
)
except
LatexError
,
e
:
...
...
This diff is collapsed.
Click to expand it.
src/features_window.py
+
1
−
54
View file @
92983123
...
...
@@ -31,10 +31,6 @@ import gtkgui_helpers
from
common
import
gajim
from
common
import
helpers
import
random
from
tempfile
import
gettempdir
from
subprocess
import
Popen
class
FeaturesWindow
:
'''
Class for features window
'''
...
...
@@ -255,56 +251,7 @@ class FeaturesWindow:
return
sleepy
.
SUPPORTED
def
latex_available
(
self
):
'''
check is latex is available and if it can create a picture.
'''
exitcode
=
0
random
.
seed
()
tmpfile
=
os
.
path
.
join
(
gettempdir
(),
"
gajimtex_
"
+
\
random
.
randint
(
0
,
100
).
__str__
())
# build latex string
texstr
=
'
\\
documentclass[12pt]{article}
\\
usepackage[dvips]{graphicx}
'
texstr
+=
'
\\
usepackage{amsmath}
\\
usepackage{amssymb}
\\
pagestyle{empty}
'
texstr
+=
'
\\
begin{document}
\\
begin{large}
\\
begin{gather*}test
'
texstr
+=
'
\\
end{gather*}
\\
end{large}
\\
end{document}
'
file_
=
open
(
os
.
path
.
join
(
tmpfile
+
"
.tex
"
),
"
w+
"
)
file_
.
write
(
texstr
)
file_
.
flush
()
file_
.
close
()
try
:
if
os
.
name
==
'
nt
'
:
# CREATE_NO_WINDOW
p
=
Popen
([
'
latex
'
,
'
--interaction=nonstopmode
'
,
tmpfile
+
'
.tex
'
],
creationflags
=
0x08000000
,
cwd
=
gettempdir
())
else
:
p
=
Popen
([
'
latex
'
,
'
--interaction=nonstopmode
'
,
tmpfile
+
'
.tex
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
except
Exception
:
exitcode
=
1
if
exitcode
==
0
:
try
:
if
os
.
name
==
'
nt
'
:
# CREATE_NO_WINDOW
p
=
Popen
([
'
dvipng
'
,
'
-bg
'
,
'
white
'
,
'
-T
'
,
'
tight
'
,
tmpfile
+
'
.dvi
'
,
'
-o
'
,
tmpfile
+
'
.png
'
],
creationflags
=
0x08000000
,
cwd
=
gettempdir
())
else
:
p
=
Popen
([
'
dvipng
'
,
'
-bg
'
,
'
white
'
,
'
-T
'
,
'
tight
'
,
tmpfile
+
'
.dvi
'
,
'
-o
'
,
tmpfile
+
'
.png
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
except
Exception
:
exitcode
=
1
extensions
=
[
'
.tex
'
,
'
.log
'
,
'
.aux
'
,
'
.dvi
'
,
'
.png
'
]
for
ext
in
extensions
:
try
:
os
.
remove
(
tmpfile
+
ext
)
except
Exception
:
pass
if
exitcode
==
0
:
return
True
return
False
return
gajim
.
HAVE_LATEX
def
pycrypto_available
(
self
):
return
gajim
.
HAVE_PYCRYPTO
...
...
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