diff options
Diffstat (limited to 'src/plugins/fs/fs.c')
-rw-r--r-- | src/plugins/fs/fs.c | 96 |
1 files changed, 95 insertions, 1 deletions
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c index 58ddc34a..1bf8877f 100644 --- a/src/plugins/fs/fs.c +++ b/src/plugins/fs/fs.c | |||
@@ -51,6 +51,17 @@ GtkTreeStore * download_summary; | |||
51 | 51 | ||
52 | GtkTreeStore * upload_summary; | 52 | GtkTreeStore * upload_summary; |
53 | 53 | ||
54 | /** | ||
55 | * Last right-click event coordinates in summary. | ||
56 | */ | ||
57 | static unsigned int last_x; | ||
58 | |||
59 | /** | ||
60 | * Last right-click event coordinates in summary. | ||
61 | */ | ||
62 | static unsigned int last_y; | ||
63 | |||
64 | |||
54 | static void * | 65 | static void * |
55 | saveEventProcessor(void * cls) { | 66 | saveEventProcessor(void * cls) { |
56 | const FSUI_Event * event = cls; | 67 | const FSUI_Event * event = cls; |
@@ -178,7 +189,7 @@ saveEventProcessor(void * cls) { | |||
178 | ret = fs_upload_started(event->data.UploadResumed.uc.pos, | 189 | ret = fs_upload_started(event->data.UploadResumed.uc.pos, |
179 | event->data.UploadResumed.uc.pcctx, | 190 | event->data.UploadResumed.uc.pcctx, |
180 | event->data.UploadResumed.filename, | 191 | event->data.UploadResumed.filename, |
181 | NULL, /* FIXME: maybe completed!? */ | 192 | event->data.UploadResumed.uri, |
182 | event->data.UploadResumed.total, | 193 | event->data.UploadResumed.total, |
183 | event->data.UploadResumed.completed, | 194 | event->data.UploadResumed.completed, |
184 | event->data.UploadResumed.state); | 195 | event->data.UploadResumed.state); |
@@ -271,6 +282,85 @@ static void on_search_summary_selection_changed(gpointer signal, | |||
271 | gtk_tree_selection_count_selected_rows(selection) > 0); | 282 | gtk_tree_selection_count_selected_rows(selection) > 0); |
272 | } | 283 | } |
273 | 284 | ||
285 | static int | ||
286 | on_upload_copy_uri_activate(void * cls, | ||
287 | GtkWidget * searchEntry) { | ||
288 | GtkTreeView * uploadList = cls; | ||
289 | GtkTreePath *path; | ||
290 | GtkTreeIter iter; | ||
291 | struct ECRS_URI * uri; | ||
292 | char * str; | ||
293 | GtkClipboard * clip; | ||
294 | |||
295 | path = NULL; | ||
296 | if (FALSE == gtk_tree_view_get_path_at_pos(uploadList, | ||
297 | last_x, | ||
298 | last_y, | ||
299 | &path, | ||
300 | NULL, | ||
301 | NULL, | ||
302 | NULL)) { | ||
303 | GE_BREAK(NULL, 0); | ||
304 | return FALSE; | ||
305 | } | ||
306 | if (FALSE == gtk_tree_model_get_iter(GTK_TREE_MODEL(upload_summary), | ||
307 | &iter, | ||
308 | path)) { | ||
309 | GE_BREAK(NULL, 0); | ||
310 | gtk_tree_path_free(path); | ||
311 | return FALSE; | ||
312 | } | ||
313 | gtk_tree_path_free(path); | ||
314 | uri = NULL; | ||
315 | gtk_tree_model_get(GTK_TREE_MODEL(upload_summary), | ||
316 | &iter, | ||
317 | UPLOAD_URISTRING, &str, | ||
318 | -1); | ||
319 | clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); | ||
320 | gtk_clipboard_set_text(clip, | ||
321 | str, | ||
322 | strlen(str)); | ||
323 | FREE(str); | ||
324 | return FALSE; | ||
325 | } | ||
326 | |||
327 | static gint | ||
328 | upload_click_handler(void * cls, | ||
329 | GdkEvent *event) { | ||
330 | GtkTreeView * uploadList = cls; | ||
331 | GtkMenu * menu; | ||
332 | GtkWidget * entry; | ||
333 | GdkEventButton * event_button; | ||
334 | |||
335 | g_return_val_if_fail (event != NULL, FALSE); | ||
336 | if (event->type != GDK_BUTTON_PRESS) | ||
337 | return FALSE; | ||
338 | event_button = (GdkEventButton *) event; | ||
339 | if (event_button->button != 3) | ||
340 | return FALSE; | ||
341 | last_x = event_button->x; | ||
342 | last_y = event_button->y; | ||
343 | entry = gtk_menu_item_new_with_label(_("_Copy URI to Clipboard")); | ||
344 | g_signal_connect_swapped (entry, | ||
345 | "activate", | ||
346 | G_CALLBACK(on_upload_copy_uri_activate), | ||
347 | uploadList); | ||
348 | gtk_label_set_use_underline(GTK_LABEL(gtk_bin_get_child(GTK_BIN(entry))), | ||
349 | TRUE); | ||
350 | gtk_widget_show(entry); | ||
351 | menu = GTK_MENU(gtk_menu_new()); | ||
352 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), | ||
353 | entry); | ||
354 | gtk_menu_popup (menu, | ||
355 | NULL, | ||
356 | NULL, | ||
357 | NULL, | ||
358 | NULL, | ||
359 | event_button->button, | ||
360 | event_button->time); | ||
361 | return TRUE; | ||
362 | } | ||
363 | |||
274 | /** | 364 | /** |
275 | * Setup the summary views (in particular the models | 365 | * Setup the summary views (in particular the models |
276 | * and the renderers). | 366 | * and the renderers). |
@@ -421,6 +511,10 @@ static void fs_summary_start() { | |||
421 | /* upload summary setup */ | 511 | /* upload summary setup */ |
422 | uploadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), | 512 | uploadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), |
423 | "activeUploadsList")); | 513 | "activeUploadsList")); |
514 | g_signal_connect_swapped (uploadList, | ||
515 | "button-press-event", | ||
516 | G_CALLBACK(upload_click_handler), | ||
517 | uploadList); | ||
424 | upload_summary = | 518 | upload_summary = |
425 | gtk_tree_store_new(UPLOAD_NUM, | 519 | gtk_tree_store_new(UPLOAD_NUM, |
426 | G_TYPE_STRING, /* filename */ | 520 | G_TYPE_STRING, /* filename */ |