[gnome-calendar] event-widget: add .vertical and .horizontal style classes
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] event-widget: add .vertical and .horizontal style classes
- Date: Thu, 14 Sep 2017 16:32:19 +0000 (UTC)
commit f42d5d0598da51622725487d97cf6417d493cdcc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Sep 14 11:27:27 2017 -0300
event-widget: add .vertical and .horizontal style classes
Depending on the GtkOrientation passed to it, just like the regular
behavior of GTK widgets. This way, we can have a finer control over
CSS selectors.
src/gcal-event-widget.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index 6025fc1..6a75b47 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -625,7 +625,11 @@ gcal_event_widget_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GcalEventWidget *self = GCAL_EVENT_WIDGET (object);
+ GcalEventWidget *self;
+ GtkStyleContext *context;
+
+ self = GCAL_EVENT_WIDGET (object);
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
switch (property_id)
{
@@ -643,6 +647,18 @@ gcal_event_widget_set_property (GObject *object,
case PROP_ORIENTATION:
self->orientation = g_value_get_enum (value);
+
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gtk_style_context_add_class (context, "horizontal");
+ gtk_style_context_remove_class (context, "vertical");
+ }
+ else
+ {
+ gtk_style_context_add_class (context, "vertical");
+ gtk_style_context_remove_class (context, "horizontal");
+ }
+
gtk_widget_queue_draw (GTK_WIDGET (object));
g_object_notify (object, "orientation");
break;
@@ -802,7 +818,6 @@ gcal_event_widget_init (GcalEventWidget *self)
widget = GTK_WIDGET (self);
self->clock_format_24h = is_clock_format_24h ();
- self->orientation = GTK_ORIENTATION_HORIZONTAL;
gtk_widget_init_template (GTK_WIDGET (self));
@@ -816,6 +831,10 @@ gcal_event_widget_init (GcalEventWidget *self)
GDK_ACTION_MOVE);
gtk_drag_source_add_text_targets (widget);
+
+ /* Starts with horizontal */
+ self->orientation = GTK_ORIENTATION_HORIZONTAL;
+ gtk_style_context_add_class (gtk_widget_get_style_context (widget), "horizontal");
}
GtkWidget*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]