Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
53
Issues
53
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim-plugins
Commits
f61f8d3d
Commit
f61f8d3d
authored
Dec 09, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[preview] Simplify setting cursor on hover
parent
5ee22a67
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
32 deletions
+27
-32
url_image_preview.py
url_image_preview/url_image_preview.py
+27
-32
No files found.
url_image_preview/url_image_preview.py
View file @
f61f8d3d
...
...
@@ -44,6 +44,7 @@ from url_image_preview.config_dialog import UrlImagePreviewConfigDialog
from
url_image_preview.resize_gif
import
resize_gif
from
gajim.gtk.filechoosers
import
FileSaveDialog
from
gajim.gtk.util
import
get_cursor
log
=
logging
.
getLogger
(
'gajim.plugin_system.preview'
)
...
...
@@ -459,12 +460,6 @@ class Base(object):
if
os
.
path
.
basename
(
filepath
)
.
startswith
(
'location_'
):
filename
=
os
.
path
.
basename
(
filepath
)
event_box
=
Gtk
.
EventBox
()
event_box
.
connect
(
'button-press-event'
,
self
.
on_button_press_event
,
filepath
,
filename
,
url
,
encrypted
)
event_box
.
connect
(
'enter-notify-event'
,
self
.
on_enter_event
)
event_box
.
connect
(
'leave-notify-event'
,
self
.
on_leave_event
)
def
add_to_textview
():
try
:
at_end
=
self
.
_get_at_end
()
...
...
@@ -475,6 +470,26 @@ class Base(object):
anchor
=
buffer_
.
create_child_anchor
(
iter_
)
anchor
.
plaintext
=
url
image
=
self
.
_create_clickable_image
(
pixbuf
,
url
)
self
.
textview
.
tv
.
add_child_at_anchor
(
image
,
anchor
)
buffer_
.
delete
(
iter_
,
buffer_
.
get_iter_at_mark
(
repl_end
))
image
.
connect
(
'button-press-event'
,
self
.
on_button_press_event
,
filepath
,
filename
,
url
,
encrypted
)
image
.
get_window
()
.
set_cursor
(
get_cursor
(
'HAND2'
))
if
at_end
:
self
.
_scroll_to_end
()
except
Exception
as
ex
:
log
.
exception
(
"Exception while loading
%
s:
%
s"
,
url
,
ex
)
return
False
# add to mainloop --> make call threadsafe
GLib
.
idle_add
(
add_to_textview
)
def
_create_clickable_image
(
self
,
pixbuf
,
url
):
if
isinstance
(
pixbuf
,
GdkPixbuf
.
PixbufAnimation
):
image
=
Gtk
.
Image
.
new_from_animation
(
pixbuf
)
else
:
...
...
@@ -486,20 +501,11 @@ class Base(object):
gtkgui_helpers
.
add_css_to_widget
(
image
,
css
)
image
.
set_name
(
'Preview'
)
event_box
=
Gtk
.
EventBox
()
event_box
.
set_tooltip_text
(
url
)
event_box
.
add
(
image
)
event_box
.
show_all
()
self
.
textview
.
tv
.
add_child_at_anchor
(
event_box
,
anchor
)
buffer_
.
delete
(
iter_
,
buffer_
.
get_iter_at_mark
(
repl_end
))
if
at_end
:
self
.
_scroll_to_end
()
except
Exception
as
ex
:
log
.
exception
(
"Exception while loading
%
s:
%
s"
,
url
,
ex
)
return
False
# add to mainloop --> make call threadsafe
GLib
.
idle_add
(
add_to_textview
)
return
event_box
def
_check_mime_size
(
self
,
tuple_arg
,
url
,
weburl
,
repl_start
,
repl_end
,
filepaths
,
...
...
@@ -690,17 +696,6 @@ class Base(object):
except
Exception
:
pass
# Change mouse pointer to HAND2 when
# mouse enter the eventbox with the image
def
on_enter_event
(
self
,
eb
,
event
):
self
.
textview
.
tv
.
get_window
(
Gtk
.
TextWindowType
.
TEXT
)
.
set_cursor
(
Gdk
.
Cursor
(
Gdk
.
CursorType
.
HAND2
))
# Change mouse pointer to default when mouse leaves the eventbox
def
on_leave_event
(
self
,
eb
,
event
):
self
.
textview
.
tv
.
get_window
(
Gtk
.
TextWindowType
.
TEXT
)
.
set_cursor
(
Gdk
.
Cursor
(
Gdk
.
CursorType
.
XTERM
))
def
on_button_press_event
(
self
,
eb
,
event
,
filepath
,
original_filename
,
url
,
encrypted
):
data
=
{
"filepath"
:
filepath
,
...
...
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