[devhelp/wip/swilmet/various-code-improvements: 12/12] sidebar: always send link-selected signal



commit 57fceb7c153d029109a6c669ee7ed54c0e745684
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Oct 10 12:14:11 2015 +0200

    sidebar: always send link-selected signal
    
    Storing the selected_link is not needed. In every case where the
    link-selected signal is sent, it is better to send it regardless of
    whether the previous signal emission provided the same link. By
    re-sending the signal with the same link, the page scrolls at the right
    location (if the user has scrolled within the page).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756341

 src/dh-sidebar.c |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index 79d0c80..be16855 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2005-2008 Imendio AB
  * Copyright (C) 2010 Lanedo GmbH
  * Copyright (C) 2013 Aleksander Morgado <aleksander gnu org>
+ * Copyright (C) 2015 Sébastien Wilmet <swilmet gnome org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -32,8 +33,6 @@
 typedef struct {
         DhBookManager           *book_manager;
 
-        DhLink                  *selected_link;
-
         DhBookTree              *book_tree;
         GtkScrolledWindow       *sw_book_tree;
 
@@ -185,10 +184,7 @@ sidebar_hitlist_selection_changed_cb (GtkTreeSelection *selection,
                                     DH_KEYWORD_MODEL_COL_LINK, &link,
                                     -1);
 
-                if (link != priv->selected_link) {
-                        priv->selected_link = link;
-                        g_signal_emit (sidebar, signals[LINK_SELECTED], 0, link);
-                }
+                g_signal_emit (sidebar, signals[LINK_SELECTED], 0, link);
         }
 }
 
@@ -218,8 +214,6 @@ sidebar_hitlist_button_press_cb (GtkTreeView    *hitlist_view,
                             DH_KEYWORD_MODEL_COL_LINK, &link,
                             -1);
 
-        priv->selected_link = link;
-
         g_signal_emit (sidebar, signals[LINK_SELECTED], 0, link);
 
         /* Always propagate the event so the tree view can update
@@ -405,16 +399,11 @@ hitlist_cell_data_func (GtkTreeViewColumn *tree_column,
 /******************************************************************************/
 
 static void
-sidebar_book_tree_link_selected_cb (GObject   *ignored,
-                                    DhLink    *link,
-                                    DhSidebar *sidebar)
+sidebar_book_tree_link_selected_cb (DhBookTree *book_tree,
+                                    DhLink     *link,
+                                    DhSidebar  *sidebar)
 {
-        DhSidebarPrivate *priv = dh_sidebar_get_instance_private (sidebar);
-
-        if (link != priv->selected_link) {
-                priv->selected_link = link;
-                g_signal_emit (sidebar, signals[LINK_SELECTED], 0, link);
-        }
+        g_signal_emit (sidebar, signals[LINK_SELECTED], 0, link);
 }
 
 DhLink *


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