ui/gtk/text.c

changeset 38
acd8c4a9d3fe
parent 35
834d9c15a69f
child 44
473954dc6b74
--- a/ui/gtk/text.c	Tue Jun 11 21:31:21 2024 +0200
+++ b/ui/gtk/text.c	Tue Jun 11 21:45:39 2024 +0200
@@ -691,6 +691,7 @@
 static gboolean path_textfield_btn_pressed(GtkWidget *widget, GdkEventButton *event, UiPathTextField *pathtf) {
     gtk_box_pack_start(GTK_BOX(pathtf->hbox), pathtf->entry, TRUE, TRUE, 0);
     gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->buttonbox);
+    pathtf->buttonbox = NULL;
     
     gtk_widget_show(pathtf->entry);
     gtk_widget_grab_focus(pathtf->entry);    
@@ -865,12 +866,16 @@
     pathtf->current_nelm = nelm;
     
     GtkWidget *buttonbox = create_path_button_box();
+    
+    // switch from entry to buttonbox or remove current buttonbox
+    if(pathtf->buttonbox) {
+        gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->buttonbox);
+    } else {
+        gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->entry);
+    }
+    gtk_box_pack_start(GTK_BOX(pathtf->hbox), buttonbox, FALSE, FALSE, 0);
     pathtf->buttonbox = buttonbox;
     
-    // switch from entry to buttonbox
-    gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->entry);
-    gtk_box_pack_start(GTK_BOX(pathtf->hbox), buttonbox, FALSE, FALSE, 0);
-    
     for (int i=0;i<nelm;i++) {
         UiPathElm *elm = &path_elm[i];
         

mercurial