rendered paste bodyIndex: linux/search.cc===================================================================RCS file: /cvsroot/linuxdcpp/linuxdcpp/linux/search.cc,vretrieving revision 1.32diff -u -r1.32 search.cc--- linux/search.cc 11 Sep 2006 20:44:37 -0000 1.32+++ linux/search.cc 13 Sep 2006 18:42:31 -0000@@ -227,11 +227,11 @@ void Search::buildDownloadMenu_gui() { GtkWidget *menuItem;+ SearchResult *result = NULL; if (gtk_tree_selection_count_selected_rows(selection) == 1) { GtkTreeIter iter;- SearchResult *result = NULL; GList *list = gtk_tree_selection_get_selected_rows(selection, NULL); GtkTreePath *path = (GtkTreePath *)g_list_nth_data(list, 0); @@ -260,12 +260,46 @@ // Build "Download to..." submenu gtk_container_foreach(GTK_CONTAINER(getWidget("downloadMenu")), (GtkCallback)gtk_widget_destroy, NULL);-+ + //Add queued file's with the same TTH.+ if (gtk_tree_selection_count_selected_rows(selection) == 1 && result)+ {+ StringList targets;+ targets.clear();+ TTHValue *tth = result->getTTH();+ if (tth != NULL)+ {+ QueueManager::getInstance()->getTargetsByRoot(targets, *tth);+ }+ else+ {+ //@todo: if no tth is found, search for same file size+// QueueManager::getInstance()->getTargetsBySize(targets, result->getSize(),+//what is needed here? "");+ }+ if (targets.size() > 0)+ {++ StringIter i = targets.begin();+ menuItem = gtk_menu_item_new_with_label(Text::toT(*i).c_str());+ g_object_set_data_full(G_OBJECT(menuItem), "foundTTH", + g_strdup(Text::toT(*i).c_str()), g_free);+ g_signal_connect(menuItem, "activate", G_CALLBACK+ (onDownloadToTTHClicked_gui), (gpointer)this);+ gtk_menu_shell_append(GTK_MENU_SHELL(getWidget("downloadMenu")),+ menuItem);++ menuItem = gtk_separator_menu_item_new();+ gtk_menu_shell_append(GTK_MENU_SHELL(getWidget("downloadMenu")), menuItem);+ }+ }+ + //Add favorites. StringPairList spl = FavoriteManager::getInstance()->getFavoriteDirs(); if (spl.size() > 0) {@@ -805,6 +839,30 @@ gtk_tree_path_free(path); } g_list_free(list);+ }+}++void Search::onDownloadToTTHClicked_gui(GtkMenuItem *item, gpointer data)+{+ Search *s = (Search *)data;+ GtkTreeIter iter;+ GtkTreePath *path;+ SearchResult *result;+ string dir;+ typedef Func2<Search, string, SearchResult *> F2;+ F2 *func;++ GtkTreeModel *m = GTK_TREE_MODEL(s->resultStore);++ dir = string((gchar *)g_object_get_data(G_OBJECT(item), "foundTTH"));+ if (gtk_tree_model_get_iter(m, &iter, path))+ {+ result = s->resultView.getValue<gpointer, SearchResult *>(&iter, "SearchResult");+ if (result)+ {+ func = new F2(s, &Search::download_client, dir, result);+ WulforManager::get()->dispatchClientFunc(func);+ } } } Index: linux/search.hh===================================================================RCS file: /cvsroot/linuxdcpp/linuxdcpp/linux/search.hh,vretrieving revision 1.14diff -u -r1.14 search.hh--- linux/search.hh 21 Aug 2006 15:52:37 -0000 1.14+++ linux/search.hh 13 Sep 2006 18:42:31 -0000@@ -64,6 +64,7 @@ static void onDownloadClicked_gui(GtkMenuItem *item, gpointer data); static void onDownloadFavoriteClicked_gui(GtkMenuItem *item, gpointer data); static void onDownloadToClicked_gui(GtkMenuItem *item, gpointer data);+ static void onDownloadToTTHClicked_gui(GtkMenuItem *item, gpointer data); static void onDownloadDirClicked_gui(GtkMenuItem *item, gpointer data); static void onDownloadFavoriteDirClicked_gui(GtkMenuItem *item, gpointer data); static void onDownloadDirToClicked_gui(GtkMenuItem *item, gpointer data);