$OpenBSD: patch-src_tree_c,v 1.8 2013/06/04 20:16:06 ajacoutot Exp $

From 7c234ed9b71d5f009abff509ef2bf576f61a0cbb Mon Sep 17 00:00:00 2001
From: Arx Cruz <arxcruz@gnome.org>
Date: Thu, 23 May 2013 19:27:58 +0000
Subject: Bug 698683 - Double clicking an item or hitting enter after selecting an item

From c89ce9c3812fdc3a2637fd76b42a07385ad50684 Mon Sep 17 00:00:00 2001
From: Arx Cruz <arxcruz@gnome.org>
Date: Tue, 04 Jun 2013 19:27:48 +0000
Subject: Bug #653468. Fixed by Kurt Miller <kurt@intricatesoftware.com>.

--- src/tree.c.orig	Thu Mar 14 02:46:04 2013
+++ src/tree.c	Tue Jun  4 22:11:58 2013
@@ -139,6 +139,7 @@ zenity_tree_handle_stdin (GIOChannel  *channel,
   static gboolean editable;
   static gboolean toggles;
   static gboolean first_time = TRUE;
+  GIOStatus status = G_IO_STATUS_NORMAL;
 
   tree_view = GTK_TREE_VIEW (data);
   n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns"));
@@ -152,7 +153,7 @@ zenity_tree_handle_stdin (GIOChannel  *channel,
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
   }
 
-  if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) {
+  if ((condition & G_IO_IN) == G_IO_IN) {
     GString *string;
     GError *error = NULL;
 
@@ -161,8 +162,6 @@ zenity_tree_handle_stdin (GIOChannel  *channel,
     while ((g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) != G_IO_FLAG_IS_READABLE)
       ;
     do {
-      gint status;
-
       do {
         if (g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE)
           status = g_io_channel_read_line_string (channel, string, NULL, &error);
@@ -221,11 +220,11 @@ zenity_tree_handle_stdin (GIOChannel  *channel,
 
       column_count++;
 
-    } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); 
+    } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == G_IO_IN && status != G_IO_STATUS_EOF); 
     g_string_free (string, TRUE);
   }
 
-  if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) {
+  if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) {
     g_io_channel_shutdown (channel, TRUE, NULL);
     return FALSE;
   }
@@ -710,12 +709,6 @@ zenity_tree_row_activated (GtkTreeView *tree_view, Gtk
                            GtkTreeViewColumn *tree_col, gpointer data)
 {
   ZenityData *zen_data = data;
-  GtkTreeSelection *selection; 
-  
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-  gtk_tree_selection_selected_foreach (selection, 
-                                       (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, 
-                                       GTK_TREE_VIEW (tree_view));
  
   zenity_tree_dialog_output ();
   zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
