← Back to team overview

linuxdcpp-team team mailing list archive

Re: [Bug 464185] Re: impliment copy file name in search

 

You need to change the implementation in

  void Search::oncopyFileNameClicked_gui

i.e. Change `magnets` to `filenames`

1. Change
  string magnets, magnet, filename, tth;
to
  string filenames, magnet, filename, tth;

2. Change
                                         if (!magnet.empty())
                                       {
                                               if (!magnets.empty())
                                                       magnets += '\n';
                                               magnets += magnet;
                                       }
to
                                         if (!filename.empty())
                                       {
                                               if (!filenames.empty())
                                                       filenames += '\n';
                                               filenames += filename;
                                       }

3. Last..
                 if (!magnets.empty())

gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
magnets.c_str(), magnets.length());

to
                 if (!filenames.empty())

gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
filenames.c_str(), filenames.length());

Hope that helps. I needed this too, for posting magnets and filenames
on our intranet website. Without this, I would have to extract the
filename from the magnet. :(

On 10/30/09, lys <laurieparry76@xxxxxxxxx> wrote:
> obv it doesnt need the magnet stuff just used that as uncertain as to
> which bits to call to just call the actual filename itself, oh and i
> missed the opening <child> in the glad bit but only in this report, not
> in my notes.
>
> --
> impliment copy file name in search
> https://bugs.launchpad.net/bugs/464185
> You received this bug notification because you are subscribed to
> LinuxDC++.
>
> Status in Linux DC++: New
>
> Bug description:
> can someone give me help on how to impliment the above mentioned item in the
> search please or impliment it in the client as can be useful to be able just
> copy filenames from the search window?
>
> am uncertain as how to complete this: ?
>
> glade/search.glade:
>
>       <widget class="GtkMenuItem" id="copyFileName">
>         <property name="visible">True</property>
>         <property name="label" translatable="yes">_Copy FileName</property>
>         <property name="use_underline">True</property>
>       </widget>
>     </child>
>
>
>
> linux/search.cc:
>
> 	g_signal_connect(getWidget("copyFileName"), "activate",
> G_CALLBACK(onCopyFileNameClicked_gui), (gpointer)this);
>
>
>
> void Search::oncopyFileNameClicked_gui(GtkMenuItem* item, gpointer data)
> {
> 	Search *s = (Search *)data;
>
> 	if (gtk_tree_selection_count_selected_rows(s->selection) > 0)
> 	{
> 		int64_t size;
> 		string magnets, magnet, filename, tth;
> 		GtkTreeIter iter;
> 		GtkTreePath *path;
> 		GList *list = gtk_tree_selection_get_selected_rows(s->selection, NULL);
>
> 		for (GList *i = list; i; i = i->next)
> 		{
> 			path = (GtkTreePath *)i->data;
> 			if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
> 			{
> 				bool parent = gtk_tree_model_iter_has_child(s->sortedFilterModel,
> &iter);
>
> 				do
> 				{
> 					filename = s->resultView.getString(&iter, "Filename");
> 					size = s->resultView.getValue<int64_t>(&iter, "Real Size");
> 					tth = s->resultView.getString(&iter, "TTH");
> 					magnet = WulforUtil::makeMagnet(filename, size, tth);
>
> 					if (!magnet.empty())
> 					{
> 						if (!magnets.empty())
> 							magnets += '\n';
> 						magnets += magnet;
> 					}
> 				}
> 				while (parent && WulforUtil::getNextIter_gui(s->sortedFilterModel,
> &iter, TRUE, FALSE));
> 			}
> 			gtk_tree_path_free(path);
> 		}
> 		g_list_free(list);
>
> 		if (!magnets.empty())
> 			gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
> magnets.c_str(), magnets.length());
> 	}
> }
>
>
>
>
>
> linux/search.hh:
>
> 		static void onCopyFileNameClicked_gui(GtkMenuItem *item, gpointer data);
>

-- 
impliment copy file name in search
https://bugs.launchpad.net/bugs/464185
You received this bug notification because you are a member of LinuxDC++
Team, which is subscribed to LinuxDC++.

Status in Linux DC++: New

Bug description:
can someone give me help on how to impliment the above mentioned item in the search please or impliment it in the client as can be useful to be able just copy filenames from the search window?

am uncertain as how to complete this: ?

glade/search.glade:

      <widget class="GtkMenuItem" id="copyFileName">
        <property name="visible">True</property>
        <property name="label" translatable="yes">_Copy FileName</property>
        <property name="use_underline">True</property>
      </widget>
    </child>



linux/search.cc:

	g_signal_connect(getWidget("copyFileName"), "activate", G_CALLBACK(onCopyFileNameClicked_gui), (gpointer)this);



void Search::oncopyFileNameClicked_gui(GtkMenuItem* item, gpointer data)
{
	Search *s = (Search *)data;

	if (gtk_tree_selection_count_selected_rows(s->selection) > 0)
	{
		int64_t size;
		string magnets, magnet, filename, tth;
		GtkTreeIter iter;
		GtkTreePath *path;
		GList *list = gtk_tree_selection_get_selected_rows(s->selection, NULL);

		for (GList *i = list; i; i = i->next)
		{
			path = (GtkTreePath *)i->data;
			if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
			{
				bool parent = gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter);

				do
				{
					filename = s->resultView.getString(&iter, "Filename");
					size = s->resultView.getValue<int64_t>(&iter, "Real Size");
					tth = s->resultView.getString(&iter, "TTH");
					magnet = WulforUtil::makeMagnet(filename, size, tth);

					if (!magnet.empty())
					{
						if (!magnets.empty())
							magnets += '\n';
						magnets += magnet;
					}
				}
				while (parent && WulforUtil::getNextIter_gui(s->sortedFilterModel, &iter, TRUE, FALSE));
			}
			gtk_tree_path_free(path);
		}
		g_list_free(list);

		if (!magnets.empty())
			gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), magnets.c_str(), magnets.length());
	}
}





linux/search.hh:

		static void onCopyFileNameClicked_gui(GtkMenuItem *item, gpointer data);



References