Skip to content

Commit 80d48fe

Browse files
authored
Merge pull request #783 from mjakeman/refresh-error-dialog
error-dialog: Refresh style
2 parents 767f97e + 6cb30fa commit 80d48fe

File tree

5 files changed

+93
-111
lines changed

5 files changed

+93
-111
lines changed

src/exm-comment-tile.blp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ using Gtk 4.0;
33
template $ExmCommentTile: Gtk.Widget {
44
Gtk.Box {
55
orientation: vertical;
6+
spacing: 6;
67

78
Gtk.Box {
89
orientation: horizontal;
910

1011
Gtk.Label author {
1112
styles [
12-
"heading"
13+
"heading",
1314
]
1415

15-
xalign: 0;
1616
label: bind template.comment as <$ExmComment>.author;
17+
xalign: 0;
1718
}
1819

1920
Gtk.Label author_badge {
2021
styles [
21-
"author-badge"
22+
"author-badge",
2223
]
2324

2425
label: _("Author");
@@ -35,11 +36,10 @@ template $ExmCommentTile: Gtk.Widget {
3536

3637
Gtk.Label {
3738
styles [
38-
"multiline"
39+
"multiline",
3940
]
4041

4142
label: bind template.comment as <$ExmComment>.comment;
42-
margin-top: 6;
4343
use-markup: true;
4444
wrap: true;
4545
wrap-mode: word_char;
@@ -48,10 +48,9 @@ template $ExmCommentTile: Gtk.Widget {
4848

4949
Gtk.Label date {
5050
styles [
51-
"dim-label"
51+
"dim-label",
5252
]
5353

54-
margin-top: 6;
5554
xalign: 0;
5655
}
5756
}

src/exm-error-dialog.blp

Lines changed: 69 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,84 @@ using Gtk 4.0;
22
using Adw 1;
33

44
template $ExmErrorDialog: Adw.Window {
5-
default-width: 450;
6-
default-height: 450;
5+
default-width: 500;
6+
default-height: 500;
77
title: _("Error Report");
88

99
Adw.ToolbarView {
1010
[top]
1111
Adw.HeaderBar {}
1212

13-
content: Gtk.Box {
14-
styles [
15-
"content"
16-
]
17-
18-
orientation: vertical;
19-
spacing: 12;
20-
21-
Gtk.Image {
22-
icon-name: "dialog-error-symbolic";
23-
icon-size: large;
24-
focusable: true;
25-
26-
accessibility {
27-
labelled-by: title;
28-
described-by: instructions;
13+
content: Adw.ToastOverlay toast_overlay {
14+
child: Adw.PreferencesPage {
15+
Adw.PreferencesGroup {
16+
Gtk.Label {
17+
styles [
18+
"title-4",
19+
]
20+
21+
justify: center;
22+
label: _("An unexpected error occurred in Extension Manager");
23+
selectable: true;
24+
wrap: true;
25+
}
2926
}
30-
}
31-
32-
Gtk.Label title {
33-
styles [
34-
"heading"
35-
]
36-
37-
label: _("An unexpected error occurred in Extension Manager");
38-
wrap: true;
39-
}
40-
41-
Gtk.Label instructions {
42-
xalign: 0;
43-
wrap: true;
44-
}
45-
46-
Gtk.ScrolledWindow {
47-
styles [
48-
"card"
49-
]
50-
51-
overflow: hidden;
52-
vexpand: true;
53-
54-
child: Gtk.TextView text_view {
55-
wrap-mode: word_char;
56-
editable: false;
57-
vexpand: true;
58-
top-margin: 12;
59-
left-margin: 12;
60-
right-margin: 12;
61-
bottom-margin: 12;
62-
monospace: true;
63-
};
64-
}
65-
66-
Gtk.Box {
67-
orientation: horizontal;
68-
homogeneous: true;
69-
halign: center;
70-
spacing: 6;
71-
72-
Gtk.Button copy_button {
73-
can-shrink: true;
74-
label: _("_Copy to Clipboard");
75-
use-underline: true;
76-
clicked => $on_copy_button_clicked();
77-
}
78-
79-
Gtk.Button new_issue_button {
80-
styles [
81-
"suggested-action"
82-
]
8327

84-
can-shrink: true;
85-
label: _("_New Issue");
86-
use-underline: true;
87-
clicked => $on_new_issue_button_clicked() swapped;
28+
Adw.PreferencesGroup instructions {
29+
header-suffix: Gtk.Button copy_button {
30+
styles [
31+
"flat",
32+
]
33+
34+
clicked => $on_copy_button_clicked();
35+
icon-name: "edit-copy-symbolic";
36+
tooltip-text: _("Copy to Clipboard");
37+
valign: center;
38+
};
39+
40+
Gtk.ScrolledWindow {
41+
styles [
42+
"card",
43+
]
44+
45+
overflow: hidden;
46+
vexpand: true;
47+
48+
child: Gtk.TextView text_view {
49+
styles [
50+
"inline",
51+
]
52+
53+
bottom-margin: 12;
54+
editable: false;
55+
left-margin: 12;
56+
monospace: true;
57+
right-margin: 12;
58+
top-margin: 12;
59+
vexpand: true;
60+
wrap-mode: word_char;
61+
62+
accessibility {
63+
labelled-by: instructions;
64+
}
65+
};
66+
}
67+
68+
Gtk.Button new_issue_button {
69+
styles [
70+
"pill",
71+
"suggested-action",
72+
]
73+
74+
can-shrink: true;
75+
clicked => $on_new_issue_button_clicked() swapped;
76+
halign: center;
77+
label: _("_New Issue");
78+
margin-top: 12;
79+
use-underline: true;
80+
}
8881
}
89-
}
82+
};
9083
};
9184
}
9285
}

src/exm-error-dialog.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ struct _ExmErrorDialog
2828
{
2929
AdwWindow parent_instance;
3030

31+
AdwToastOverlay *toast_overlay;
32+
AdwPreferencesGroup *instructions;
3133
char *error_string;
3234
GtkTextView *text_view;
33-
GtkLabel *instructions;
3435
GtkButton *new_issue_button;
3536
};
3637

@@ -108,8 +109,8 @@ exm_error_dialog_set_property (GObject *object,
108109
}
109110

110111
static void
111-
on_copy_button_clicked (GtkButton *button,
112-
ExmErrorDialog *window)
112+
on_copy_button_clicked (GtkButton *button G_GNUC_UNUSED,
113+
ExmErrorDialog *self)
113114
{
114115
GdkDisplay *display;
115116
GdkClipboard *clipboard;
@@ -118,19 +119,19 @@ on_copy_button_clicked (GtkButton *button,
118119
display = gdk_display_get_default ();
119120
clipboard = gdk_display_get_clipboard (display);
120121

121-
gdk_clipboard_set_text (clipboard, window->error_string);
122+
gdk_clipboard_set_text (clipboard, self->error_string);
122123

123124
// Success indicator
124-
gtk_button_set_label (button, _("Copied"));
125-
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
125+
adw_toast_overlay_add_toast (self->toast_overlay, adw_toast_new (_("Copied")));
126126
}
127127

128128
static void
129-
on_new_issue_button_clicked (ExmErrorDialog *window)
129+
on_new_issue_button_clicked (GtkButton *button G_GNUC_UNUSED,
130+
ExmErrorDialog *self)
130131
{
131132
GtkUriLauncher *uri = gtk_uri_launcher_new ("https://github.com/mjakeman/extension-manager/issues");
132133

133-
gtk_uri_launcher_launch (uri, GTK_WINDOW (window), NULL, NULL, NULL);
134+
gtk_uri_launcher_launch (uri, GTK_WINDOW (self), NULL, NULL, NULL);
134135
}
135136

136137
static void
@@ -154,8 +155,9 @@ exm_error_dialog_class_init (ExmErrorDialogClass *klass)
154155

155156
gtk_widget_class_set_template_from_resource (widget_class, g_strdup_printf ("%s/exm-error-dialog.ui", RESOURCE_PATH));
156157

157-
gtk_widget_class_bind_template_child (widget_class, ExmErrorDialog, text_view);
158+
gtk_widget_class_bind_template_child (widget_class, ExmErrorDialog, toast_overlay);
158159
gtk_widget_class_bind_template_child (widget_class, ExmErrorDialog, instructions);
160+
gtk_widget_class_bind_template_child (widget_class, ExmErrorDialog, text_view);
159161
gtk_widget_class_bind_template_child (widget_class, ExmErrorDialog, new_issue_button);
160162

161163
gtk_widget_class_bind_template_callback (widget_class, on_copy_button_clicked);
@@ -167,15 +169,13 @@ exm_error_dialog_init (ExmErrorDialog *self)
167169
{
168170
gtk_widget_init_template (GTK_WIDGET (self));
169171

170-
gtk_label_set_use_markup (self->instructions, TRUE);
171-
172172
#if IS_OFFICIAL
173-
gtk_label_set_text (self->instructions, _("Please open a new issue and attach the following information:"));
173+
adw_preferences_group_set_description (self->instructions, _("Please open a new issue and attach the following information:"));
174174
gtk_widget_set_visible (GTK_WIDGET (self->new_issue_button), TRUE);
175175
#else
176176
// Translators: '%s' = Name of Distributor (e.g. "Packager123")
177177
char *text = g_markup_printf_escaped (_("You are using a third-party build of Extension Manager. Please <span weight=\"bold\">contact the package distributor (%s) first</span> before filing an issue. Be sure to attach the following information:"), PKG_DISTRIBUTOR);
178-
gtk_label_set_markup (self->instructions, text);
178+
adw_preferences_group_set_description (self->instructions, text);
179179
gtk_widget_set_visible (GTK_WIDGET (self->new_issue_button), FALSE);
180180
g_free (text);
181181
#endif

src/exm-upgrade-assistant.blp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ template $ExmUpgradeAssistant: Adw.Dialog {
2323
content: Adw.Clamp {
2424
child: Gtk.Box {
2525
styles [
26-
"detail"
26+
"detail",
2727
]
2828

2929
orientation: vertical;
@@ -50,13 +50,7 @@ template $ExmUpgradeAssistant: Adw.Dialog {
5050
wrap: true;
5151
}
5252

53-
Gtk.ListBox {
54-
styles [
55-
"boxed-list"
56-
]
57-
58-
selection-mode: none;
59-
53+
Adw.PreferencesGroup {
6054
Adw.ComboRow drop_down {
6155
title: "GNOME";
6256
}
@@ -66,7 +60,7 @@ template $ExmUpgradeAssistant: Adw.Dialog {
6660
Gtk.Button run_button {
6761
styles [
6862
"pill",
69-
"suggested-action"
63+
"suggested-action",
7064
]
7165

7266
label: _("_Check Compatibility");
@@ -141,7 +135,7 @@ template $ExmUpgradeAssistant: Adw.Dialog {
141135
Gtk.ListBox user_list_box {
142136
styles [
143137
"boxed-list",
144-
"boxed-list-placeholder"
138+
"boxed-list-placeholder",
145139
]
146140

147141
selection-mode: none;
@@ -168,7 +162,7 @@ template $ExmUpgradeAssistant: Adw.Dialog {
168162
Gtk.ListBox system_list_box {
169163
styles [
170164
"boxed-list",
171-
"boxed-list-placeholder"
165+
"boxed-list-placeholder",
172166
]
173167

174168
selection-mode: none;

src/style.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.content {
2-
margin: 24px 12px;
3-
}
4-
51
.detail {
62
margin: 24px;
73
}

0 commit comments

Comments
 (0)