add check for empty input
This commit is contained in:
14
main.c
14
main.c
@@ -6,8 +6,8 @@ typedef struct{
|
|||||||
GtkApplication *app;
|
GtkApplication *app;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *input;
|
GtkWidget *input;
|
||||||
GtkWidget* box;
|
GtkWidget *box;
|
||||||
GtkWidget* grid;
|
GtkWidget *grid;
|
||||||
char dir[256];
|
char dir[256];
|
||||||
} Appdata;
|
} Appdata;
|
||||||
|
|
||||||
@@ -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));
|
||||||
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);
|
remove_child(data);
|
||||||
buttons(data->app,data,data->dir);
|
buttons(data->app,data,data->dir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user