Skip to content

Commit

Permalink
Run 'make format'
Browse files Browse the repository at this point in the history
  • Loading branch information
wins1ey committed Jun 3, 2024
1 parent f51ec0a commit 55be057
Show file tree
Hide file tree
Showing 21 changed files with 1,162 additions and 1,704 deletions.
189 changes: 88 additions & 101 deletions src/auto-splitter.c

Large diffs are not rendered by default.

883 changes: 413 additions & 470 deletions src/bind.c

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@

G_BEGIN_DECLS

typedef void (* KeybinderHandler) (const char *keystring, void *user_data);
typedef void (*KeybinderHandler)(const char *keystring, void *user_data);

void keybinder_init (void);
void keybinder_init(void);

gboolean keybinder_bind (const char *keystring,
KeybinderHandler handler,
void *user_data);
gboolean keybinder_bind(const char *keystring,
KeybinderHandler handler,
void *user_data);

gboolean
keybinder_bind_full (const char *keystring,
KeybinderHandler handler,
void *user_data,
GDestroyNotify notify);
keybinder_bind_full(const char *keystring,
KeybinderHandler handler,
void *user_data,
GDestroyNotify notify);

void keybinder_unbind (const char *keystring,
KeybinderHandler handler);
void keybinder_unbind(const char *keystring,
KeybinderHandler handler);

void keybinder_unbind_all (const char *keystring);
void keybinder_unbind_all(const char *keystring);

guint32 keybinder_get_current_event_time (void);
guint32 keybinder_get_current_event_time(void);

G_END_DECLS

Expand Down
19 changes: 7 additions & 12 deletions src/component/best-sum.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "components.h"

