aboutsummaryrefslogtreecommitdiff
path: root/src/ui/message.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/message.c')
-rw-r--r--src/ui/message.c65
1 files changed, 58 insertions, 7 deletions
diff --git a/src/ui/message.c b/src/ui/message.c
index cacf666..4c89edb 100644
--- a/src/ui/message.c
+++ b/src/ui/message.c
@@ -27,7 +27,8 @@
27#include "../application.h" 27#include "../application.h"
28 28
29UI_MESSAGE_Handle* 29UI_MESSAGE_Handle*
30ui_message_new(UI_MESSAGE_Type type) 30ui_message_new(UI_MESSAGE_Type type,
31 UI_MESSAGE_ContentType content_type)
31{ 32{
32 UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); 33 UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle));
33 34
@@ -62,12 +63,16 @@ ui_message_new(UI_MESSAGE_Type type)
62 gtk_builder_get_object(handle->builder, "sender_label") 63 gtk_builder_get_object(handle->builder, "sender_label")
63 ); 64 );
64 65
65 handle->text_label = GTK_LABEL(
66 gtk_builder_get_object(handle->builder, "text_label")
67 );
68
69 if (UI_MESSAGE_STATUS == handle->type) 66 if (UI_MESSAGE_STATUS == handle->type)
70 { 67 {
68 handle->deny_revealer = GTK_REVEALER(
69 gtk_builder_get_object(handle->builder, "deny_revealer")
70 );
71
72 handle->accept_revealer = GTK_REVEALER(
73 gtk_builder_get_object(handle->builder, "accept_revealer")
74 );
75
71 handle->deny_button = GTK_BUTTON( 76 handle->deny_button = GTK_BUTTON(
72 gtk_builder_get_object(handle->builder, "deny_button") 77 gtk_builder_get_object(handle->builder, "deny_button")
73 ); 78 );
@@ -78,18 +83,64 @@ ui_message_new(UI_MESSAGE_Type type)
78 } 83 }
79 else 84 else
80 { 85 {
86 handle->deny_revealer = NULL;
87 handle->accept_revealer = NULL;
88
81 handle->deny_button = NULL; 89 handle->deny_button = NULL;
82 handle->accept_button = NULL; 90 handle->accept_button = NULL;
83 } 91 }
84 92
93 GtkContainer *content_box = GTK_CONTAINER(
94 gtk_builder_get_object(handle->builder, "content_box")
95 );
96
97 GtkBuilder *builder = gtk_builder_new_from_file(
98 "resources/ui/message_content.ui"
99 );
100
85 handle->timestamp_label = GTK_LABEL( 101 handle->timestamp_label = GTK_LABEL(
86 gtk_builder_get_object(handle->builder, "timestamp_label") 102 gtk_builder_get_object(builder, "timestamp_label")
87 ); 103 );
88 104
89 handle->read_receipt_image = GTK_IMAGE( 105 handle->read_receipt_image = GTK_IMAGE(
90 gtk_builder_get_object(handle->builder, "read_receipt_image") 106 gtk_builder_get_object(builder, "read_receipt_image")
107 );
108
109 handle->text_label = GTK_LABEL(
110 gtk_builder_get_object(builder, "text_label")
111 );
112
113 handle->file_revealer = GTK_REVEALER(
114 gtk_builder_get_object(builder, "file_revealer")
91 ); 115 );
92 116
117 handle->preview_drawing_area = GTK_DRAWING_AREA(
118 gtk_builder_get_object(builder, "preview_drawing_area")
119 );
120
121 switch (handle->type)
122 {
123 case UI_MESSAGE_STATUS:
124 gtk_widget_set_visible(GTK_WIDGET(handle->timestamp_label), FALSE);
125 break;
126 default:
127 break;
128 }
129
130 switch (content_type)
131 {
132 case UI_MESSAGE_CONTENT_FILE:
133 gtk_revealer_set_reveal_child(handle->file_revealer, TRUE);
134 break;
135 default:
136 break;
137 }
138
139 gtk_container_add(content_box, GTK_WIDGET(
140 gtk_builder_get_object(builder, "message_content_box")
141 ));
142
143 g_object_unref(builder);
93 return handle; 144 return handle;
94} 145}
95 146