Philipp Hörist pushed to branch master at gajim / gajim


Commits:
d770b794 by Daniel Brötzmann at 2019-11-14T17:55:42Z
Roster: Fix file drag and drop

- - - - -
edc7971b by Daniel Brötzmann at 2019-11-14T17:55:42Z
Remove usage of NonModalConfirmationDialog

- - - - -
fde22a8a by Daniel Brötzmann at 2019-11-14T17:55:42Z
Dialogs: Remove unused NonModalConfirmationDialog

- - - - -


2 changed files:

- gajim/gtk/dialogs.py
- gajim/roster_window.py


Changes:

=====================================
gajim/gtk/dialogs.py
=====================================
@@ -169,40 +169,6 @@ class ConfirmationDialog(HigDialog):
         self.destroy()
 
 
-class NonModalConfirmationDialog(HigDialog):
-    """
-    HIG compliant non modal confirmation dialog
-    """
-
-    def __init__(self, pritext, sectext='', on_response_ok=None,
-    on_response_cancel=None):
-        self.user_response_ok = on_response_ok
-        self.user_response_cancel = on_response_cancel
-        transient_for = app.app.get_active_window()
-        HigDialog.__init__(self, transient_for, Gtk.MessageType.QUESTION,
-            Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok,
-            self.on_response_cancel)
-        self.set_modal(False)
-
-    def on_response_ok(self, widget):
-        if self.user_response_ok:
-            if isinstance(self.user_response_ok, tuple):
-                self.user_response_ok[0](*self.user_response_ok[1:])
-            else:
-                self.user_response_ok()
-        self.call_cancel_on_destroy = False
-        self.destroy()
-
-    def on_response_cancel(self, widget):
-        if self.user_response_cancel:
-            if isinstance(self.user_response_cancel, tuple):
-                self.user_response_cancel[0](*self.user_response_cancel[1:])
-            else:
-                self.user_response_cancel()
-        self.call_cancel_on_destroy = False
-        self.destroy()
-
-
 class WarningDialog(HigDialog):
     """
     HIG compliant warning dialog


=====================================
gajim/roster_window.py
=====================================
@@ -72,7 +72,6 @@ from gajim.gtk.dialogs import ErrorDialog
 from gajim.gtk.dialogs import InputDialog
 from gajim.gtk.dialogs import WarningDialog
 from gajim.gtk.dialogs import InformationDialog
-from gajim.gtk.dialogs import NonModalConfirmationDialog
 from gajim.gtk.dialogs import InvitationReceivedDialog
 from gajim.gtk.server_info import ServerInfo
 from gajim.gtk.single_message import SingleMessageWindow
@@ -4220,17 +4219,25 @@ class RosterWindow:
                         app.interface.instances['file_transfers'].send_file(
                             account, c, path)
             # Popup dialog to confirm sending
-            prim_text = _('Send file?')
-            sec_text = i18n.ngettext('Do you want to send this file to %s:',
-                'Do you want to send these files to %s:', nb_uri) %\
-                c_dest.get_shown_name()
+            text = i18n.ngettext(
+                'Send this file to %s:\n',
+                'Send these files to %s:\n',
+                nb_uri) % c_dest.get_shown_name()
+
             for uri in uri_splitted:
                 path = helpers.get_file_path_from_dnd_dropped_uri(uri)
-                sec_text += '\n' + os.path.basename(path)
-            dialog = NonModalConfirmationDialog(prim_text, sec_text,
-                on_response_ok=(_on_send_files, account_dest, jid_dest,
-                uri_splitted))
-            dialog.popup()
+                text += '\n' + os.path.basename(path)
+            NewConfirmationDialog(
+                _('File Transfer'),
+                _('File Transfer'),
+                text,
+                [DialogButton.make('Cancel'),
+                 DialogButton.make('Accept',
+                                   text=_('_Send'),
+                                   is_default=True,
+                                   callback=_on_send_files,
+                                   args=(account_dest, jid_dest, 
uri_splitted))],
+                transient_for=self.window).show()
             return
 
         # Check if something is selected
@@ -5541,17 +5548,28 @@ class RosterWindow:
         col.set_visible(False)
         self.tree.set_expander_column(col)
 
-        # signals
-        self.TARGET_TYPE_URI_LIST = 80
-        self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
-            [], Gdk.DragAction.DEFAULT | Gdk.DragAction.MOVE | \
+        # Signals
+        # Drag
+        self.tree.enable_model_drag_source(
+            Gdk.ModifierType.BUTTON1_MASK,
+            [],
+            Gdk.DragAction.DEFAULT |
+            Gdk.DragAction.MOVE |
             Gdk.DragAction.COPY)
         self.tree.drag_source_add_text_targets()
+
+        # Drop
         self.tree.enable_model_drag_dest([], Gdk.DragAction.DEFAULT)
-        dst_targets = Gtk.TargetList.new([])
+        self.TARGET_TYPE_URI_LIST = 80
+        uri_entry = Gtk.TargetEntry.new(
+            'text/uri-list',
+            Gtk.TargetFlags.OTHER_APP,
+            self.TARGET_TYPE_URI_LIST)
+        dst_targets = Gtk.TargetList.new([uri_entry])
         dst_targets.add_text_targets(0)
-        dst_targets.add_uri_targets(self.TARGET_TYPE_URI_LIST)
         self.tree.drag_dest_set_target_list(dst_targets)
+
+        # Connect
         self.tree.connect('drag-begin', self.drag_begin)
         self.tree.connect('drag-end', self.drag_end)
         self.tree.connect('drag-drop', self.drag_drop)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/4fb0c787d28cc639a71d4ab709efb4da6f1bfbec...fde22a8a1b0b2dc51e5d46a5c13a9705ee812fbd

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/4fb0c787d28cc639a71d4ab709efb4da6f1bfbec...fde22a8a1b0b2dc51e5d46a5c13a9705ee812fbd
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to