diff options
| author | Federico Angelilli <code@fedang.net> | 2024-05-14 10:54:47 +0200 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-05-14 10:54:47 +0200 |
| commit | 247a74810374894a74ca63af4eb86d9614cf6c74 (patch) | |
| tree | 52f85875ab4aa0ca64112d86a151ba0cc44a4d5b /src/comet.c | |
| parent | 3768820fb27ff394114a17f6612417bcc78689a0 (diff) | |
Implement multiple windows
Diffstat (limited to 'src/comet.c')
| -rw-r--r-- | src/comet.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/comet.c b/src/comet.c index 54bb851..86023fc 100644 --- a/src/comet.c +++ b/src/comet.c @@ -300,7 +300,21 @@ int main(int argc, char **argv) draw_set_context(draw, context); draw_set_size(draw, height, x_padding, x_padding, y_padding); - State *state = state_create(win, draw); + State *state = state_create("$1", win, draw); + + Window *win2 = window_create(con); + int y_padding2 = EVEN(round(screen_height * 0.204)); + + PangoContext *context2 = pango_cairo_create_context(window_get_context(win2)); + + Drawer *draw2 = draw_create(); + draw_set_background(draw2, background_all); + draw_set_separator(draw2, 10); + draw_set_font(draw2, "Hack 13 Bold"); + draw_set_context(draw2, context); + draw_set_size(draw2, height, x_padding, x_padding, y_padding2); + + State *state2 = state_create("$2", win2, draw2); Color color = { 0.4, 0.4, 0.4, 1 }; Color purple = { 0.502, 0.168, 0.886, 1 }; @@ -386,7 +400,19 @@ int main(int argc, char **argv) state_order_button(state); - connect_attach_state(con, state); + Button *btn2 = button_simple_create(PANGO_ALIGN_LEFT, color); + button_set_padding(btn2, 1, 1); + button_simple_set_text(btn2, g_strdup("YAY"), text_color); + button_simple_set_action(btn2, show_action, NULL); + + state_add_button(state2, btn2); + state_order_button(state2); + + // TODO: Mirroring + //state2->btns = state->btns; + + connect_add_state(con, state); + connect_add_state(con, state2); connect_attach_source(con); guint source_alrm = g_unix_signal_add(SIGUSR1, G_SOURCE_FUNC(date_update), date_btn); @@ -416,9 +442,17 @@ int main(int argc, char **argv) // NOTE: Buttons are freed by state_destroy dwm_destroy(dwm); + + g_list_free_full(state->btns, (GDestroyNotify)button_destroy); + state_destroy(state); draw_destroy(draw); window_destroy(win); + + state_destroy(state2); + draw_destroy(draw2); + window_destroy(win2); + connect_destroy(con); return 0; |
