[gnome-calendar/wip/gbsneto/css-nodes] month-view: set a css name



commit 189dcb1e32e2a0d404128aadde68aff62d86467e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 9 02:02:13 2015 -0200

    month-view: set a css name
    
    This will add a CSS Node in the style context,
    and keep Calendar in sync with latest gtk+
    upstream changes.

 data/theme/gtk-styles.css |   50 ++++++++++++++++++++++----------------------
 src/gcal-month-view.c     |   20 +++++++++--------
 2 files changed, 36 insertions(+), 34 deletions(-)
---
diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index b411897..8af32f9 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -23,49 +23,49 @@
     padding: 12px;
 }
 
-.calendar-view {
+calendar-view {
     padding: 6px;
     font: 10;
 }
 
-.calendar-view.header {
+calendar-view.header {
     font-weight: bold;
 }
 
-.calendar-view.current {
+calendar-view.current {
     background-color: black;
     border-radius: 2px;
     color: white;
     font: bold;
 }
 
-.calendar-view:selected {
+calendar-view:selected {
     color: @theme_selected_bg_color;
     font-weight: bold;
 }
 
-.calendar-view.overflow:hover {
+calendar-view.overflow:hover {
     font-weight: bold;
     color: @theme_selected_bg_color;
     background-image: linear-gradient(to bottom, shade(@theme_bg_color, 0.9), alpha(@theme_bg_color, 0.2) 
10%,
                                       alpha(@theme_bg_color, 0.2) 95%, shade(@theme_bg_color, 0.95) 100%);
 }
 
-.calendar-view.overflow {
+calendar-view.overflow {
     font: 8;
 }
 
-.calendar-view.lines {
+calendar-view.lines {
     color: alpha(@theme_fg_color, 0.4);
 }
 
-.calendar-view.first-view-header {
+calendar-view.first-view-header {
     font: bold 16;
     color: @theme_selected_bg_color;
     padding: 12px;
 }
 
-.calendar-view.second-view-header {
+calendar-view.second-view-header {
     font: bold 16;
     padding: 12px;
     color: alpha(@theme_fg_color, 0.55);
@@ -124,54 +124,54 @@
     font-style: italic;
 }
 
-GtkListBox.sidebar {
+list.sidebar {
     background-color: @theme_bg_color;
 }
 
-GtkBox.sidebar {
+box.sidebar {
     background-color: @theme_bg_color;
     border-color: @borders;
     border-style: solid;
 }
 
-GcalYearView GtkBox.sidebar:dir(ltr) {
+GcalYearView box.sidebar:dir(ltr) {
     border-left-width: 1px;
 }
 
-GcalYearView GtkBox.sidebar:dir(rtl) {
+GcalYearView box.sidebar:dir(rtl) {
     border-right-width: 1px;
 }
 
-GcalYearView GtkScrolledWindow {
+GcalYearView scrolledwindow {
     border-top-width: 0;
     border-bottom-width: 0;
 }
 
-GcalYearView GtkButton {
+GcalYearView button {
     border-radius: 0;
     border-bottom-width: 0;
 }
 
-GtkPopover.events {
+popover.events {
     background-color: @theme_bg_color;
     padding: 0;
 }
 
-GtkPopover.events GtkBox {
+popover.events box {
     border-top-left-radius: 6px;
     border-top-right-radius: 6px;
 }
 
-GtkPopover.events GtkListBox {
+popover.events list {
     background-color: @theme_bg_color;
     border-radius: 6px;
 }
 
-GtkPopover.events GtkScrolledWindow {
+popover.events scrolledwindow {
     border-width: 0;
 }
 
-GtkPopover.events GtkButton {
+popover.events button {
     border-radius: 6px;
     border-top-left-radius: 0;
     border-top-right-radius: 0;
@@ -179,28 +179,28 @@ GtkPopover.events GtkButton {
     box-shadow: none;
 }
 
-GcalEventWidget {
+event-widget {
     border-radius: 2px;
     margin: 2px;
     padding: 4px;
     font: 10;
 }
 
-GcalEventWidget.color-dark {
+event-widget.color-dark {
     color: white;
     outline-color: rgba(0, 0, 0, 0.3);
 }
 
-GcalEventWidget.color-dark:backdrop {
+event-widget.color-dark:backdrop {
     color: rgba(255, 255, 255, 0.3);
 }
 
-GcalEventWidget.color-light {
+event-widget.color-light {
     color: black;
     outline-color: rgba(255, 255, 255, 0.5);
 }
 
-GcalEventWidget.color-light:backdrop {
+event-widget.color-light:backdrop {
     color: rgba(0, 0, 0, 0.3);
 }
 
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 299326d..f3151f7 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -337,7 +337,7 @@ gather_button_event_data (GcalMonthView *view,
   cell_height = (gtk_widget_get_allocated_height (widget) - start_grid_y) / 6.0;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "overflow");
   gtk_style_context_get (context, state, "font", &ofont_desc, "padding-bottom", &padding_bottom, NULL);
@@ -389,7 +389,7 @@ get_start_grid_y (GtkWidget *widget)
   gdouble start_grid_y;
 
   context = gtk_widget_get_style_context (widget);
-  state_flags = gtk_widget_get_state_flags (widget);
+  state_flags = gtk_style_context_get_state (context);
 
   layout = gtk_widget_create_pango_layout (widget, NULL);
 
@@ -544,7 +544,7 @@ rebuild_popover_for_day (GcalMonthView *view,
   cell_height = (gtk_widget_get_allocated_height (GTK_WIDGET (view)) - start_grid_y) / 6.0;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (view));
-  state = gtk_widget_get_state_flags (GTK_WIDGET (view));
+  state = gtk_style_context_get_state (context);
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "overflow");
   gtk_style_context_get (context, state, "font", &ofont_desc, "padding-bottom", &padding_bottom, NULL);
@@ -784,6 +784,8 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
   subscriber_view_class->clear_state = gcal_month_view_clear_state;
 
   g_object_class_override_property (object_class, PROP_DATE, "active-date");
+
+  gtk_widget_class_set_css_name (widget_class, "calendar-view");
 }
 
 static void
@@ -803,8 +805,6 @@ gcal_month_view_init (GcalMonthView *self)
   priv->pressed_overflow_indicator = -1;
   priv->hovered_overflow_indicator = -1;
 
-  gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "calendar-view");
-
   priv->k = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
 
   priv->overflow_popover = gtk_popover_new (GTK_WIDGET (self));
@@ -992,6 +992,7 @@ gcal_month_view_size_allocate (GtkWidget     *widget,
 {
   GcalSubscriberViewPrivate *ppriv;
   GcalMonthViewPrivate *priv;
+  GtkStyleContext *context;
 
   gint i, j, sw, shown_rows;
 
@@ -1013,6 +1014,7 @@ gcal_month_view_size_allocate (GtkWidget     *widget,
   gpointer key, value;
 
   priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (widget));
+  context = gtk_widget_get_style_context (widget);
   ppriv = GCAL_SUBSCRIBER_VIEW (widget)->priv;
 
   if (!ppriv->children_changed &&
@@ -1037,7 +1039,7 @@ gcal_month_view_size_allocate (GtkWidget     *widget,
   if (gtk_widget_get_realized (widget))
     gdk_window_move_resize (priv->event_window, allocation->x, allocation->y, allocation->width, 
allocation->height);
 
-  gtk_style_context_get (gtk_widget_get_style_context (widget), gtk_widget_get_state_flags (widget),
+  gtk_style_context_get (context, gtk_style_context_get_state (context),
                          "font", &font_desc, "padding-bottom", &padding_bottom, NULL);
 
   layout = gtk_widget_create_pango_layout (widget, _("Other events"));
@@ -1167,7 +1169,7 @@ gcal_month_view_size_allocate (GtkWidget     *widget,
                 }
 
               gtk_style_context_get_margin (gtk_widget_get_style_context (child_widget),
-                                            gtk_widget_get_state_flags (child_widget),
+                                            gtk_style_context_get_state (context),
                                             &margin);
 
               pos_x = cell_width * column + margin.left;
@@ -1229,7 +1231,7 @@ gcal_month_view_size_allocate (GtkWidget     *widget,
           if (size_left[i] > natural_height)
             {
               gtk_style_context_get_margin (gtk_widget_get_style_context (child_widget),
-                                            gtk_widget_get_state_flags (child_widget),
+                                            gtk_style_context_get_state (context),
                                             &margin);
 
               pos_x = cell_width * (i % 7) + margin.left;
@@ -1296,7 +1298,7 @@ gcal_month_view_draw (GtkWidget *widget,
 
   /* fonts and colors selection */
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_style_context_get (context, state | GTK_STATE_FLAG_SELECTED, "font", &sfont_desc, NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]