-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfgmgr.h
67 lines (57 loc) · 2.62 KB
/
cfgmgr.h
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
void cancelconfig()
{
gtk_widget_destroy(dialog);
}
void on_preferences(GtkWidget *button, gpointer data)
{
dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(dialog), "GXCapIndicator Settings");
theme = gtk_icon_theme_get_default();
info = gtk_icon_theme_lookup_icon(theme, "keyboard-caps-enabled", 48, 0);
if (info != NULL)
{
icon = gtk_icon_info_load_icon(info, NULL);
gtk_window_set_icon(GTK_WINDOW(dialog), icon);
g_object_unref(icon);
g_object_unref(info);
}
gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
grid = gtk_grid_new();
gtk_container_add(GTK_CONTAINER(dialog), grid);
gtk_grid_set_column_homogeneous(GTK_GRID(grid), TRUE);
gtk_grid_set_row_homogeneous(GTK_GRID(grid), TRUE);
gshowcap = gtk_check_button_new();
gshownum = gtk_check_button_new();
gcapstate = gtk_check_button_new();
gnumstate = gtk_check_button_new();
gupdrate = gtk_entry_new();
btn_cancel = gtk_button_new_with_label("cancel");
btn_savesettings = gtk_button_new_with_label("save");
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Show Caps Lock:"), 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gshowcap, 1, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Show Num Lock:"), 0, 1, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gshownum, 1, 1, 1, 1);
#ifdef WITHX11
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Update rate (seconds):"), 0, 2, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gupdrate, 1, 2, 1, 1);
#else
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Start with caps lock \n visually enabled:"), 0, 2, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gcapstate, 1, 2, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Start with num lock \n visually enabled:"), 0, 3, 1, 1);
gtk_grid_attach(GTK_GRID(grid), gnumstate, 1, 3, 1, 1);
#endif
gtk_grid_attach(GTK_GRID(grid), btn_cancel, 0, 6, 1, 1);
gtk_grid_attach(GTK_GRID(grid), btn_savesettings, 1, 6, 1, 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gshowcap), !!showcap);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gshownum), !!shownum);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gcapstate), !!vcapstate);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gnumstate), !!vnumstate);
char buffer[32];
snprintf(buffer, sizeof(buffer), "%d", updrate);
gtk_entry_set_text(GTK_ENTRY(gupdrate), buffer);
g_signal_connect(btn_cancel, "clicked", G_CALLBACK(cancelconfig), NULL);
g_signal_connect(btn_savesettings, "clicked", G_CALLBACK(saveconfig), dialog);
gtk_widget_show_all(dialog);
gtk_main();
}