From ee7e3c0b8503ebd69a64fa792fb92c473c1d3daf Mon Sep 17 00:00:00 2001 From: AkriliksKotya Date: Thu, 25 Dec 2025 00:36:36 +0500 Subject: [PATCH] add check for empty input --- main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 9bc3107..2b69960 100644 --- a/main.c +++ b/main.c @@ -6,8 +6,8 @@ typedef struct{ GtkApplication *app; GtkWidget *window; GtkWidget *input; - GtkWidget* box; - GtkWidget* grid; + GtkWidget *box; + GtkWidget *grid; char dir[256]; } Appdata; @@ -60,9 +60,15 @@ int *check_dir(int *arr, DIR *d, char *directory){ // activates after enter dir in input void on_entry_activate(GtkEntry *entry, Appdata *data){ const gchar *user_text; - GtkTextIter end_iter; user_text = gtk_editable_get_text(GTK_EDITABLE(entry)); - snprintf(data->dir, sizeof(data->dir), "%s", user_text); + 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); + } remove_child(data); buttons(data->app,data,data->dir); }