aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animate.h2
-rw-r--r--src/comet.c17
-rw-r--r--src/connect.c4
3 files changed, 15 insertions, 8 deletions
diff --git a/src/animate.h b/src/animate.h
index d153cda..2323017 100644
--- a/src/animate.h
+++ b/src/animate.h
@@ -5,6 +5,8 @@
#include "draw.h"
+#define MILLIS(n) ((n) * G_TIME_SPAN_MILLISECOND)
+
typedef struct Animation Animation;
typedef struct State State;
diff --git a/src/comet.c b/src/comet.c
index 9c552f5..b417489 100644
--- a/src/comet.c
+++ b/src/comet.c
@@ -211,7 +211,7 @@ static void menu_action(Button *btn)
button_simple_set_text(btn, g_strdup(menu_ctx->strings[to_open]), CAST(btn, ButtonSimple)->text_color);
if (!to_open) {
- Animation *shrink = animation_group_shrink_create(600 * G_TIME_SPAN_MILLISECOND);
+ Animation *shrink = animation_group_shrink_create(MILLIS(600));
if (button_set_animation((gpointer)menu_ctx->group, shrink))
state_request_animation(menu_ctx->state);
@@ -238,7 +238,7 @@ static void register_buttons(State *state, Color color, Color text_color, Color
state_add_button(state, cpu_btn);
cpu_update(cpu_btn);
- g_timeout_add(G_TIME_SPAN_MILLISECOND, G_SOURCE_FUNC(cpu_update), cpu_btn);
+ g_timeout_add(MILLIS(1), G_SOURCE_FUNC(cpu_update), cpu_btn);
// Temperature button
Button *temp_btn = button_simple_create(PANGO_ALIGN_RIGHT, color);
@@ -249,7 +249,7 @@ static void register_buttons(State *state, Color color, Color text_color, Color
state_add_button(state, temp_btn);
temp_update(temp_btn);
- g_timeout_add(20 * G_TIME_SPAN_MILLISECOND, G_SOURCE_FUNC(temp_update), temp_btn);
+ g_timeout_add(MILLIS(20), G_SOURCE_FUNC(temp_update), temp_btn);
// Ram usage button
Button *ram_btn = button_simple_create(PANGO_ALIGN_RIGHT, color);
@@ -260,7 +260,7 @@ static void register_buttons(State *state, Color color, Color text_color, Color
state_add_button(state, ram_btn);
ram_update(ram_btn);
- g_timeout_add(10 * G_TIME_SPAN_MILLISECOND, G_SOURCE_FUNC(ram_update), ram_btn);
+ g_timeout_add(MILLIS(10), G_SOURCE_FUNC(ram_update), ram_btn);
// Disk usage button
Button *disk_btn = button_simple_create(PANGO_ALIGN_RIGHT, color);
@@ -271,7 +271,7 @@ static void register_buttons(State *state, Color color, Color text_color, Color
state_add_button(state, disk_btn);
disk_update(disk_btn);
- g_timeout_add(60 * G_TIME_SPAN_MILLISECOND, G_SOURCE_FUNC(disk_update), disk_btn);
+ g_timeout_add(MILLIS(60), G_SOURCE_FUNC(disk_update), disk_btn);
}
int main(int argc, char **argv)
@@ -325,10 +325,15 @@ int main(int argc, char **argv)
timer_t timer;
} date_ctx = { state, 0 };
+ int text_w;
+ draw_compute_text_size(state->draw, "Wednesday 31 12:34", &text_w, NULL);
+ int min_w = text_w + line_w + state->draw->height;
+
// Date & time button
Button *date_btn = button_simple_create(PANGO_ALIGN_CENTER, color);
- button_simple_set_text(date_btn, g_strdup("date"), text_color);
+ button_simple_set_text(date_btn, NULL, text_color);
button_simple_set_action(date_btn, NULL, &date_ctx);
+ button_set_width(date_btn, 0, min_w);
state_add_button(state, date_btn);
struct sigevent sev = { 0 };
diff --git a/src/connect.c b/src/connect.c
index 3788db1..4b04ac4 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -113,8 +113,8 @@ static bool button_action_find(State *state, GList *layouts, int x, int y)
}
// NOTE: Animations may change the layouts!
- Animation *anim = animation_shine_create(300 * G_TIME_SPAN_MILLISECOND);
- //Animation *anim = animation_pulse_create(200 * G_TIME_SPAN_MILLISECOND);
+ Animation *anim = animation_shine_create(MILLIS(250));
+ //Animation *anim = animation_pulse_create(MILLIS(200));
if (button_set_animation(btn, anim))
state_request_animation(state);