|
23 | 23 | * https://github.com/solus-project/budgie-desktop
|
24 | 24 | */
|
25 | 25 |
|
26 |
| -public class Ag.PolkitDialog : Granite.MessageDialog { |
| 26 | +public class Ag.PolkitDialog : Gtk.Window { |
27 | 27 | public signal void done ();
|
28 | 28 | public bool was_canceled = false;
|
29 | 29 |
|
@@ -57,8 +57,41 @@ public class Ag.PolkitDialog : Granite.MessageDialog {
|
57 | 57 | cancellable = _cancellable;
|
58 | 58 | cancellable.cancelled.connect (cancel);
|
59 | 59 |
|
60 |
| - primary_text = _("Authentication Required"); |
61 |
| - secondary_text = message; |
| 60 | + var image = new Gtk.Image.from_icon_name ("dialog-password") { |
| 61 | + pixel_size = 48 |
| 62 | + }; |
| 63 | + |
| 64 | + var overlay = new Gtk.Overlay () { |
| 65 | + child = image, |
| 66 | + valign = START |
| 67 | + }; |
| 68 | + |
| 69 | + if (icon_name != "" && Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).has_icon (icon_name)) { |
| 70 | + var badge = new Gtk.Image.from_icon_name (icon_name) { |
| 71 | + pixel_size = 24, |
| 72 | + halign = END, |
| 73 | + valign = END |
| 74 | + }; |
| 75 | + |
| 76 | + overlay.add_overlay (badge); |
| 77 | + } |
| 78 | + |
| 79 | + var primary_label = new Gtk.Label (_("Authentication Required")) { |
| 80 | + max_width_chars = 0, // Wrap, but secondary label sets the width |
| 81 | + selectable = true, |
| 82 | + wrap = true, |
| 83 | + xalign = 0 |
| 84 | + }; |
| 85 | + primary_label.add_css_class (Granite.STYLE_CLASS_TITLE_LABEL); |
| 86 | + |
| 87 | + var secondary_label = new Gtk.Label (message) { |
| 88 | + max_width_chars = 50, |
| 89 | + width_chars = 50, // Prevents a bug where extra height is preserved |
| 90 | + selectable = true, |
| 91 | + use_markup = true, |
| 92 | + wrap = true, |
| 93 | + xalign = 0 |
| 94 | + }; |
62 | 95 |
|
63 | 96 | password_entry = new Gtk.Entry () {
|
64 | 97 | activates_default = true,
|
@@ -100,26 +133,57 @@ public class Ag.PolkitDialog : Granite.MessageDialog {
|
100 | 133 | credentials_box.append (password_entry);
|
101 | 134 | credentials_box.append (feedback_revealer);
|
102 | 135 |
|
103 |
| - image_icon = new ThemedIcon ("dialog-password"); |
104 |
| - |
105 |
| - if (icon_name != "" && Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).has_icon (icon_name)) { |
106 |
| - badge_icon = new ThemedIcon (icon_name); |
107 |
| - } |
108 |
| - |
109 |
| - custom_bin.append (credentials_box); |
| 136 | + var content_area = new Gtk.Grid () { |
| 137 | + column_spacing = 12, |
| 138 | + row_spacing = 6, |
| 139 | + vexpand = true |
| 140 | + }; |
| 141 | + content_area.attach (overlay, 0, 0, 1, 2); |
| 142 | + content_area.attach (primary_label, 1, 0); |
| 143 | + content_area.attach (secondary_label, 1, 1); |
| 144 | + content_area.attach (credentials_box, 1, 3); |
| 145 | + content_area.add_css_class (Granite.STYLE_CLASS_DIALOG_CONTENT_AREA); |
110 | 146 |
|
111 |
| - var cancel_button = (Gtk.Button)add_button (_("Cancel"), Gtk.ResponseType.CANCEL); |
| 147 | + var cancel_button = new Gtk.Button.with_label (_("Cancel")); |
112 | 148 | cancel_button.clicked.connect (() => cancel ());
|
113 | 149 |
|
114 |
| - var authenticate_button = (Gtk.Button)add_button (_("Authenticate"), Gtk.ResponseType.APPLY); |
115 |
| - authenticate_button.receives_default = true; |
| 150 | + var authenticate_button = new Gtk.Button.with_label (_("Authenticate")) { |
| 151 | + receives_default = true |
| 152 | + }; |
116 | 153 | authenticate_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);
|
117 | 154 | authenticate_button.clicked.connect (authenticate);
|
118 | 155 |
|
| 156 | + var button_box = new Gtk.Box (HORIZONTAL, 0) { |
| 157 | + halign = END |
| 158 | + }; |
| 159 | + button_box.append (cancel_button); |
| 160 | + button_box.append (authenticate_button); |
| 161 | + button_box.add_css_class ("dialog-action-area"); |
| 162 | + |
119 | 163 | default_widget = authenticate_button;
|
120 | 164 | focus_widget = password_entry;
|
121 | 165 |
|
122 |
| - close.connect (cancel); |
| 166 | + var vbox = new Gtk.Box (VERTICAL, 0); |
| 167 | + vbox.append (content_area); |
| 168 | + vbox.append (button_box); |
| 169 | + vbox.add_css_class ("dialog-vbox"); |
| 170 | + |
| 171 | + add_css_class ("dialog"); |
| 172 | + add_css_class (Granite.STYLE_CLASS_MESSAGE_DIALOG); |
| 173 | + child = vbox; |
| 174 | + deletable = false; |
| 175 | + resizable = false; |
| 176 | + modal = true; |
| 177 | + |
| 178 | + // We need to hide the title area |
| 179 | + titlebar = new Gtk.Grid () { |
| 180 | + visible = false |
| 181 | + }; |
| 182 | + |
| 183 | + close_request.connect (() => { |
| 184 | + cancel (); |
| 185 | + return Gdk.EVENT_PROPAGATE; |
| 186 | + }); |
123 | 187 |
|
124 | 188 | update_idents ();
|
125 | 189 | select_session ();
|
|
0 commit comments