impliment copy file name in search

Reported by lys on 2009-10-30
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LinuxDC++
Wishlist
Unassigned

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);

lys (lys) 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.

Download full text (3.9 KiB)

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 <email address hidden> 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->sortedFilt...

Read more...

lys (lys) wrote :

hi sorry but i should of remebered that posting code on here messes it up and attached a txt file dont suppose you could attach the relevant bits in a txt file could you please or just email it straight to me, i looked at it in my email client and still doesnt look right

lys (lys) wrote :

this is what i have so far

lys (lys) wrote :

dont suppose it matters but,ive been working the latest bzr an doing patches, my commit it stuck on this atm

Steven Sheehy (steven-sheehy) wrote :

You can use `bzr diff` to produce patches. I think Jakh was just say what changes to make to your local copy, he wasn't providing a patch. You should manually modify the code with his changes to get it to work.

lys (lys) wrote :

yes, ive recentley learnt how to, am still working on my code tho

lys (lys) wrote :

im 3/4 done on this but thanks to this bug tracker it prob after prob wen it comes to code, dont know why u guys went for this lp crap?

lys (lys) wrote :

in retrospect maybe i should not attempt to do these things on friday nights, anyways done.

lys (lys) wrote :

err strike that was a little to fast on that one it doesn't copy the name of the highlighted file it copys the word filenames

lys (lys) wrote :

this time its right

lys (lys) wrote :

oh & for the record : Tree is up to date at revision 340.

lys (lys) wrote :

no offense but if your going to ignore me at least close the bug please.

Razzloss (razzloss) wrote :

Well, I don't really know what to say about this.
The latest patch has way too much crap in it to be included in main trunk. And if anything like this would be included, it should be possible to copy all the other fields also. eg. sub-menu where to select field to copy (and the whole row).

--RZ

Steven Sheehy (steven-sheehy) wrote :

I think instead of adding functions for every column wanting to be copied in every list, we can simply create a copy sub-menu in treeview.hh that contains a generic way to copy all visible columns dynamically. It would also be nice if it could handle ctrl+c as well. This sub-menu can then be added to the regular menu inside the individual tabs.

Steven Sheehy (steven-sheehy) wrote :

I think the generalized approach in bug #473205 will resolve this. However, keeping this open so we remember to activate the copy menu in search tab as well.

Changed in linuxdcpp:
importance: Undecided → Wishlist
status: New → Confirmed
tags: added: copy search ui
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers