-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.c
122 lines (97 loc) · 4.77 KB
/
menu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <stdlib.h>
void open_browser() {
system("firefox &");
system("pkill -f \"build/menu\"");
}
void open_file_manager() {
system("thunar &");
system("pkill -f \"build/menu\"");
}
void open_terminal() {
system("xfce4-terminal &");
system("pkill -f \"build/menu\"");
}
void open_screen_settings() {
system("xfce4-display-settings &");
system("pkill -f \"build/menu\"");
}
void open_set_wallpaper() {
system("build/settings &");
system("pkill -f \"build/menu\"");
}
void open_search() {
system("rofi -show run -theme-str \"window { location: southwest; anchor: southwest; width: 360; height: 260; }\"");
}
void open_shutdown() {
system("systemctl poweroff");
}
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Panel");
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
gtk_window_set_default_size(GTK_WINDOW(window), 640, 720);
GtkWidget *fixed = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(window), fixed);
//GtkWidget *image = gtk_image_new_from_file("assets/menu9x.png");
GtkWidget *image = gtk_image_new_from_file("/home/anon/.comfy/menubg.png");
gtk_fixed_put(GTK_FIXED(fixed), image, 0, 0);
//GtkWidget *image2 = gtk_image_new_from_file("assets/user.png");
//gtk_fixed_put(GTK_FIXED(fixed), image2, 456, 56);
GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
gtk_fixed_put(GTK_FIXED(fixed), vbox, 13, 10);
GtkWidget *create_button(const gchar *label, const gchar *icon_path) {
GtkWidget *button = gtk_button_new();
GtkWidget *label_widget = gtk_label_new(label);
GtkWidget *icon_widget = gtk_image_new_from_file(icon_path);
GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
gtk_box_pack_start(GTK_BOX(hbox), icon_widget, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), label_widget, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), hbox);
return button;
}
GtkWidget *button1 = create_button("Web Browser", "assets/firefox.png");
GtkWidget *button2 = create_button("File Manager", "assets/folder.png");
GtkWidget *button3 = create_button("Terminal", "assets/terminal.png");
GtkWidget *button4 = create_button("Screen Settings", "assets/settings.png");
GtkWidget *button5 = create_button("Settings", "assets/settings.png");
GtkWidget *button6 = create_button("Search", "assets/search.png");
GtkWidget *button7 = create_button("Turn Off", "assets/power.png");
gtk_widget_set_size_request(button1, 375, 60);
gtk_widget_set_size_request(button2, 200, 60);
gtk_widget_set_size_request(button3, 200, 60);
gtk_widget_set_size_request(button4, 200, 60);
gtk_widget_set_size_request(button5, 200, 60);
gtk_widget_set_size_request(button6, 200, 40);
gtk_widget_set_size_request(button7, 100, 40);
gtk_box_pack_start(GTK_BOX(vbox), button1, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), button2, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), button3, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), button4, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), button5, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), button6, FALSE, FALSE, 290);
GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
gtk_fixed_put(GTK_FIXED(fixed), hbox, 450, 650);
gtk_box_pack_start(GTK_BOX(hbox), button7, FALSE, FALSE, 0);
g_signal_connect(button1, "clicked", G_CALLBACK(open_browser), NULL);
g_signal_connect(button2, "clicked", G_CALLBACK(open_file_manager), NULL);
g_signal_connect(button3, "clicked", G_CALLBACK(open_terminal), NULL);
g_signal_connect(button4, "clicked", G_CALLBACK(open_screen_settings), NULL);
g_signal_connect(button5, "clicked", G_CALLBACK(open_set_wallpaper), NULL);
g_signal_connect(button6, "clicked", G_CALLBACK(open_search), NULL);
g_signal_connect(button7, "clicked", G_CALLBACK(open_shutdown), NULL);
gtk_widget_show_all(window);
GdkScreen *screen = gdk_screen_get_default();
int screen_width = gdk_screen_get_width(screen);
int screen_height = gdk_screen_get_height(screen);
// Position the window at the bottom left corner with a 50px margin
gtk_window_move(GTK_WINDOW(window), 3, screen_height - 720 - 50);
GtkCssProvider *provider = gtk_css_provider_new();
gtk_css_provider_load_from_file(provider, g_file_new_for_path("style.css"), NULL);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_main();
return 0;
}