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