create app notification widget

Bug #1582883 reported by Danielle Foré
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Granite
Fix Committed
Wishlist
Artem Anufrij

Bug Description

Not sure if we want to copy Android and call this "Granite.Widgets.Toast". Just committed an example to Switchboard's Online Accounts plug. It basically looks like this:

                var close_button = new Gtk.Button.from_icon_name ("close-symbolic", Gtk.IconSize.MENU);
                close_button.get_style_context ().add_class ("close-button");
                close_button.clicked.connect (() => {
                    // Response here
                    app_notification.reveal_child = false;
                });

                notification_label = new Gtk.Label ("");
                var button = new Gtk.Button.with_label (_("Button"));
                button.clicked.connect (() => {
                    // Response here
                    app_notification.reveal_child = false;
                });

                var notification_box = new Gtk.Grid ();
                notification_box.column_spacing = 12;
                notification_box.add (close_button);
                notification_box.add (notification_label);
                notification_box.add (button);

                var notification_frame = new Gtk.Frame (null);
                notification_frame.get_style_context ().add_class ("app-notification");
                notification_frame.add (notification_box);

                app_notification = new Gtk.Revealer ();
                app_notification.margin = 3;
                app_notification.halign = Gtk.Align.CENTER;
                app_notification.valign = Gtk.Align.START;
                app_notification.add (notification_frame);

Then you stick that in an overlay and show/hide when necessary. Things to consider:

* Do we want to hard code the availability of a single button? I'm pretty sure we don't want to be able to pack arbitrary widgets. Is there a case for two buttons or should we recommend that developers use an alert in that case?

* Should these time out? On Android toasts time out

Related branches

Changed in granite:
importance: Undecided → Wishlist
Revision history for this message
Cassidy James Blaede (cassidyjames) wrote :

One action and a dismiss makes sense to me. And a default timeout also makes sense.

Revision history for this message
Zisu Andrei (matzipan) wrote :

" Is there a case for two buttons or should we recommend that developers use an alert in that case?"

I'd say the quicker we use it, the quicker we find out.

The timeout should be something along the lines of 5-10 seconds after the user has performed the action which triggered the toast.

Changed in granite:
status: New → Confirmed
Changed in granite:
assignee: nobody → Artem Anufrij (artem-anufrij)
status: Confirmed → In Progress
Changed in granite:
milestone: none → loki+1-beta1
RabbitBot (rabbitbot-a)
Changed in granite:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.