[balsa] address-view: Set "activate-on-single-click"



commit 595ac0077857eaa85665d402de6c79c8d4f3c541
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Sep 23 15:06:14 2020 -0400

    address-view: Set "activate-on-single-click"
    
    Set GtkTreeView's "activate-on-single-click" property to TRUE,
    instead of doing it the hard way.

 ChangeLog               |  6 ++++++
 libbalsa/address-view.c | 52 +++++--------------------------------------------
 2 files changed, 11 insertions(+), 47 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d6912a239..25feba7ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-09-23  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       * libbalsa/address-view.c (libbalsa_address_view_new): Set
+       "activate-on-single-click" property to TRUE, instead of doing it
+       the hard way.
+
 2020-09-02  Peter Bloomfield  <pbloomfield bellsouth net>
 
        balsa-index: add a timeout to verify that the scrolled-to row is
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index 817b34617..a87996535 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -932,46 +932,6 @@ lbav_sort_func(GtkTreeModel * model, GtkTreeIter * a, GtkTreeIter * b,
     return is_blank_a - is_blank_b;
 }
 
-/*
- * Callback for the tree-view's selection "changed" signal.
- * Implement one-click actions.
- */
-static void
-lbav_selection_changed_cb(GtkTreeSelection * selection,
-                          LibBalsaAddressView * address_view)
-{
-    GdkEvent *event = gtk_get_current_event();
-
-    if (event == NULL)
-        return;
-
-    if (gdk_event_get_event_type(event) == GDK_BUTTON_PRESS) {
-        GtkTreeView *tree_view = (GtkTreeView *) address_view;
-
-        if (gdk_event_get_window(event) ==
-            gtk_tree_view_get_bin_window(tree_view)) {
-            gdouble x_win, y_win;
-
-            if (gdk_event_get_coords(event, &x_win, &y_win)) {
-                gint x, y;
-                GtkTreePath *path;
-                GtkTreeViewColumn *column;
-
-                gtk_tree_view_convert_widget_to_bin_window_coords
-                    (tree_view, (gint) x_win, (gint) y_win, &x, &y);
-
-                if (gtk_tree_view_get_path_at_pos
-                    (tree_view, x, y, &path, &column, NULL, NULL)) {
-                    gtk_tree_view_row_activated(tree_view, path, column);
-                    gtk_tree_path_free(path);
-                }
-            }
-        }
-    }
-
-    gdk_event_free(event);
-}
-
 /*
  *     Public API.
  */
@@ -989,7 +949,6 @@ libbalsa_address_view_new(const gchar * const *types,
     LibBalsaAddressView *address_view;
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *column;
-    GtkTreeSelection *selection;
 
     /* List store for the widget: */
     address_store = gtk_list_store_new(4,
@@ -1010,9 +969,11 @@ libbalsa_address_view_new(const gchar * const *types,
          GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
 
     /* The widget: */
-    address_view =
-        g_object_new(LIBBALSA_TYPE_ADDRESS_VIEW, "model", address_store,
-                     "headers-visible", FALSE, NULL);
+    address_view = g_object_new(LIBBALSA_TYPE_ADDRESS_VIEW,
+                                "model", address_store,
+                                "headers-visible", FALSE,
+                                "activate-on-single-click", TRUE,
+                                NULL);
     g_object_unref(address_store);
 
     address_view->types = types;
@@ -1021,9 +982,6 @@ libbalsa_address_view_new(const gchar * const *types,
     address_view->fallback = fallback;
 
     tree_view = GTK_TREE_VIEW(address_view);
-    selection = gtk_tree_view_get_selection(tree_view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(lbav_selection_changed_cb), address_view);
 
     /* The button: */
     column = gtk_tree_view_column_new();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]