Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim-plugins
Commits
36948f69
Commit
36948f69
authored
May 10, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[preview] Port to new FileChooser API
parent
561a2e3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
url_image_preview/url_image_preview.py
url_image_preview/url_image_preview.py
+31
-2
No files found.
url_image_preview/url_image_preview.py
View file @
36948f69
...
...
@@ -38,6 +38,12 @@ from url_image_preview.http_functions import get_http_head, get_http_file
from
url_image_preview.config_dialog
import
UrlImagePreviewConfigDialog
from
url_image_preview.resize_gif
import
resize_gif
try
:
from
gajim.filechoosers
import
FileSaveDialog
NEW_FILECHOOSER
=
True
except
ImportError
:
NEW_FILECHOOSER
=
False
log
=
logging
.
getLogger
(
'gajim.plugin_system.preview'
)
PILLOW_AVAILABLE
=
True
...
...
@@ -590,8 +596,12 @@ class Base(object):
id_
=
open_menuitem
.
connect
(
'activate'
,
self
.
on_open_menuitem_activate
,
data
)
self
.
handlers
[
id_
]
=
open_menuitem
id_
=
save_as_menuitem
.
connect
(
'activate'
,
self
.
on_save_as_menuitem_activate
,
data
)
if
NEW_FILECHOOSER
:
id_
=
save_as_menuitem
.
connect
(
'activate'
,
self
.
on_save_as_menuitem_activate_new
,
data
)
else
:
id_
=
save_as_menuitem
.
connect
(
'activate'
,
self
.
on_save_as_menuitem_activate
,
data
)
self
.
handlers
[
id_
]
=
save_as_menuitem
id_
=
copy_link_location_menuitem
.
connect
(
'activate'
,
self
.
on_copy_link_location_menuitem_activate
,
data
)
...
...
@@ -669,6 +679,25 @@ class Base(object):
dialog
.
connect
(
'delete-event'
,
lambda
widget
,
event
:
on_cancel
(
widget
))
def
on_save_as_menuitem_activate_new
(
self
,
menu
,
data
):
filepath
=
data
[
"filepath"
]
original_filename
=
data
[
"original_filename"
]
def
on_ok
(
target_path
):
dirname
=
os
.
path
.
dirname
(
target_path
)
if
not
os
.
access
(
dirname
,
os
.
W_OK
):
dialogs
.
ErrorDialog
(
_
(
'Directory "%s" is not writable'
)
%
dirname
,
_
(
'You do not have permission to '
'create files in this directory.'
))
return
shutil
.
copy
(
filepath
,
target_path
)
FileSaveDialog
(
on_ok
,
path
=
app
.
config
.
get
(
'last_save_dir'
),
file_name
=
original_filename
,
transient_for
=
app
.
app
.
get_active_window
())
def
on_copy_link_location_menuitem_activate
(
self
,
menu
,
data
):
url
=
data
[
"url"
]
clipboard
=
Gtk
.
Clipboard
.
get
(
Gdk
.
SELECTION_CLIPBOARD
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment