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
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
a3cbaf1e81
commit
043cca24b6
@@ -149,6 +149,8 @@ static gboolean key_pressed (GtkWidget *w
|
|||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void update_today_button_sensitive (GcalWindow *window);
|
||||||
|
|
||||||
static void date_updated (GtkButton *buttton,
|
static void date_updated (GtkButton *buttton,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
@@ -384,6 +386,8 @@ update_active_date (GcalWindow *window,
|
|||||||
g_clear_pointer (&date_end, g_date_time_unref);
|
g_clear_pointer (&date_end, g_date_time_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_today_button_sensitive (window);
|
||||||
|
|
||||||
g_free (previous_date);
|
g_free (previous_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,6 +410,41 @@ update_current_date (GcalWindow *window)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
date_updated (GtkButton *button,
|
date_updated (GtkButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -629,6 +668,7 @@ view_changed (GObject *object,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
window->active_view = view_type;
|
window->active_view = view_type;
|
||||||
|
update_today_button_sensitive (window);
|
||||||
g_object_notify (G_OBJECT (user_data), "active-view");
|
g_object_notify (G_OBJECT (user_data), "active-view");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user