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); }