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 <stdio.h>
|
||||||
#include <dirent.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 *check_dir(int *arr, DIR *d, char *directory){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
// char label[100];
|
|
||||||
// DIR *d;
|
|
||||||
struct dirent *dir;
|
struct dirent *dir;
|
||||||
d = opendir(directory);
|
d = opendir(directory);
|
||||||
printf("dirrrr %s %s\n", d);
|
|
||||||
if (d) {
|
if (d) {
|
||||||
while ((dir = readdir(d)) != NULL){
|
while ((dir = readdir(d)) != NULL){
|
||||||
char *name = dir->d_name;
|
char *name = dir->d_name;
|
||||||
printf("%s\n", name);
|
|
||||||
if (*name == '.'){
|
if (*name == '.'){
|
||||||
printf("directory starts with .\n");
|
printf("directory starts with .\n");
|
||||||
}
|
}
|
||||||
@@ -23,17 +24,9 @@ int *check_dir(int *arr, DIR *d, char *directory){
|
|||||||
i = 0;
|
i = 0;
|
||||||
j += 1;
|
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[0] = i;
|
||||||
arr[1] = j;
|
arr[1] = j;
|
||||||
// printf("%i %i\n", i,j);
|
|
||||||
// printf("%i %i\n",arr[0],arr[1]);
|
|
||||||
}
|
}
|
||||||
// closedir(d);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -59,9 +52,7 @@ static void app_activate (GtkApplication *app, gpointer *user_data){
|
|||||||
g = 10;
|
g = 10;
|
||||||
while ((dir = readdir(d)) != NULL && i <=p[1] && j < g){
|
while ((dir = readdir(d)) != NULL && i <=p[1] && j < g){
|
||||||
if (d) {
|
if (d) {
|
||||||
printf("directory names\n");
|
|
||||||
char *name = dir->d_name;
|
char *name = dir->d_name;
|
||||||
printf("%s\n", name);
|
|
||||||
if (*name == '.'){
|
if (*name == '.'){
|
||||||
printf("directory starts with .\n");
|
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");
|
printf("i=10 g=p[0]\n");
|
||||||
g = p[0];
|
g = p[0];
|
||||||
}
|
}
|
||||||
// char lablell[100];
|
printf("set directory label: %s\n", name);
|
||||||
printf("set directory label\n");
|
|
||||||
GtkWidget* btn = gtk_button_new();
|
GtkWidget* btn = gtk_button_new();
|
||||||
gtk_grid_set_row_spacing(GTK_GRID (grid), 10);
|
gtk_grid_set_row_spacing(GTK_GRID (grid), 10);
|
||||||
gtk_grid_set_column_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_column_homogeneous(GTK_GRID (grid), TRUE);
|
||||||
gtk_grid_set_row_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_button_set_label(GTK_BUTTON(btn),name);
|
||||||
gtk_grid_attach (GTK_GRID(grid), btn, j, i, 1,1);
|
gtk_grid_attach (GTK_GRID(grid), btn, j, i, 1,1);
|
||||||
gtk_widget_set_halign(btn, GTK_ALIGN_CENTER);
|
gtk_widget_set_halign(btn, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_set_valign(btn, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign(btn, GTK_ALIGN_CENTER);
|
||||||
|
g_signal_connect(btn, "clicked",G_CALLBACK(on_button_clicked),NULL);
|
||||||
j++;
|
j++;
|
||||||
if (j >= 9){
|
if (j >= 10){
|
||||||
j = 0;
|
j = 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -91,7 +81,7 @@ static void app_activate (GtkApplication *app, gpointer *user_data){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(d);
|
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_set_child(GTK_WINDOW(window),grid);
|
||||||
gtk_window_present(GTK_WINDOW(window));
|
gtk_window_present(GTK_WINDOW(window));
|
||||||
g_print("Started\n");
|
g_print("Started\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user