diff options
Diffstat (limited to 'src/ui/message.c')
-rw-r--r-- | src/ui/message.c | 85 |
1 files changed, 56 insertions, 29 deletions
diff --git a/src/ui/message.c b/src/ui/message.c index c358e73..c1bd648 100644 --- a/src/ui/message.c +++ b/src/ui/message.c | |||
@@ -373,6 +373,10 @@ ui_message_new(MESSENGER_Application *app, | |||
373 | handle | 373 | handle |
374 | ); | 374 | ); |
375 | 375 | ||
376 | handle->whisper_box = GTK_WIDGET( | ||
377 | gtk_builder_get_object(handle->builder[1], "whisper_box") | ||
378 | ); | ||
379 | |||
376 | switch (handle->type) | 380 | switch (handle->type) |
377 | { | 381 | { |
378 | case UI_MESSAGE_STATUS: | 382 | case UI_MESSAGE_STATUS: |
@@ -425,44 +429,28 @@ ui_message_refresh(UI_MESSAGE_Handle *handle) | |||
425 | gtk_widget_hide(GTK_WIDGET(handle->read_receipt_image)); | 429 | gtk_widget_hide(GTK_WIDGET(handle->read_receipt_image)); |
426 | } | 430 | } |
427 | 431 | ||
428 | void | 432 | static void |
429 | ui_message_update(UI_MESSAGE_Handle *handle, | 433 | _update_file_message(UI_MESSAGE_Handle *handle, |
430 | MESSENGER_Application *app, | 434 | MESSENGER_Application *app, |
431 | const struct GNUNET_CHAT_Message *msg) | 435 | struct GNUNET_CHAT_File *file) |
432 | { | 436 | { |
433 | struct GNUNET_CHAT_File *file = NULL; | ||
434 | |||
435 | handle->msg = msg; | ||
436 | |||
437 | ui_message_refresh(handle); | ||
438 | |||
439 | if (msg) | ||
440 | { | ||
441 | file = GNUNET_CHAT_message_get_file(msg); | ||
442 | |||
443 | handle->timestamp = GNUNET_CHAT_message_get_timestamp(msg); | ||
444 | } | ||
445 | else | ||
446 | file = (struct GNUNET_CHAT_File*) ( | ||
447 | g_object_get_qdata(G_OBJECT(handle->message_box), app->quarks.data) | ||
448 | ); | ||
449 | |||
450 | if (!file) | ||
451 | return; | ||
452 | |||
453 | g_object_set_qdata(G_OBJECT(handle->message_box), app->quarks.data, file); | ||
454 | |||
455 | uint64_t size = GNUNET_CHAT_file_get_size(file); | 437 | uint64_t size = GNUNET_CHAT_file_get_size(file); |
456 | uint64_t local_size = GNUNET_CHAT_file_get_local_size(file); | 438 | uint64_t local_size = GNUNET_CHAT_file_get_local_size(file); |
457 | 439 | ||
440 | gboolean autostart_download = FALSE; | ||
441 | |||
458 | if ((size <= 0) || (size > local_size)) | 442 | if ((size <= 0) || (size > local_size)) |
459 | { | 443 | { |
460 | gtk_image_set_from_icon_name( | 444 | gtk_image_set_from_icon_name( |
461 | handle->file_status_image, | 445 | handle->file_status_image, |
462 | "folder-download-symbolic", | 446 | "folder-download-symbolic", |
463 | GTK_ICON_SIZE_BUTTON | 447 | GTK_ICON_SIZE_BUTTON |
464 | ); | 448 | ); |
465 | 449 | ||
450 | if ((app->settings.accept_all_files) && | ||
451 | (!GNUNET_CHAT_file_is_downloading(file))) | ||
452 | autostart_download = TRUE; | ||
453 | |||
466 | goto file_content; | 454 | goto file_content; |
467 | } | 455 | } |
468 | 456 | ||
@@ -524,6 +512,45 @@ file_content: | |||
524 | app->quarks.data, | 512 | app->quarks.data, |
525 | file | 513 | file |
526 | ); | 514 | ); |
515 | |||
516 | if (autostart_download) | ||
517 | gtk_button_clicked(handle->file_button); | ||
518 | } | ||
519 | |||
520 | void | ||
521 | ui_message_update(UI_MESSAGE_Handle *handle, | ||
522 | MESSENGER_Application *app, | ||
523 | const struct GNUNET_CHAT_Message *msg) | ||
524 | { | ||
525 | struct GNUNET_CHAT_File *file = NULL; | ||
526 | |||
527 | handle->msg = msg; | ||
528 | |||
529 | ui_message_refresh(handle); | ||
530 | |||
531 | if (msg) | ||
532 | { | ||
533 | if (GNUNET_CHAT_KIND_WHISPER == GNUNET_CHAT_message_get_kind(msg)) | ||
534 | gtk_stack_set_visible_child( | ||
535 | handle->content_stack, | ||
536 | GTK_WIDGET(handle->whisper_box) | ||
537 | ); | ||
538 | |||
539 | file = GNUNET_CHAT_message_get_file(msg); | ||
540 | |||
541 | handle->timestamp = GNUNET_CHAT_message_get_timestamp(msg); | ||
542 | |||
543 | g_object_set_qdata(G_OBJECT(handle->message_box), app->quarks.data, file); | ||
544 | } | ||
545 | else | ||
546 | file = (struct GNUNET_CHAT_File*) ( | ||
547 | g_object_get_qdata(G_OBJECT(handle->message_box), app->quarks.data) | ||
548 | ); | ||
549 | |||
550 | if (!file) | ||
551 | return; | ||
552 | |||
553 | _update_file_message(handle, app, file); | ||
527 | } | 554 | } |
528 | 555 | ||
529 | void | 556 | void |