[gnome-boxes] notificationbar: API to display actual auth notification
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] notificationbar: API to display actual auth notification
- Date: Mon, 10 Feb 2014 12:55:03 +0000 (UTC)
commit 72f22bf58b3c57375530cd6752ee984cab3dd784
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Feb 7 14:36:52 2014 +0100
notificationbar: API to display actual auth notification
src/auth-notification.vala | 18 ++++++++++++++++--
src/notificationbar.vala | 21 +++++++++++++--------
src/ovirt-broker.vala | 2 +-
3 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/auth-notification.vala b/src/auth-notification.vala
index eb753da..2022f91 100644
--- a/src/auth-notification.vala
+++ b/src/auth-notification.vala
@@ -8,6 +8,8 @@ private class Boxes.AuthNotification: Gd.Notification {
[GtkChild]
private Gtk.Label title_label;
[GtkChild]
+ private Gtk.Label username_label;
+ [GtkChild]
private Gtk.Entry username_entry;
[GtkChild]
private Gtk.Entry password_entry;
@@ -15,12 +17,22 @@ private class Boxes.AuthNotification: Gd.Notification {
private Gtk.Button auth_button;
private AuthFunc? auth_func;
+ private bool auth_pressed;
public AuthNotification (string auth_string,
owned AuthFunc? auth_func,
- owned Notification.CancelFunc? cancel_func) {
+ owned Notification.CancelFunc? cancel_func,
+ bool need_username) {
show_close_button = false; // FIXME: Seems setting this from .UI file doesn't work
- title_label.label = "<span font-weight=\"bold\">" + _("Sign In to %s").printf(auth_string) +
"</span>";
+ title_label.label = auth_string;
+
+ dismissed.connect (() => {
+ if (!auth_pressed && cancel_func != null)
+ cancel_func ();
+ });
+
+ username_label.visible = need_username;
+ username_entry.visible = need_username;
this.auth_func = (owned) auth_func;
}
@@ -58,6 +70,8 @@ private class Boxes.AuthNotification: Gd.Notification {
private void on_auth_button_clicked () {
if (auth_func != null)
auth_func (username_entry.get_text (), password_entry.get_text ());
+ auth_pressed = true;
+
dismiss ();
}
}
diff --git a/src/notificationbar.vala b/src/notificationbar.vala
index c892905..79a6bfe 100644
--- a/src/notificationbar.vala
+++ b/src/notificationbar.vala
@@ -44,11 +44,12 @@ private class Boxes.Notificationbar: GLib.Object {
return display (message, MessageType.INFO, action_label, (owned) action_func, (owned) ignore_func,
timeout);
}
- public Gd.Notification display_for_authentication (string broker_name,
- owned AuthNotification.AuthFunc? auth_func,
- owned Notification.CancelFunc? cancel_func) {
+ public Gd.Notification display_for_optional_auth (string broker_name,
+ owned AuthNotification.AuthFunc? auth_func,
+ owned Notification.CancelFunc? cancel_func) {
Notification.OKFunc next_auth_step = () => {
- display_for_auth_next (broker_name, (owned) auth_func, (owned) cancel_func);
+ var auth_string = "<span font-weight=\"bold\">" + _("Sign In to %s").printf(broker_name) +
"</span>";
+ display_for_auth (auth_string, (owned) auth_func, (owned) cancel_func);
};
return display_for_action (_("Not connected to %s").printf (broker_name),
_("Sign In"),
@@ -56,10 +57,14 @@ private class Boxes.Notificationbar: GLib.Object {
(owned) cancel_func, -1);
}
- private Gd.Notification display_for_auth_next (string auth_string,
- owned AuthNotification.AuthFunc? auth_func,
- owned Notification.CancelFunc? cancel_func) {
- var notification = new Boxes.AuthNotification (auth_string, (owned) auth_func, (owned) cancel_func);
+ public Gd.Notification display_for_auth (string auth_string,
+ owned AuthNotification.AuthFunc? auth_func,
+ owned Notification.CancelFunc? cancel_func,
+ bool need_username = true) {
+ var notification = new Boxes.AuthNotification (auth_string,
+ (owned) auth_func,
+ (owned) cancel_func,
+ need_username);
active_notifications.prepend (notification);
diff --git a/src/ovirt-broker.vala b/src/ovirt-broker.vala
index d66ac9e..2b5940b 100644
--- a/src/ovirt-broker.vala
+++ b/src/ovirt-broker.vala
@@ -55,7 +55,7 @@ private class Boxes.OvirtBroker : Boxes.Broker {
// finish, otherwise yield add_source() will never return
auth.unpause ();
};
- App.app.notificationbar.display_for_authentication ("oVirt broker", (owned) auth_cb, (owned)
cancel_cb);
+ App.app.notificationbar.display_for_optional_auth ("oVirt broker", (owned) auth_cb, (owned)
cancel_cb);
auth.pause ();
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]