messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit 03f9d1d46592248c3091221587a5706adee5087b
parent 26cdd5581daeed962c4a481749b42dd87c310a45
Author: Jacki <jacki@thejackimonster.de>
Date:   Fri, 19 Jan 2024 05:30:29 +0100

Adjust revealer to be dynamic

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Mresources/ui/new_contact.ui | 5++---
Msrc/ui/new_contact.c | 15+++++++++++++--
Msrc/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 @@ -90,16 +90,15 @@ Author: Tobias Frisch <property name="orientation">vertical</property> <property name="spacing">4</property> <child> - <object class="GtkRevealer"> + <object class="GtkRevealer" id="camera_combo_box_revealer"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="margin-start">8</property> <property name="margin-end">8</property> <property name="margin-bottom">8</property> - <property name="transition-type">none</property> - <property name="reveal-child">True</property> <child> <object class="GtkComboBox" id="camera_combo_box"> + <property name="width-request">250</property> <property name="visible">True</property> <property name="can-focus">False</property> <property name="halign">center</property> diff --git 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 @@ -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;