From 03f9d1d46592248c3091221587a5706adee5087b Mon Sep 17 00:00:00 2001 From: Jacki Date: Fri, 19 Jan 2024 05:30:29 +0100 Subject: Adjust revealer to be dynamic Signed-off-by: Jacki --- resources/ui/new_contact.ui | 5 ++--- src/ui/new_contact.c | 15 +++++++++++++-- src/ui/new_contact.h | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/resources/ui/new_contact.ui b/resources/ui/new_contact.ui index 36e309a..b182919 100644 --- a/resources/ui/new_contact.ui +++ b/resources/ui/new_contact.ui @@ -90,16 +90,15 @@ Author: Tobias Frisch vertical 4 - + True False 8 8 8 - none - True + 250 True False center diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c index 1b79cdc..8267fab 100644 --- a/src/ui/new_contact.c +++ b/src/ui/new_contact.c @@ -339,6 +339,7 @@ iterate_global(void *obj, -1 ); + handle->camera_count++; return 0; } @@ -347,6 +348,8 @@ _init_camera_pipeline(MESSENGER_Application *app, UI_NEW_CONTACT_Handle *handle, gboolean access) { + handle->camera_count = 0; + if ((app->portal) && ((access) || xdp_portal_is_camera_present(app->portal))) { app->pw.pending = pw_core_sync(app->pw.core, 0, 0); @@ -354,11 +357,15 @@ _init_camera_pipeline(MESSENGER_Application *app, pw_main_loop_run(app->pw.main_loop); pw_map_for_each(&(app->pw.globals), iterate_global, handle); - GtkTreeIter iter; - if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(handle->camera_list_store), &iter)) + if (handle->camera_count) gtk_combo_box_set_active(handle->camera_combo_box, 0); } + gtk_revealer_set_reveal_child( + handle->camera_combo_box_revealer, + handle->camera_count > 1 + ); + pthread_create( &(handle->video_tid), NULL, @@ -428,6 +435,10 @@ ui_new_contact_dialog_init(MESSENGER_Application *app, GTK_WINDOW(app->ui.messenger.main_window) ); + handle->camera_combo_box_revealer = GTK_REVEALER( + gtk_builder_get_object(handle->builder, "camera_combo_box_revealer") + ); + handle->camera_combo_box = GTK_COMBO_BOX( gtk_builder_get_object(handle->builder, "camera_combo_box") ); diff --git a/src/ui/new_contact.h b/src/ui/new_contact.h index 7d969cd..3896f56 100644 --- a/src/ui/new_contact.h +++ b/src/ui/new_contact.h @@ -34,6 +34,8 @@ typedef struct UI_NEW_CONTACT_Handle { + guint camera_count; + GstElement *pipeline; GstElement *source; GstElement *scanner; @@ -42,6 +44,7 @@ typedef struct UI_NEW_CONTACT_Handle GtkBuilder *builder; GtkDialog *dialog; + GtkRevealer *camera_combo_box_revealer; GtkComboBox *camera_combo_box; GtkListStore *camera_list_store; -- cgit v1.2.3