[gnome-calendar/gbsneto/gtk4] WIP: year-view: Port to GTK4



commit 2bf5776f74ec596de6838bf1e94ecba3f0244c59
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Feb 7 19:49:28 2022 -0300

    WIP: year-view: Port to GTK4

 src/gui/views/gcal-year-view.c  | 211 ++++++++++++++--------------------------
 src/gui/views/gcal-year-view.ui | 158 ++++++++++++------------------
 2 files changed, 133 insertions(+), 236 deletions(-)
---
diff --git a/src/gui/views/gcal-year-view.c b/src/gui/views/gcal-year-view.c
index ac32a8f9..b03afdeb 100644
--- a/src/gui/views/gcal-year-view.c
+++ b/src/gui/views/gcal-year-view.c
@@ -47,7 +47,7 @@ typedef struct
 typedef struct
 {
   gdouble             box_side;
-  GdkPoint            coordinates [12];
+  graphene_point_t    coordinates[12];
 } GridData;
 
 struct _GcalYearView
@@ -448,13 +448,15 @@ static void
 update_sidebar (GcalYearView *year_view)
 {
   g_autoptr (GPtrArray) events = NULL;
+  GtkWidget *child;
   GtkWidget *child_widget;
   GList **days_widgets_array;
   gint i, days_span;
 
   update_selected_dates_from_button_data (year_view);
 
-  gtk_container_foreach (GTK_CONTAINER (year_view->events_sidebar), (GtkCallback) gtk_widget_destroy, NULL);
+  while ((child = gtk_widget_get_first_child (year_view->events_sidebar)) != NULL)
+    gtk_list_box_remove (GTK_LIST_BOX (year_view->events_sidebar), child);
 
   days_span = g_date_time_get_day_of_year (year_view->end_selected_date) - g_date_time_get_day_of_year 
(year_view->start_selected_date) + 1;
   days_widgets_array = g_new0 (GList*, days_span);
@@ -493,10 +495,9 @@ update_sidebar (GcalYearView *year_view)
       for (l = current_day; l != NULL; l = g_list_next (l))
         {
           child_widget = l->data;
-          gtk_widget_show (child_widget);
           g_signal_connect_object (child_widget, "activate", G_CALLBACK (event_activated), year_view, 0);
           g_object_set_data (G_OBJECT (child_widget), "shift", GINT_TO_POINTER (i));
-          gtk_container_add (GTK_CONTAINER (year_view->events_sidebar), child_widget);
+          gtk_list_box_append (GTK_LIST_BOX (year_view->events_sidebar), child_widget);
         }
 
       g_list_free (current_day);
@@ -517,7 +518,7 @@ reset_sidebar (GcalYearView *year_view)
 static void
 update_sidebar_headers (GtkListBoxRow *row,
                         GtkListBoxRow *before,
-                        gpointer user_data)
+                        gpointer       user_data)
 {
   GcalYearView *year_view;
   GtkWidget *row_child, *before_child = NULL, *row_header = NULL;
@@ -526,7 +527,7 @@ update_sidebar_headers (GtkListBoxRow *row,
   gint row_shift, before_shift =-1;
 
   year_view = GCAL_YEAR_VIEW (user_data);
-  row_child = gtk_bin_get_child (GTK_BIN (row));
+  row_child = gtk_list_box_row_get_child (row);
 
   if (!row_child)
     return;
@@ -538,7 +539,7 @@ update_sidebar_headers (GtkListBoxRow *row,
 
   if (before)
     {
-      before_child = gtk_bin_get_child (GTK_BIN (before));
+      before_child = gtk_list_box_row_get_child (before);
       before_event = gcal_event_widget_get_event (GCAL_EVENT_WIDGET (before_child));
       before_date = gcal_event_get_date_start (before_event);
       before_date = g_date_time_to_local (before_date);
@@ -567,11 +568,9 @@ update_sidebar_headers (GtkListBoxRow *row,
       g_object_set (label, "margin", 6, "halign", GTK_ALIGN_START, NULL);
       g_free (label_str);
 
-      gtk_container_add (GTK_CONTAINER (row_header), label);
+      gtk_box_append (GTK_BOX (row_header), label);
     }
 
-  if (row_header != NULL)
-    gtk_widget_show_all (row_header);
   gtk_list_box_row_set_header (row, row_header);
 
   g_clear_pointer (&before_date, g_date_time_unref);
@@ -620,8 +619,8 @@ sidebar_sort_func (GtkListBoxRow *row1,
   GtkWidget *row1_child, *row2_child;
   gint result, row1_shift, row2_shift;
 
-  row1_child = gtk_bin_get_child (GTK_BIN (row1));
-  row2_child = gtk_bin_get_child (GTK_BIN (row2));
+  row1_child = gtk_list_box_row_get_child (row1);
+  row2_child = gtk_list_box_row_get_child (row2);
   row1_shift = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row1_child), "shift"));
   row2_shift = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row2_child), "shift"));
 
