Changed toolbar button to Toggles.
Added behavior in GcalToolbar to manage the toogling mode of the view buttons Added parameter in gcal_window_new to set the view-type initially.
This commit is contained in:
@@ -115,7 +115,10 @@ gcal_application_activate (GApplication *application)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
priv->window = gcal_window_new (GCAL_APPLICATION (application));
|
priv->window =
|
||||||
|
gcal_window_new_with_view (GCAL_APPLICATION (application),
|
||||||
|
g_settings_get_enum (priv->settings,
|
||||||
|
"active-view"));
|
||||||
g_settings_bind (priv->settings,
|
g_settings_bind (priv->settings,
|
||||||
"active-view",
|
"active-view",
|
||||||
priv->window,
|
priv->window,
|
||||||
|
|||||||
+61
-13
@@ -38,6 +38,8 @@ struct _GcalToolbarPrivate
|
|||||||
/* events widgets */
|
/* events widgets */
|
||||||
GtkWidget *back_button;
|
GtkWidget *back_button;
|
||||||
GtkWidget *edit_button;
|
GtkWidget *edit_button;
|
||||||
|
|
||||||
|
GtkWidget *active_view_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -299,7 +301,7 @@ gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
|
|||||||
gtk_style_context_add_class (context, "linked");
|
gtk_style_context_add_class (context, "linked");
|
||||||
|
|
||||||
/* day */
|
/* day */
|
||||||
button = gtk_button_new_with_label (_("Day"));
|
button = gtk_toggle_button_new_with_label (_("Day"));
|
||||||
gtk_widget_set_size_request (button, 80, -1);
|
gtk_widget_set_size_request (button, 80, -1);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (button);
|
context = gtk_widget_get_style_context (button);
|
||||||
@@ -311,12 +313,12 @@ gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
|
|||||||
"view-type",
|
"view-type",
|
||||||
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_DAY));
|
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_DAY));
|
||||||
g_signal_connect (button,
|
g_signal_connect (button,
|
||||||
"clicked",
|
"toggled",
|
||||||
G_CALLBACK (gcal_toolbar_view_changed),
|
G_CALLBACK (gcal_toolbar_view_changed),
|
||||||
toolbar);
|
toolbar);
|
||||||
|
|
||||||
/* week */
|
/* week */
|
||||||
button = gtk_button_new_with_label (_("Week"));
|
button = gtk_toggle_button_new_with_label (_("Week"));
|
||||||
gtk_widget_set_size_request (button, 80, -1);
|
gtk_widget_set_size_request (button, 80, -1);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (button);
|
context = gtk_widget_get_style_context (button);
|
||||||
@@ -328,12 +330,12 @@ gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
|
|||||||
"view-type",
|
"view-type",
|
||||||
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_WEEK));
|
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_WEEK));
|
||||||
g_signal_connect (button,
|
g_signal_connect (button,
|
||||||
"clicked",
|
"toggled",
|
||||||
G_CALLBACK (gcal_toolbar_view_changed),
|
G_CALLBACK (gcal_toolbar_view_changed),
|
||||||
toolbar);
|
toolbar);
|
||||||
|
|
||||||
/* month */
|
/* month */
|
||||||
button = gtk_button_new_with_label (_("Month"));
|
button = gtk_toggle_button_new_with_label (_("Month"));
|
||||||
gtk_widget_set_size_request (button, 80, -1);
|
gtk_widget_set_size_request (button, 80, -1);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (button);
|
context = gtk_widget_get_style_context (button);
|
||||||
@@ -345,12 +347,12 @@ gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
|
|||||||
"view-type",
|
"view-type",
|
||||||
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_MONTH));
|
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_MONTH));
|
||||||
g_signal_connect (button,
|
g_signal_connect (button,
|
||||||
"clicked",
|
"toggled",
|
||||||
G_CALLBACK (gcal_toolbar_view_changed),
|
G_CALLBACK (gcal_toolbar_view_changed),
|
||||||
toolbar);
|
toolbar);
|
||||||
|
|
||||||
/* year */
|
/* year */
|
||||||
button = gtk_button_new_with_label (_("Year"));
|
button = gtk_toggle_button_new_with_label (_("Year"));
|
||||||
gtk_widget_set_size_request (button, 80, -1);
|
gtk_widget_set_size_request (button, 80, -1);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (button);
|
context = gtk_widget_get_style_context (button);
|
||||||
@@ -362,12 +364,12 @@ gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
|
|||||||
"view-type",
|
"view-type",
|
||||||
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_YEAR));
|
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_YEAR));
|
||||||
g_signal_connect (button,
|
g_signal_connect (button,
|
||||||
"clicked",
|
"toggled",
|
||||||
G_CALLBACK (gcal_toolbar_view_changed),
|
G_CALLBACK (gcal_toolbar_view_changed),
|
||||||
toolbar);
|
toolbar);
|
||||||
|
|
||||||
/* list */
|
/* list */
|
||||||
button = gtk_button_new_with_label (_("List"));
|
button = gtk_toggle_button_new_with_label (_("List"));
|
||||||
gtk_widget_set_size_request (button, 80, -1);
|
gtk_widget_set_size_request (button, 80, -1);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (button);
|
context = gtk_widget_get_style_context (button);
|
||||||
@@ -379,7 +381,7 @@ gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
|
|||||||
"view-type",
|
"view-type",
|
||||||
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_LIST));
|
GUINT_TO_POINTER (GCAL_WINDOW_VIEW_LIST));
|
||||||
g_signal_connect (button,
|
g_signal_connect (button,
|
||||||
"clicked",
|
"toggled",
|
||||||
G_CALLBACK (gcal_toolbar_view_changed),
|
G_CALLBACK (gcal_toolbar_view_changed),
|
||||||
toolbar);
|
toolbar);
|
||||||
}
|
}
|
||||||
@@ -466,14 +468,32 @@ static void
|
|||||||
gcal_toolbar_view_changed (GtkWidget *button,
|
gcal_toolbar_view_changed (GtkWidget *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GcalToolbar *toolbar;
|
GcalToolbarPrivate *priv;
|
||||||
guint view_type;
|
guint view_type;
|
||||||
|
|
||||||
toolbar = GCAL_TOOLBAR (user_data);
|
priv = GCAL_TOOLBAR (user_data)->priv;
|
||||||
|
|
||||||
|
if (priv->active_view_button != NULL)
|
||||||
|
{
|
||||||
|
g_signal_handlers_block_by_func (priv->active_view_button,
|
||||||
|
gcal_toolbar_view_changed,
|
||||||
|
user_data);
|
||||||
|
gtk_toggle_button_set_active (
|
||||||
|
GTK_TOGGLE_BUTTON (priv->active_view_button),
|
||||||
|
FALSE);
|
||||||
|
g_signal_handlers_unblock_by_func (priv->active_view_button,
|
||||||
|
gcal_toolbar_view_changed,
|
||||||
|
user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->active_view_button = button;
|
||||||
view_type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button),
|
view_type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button),
|
||||||
"view-type"));
|
"view-type"));
|
||||||
|
|
||||||
g_signal_emit (toolbar, signals[VIEW_CHANGED], 0, view_type);
|
g_signal_emit (GCAL_TOOLBAR (user_data),
|
||||||
|
signals[VIEW_CHANGED],
|
||||||
|
0,
|
||||||
|
view_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -554,3 +574,31 @@ gcal_toolbar_set_mode (GcalToolbar *toolbar,
|
|||||||
gcal_toolbar_set_event_mode (toolbar);
|
gcal_toolbar_set_event_mode (toolbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gcal_toolbar_set_active_view (GcalToolbar *toolbar,
|
||||||
|
GcalWindowViewType view_type)
|
||||||
|
{
|
||||||
|
GcalToolbarPrivate *priv;
|
||||||
|
GList *children;
|
||||||
|
GList *l;
|
||||||
|
guint button_view_type;
|
||||||
|
|
||||||
|
g_return_if_fail (GCAL_IS_TOOLBAR (toolbar));
|
||||||
|
priv = toolbar->priv;
|
||||||
|
|
||||||
|
children = gtk_container_get_children (GTK_CONTAINER (priv->views_box));
|
||||||
|
for (l = children; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
button_view_type =
|
||||||
|
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (l->data),
|
||||||
|
"view-type"));
|
||||||
|
if (view_type == button_view_type)
|
||||||
|
{
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l->data), TRUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (children);
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ ClutterActor* gcal_toolbar_new (void);
|
|||||||
void gcal_toolbar_set_mode (GcalToolbar *toolbar,
|
void gcal_toolbar_set_mode (GcalToolbar *toolbar,
|
||||||
GcalToolbarMode mode);
|
GcalToolbarMode mode);
|
||||||
|
|
||||||
|
void gcal_toolbar_set_active_view (GcalToolbar *toolbar,
|
||||||
|
GcalWindowViewType view_type);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _GCAL_TOOLBAR_H_ */
|
#endif /* _GCAL_TOOLBAR_H_ */
|
||||||
|
|||||||
+4
-1
@@ -974,7 +974,8 @@ gcal_window_undo_remove_event (GtkButton *button,
|
|||||||
|
|
||||||
/* Public API */
|
/* Public API */
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
gcal_window_new (GcalApplication *app)
|
gcal_window_new_with_view (GcalApplication *app,
|
||||||
|
GcalWindowViewType view_type)
|
||||||
{
|
{
|
||||||
GcalWindow *win;
|
GcalWindow *win;
|
||||||
GcalManager *manager;
|
GcalManager *manager;
|
||||||
@@ -997,6 +998,8 @@ gcal_window_new (GcalApplication *app)
|
|||||||
G_CALLBACK (gcal_window_events_removed),
|
G_CALLBACK (gcal_window_events_removed),
|
||||||
win);
|
win);
|
||||||
|
|
||||||
|
gcal_toolbar_set_active_view (GCAL_TOOLBAR (win->priv->main_toolbar),
|
||||||
|
view_type);
|
||||||
return GTK_WIDGET (win);
|
return GTK_WIDGET (win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -21,6 +21,7 @@
|
|||||||
#define __GCAL_WINDOW_H__
|
#define __GCAL_WINDOW_H__
|
||||||
|
|
||||||
#include "gcal-application.h"
|
#include "gcal-application.h"
|
||||||
|
#include "gcal-utils.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
@@ -53,7 +54,8 @@ struct _GcalWindowClass
|
|||||||
|
|
||||||
GType gcal_window_get_type (void);
|
GType gcal_window_get_type (void);
|
||||||
|
|
||||||
GtkWidget* gcal_window_new (GcalApplication *app);
|
GtkWidget* gcal_window_new_with_view (GcalApplication *app,
|
||||||
|
GcalWindowViewType view_type);
|
||||||
|
|
||||||
void gcal_window_show_notification (GcalWindow *window,
|
void gcal_window_show_notification (GcalWindow *window,
|
||||||
GtkWidget *notification);
|
GtkWidget *notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user