gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19676 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r19676 - gnunet-gtk/src/fs
Date: Fri, 3 Feb 2012 23:48:05 +0100

Author: grothoff
Date: 2012-02-03 23:48:05 +0100 (Fri, 03 Feb 2012)
New Revision: 19676

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
Log:
-fix crash, nicer selection of items after deletion in publish dialog

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2012-02-03 21:55:39 UTC 
(rev 19675)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2012-02-03 22:48:05 UTC 
(rev 19676)
@@ -673,7 +673,8 @@
     gtk_widget_show (child);
     gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
   }
-  if (NULL != sr->download)
+  if ( (NULL != sr->download) &&
+       (GNUNET_YES != sr->download->is_done) )
   {
     child = gtk_menu_item_new_with_label (_("_Abort download"));
     g_signal_connect (child, "activate",

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-03 21:55:39 UTC 
(rev 19675)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-03 22:48:05 UTC 
(rev 19676)
@@ -834,16 +834,60 @@
   struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
   struct GNUNET_FS_FileInformation *fip;
+  GtkTreeRowReference *rr;
+  GtkTreePath *path;
 
+  /* initially, both 'iter' and 'next' point to the selected row */
   if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
+
+  path = gtk_tree_model_get_path (ctx->file_info_treemodel, &iter);
+  if (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter))
+    gtk_tree_path_next (path);
+  else
+  {
+    if (! gtk_tree_path_prev (path))
+    {
+      if ( (1 == gtk_tree_path_get_depth (path) ) ||
+          (! gtk_tree_path_up (path) ) )
+      {
+       gtk_tree_path_free (path);
+       path = NULL;
+      }
+    }
+  }
+  if (NULL == path)
+  {
+    rr = NULL;
+  }
+  else
+  {
+    rr = gtk_tree_row_reference_new (ctx->file_info_treemodel, path);
+    gtk_tree_path_free (path);
+  } 
+
+  /* 'iter' might have again been clobbered, get it one more time... */
+  GNUNET_assert (gtk_tree_selection_get_selected (ctx->file_info_selection, 
NULL, &iter));
+
+  /* now delete the subtree */
   gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1);
   GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL);
   GNUNET_FS_GTK_remove_treestore_subtree  (GTK_TREE_STORE 
(ctx->file_info_treemodel), 
                                           &iter);
+
+  /* finally, select the item from 'rr' (if any) */
+  if (NULL != rr)
+  {
+    path = gtk_tree_row_reference_get_path (rr);
+    gtk_tree_row_reference_free (rr);
+    gtk_tree_selection_select_path (ctx->file_info_selection, path);
+    gtk_tree_path_free (path);
+  }
+
+  /* and now, depending on the selection, update the sensitivity of buttons */
   update_selectivity (ctx);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]