diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/message.c | 42 | ||||
-rw-r--r-- | src/ui/message.h | 14 |
2 files changed, 49 insertions, 7 deletions
diff --git a/src/ui/message.c b/src/ui/message.c index f89f5ef..def4524 100644 --- a/src/ui/message.c +++ b/src/ui/message.c | |||
@@ -28,14 +28,28 @@ | |||
28 | 28 | ||
29 | UI_MESSAGE_Handle* | 29 | UI_MESSAGE_Handle* |
30 | ui_message_new(MESSENGER_Application *app, | 30 | ui_message_new(MESSENGER_Application *app, |
31 | bool sent) | 31 | UI_MESSAGE_Type type) |
32 | { | 32 | { |
33 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); | 33 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); |
34 | 34 | ||
35 | if (sent) | 35 | handle->type = type; |
36 | handle->builder = gtk_builder_new_from_file("resources/ui/message-sent.ui"); | 36 | |
37 | else | 37 | const char *ui_builder_file; |
38 | handle->builder = gtk_builder_new_from_file("resources/ui/message.ui"); | 38 | |
39 | switch (handle->type) | ||
40 | { | ||
41 | case UI_MESSAGE_SENT: | ||
42 | ui_builder_file = "resources/ui/message-sent.ui"; | ||
43 | break; | ||
44 | case UI_MESSAGE_STATUS: | ||
45 | ui_builder_file = "resources/ui/message-status.ui"; | ||
46 | break; | ||
47 | default: | ||
48 | ui_builder_file = "resources/ui/message.ui"; | ||
49 | break; | ||
50 | } | ||
51 | |||
52 | handle->builder = gtk_builder_new_from_file(ui_builder_file); | ||
39 | 53 | ||
40 | handle->message_box = GTK_WIDGET( | 54 | handle->message_box = GTK_WIDGET( |
41 | gtk_builder_get_object(handle->builder, "message_box") | 55 | gtk_builder_get_object(handle->builder, "message_box") |
@@ -49,7 +63,7 @@ ui_message_new(MESSENGER_Application *app, | |||
49 | gtk_builder_get_object(handle->builder, "sender_label") | 63 | gtk_builder_get_object(handle->builder, "sender_label") |
50 | ); | 64 | ); |
51 | 65 | ||
52 | if (sent) | 66 | if (UI_MESSAGE_SENT == handle->type) |
53 | { | 67 | { |
54 | const char *sender = GNUNET_CHAT_get_name(app->chat.messenger.handle); | 68 | const char *sender = GNUNET_CHAT_get_name(app->chat.messenger.handle); |
55 | 69 | ||
@@ -61,6 +75,22 @@ ui_message_new(MESSENGER_Application *app, | |||
61 | gtk_builder_get_object(handle->builder, "text_label") | 75 | gtk_builder_get_object(handle->builder, "text_label") |
62 | ); | 76 | ); |
63 | 77 | ||
78 | if (UI_MESSAGE_STATUS == handle->type) | ||
79 | { | ||
80 | handle->deny_button = GTK_BUTTON( | ||
81 | gtk_builder_get_object(handle->builder, "deny_button") | ||
82 | ); | ||
83 | |||
84 | handle->accept_button = GTK_BUTTON( | ||
85 | gtk_builder_get_object(handle->builder, "accept_button") | ||
86 | ); | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | handle->deny_button = NULL; | ||
91 | handle->accept_button = NULL; | ||
92 | } | ||
93 | |||
64 | handle->timestamp_label = GTK_LABEL( | 94 | handle->timestamp_label = GTK_LABEL( |
65 | gtk_builder_get_object(handle->builder, "timestamp_label") | 95 | gtk_builder_get_object(handle->builder, "timestamp_label") |
66 | ); | 96 | ); |
diff --git a/src/ui/message.h b/src/ui/message.h index 1b3a80c..333ef75 100644 --- a/src/ui/message.h +++ b/src/ui/message.h | |||
@@ -32,8 +32,17 @@ | |||
32 | 32 | ||
33 | typedef struct MESSENGER_Application MESSENGER_Application; | 33 | typedef struct MESSENGER_Application MESSENGER_Application; |
34 | 34 | ||
35 | typedef enum UI_MESSAGE_Type | ||
36 | { | ||
37 | UI_MESSAGE_DEFAULT = 0, | ||
38 | UI_MESSAGE_SENT = 1, | ||
39 | UI_MESSAGE_STATUS = 2 | ||
40 | } UI_MESSAGE_Type; | ||
41 | |||
35 | typedef struct UI_MESSAGE_Handle | 42 | typedef struct UI_MESSAGE_Handle |
36 | { | 43 | { |
44 | UI_MESSAGE_Type type; | ||
45 | |||
37 | GtkBuilder *builder; | 46 | GtkBuilder *builder; |
38 | GtkWidget *message_box; | 47 | GtkWidget *message_box; |
39 | 48 | ||
@@ -42,13 +51,16 @@ typedef struct UI_MESSAGE_Handle | |||
42 | 51 | ||
43 | GtkLabel *text_label; | 52 | GtkLabel *text_label; |
44 | 53 | ||
54 | GtkButton *deny_button; | ||
55 | GtkButton *accept_button; | ||
56 | |||
45 | GtkLabel *timestamp_label; | 57 | GtkLabel *timestamp_label; |
46 | GtkImage *read_receipt_image; | 58 | GtkImage *read_receipt_image; |
47 | } UI_MESSAGE_Handle; | 59 | } UI_MESSAGE_Handle; |
48 | 60 | ||
49 | UI_MESSAGE_Handle* | 61 | UI_MESSAGE_Handle* |
50 | ui_message_new(MESSENGER_Application *app, | 62 | ui_message_new(MESSENGER_Application *app, |
51 | bool sent); | 63 | UI_MESSAGE_Type type); |
52 | 64 | ||
53 | void | 65 | void |
54 | ui_message_delete(UI_MESSAGE_Handle *handle); | 66 | ui_message_delete(UI_MESSAGE_Handle *handle); |