delete comments, button click function, fix
This commit is contained in:
28
main.c
28
main.c
@@ -2,18 +2,19 @@
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
static void on_button_clicked(GtkWidget *widget, gpointer user_data){
|
||||
g_print("Button clicked\n");
|
||||
}
|
||||
|
||||
int *check_dir(int *arr, DIR *d, char *directory){
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
// char label[100];
|
||||
// DIR *d;
|
||||
struct dirent *dir;
|
||||
d = opendir(directory);
|
||||
printf("dirrrr %s %s\n", d);
|
||||
if (d) {
|
||||
while ((dir = readdir(d)) != NULL){
|
||||
char *name = dir->d_name;
|
||||
printf("%s\n", name);
|
||||
if (*name == '.'){
|
||||
printf("directory starts with .\n");
|
||||
}
|
||||
@@ -23,17 +24,9 @@ int *check_dir(int *arr, DIR *d, char *directory){
|
||||
i = 0;
|
||||
j += 1;
|
||||
}
|
||||
// printf("%i %i \n",i,j);
|
||||
// printf("%s\n", dir->d_name);
|
||||
// sprintf(label, "%d" ,dir->d_name);
|
||||
// char *lll = label;
|
||||
// return lll;
|
||||
arr[0] = i;
|
||||
arr[1] = j;
|
||||
// printf("%i %i\n", i,j);
|
||||
// printf("%i %i\n",arr[0],arr[1]);
|
||||
}
|
||||
// closedir(d);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -59,9 +52,7 @@ static void app_activate (GtkApplication *app, gpointer *user_data){
|
||||
g = 10;
|
||||
while ((dir = readdir(d)) != NULL && i <=p[1] && j < g){
|
||||
if (d) {
|
||||
printf("directory names\n");
|
||||
char *name = dir->d_name;
|
||||
printf("%s\n", name);
|
||||
if (*name == '.'){
|
||||
printf("directory starts with .\n");
|
||||
}
|
||||
@@ -70,20 +61,19 @@ static void app_activate (GtkApplication *app, gpointer *user_data){
|
||||
printf("i=10 g=p[0]\n");
|
||||
g = p[0];
|
||||
}
|
||||
// char lablell[100];
|
||||
printf("set directory label\n");
|
||||
printf("set directory label: %s\n", name);
|
||||
GtkWidget* btn = gtk_button_new();
|
||||
gtk_grid_set_row_spacing(GTK_GRID (grid), 10);
|
||||
gtk_grid_set_column_spacing(GTK_GRID (grid), 10);
|
||||
gtk_grid_set_column_homogeneous(GTK_GRID (grid), TRUE);
|
||||
gtk_grid_set_row_homogeneous(GTK_GRID (grid), TRUE);
|
||||
// sprintf(lablell, "" ,check_dir());
|
||||
gtk_button_set_label(GTK_BUTTON(btn),name);
|
||||
gtk_grid_attach (GTK_GRID(grid), btn, j, i, 1,1);
|
||||
gtk_widget_set_halign(btn, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign(btn, GTK_ALIGN_CENTER);
|
||||
g_signal_connect(btn, "clicked",G_CALLBACK(on_button_clicked),NULL);
|
||||
j++;
|
||||
if (j >= 9){
|
||||
if (j >= 10){
|
||||
j = 0;
|
||||
i++;
|
||||
}
|
||||
@@ -91,7 +81,7 @@ static void app_activate (GtkApplication *app, gpointer *user_data){
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
printf("set child and present window");
|
||||
printf("set child and present window\n");
|
||||
gtk_window_set_child(GTK_WINDOW(window),grid);
|
||||
gtk_window_present(GTK_WINDOW(window));
|
||||
g_print("Started\n");
|
||||
|
||||
Reference in New Issue
Block a user