diff --git a/bitch/Makefile b/bitch/Makefile index 510e2f1..dbc151a 100644 --- a/bitch/Makefile +++ b/bitch/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -g `pkg-config --cflags gtk4` `pkg-config --libs gtk4` +CFLAGS = -g -DGTK4=1 `pkg-config --cflags gtk4` `pkg-config --libs gtk4` RM = rm -f TARGETS = bitch diff --git a/bitch/bitch.1 b/bitch/bitch.1 new file mode 100644 index 0000000..3d6a513 --- /dev/null +++ b/bitch/bitch.1 @@ -0,0 +1,45 @@ +.TH BITCH 1 + +.SH NAME + +bitch \(en a pretty interface from which to select tasks + +.SH SYNOPSIS + +bitch +.RB ( -rx ) +.RB [ -h +.BR horizontal ] +.RB [ -v +.BR vertical ] + +.SH GRAPHICS + +Bitch is written for the GNU Image Manipulation Program's Graphical Toolkit 4. +A windowing system is required to use bitch. + +.SH DESCRIPTION + +Bitch reads a list of newline-delimited items from standard input and presents a menu with the options. +.PP +With the +.B -x +option, bitch will eXit when the first item is chosen, otherwise bitch will print or execute subsequent selections. +.PP +With the +.B -r +option, bitch will execute the selected item with system(3). Otherwise, bitch will print the selection text. +.PP +The window bitch presents will be of the horizontal and vertical resolution specified with +.B -h +and +.B -v +respectively. + +.SH BUGS + +He who calls bitches bitches gets no bitches. + +.SH COPYRIGHT + +Public domain. diff --git a/bitch/bitch.c b/bitch/bitch.c index ed11836..cef705c 100644 --- a/bitch/bitch.c +++ b/bitch/bitch.c @@ -1,36 +1,77 @@ #include -#include +#include /* stderr, atoi(3) */ +#include /* EX_USAGE */ +#include /* getopt(3) */ /* Written for Gtk4 */ -#include +#ifdef GTK4 +# include +#endif #define BUF 100 -/* Pinephone dimensions */ -#define DEFAULT_H 720 -#define DEFAULT_V 1440 +/* Pinephone dimensions as default */ +static unsigned int h = 720; +static unsigned int v = 1440; static char *argv0; static char buf[BUF]; +static char f; +static unsigned char shy = 0; + +static char *fake_argv[2] = { NULL, NULL }; + +#ifdef GTK4 +static GtkApplication *app; static void activate(GtkApplication *app, gpointer user_data); static void button_pressed(GtkWidget *button, gpointer data); +#endif int main(int argc, char *argv[]){ - GtkApplication *app; + int c; + extern char *optarg; int status; argv0 = argv[0]; + fake_argv[0] = argv0; + + while((c = getopt(argc, argv, "h:rv:x")) != -1) + switch(c){ + case 'h': + h = atoi(optarg); + break; + case 'r': + f = 'r'; + break; + case 'v': + v = atoi(optarg); + break; + case 'x': + shy = 1; + break; + default: usage: + fprintf(stderr, "\ +Usage: %s (-rx)\n\ +\t(-h [horizontal resolution]) (-v [vertical resolution])\n", + argv0 + ); + return EX_USAGE; + } + +#ifdef GTK4 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); + status = g_application_run(G_APPLICATION(app), 1, fake_argv); g_object_unref(app); +#endif return status; } +#ifdef GTK4 static void activate(GtkApplication *app, gpointer user_data){ GtkWidget *box; @@ -41,7 +82,7 @@ activate(GtkApplication *app, gpointer user_data){ window = gtk_application_window_new(app); gtk_window_set_title(GTK_WINDOW(window), "Bitch"); - gtk_window_set_default_size(GTK_WINDOW(window), DEFAULT_H, DEFAULT_V); + gtk_window_set_default_size(GTK_WINDOW(window), h, v); box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_halign(box, GTK_ALIGN_CENTER); @@ -73,8 +114,18 @@ activate(GtkApplication *app, gpointer user_data){ static void button_pressed(GtkWidget *button, gpointer data){ - system(gtk_button_get_label(GTK_BUTTON(button))); + switch(f){ + case 'w': + g_print("%s\n", gtk_button_get_label(GTK_BUTTON(button))); + break; + case 'x': + system(gtk_button_get_label(GTK_BUTTON(button))); + break; + } + if(shy) + g_application_quit(G_APPLICATION(app)); return; } +#endif diff --git a/dist/Makefile b/dist/Makefile index 281fd20..1544e02 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -6,6 +6,13 @@ bin: share/man/man1: mkdir -p share/man/man1 +.PHONY: bitch +bitch: bin/bitch +bin/bitch: bin ../bitch/bitch + cp ../bitch/bitch bin/ +../bitch/bitch: + $(MAKE) -C ../bitch + .PHONY: battery battery: bin/battery bin/battery: bin ../battery/battery diff --git a/src/id.c b/id/id.c similarity index 100% rename from src/id.c rename to id/id.c