gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r19688 - gnunet-gtk/src/fs
Date: Sat, 4 Feb 2012 21:26:25 +0100

Author: grothoff
Date: 2012-02-04 21:26:25 +0100 (Sat, 04 Feb 2012)
New Revision: 19688

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
Log:
-fixes

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c  2012-02-04 20:13:38 UTC 
(rev 19687)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c  2012-02-04 20:26:25 UTC 
(rev 19688)
@@ -160,6 +160,7 @@
                                           (dlc->builder,
                                            
"GNUNET_GTK_save_as_dialog_anonymity_spin_button")));
   gtk_widget_destroy (GTK_WIDGET (dialog));
+  /* we were successful, do not remove the directory (if we created one) */
   GNUNET_free_non_null (dlc->dirname);
   dlc->dirname = NULL;
   clean_up_download_as_context (dlc);
@@ -259,7 +260,7 @@
   if (de->is_recursive)
     opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
   len = GNUNET_FS_uri_chk_get_file_size (de->uri);
-  if (NULL != de->sr)
+  if (NULL != de->sr->result)
   {
     GNUNET_break (NULL !=
                   GNUNET_FS_download_start_from_search (fs, 

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2012-02-04 20:13:38 UTC 
(rev 19687)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2012-02-04 20:26:25 UTC 
(rev 19688)
@@ -206,13 +206,17 @@
   gtk_tree_model_get (tm, iter, 0, &meta, 
                      15, &local_filename, 
                      16, &downloaded_anonymity, 
-                     -1);
-  if ( (NULL != local_filename) && (GNUNET_YES == top) )
-    *local_parents = GNUNET_YES;
-  if ( (NULL == local_filename) && (GNUNET_NO == top) )
-    *local_parents = GNUNET_NO;
-  if ( (downloaded_anonymity != -1) && (*anonymity == -1) && (GNUNET_NO == 
top) )
-    *anonymity = downloaded_anonymity;
+                     -1);  
+  if (GNUNET_NO == top)
+  {
+    if (NULL != local_filename)
+      *local_parents = GNUNET_YES;
+    else
+      *local_parents = GNUNET_NO;
+    if  ( (downloaded_anonymity != -1) &&
+         (*anonymity == -1) )
+      *anonymity = downloaded_anonymity;
+  }
   if (gtk_tree_model_iter_parent (tm, &parent, iter))
   {
     have_a_parent = GNUNET_YES;
@@ -224,8 +228,6 @@
   {
     have_a_parent = GNUNET_NO;
     dirname = NULL;
-    if (GNUNET_NO == top)
-      *local_parents = GNUNET_NO;
   }
   if (local_filename == NULL)
   {
@@ -242,7 +244,7 @@
      */
     if ( (NULL == dirname) && (GNUNET_NO == have_a_parent))
     {
-      /* This is the ealderlest parent directory. Use absolute path. */
+      /* This is the root. Use absolute path. */
       basename = (const char *) local_filename;
       *filename_is_absolute = GNUNET_YES;
     }
@@ -284,12 +286,14 @@
  * @param path path selecting which entry we want to download
  * @param tab the search tab where the user triggered the download request
  * @param is_recursive was the request for a recursive download?
+ * @param save_as force opening the 'save as' dialog?
  */
 static void
 start_download (GtkTreeView *tree_view, 
                GtkTreePath *path,
                 struct SearchTab *tab,
-               int is_recursive)
+               int is_recursive,
+               int save_as)
 {
   GtkTreeModel *tm;
   GtkTreeIter iter;
@@ -396,10 +400,13 @@
   de->anonymity = anonymity;
   de->is_recursive = is_recursive;
   de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta);
+  if (save_as)
+    have_a_suggestion = GNUNET_NO;
   fprintf (stderr,
           "lp %d, have-sug: %d\n",
           local_parents,
           have_a_suggestion);
+
   if ( (GNUNET_YES == local_parents) &&
        (GNUNET_YES == have_a_suggestion) )
     /* Skip the dialog, call directly */
@@ -444,18 +451,19 @@
 {
   struct SearchTab *tab = user_data;
 
-  start_download (tree_view, path, tab, GNUNET_NO);
+  start_download (tree_view, path, tab, GNUNET_NO, GNUNET_NO);
 }
 
 
 /**
  * "Download" was selected in the current search context menu.
  * 
- * @param item the 'download' menu item
- * @parma user_data the 'struct DownloadEntry' to download.
+ * @param is_recursive was this the 'recursive' option?
+ * @parma save_as was this the 'save as' option?
  */
 static void
-start_download_ctx_menu (GtkMenuItem *item, gpointer user_data)
+start_download_ctx_menu_helper (int is_recursive,
+                               int save_as)
 {
   GtkTreePath *path;
   GtkTreeView *tv;
@@ -471,38 +479,50 @@
   tv = GTK_TREE_VIEW (gtk_builder_get_object
                       (current_context_search_tab->builder,
                        "_search_result_frame"));
-  start_download (tv, path, current_context_search_tab, GNUNET_NO);
+  start_download (tv, path, current_context_search_tab,
+                 is_recursive,
+                 save_as);
   gtk_tree_path_free (path);
   current_context_search_tab = NULL;
 }
 
 
 /**
+ * "Download" was selected in the current search context menu.
+ * 
+ * @param item the 'download' menu item
+ * @parma user_data FIXME
+ */
+static void
+start_download_ctx_menu (GtkMenuItem *item, gpointer user_data)
+{
+  start_download_ctx_menu_helper (GNUNET_NO, GNUNET_NO);
+}
+
+
+/**
  * "Download recursively" was selected in the current search context menu.
  * 
  * @param item the 'download recursively' menu item
- * @parma user_data the 'struct DownloadEntry' to download.
+ * @parma user_data FIXME
  */
 static void
 start_download_recursively_ctx_menu (GtkMenuItem *item, gpointer user_data)
 {
-  GtkTreePath *path;
-  GtkTreeView *tv;
+  start_download_ctx_menu_helper (GNUNET_YES, GNUNET_NO);
+}
 
-  if (current_context_row_reference == NULL)
-  {
-    GNUNET_break (0);
-    return;
-  }
-  path = gtk_tree_row_reference_get_path (current_context_row_reference);
-  gtk_tree_row_reference_free (current_context_row_reference);
-  current_context_row_reference = NULL;
-  tv = GTK_TREE_VIEW (gtk_builder_get_object
-                      (current_context_search_tab->builder,
-                       "_search_result_frame"));
-  start_download (tv, path, current_context_search_tab, GNUNET_YES);
-  gtk_tree_path_free (path);
-  current_context_search_tab = NULL;
+
+/**
+ * "Download as..." was selected in the current search context menu.
+ * 
+ * @param item the 'download as...' menu item
+ * @parma user_data FIXME
+ */
+static void
+start_download_as_ctx_menu (GtkMenuItem *item, gpointer user_data)
+{
+  start_download_ctx_menu_helper (GNUNET_NO, GNUNET_YES);
 }
 
 
@@ -643,6 +663,16 @@
                                 TRUE);
     gtk_widget_show (child);
     gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
+
+
+    child = gtk_menu_item_new_with_label (_("Download _as..."));
+    g_signal_connect (child, "activate",
+                     G_CALLBACK (start_download_as_ctx_menu), NULL);
+    gtk_label_set_use_underline (GTK_LABEL
+                                (gtk_bin_get_child (GTK_BIN (child))),
+                                TRUE);
+    gtk_widget_show (child);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
   }
   if ( (NULL != sr->download) &&
        (GNUNET_YES != sr->download->is_done) )




reply via email to

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