1
0
Fork 0

add more features

This commit is contained in:
dtb 2022-10-03 02:00:38 -04:00
parent 63236f9e36
commit 5c9cda563c
5 changed files with 113 additions and 10 deletions

View File

@ -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

45
bitch/bitch.1 Normal file
View File

@ -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.

View File

@ -1,36 +1,77 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h> /* stderr, atoi(3) */
#include <sysexits.h> /* EX_USAGE */
#include <unistd.h> /* getopt(3) */
/* Written for Gtk4 */
#include <gtk/gtk.h>
#ifdef GTK4
# include <gtk/gtk.h>
#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

7
dist/Makefile vendored
View File

@ -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

View File