aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-12-18 15:41:15 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-12-18 15:41:15 +0100
commitc3195ac1db60e615acd42ab5e213d7a5a6a35064 (patch)
tree584cb25c12283a31826b8e8df8c2143406d19f41
parent106ece8407806a70e8327b15178668daae003fc2 (diff)
downloadmessenger-gtk-c3195ac1db60e615acd42ab5e213d7a5a6a35064.tar.gz
messenger-gtk-c3195ac1db60e615acd42ab5e213d7a5a6a35064.zip
Adapted UI to visualize problems with the camera connection
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--resources/ui/new_contact.ui53
-rw-r--r--src/ui/new_contact.c24
-rw-r--r--src/ui/new_contact.h3
3 files changed, 75 insertions, 5 deletions
diff --git a/resources/ui/new_contact.ui b/resources/ui/new_contact.ui
index b483a25..25a90a9 100644
--- a/resources/ui/new_contact.ui
+++ b/resources/ui/new_contact.ui
@@ -77,10 +77,58 @@ Author: Tobias Frisch
77 <property name="orientation">vertical</property> 77 <property name="orientation">vertical</property>
78 <property name="spacing">4</property> 78 <property name="spacing">4</property>
79 <child> 79 <child>
80 <object class="GtkDrawingArea" id="id_drawing_area"> 80 <object class="GtkStack" id="preview_stack">
81 <property name="height-request">250</property>
82 <property name="visible">True</property> 81 <property name="visible">True</property>
83 <property name="can-focus">False</property> 82 <property name="can-focus">False</property>
83 <child>
84 <object class="GtkBox" id="fail_box">
85 <property name="visible">True</property>
86 <property name="can-focus">False</property>
87 <property name="valign">center</property>
88 <property name="orientation">vertical</property>
89 <property name="spacing">8</property>
90 <child>
91 <object class="GtkImage">
92 <property name="visible">True</property>
93 <property name="can-focus">False</property>
94 <property name="pixel-size">64</property>
95 <property name="icon-name">action-unavailable-symbolic</property>
96 <property name="icon_size">3</property>
97 </object>
98 <packing>
99 <property name="expand">False</property>
100 <property name="fill">True</property>
101 <property name="position">0</property>
102 </packing>
103 </child>
104 <child>
105 <object class="GtkLabel">
106 <property name="visible">True</property>
107 <property name="can-focus">False</property>
108 <property name="label" translatable="yes">Connection to camera failed!</property>
109 </object>
110 <packing>
111 <property name="expand">False</property>
112 <property name="fill">True</property>
113 <property name="position">1</property>
114 </packing>
115 </child>
116 </object>
117 <packing>
118 <property name="name">page_fail</property>
119 </packing>
120 </child>
121 <child>
122 <object class="GtkDrawingArea" id="id_drawing_area">
123 <property name="height-request">250</property>
124 <property name="visible">True</property>
125 <property name="can-focus">False</property>
126 </object>
127 <packing>
128 <property name="name">page_drawing</property>
129 <property name="position">1</property>
130 </packing>
131 </child>
84 </object> 132 </object>
85 <packing> 133 <packing>
86 <property name="expand">True</property> 134 <property name="expand">True</property>
@@ -106,7 +154,6 @@ Author: Tobias Frisch
106 <property name="width-request">250</property> 154 <property name="width-request">250</property>
107 <property name="visible">True</property> 155 <property name="visible">True</property>
108 <property name="can-focus">True</property> 156 <property name="can-focus">True</property>
109 <property name="editable">False</property>
110 </object> 157 </object>
111 <packing> 158 <packing>
112 <property name="expand">False</property> 159 <property name="expand">False</property>
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c
index c193629..3acae1a 100644
--- a/src/ui/new_contact.c
+++ b/src/ui/new_contact.c
@@ -150,6 +150,8 @@ render_image:
150static void 150static void
151_disable_video_processing(UI_NEW_CONTACT_Handle *handle) 151_disable_video_processing(UI_NEW_CONTACT_Handle *handle)
152{ 152{
153 gtk_stack_set_visible_child(handle->preview_stack, handle->fail_box);
154
153 if (!(handle->video)) 155 if (!(handle->video))
154 return; 156 return;
155 157
@@ -269,6 +271,11 @@ _ui_new_contact_video_thread(void *args)
269 TRUE 271 TRUE
270 ); 272 );
271 273
274 gtk_stack_set_visible_child(
275 handle->preview_stack,
276 GTK_WIDGET(handle->id_drawing_area)
277 );
278
272 handle->idle_processing = g_idle_add(idle_video_processing, handle); 279 handle->idle_processing = g_idle_add(idle_video_processing, handle);
273 return NULL; 280 return NULL;
274} 281}
@@ -280,8 +287,6 @@ ui_new_contact_dialog_init(MESSENGER_Application *app,
280 handle->video = zbar_video_create(); 287 handle->video = zbar_video_create();
281 handle->scanner = zbar_image_scanner_create(); 288 handle->scanner = zbar_image_scanner_create();
282 289
283 pthread_create(&(handle->video_tid), NULL, _ui_new_contact_video_thread, handle);
284
285 handle->builder = gtk_builder_new_from_file("resources/ui/new_contact.ui"); 290 handle->builder = gtk_builder_new_from_file("resources/ui/new_contact.ui");
286 291
287 handle->dialog = GTK_DIALOG( 292 handle->dialog = GTK_DIALOG(
@@ -298,10 +303,25 @@ ui_new_contact_dialog_init(MESSENGER_Application *app,
298 GTK_WINDOW(app->ui.messenger.main_window) 303 GTK_WINDOW(app->ui.messenger.main_window)
299 ); 304 );
300 305
306 handle->preview_stack = GTK_STACK(
307 gtk_builder_get_object(handle->builder, "preview_stack")
308 );
309
310 handle->fail_box = GTK_WIDGET(
311 gtk_builder_get_object(handle->builder, "fail_box")
312 );
313
301 handle->id_drawing_area = GTK_DRAWING_AREA( 314 handle->id_drawing_area = GTK_DRAWING_AREA(
302 gtk_builder_get_object(handle->builder, "id_drawing_area") 315 gtk_builder_get_object(handle->builder, "id_drawing_area")
303 ); 316 );
304 317
318 pthread_create(
319 &(handle->video_tid),
320 NULL,
321 _ui_new_contact_video_thread,
322 handle
323 );
324
305 g_signal_connect( 325 g_signal_connect(
306 handle->id_drawing_area, 326 handle->id_drawing_area,
307 "draw", 327 "draw",
diff --git a/src/ui/new_contact.h b/src/ui/new_contact.h
index 18bb042..4ab397a 100644
--- a/src/ui/new_contact.h
+++ b/src/ui/new_contact.h
@@ -41,6 +41,9 @@ typedef struct UI_NEW_CONTACT_Handle
41 GtkBuilder *builder; 41 GtkBuilder *builder;
42 GtkDialog *dialog; 42 GtkDialog *dialog;
43 43
44 GtkStack *preview_stack;
45 GtkWidget *fail_box;
46
44 GtkDrawingArea *id_drawing_area; 47 GtkDrawingArea *id_drawing_area;
45 GtkEntry *id_entry; 48 GtkEntry *id_entry;
46 49