|
|
a60cd7 |
From 8e31dd5a50c0236ea5853892d05e3376f061ee23 Mon Sep 17 00:00:00 2001
|
|
|
a60cd7 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
a60cd7 |
Date: Thu, 9 Jan 2014 21:18:37 +0100
|
|
|
a60cd7 |
Subject: [ABRT PATCH 12/12] configui: show 'Close' button in the dialog
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Closes rhbz#1050167
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
a60cd7 |
---
|
|
|
a60cd7 |
src/configuration-gui/main.c | 10 ++++++-
|
|
|
a60cd7 |
src/configuration-gui/system-config-abrt.c | 45 +++++++++++++++++++++++++++++-
|
|
|
a60cd7 |
2 files changed, 53 insertions(+), 2 deletions(-)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
diff --git a/src/configuration-gui/main.c b/src/configuration-gui/main.c
|
|
|
a60cd7 |
index b07b852..bd37ef9 100644
|
|
|
a60cd7 |
--- a/src/configuration-gui/main.c
|
|
|
a60cd7 |
+++ b/src/configuration-gui/main.c
|
|
|
a60cd7 |
@@ -22,6 +22,12 @@
|
|
|
a60cd7 |
|
|
|
a60cd7 |
#define APP_NAME "System Config ABRT"
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+static void
|
|
|
a60cd7 |
+system_config_abrt_window_close_cb(gpointer user_data)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ gtk_widget_destroy(GTK_WIDGET(user_data));
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
static GtkWidget *
|
|
|
a60cd7 |
system_config_abrt_window_new(GApplication *app)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
@@ -29,7 +35,9 @@ system_config_abrt_window_new(GApplication *app)
|
|
|
a60cd7 |
gtk_window_set_default_size(GTK_WINDOW(wnd), 500, 300);
|
|
|
a60cd7 |
gtk_window_set_title(GTK_WINDOW(wnd), _("Problem Reporting Configuration"));
|
|
|
a60cd7 |
|
|
|
a60cd7 |
- GtkWidget *sca = system_config_abrt_widget_new();
|
|
|
a60cd7 |
+ GtkWidget *sca = system_config_abrt_widget_new_with_close_button(
|
|
|
a60cd7 |
+ system_config_abrt_window_close_cb, wnd);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
gtk_container_add(GTK_CONTAINER(wnd), sca);
|
|
|
a60cd7 |
|
|
|
a60cd7 |
return wnd;
|
|
|
a60cd7 |
diff --git a/src/configuration-gui/system-config-abrt.c b/src/configuration-gui/system-config-abrt.c
|
|
|
a60cd7 |
index 4638dd6..b15a5ef 100644
|
|
|
a60cd7 |
--- a/src/configuration-gui/system-config-abrt.c
|
|
|
a60cd7 |
+++ b/src/configuration-gui/system-config-abrt.c
|
|
|
a60cd7 |
@@ -24,6 +24,15 @@
|
|
|
a60cd7 |
#define CLOSE_BUTTON_DATA_NAME_USER_DATA "my-close-user-data"
|
|
|
a60cd7 |
|
|
|
a60cd7 |
static void
|
|
|
a60cd7 |
+system_config_abrt_close_btn_cb(GtkButton *button, gpointer user_data)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ system_config_abrt_widget_close_callback callback = g_object_get_data(G_OBJECT(button), CLOSE_BUTTON_DATA_NAME_CALLBACK);
|
|
|
a60cd7 |
+ gpointer callback_user_data = g_object_get_data(G_OBJECT(button), CLOSE_BUTTON_DATA_NAME_USER_DATA);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ callback(callback_user_data);
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+static void
|
|
|
a60cd7 |
system_config_abrt_defaults_cb(GtkButton *button, gpointer user_data)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
AbrtConfigWidget *config = ABRT_CONFIG_WIDGET(user_data);
|
|
|
a60cd7 |
@@ -32,6 +41,12 @@ system_config_abrt_defaults_cb(GtkButton *button, gpointer user_data)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
GtkWidget *system_config_abrt_widget_new(void)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
+ return system_config_abrt_widget_new_with_close_button(/*no close button*/NULL,
|
|
|
a60cd7 |
+ /*no user data*/NULL);
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+GtkWidget *system_config_abrt_widget_new_with_close_button(system_config_abrt_widget_close_callback close_cb, gpointer user_data)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, /*spacing*/0));
|
|
|
a60cd7 |
|
|
|
a60cd7 |
AbrtConfigWidget *config = abrt_config_widget_new();
|
|
|
a60cd7 |
@@ -55,6 +70,17 @@ GtkWidget *system_config_abrt_widget_new(void)
|
|
|
a60cd7 |
gtk_widget_set_margin_top(buttons, 10);
|
|
|
a60cd7 |
gtk_widget_set_margin_bottom(buttons, 10);
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+ if (close_cb != NULL)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ GtkWidget *btn_close = gtk_button_new_with_mnemonic(_("_Close"));
|
|
|
a60cd7 |
+ gtk_box_pack_end(GTK_BOX(buttons), btn_close, /*expand*/FALSE, /*fill*/FALSE, /*padding*/0);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ g_object_set_data(G_OBJECT(btn_close), CLOSE_BUTTON_DATA_NAME_CALLBACK, close_cb);
|
|
|
a60cd7 |
+ g_object_set_data(G_OBJECT(btn_close), CLOSE_BUTTON_DATA_NAME_USER_DATA, user_data);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ g_signal_connect(btn_close, "clicked", G_CALLBACK(system_config_abrt_close_btn_cb), /*user_data*/NULL);
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
GtkWidget *btn_defaults = gtk_button_new_with_mnemonic(_("_Defaults"));
|
|
|
a60cd7 |
gtk_box_pack_start(GTK_BOX(buttons), btn_defaults, /*expand*/FALSE, /*fill*/FALSE, /*padding*/0);
|
|
|
a60cd7 |
g_signal_connect(btn_defaults, "clicked", G_CALLBACK(system_config_abrt_defaults_cb), config);
|
|
|
a60cd7 |
@@ -64,6 +90,19 @@ GtkWidget *system_config_abrt_widget_new(void)
|
|
|
a60cd7 |
return GTK_WIDGET(box);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+static void
|
|
|
a60cd7 |
+system_config_abrt_dialog_close_cb(gpointer user_data)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ gtk_widget_destroy(GTK_WIDGET(user_data));
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+static gboolean
|
|
|
a60cd7 |
+system_config_abrt_dialog_delete_event(GtkWidget *dialog, GdkEvent *event, gpointer user_data)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ system_config_abrt_dialog_close_cb(dialog);
|
|
|
a60cd7 |
+ return TRUE; /*do not propagate the event*/
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
void show_system_config_abrt_dialog(GtkWindow *parent)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
GtkWidget *dialog = gtk_dialog_new();
|
|
|
a60cd7 |
@@ -79,8 +118,12 @@ void show_system_config_abrt_dialog(GtkWindow *parent)
|
|
|
a60cd7 |
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+ /* Have to handle this signal, which is emitted on Esc or Alt+F4, otherwise */
|
|
|
a60cd7 |
+ /* the user must commit the action twice to take effect. */
|
|
|
a60cd7 |
+ g_signal_connect(dialog, "delete-event", G_CALLBACK(system_config_abrt_dialog_delete_event), /*user_data*/NULL);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
|
|
a60cd7 |
- GtkWidget *sca = system_config_abrt_widget_new();
|
|
|
a60cd7 |
+ GtkWidget *sca = system_config_abrt_widget_new_with_close_button(system_config_abrt_dialog_close_cb, dialog);
|
|
|
a60cd7 |
gtk_box_pack_start(GTK_BOX(content), sca, /*expand*/TRUE, /*fill*/TRUE, /*padding*/0);
|
|
|
a60cd7 |
|
|
|
a60cd7 |
gtk_widget_show_all(content);
|
|
|
a60cd7 |
--
|
|
|
a60cd7 |
1.8.3.1
|
|
|
a60cd7 |
|