689 } |
689 } |
690 |
690 |
691 static gboolean path_textfield_btn_pressed(GtkWidget *widget, GdkEventButton *event, UiPathTextField *pathtf) { |
691 static gboolean path_textfield_btn_pressed(GtkWidget *widget, GdkEventButton *event, UiPathTextField *pathtf) { |
692 gtk_box_pack_start(GTK_BOX(pathtf->hbox), pathtf->entry, TRUE, TRUE, 0); |
692 gtk_box_pack_start(GTK_BOX(pathtf->hbox), pathtf->entry, TRUE, TRUE, 0); |
693 gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->buttonbox); |
693 gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->buttonbox); |
|
694 pathtf->buttonbox = NULL; |
694 |
695 |
695 gtk_widget_show(pathtf->entry); |
696 gtk_widget_show(pathtf->entry); |
696 gtk_widget_grab_focus(pathtf->entry); |
697 gtk_widget_grab_focus(pathtf->entry); |
697 |
698 |
698 return TRUE; |
699 return TRUE; |
845 free(path.ptr); |
846 free(path.ptr); |
846 } |
847 } |
847 |
848 |
848 int ui_pathtextfield_update(UiPathTextField* pathtf, const char *full_path) { |
849 int ui_pathtextfield_update(UiPathTextField* pathtf, const char *full_path) { |
849 size_t full_path_len = strlen(full_path); |
850 size_t full_path_len = strlen(full_path); |
|
851 if(full_path_len == 0) { |
|
852 return 1; |
|
853 } |
850 |
854 |
851 size_t nelm = 0; |
855 size_t nelm = 0; |
852 UiPathElm* path_elm = pathtf->getpathelm(full_path, full_path_len, &nelm, pathtf->getpathelmdata); |
856 UiPathElm* path_elm = pathtf->getpathelm(full_path, full_path_len, &nelm, pathtf->getpathelmdata); |
853 if (!path_elm) { |
857 if (!path_elm) { |
854 return 1; |
858 return 1; |
860 ui_pathelm_destroy(pathtf->current_pathelms, pathtf->current_nelm); |
864 ui_pathelm_destroy(pathtf->current_pathelms, pathtf->current_nelm); |
861 pathtf->current_pathelms = path_elm; |
865 pathtf->current_pathelms = path_elm; |
862 pathtf->current_nelm = nelm; |
866 pathtf->current_nelm = nelm; |
863 |
867 |
864 GtkWidget *buttonbox = create_path_button_box(); |
868 GtkWidget *buttonbox = create_path_button_box(); |
|
869 |
|
870 // switch from entry to buttonbox or remove current buttonbox |
|
871 if(pathtf->buttonbox) { |
|
872 gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->buttonbox); |
|
873 } else { |
|
874 gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->entry); |
|
875 } |
|
876 gtk_box_pack_start(GTK_BOX(pathtf->hbox), buttonbox, FALSE, FALSE, 0); |
865 pathtf->buttonbox = buttonbox; |
877 pathtf->buttonbox = buttonbox; |
866 |
|
867 // switch from entry to buttonbox |
|
868 gtk_container_remove(GTK_CONTAINER(pathtf->hbox), pathtf->entry); |
|
869 gtk_box_pack_start(GTK_BOX(pathtf->hbox), buttonbox, FALSE, FALSE, 0); |
|
870 |
878 |
871 for (int i=0;i<nelm;i++) { |
879 for (int i=0;i<nelm;i++) { |
872 UiPathElm *elm = &path_elm[i]; |
880 UiPathElm *elm = &path_elm[i]; |
873 |
881 |
874 cxmutstr name = cx_strdup(cx_strn(elm->name, elm->name_len)); |
882 cxmutstr name = cx_strdup(cx_strn(elm->name, elm->name_len)); |