Make the previous problems worese
This commit is contained in:
parent
d8d47a5f83
commit
d02e75689b
@ -26,6 +26,7 @@ struct _TimerMainWindow {
|
||||
|
||||
TimerMiniWindow *miniWindow;
|
||||
int miniWindowFirstOpen;
|
||||
int miniWindowMode;
|
||||
|
||||
char *labelColorString;
|
||||
|
||||
@ -366,7 +367,7 @@ void timer_main_window_read_mini_window_pos(TimerMainWindow *self, int *x, int *
|
||||
*y = g_key_file_get_integer(self->keyFile, "Cache", "smallY", NULL);
|
||||
}
|
||||
|
||||
static gboolean window_configure_callback(TimerMainWindow *win) {
|
||||
static gboolean window_configure_callback(TimerMainWindow *win, GdkEventConfigure 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);
|
||||
@ -377,7 +378,7 @@ static gboolean window_configure_callback(TimerMainWindow *win) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void window_destroy_callback(TimerMainWindow *win) {
|
||||
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;
|
||||
@ -396,7 +397,7 @@ static void window_destroy_callback(TimerMainWindow *win) {
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean window_delete_event(TimerMainWindow *win, GdkEvent *evt) {
|
||||
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);
|
||||
@ -407,30 +408,34 @@ static gboolean window_delete_event(TimerMainWindow *win, GdkEvent *evt) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean mini_window_configure_callback(TimerMiniWindow *win) {
|
||||
int x, y;
|
||||
gtk_window_get_position(GTK_WINDOW(win), &x, &y);
|
||||
timer_main_window_save_mini_window_pos(
|
||||
TIMER_MAIN_WINDOW(timer_mini_window_get_parent(win)), x, y);
|
||||
static gboolean mini_window_configure_callback(TimerMiniWindow *win, GdkEventConfigure event, TimerMainWindow *main) {
|
||||
if (main->miniWindowMode) {
|
||||
int x, y;
|
||||
gtk_window_get_position(GTK_WINDOW(win), &x, &y);
|
||||
timer_main_window_save_mini_window_pos(main, x, y);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean mini_window_delete_event(TimerMiniWindow *win, GdkEvent *evt) {
|
||||
static gboolean mini_window_delete_event(TimerMiniWindow *win, GdkEvent *evt, TimerMainWindow *main) {
|
||||
main->miniWindowMode = FALSE;
|
||||
gtk_widget_hide(GTK_WIDGET(win));
|
||||
gtk_widget_show_all(GTK_WIDGET(timer_mini_window_get_parent(win)));
|
||||
gtk_widget_show_all(GTK_WIDGET(main));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void mini_window_expand_callback(GtkButton *btn, TimerMainWindow *win) {
|
||||
win->miniWindowMode = FALSE;
|
||||
gtk_widget_hide(GTK_WIDGET(win->miniWindow));
|
||||
gtk_widget_show_all(GTK_WIDGET(win));
|
||||
}
|
||||
|
||||
static void init_mini_window(TimerMainWindow *self) {
|
||||
self->miniWindowFirstOpen = TRUE;
|
||||
self->miniWindow = timer_mini_window_new(GTK_WINDOW(self));
|
||||
g_signal_connect(self->miniWindow, "configure-event", G_CALLBACK(mini_window_configure_callback), NULL);
|
||||
g_signal_connect(self->miniWindow, "delete-event", G_CALLBACK(mini_window_delete_event), NULL);
|
||||
self->miniWindowMode = FALSE;
|
||||
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_reset_button(self->miniWindow),
|
||||
@ -442,6 +447,7 @@ static void init_mini_window(TimerMainWindow *self) {
|
||||
static void main_window_collapse_callback(GtkButton *btn, TimerMainWindow *win) {
|
||||
gtk_widget_hide(GTK_WIDGET(win));
|
||||
gtk_widget_show_all(GTK_WIDGET(win->miniWindow));
|
||||
win->miniWindowMode = TRUE;
|
||||
if (win->miniWindowFirstOpen) {
|
||||
gtk_window_set_keep_above(GTK_WINDOW(win->miniWindow), TRUE);
|
||||
int x, y;
|
||||
@ -455,6 +461,7 @@ 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);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
struct _TimerMiniWindow {
|
||||
GtkWindow parent;
|
||||
|
||||
GtkWindow *parentWindow;
|
||||
GtkWidget *startStopButton;
|
||||
GtkWidget *resetButton;
|
||||
GtkWidget *expandButton;
|
||||
@ -12,14 +11,8 @@ struct _TimerMiniWindow {
|
||||
|
||||
G_DEFINE_TYPE(TimerMiniWindow, timer_mini_window, GTK_TYPE_WINDOW);
|
||||
|
||||
TimerMiniWindow *timer_mini_window_new(GtkWindow *parent) {
|
||||
TimerMiniWindow *self = g_object_new(TIMER_TYPE_MINI_WINDOW, NULL);
|
||||
self->parentWindow = parent;
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkWindow *timer_mini_window_get_parent(TimerMiniWindow *self) {
|
||||
return self->parentWindow;
|
||||
TimerMiniWindow *timer_mini_window_new() {
|
||||
return g_object_new(TIMER_TYPE_MINI_WINDOW, NULL);
|
||||
}
|
||||
|
||||
GtkLabel *timer_mini_window_get_timer_label(TimerMiniWindow *self) {
|
||||
|
@ -8,8 +8,7 @@ G_BEGIN_DECLS
|
||||
#define TIMER_TYPE_MINI_WINDOW timer_mini_window_get_type()
|
||||
G_DECLARE_FINAL_TYPE(TimerMiniWindow, timer_mini_window, TIMER, MINI_WINDOW, GtkWindow)
|
||||
|
||||
TimerMiniWindow *timer_mini_window_new(GtkWindow *parent);
|
||||
GtkWindow *timer_mini_window_get_parent(TimerMiniWindow *self);
|
||||
TimerMiniWindow *timer_mini_window_new();
|
||||
GtkLabel *timer_mini_window_get_timer_label(TimerMiniWindow *self);
|
||||
GtkButton *timer_mini_window_get_start_stop_button(TimerMiniWindow *self);
|
||||
GtkButton *timer_mini_window_get_reset_button(TimerMiniWindow *self);
|
||||
|
Loading…
Reference in New Issue
Block a user