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
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor 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
mesonium
gajim
Commits
1b9ccad1
Commit
1b9ccad1
authored
4 years ago
by
Daniel Brötzmann
Committed by
Philipp Hörist
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Show preview when pasting image from clipboard
parent
cbc7e8be
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
gajim/chat_control_base.py
+3
-2
3 additions, 2 deletions
gajim/chat_control_base.py
gajim/gtk/dialogs.py
+34
-0
34 additions, 0 deletions
gajim/gtk/dialogs.py
gajim/gtk/util.py
+20
-0
20 additions, 0 deletions
gajim/gtk/util.py
with
57 additions
and
2 deletions
gajim/chat_control_base.py
+
3
−
2
View file @
1b9ccad1
...
...
@@ -53,7 +53,7 @@
from
gajim.gtk.dialogs
import
DialogButton
from
gajim.gtk.dialogs
import
NewConfirmationDialog
from
gajim.gtk.dialogs
import
NewConfirmationCheck
Dialog
from
gajim.gtk.dialogs
import
PastePreview
Dialog
from
gajim.gtk.message_input
import
MessageInputTextView
from
gajim.gtk.util
import
at_the_end
from
gajim.gtk.util
import
get_show_in_roster
...
...
@@ -731,12 +731,13 @@ def _on_message_textview_paste_event(self, _texview):
if
not
app
.
settings
.
get
(
'
confirm_paste_image
'
):
self
.
_paste_event_confirmed
(
True
,
image
)
return
NewConfirmationCheck
Dialog
(
PastePreview
Dialog
(
_
(
'
Paste Image
'
),
_
(
'
You are trying to paste an image
'
),
_
(
'
Are you sure you want to paste your
'
'
clipboard
\'
s image into the chat window?
'
),
_
(
'
_Do not ask me again
'
),
image
,
[
DialogButton
.
make
(
'
Cancel
'
),
DialogButton
.
make
(
'
Accept
'
,
text
=
_
(
'
_Paste
'
),
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/dialogs.py
+
34
−
0
View file @
1b9ccad1
...
...
@@ -18,6 +18,7 @@
from
gi.repository
import
GLib
from
gi.repository
import
Gtk
from
gi.repository
import
Gdk
from
gi.repository
import
GdkPixbuf
from
gi.repository
import
Pango
from
gajim.common
import
app
...
...
@@ -26,6 +27,7 @@
from
gajim.common.helpers
import
convert_gio_to_openssl_cert
from
gajim.gtk.util
import
get_builder
from
gajim.gtk.util
import
get_thumbnail_size
class
DialogButton
(
namedtuple
(
'
DialogButton
'
,
(
'
response text callback args
'
...
...
@@ -489,6 +491,38 @@ def _on_response(self, _dialog, response):
super
().
_on_response
(
_dialog
,
response
)
class
PastePreviewDialog
(
NewConfirmationCheckDialog
):
def
__init__
(
self
,
title
,
text
,
sec_text
,
check_text
,
image
,
buttons
,
modal
=
True
,
transient_for
=
None
):
NewConfirmationCheckDialog
.
__init__
(
self
,
title
,
text
,
sec_text
,
check_text
,
buttons
,
transient_for
=
transient_for
,
modal
=
modal
)
preview
=
Gtk
.
Image
()
preview
.
set_halign
(
Gtk
.
Align
.
CENTER
)
preview
.
get_style_context
().
add_class
(
'
preview-image
'
)
size
=
300
image_width
=
image
.
get_width
()
image_height
=
image
.
get_height
()
if
size
>
image_width
and
size
>
image_height
:
preview
.
set_from_pixbuf
(
image
)
else
:
thumb_width
,
thumb_height
=
get_thumbnail_size
(
image
,
size
)
pixbuf_scaled
=
image
.
scale_simple
(
thumb_width
,
thumb_height
,
GdkPixbuf
.
InterpType
.
BILINEAR
)
preview
.
set_from_pixbuf
(
pixbuf_scaled
)
content_area
=
self
.
get_content_area
()
content_area
.
pack_start
(
preview
,
True
,
True
,
0
)
content_area
.
reorder_child
(
preview
,
2
)
class
InputDialog
(
NewConfirmationDialog
):
def
__init__
(
self
,
title
,
text
,
sec_text
,
buttons
,
input_str
=
None
,
transient_for
=
None
,
modal
=
True
):
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/util.py
+
20
−
0
View file @
1b9ccad1
...
...
@@ -23,6 +23,7 @@
import
sys
import
weakref
import
logging
import
math
import
textwrap
import
functools
from
importlib
import
import_module
...
...
@@ -757,6 +758,25 @@ def load_pixbuf(path, size=None):
return
pixbuf
def
get_thumbnail_size
(
pixbuf
,
size
):
# Calculates the new thumbnail size while preserving the aspect ratio
image_width
=
pixbuf
.
get_width
()
image_height
=
pixbuf
.
get_height
()
if
image_width
>
image_height
:
if
image_width
>
size
:
image_height
=
math
.
ceil
(
(
size
/
float
(
image_width
)
*
image_height
))
image_width
=
int
(
size
)
else
:
if
image_height
>
size
:
image_width
=
math
.
ceil
(
(
size
/
float
(
image_height
)
*
image_width
))
image_height
=
int
(
size
)
return
image_width
,
image_height
def
make_href_markup
(
string
):
url_color
=
app
.
css_config
.
get_value
(
'
.gajim-url
'
,
StyleAttr
.
COLOR
)
color
=
convert_rgb_to_hex
(
url_color
)
...
...
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