1
0
This commit is contained in:
dtb 2022-10-01 17:30:12 -04:00
parent 0194362686
commit ba603793a2
2 changed files with 77 additions and 0 deletions

19
bitch/Makefile Normal file
View File

@ -0,0 +1,19 @@
CFLAGS = -g `pkg-config --cflags gtk4` `pkg-config --libs gtk4`
RM = rm -f
TARGETS = bitch
all: $(TARGETS)
clean:
$(RM) $(TARGETS)
naughty:
$(CC) -g `pkg-config --cflags gtk4` `pkg-config --libs gtk4` \
-D APPLICATION_NAME=\"org.trinity.bitch\" bitch.c -o bitch
nice:
$(CC) -g `pkg-config --cflags gtk4` `pkg-config --libs gtk4` \
-D APPLICATION_NAME=\"org.trinity.project\" bitch.c -o project
%: %.c
$(CC) -o $@ $(CFLAGS) $@.c
.PHONY: all clean

58
bitch/bitch.c Normal file
View File

@ -0,0 +1,58 @@
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h> /* Written for GTK 4 */
static char *argv0;
static char buf[100];
static void button_pressed(GtkWidget *button, gpointer data);
static void
activate(GtkApplication *app, gpointer user_data){
GtkWidget *button;
int c;
GtkWidget *window;
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Bitch");
gtk_window_set_default_size(GTK_WINDOW(window), 720, 1440);
g_print("bitch: stdin: reading...\n");
for(;;){
if(fgets(buf, sizeof(buf) / sizeof(*buf), stdin) == NULL){
if(feof(stdin))
g_print("bitch: stdin: reached EOF\n", argv0);
else if(ferror(stdin) != 0)
g_print("bitch: stdin: file read error\n", argv0);
break;
}
button = gtk_button_new_with_label(buf);
g_signal_connect(button, "clicked", G_CALLBACK(button_pressed), NULL);
gtk_window_set_child(GTK_WINDOW(window), button);
if(strchr(buf, '\n') == NULL) /* flush */
while((c = getc(stdin)) != '\n' && c != EOF);
}
gtk_window_present(GTK_WINDOW(window));
return;
}
static void
button_pressed(GtkWidget *button, gpointer data){
system(gtk_button_get_label(GTK_BUTTON(button)));
return;
}
int main(int argc, char *argv[]){
GtkApplication *app;
int status;
argv0 = argv[0];
app = gtk_application_new("org.trinity.femaledog", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}