Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
d770b794
by Daniel Brötzmann at 2019-11-14T17:55:42Z
-
edc7971b
by Daniel Brötzmann at 2019-11-14T17:55:42Z
-
fde22a8a
by Daniel Brötzmann at 2019-11-14T17:55:42Z
2 changed files:
Changes:
| ... | ... | @@ -169,40 +169,6 @@ class ConfirmationDialog(HigDialog): |
| 169 | 169 |
self.destroy()
|
| 170 | 170 |
|
| 171 | 171 |
|
| 172 |
-class NonModalConfirmationDialog(HigDialog):
|
|
| 173 |
- """
|
|
| 174 |
- HIG compliant non modal confirmation dialog
|
|
| 175 |
- """
|
|
| 176 |
- |
|
| 177 |
- def __init__(self, pritext, sectext='', on_response_ok=None,
|
|
| 178 |
- on_response_cancel=None):
|
|
| 179 |
- self.user_response_ok = on_response_ok
|
|
| 180 |
- self.user_response_cancel = on_response_cancel
|
|
| 181 |
- transient_for = app.app.get_active_window()
|
|
| 182 |
- HigDialog.__init__(self, transient_for, Gtk.MessageType.QUESTION,
|
|
| 183 |
- Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok,
|
|
| 184 |
- self.on_response_cancel)
|
|
| 185 |
- self.set_modal(False)
|
|
| 186 |
- |
|
| 187 |
- def on_response_ok(self, widget):
|
|
| 188 |
- if self.user_response_ok:
|
|
| 189 |
- if isinstance(self.user_response_ok, tuple):
|
|
| 190 |
- self.user_response_ok[0](*self.user_response_ok[1:])
|
|
| 191 |
- else:
|
|
| 192 |
- self.user_response_ok()
|
|
| 193 |
- self.call_cancel_on_destroy = False
|
|
| 194 |
- self.destroy()
|
|
| 195 |
- |
|
| 196 |
- def on_response_cancel(self, widget):
|
|
| 197 |
- if self.user_response_cancel:
|
|
| 198 |
- if isinstance(self.user_response_cancel, tuple):
|
|
| 199 |
- self.user_response_cancel[0](*self.user_response_cancel[1:])
|
|
| 200 |
- else:
|
|
| 201 |
- self.user_response_cancel()
|
|
| 202 |
- self.call_cancel_on_destroy = False
|
|
| 203 |
- self.destroy()
|
|
| 204 |
- |
|
| 205 |
- |
|
| 206 | 172 |
class WarningDialog(HigDialog):
|
| 207 | 173 |
"""
|
| 208 | 174 |
HIG compliant warning dialog
|
| ... | ... | @@ -72,7 +72,6 @@ from gajim.gtk.dialogs import ErrorDialog |
| 72 | 72 |
from gajim.gtk.dialogs import InputDialog
|
| 73 | 73 |
from gajim.gtk.dialogs import WarningDialog
|
| 74 | 74 |
from gajim.gtk.dialogs import InformationDialog
|
| 75 |
-from gajim.gtk.dialogs import NonModalConfirmationDialog
|
|
| 76 | 75 |
from gajim.gtk.dialogs import InvitationReceivedDialog
|
| 77 | 76 |
from gajim.gtk.server_info import ServerInfo
|
| 78 | 77 |
from gajim.gtk.single_message import SingleMessageWindow
|
| ... | ... | @@ -4220,17 +4219,25 @@ class RosterWindow: |
| 4220 | 4219 |
app.interface.instances['file_transfers'].send_file(
|
| 4221 | 4220 |
account, c, path)
|
| 4222 | 4221 |
# Popup dialog to confirm sending
|
| 4223 |
- prim_text = _('Send file?')
|
|
| 4224 |
- sec_text = i18n.ngettext('Do you want to send this file to %s:',
|
|
| 4225 |
- 'Do you want to send these files to %s:', nb_uri) %\
|
|
| 4226 |
- c_dest.get_shown_name()
|
|
| 4222 |
+ text = i18n.ngettext(
|
|
| 4223 |
+ 'Send this file to %s:\n',
|
|
| 4224 |
+ 'Send these files to %s:\n',
|
|
| 4225 |
+ nb_uri) % c_dest.get_shown_name()
|
|
| 4226 |
+ |
|
| 4227 | 4227 |
for uri in uri_splitted:
|
| 4228 | 4228 |
path = helpers.get_file_path_from_dnd_dropped_uri(uri)
|
| 4229 |
- sec_text += '\n' + os.path.basename(path)
|
|
| 4230 |
- dialog = NonModalConfirmationDialog(prim_text, sec_text,
|
|
| 4231 |
- on_response_ok=(_on_send_files, account_dest, jid_dest,
|
|
| 4232 |
- uri_splitted))
|
|
| 4233 |
- dialog.popup()
|
|
| 4229 |
+ text += '\n' + os.path.basename(path)
|
|
| 4230 |
+ NewConfirmationDialog(
|
|
| 4231 |
+ _('File Transfer'),
|
|
| 4232 |
+ _('File Transfer'),
|
|
| 4233 |
+ text,
|
|
| 4234 |
+ [DialogButton.make('Cancel'),
|
|
| 4235 |
+ DialogButton.make('Accept',
|
|
| 4236 |
+ text=_('_Send'),
|
|
| 4237 |
+ is_default=True,
|
|
| 4238 |
+ callback=_on_send_files,
|
|
| 4239 |
+ args=(account_dest, jid_dest, uri_splitted))],
|
|
| 4240 |
+ transient_for=self.window).show()
|
|
| 4234 | 4241 |
return
|
| 4235 | 4242 |
|
| 4236 | 4243 |
# Check if something is selected
|
| ... | ... | @@ -5541,17 +5548,28 @@ class RosterWindow: |
| 5541 | 5548 |
col.set_visible(False)
|
| 5542 | 5549 |
self.tree.set_expander_column(col)
|
| 5543 | 5550 |
|
| 5544 |
- # signals
|
|
| 5545 |
- self.TARGET_TYPE_URI_LIST = 80
|
|
| 5546 |
- self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
|
| 5547 |
- [], Gdk.DragAction.DEFAULT | Gdk.DragAction.MOVE | \
|
|
| 5551 |
+ # Signals
|
|
| 5552 |
+ # Drag
|
|
| 5553 |
+ self.tree.enable_model_drag_source(
|
|
| 5554 |
+ Gdk.ModifierType.BUTTON1_MASK,
|
|
| 5555 |
+ [],
|
|
| 5556 |
+ Gdk.DragAction.DEFAULT |
|
|
| 5557 |
+ Gdk.DragAction.MOVE |
|
|
| 5548 | 5558 |
Gdk.DragAction.COPY)
|
| 5549 | 5559 |
self.tree.drag_source_add_text_targets()
|
| 5560 |
+ |
|
| 5561 |
+ # Drop
|
|
| 5550 | 5562 |
self.tree.enable_model_drag_dest([], Gdk.DragAction.DEFAULT)
|
| 5551 |
- dst_targets = Gtk.TargetList.new([])
|
|
| 5563 |
+ self.TARGET_TYPE_URI_LIST = 80
|
|
| 5564 |
+ uri_entry = Gtk.TargetEntry.new(
|
|
| 5565 |
+ 'text/uri-list',
|
|
| 5566 |
+ Gtk.TargetFlags.OTHER_APP,
|
|
| 5567 |
+ self.TARGET_TYPE_URI_LIST)
|
|
| 5568 |
+ dst_targets = Gtk.TargetList.new([uri_entry])
|
|
| 5552 | 5569 |
dst_targets.add_text_targets(0)
|
| 5553 |
- dst_targets.add_uri_targets(self.TARGET_TYPE_URI_LIST)
|
|
| 5554 | 5570 |
self.tree.drag_dest_set_target_list(dst_targets)
|
| 5571 |
+ |
|
| 5572 |
+ # Connect
|
|
| 5555 | 5573 |
self.tree.connect('drag-begin', self.drag_begin)
|
| 5556 | 5574 |
self.tree.connect('drag-end', self.drag_end)
|
| 5557 | 5575 |
self.tree.connect('drag-drop', self.drag_drop)
|