[gtranslator: 6/9] context: Use response signal on dialog
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator: 6/9] context: Use response signal on dialog
- Date: Fri, 18 Mar 2022 09:37:22 +0000 (UTC)
commit 930f0edeed9b6adf81c85890f59a085e59c6393e
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Sun Mar 6 16:42:28 2022 +0100
context: Use response signal on dialog
src/gtr-context.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/src/gtr-context.c b/src/gtr-context.c
index 22785dfe..b0fb96f5 100644
--- a/src/gtr-context.c
+++ b/src/gtr-context.c
@@ -66,6 +66,24 @@ static guint signals[LAST_SIGNAL] = { 0 };
static void buffer_end_user_action (GtkTextBuffer *buffer, GtrContextPanel *panel);
static void reload_values (GtrContextPanel *panel);
+typedef struct {
+ GtrContextPanel *panel;
+ GtkTextBuffer *text_buffer;
+} DialogData;
+
+static void
+dialog_response_cb (GtkDialog *dialog, guint response, gpointer user_data)
+{
+ DialogData *dd = user_data;
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ buffer_end_user_action (dd->text_buffer, dd->panel);
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ reload_values (dd->panel);
+ g_free (dd);
+}
+
static void
setup_notes_edition (GtrContextPanel *panel)
{
@@ -75,7 +93,7 @@ setup_notes_edition (GtrContextPanel *panel)
GtkBox *dialog_area;
GtkWidget *text_view;
GtkTextBuffer *text_buffer = gtk_text_buffer_new (NULL);;
- gint result;
+ DialogData *dd;
priv = gtr_context_panel_get_instance_private (panel);
@@ -116,20 +134,12 @@ setup_notes_edition (GtrContextPanel *panel)
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
- gtk_widget_show_all (dialog);
- result = gtk_dialog_run (GTK_DIALOG (dialog));
+ dd = g_new0 (DialogData, 1);
+ dd->panel = panel;
+ dd->text_buffer = text_buffer;
- switch (result)
- {
- case GTK_RESPONSE_ACCEPT:
- buffer_end_user_action (text_buffer, panel);
- break;
- default:
- break;
- }
-
- gtk_widget_destroy (dialog);
- reload_values(panel);
+ g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), dd);
+ gtk_widget_show_all (dialog);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]