[balsa: 1/2] Various: Use GtkTreeView's "row-activated" signal
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa: 1/2] Various: Use GtkTreeView's "row-activated" signal
- Date: Sat, 13 Jun 2020 16:16:07 +0000 (UTC)
commit cfbcdd7a876f44c58fdf086764740d7f2d31618a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Jun 13 12:06:29 2020 -0400
Various: Use GtkTreeView's "row-activated" signal
Use GtkTreeView's "row-activated" signal instead of connecting to "button-press-event".
* libbalsa/autocrypt.c (autocrypt_db_dialog_run), (row_activated_cb):
* libbalsa/libbalsa-gpgme-cb.c (row_activated_cb), (lb_gpgme_select_key):
ChangeLog | 10 ++++++++++
libbalsa/autocrypt.c | 45 ++++++++++++++------------------------------
libbalsa/libbalsa-gpgme-cb.c | 41 +++++++++++++---------------------------
3 files changed, 37 insertions(+), 59 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 56d839307..d757291a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-06-13 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Various: Use GtkTreeView's "row-activated" signal instead of
+ connecting to "button-press-event".
+
+ * libbalsa/autocrypt.c (autocrypt_db_dialog_run),
+ (row_activated_cb):
+ * libbalsa/libbalsa-gpgme-cb.c (row_activated_cb),
+ (lb_gpgme_select_key):
+
2020-06-09 Peter Bloomfield <pbloomfield bellsouth net>
Various: restore filtering in a mailbox that is not currently
diff --git a/libbalsa/autocrypt.c b/libbalsa/autocrypt.c
index 407f16062..af081fa83 100644
--- a/libbalsa/autocrypt.c
+++ b/libbalsa/autocrypt.c
@@ -118,11 +118,10 @@ static AutocryptRecommend autocrypt_check_ia_list(gpgme_ctx_t gpgme_ct
time_t
ref_time,
GList
**missing_keys,
GError
**error);
-static void gesture_pressed_cb(GtkGestureMultiPress *gesture,
- gint n_press,
- gdouble x,
- gdouble y,
- gpointer user_data);
+static void row_activated_cb(GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data);
static sqlite3 *autocrypt_db = NULL;
@@ -432,7 +431,6 @@ autocrypt_db_dialog_run(const gchar *date_string, GtkWindow *parent)
GtkTreeViewColumn *column;
GList *keys = NULL;
int sqlite_res;
- GtkGesture *gesture;
dialog = gtk_dialog_new_with_buttons(_("Autocrypt database"), parent,
GTK_DIALOG_DESTROY_WITH_PARENT | libbalsa_dialog_flags(), _("_Close"), GTK_RESPONSE_CLOSE,
NULL);
@@ -458,8 +456,7 @@ autocrypt_db_dialog_run(const gchar *date_string, GtkWindow *parent)
tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
- gesture = gtk_gesture_multi_press_new(tree_view);
- g_signal_connect(gesture, "pressed", G_CALLBACK(gesture_pressed_cb), dialog);
+ g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), dialog);
gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
@@ -774,32 +771,17 @@ update_last_seen(GMimeAutocryptHeader *autocrypt_header, GError **error)
static void
-gesture_pressed_cb(GtkGestureMultiPress *gesture,
- gint n_press,
- gdouble x,
- gdouble y,
- gpointer data)
+row_activated_cb(GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
{
- GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
- GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
- GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
- GtkTreePath *path;
- GtkTreeIter iter;
GtkTreeModel *model;
-
- if (n_press != 2)
- return;
-
- if (gtk_tree_view_get_path_at_pos(tree_view, x, y, &path, NULL, NULL, NULL)) {
- if (!gtk_tree_selection_path_is_selected(selection, path)) {
- gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell(tree_view, path, NULL, FALSE, 0, 0);
- }
- gtk_tree_path_free(path);
- }
+ GtkTreeIter iter;
/* note: silently ignore all errors below... */
- if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ model = gtk_tree_view_get_model(tree_view);
+ if (gtk_tree_model_get_iter(model, &iter, path)) {
gpgme_ctx_t ctx;
ctx = libbalsa_gpgme_new_with_proto(GPGME_PROTOCOL_OpenPGP, NULL, NULL, NULL);
@@ -816,9 +798,10 @@ gesture_pressed_cb(GtkGestureMultiPress *gesture,
libbalsa_gpgme_import_bin_key(ctx, key, NULL, NULL) &&
libbalsa_gpgme_list_keys(ctx, &keys, NULL, NULL, FALSE, FALSE, TRUE,
NULL);
if (success && (keys != NULL)) {
+ GtkWindow *window = user_data;
GtkWidget *dialog;
- dialog = libbalsa_key_dialog(GTK_WINDOW(data), GTK_BUTTONS_CLOSE,
(gpgme_key_t) keys->data, GPG_SUBKEY_CAP_ALL,
+ dialog = libbalsa_key_dialog(window, GTK_BUTTONS_CLOSE, (gpgme_key_t)
keys->data, GPG_SUBKEY_CAP_ALL,
NULL, NULL);
(void) gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
diff --git a/libbalsa/libbalsa-gpgme-cb.c b/libbalsa/libbalsa-gpgme-cb.c
index 9a3581e52..00fb31d21 100644
--- a/libbalsa/libbalsa-gpgme-cb.c
+++ b/libbalsa/libbalsa-gpgme-cb.c
@@ -132,41 +132,26 @@ lb_gpgme_passphrase(void *hook, const gchar * uid_hint,
}
-static gboolean
-key_button_event_press_cb(GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
+static void
+row_activated_cb(GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
- GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
- GtkTreePath *path;
GtkTreeIter iter;
GtkTreeModel *model;
- g_return_val_if_fail(event != NULL, FALSE);
- if ((event->type != GDK_2BUTTON_PRESS) || event->window != gtk_tree_view_get_bin_window(tree_view)) {
- return FALSE;
- }
-
- if (gtk_tree_view_get_path_at_pos(tree_view, event->x, event->y, &path, NULL, NULL, NULL)) {
- if (!gtk_tree_selection_path_is_selected(selection, path)) {
- gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell(tree_view, path, NULL, FALSE, 0, 0);
- }
- gtk_tree_path_free(path);
- }
-
- if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ model = gtk_tree_view_get_model(tree_view);
+ if (gtk_tree_model_get_iter(model, &iter, path)) {
gpgme_key_t key;
+ GtkWindow *window = user_data;
GtkWidget *dialog;
- gtk_tree_model_get(model, &iter, GPG_KEY_PTR_COLUMN, &key, -1);
- dialog = libbalsa_key_dialog(GTK_WINDOW(data), GTK_BUTTONS_CLOSE, key, GPG_SUBKEY_CAP_ALL,
NULL, NULL);
- (void) gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ gtk_tree_model_get(model, &iter, GPG_KEY_PTR_COLUMN, &key, -1);
+ dialog = libbalsa_key_dialog(window, GTK_BUTTONS_CLOSE, key, GPG_SUBKEY_CAP_ALL, NULL, NULL);
+ (void) gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
-
- return TRUE;
}
@@ -288,7 +273,7 @@ lb_gpgme_select_key(const gchar * user_name, lb_key_sel_md_t mode, GList * keys,
gtk_tree_view_column_set_resizable(column, TRUE);
gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
- g_signal_connect(tree_view, "button_press_event", G_CALLBACK(key_button_event_press_cb), dialog);
+ g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), dialog);
gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]