[epiphany/wip/exalm/gtk4-cleanups-2: 20/24] web-extension-dialog: Stop using gtk_(native)_dialog_run()
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/gtk4-cleanups-2: 20/24] web-extension-dialog: Stop using gtk_(native)_dialog_run()
- Date: Tue, 30 Nov 2021 20:23:48 +0000 (UTC)
commit 9f2399e24d1a5cc4184ffa5177782d052a90e630
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 30 18:36:26 2021 +0500
web-extension-dialog: Stop using gtk_(native)_dialog_run()
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1035>
src/ephy-web-extension-dialog.c | 58 +++++++++++++++++++++++++++--------------
1 file changed, 39 insertions(+), 19 deletions(-)
---
diff --git a/src/ephy-web-extension-dialog.c b/src/ephy-web-extension-dialog.c
index 710952950..b8255f2e5 100644
--- a/src/ephy-web-extension-dialog.c
+++ b/src/ephy-web-extension-dialog.c
@@ -52,6 +52,25 @@ clear_listbox (GtkWidget *listbox)
g_list_free (children);
}
+static void
+on_remove_confirmed (GtkDialog *dialog,
+ GtkResponseType response,
+ gpointer user_data)
+{
+ GtkListBoxRow *row = user_data;
+ EphyWebExtensionDialog *self =
+ EPHY_WEB_EXTENSION_DIALOG (gtk_widget_get_toplevel (GTK_WIDGET (row)));
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (response == GTK_RESPONSE_OK) {
+ EphyWebExtension *web_extension = g_object_get_data (G_OBJECT (row), "web_extension");
+
+ g_assert (web_extension);
+ ephy_web_extension_manager_uninstall (self->web_extension_manager, web_extension);
+ }
+}
+
static void
on_remove_button_clicked (GtkButton *button,
gpointer user_data)
@@ -60,7 +79,6 @@ on_remove_button_clicked (GtkButton *button,
GtkWidget *dialog = NULL;
GtkListBoxRow *row;
GtkWidget *widget;
- gint res;
row = g_object_get_data (G_OBJECT (button), "row");
if (!row)
@@ -81,15 +99,8 @@ on_remove_button_clicked (GtkButton *button,
widget = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "destructive-action");
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK) {
- EphyWebExtension *web_extension = g_object_get_data (G_OBJECT (row), "web_extension");
-
- g_assert (web_extension);
- ephy_web_extension_manager_uninstall (self->web_extension_manager, web_extension);
- }
-
- gtk_widget_destroy (dialog);
+ g_signal_connect (dialog, "response", G_CALLBACK (on_remove_confirmed), row);
+ gtk_window_present (GTK_WINDOW (dialog));
}
static void
@@ -226,6 +237,22 @@ ephy_web_extension_dialog_refresh_listbox (EphyWebExtensionDialog *self)
gtk_stack_set_visible_child_name (self->stack, empty ? "empty" : "list");
}
+static void
+on_add_file_selected (GtkNativeDialog *dialog,
+ GtkResponseType response,
+ gpointer user_data)
+{
+ EphyWebExtensionDialog *self = user_data;
+
+ gtk_native_dialog_destroy (dialog);
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ g_autoptr (GFile) file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+
+ ephy_web_extension_manager_install (self->web_extension_manager, file);
+ }
+}
+
static void
on_add_button_clicked (GtkButton *button,
gpointer user_data)
@@ -233,7 +260,6 @@ on_add_button_clicked (GtkButton *button,
EphyWebExtensionDialog *self = EPHY_WEB_EXTENSION_DIALOG (user_data);
GtkFileChooserNative *dialog = NULL;
GtkFileFilter *filter;
- gint res;
/* Translators: this is the title of a file chooser dialog. */
dialog = gtk_file_chooser_native_new (_("Open File (manifest.json/xpi)"),
@@ -248,14 +274,8 @@ on_add_button_clicked (GtkButton *button,
gtk_file_filter_add_mime_type (GTK_FILE_FILTER (filter), "application/x-xpinstall");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), g_steal_pointer (&filter));
- res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog));
- if (res == GTK_RESPONSE_ACCEPT) {
- g_autoptr (GFile) file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
-
- ephy_web_extension_manager_install (self->web_extension_manager, file);
- }
-
- gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (dialog));
+ g_signal_connect (dialog, "response", G_CALLBACK (on_add_file_selected), self);
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]