Пример #1
0
 def check_for_autostart(self, op):
     if op.status == OpStatus.WAITING_PERMISSION:
         if isinstance(op, ReceiveOp) and \
           op.have_space and \
           (not (op.existing and prefs.prevent_overwriting())) and \
           (not prefs.require_permission_for_transfer()):
             op.accept_transfer()
Пример #2
0
    def send_notification(self):
        if prefs.get_show_notifications():
            notification = Gio.Notification.new(_("New incoming files"))

            if prefs.require_permission_for_transfer():
                # John Johnson would like to send you 1 file (foobar.txt)
                # John Johnson would like to send you 5 files
                body =gettext.ngettext(
                    _("%(sender_name)s would like to send you %(file_count)d file (%(file_name)s)."),
                    _("%(sender_name)s would like to send you %(file_count)d files"),self.op.total_count) \
                        % ({
                              "sender_name": self.op.sender_name,
                              "file_count": self.op.total_count,
                              "file_name": self.op.top_dir_basenames[0]
                          })

                notification.set_body(body)
                notification.set_icon(
                    Gio.ThemedIcon(name="org.x.Warpinator-symbolic"))

                # Cinnamon (possibly others) doesn't currently support org.freedesktop.portal.Notification.
                if not config.FLATPAK_BUILD:
                    notification.add_button(
                        _("Accept"), "app.notification-response::accept")
                    notification.add_button(
                        _("Decline"), "app.notification-response::decline")
                    notification.set_default_action(
                        "app.notification-response::focus")

                notification.set_priority(Gio.NotificationPriority.URGENT)

                app = Gio.Application.get_default()
                app.lookup_action("notification-response").connect(
                    "activate", self._notification_response, self.op)

                self.op.connect("status-changed", \
                   lambda op: app.withdraw_notification(op.sender) if self.op.status != OpStatus.WAITING_PERMISSION else None)
            else:
                # John Johnson is sending you 1 file (foobar.txt)
                # John Johnson is sending you 5 files
                body =gettext.ngettext(
                    _("%(sender_name)s is sending you %(file_count)d file (%(file_name)s)."),
                    _("%(sender_name)s is sending you %(file_count)d files"), self.op.total_count) \
                        % ({
                              "sender_name": self.op.sender_name,
                              "file_count": self.op.total_count,
                              "file_name": self.op.top_dir_basenames[0]
                          })

                notification.set_body(body)
                notification.set_icon(
                    Gio.ThemedIcon(name="org.x.Warpinator-symbolic"))

        Gio.Application.get_default().send_notification(
            self.op.sender, notification)
Пример #3
0
    def send_notification(self):
        if prefs.get_show_notifications():
            notification = Gio.Notification.new(_("New incoming files"))

            if prefs.require_permission_for_transfer():
                body =gettext.ngettext(
                    _("%s would like to send you %d file (%s)."),
                    _("%s would like to send you %d files%s"),self.op.total_count) \
                        % (self.op.sender_name,
                           self.op.total_count,
                           self.op.top_dir_basenames[0] if self.op.total_count == 1 else "")

                notification.set_body(body)
                notification.set_icon(
                    Gio.ThemedIcon(name="mail-send-symbolic"))

                notification.add_button(_("Accept"),
                                        "app.notification-response::accept")
                notification.add_button(_("Decline"),
                                        "app.notification-response::decline")

                notification.set_priority(Gio.NotificationPriority.URGENT)

                app = Gio.Application.get_default()
                app.lookup_action("notification-response").connect(
                    "activate", self._notification_response, self.op)

                self.op.connect("status-changed", \
                   lambda op: app.withdraw_notification(op.sender) if self.op.status != OpStatus.WAITING_PERMISSION else None)
            else:
                body =gettext.ngettext(
                    _("%s is sending you %d file (%s)."),
                    _("%s is sending you %d files%s"), self.op.total_count) \
                        % (self.op.sender_name,
                           self.op.total_count,
                           self.op.top_dir_basenames[0] if self.op.total_count == 1 else "")

                notification.set_body(body)
                notification.set_icon(
                    Gio.ThemedIcon(name="mail-send-symbolic"))

        Gio.Application.get_default().send_notification(
            self.op.sender, notification)
Пример #4
0
 def _permission_needed(self):
     return prefs.require_permission_for_transfer()