add check for empty input

This commit is contained in:
2025-12-25 00:36:36 +05:00
parent 7688d698d8
commit ee7e3c0b85

8
main.c
View File

@@ -60,9 +60,15 @@ int *check_dir(int *arr, DIR *d, char *directory){
// activates after enter dir in input // activates after enter dir in input
void on_entry_activate(GtkEntry *entry, Appdata *data){ void on_entry_activate(GtkEntry *entry, Appdata *data){
const gchar *user_text; const gchar *user_text;
GtkTextIter end_iter;
user_text = gtk_editable_get_text(GTK_EDITABLE(entry)); user_text = gtk_editable_get_text(GTK_EDITABLE(entry));
g_print("input: %s\n", user_text);
// check empty input
if (strcmp(user_text, "") || strcmp(user_text, " ")){
snprintf(data->dir, sizeof(data->dir), "/");
}
else{
snprintf(data->dir, sizeof(data->dir), "%s", user_text); snprintf(data->dir, sizeof(data->dir), "%s", user_text);
}
remove_child(data); remove_child(data);
buttons(data->app,data,data->dir); buttons(data->app,data,data->dir);
} }