typedef struct _LSBestSum
{
typedef struct _LSBestSum {
LSComponent base;
GtkWidget *container;
GtkWidget *sum_of_bests;
Expand All @@ -16,8 +15,7 @@ LSComponent *ls_component_best_sum_new()
GtkWidget *label;

self = malloc(sizeof(LSBestSum));
if (!self)
{
if (!self) {
return NULL;
}
self->base.ops = &ls_best_sum_operations;
Expand Down Expand Up @@ -53,12 +51,11 @@ static GtkWidget *best_sum_widget(LSComponent *self)
}

static void best_sum_show_game(LSComponent *self_,
ls_game *game, ls_timer *timer)
ls_game *game, ls_timer *timer)
{
LSBestSum *self = (LSBestSum *)self_;
char str[256];
if (game->split_count && timer->sum_of_bests)
{
if (game->split_count && timer->sum_of_bests) {
ls_time_string(str, timer->sum_of_bests);
gtk_label_set_text(GTK_LABEL(self->sum_of_bests), str);
}
Expand All @@ -71,22 +68,20 @@ static void best_sum_clear_game(LSComponent *self_)
}

static void best_sum_draw(LSComponent *self_, ls_game *game,
ls_timer *timer)
ls_timer *timer)
{
LSBestSum *self = (LSBestSum *)self_;
char str[256];
remove_class(self->sum_of_bests, "time");
gtk_label_set_text(GTK_LABEL(self->sum_of_bests), "-");
if (timer->sum_of_bests)
{
if (timer->sum_of_bests) {
add_class(self->sum_of_bests, "time");
ls_time_string(str, timer->sum_of_bests);
gtk_label_set_text(GTK_LABEL(self->sum_of_bests), str);
}
}

LSComponentOps ls_best_sum_operations =
{
LSComponentOps ls_best_sum_operations = {
.delete = best_sum_delete,
.widget = best_sum_widget,
.show_game = best_sum_show_game,
Expand Down
37 changes: 11 additions & 26 deletions src/component/clock.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "components.h"

typedef struct _LSTimer
{
typedef struct _LSTimer {
LSComponent base;
GtkWidget *time;
GtkWidget *time_seconds;
Expand All @@ -15,8 +14,7 @@ LSComponent *ls_component_timer_new()
GtkWidget *spacer;

self = malloc(sizeof(LSTimer));
if (!self)
{
if (!self) {
return NULL;
}
self->base.ops = &ls_timer_operations;
Expand Down Expand Up @@ -48,7 +46,6 @@ LSComponent *ls_component_timer_new()
gtk_container_add(GTK_CONTAINER(spacer), self->time_millis);
gtk_widget_show(self->time_millis);


return (LSComponent *)self;
}

Expand All @@ -70,7 +67,6 @@ static void timer_clear_game(LSComponent *self_)
gtk_label_set_text(GTK_LABEL(self->time_millis), "");
remove_class(self->time, "behind");
remove_class(self->time, "losing");

}

static void timer_draw(LSComponent *self_, ls_game *game, ls_timer *timer)
Expand All @@ -80,8 +76,7 @@ static void timer_draw(LSComponent *self_, ls_game *game, ls_timer *timer)
int curr;

curr = timer->curr_split;
if (curr == game->split_count)
{
if (curr == game->split_count) {
--curr;
}

Expand All @@ -90,32 +85,23 @@ static void timer_draw(LSComponent *self_, ls_game *game, ls_timer *timer)
remove_class(self->time, "losing");
remove_class(self->time, "best-split");

if (curr == game->split_count)
{
if (curr == game->split_count) {
curr = game->split_count - 1;
}
if (timer->time <= 0)
{
if (timer->time <= 0) {
add_class(self->time, "delay");
}
else
{
} else {
if (timer->curr_split == game->split_count
&& timer->split_info[curr]
& LS_INFO_BEST_SPLIT)
{
& LS_INFO_BEST_SPLIT) {
add_class(self->time, "best-split");
}
else
{
} else {
if (timer->split_info[curr]
& LS_INFO_BEHIND_TIME)
{
& LS_INFO_BEHIND_TIME) {
add_class(self->time, "behind");
}
if (timer->split_info[curr]
& LS_INFO_LOSING_TIME)
{
& LS_INFO_LOSING_TIME) {
add_class(self->time, "losing");
}
}
Expand All @@ -126,8 +112,7 @@ static void timer_draw(LSComponent *self_, ls_game *game, ls_timer *timer)
gtk_label_set_text(GTK_LABEL(self->time_millis), millis);
}

LSComponentOps ls_timer_operations =
{
LSComponentOps ls_timer_operations = {
.delete = ls_timer_delete,
.widget = timer_widget,
.clear_game = timer_clear_game,
Expand Down
19 changes: 9 additions & 10 deletions src/component/components.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ LSComponent *ls_component_best_sum_new();
LSComponent *ls_component_pb_new();
LSComponent *ls_component_wr_new();

LSComponentAvailable ls_components[] =
{
{"title", ls_component_title_new},
{"splits", ls_component_splits_new},
{"timer", ls_component_timer_new},
{"prev-segment", ls_component_prev_segment_new},
{"best-sum", ls_component_best_sum_new},
{"pb", ls_component_pb_new},
{"wr", ls_component_wr_new},
{NULL, NULL}
LSComponentAvailable ls_components[] = {
{ "title", ls_component_title_new },
{ "splits", ls_component_splits_new },
{ "timer", ls_component_timer_new },
{ "prev-segment", ls_component_prev_segment_new },
{ "best-sum", ls_component_best_sum_new },
{ "pb", ls_component_pb_new },
{ "wr", ls_component_wr_new },
{ NULL, NULL }
};

void add_class(GtkWidget *widget, const char *class)
Expand Down
13 changes: 5 additions & 8 deletions src/component/components.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#ifndef __COMPONENTS_H__
#define __COMPONENTS_H__

#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>

#include "../timer.h"

typedef struct _LSComponent LSComponent;
typedef struct _LSComponentOps LSComponentOps;
typedef struct _LSComponentAvailable LSComponentAvailable;

struct _LSComponent
{
struct _LSComponent {
LSComponentOps *ops;
};

struct _LSComponentOps
{
struct _LSComponentOps {
void (*delete)(LSComponent *self);
GtkWidget *(*widget)(LSComponent *self);

Expand All @@ -34,8 +32,7 @@ struct _LSComponentOps
void (*cancel_run)(LSComponent *self, ls_timer *timer);
};

struct _LSComponentAvailable
{
struct _LSComponentAvailable {
char *name;
LSComponent *(*new)();
};
Expand Down
27 changes: 9 additions & 18 deletions src/component/pb.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "components.h"

typedef struct _LSPb
{
typedef struct _LSPb {
LSComponent base;
GtkWidget *container;
GtkWidget *personal_best;
Expand All @@ -16,8 +15,7 @@ LSComponent *ls_component_pb_new()
GtkWidget *label;

self = malloc(sizeof(LSPb));
if (!self)
{
if (!self) {
return NULL;
}
self->base.ops = &ls_pb_operations;
Expand Down Expand Up @@ -53,20 +51,17 @@ static GtkWidget *pb_widget(LSComponent *self)
}

static void pb_show_game(LSComponent *self_,
ls_game *game, ls_timer *timer)
ls_game *game, ls_timer *timer)
{
LSPb *self = (LSPb *)self_;
char str[256];
if (game->split_count && game->split_times[game->split_count - 1])
{
if (game->split_times[game->split_count - 1])
{
if (game->split_count && game->split_times[game->split_count - 1]) {
if (game->split_times[game->split_count - 1]) {
ls_time_string(
str, game->split_times[game->split_count - 1]);
gtk_label_set_text(GTK_LABEL(self->personal_best), str);
}
}

}

static void pb_clear_game(LSComponent *self_)
Expand All @@ -76,7 +71,7 @@ static void pb_clear_game(LSComponent *self_)
}

static void pb_draw(LSComponent *self_, ls_game *game,
ls_timer *timer)
ls_timer *timer)
{
LSPb *self = (LSPb *)self_;
char str[256];
Expand All @@ -86,24 +81,20 @@ static void pb_draw(LSComponent *self_, ls_game *game,
&& timer->split_times[game->split_count - 1]
&& (!game->split_times[game->split_count - 1]
|| (timer->split_times[game->split_count - 1]
< game->split_times[game->split_count - 1])))
{
< game->split_times[game->split_count - 1]))) {
add_class(self->personal_best, "time");
ls_time_string(
str, timer->split_times[game->split_count - 1]);
gtk_label_set_text(GTK_LABEL(self->personal_best), str);
}
else if (game->split_times[game->split_count - 1])
{
} else if (game->split_times[game->split_count - 1]) {
add_class(self->personal_best, "time");
ls_time_string(
str, game->split_times[game->split_count - 1]);
gtk_label_set_text(GTK_LABEL(self->personal_best), str);
}
}

LSComponentOps ls_pb_operations =
{
LSComponentOps ls_pb_operations = {
.delete = pb_delete,
.widget = pb_widget,
.show_game = pb_show_game,
Expand Down
Loading

0 comments on commit 55be057

Please sign in to comment.