Initial commit

This commit is contained in:
Trevor Vallender 2023-06-02 16:36:35 +01:00
commit 9f1c659bcb
1 changed files with 58 additions and 0 deletions

58
main.c Normal file
View File

@ -0,0 +1,58 @@
#include <gtk-4.0/gtk/gtk.h>
#include <stdlib.h>
static void launch_mopidy(GtkWidget *widget, gpointer data, gchar **app_name) {
g_print("LAUNCHING!\n");
int status = system("mopidy");
}
static void launch_retroarch(GtkWidget *widget, gpointer data, gchar **app_name) {
g_print("LAUNCHING!\n");
int status = system("retroarch");
}
static void activate(GtkApplication *app, gpointer user_data) {
GtkWidget *window;
GtkWidget *grid;
GtkWidget *button;
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Launcher");
grid = gtk_grid_new();
gtk_window_set_child(GTK_WINDOW(window), grid);
button = gtk_button_new_with_label("RetroArch");
g_signal_connect(button, "clicked", G_CALLBACK(launch_retroarch), NULL);
gtk_grid_attach(GTK_GRID(grid), button, 0, 0, 1, 1);
gtk_widget_set_hexpand(GTK_WIDGET(button), true);
gtk_widget_set_vexpand(GTK_WIDGET(button), true);
button = gtk_button_new_with_label("Mopidy");
g_signal_connect(button, "clicked", G_CALLBACK(launch_mopidy), NULL);
gtk_grid_attach(GTK_GRID(grid), button, 1, 0, 1, 1);
gtk_widget_set_hexpand(GTK_WIDGET(button), true);
gtk_widget_set_vexpand(GTK_WIDGET(button), true);
button = gtk_button_new_with_label("Power off");
g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_window_destroy), window);
gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
gtk_widget_set_hexpand(GTK_WIDGET(button), true);
gtk_grid_set_row_spacing(GTK_GRID(grid), 10);
gtk_grid_set_column_spacing(GTK_GRID(grid), 10);
gtk_widget_show(window);
}
int main(int argc, char **argv) {
GtkApplication *app;
int status;
app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}