[devhelp/wip/swilmet/misc: 4/4] window: simplify close_button_clicked_cb()



commit 5e785f4f5bb72c492a4c9984f7534b2ca3d8109b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Nov 15 17:20:07 2015 +0100

    window: simplify close_button_clicked_cb()

 src/dh-window.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/src/dh-window.c b/src/dh-window.c
index 7ec2fcb..f8b7309 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -1311,19 +1311,13 @@ close_button_clicked_cb (GtkButton *button,
 {
         DhWindowPrivate *priv;
         GtkWidget *parent_tab;
-        gint       pages;
-        gint       i;
+        gint page_num;
 
         priv = dh_window_get_instance_private (window);
 
         parent_tab = g_object_get_data (G_OBJECT (button), "parent_tab");
-        pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
-        for (i=0; i<pages; i++) {
-                if (gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), i) == parent_tab) {
-                        window_close_tab (window, i);
-                        break;
-                }
-        }
+        page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), parent_tab);
+        window_close_tab (window, page_num);
 }
 
 static GtkWidget *


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