summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Borges <felipeborges@gnome.org>2023-05-03 12:04:43 +0200
committerFelipe Borges <felipeborges@gnome.org>2023-05-10 10:38:51 +0200
commit2727b883ac5bb04148e0a8e621a05f91e1493561 (patch)
treec0f88a71e1bb09bb004393f24c2c6fa8398388a7
parent1ff54761b2346955eee043b1a4e26f8356d5862d (diff)
downloadgnome-control-center-network-modernize-vpn-import-ui.tar.gz
network: Add ToastOverlay to connection-editornetwork-modernize-vpn-import-ui
-rw-r--r--panels/network/connection-editor/connection-editor.ui52
-rw-r--r--panels/network/connection-editor/net-connection-editor.c50
2 files changed, 46 insertions, 56 deletions
diff --git a/panels/network/connection-editor/connection-editor.ui b/panels/network/connection-editor/connection-editor.ui
index 18031e8ac..2bff4d0ab 100644
--- a/panels/network/connection-editor/connection-editor.ui
+++ b/panels/network/connection-editor/connection-editor.ui
@@ -28,41 +28,45 @@
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
- <object class="GtkStack" id="toplevel_stack">
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <child>
- <object class="GtkSpinner" id="spinner">
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="spinning">True</property>
- </object>
- </child>
- <child>
- <object class="GtkNotebook" id="notebook">
- <property name="show_border">False</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="add_connection_box">
+ <object class="AdwToastOverlay" id="toast_overlay">
+ <property name="child">
+ <object class="GtkStack" id="toplevel_stack">
+ <property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
- <object class="GtkBox">
- <property name="hexpand">True</property>
+ <object class="GtkSpinner" id="spinner">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="spinning">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="notebook">
+ <property name="show_border">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="add_connection_box">
<property name="vexpand">True</property>
- <property name="orientation">vertical</property>
<child>
- <object class="AdwBin" id="add_connection_frame">
+ <object class="GtkBox">
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="width_request">300</property>
- <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="AdwBin" id="add_connection_frame">
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="width_request">300</property>
+ <property name="valign">start</property>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</object>
- </child>
+ </property>
</object>
</child>
</object>
diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c
index 297c6607e..e67da42b2 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -56,6 +56,7 @@ struct _NetConnectionEditor
GtkButton *apply_button;
GtkButton *cancel_button;
GtkNotebook *notebook;
+ AdwToastOverlay *toast_overlay;
GtkStack *toplevel_stack;
NMClient *client;
@@ -335,6 +336,7 @@ net_connection_editor_class_init (NetConnectionEditorClass *class)
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, apply_button);
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, cancel_button);
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, notebook);
+ gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, toast_overlay);
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, toplevel_stack);
gtk_widget_class_bind_template_callback (widget_class, cancel_clicked_cb);
@@ -343,33 +345,6 @@ net_connection_editor_class_init (NetConnectionEditorClass *class)
}
static void
-net_connection_editor_error_dialog (NetConnectionEditor *self,
- const char *primary_text,
- const char *secondary_text)
-{
- GtkWidget *dialog;
- GtkWindow *parent;
-
- if (gtk_widget_is_visible (GTK_WIDGET (self)))
- parent = GTK_WINDOW (self);
- else
- parent = gtk_window_get_transient_for (GTK_WINDOW (self));
-
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s", primary_text);
-
- if (secondary_text) {
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", secondary_text);
- }
-
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static void
net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type)
{
g_autofree gchar *cmdline = NULL;
@@ -384,10 +359,15 @@ net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type)
g_spawn_command_line_async (cmdline, &error);
- if (error)
- net_connection_editor_error_dialog (self,
- _("Unable to open connection editor"),
- error->message);
+ if (error) {
+ AdwToast *toast;
+ g_autofree gchar *message = NULL;
+
+ message = g_strdup_printf (_("Unable to open connection editor: %s"), error->message);
+ toast = adw_toast_new (message);
+
+ adw_toast_overlay_add_toast (self->toast_overlay, toast);
+ }
g_signal_emit (self, signals[DONE], 0, FALSE);
}
@@ -745,7 +725,13 @@ vpn_import_complete (NMConnection *connection, gpointer user_data)
NMSettingConnection *s_con;
if (!connection) {
- /* The import code shows its own error dialogs. */
+ AdwToast *toast;
+ g_autofree gchar *message = NULL;
+
+ message = g_strdup_printf (_("Invalid VPN configuration file"));
+ toast = adw_toast_new (message);
+ adw_toast_overlay_add_toast (self->toast_overlay, toast);
+
g_signal_emit (self, signals[DONE], 0, FALSE);
return;
}