create app notification widget

Bug #1582883 reported by Daniel Fore on 2016-05-17
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

Daniel Fore (danrabbit) on 2016-05-17
Changed in granite:
importance: Undecided → Wishlist

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

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
Daniel Fore (danrabbit) on 2016-09-28
Changed in granite:
milestone: none → loki+1-beta1
RabbitBot (rabbitbot-a) on 2016-09-28
Changed in granite:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers