[gnome-calendar] nav-bar: implemented today button
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] nav-bar: implemented today button
- Date: Thu, 4 Dec 2014 22:35:25 +0000 (UTC)
commit 7dc4ae6a8497962fb807473f0e734d572f355fec
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Oct 13 11:52:26 2014 -0300
nav-bar: implemented today button
Implements today button between previous and forward buttons.
Fix bug #703316.
data/ui/nav_bar.ui | 24 +++++++++++++++++++++++-
src/gcal-nav-bar.c | 11 +++++++++++
src/gcal-nav-bar.h | 2 ++
src/gcal-window.c | 45 +++++++++++++++++++++++++++++----------------
4 files changed, 65 insertions(+), 17 deletions(-)
---
diff --git a/data/ui/nav_bar.ui b/data/ui/nav_bar.ui
index 054830c..b5af6fb 100644
--- a/data/ui/nav_bar.ui
+++ b/data/ui/nav_bar.ui
@@ -38,6 +38,28 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="today_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="nav-button"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="today_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Today</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkButton" id="forward_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -56,7 +78,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/src/gcal-nav-bar.c b/src/gcal-nav-bar.c
index f59c686..0fb7dfd 100644
--- a/src/gcal-nav-bar.c
+++ b/src/gcal-nav-bar.c
@@ -26,6 +26,7 @@
typedef struct
{
GtkWidget *back_button;
+ GtkWidget *today_button;
GtkWidget *forward_button;
GtkWidget *left_label;
@@ -88,6 +89,7 @@ gcal_nav_bar_class_init (GcalNavBarClass *klass)
/* Bind internals widgets */
gtk_widget_class_bind_template_child_private (widget_class, GcalNavBar, back_button);
+ gtk_widget_class_bind_template_child_private (widget_class, GcalNavBar, today_button);
gtk_widget_class_bind_template_child_private (widget_class, GcalNavBar, forward_button);
gtk_widget_class_bind_template_child_private (widget_class, GcalNavBar, left_label);
gtk_widget_class_bind_template_child_private (widget_class, GcalNavBar, right_label);
@@ -175,6 +177,15 @@ gcal_nav_bar_get_prev_button (GcalNavBar *nav_bar)
}
GtkWidget*
+gcal_nav_bar_get_today_button (GcalNavBar *nav_bar)
+{
+ GcalNavBarPrivate *priv;
+
+ priv = gcal_nav_bar_get_instance_private (nav_bar);
+ return priv->today_button;
+}
+
+GtkWidget*
gcal_nav_bar_get_next_button (GcalNavBar *nav_bar)
{
GcalNavBarPrivate *priv;
diff --git a/src/gcal-nav-bar.h b/src/gcal-nav-bar.h
index 076ef40..9ed3f16 100644
--- a/src/gcal-nav-bar.h
+++ b/src/gcal-nav-bar.h
@@ -50,6 +50,8 @@ GtkWidget* gcal_nav_bar_new (void);
GtkWidget* gcal_nav_bar_get_prev_button (GcalNavBar *nav_bar);
+GtkWidget* gcal_nav_bar_get_today_button (GcalNavBar *nav_bar);
+
GtkWidget* gcal_nav_bar_get_next_button (GcalNavBar *nav_bar);
G_END_DECLS
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 9335bc9..d5395f2 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -257,28 +257,39 @@ date_updated (GtkButton *button,
{
GcalWindowPrivate *priv;
- gboolean move_back;
+ gboolean move_back, move_today;
priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
+ move_today = gcal_nav_bar_get_today_button (GCAL_NAV_BAR (priv->nav_bar)) == (GtkWidget*) button;
move_back = gcal_nav_bar_get_prev_button (GCAL_NAV_BAR (priv->nav_bar)) == (GtkWidget*) button;
- switch (priv->active_view)
+ if (move_today)
{
- case GCAL_WINDOW_VIEW_DAY:
- priv->active_date->day += 1 * (move_back ? -1 : 1);
- break;
- case GCAL_WINDOW_VIEW_WEEK:
- priv->active_date->day += 7 * (move_back ? -1 : 1);
- break;
- case GCAL_WINDOW_VIEW_MONTH:
- priv->active_date->month += 1 * (move_back ? -1 : 1);
- break;
- case GCAL_WINDOW_VIEW_YEAR:
- priv->active_date->year += 1 * (move_back ? -1 : 1);
- break;
- case GCAL_WINDOW_VIEW_LIST:
- break;
+ GcalManager *manager;
+
+ manager = get_manager (GCAL_WINDOW (user_data));
+ *(priv->active_date) = icaltime_current_time_with_zone (gcal_manager_get_system_timezone (manager));
+ }
+ else
+ {
+ switch (priv->active_view)
+ {
+ case GCAL_WINDOW_VIEW_DAY:
+ priv->active_date->day += 1 * (move_back ? -1 : 1);
+ break;
+ case GCAL_WINDOW_VIEW_WEEK:
+ priv->active_date->day += 7 * (move_back ? -1 : 1);
+ break;
+ case GCAL_WINDOW_VIEW_MONTH:
+ priv->active_date->month += 1 * (move_back ? -1 : 1);
+ break;
+ case GCAL_WINDOW_VIEW_YEAR:
+ priv->active_date->year += 1 * (move_back ? -1 : 1);
+ break;
+ case GCAL_WINDOW_VIEW_LIST:
+ break;
+ }
}
*(priv->active_date) = icaltime_normalize (*(priv->active_date));
g_object_notify (user_data, "active-date");
@@ -1054,6 +1065,8 @@ gcal_window_constructed (GObject *object)
G_CALLBACK (view_changed), object);
g_signal_connect (gcal_nav_bar_get_prev_button (GCAL_NAV_BAR (priv->nav_bar)),
"clicked", G_CALLBACK (date_updated), object);
+ g_signal_connect (gcal_nav_bar_get_today_button (GCAL_NAV_BAR (priv->nav_bar)),
+ "clicked", G_CALLBACK (date_updated), object);
g_signal_connect (gcal_nav_bar_get_next_button (GCAL_NAV_BAR (priv->nav_bar)),
"clicked", G_CALLBACK (date_updated), object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]