|
|
28bab8 |
From c0931b8a091e10fa6f89625c84f6da453e8fc4d0 Mon Sep 17 00:00:00 2001
|
|
|
28bab8 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
28bab8 |
Date: Wed, 10 Dec 2014 07:02:00 +0100
|
|
|
28bab8 |
Subject: [LIBREPORT PATCH 120/120] gui: support Enter & 2Click in Preferences
|
|
|
28bab8 |
list
|
|
|
28bab8 |
|
|
|
28bab8 |
Related to rhbz#1067123
|
|
|
28bab8 |
|
|
|
28bab8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
28bab8 |
---
|
|
|
28bab8 |
src/gtk-helpers/config_dialog.c | 81 ++++++++++++++++++++++++--------
|
|
|
28bab8 |
src/gtk-helpers/event_config_dialog.c | 51 ++------------------
|
|
|
28bab8 |
src/gtk-helpers/internal_libreport_gtk.h | 1 +
|
|
|
28bab8 |
3 files changed, 66 insertions(+), 67 deletions(-)
|
|
|
28bab8 |
|
|
|
28bab8 |
diff --git a/src/gtk-helpers/config_dialog.c b/src/gtk-helpers/config_dialog.c
|
|
|
28bab8 |
index c80dc56..b5835de 100644
|
|
|
28bab8 |
--- a/src/gtk-helpers/config_dialog.c
|
|
|
28bab8 |
+++ b/src/gtk-helpers/config_dialog.c
|
|
|
28bab8 |
@@ -18,6 +18,7 @@
|
|
|
28bab8 |
*/
|
|
|
28bab8 |
|
|
|
28bab8 |
#include <gtk/gtk.h>
|
|
|
28bab8 |
+#include <gdk/gdk.h>
|
|
|
28bab8 |
#include "internal_libreport_gtk.h"
|
|
|
28bab8 |
|
|
|
28bab8 |
enum
|
|
|
28bab8 |
@@ -83,6 +84,28 @@ gpointer cdialog_get_data(config_dialog_t *cdialog)
|
|
|
28bab8 |
return cdialog->data;
|
|
|
28bab8 |
}
|
|
|
28bab8 |
|
|
|
28bab8 |
+int cdialog_run(config_dialog_t *cdialog, const char *name)
|
|
|
28bab8 |
+{
|
|
|
28bab8 |
+ if (cdialog == NULL || cdialog->dialog == NULL)
|
|
|
28bab8 |
+ {
|
|
|
28bab8 |
+ log("There is no configurable option for: '%s'", name);
|
|
|
28bab8 |
+ return GTK_RESPONSE_REJECT;
|
|
|
28bab8 |
+ }
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ const int result = gtk_dialog_run(GTK_DIALOG(cdialog->dialog));
|
|
|
28bab8 |
+ if (result == GTK_RESPONSE_APPLY)
|
|
|
28bab8 |
+ {
|
|
|
28bab8 |
+ if (cdialog->save_data)
|
|
|
28bab8 |
+ cdialog->save_data(cdialog->data, name);
|
|
|
28bab8 |
+ }
|
|
|
28bab8 |
+ else if (result == GTK_RESPONSE_CANCEL)
|
|
|
28bab8 |
+ log_notice("Cancelling on user request");
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ gtk_widget_hide(GTK_WIDGET(cdialog->dialog));
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ return result;
|
|
|
28bab8 |
+}
|
|
|
28bab8 |
+
|
|
|
28bab8 |
static const void *get_column_value_from_row(GtkTreeView *treeview, int column, int type)
|
|
|
28bab8 |
{
|
|
|
28bab8 |
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
|
|
28bab8 |
@@ -184,6 +207,40 @@ static gboolean config_filter_func(GtkTreeModel *model,
|
|
|
28bab8 |
return visible;
|
|
|
28bab8 |
}
|
|
|
28bab8 |
|
|
|
28bab8 |
+static void open_config_for_selected_row(GtkTreeView *tv)
|
|
|
28bab8 |
+{
|
|
|
28bab8 |
+ config_dialog_t *cdialog = (config_dialog_t *)get_column_value_from_row(tv, CONFIG_DIALOG, TYPE_POINTER);
|
|
|
28bab8 |
+ const char *name = (const char *)get_column_value_from_row(tv, COLUMN_NAME, TYPE_STR);
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ cdialog_run(cdialog, name);
|
|
|
28bab8 |
+}
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+static gboolean on_key_press_event_cb(GtkWidget *btn, GdkEvent *event, gpointer user_data)
|
|
|
28bab8 |
+{
|
|
|
28bab8 |
+ GdkEventKey *ek = (GdkEventKey *)event;
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ if (ek->keyval == GDK_KEY_Return)
|
|
|
28bab8 |
+ {
|
|
|
28bab8 |
+ GtkTreeView *tv = (GtkTreeView *)user_data;
|
|
|
28bab8 |
+ open_config_for_selected_row(tv);
|
|
|
28bab8 |
+ }
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ return FALSE;
|
|
|
28bab8 |
+}
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+static gboolean on_button_press_event_cb(GtkWidget *btn, GdkEvent *event, gpointer user_data)
|
|
|
28bab8 |
+{
|
|
|
28bab8 |
+ GdkEventButton *eb = (GdkEventButton *)event;
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ if (eb->type == GDK_2BUTTON_PRESS)
|
|
|
28bab8 |
+ {
|
|
|
28bab8 |
+ GtkTreeView *tv = (GtkTreeView *)user_data;
|
|
|
28bab8 |
+ open_config_for_selected_row(tv);
|
|
|
28bab8 |
+ }
|
|
|
28bab8 |
+
|
|
|
28bab8 |
+ return FALSE;
|
|
|
28bab8 |
+}
|
|
|
28bab8 |
+
|
|
|
28bab8 |
GtkWidget *create_config_tab_content(const char *column_label,
|
|
|
28bab8 |
GtkListStore *store)
|
|
|
28bab8 |
{
|
|
|
28bab8 |
@@ -194,6 +251,9 @@ GtkWidget *create_config_tab_content(const char *column_label,
|
|
|
28bab8 |
GTK_POLICY_AUTOMATIC);
|
|
|
28bab8 |
/* workflow list treeview */
|
|
|
28bab8 |
GtkWidget *tv = gtk_tree_view_new();
|
|
|
28bab8 |
+ g_signal_connect(tv, "key-press-event", G_CALLBACK(on_key_press_event_cb), tv);
|
|
|
28bab8 |
+ g_signal_connect(tv, "button-press-event", G_CALLBACK(on_button_press_event_cb), tv);
|
|
|
28bab8 |
+
|
|
|
28bab8 |
/* column with workflow name and description */
|
|
|
28bab8 |
GtkCellRenderer *renderer;
|
|
|
28bab8 |
GtkTreeViewColumn *column;
|
|
|
28bab8 |
@@ -243,27 +303,8 @@ static void on_configure_cb(GtkWidget *btn, gpointer user_data)
|
|
|
28bab8 |
GtkWidget *vbox = gtk_notebook_get_nth_page(nb, current_page_n);
|
|
|
28bab8 |
GList *children = gtk_container_get_children(GTK_CONTAINER(vbox));
|
|
|
28bab8 |
GtkScrolledWindow *sw = (GtkScrolledWindow *)children->data;
|
|
|
28bab8 |
- GtkTreeView *tv = (GtkTreeView *)gtk_bin_get_child(GTK_BIN(sw));
|
|
|
28bab8 |
- config_dialog_t *cdialog = (config_dialog_t *)get_column_value_from_row(tv, CONFIG_DIALOG, TYPE_POINTER);
|
|
|
28bab8 |
- const char *name = (const char *)get_column_value_from_row(tv, COLUMN_NAME, TYPE_STR);
|
|
|
28bab8 |
-
|
|
|
28bab8 |
|
|
|
28bab8 |
- if (cdialog == NULL || cdialog->dialog == NULL)
|
|
|
28bab8 |
- {
|
|
|
28bab8 |
- log("There is no configurable option for: '%s'", name);
|
|
|
28bab8 |
- return;
|
|
|
28bab8 |
- }
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- int result = gtk_dialog_run(GTK_DIALOG(cdialog->dialog));
|
|
|
28bab8 |
- if (result == GTK_RESPONSE_APPLY)
|
|
|
28bab8 |
- {
|
|
|
28bab8 |
- if (cdialog->save_data)
|
|
|
28bab8 |
- cdialog->save_data(cdialog->data, name);
|
|
|
28bab8 |
- }
|
|
|
28bab8 |
- else if (result == GTK_RESPONSE_CANCEL)
|
|
|
28bab8 |
- log_notice("Cancelling on user request");
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- gtk_widget_hide(GTK_WIDGET(cdialog->dialog));
|
|
|
28bab8 |
+ open_config_for_selected_row((GtkTreeView *)gtk_bin_get_child(GTK_BIN(sw)));
|
|
|
28bab8 |
}
|
|
|
28bab8 |
|
|
|
28bab8 |
static void on_close_cb(GtkWidget *btn, gpointer config_list_w)
|
|
|
28bab8 |
diff --git a/src/gtk-helpers/event_config_dialog.c b/src/gtk-helpers/event_config_dialog.c
|
|
|
28bab8 |
index 659f563..402f6f2 100644
|
|
|
28bab8 |
--- a/src/gtk-helpers/event_config_dialog.c
|
|
|
28bab8 |
+++ b/src/gtk-helpers/event_config_dialog.c
|
|
|
28bab8 |
@@ -337,7 +337,7 @@ config_dialog_t *create_event_config_dialog(const char *event_name, GtkWindow *p
|
|
|
28bab8 |
if (parent_window != NULL)
|
|
|
28bab8 |
{
|
|
|
28bab8 |
gtk_window_set_icon_name(GTK_WINDOW(dialog),
|
|
|
28bab8 |
- gtk_window_get_icon_name(parent_window));
|
|
|
28bab8 |
+ gtk_window_get_icon_name(parent_window));
|
|
|
28bab8 |
}
|
|
|
28bab8 |
|
|
|
28bab8 |
GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
|
|
28bab8 |
@@ -367,53 +367,10 @@ int show_event_config_dialog(const char *event_name, GtkWindow *parent)
|
|
|
28bab8 |
{
|
|
|
28bab8 |
INITIALIZE_LIBREPORT();
|
|
|
28bab8 |
|
|
|
28bab8 |
- event_config_t *event = get_event_config(event_name);
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- GtkWindow *parent_window = parent ? parent : g_event_list_window;
|
|
|
28bab8 |
+ config_dialog_t *dialog = create_event_config_dialog(event_name, parent);
|
|
|
28bab8 |
+ const int result = cdialog_run(dialog, event_name);
|
|
|
28bab8 |
+ free(dialog);
|
|
|
28bab8 |
|
|
|
28bab8 |
- GtkWidget *dialog = gtk_dialog_new_with_buttons(
|
|
|
28bab8 |
- /*title:*/ec_get_screen_name(event) ? ec_get_screen_name(event) : event_name,
|
|
|
28bab8 |
- parent_window,
|
|
|
28bab8 |
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
28bab8 |
- _("_Cancel"),
|
|
|
28bab8 |
- GTK_RESPONSE_CANCEL,
|
|
|
28bab8 |
- _("_OK"),
|
|
|
28bab8 |
- GTK_RESPONSE_APPLY,
|
|
|
28bab8 |
- NULL);
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- /* Allow resize?
|
|
|
28bab8 |
- * W/o resize, e.g. upload configuration hint looks awfully
|
|
|
28bab8 |
- * line wrapped.
|
|
|
28bab8 |
- * With resize, there are some somewhat not nice effects:
|
|
|
28bab8 |
- * for one, opening an expander will enlarge window,
|
|
|
28bab8 |
- * but won't contract it back when expander is closed.
|
|
|
28bab8 |
- */
|
|
|
28bab8 |
- gtk_window_set_resizable(GTK_WINDOW(dialog), true);
|
|
|
28bab8 |
- gtk_window_set_default_size(GTK_WINDOW(dialog), 450, -1);
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- if (parent_window != NULL)
|
|
|
28bab8 |
- {
|
|
|
28bab8 |
- gtk_window_set_icon_name(GTK_WINDOW(dialog),
|
|
|
28bab8 |
- gtk_window_get_icon_name(parent_window));
|
|
|
28bab8 |
- }
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
|
|
28bab8 |
- content = cdialog_get_widget(create_event_config_dialog_content(event, content));
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- gtk_widget_show_all(content);
|
|
|
28bab8 |
-
|
|
|
28bab8 |
- int result = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
28bab8 |
- if (result == GTK_RESPONSE_APPLY)
|
|
|
28bab8 |
- {
|
|
|
28bab8 |
- dehydrate_config_dialog(g_option_list);
|
|
|
28bab8 |
- const char *const store_passwords_s = get_user_setting("store_passwords");
|
|
|
28bab8 |
- save_event_config_data_to_user_storage(event_name,
|
|
|
28bab8 |
- get_event_config(event_name),
|
|
|
28bab8 |
- !(store_passwords_s && !strcmp(store_passwords_s, "no")));
|
|
|
28bab8 |
- }
|
|
|
28bab8 |
- //else if (result == GTK_RESPONSE_CANCEL)
|
|
|
28bab8 |
- // log("log");
|
|
|
28bab8 |
- gtk_widget_destroy(dialog);
|
|
|
28bab8 |
return result;
|
|
|
28bab8 |
}
|
|
|
28bab8 |
|
|
|
28bab8 |
diff --git a/src/gtk-helpers/internal_libreport_gtk.h b/src/gtk-helpers/internal_libreport_gtk.h
|
|
|
28bab8 |
index dc1ef31..f8f1c13 100644
|
|
|
28bab8 |
--- a/src/gtk-helpers/internal_libreport_gtk.h
|
|
|
28bab8 |
+++ b/src/gtk-helpers/internal_libreport_gtk.h
|
|
|
28bab8 |
@@ -80,6 +80,7 @@ void load_workflow_config_data_from_user_storage(GHashTable *workflows);
|
|
|
28bab8 |
void cdialog_set_widget(config_dialog_t *cdialog, GtkWidget *widget);
|
|
|
28bab8 |
GtkWidget *cdialog_get_widget(config_dialog_t *cdialog);
|
|
|
28bab8 |
gpointer cdialog_get_data(config_dialog_t *cdialog);
|
|
|
28bab8 |
+int cdialog_run(config_dialog_t *cdialog, const char *name);
|
|
|
28bab8 |
|
|
|
28bab8 |
void dehydrate_config_dialog(GList *option_widgets);
|
|
|
28bab8 |
|
|
|
28bab8 |
--
|
|
|
28bab8 |
1.8.3.1
|
|
|
28bab8 |
|