diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-12-05 21:19:06 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-12-05 21:19:06 +0100 |
commit | 36058f083af2fccf616b72df5fa387a14db3b657 (patch) | |
tree | 1f0208417778a9e6fc1f09f5390b774c453d50c7 | |
parent | e67d27e74d0a2b0281256402ea79adea8ae91373 (diff) | |
download | messenger-gtk-36058f083af2fccf616b72df5fa387a14db3b657.tar.gz messenger-gtk-36058f083af2fccf616b72df5fa387a14db3b657.zip |
Allow opening internal video player with received mp4 files
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | resources/ui/message_content.ui | 16 | ||||
-rw-r--r-- | src/ui/message.c | 27 | ||||
-rw-r--r-- | src/ui/message.h | 1 | ||||
-rw-r--r-- | src/ui/picker.c | 8 | ||||
-rw-r--r-- | src/ui/play_media.c | 17 | ||||
-rw-r--r-- | src/ui/play_media.h | 4 |
6 files changed, 56 insertions, 17 deletions
diff --git a/resources/ui/message_content.ui b/resources/ui/message_content.ui index 8fb06d1..1d32e93 100644 --- a/resources/ui/message_content.ui +++ b/resources/ui/message_content.ui | |||
@@ -1,5 +1,5 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!-- Generated with glade 3.38.2 | 2 | <!-- Generated with glade 3.40.0 |
3 | 3 | ||
4 | Copyright (C) 2021‑‑2022 GNUnet e.V. | 4 | Copyright (C) 2021‑‑2022 GNUnet e.V. |
5 | 5 | ||
@@ -81,6 +81,7 @@ Author: Tobias Frisch | |||
81 | <property name="wrap">True</property> | 81 | <property name="wrap">True</property> |
82 | <property name="max-width-chars">64</property> | 82 | <property name="max-width-chars">64</property> |
83 | <property name="xalign">0</property> | 83 | <property name="xalign">0</property> |
84 | <property name="yalign">1</property> | ||
84 | </object> | 85 | </object> |
85 | <packing> | 86 | <packing> |
86 | <property name="name">text_page</property> | 87 | <property name="name">text_page</property> |
@@ -100,16 +101,19 @@ Author: Tobias Frisch | |||
100 | <object class="GtkBox"> | 101 | <object class="GtkBox"> |
101 | <property name="visible">True</property> | 102 | <property name="visible">True</property> |
102 | <property name="can-focus">False</property> | 103 | <property name="can-focus">False</property> |
103 | <property name="valign">center</property> | ||
104 | <property name="orientation">vertical</property> | 104 | <property name="orientation">vertical</property> |
105 | <property name="spacing">4</property> | 105 | <property name="spacing">4</property> |
106 | <child> | 106 | <child> |
107 | <object class="GtkLabel" id="filename_label"> | 107 | <object class="GtkLabel" id="filename_label"> |
108 | <property name="visible">True</property> | 108 | <property name="visible">True</property> |
109 | <property name="can-focus">False</property> | 109 | <property name="can-focus">False</property> |
110 | <property name="label" translatable="yes"> | ||
111 | </property> | ||
112 | <property name="xalign">0</property> | ||
113 | <property name="yalign">1</property> | ||
110 | </object> | 114 | </object> |
111 | <packing> | 115 | <packing> |
112 | <property name="expand">False</property> | 116 | <property name="expand">True</property> |
113 | <property name="fill">True</property> | 117 | <property name="fill">True</property> |
114 | <property name="position">0</property> | 118 | <property name="position">0</property> |
115 | </packing> | 119 | </packing> |
@@ -122,6 +126,7 @@ Author: Tobias Frisch | |||
122 | <packing> | 126 | <packing> |
123 | <property name="expand">False</property> | 127 | <property name="expand">False</property> |
124 | <property name="fill">True</property> | 128 | <property name="fill">True</property> |
129 | <property name="pack-type">end</property> | ||
125 | <property name="position">1</property> | 130 | <property name="position">1</property> |
126 | </packing> | 131 | </packing> |
127 | </child> | 132 | </child> |
@@ -137,8 +142,7 @@ Author: Tobias Frisch | |||
137 | <property name="visible">True</property> | 142 | <property name="visible">True</property> |
138 | <property name="can-focus">True</property> | 143 | <property name="can-focus">True</property> |
139 | <property name="receives-default">True</property> | 144 | <property name="receives-default">True</property> |
140 | <property name="halign">center</property> | 145 | <property name="valign">end</property> |
141 | <property name="valign">center</property> | ||
142 | <property name="relief">none</property> | 146 | <property name="relief">none</property> |
143 | <child> | 147 | <child> |
144 | <object class="GtkImage" id="file_status_image"> | 148 | <object class="GtkImage" id="file_status_image"> |
@@ -182,6 +186,7 @@ Author: Tobias Frisch | |||
182 | <object class="GtkImage"> | 186 | <object class="GtkImage"> |
183 | <property name="visible">True</property> | 187 | <property name="visible">True</property> |
184 | <property name="can-focus">False</property> | 188 | <property name="can-focus">False</property> |
189 | <property name="valign">end</property> | ||
185 | <property name="icon-name">face-shutmouth-symbolic</property> | 190 | <property name="icon-name">face-shutmouth-symbolic</property> |
186 | </object> | 191 | </object> |
187 | <packing> | 192 | <packing> |
@@ -196,6 +201,7 @@ Author: Tobias Frisch | |||
196 | <property name="can-focus">False</property> | 201 | <property name="can-focus">False</property> |
197 | <property name="label" translatable="yes">whispering...</property> | 202 | <property name="label" translatable="yes">whispering...</property> |
198 | <property name="xalign">0</property> | 203 | <property name="xalign">0</property> |
204 | <property name="yalign">1</property> | ||
199 | <attributes> | 205 | <attributes> |
200 | <attribute name="style" value="italic"/> | 206 | <attribute name="style" value="italic"/> |
201 | </attributes> | 207 | </attributes> |
diff --git a/src/ui/message.c b/src/ui/message.c index 8d5627f..3678414 100644 --- a/src/ui/message.c +++ b/src/ui/message.c | |||
@@ -101,7 +101,19 @@ handle_file_button_click(GtkButton *button, | |||
101 | GString* uri = g_string_new("file://"); | 101 | GString* uri = g_string_new("file://"); |
102 | g_string_append(uri, preview); | 102 | g_string_append(uri, preview); |
103 | 103 | ||
104 | if (!g_app_info_launch_default_for_uri(uri->str, NULL, NULL)) | 104 | if (handle->media) |
105 | { | ||
106 | ui_play_media_window_init(app, &(app->ui.play_media)); | ||
107 | |||
108 | ui_play_media_window_update( | ||
109 | &(app->ui.play_media), | ||
110 | uri->str, | ||
111 | file | ||
112 | ); | ||
113 | |||
114 | gtk_widget_show(GTK_WIDGET(app->ui.play_media.window)); | ||
115 | } | ||
116 | else if (!g_app_info_launch_default_for_uri(uri->str, NULL, NULL)) | ||
105 | GNUNET_CHAT_file_close_preview(file); | 117 | GNUNET_CHAT_file_close_preview(file); |
106 | 118 | ||
107 | g_string_free(uri, TRUE); | 119 | g_string_free(uri, TRUE); |
@@ -248,6 +260,7 @@ ui_message_new(MESSENGER_Application *app, | |||
248 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); | 260 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); |
249 | 261 | ||
250 | handle->type = type; | 262 | handle->type = type; |
263 | handle->media = FALSE; | ||
251 | 264 | ||
252 | handle->timestamp = GNUNET_TIME_absolute_get_zero_(); | 265 | handle->timestamp = GNUNET_TIME_absolute_get_zero_(); |
253 | handle->msg = NULL; | 266 | handle->msg = NULL; |
@@ -472,7 +485,7 @@ _update_file_message(UI_MESSAGE_Handle *handle, | |||
472 | if (!(handle->preview_animation)) | 485 | if (!(handle->preview_animation)) |
473 | handle->preview_image = gdk_pixbuf_new_from_file(preview, NULL); | 486 | handle->preview_image = gdk_pixbuf_new_from_file(preview, NULL); |
474 | 487 | ||
475 | if ((handle->preview_animation) || (handle->preview_animation)) | 488 | if ((handle->preview_animation) || (handle->preview_image)) |
476 | { | 489 | { |
477 | gtk_widget_set_size_request( | 490 | gtk_widget_set_size_request( |
478 | GTK_WIDGET(handle->preview_drawing_area), | 491 | GTK_WIDGET(handle->preview_drawing_area), |
@@ -489,6 +502,14 @@ _update_file_message(UI_MESSAGE_Handle *handle, | |||
489 | return; | 502 | return; |
490 | } | 503 | } |
491 | 504 | ||
505 | const char* extension = strrchr(filename, '.'); | ||
506 | |||
507 | if (0 == g_strcmp0(extension, ".mp4")) | ||
508 | { | ||
509 | handle->media = TRUE; | ||
510 | goto file_progress; | ||
511 | } | ||
512 | |||
492 | GNUNET_CHAT_file_close_preview(file); | 513 | GNUNET_CHAT_file_close_preview(file); |
493 | 514 | ||
494 | file_progress: | 515 | file_progress: |
@@ -496,7 +517,7 @@ file_progress: | |||
496 | 517 | ||
497 | gtk_image_set_from_icon_name( | 518 | gtk_image_set_from_icon_name( |
498 | handle->file_status_image, | 519 | handle->file_status_image, |
499 | "document-open-symbolic", | 520 | (handle->media? "video-x-generic-symbolic" : "document-open-symbolic"), |
500 | GTK_ICON_SIZE_BUTTON | 521 | GTK_ICON_SIZE_BUTTON |
501 | ); | 522 | ); |
502 | 523 | ||
diff --git a/src/ui/message.h b/src/ui/message.h index 84ec7e8..1205881 100644 --- a/src/ui/message.h +++ b/src/ui/message.h | |||
@@ -44,6 +44,7 @@ typedef enum UI_MESSAGE_Type | |||
44 | typedef struct UI_MESSAGE_Handle | 44 | typedef struct UI_MESSAGE_Handle |
45 | { | 45 | { |
46 | UI_MESSAGE_Type type; | 46 | UI_MESSAGE_Type type; |
47 | gboolean media; | ||
47 | 48 | ||
48 | struct GNUNET_TIME_Absolute timestamp; | 49 | struct GNUNET_TIME_Absolute timestamp; |
49 | const struct GNUNET_CHAT_Message *msg; | 50 | const struct GNUNET_CHAT_Message *msg; |
diff --git a/src/ui/picker.c b/src/ui/picker.c index eb42a1d..bd11bab 100644 --- a/src/ui/picker.c +++ b/src/ui/picker.c | |||
@@ -100,14 +100,8 @@ handle_settings_button_click(UNUSED GtkButton *button, | |||
100 | gpointer user_data) | 100 | gpointer user_data) |
101 | { | 101 | { |
102 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 102 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
103 | ui_play_media_window_init(app, &(app->ui.play_media)); | ||
104 | 103 | ||
105 | ui_play_media_window_update( | 104 | // TODO |
106 | &(app->ui.play_media), | ||
107 | "TODO" // uri path to video file | ||
108 | ); | ||
109 | |||
110 | gtk_widget_show(GTK_WIDGET(app->ui.play_media.window)); | ||
111 | } | 105 | } |
112 | 106 | ||
113 | UI_PICKER_Handle* | 107 | UI_PICKER_Handle* |
diff --git a/src/ui/play_media.c b/src/ui/play_media.c index a7e9d88..6dd9c6e 100644 --- a/src/ui/play_media.c +++ b/src/ui/play_media.c | |||
@@ -746,8 +746,11 @@ ui_play_media_window_init(MESSENGER_Application *app, | |||
746 | 746 | ||
747 | void | 747 | void |
748 | ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, | 748 | ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, |
749 | const gchar *uri) | 749 | const gchar *uri, |
750 | const struct GNUNET_CHAT_File *file) | ||
750 | { | 751 | { |
752 | GNUNET_assert((handle) && (uri)); | ||
753 | |||
751 | if (handle->video_tid) | 754 | if (handle->video_tid) |
752 | pthread_join(handle->video_tid, NULL); | 755 | pthread_join(handle->video_tid, NULL); |
753 | 756 | ||
@@ -757,6 +760,18 @@ ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, | |||
757 | _disable_video_processing(handle, TRUE); | 760 | _disable_video_processing(handle, TRUE); |
758 | g_object_set(G_OBJECT(handle->pipeline), "uri", uri, NULL); | 761 | g_object_set(G_OBJECT(handle->pipeline), "uri", uri, NULL); |
759 | 762 | ||
763 | const gchar *filename; | ||
764 | |||
765 | if (file) | ||
766 | filename = GNUNET_CHAT_file_get_name(file); | ||
767 | else | ||
768 | filename = uri; | ||
769 | |||
770 | hdy_header_bar_set_subtitle( | ||
771 | handle->title_bar, | ||
772 | filename? filename : "" | ||
773 | ); | ||
774 | |||
760 | pthread_create( | 775 | pthread_create( |
761 | &(handle->video_tid), | 776 | &(handle->video_tid), |
762 | NULL, | 777 | NULL, |
diff --git a/src/ui/play_media.h b/src/ui/play_media.h index 75132d6..301e070 100644 --- a/src/ui/play_media.h +++ b/src/ui/play_media.h | |||
@@ -91,10 +91,12 @@ ui_play_media_window_init(MESSENGER_Application *app, | |||
91 | * | 91 | * |
92 | * @param handle Play media window handle | 92 | * @param handle Play media window handle |
93 | * @param uri URI of media file | 93 | * @param uri URI of media file |
94 | * @param file Media file handle or NULL | ||
94 | */ | 95 | */ |
95 | void | 96 | void |
96 | ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, | 97 | ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, |
97 | const gchar *uri); | 98 | const gchar *uri, |
99 | const struct GNUNET_CHAT_File *file); | ||
98 | 100 | ||
99 | /** | 101 | /** |
100 | * Cleans up the allocated resources and resets the | 102 | * Cleans up the allocated resources and resets the |