@@ -641,7 +640,7 @@ calculate_day_month_for_coord (GcalYearView *year_view,
                                gint         *out_month,
                                gboolean     *is_title)
 {
-  GdkPoint *coordinates;
+  graphene_point_t *coordinates;
   gint row, column, i, sw, clicked_cell, day, month, columns_or_rows;
   gint number_of_rows;
   gdouble box_side;
@@ -748,13 +747,9 @@ draw_month_grid (GcalYearView *year_view,
 {
   GtkStyleContext *context;
   GtkStateFlags state_flags;
-
   PangoLayout *layout, *slayout;
-  PangoFontDescription *font_desc, *sfont_desc;
-
   g_autoptr (GDateTime) day = NULL;
   g_autoptr (GDateTime) now = NULL;
-
   GdkRGBA color;
   gint layout_width, layout_height, i, j, sw;
   gint column, row;
@@ -777,21 +772,16 @@ draw_month_grid (GcalYearView *year_view,
   /* Get the font description */
   gtk_style_context_save (context);
   gtk_style_context_set_state (context, state_flags | GTK_STATE_FLAG_SELECTED);
-  gtk_style_context_get (context, state_flags | GTK_STATE_FLAG_SELECTED, "font", &sfont_desc, NULL);
-  gtk_style_context_restore (context);
-
   slayout = gtk_widget_create_pango_layout (widget, NULL);
-  pango_layout_set_font_description (slayout, sfont_desc);
+  gtk_style_context_restore (context);
 
   /* header */
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "header");
 
   str = g_strdup (gcal_get_month_name (month_nr));
-  gtk_style_context_get (context, state_flags, "font", &font_desc, NULL);
 
   layout = gtk_widget_create_pango_layout (widget, str);
-  pango_layout_set_font_description (layout, font_desc);
   pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
   gtk_render_layout (context, cr, x + (year_view->column_width - layout_width) / 2.0, y + (box_side - 
layout_height) / 2.0,
                      layout);
@@ -800,7 +790,6 @@ draw_month_grid (GcalYearView *year_view,
                          x + (year_view->column_width - layout_width) / 2.0, y + (box_side - layout_height) 
/ 2.0,
                          layout_width, layout_width);
 
-  pango_font_description_free (font_desc);
   g_free (str);
   gtk_style_context_restore (context);
 
@@ -808,7 +797,7 @@ draw_month_grid (GcalYearView *year_view,
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "lines");
 
-  gtk_style_context_get_color (context, state_flags, &color);
+  gtk_style_context_get_color (context, &color);
   cairo_set_line_width (cr, 0.2);
   gdk_cairo_set_source_rgba (cr, &color);
 
@@ -822,9 +811,6 @@ draw_month_grid (GcalYearView *year_view,
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "days");
 
-  gtk_style_context_get (context, state_flags, "font", &font_desc, NULL);
-  pango_layout_set_font_description (layout, font_desc);
-
   days_delay = (time_day_of_week (1, month_nr, g_date_time_get_year (year_view->date)) - 
year_view->first_weekday + 7) % 7;
   days = days_delay + g_date_get_days_in_month (month_nr + 1, g_date_time_get_year (year_view->date));
   shown_rows = ceil (days / 7.0);
@@ -926,14 +912,11 @@ draw_month_grid (GcalYearView *year_view,
           j == g_date_time_get_day_of_month (now))
         {
           PangoLayout *clayout;
-          PangoFontDescription *cfont_desc;
 
           gtk_style_context_save (context);
           gtk_style_context_add_class (context, "current");
 
           clayout = gtk_widget_create_pango_layout (widget, nr_day);
-          gtk_style_context_get (context, state_flags, "font", &cfont_desc, NULL);
-          pango_layout_set_font_description (clayout, cfont_desc);
           pango_layout_get_pixel_size (clayout, &layout_width, &layout_height);
           box_padding_top = (box_side - layout_height) / 2 > 0 ? (box_side - layout_height) / 2 : 0;
           box_padding_start = (box_side - layout_width) / 2 > 0 ? (box_side - layout_width) / 2 : 0;
@@ -949,7 +932,6 @@ draw_month_grid (GcalYearView *year_view,
                              clayout);
 
           gtk_style_context_restore (context);
-          pango_font_description_free (cfont_desc);
           g_object_unref (clayout);
         }
       else if (selected_day)
@@ -1010,16 +992,13 @@ draw_month_grid (GcalYearView *year_view,
 
       g_free (nr_day);
     }
-  pango_font_description_free (font_desc);
+
   gtk_style_context_restore (context);
 
   /* week numbers */
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "week-numbers");
 
-  gtk_style_context_get (context, state_flags, "font", &font_desc, NULL);
-  pango_layout_set_font_description (layout, font_desc);
-
   for (i = 0; i < shown_rows; i++)
     {
       /* special condition for first and last weeks of the year */
@@ -1060,36 +1039,30 @@ draw_month_grid (GcalYearView *year_view,
     }
   gtk_style_context_restore (context);
 
-  pango_font_description_free (sfont_desc);
-  g_object_unref (slayout);
-
-  pango_font_description_free (font_desc);
-  g_object_unref (layout);
   cairo_restore (cr);
 }
 
-static gboolean
-draw_navigator (GcalYearView *year_view,
-                cairo_t      *cr,
-                GtkWidget    *widget)
+static void
+draw_navigator (GtkWidget *widget,
+                cairo_t   *cr,
+                gint       width,
+                gint       height,
+                gpointer   user_data)
 {
+  GcalYearView *year_view = GCAL_YEAR_VIEW (user_data);
   GtkStyleContext *context;
   GtkStateFlags state_flags;
+  PangoLayout *header_layout;
   GtkBorder padding;
 
   gint header_height, layout_width, layout_height;
   gint real_padding_left, real_padding_top, i, sw, weeks_counter, number_of_rows;
-  gdouble width, height;
 
   gchar *header_str;
 
-  PangoLayout *header_layout;
-  PangoFontDescription *font_desc;
-
   context = gtk_widget_get_style_context (widget);
   state_flags = gtk_style_context_get_state (context);
   sw = 1 - 2 * year_view->k;
-  width = gtk_widget_get_allocated_width (widget);
   number_of_rows = ceil (12.0 / year_view->number_of_columns);
 
   /* read header from CSS code related to the view */
@@ -1097,13 +1070,11 @@ draw_navigator (GcalYearView *year_view,
   gtk_style_context_add_class (context, "primary-label");
 
   header_str = g_strdup_printf ("%d", g_date_time_get_year (year_view->date));
-  gtk_style_context_get (context, state_flags, "font", &font_desc, NULL);
-  gtk_style_context_get_padding (context, state_flags, &padding);
+  gtk_style_context_get_padding (context, &padding);
 
   gtk_style_context_restore (context);
 
   header_layout = gtk_widget_create_pango_layout (widget, header_str);
-  pango_layout_set_font_description (header_layout, font_desc);
   pango_layout_get_pixel_size (header_layout, &layout_width, &layout_height);
   /* XXX: here the color of the text isn't read from year-view but from navigator widget,
    * which has the same color on the CSS file */
@@ -1112,12 +1083,11 @@ draw_navigator (GcalYearView *year_view,
                      padding.top,
                      header_layout);
 
-  pango_font_description_free (font_desc);
   g_object_unref (header_layout);
   g_free (header_str);
 
   header_height = padding.top * 2 + layout_height;
-  height = gtk_widget_get_allocated_height (widget) - header_height;
+  height -= header_height;
 
   real_padding_left = (width - year_view->column_width * year_view->number_of_columns) / 
(year_view->number_of_columns + 1);
   real_padding_top = (height - year_view->row_height * number_of_rows) / number_of_rows;
@@ -1135,10 +1105,9 @@ draw_navigator (GcalYearView *year_view,
       year_view->navigator_grid->coordinates[i].y = row * real_padding_top + row * year_view->row_height + 
header_height;
       draw_month_grid (year_view, widget, cr, i, &weeks_counter);
     }
-
-  return FALSE;
 }
 
+#if 0
 static gboolean
 navigator_button_press_cb (GcalYearView   *year_view,
                            GdkEventButton *event,
@@ -1316,6 +1285,8 @@ navigator_scroll_event_cb (GcalYearView   *self,
   return GDK_EVENT_STOP;
 }
 
+#endif
+
 static void
 add_event_clicked_cb (GcalYearView *year_view,
                       GtkButton    *button)
@@ -1364,9 +1335,7 @@ calculate_sizes (GcalYearView *self)
 {
   GtkStyleContext *context;
   PangoLayout *layout;
-  PangoFontDescription *font;
-
-  gint padding_left, padding_right, padding_top, padding_bottom;
+  GtkBorder padding;
   gint width, height, box_width, box_height, natural;
   gchar *test_str;
 
@@ -1374,53 +1343,46 @@ calculate_sizes (GcalYearView *self)
   context = gtk_widget_get_style_context (GTK_WIDGET (self));
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "primary-label");
-  gtk_style_context_get (context, gtk_style_context_get_state (context),
-                         "padding-top", &padding_top,
-                         "padding-bottom", &padding_bottom,
-                         "font", &font, NULL);
+  gtk_style_context_get_padding (context, &padding);
   gtk_style_context_restore (context);
 
   /* measure header height */
   test_str = g_strdup_printf ("8888");
   layout = gtk_widget_create_pango_layout (self->navigator, test_str);
-  pango_layout_set_font_description (layout, font);
   pango_layout_get_pixel_size (layout, &width, &height);
 
-  pango_font_description_free (font);
   g_object_unref (layout);
   g_free (test_str);
 
-  self->header_height = padding_top + height + padding_bottom;
+  self->header_height = padding.top + height + padding.bottom;
 
   /* get day info from CSS */
   context = gtk_widget_get_style_context (GTK_WIDGET (self->navigator));
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "days");
-  gtk_style_context_get (context, gtk_style_context_get_state (context),
-                         "padding-left", &padding_left,
-                         "padding-right", &padding_right,
-                         "padding-top", &padding_top,
-                         "padding-bottom", &padding_bottom,
-                         "font", &font, NULL);
+  gtk_style_context_get_padding (context, &padding);
   gtk_style_context_restore (context);
 
   /* measure box size */
   test_str = g_strdup_printf ("88");
   layout = gtk_widget_create_pango_layout (self->navigator, test_str);
-  pango_layout_set_font_description (layout, font);
   pango_layout_get_pixel_size (layout, &width, &height);
 
-  pango_font_description_free (font);
   g_object_unref (layout);
   g_free (test_str);
 
-  box_width = padding_left + width + padding_right;
-  box_height = padding_top + height + padding_bottom;
+  box_width = padding.left + width + padding.right;
+  box_height = padding.top + height + padding.bottom;
 
   self->navigator_grid->box_side = (box_width > box_height) ? box_width : box_height;
 
   /* get sidebar width */
-  gtk_widget_get_preferred_width (self->sidebar, &width, &natural);
+  gtk_widget_measure (self->sidebar,
+                      GTK_ORIENTATION_HORIZONTAL,
+                      -1,
+                      &width, &natural,
+                      NULL, NULL);
+
   self->sidebar_width = width;
 
   calculate_grid_sizes (self);
@@ -1429,6 +1391,7 @@ calculate_sizes (GcalYearView *self)
 /*
  * Drag and Drop functions
  */
+#if 0 // TODO: DnD
 static gboolean
 navigator_drag_motion_cb (GcalYearView   *self,
                           GdkDragContext *context,
@@ -1569,6 +1532,7 @@ navigator_drag_leave_cb (GcalYearView   *self,
 
   gtk_widget_queue_draw (navigator);
 }
+#endif
 
 /*
  * GcalTimelineSubscriber implementation
@@ -1633,9 +1597,8 @@ static void
 gcal_year_view_remove_event (GcalTimelineSubscriber *subscriber,
                              GcalEvent              *event)
 {
-  g_autoptr (GList) children = NULL;
   GcalYearView *self;
-  GList *l;
+  GtkWidget *child;
   const gchar *event_id;
   guint n_children;
   guint i;
@@ -1646,20 +1609,24 @@ gcal_year_view_remove_event (GcalTimelineSubscriber *subscriber,
   event_id = gcal_event_get_uid (event);
 
   n_children = 0;
-  children = gtk_container_get_children (GTK_CONTAINER (self->events_sidebar));
 
-  for (l = children; l != NULL; l = g_list_next (l))
+  child = gtk_widget_get_first_child (self->events_sidebar);
+  while (child)
     {
       GcalEventWidget *child_widget;
       GcalEvent *list_event;
+      GtkWidget *next;
 
-      child_widget = GCAL_EVENT_WIDGET (gtk_bin_get_child (GTK_BIN (l->data)));
+      next = gtk_widget_get_next_sibling (child);
+      child_widget = GCAL_EVENT_WIDGET (gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (child)));
       list_event = gcal_event_widget_get_event (child_widget);
 
       if (g_strcmp0 (event_id, gcal_event_get_uid (list_event)) == 0)
-        gtk_widget_destroy (GTK_WIDGET (l->data));
+        gtk_list_box_remove (GTK_LIST_BOX (self->events_sidebar), child);
       else
         n_children++;
+
+      child = next;
     }
 
   /*
@@ -1708,7 +1675,6 @@ gcal_year_view_update_event (GcalTimelineSubscriber *subscriber,
   gcal_year_view_remove_event (subscriber, event);
   gcal_year_view_add_event (subscriber, event);
 
-
   GCAL_EXIT;
 }
 
@@ -1775,16 +1741,8 @@ gcal_year_view_get_children_by_uuid (GcalView              *view,
                                      const gchar           *uuid)
 {
   GcalYearView *self = GCAL_YEAR_VIEW (view);
-  GList *result, *children;
-
-  result = NULL;
 
-  children = gtk_container_get_children (GTK_CONTAINER (self->sidebar));
-  result = filter_event_list_by_uid_and_modtype (children, mod, uuid);
-
-  g_list_free (children);
-
-  return result;
+  return filter_children_by_uid_and_modtype (self->events_sidebar, mod, uuid);
 }
 
 static GDateTime*
@@ -1911,51 +1869,25 @@ gcal_year_view_set_property (GObject      *object,
     }
 }
 
-static void
-gcal_year_view_get_preferred_width (GtkWidget *widget,
-                                    gint      *minimum,
-                                    gint      *natural)
-{
-  GcalYearView *year_view = GCAL_YEAR_VIEW (widget);
-  GtkStyleContext *context;
-  gint padding_left, padding_right, hpadding;
-
-  context = gtk_widget_get_style_context (year_view->navigator);
-
-  gtk_style_context_get (context,
-                         gtk_style_context_get_state (context),
-                         "padding-left", &padding_left,
-                         "padding-right", &padding_right, NULL);
-
-  hpadding = padding_left + padding_right;
-  if (minimum != NULL)
-    *minimum = hpadding + year_view->column_width;
-  if (natural != NULL)
-    *natural = hpadding + year_view->column_width + year_view->sidebar_width;
-}
-
+#if 0
 static void
 gcal_year_view_size_allocate (GtkWidget     *widget,
                               GtkAllocation *alloc)
 {
   GcalYearView *year_view = GCAL_YEAR_VIEW (widget);
   GtkStyleContext *context;
-  gint padding_left, padding_right, padding_top, padding_bottom, hpadding, vpadding;
+  GtkBorder padding;
+  gint hpadding, vpadding;
   gint number_of_rows;
 
   context = gtk_widget_get_style_context (widget);
   gtk_style_context_save (context);
   gtk_style_context_add_class (context, "year-navigator");
-  gtk_style_context_get (context,
-                         gtk_style_context_get_state (context),
-                         "padding-left", &padding_left,
-                         "padding-right", &padding_right,
-                         "padding-top", &padding_top,
-                         "padding-bottom", &padding_bottom, NULL);
+  gtk_style_context_get_padding (context, &padding);
   gtk_style_context_restore (context);
 
-  hpadding = padding_left + padding_right;
-  vpadding = padding_top + padding_bottom;
+  hpadding = padding.left + padding.right;
+  vpadding = padding.top + padding.bottom;
 
   year_view->popover_mode = (alloc->width < (hpadding + year_view->column_width * 2 + 
year_view->sidebar_width));
 
@@ -1999,6 +1931,7 @@ gcal_year_view_size_allocate (GtkWidget     *widget,
 
   GTK_WIDGET_CLASS (gcal_year_view_parent_class)->size_allocate (widget, alloc);
 }
+#endif
 
 static void
 gcal_year_view_direction_changed (GtkWidget        *widget,
@@ -2023,8 +1956,7 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
   object_class->get_property = gcal_year_view_get_property;
   object_class->set_property = gcal_year_view_set_property;
 
-  widget_class->get_preferred_width = gcal_year_view_get_preferred_width;
-  widget_class->size_allocate = gcal_year_view_size_allocate;
+  //widget_class->size_allocate = gcal_year_view_size_allocate;
   widget_class->direction_changed = gcal_year_view_direction_changed;
 
   g_object_class_override_property (object_class, PROP_DATE, "active-date");
@@ -2051,15 +1983,14 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GcalYearView, temp_label);
   gtk_widget_class_bind_template_child (widget_class, GcalYearView, weather_icon);
 
-  gtk_widget_class_bind_template_callback (widget_class, draw_navigator);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_button_press_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_button_release_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_drag_drop_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_drag_leave_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_drag_motion_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_edge_overshot_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_motion_notify_cb);
-  gtk_widget_class_bind_template_callback (widget_class, navigator_scroll_event_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_button_press_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_button_release_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_drag_drop_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_drag_leave_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_drag_motion_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_edge_overshot_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_motion_notify_cb);
+  //gtk_widget_class_bind_template_callback (widget_class, navigator_scroll_event_cb);
   gtk_widget_class_bind_template_callback (widget_class, add_event_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, popover_closed_cb);
 
@@ -2098,12 +2029,16 @@ gcal_year_view_init (GcalYearView *self)
   gtk_list_box_set_header_func (GTK_LIST_BOX (self->events_sidebar), update_sidebar_headers, self, NULL);
   gtk_list_box_set_sort_func (GTK_LIST_BOX (self->events_sidebar), sidebar_sort_func, NULL, NULL);
 
+  gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->navigator), draw_navigator, self, NULL);
+
+#if 0 // TODO: DnD
   /* The year navigator is a DnD destination */
   gtk_drag_dest_set (self->navigator,
                      0,
                      NULL,
                      0,
                      GDK_ACTION_MOVE);
+#endif
 }
 
 
@@ -2148,7 +2083,7 @@ update_weather (GcalYearView *self)
               icon_nm = gcal_weather_info_get_icon_name (info);
 
               gtk_label_set_text (self->temp_label, temp_str);
-              gtk_image_set_from_icon_name (self->weather_icon, icon_nm, GTK_ICON_SIZE_SMALL_TOOLBAR);
+              gtk_image_set_from_icon_name (self->weather_icon, icon_nm);
               updated = TRUE;
               break;
             }
diff --git a/src/gui/views/gcal-year-view.ui b/src/gui/views/gcal-year-view.ui
index 6dc8328d..89e22ef3 100644
--- a/src/gui/views/gcal-year-view.ui
+++ b/src/gui/views/gcal-year-view.ui
@@ -1,34 +1,30 @@
 <?xml version="1.0"?>
 <interface>
-  <!-- interface-requires gtk+ 3.10 -->
   <template class="GcalYearView" parent="GtkBox">
     <style>
       <class name="year-view"/>
     </style>
     <child>
       <object class="GtkScrolledWindow" id="scrolled_window">
-        <property name="visible">True</property>
-        <property name="shadow_type">none</property>
         <property name="vexpand">True</property>
+        <!--
         <signal name="edge-overshot" handler="navigator_edge_overshot_cb" object="GcalYearView" 
swapped="yes"/>
         <signal name="scroll-event" handler="navigator_scroll_event_cb" object="GcalYearView" swapped="yes"/>
+        -->
         <child>
           <object class="GtkViewport">
-            <property name="visible">True</property>
-            <property name="shadow_type">none</property>
             <property name="vexpand">True</property>
             <child>
               <object class="GtkDrawingArea" id="navigator">
-                <property name="visible">True</property>
                 <property name="hexpand">True</property>
-                <property 
name="events">GDK_POINTER_MOTION_MASK|GDK_BUTTON_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_STRUCTURE_MASK</property>
-                <signal name="draw" handler="draw_navigator" object="GcalYearView" swapped="yes"/>
+                <!--
                 <signal name="button-press-event" handler="navigator_button_press_cb" object="GcalYearView" 
swapped="yes"/>
                 <signal name="button-release-event" handler="navigator_button_release_cb" 
object="GcalYearView" swapped="yes"/>
                 <signal name="motion-notify-event" handler="navigator_motion_notify_cb" 
object="GcalYearView" swapped="yes"/>
                 <signal name="drag-motion" handler="navigator_drag_motion_cb" object="GcalYearView" 
swapped="yes"/>
                 <signal name="drag-drop" handler="navigator_drag_drop_cb" object="GcalYearView" 
swapped="yes"/>
                 <signal name="drag-leave" handler="navigator_drag_leave_cb" object="GcalYearView" 
swapped="yes"/>
+                -->
                 <style>
                   <class name="year-navigator"/>
                 </style>
@@ -37,133 +33,99 @@
           </object>
         </child>
       </object>
-      <packing>
-        <property name="position">0</property>
-        <property name="pack_type">start</property>
-      </packing>
     </child>
     <child>
       <object class="GtkBox" id="sidebar">
-        <property name="visible">True</property>
         <property name="width_request">200</property>
         <property name="orientation">vertical</property>
         <child>
           <object class="GtkStack" id="navigator_stack">
-            <property name="visible">True</property>
+
             <child>
-              <object class="GtkScrolledWindow" id="navigator_sidebar">
-                <property name="visible">True</property>
-                <property name="shadow_type">none</property>
-                <property name="vexpand">True</property>
-                <child>
-                  <object class="GtkListBox" id="events_sidebar">
-                    <property name="visible">True</property>
-                    <property name="selection-mode">none</property>
-                    <style>
-                      <class name="sidebar"/>
-                    </style>
+              <object class="GtkStackPage">
+                <property name="name">events-list</property>
+                <property name="child">
+                  <object class="GtkScrolledWindow" id="navigator_sidebar">
+                    <property name="vexpand">True</property>
+                    <child>
+                      <object class="GtkListBox" id="events_sidebar">
+                        <property name="selection-mode">none</property>
+                        <style>
+                          <class name="sidebar"/>
+                        </style>
+                      </object>
+                    </child>
                   </object>
-                </child>
+                </property>
               </object>
-              <packing>
-                <property name="name">events-list</property>
-              </packing>
             </child>
+
             <child>
-              <object class="GtkBox">
-                <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <style>
-                  <class name="sidebar"/>
-                </style>
-                <child>
+              <object class="GtkStackPage">
+                <property name="name">no-events</property>
+                <property name="child">
                   <object class="GtkBox">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="spacing">6</property>
+                    <property name="orientation">vertical</property>
+                    <style>
+                      <class name="sidebar"/>
+                    </style>
                     <child>
-                      <object class="GtkLabel" id="no_events_title">
-                        <property name="visible">True</property>
-                        <property name="halign">start</property>
-                        <property name="label" translatable="yes">Today</property>
-                        <style>
-                          <class name="sidebar-header"/>
-                        </style>
+                      <object class="GtkBox">
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="no_events_title">
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="halign">start</property>
+                            <property name="label" translatable="yes">Today</property>
+                            <style>
+                              <class name="sidebar-header"/>
+                            </style>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="temp_label">
+                            <property name="label">temp</property>
+                            <property name="label">foo</property>
+                            <style>
+                              <class name="temp-label" />
+                            </style>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="weather_icon" />
+                        </child>
                       </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="temp_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label">temp</property>
-                        <property name="label">foo</property>
+                      <object class="GtkLabel">
+                        <property name="halign">start</property>
+                        <property name="margin_start">6</property>
+                        <property name="label" translatable="yes">No events</property>
                         <style>
-                          <class name="temp-label" />
+                          <class name="dim-label"/>
+                          <class name="italic-label"/>
                         </style>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
                     </child>
-                    <child>
-                      <object class="GtkImage" id="weather_icon">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="halign">start</property>
-                    <property name="margin_start">6</property>
-                    <property name="label" translatable="yes">No events</property>
-                    <style>
-                      <class name="dim-label"/>
-                      <class name="italic-label"/>
-                    </style>
                   </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
+                </property>
               </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="name">no-events</property>
-              </packing>
             </child>
+
           </object>
         </child>
         <child>
           <object class="GtkButton">
-            <property name="visible">True</property>
             <property name="valign">end</property>
             <property name="label" translatable="yes">Add Event…</property>
             <signal name="clicked" handler="add_event_clicked_cb" object="GcalYearView" swapped="yes"/>
           </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
     </child>
   </template>
   <object class="GtkPopover" id="popover">
-    <property name="relative_to">navigator</property>
     <style>
       <class name="events"/>
     </style>


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