diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-19 18:22:12 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-19 18:22:12 +0100 |
commit | be913f75546422d3e8e1c3b84d0ee66ae3e26602 (patch) | |
tree | e1af832857c23fd7dfd654df24db63ed42f5ce29 | |
parent | 2ed903525356c027d16fc3ae7cef16a7ee1775af (diff) | |
download | messenger-gtk-be913f75546422d3e8e1c3b84d0ee66ae3e26602.tar.gz messenger-gtk-be913f75546422d3e8e1c3b84d0ee66ae3e26602.zip |
Implemented switchable settings and added visible whispering
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | resources/ui/message_content.ui | 40 | ||||
-rw-r--r-- | resources/ui/settings.ui | 31 | ||||
-rw-r--r-- | src/application.h | 9 | ||||
-rw-r--r-- | src/chat/messenger.c | 1 | ||||
-rw-r--r-- | src/event.c | 13 | ||||
-rw-r--r-- | src/ui/message.c | 85 | ||||
-rw-r--r-- | src/ui/message.h | 2 | ||||
-rw-r--r-- | src/ui/settings.c | 130 | ||||
-rw-r--r-- | src/ui/settings.h | 19 |
9 files changed, 287 insertions, 43 deletions
diff --git a/resources/ui/message_content.ui b/resources/ui/message_content.ui index 9c2bd22..8fb06d1 100644 --- a/resources/ui/message_content.ui +++ b/resources/ui/message_content.ui | |||
@@ -173,6 +173,46 @@ Author: Tobias Frisch | |||
173 | <property name="position">2</property> | 173 | <property name="position">2</property> |
174 | </packing> | 174 | </packing> |
175 | </child> | 175 | </child> |
176 | <child> | ||
177 | <object class="GtkBox" id="whisper_box"> | ||
178 | <property name="visible">True</property> | ||
179 | <property name="can-focus">False</property> | ||
180 | <property name="spacing">4</property> | ||
181 | <child> | ||
182 | <object class="GtkImage"> | ||
183 | <property name="visible">True</property> | ||
184 | <property name="can-focus">False</property> | ||
185 | <property name="icon-name">face-shutmouth-symbolic</property> | ||
186 | </object> | ||
187 | <packing> | ||
188 | <property name="expand">False</property> | ||
189 | <property name="fill">True</property> | ||
190 | <property name="position">0</property> | ||
191 | </packing> | ||
192 | </child> | ||
193 | <child> | ||
194 | <object class="GtkLabel"> | ||
195 | <property name="visible">True</property> | ||
196 | <property name="can-focus">False</property> | ||
197 | <property name="label" translatable="yes">whispering...</property> | ||
198 | <property name="xalign">0</property> | ||
199 | <attributes> | ||
200 | <attribute name="style" value="italic"/> | ||
201 | </attributes> | ||
202 | </object> | ||
203 | <packing> | ||
204 | <property name="expand">True</property> | ||
205 | <property name="fill">True</property> | ||
206 | <property name="pack-type">end</property> | ||
207 | <property name="position">1</property> | ||
208 | </packing> | ||
209 | </child> | ||
210 | </object> | ||
211 | <packing> | ||
212 | <property name="name">whisper_page</property> | ||
213 | <property name="position">3</property> | ||
214 | </packing> | ||
215 | </child> | ||
176 | </object> | 216 | </object> |
177 | <packing> | 217 | <packing> |
178 | <property name="expand">True</property> | 218 | <property name="expand">True</property> |
diff --git a/resources/ui/settings.ui b/resources/ui/settings.ui index bf14bd1..d2622b9 100644 --- a/resources/ui/settings.ui +++ b/resources/ui/settings.ui | |||
@@ -107,6 +107,7 @@ Author: Tobias Frisch | |||
107 | <child> | 107 | <child> |
108 | <object class="GtkSwitch"> | 108 | <object class="GtkSwitch"> |
109 | <property name="visible">True</property> | 109 | <property name="visible">True</property> |
110 | <property name="sensitive">False</property> | ||
110 | <property name="can-focus">True</property> | 111 | <property name="can-focus">True</property> |
111 | </object> | 112 | </object> |
112 | <packing> | 113 | <packing> |
@@ -148,6 +149,7 @@ Author: Tobias Frisch | |||
148 | <child> | 149 | <child> |
149 | <object class="GtkSwitch"> | 150 | <object class="GtkSwitch"> |
150 | <property name="visible">True</property> | 151 | <property name="visible">True</property> |
152 | <property name="sensitive">False</property> | ||
151 | <property name="can-focus">True</property> | 153 | <property name="can-focus">True</property> |
152 | </object> | 154 | </object> |
153 | <packing> | 155 | <packing> |
@@ -202,7 +204,7 @@ Author: Tobias Frisch | |||
202 | </packing> | 204 | </packing> |
203 | </child> | 205 | </child> |
204 | <child> | 206 | <child> |
205 | <object class="GtkSwitch"> | 207 | <object class="GtkSwitch" id="enable_notifications_switch"> |
206 | <property name="visible">True</property> | 208 | <property name="visible">True</property> |
207 | <property name="can-focus">True</property> | 209 | <property name="can-focus">True</property> |
208 | </object> | 210 | </object> |
@@ -245,6 +247,7 @@ Author: Tobias Frisch | |||
245 | <child> | 247 | <child> |
246 | <object class="GtkSwitch"> | 248 | <object class="GtkSwitch"> |
247 | <property name="visible">True</property> | 249 | <property name="visible">True</property> |
250 | <property name="sensitive">False</property> | ||
248 | <property name="can-focus">True</property> | 251 | <property name="can-focus">True</property> |
249 | </object> | 252 | </object> |
250 | <packing> | 253 | <packing> |
@@ -322,7 +325,7 @@ Author: Tobias Frisch | |||
322 | </packing> | 325 | </packing> |
323 | </child> | 326 | </child> |
324 | <child> | 327 | <child> |
325 | <object class="GtkSwitch"> | 328 | <object class="GtkSwitch" id="read_receipts_switch"> |
326 | <property name="visible">True</property> | 329 | <property name="visible">True</property> |
327 | <property name="can-focus">True</property> | 330 | <property name="can-focus">True</property> |
328 | </object> | 331 | </object> |
@@ -363,7 +366,7 @@ Author: Tobias Frisch | |||
363 | </packing> | 366 | </packing> |
364 | </child> | 367 | </child> |
365 | <child> | 368 | <child> |
366 | <object class="GtkSwitch"> | 369 | <object class="GtkSwitch" id="whispering_switch"> |
367 | <property name="visible">True</property> | 370 | <property name="visible">True</property> |
368 | <property name="can-focus">True</property> | 371 | <property name="can-focus">True</property> |
369 | </object> | 372 | </object> |
@@ -412,7 +415,7 @@ Author: Tobias Frisch | |||
412 | </packing> | 415 | </packing> |
413 | </child> | 416 | </child> |
414 | <child> | 417 | <child> |
415 | <object class="GtkComboBox"> | 418 | <object class="GtkComboBox" id="auto_delete_combo_box"> |
416 | <property name="visible">True</property> | 419 | <property name="visible">True</property> |
417 | <property name="can-focus">False</property> | 420 | <property name="can-focus">False</property> |
418 | <property name="model">delay_store</property> | 421 | <property name="model">delay_store</property> |
@@ -470,6 +473,7 @@ Author: Tobias Frisch | |||
470 | <child> | 473 | <child> |
471 | <object class="GtkComboBox"> | 474 | <object class="GtkComboBox"> |
472 | <property name="visible">True</property> | 475 | <property name="visible">True</property> |
476 | <property name="sensitive">False</property> | ||
473 | <property name="can-focus">False</property> | 477 | <property name="can-focus">False</property> |
474 | <property name="model">delay_store</property> | 478 | <property name="model">delay_store</property> |
475 | <property name="active">0</property> | 479 | <property name="active">0</property> |
@@ -506,6 +510,7 @@ Author: Tobias Frisch | |||
506 | <object class="GtkButton"> | 510 | <object class="GtkButton"> |
507 | <property name="label" translatable="yes">Clear all history</property> | 511 | <property name="label" translatable="yes">Clear all history</property> |
508 | <property name="visible">True</property> | 512 | <property name="visible">True</property> |
513 | <property name="sensitive">False</property> | ||
509 | <property name="can-focus">True</property> | 514 | <property name="can-focus">True</property> |
510 | <property name="receives-default">True</property> | 515 | <property name="receives-default">True</property> |
511 | <style> | 516 | <style> |
@@ -564,7 +569,7 @@ Author: Tobias Frisch | |||
564 | </packing> | 569 | </packing> |
565 | </child> | 570 | </child> |
566 | <child> | 571 | <child> |
567 | <object class="GtkSwitch"> | 572 | <object class="GtkSwitch" id="auto_accept_invitations_switch"> |
568 | <property name="visible">True</property> | 573 | <property name="visible">True</property> |
569 | <property name="can-focus">True</property> | 574 | <property name="can-focus">True</property> |
570 | </object> | 575 | </object> |
@@ -606,7 +611,7 @@ Author: Tobias Frisch | |||
606 | </packing> | 611 | </packing> |
607 | </child> | 612 | </child> |
608 | <child> | 613 | <child> |
609 | <object class="GtkComboBox"> | 614 | <object class="GtkComboBox" id="delete_invitations_combo_box"> |
610 | <property name="visible">True</property> | 615 | <property name="visible">True</property> |
611 | <property name="can-focus">False</property> | 616 | <property name="can-focus">False</property> |
612 | <property name="model">delay_store</property> | 617 | <property name="model">delay_store</property> |
@@ -641,7 +646,7 @@ Author: Tobias Frisch | |||
641 | <property name="visible">True</property> | 646 | <property name="visible">True</property> |
642 | <property name="can-focus">False</property> | 647 | <property name="can-focus">False</property> |
643 | <child> | 648 | <child> |
644 | <object class="GtkButton"> | 649 | <object class="GtkButton" id="delete_invitations_button"> |
645 | <property name="label" translatable="yes">Delete all invitations</property> | 650 | <property name="label" translatable="yes">Delete all invitations</property> |
646 | <property name="visible">True</property> | 651 | <property name="visible">True</property> |
647 | <property name="can-focus">True</property> | 652 | <property name="can-focus">True</property> |
@@ -694,7 +699,7 @@ Author: Tobias Frisch | |||
694 | </packing> | 699 | </packing> |
695 | </child> | 700 | </child> |
696 | <child> | 701 | <child> |
697 | <object class="GtkSwitch"> | 702 | <object class="GtkSwitch" id="auto_accept_files_switch"> |
698 | <property name="visible">True</property> | 703 | <property name="visible">True</property> |
699 | <property name="can-focus">True</property> | 704 | <property name="can-focus">True</property> |
700 | </object> | 705 | </object> |
@@ -736,7 +741,7 @@ Author: Tobias Frisch | |||
736 | </packing> | 741 | </packing> |
737 | </child> | 742 | </child> |
738 | <child> | 743 | <child> |
739 | <object class="GtkFileChooserButton"> | 744 | <object class="GtkFileChooserButton" id="download_folder_button"> |
740 | <property name="visible">True</property> | 745 | <property name="visible">True</property> |
741 | <property name="can-focus">False</property> | 746 | <property name="can-focus">False</property> |
742 | <property name="title" translatable="yes">Select download folder</property> | 747 | <property name="title" translatable="yes">Select download folder</property> |
@@ -778,7 +783,7 @@ Author: Tobias Frisch | |||
778 | </packing> | 783 | </packing> |
779 | </child> | 784 | </child> |
780 | <child> | 785 | <child> |
781 | <object class="GtkComboBox"> | 786 | <object class="GtkComboBox" id="delete_files_combo_box"> |
782 | <property name="visible">True</property> | 787 | <property name="visible">True</property> |
783 | <property name="can-focus">False</property> | 788 | <property name="can-focus">False</property> |
784 | <property name="model">delay_store</property> | 789 | <property name="model">delay_store</property> |
@@ -813,7 +818,7 @@ Author: Tobias Frisch | |||
813 | <property name="visible">True</property> | 818 | <property name="visible">True</property> |
814 | <property name="can-focus">False</property> | 819 | <property name="can-focus">False</property> |
815 | <child> | 820 | <child> |
816 | <object class="GtkButton"> | 821 | <object class="GtkButton" id="delete_files_button"> |
817 | <property name="label" translatable="yes">Delete all files</property> | 822 | <property name="label" translatable="yes">Delete all files</property> |
818 | <property name="visible">True</property> | 823 | <property name="visible">True</property> |
819 | <property name="can-focus">True</property> | 824 | <property name="can-focus">True</property> |
@@ -867,7 +872,7 @@ Author: Tobias Frisch | |||
867 | </packing> | 872 | </packing> |
868 | </child> | 873 | </child> |
869 | <child> | 874 | <child> |
870 | <object class="GtkComboBox"> | 875 | <object class="GtkComboBox" id="leave_chats_combo_box"> |
871 | <property name="visible">True</property> | 876 | <property name="visible">True</property> |
872 | <property name="can-focus">False</property> | 877 | <property name="can-focus">False</property> |
873 | <property name="model">delay_store</property> | 878 | <property name="model">delay_store</property> |
@@ -902,7 +907,7 @@ Author: Tobias Frisch | |||
902 | <property name="visible">True</property> | 907 | <property name="visible">True</property> |
903 | <property name="can-focus">False</property> | 908 | <property name="can-focus">False</property> |
904 | <child> | 909 | <child> |
905 | <object class="GtkButton"> | 910 | <object class="GtkButton" id="leave_chats_button"> |
906 | <property name="label" translatable="yes">Leave all chats</property> | 911 | <property name="label" translatable="yes">Leave all chats</property> |
907 | <property name="visible">True</property> | 912 | <property name="visible">True</property> |
908 | <property name="can-focus">True</property> | 913 | <property name="can-focus">True</property> |
diff --git a/src/application.h b/src/application.h index 8dc92a2..1fd14be 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -114,9 +114,16 @@ typedef struct MESSENGER_Application | |||
114 | struct { | 114 | struct { |
115 | gboolean mobile_design; | 115 | gboolean mobile_design; |
116 | gboolean hide_delete_dialog; | 116 | gboolean hide_delete_dialog; |
117 | |||
117 | gboolean disable_notifications; | 118 | gboolean disable_notifications; |
119 | |||
120 | gboolean send_read_receipts; | ||
121 | gboolean show_whispering; | ||
122 | |||
123 | gboolean accept_all_invitations; | ||
118 | gboolean accept_all_files; | 124 | gboolean accept_all_files; |
119 | gboolean accept_all_invites; | 125 | |
126 | gchar *download_folder_path; | ||
120 | } settings; | 127 | } settings; |
121 | } MESSENGER_Application; | 128 | } MESSENGER_Application; |
122 | 129 | ||
diff --git a/src/chat/messenger.c b/src/chat/messenger.c index f5aab78..14b1cb6 100644 --- a/src/chat/messenger.c +++ b/src/chat/messenger.c | |||
@@ -150,6 +150,7 @@ _chat_messenger_message(void *cls, | |||
150 | } | 150 | } |
151 | case GNUNET_CHAT_KIND_TEXT: | 151 | case GNUNET_CHAT_KIND_TEXT: |
152 | case GNUNET_CHAT_KIND_FILE: | 152 | case GNUNET_CHAT_KIND_FILE: |
153 | case GNUNET_CHAT_KIND_WHISPER: | ||
153 | { | 154 | { |
154 | application_call_message_event( | 155 | application_call_message_event( |
155 | app, | 156 | app, |
diff --git a/src/event.c b/src/event.c index 486d724..0f71697 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -521,6 +521,9 @@ event_invitation(MESSENGER_Application *app, | |||
521 | 521 | ||
522 | ui_chat_add_message(handle->chat, app, message); | 522 | ui_chat_add_message(handle->chat, app, message); |
523 | 523 | ||
524 | if (app->settings.accept_all_invitations) | ||
525 | gtk_button_clicked(message->accept_button); | ||
526 | |||
524 | enqueue_chat_entry_update(handle); | 527 | enqueue_chat_entry_update(handle); |
525 | } | 528 | } |
526 | 529 | ||
@@ -534,9 +537,19 @@ event_receive_message(MESSENGER_Application *app, | |||
534 | if (!handle) | 537 | if (!handle) |
535 | return; | 538 | return; |
536 | 539 | ||
540 | const gboolean whispering = ( | ||
541 | GNUNET_CHAT_KIND_WHISPER == GNUNET_CHAT_message_get_kind(msg) | ||
542 | ); | ||
543 | |||
544 | if ((whispering) && (!(app->settings.show_whispering))) | ||
545 | return; | ||
546 | |||
537 | const int sent = GNUNET_CHAT_message_is_sent(msg); | 547 | const int sent = GNUNET_CHAT_message_is_sent(msg); |
538 | const gchar *text = GNUNET_CHAT_message_get_text(msg); | 548 | const gchar *text = GNUNET_CHAT_message_get_text(msg); |
539 | 549 | ||
550 | if (whispering) | ||
551 | text = _("whispers..."); | ||
552 | |||
540 | if ((text) && (!(*text))) | 553 | if ((text) && (!(*text))) |
541 | goto skip_message; | 554 | goto skip_message; |
542 | 555 | ||
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 |
diff --git a/src/ui/message.h b/src/ui/message.h index befe536..f86ac3b 100644 --- a/src/ui/message.h +++ b/src/ui/message.h | |||
@@ -75,6 +75,8 @@ typedef struct UI_MESSAGE_Handle | |||
75 | 75 | ||
76 | GtkDrawingArea *preview_drawing_area; | 76 | GtkDrawingArea *preview_drawing_area; |
77 | 77 | ||
78 | GtkWidget *whisper_box; | ||
79 | |||
78 | GdkPixbuf *preview_image; | 80 | GdkPixbuf *preview_image; |
79 | GdkPixbufAnimation *preview_animation; | 81 | GdkPixbufAnimation *preview_animation; |
80 | GdkPixbufAnimationIter *preview_animation_iter; | 82 | GdkPixbufAnimationIter *preview_animation_iter; |
diff --git a/src/ui/settings.c b/src/ui/settings.c index 7583941..87812f2 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -26,6 +26,24 @@ | |||
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | static gboolean | ||
30 | handle_general_switch_state(UNUSED GtkSwitch *widget, | ||
31 | gboolean state, | ||
32 | gpointer user_data) | ||
33 | { | ||
34 | gboolean *setting = (gboolean*) user_data; | ||
35 | *setting = state; | ||
36 | return FALSE; | ||
37 | } | ||
38 | |||
39 | static gboolean | ||
40 | handle_inverted_switch_state(GtkSwitch *widget, | ||
41 | gboolean state, | ||
42 | gpointer user_data) | ||
43 | { | ||
44 | return handle_general_switch_state(widget, !state, user_data); | ||
45 | } | ||
46 | |||
29 | static void | 47 | static void |
30 | handle_dialog_destroy(UNUSED GtkWidget *window, | 48 | handle_dialog_destroy(UNUSED GtkWidget *window, |
31 | gpointer user_data) | 49 | gpointer user_data) |
@@ -50,6 +68,118 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
50 | GTK_WINDOW(app->ui.messenger.main_window) | 68 | GTK_WINDOW(app->ui.messenger.main_window) |
51 | ); | 69 | ); |
52 | 70 | ||
71 | handle->enable_notifications_switch = GTK_SWITCH( | ||
72 | gtk_builder_get_object(handle->builder, "enable_notifications_switch") | ||
73 | ); | ||
74 | |||
75 | gtk_switch_set_active( | ||
76 | handle->enable_notifications_switch, | ||
77 | !(app->settings.disable_notifications) | ||
78 | ); | ||
79 | |||
80 | g_signal_connect( | ||
81 | handle->enable_notifications_switch, | ||
82 | "state-set", | ||
83 | G_CALLBACK(handle_inverted_switch_state), | ||
84 | &(app->settings.disable_notifications) | ||
85 | ); | ||
86 | |||
87 | handle->read_receipts_switch = GTK_SWITCH( | ||
88 | gtk_builder_get_object(handle->builder, "read_receipts_switch") | ||
89 | ); | ||
90 | |||
91 | gtk_switch_set_active( | ||
92 | handle->read_receipts_switch, | ||
93 | app->settings.send_read_receipts | ||
94 | ); | ||
95 | |||
96 | g_signal_connect( | ||
97 | handle->read_receipts_switch, | ||
98 | "state-set", | ||
99 | G_CALLBACK(handle_general_switch_state), | ||
100 | &(app->settings.send_read_receipts) | ||
101 | ); | ||
102 | |||
103 | handle->whispering_switch = GTK_SWITCH( | ||
104 | gtk_builder_get_object(handle->builder, "whispering_switch") | ||
105 | ); | ||
106 | |||
107 | gtk_switch_set_active( | ||
108 | handle->whispering_switch, | ||
109 | app->settings.show_whispering | ||
110 | ); | ||
111 | |||
112 | g_signal_connect( | ||
113 | handle->whispering_switch, | ||
114 | "state-set", | ||
115 | G_CALLBACK(handle_general_switch_state), | ||
116 | &(app->settings.show_whispering) | ||
117 | ); | ||
118 | |||
119 | handle->auto_delete_combo_box = GTK_COMBO_BOX( | ||
120 | gtk_builder_get_object(handle->builder, "auto_delete_combo_box") | ||
121 | ); | ||
122 | |||
123 | handle->auto_accept_invitations_switch = GTK_SWITCH( | ||
124 | gtk_builder_get_object(handle->builder, "auto_accept_invitations_switch") | ||
125 | ); | ||
126 | |||
127 | gtk_switch_set_active( | ||
128 | handle->auto_accept_invitations_switch, | ||
129 | app->settings.accept_all_invitations | ||
130 | ); | ||
131 | |||
132 | g_signal_connect( | ||
133 | handle->auto_accept_invitations_switch, | ||
134 | "state-set", | ||
135 | G_CALLBACK(handle_general_switch_state), | ||
136 | &(app->settings.accept_all_invitations) | ||
137 | ); | ||
138 | |||
139 | handle->delete_invitations_combo_box = GTK_COMBO_BOX( | ||
140 | gtk_builder_get_object(handle->builder, "delete_invitations_combo_box") | ||
141 | ); | ||
142 | |||
143 | handle->delete_invitations_button = GTK_BUTTON( | ||
144 | gtk_builder_get_object(handle->builder, "delete_invitations_button") | ||
145 | ); | ||
146 | |||
147 | handle->auto_accept_files_switch = GTK_SWITCH( | ||
148 | gtk_builder_get_object(handle->builder, "auto_accept_files_switch") | ||
149 | ); | ||
150 | |||
151 | gtk_switch_set_active( | ||
152 | handle->auto_accept_files_switch, | ||
153 | app->settings.accept_all_files | ||
154 | ); | ||
155 | |||
156 | g_signal_connect( | ||
157 | handle->auto_accept_files_switch, | ||
158 | "state-set", | ||
159 | G_CALLBACK(handle_general_switch_state), | ||
160 | &(app->settings.accept_all_files) | ||
161 | ); | ||
162 | |||
163 | handle->download_folder_button = GTK_FILE_CHOOSER_BUTTON( | ||
164 | gtk_builder_get_object(handle->builder, "download_folder_button") | ||
165 | ); | ||
166 | |||
167 | handle->delete_files_combo_box = GTK_COMBO_BOX( | ||
168 | gtk_builder_get_object(handle->builder, "delete_files_combo_box") | ||
169 | ); | ||
170 | |||
171 | handle->delete_files_button = GTK_BUTTON( | ||
172 | gtk_builder_get_object(handle->builder, "delete_files_button") | ||
173 | ); | ||
174 | |||
175 | handle->leave_chats_combo_box = GTK_COMBO_BOX( | ||
176 | gtk_builder_get_object(handle->builder, "leave_chats_combo_box") | ||
177 | ); | ||
178 | |||
179 | handle->leave_chats_button = GTK_BUTTON( | ||
180 | gtk_builder_get_object(handle->builder, "leave_chats_button") | ||
181 | ); | ||
182 | |||
53 | g_signal_connect( | 183 | g_signal_connect( |
54 | handle->dialog, | 184 | handle->dialog, |
55 | "destroy", | 185 | "destroy", |
diff --git a/src/ui/settings.h b/src/ui/settings.h index 733efed..b2b7486 100644 --- a/src/ui/settings.h +++ b/src/ui/settings.h | |||
@@ -31,6 +31,25 @@ typedef struct UI_SETTINGS_Handle | |||
31 | { | 31 | { |
32 | GtkBuilder *builder; | 32 | GtkBuilder *builder; |
33 | HdyPreferencesWindow *dialog; | 33 | HdyPreferencesWindow *dialog; |
34 | |||
35 | GtkSwitch *enable_notifications_switch; | ||
36 | |||
37 | GtkSwitch *read_receipts_switch; | ||
38 | GtkSwitch *whispering_switch; | ||
39 | |||
40 | GtkComboBox *auto_delete_combo_box; | ||
41 | |||
42 | GtkSwitch *auto_accept_invitations_switch; | ||
43 | GtkComboBox *delete_invitations_combo_box; | ||
44 | GtkButton *delete_invitations_button; | ||
45 | |||
46 | GtkSwitch *auto_accept_files_switch; | ||
47 | GtkFileChooserButton *download_folder_button; | ||
48 | GtkComboBox *delete_files_combo_box; | ||
49 | GtkButton *delete_files_button; | ||
50 | |||
51 | GtkComboBox *leave_chats_combo_box; | ||
52 | GtkButton *leave_chats_button; | ||
34 | } UI_SETTINGS_Handle; | 53 | } UI_SETTINGS_Handle; |
35 | 54 | ||
36 | void | 55 | void |