[gnome-calendar/gnome-3-20] window: make Today button insensitive when today is visible
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gnome-3-20] window: make Today button insensitive when today is visible
- Date: Sun, 27 Mar 2016 14:28:19 +0000 (UTC)
commit 3ac7d8ee72adb4864bd435adff6043e1299b4b57
Author: Javier Sánchez Ochando <jsanchez deskblue com>
Date: Sat Mar 26 11:57:44 2016 +0100
window: make Today button insensitive when today is visible
When a view shows the current day, the Today button should be insensitive.
This patch makes today button sensitive only when today is not shown.
https://bugzilla.gnome.org/show_bug.cgi?id=747963
src/gcal-window.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 869bf11..eceabcb 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -149,6 +149,8 @@ static gboolean key_pressed (GtkWidget *w
GdkEvent *event,
gpointer user_data);
+static void update_today_button_sensitive (GcalWindow *window);
+
static void date_updated (GtkButton *buttton,
gpointer user_data);
@@ -384,6 +386,8 @@ update_active_date (GcalWindow *window,
g_clear_pointer (&date_end, g_date_time_unref);
}
+ update_today_button_sensitive (window);
+
g_free (previous_date);
}
@@ -407,6 +411,41 @@ update_current_date (GcalWindow *window)
}
static void
+update_today_button_sensitive (GcalWindow *window)
+{
+ gboolean sensitive;
+
+ switch (window->active_view)
+ {
+ case GCAL_WINDOW_VIEW_DAY:
+ sensitive = window->active_date->year != window->current_date->year ||
+ window->active_date->month != window->current_date->month ||
+ window->active_date->day != window->current_date->day;
+ break;
+
+ case GCAL_WINDOW_VIEW_WEEK:
+ /* TODO: determine when the today button would be sensitive on week view */
+ sensitive = TRUE;
+ break;
+
+ case GCAL_WINDOW_VIEW_MONTH:
+ sensitive = window->active_date->year != window->current_date->year ||
+ window->active_date->month != window->current_date->month;
+ break;
+
+ case GCAL_WINDOW_VIEW_YEAR:
+ sensitive = window->active_date->year != window->current_date->year;
+ break;
+
+ default:
+ sensitive = TRUE;
+ break;
+ }
+
+ gtk_widget_set_sensitive (window->today_button, sensitive);
+}
+
+static void
date_updated (GtkButton *button,
gpointer user_data)
{
@@ -629,6 +668,7 @@ view_changed (GObject *object,
return;
window->active_view = view_type;
+ update_today_button_sensitive (window);
g_object_notify (G_OBJECT (user_data), "active-view");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]