Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
78
Issues
78
List
Boards
Labels
Milestones
Merge Requests
31
Merge Requests
31
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
32 deletions
+27
-32
url_image_preview/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,24 +470,17 @@ class Base(object):
anchor
=
buffer_
.
create_child_anchor
(
iter_
)
anchor
.
plaintext
=
url
if
isinstance
(
pixbuf
,
GdkPixbuf
.
PixbufAnimation
):
image
=
Gtk
.
Image
.
new_from_animation
(
pixbuf
)
else
:
image
=
Gtk
.
Image
.
new_from_pixbuf
(
pixbuf
)
css
=
'''#Preview {
box-shadow: 0px 0px 3px 0px alpha(@theme_text_color, 0.2);
margin: 5px 10px 5px 10px; }'''
gtkgui_helpers
.
add_css_to_widget
(
image
,
css
)
image
.
set_name
(
'Preview'
)
event_box
.
set_tooltip_text
(
url
)
event_box
.
add
(
image
)
event_box
.
show_all
()
self
.
textview
.
tv
.
add_child_at_anchor
(
event_box
,
anchor
)
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
:
...
...
@@ -501,6 +489,24 @@ class Base(object):
# 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
:
image
=
Gtk
.
Image
.
new_from_pixbuf
(
pixbuf
)
css
=
'''#Preview {
box-shadow: 0px 0px 3px 0px alpha(@theme_text_color, 0.2);
margin: 5px 10px 5px 10px; }'''
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
()
return
event_box
def
_check_mime_size
(
self
,
tuple_arg
,
url
,
weburl
,
repl_start
,
repl_end
,
filepaths
,
key
,
iv
,
encrypted
):
...
...
@@ -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