Пример #1
0
    def _init_playlist_removal_notification(self):
        if self.pl_todelete_notification:
            self.views[3].really_delete = False
            self.pl_todelete_notification.destroy()
            playlist.delete_playlist(self.views[3].pl_todelete)

        self.notification = Gd.Notification()
        self.notification.set_timeout(20)

        grid = Gtk.Grid(valign=Gtk.Align.CENTER, margin_right=8)
        grid.set_column_spacing(8)
        self.notification.add(grid)

        undo_button = Gtk.Button.new_with_mnemonic(_("_Undo"))
        label = _("Playlist %s removed" % (
            self.views[3].current_playlist.get_title()))
        grid.add(Gtk.Label.new(label))
        grid.add(undo_button)

        self.notification.show_all()
        self._overlay.add_overlay(self.notification)
        self.pl_todelete_notification = self.notification

        self.notification.connect("dismissed", self._playlist_removal_notification_dismissed)
        undo_button.connect("clicked", self._undo_deletion)
Пример #2
0
    def __send_notification(self, message):
        notification = Gd.Notification()
        notification.set_timeout(5)
        container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        notification_lbl = Gtk.Label()
        notification_lbl.set_text(message)
        container.pack_start(notification_lbl, False, False, 3)

        notification.add(container)
        notification_parent = self.get_children()[-1]
        notification_parent.add(notification)
        notification_parent.reorder_child(notification, 0)
        self.show_all()
Пример #3
0
 def _init_loading_notification(self):
     self.notification = Gd.Notification()
     self.notification.set_timeout(5)
     grid = Gtk.Grid(valign=Gtk.Align.CENTER, margin_end=8)
     grid.set_column_spacing(8)
     spinner = Gtk.Spinner()
     spinner.start()
     grid.add(spinner)
     label = Gtk.Label.new(_("Loading"))
     grid.add(label)
     self.notification.add(grid)
     self._overlay.add_overlay(self.notification)
     if self.notification_handler:
         GLib.Source.remove(self.notification_handler)
         self.notification_handler = None
     self.notification_handler = GLib.timeout_add(1000, self._show_notification)
Пример #4
0
    def __send_notification(self, message):
        """
            Show a notification using Gd.Notification.
            :param message: the notification message
            :type message: str
        """
        notification = Gd.Notification()
        notification.set_show_close_button(True)
        notification.set_timeout(5)

        notification_lbl = Gtk.Label()
        notification_lbl.set_text(message)

        notification.add(notification_lbl)

        self.add(notification)
        self.reorder_child(notification, 0)
        self.show_all()
Пример #5
0
    def __on_clear_database_clicked(self, *__):
        notification = Gd.Notification()
        notification.set_timeout(5)
        notification.connect("dismissed", self.__clear_database)
        container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        notification_lbl = Gtk.Label()
        notification_lbl.set_text(
            _("The existing accounts will be erased in 5 seconds"))
        container.pack_start(notification_lbl, False, False, 3)

        undo_btn = Gtk.Button()
        undo_btn.set_label(_("Undo"))
        undo_btn.connect("clicked", lambda widget: notification.hide())
        container.pack_end(undo_btn, False, False, 3)

        notification.add(container)
        notification_parent = self.stack.get_child_by_name("behaviour")
        notification_parent.add(notification)
        notification_parent.reorder_child(notification, 0)
        self.show_all()