#include "TimerMainWindow.h" #include "TimerClock.h" #include "TimerEditWindow.h" #include "TimerSettingsWindow.h" #include "TimerMiniWindow.h" #include struct _TimerMainWindow { GtkApplicationWindow parent; GtkWidget *timerButton; GtkWidget *timerLabel; GtkWidget *nameBox; GtkWidget *startStopButton; GtkWidget *resetButton; GtkWidget *saveButton; GtkWidget *optionsButton; GtkWidget *taskTreeBox; GtkWidget *taskTree; GtkWidget *shrinkButton; TimerClock *timerClock; TimerClock *updateClock; GKeyFile *keyFile; TimerMiniWindow *miniWindow; int miniWindowFirstOpen; int miniWindowMode; char *labelColorString; GDateTime *lastUpdateTime; /* time in seconds */ gint64 currentTime; GDateTime *startTime; }; G_DEFINE_TYPE(TimerMainWindow, timer_main_window, GTK_TYPE_APPLICATION_WINDOW); static gboolean timer_main_window_get_boolean_with_default( TimerMainWindow *self, const char *group, const char *key, gboolean def) { GError *err = NULL; gboolean b = g_key_file_get_boolean(self->keyFile, group, key, &err); if (err != NULL) { g_error_free(err); return def; } return b; } static char *timer_main_window_get_string_with_default(TimerMainWindow *self, const char *group, const char *key, const char *def) { GError *err = NULL; char *s = g_key_file_get_string(self->keyFile, group, key, &err); if (err != NULL) { g_error_free(err); return g_strdup(def); } return s; } static void timer_main_window_make_data_file(TimerMainWindow *self) { char *path = timer_main_window_get_string_with_default(self, "Settings", "Data Path", timer_application_get_default_data_file(TIMER_APPLICATION(gtk_window_get_application(GTK_WINDOW(self))))); GFile *file = g_file_new_for_path(path); GFile *parent = g_file_get_parent(file); GError *err = NULL; g_file_make_directory_with_parents(parent, NULL, &err); if (err != NULL) { if (err->code != G_IO_ERROR_EXISTS) { GtkWidget *msgDiag = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not create data file: %s", err->message); gtk_window_set_position(GTK_WINDOW(msgDiag), GTK_WIN_POS_MOUSE); gtk_dialog_run(GTK_DIALOG(msgDiag)); gtk_widget_destroy(msgDiag); } g_clear_error(&err); } GFileOutputStream *stream = g_file_create(file, G_FILE_CREATE_NONE, NULL, &err); if (err != NULL) { if (err->code != G_IO_ERROR_EXISTS) { GtkWidget *msgDiag = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not create data file: %s", err->message); gtk_window_set_position(GTK_WINDOW(msgDiag), GTK_WIN_POS_MOUSE); gtk_dialog_run(GTK_DIALOG(msgDiag)); gtk_widget_destroy(msgDiag); } g_error_free(err); } else { g_output_stream_write(G_OUTPUT_STREAM(stream), "[]", 2, NULL, &err); if (err != NULL) { GtkWidget *msgDiag = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "An internal error occured: %s", err->message); gtk_window_set_position(GTK_WINDOW(msgDiag), GTK_WIN_POS_MOUSE); gtk_dialog_run(GTK_DIALOG(msgDiag)); gtk_widget_destroy(msgDiag); g_error_free(err); } g_object_unref(stream); } timer_task_tree_set_data_path(TIMER_TASK_TREE(self->taskTree), path); g_free(path); g_object_unref(parent); g_object_unref(file); } gboolean timer_main_window_is_always_on_top(TimerMainWindow *self) { return timer_main_window_get_boolean_with_default(self, "Settings", "Always on Top", FALSE); } GDateTime *timer_main_window_get_last_task_end(TimerMainWindow *self) { return timer_task_tree_get_last_task_end(TIMER_TASK_TREE(self->taskTree)); } static void timer_main_window_interpret_settings(TimerMainWindow *self) { gtk_window_set_keep_above(GTK_WINDOW(self), timer_main_window_get_boolean_with_default( self, "Settings", "Always on Top", FALSE)); gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(self->nameBox)); gtk_combo_box_text_remove_all(timer_mini_window_get_name_box(self->miniWindow)); gsize len; GError *err = NULL; char **data = g_key_file_get_string_list(self->keyFile, "Settings", "Tasks", &len, &err); if (err == NULL) { timer_task_tree_set_task_names(TIMER_TASK_TREE(self->taskTree), (const char **)data, len); gsize i; for (i = 0; i < len; ++i) { gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(self->nameBox), data[i]); gtk_combo_box_text_append_text(timer_mini_window_get_name_box(self->miniWindow), data[i]); g_free(data[i]); } g_free(data); } else { timer_task_tree_set_task_names(TIMER_TASK_TREE(self->taskTree), NULL, 0); g_error_free(err); } char *taskName = timer_main_window_get_string_with_default( self, "Cache", "Current Name", ""); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(self->nameBox))), taskName); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN( timer_mini_window_get_name_box(self->miniWindow)))), taskName); g_free(taskName); int x = g_key_file_get_integer(self->keyFile, "Cache", "x", NULL); int y = g_key_file_get_integer(self->keyFile, "Cache", "y", NULL); int w = g_key_file_get_integer(self->keyFile, "Cache", "width", NULL); int h = g_key_file_get_integer(self->keyFile, "Cache", "height", NULL); gtk_window_move(GTK_WINDOW(self), x, y); gtk_window_resize(GTK_WINDOW(self), w, h); timer_main_window_make_data_file(self); } TimerMainWindow *timer_main_window_new(TimerApplication *app) { TimerMainWindow *win = TIMER_MAIN_WINDOW( g_object_new(TIMER_TYPE_MAIN_WINDOW, "application", app, NULL)); g_key_file_load_from_file(win->keyFile, timer_application_get_config_file(app), G_KEY_FILE_NONE, NULL); timer_main_window_interpret_settings(win); timer_task_tree_expand_today(TIMER_TASK_TREE(win->taskTree)); win->lastUpdateTime = g_date_time_new_now_local(); timer_clock_start(win->updateClock); return win; } char *timer_main_window_get_task_csv(TimerMainWindow *self) { return timer_task_tree_get_csv(TIMER_TASK_TREE(self->taskTree)); } TimerDataPoint *timer_main_window_get_day_data(TimerMainWindow *self, gsize *len) { return timer_task_tree_get_day_data(TIMER_TASK_TREE(self->taskTree), len); } TimerDataPoint *timer_main_window_get_task_data(TimerMainWindow *self, gsize *len) { return timer_task_tree_get_task_data(TIMER_TASK_TREE(self->taskTree), len); } static gboolean timer_main_window_update_time(TimerMainWindow *self) { int hour = floor(self->currentTime / 3600.0f); int minute = floor(self->currentTime / 60.0f) - (hour * 60); int second = self->currentTime - (hour * 3600) - (minute * 60); char *time = g_strdup_printf( "%02d:%02d:%02d", timer_clock_is_running(self->timerClock) ? "red" : self->labelColorString, hour, minute, second); gtk_label_set_markup(GTK_LABEL(self->timerLabel), time); gtk_label_set_markup(timer_mini_window_get_timer_label(self->miniWindow), time); g_free(time); return FALSE; } static void timer_clock_callback(TimerMainWindow *win) { ++win->currentTime; g_main_context_invoke(NULL, G_SOURCE_FUNC(timer_main_window_update_time), win); } static void options_button_callback(GtkWidget *btn, TimerMainWindow *win) { TimerSettingsWindow *diag = timer_settings_window_new( TIMER_APPLICATION(gtk_window_get_application(GTK_WINDOW(win))), win->keyFile, GTK_WINDOW(win)); int resp = gtk_dialog_run(GTK_DIALOG(diag)); if (resp == GTK_RESPONSE_APPLY) { GKeyFile *sKeyFile = timer_settings_window_get_key_file(diag); gsize len; char *data = g_key_file_to_data(sKeyFile, &len, NULL); g_key_file_load_from_data(win->keyFile, data, len, G_KEY_FILE_NONE, NULL); g_free(data); GError *err = NULL; g_key_file_save_to_file( win->keyFile, timer_application_get_config_file( TIMER_APPLICATION(gtk_window_get_application(GTK_WINDOW(win)))), &err); if (err != NULL) { GtkWidget *msgDiag = gtk_message_dialog_new( GTK_WINDOW(win), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not save settings: %s", err->message); gtk_window_set_position(GTK_WINDOW(msgDiag), GTK_WIN_POS_MOUSE); gtk_dialog_run(GTK_DIALOG(msgDiag)); g_error_free(err); gtk_widget_destroy(msgDiag); } timer_main_window_interpret_settings(win); } gtk_widget_destroy(GTK_WIDGET(diag)); } static void start_stop_button_callback(GtkButton *btn, TimerMainWindow *win) { if (timer_clock_is_running(win->timerClock)) { timer_clock_stop(win->timerClock); gtk_button_set_label(GTK_BUTTON(win->startStopButton), "Start"); gtk_button_set_label(timer_mini_window_get_start_stop_button(win->miniWindow), "Start"); timer_main_window_update_time(win); } else { timer_clock_start(win->timerClock); gtk_button_set_label(GTK_BUTTON(win->startStopButton), "Stop"); gtk_button_set_label(timer_mini_window_get_start_stop_button(win->miniWindow), "Stop"); gtk_widget_set_sensitive(win->resetButton, TRUE); gtk_widget_set_sensitive(win->saveButton, TRUE); gtk_widget_set_sensitive(GTK_WIDGET(timer_mini_window_get_save_button(win->miniWindow)), TRUE); win->startTime = g_date_time_new_now_local(); timer_main_window_update_time(win); } } static void reset_button_callback(GtkButton *btn, TimerMainWindow *win) { if (timer_clock_is_running(win->timerClock)) { timer_clock_stop(win->timerClock); } win->currentTime = 0; timer_main_window_update_time(win); gtk_button_set_label(GTK_BUTTON(win->startStopButton), "Start"); gtk_button_set_label(timer_mini_window_get_start_stop_button(win->miniWindow), "Start"); gtk_widget_set_sensitive(win->resetButton, FALSE); gtk_widget_set_sensitive(win->saveButton, FALSE); gtk_widget_set_sensitive(GTK_WIDGET(timer_mini_window_get_save_button(win->miniWindow)), FALSE); g_date_time_unref(win->startTime); win->startTime = NULL; } static void save_button_callback(GtkButton *btn, TimerMainWindow *win) { if (timer_clock_is_running(win->timerClock)) { timer_clock_stop(win->timerClock); } const char *text; if (win->miniWindowMode) { text = gtk_combo_box_text_get_active_text(timer_mini_window_get_name_box(win->miniWindow)); } else { text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(win->nameBox)); } timer_task_tree_add_task(TIMER_TASK_TREE(win->taskTree), win->startTime, strcmp(text, "") == 0 ? "Untitled" : text, win->currentTime); win->currentTime = 0; g_date_time_unref(win->startTime); win->startTime = NULL; timer_main_window_update_time(win); gtk_button_set_label(GTK_BUTTON(win->startStopButton), "Start"); gtk_button_set_label(timer_mini_window_get_start_stop_button(win->miniWindow), "Start"); gtk_widget_set_sensitive(win->resetButton, FALSE); gtk_widget_set_sensitive(win->saveButton, FALSE); gtk_widget_set_sensitive(GTK_WIDGET(timer_mini_window_get_save_button(win->miniWindow)), FALSE); } static void timer_button_callback(GtkButton *btn, TimerMainWindow *win) { if (timer_clock_is_running(win->timerClock)) { timer_clock_stop(win->timerClock); timer_main_window_update_time(win); gtk_button_set_label(GTK_BUTTON(win->startStopButton), "Start"); gtk_button_set_label(timer_mini_window_get_start_stop_button(win->miniWindow), "Start"); } gsize optLen; const char **names = timer_task_tree_get_task_names(TIMER_TASK_TREE(win->taskTree), &optLen); GDateTime *start = win->startTime == NULL ? g_date_time_new_now_local() : g_date_time_to_local(win->startTime); TimerEditWindow *diag = timer_edit_window_new( gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(win->nameBox)), start, win->currentTime, names, optLen, TRUE, timer_main_window_get_last_task_end(win)); g_date_time_unref(start); int resp = gtk_dialog_run(GTK_DIALOG(diag)); if (resp == GTK_RESPONSE_APPLY) { if (win->startTime) { g_date_time_unref(win->startTime); } win->startTime = timer_edit_window_get_start(diag); win->currentTime = timer_edit_window_get_length(diag); char *name = timer_edit_window_get_name(diag); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(win->nameBox))), name); g_free(name); timer_main_window_update_time(win); gtk_widget_set_sensitive(win->resetButton, TRUE); gtk_widget_set_sensitive(win->saveButton, TRUE); gtk_widget_set_sensitive(GTK_WIDGET(timer_mini_window_get_save_button(win->miniWindow)), TRUE); } gtk_widget_destroy(GTK_WIDGET(diag)); } static gboolean do_update_header_dates(TimerMainWindow *win) { timer_task_tree_update_header_dates(TIMER_TASK_TREE(win->taskTree)); return FALSE; } static gboolean compare_date(GDateTime *dt1, GDateTime *dt2) { int y1, m1, d1, y2, m2, d2; g_date_time_get_ymd(dt1, &y1, &m1, &d1); g_date_time_get_ymd(dt2, &y2, &m2, &d2); return y1 == y2 && m1 == m2 && d1 == d2; } static void update_clock_callback(TimerMainWindow *win) { GDateTime *now = g_date_time_new_now_local(); if (!compare_date(win->lastUpdateTime, now)) { g_main_context_invoke(NULL, G_SOURCE_FUNC(do_update_header_dates), win); g_date_time_unref(win->lastUpdateTime); win->lastUpdateTime = now; } } static void timer_main_window_get_defualt_label_color(TimerMainWindow *self) { GtkStyleContext *ctx = gtk_widget_get_style_context(self->timerLabel); GdkRGBA color; gtk_style_context_get_color(ctx, GTK_STATE_FLAG_NORMAL, &color); self->labelColorString = g_strdup_printf( "#%x%x%x", (int)round(color.red * 255), (int)round(color.green * 255), (int)round(color.blue * 255)); } static void timer_main_window_save_mini_window_specs(TimerMainWindow *self, int x, int y, int w, int h) { g_key_file_set_integer(self->keyFile, "Cache", "smallX", x); g_key_file_set_integer(self->keyFile, "Cache", "smallY", y); g_key_file_set_integer(self->keyFile, "Cache", "smallW", w); g_key_file_set_integer(self->keyFile, "Cache", "smallH", h); } static void timer_main_window_read_mini_window_specs(TimerMainWindow *self, int *x, int *y, int *w, int *h) { *x = g_key_file_get_integer(self->keyFile, "Cache", "smallX", NULL); *y = g_key_file_get_integer(self->keyFile, "Cache", "smallY", NULL); *w = g_key_file_get_integer(self->keyFile, "Cache", "smallW", NULL); *h = g_key_file_get_integer(self->keyFile, "Cache", "smallH", NULL); } static gboolean window_configure_callback(TimerMainWindow *win, GdkEvent *event, gpointer ptr) { int x, y, w, h; gtk_window_get_size(GTK_WINDOW(win), &w, &h); gtk_window_get_position(GTK_WINDOW(win), &x, &y); g_key_file_set_integer(win->keyFile, "Cache", "x", x); g_key_file_set_integer(win->keyFile, "Cache", "y", y); g_key_file_set_integer(win->keyFile, "Cache", "width", w); g_key_file_set_integer(win->keyFile, "Cache", "height", h); return FALSE; } static void window_destroy_callback(TimerMainWindow *win, gpointer ptr) { g_key_file_set_string(win->keyFile, "Cache", "Current Name", gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(win->nameBox))))); GError *err = NULL; g_key_file_save_to_file(win->keyFile, timer_application_get_config_file(TIMER_APPLICATION( gtk_window_get_application(GTK_WINDOW(win)))), &err); if (err != NULL) { GtkWidget *diag = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not save window state: %s", err->message); gtk_window_set_position(GTK_WINDOW(diag), GTK_WIN_POS_MOUSE); gtk_dialog_run(GTK_DIALOG(diag)); gtk_widget_destroy(diag); g_error_free(err); } } static gboolean window_delete_event(TimerMainWindow *win, GdkEvent *evt, gpointer ptr) { if (win->startTime != NULL) { GtkWidget *diag = gtk_message_dialog_new(GTK_WINDOW(win), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Are you sure you would like to exit?"); gtk_window_set_position(GTK_WINDOW(diag), GTK_WIN_POS_MOUSE); int resp = gtk_dialog_run(GTK_DIALOG(diag)); gtk_widget_destroy(diag); return resp == GTK_RESPONSE_NO; } return FALSE; } static gboolean mini_window_configure_callback(TimerMiniWindow *win, GdkEvent *event, TimerMainWindow *main) { if (main->miniWindowMode) { int x, y, w, h; gtk_window_get_position(GTK_WINDOW(win), &x, &y); gtk_window_get_size(GTK_WINDOW(win), &w, &h); timer_main_window_save_mini_window_specs(main, x, y, w, h); } return FALSE; } static gboolean mini_window_delete_event(TimerMiniWindow *win, GdkEvent *evt, TimerMainWindow *main) { if (main->startTime != NULL) { GtkWidget *diag = gtk_message_dialog_new(GTK_WINDOW(win), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Are you sure you would like to exit?"); gtk_window_set_position(GTK_WINDOW(diag), GTK_WIN_POS_MOUSE); int resp = gtk_dialog_run(GTK_DIALOG(diag)); gtk_widget_destroy(diag); if (resp != GTK_RESPONSE_NO) { main->miniWindowMode = FALSE; gtk_widget_destroy(GTK_WIDGET(main)); } } main->miniWindowMode = FALSE; gtk_widget_destroy(GTK_WIDGET(main)); return TRUE; } static void mini_window_expand_callback(GtkButton *btn, TimerMainWindow *win) { win->miniWindowMode = FALSE; gtk_widget_hide(GTK_WIDGET(win->miniWindow)); const char *text = gtk_combo_box_text_get_active_text(timer_mini_window_get_name_box(win->miniWindow)); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(win->nameBox))), text); if (timer_main_window_is_always_on_top(win)) { gtk_window_set_keep_above(GTK_WINDOW(win), TRUE); } gtk_widget_show_all(GTK_WIDGET(win)); g_key_file_set_boolean(win->keyFile, "Cache", "isMini", FALSE); } static void init_mini_window(TimerMainWindow *self) { self->miniWindowMode = FALSE; self->miniWindowFirstOpen = TRUE; self->miniWindow = timer_mini_window_new(); g_signal_connect(self->miniWindow, "configure-event", G_CALLBACK(mini_window_configure_callback), self); g_signal_connect(self->miniWindow, "delete-event", G_CALLBACK(mini_window_delete_event), self); g_signal_connect(timer_mini_window_get_start_stop_button(self->miniWindow), "clicked", G_CALLBACK(start_stop_button_callback), self); g_signal_connect(timer_mini_window_get_save_button(self->miniWindow), "clicked", G_CALLBACK(save_button_callback), self); g_signal_connect(timer_mini_window_get_expand_button(self->miniWindow), "clicked", G_CALLBACK(mini_window_expand_callback), self); g_signal_connect(timer_mini_window_get_timer_button(self->miniWindow), "clicked", G_CALLBACK(timer_button_callback), self); } static void main_window_collapse_callback(GtkButton *btn, TimerMainWindow *win) { gtk_widget_hide(GTK_WIDGET(win)); const char *text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(win->nameBox)); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(timer_mini_window_get_name_box(win->miniWindow)))), text); gtk_window_set_keep_above(GTK_WINDOW(win->miniWindow), TRUE); gtk_widget_show_all(GTK_WIDGET(win->miniWindow)); if (win->miniWindowFirstOpen) { int x, y, w, h; timer_main_window_read_mini_window_specs(win, &x, &y, &w, &h); gtk_window_move(GTK_WINDOW(win->miniWindow), x, y); gtk_window_resize(GTK_WINDOW(win->miniWindow), w, h); win->miniWindowFirstOpen = FALSE; } win->miniWindowMode = TRUE; g_key_file_set_boolean(win->keyFile, "Cache", "isMini", TRUE); } void timer_main_window_show_for_mode(TimerMainWindow *self) { if (g_key_file_get_boolean(self->keyFile, "Cache", "isMini", NULL)) { main_window_collapse_callback(NULL, self); } else { mini_window_expand_callback(NULL, self); } } static void timer_main_window_finalize(GObject *self) { g_free(TIMER_MAIN_WINDOW(self)->labelColorString); g_object_unref(TIMER_MAIN_WINDOW(self)->timerClock); g_object_unref(TIMER_MAIN_WINDOW(self)->updateClock); gtk_widget_destroy(GTK_WIDGET(TIMER_MAIN_WINDOW(self)->miniWindow)); if (TIMER_MAIN_WINDOW(self)->lastUpdateTime != NULL) { g_date_time_unref(TIMER_MAIN_WINDOW(self)->lastUpdateTime); } if (TIMER_MAIN_WINDOW(self)->startTime != NULL) { g_date_time_unref(TIMER_MAIN_WINDOW(self)->startTime); } G_OBJECT_CLASS(timer_main_window_parent_class)->finalize(self); } static void timer_main_window_class_init(TimerMainWindowClass *class) { G_OBJECT_CLASS(class)->finalize = timer_main_window_finalize; gtk_widget_class_set_template_from_resource( GTK_WIDGET_CLASS(class), "/zander/practicetimer/ui/main-window.glade"); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, timerButton); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, timerLabel); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, nameBox); gtk_widget_class_bind_template_child_internal( GTK_WIDGET_CLASS(class), TimerMainWindow, startStopButton); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, resetButton); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, saveButton); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, shrinkButton); gtk_widget_class_bind_template_child_internal( GTK_WIDGET_CLASS(class), TimerMainWindow, optionsButton); gtk_widget_class_bind_template_child_internal(GTK_WIDGET_CLASS(class), TimerMainWindow, taskTreeBox); } static void timer_main_window_init(TimerMainWindow *self) { gtk_widget_init_template(GTK_WIDGET(self)); self->taskTree = timer_task_tree_new(); gtk_container_add(GTK_CONTAINER(self->taskTreeBox), self->taskTree); self->keyFile = g_key_file_new(); g_signal_connect(self->optionsButton, "clicked", G_CALLBACK(options_button_callback), self); self->timerClock = timer_clock_new(1000, (TimerClockAction)timer_clock_callback, self); self->updateClock = timer_clock_new(60000 /* one minute */, (TimerClockAction) update_clock_callback, self); g_signal_connect(self->startStopButton, "clicked", G_CALLBACK(start_stop_button_callback), self); g_signal_connect(self->resetButton, "clicked", G_CALLBACK(reset_button_callback), self); g_signal_connect(self->saveButton, "clicked", G_CALLBACK(save_button_callback), self); g_signal_connect(self->timerButton, "clicked", G_CALLBACK(timer_button_callback), self); g_signal_connect(self->shrinkButton, "clicked", G_CALLBACK(main_window_collapse_callback), self); g_signal_connect(self, "destroy", G_CALLBACK(window_destroy_callback), NULL); g_signal_connect(self, "configure-event", G_CALLBACK(window_configure_callback), NULL); g_signal_connect(self, "delete-event", G_CALLBACK(window_delete_event), NULL); timer_main_window_get_defualt_label_color(self); init_mini_window(self); }