[gnome-calendar/wip/pandusonu/week-view: 26/60] week-header: turn into a GtkGrid
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/pandusonu/week-view: 26/60] week-header: turn into a GtkGrid
- Date: Fri, 2 Dec 2016 01:50:41 +0000 (UTC)
commit a43df17b08e24a295180baa7cdd5152b6650653a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jun 21 11:54:07 2016 -0300
week-header: turn into a GtkGrid
If the header is a GtkScrolledWindow, all the content
(including the top labels and week names) are scrolled.
This is a wrong behavior, since only the events should
be scrollable.
Fix that by making GcalWeekHeader a GtkGrid, and adding
the scrolled window in the correct position.
data/ui/week-header.ui | 38 +++++++++++++++++++++-----------------
src/views/gcal-week-header.c | 11 +++++++----
src/views/gcal-week-header.h | 2 +-
3 files changed, 29 insertions(+), 22 deletions(-)
---
diff --git a/data/ui/week-header.ui b/data/ui/week-header.ui
index 02ac769..4b430ad 100644
--- a/data/ui/week-header.ui
+++ b/data/ui/week-header.ui
@@ -1,9 +1,8 @@
<?xml version="1.0"?>
<interface>
- <template class="GcalWeekHeader" parent="GtkScrolledWindow">
+ <template class="GcalWeekHeader" parent="GtkGrid">
<property name="visible">True</property>
<property name="hexpand">True</property>
- <property name="max-content-height">200</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
@@ -44,25 +43,30 @@
</object>
</child>
<child>
- <object class="GtkViewport">
+ <object class="GtkOverlay">
<property name="visible">True</property>
- <property name="shadow_type">none</property>
<child>
- <object class="GtkOverlay">
+ <object class="GtkDrawingArea" id="draw_area">
<property name="visible">True</property>
+ <property name="height-request">100</property>
+ <signal name="draw" handler="gcal_week_header_draw" object="GcalWeekHeader" swapped="yes"/>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkScrolledWindow" id="scrolledwindow">
+ <property name="visible">True</property>
+ <property name="max-content-height">150</property>
<child>
- <object class="GtkDrawingArea" id="draw_area">
- <property name="visible">True</property>
- <property name="height-request">100</property>
- <signal name="draw" handler="gcal_week_header_draw" object="GcalWeekHeader"
swapped="yes"/>
- </object>
- </child>
- <child type="overlay">
- <object class="GtkGrid" id="grid">
+ <object class="GtkViewport">
<property name="visible">True</property>
- <property name="height-request">100</property>
- <property name="column-homogeneous">True</property>
- <property name="row-homogeneous">True</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="column-homogeneous">True</property>
+ <property name="row-homogeneous">True</property>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -72,4 +76,4 @@
</object>
</child>
</template>
-</interface>
\ No newline at end of file
+</interface>
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index bfeb197..c2d2280 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -31,13 +31,14 @@
struct _GcalWeekHeader
{
- GtkScrolledWindow parent;
+ GtkGrid parent;
GtkWidget *grid;
GtkWidget *draw_area;
GtkWidget *month_label;
GtkWidget *week_label;
GtkWidget *year_label;
+ GtkWidget *scrolledwindow;
GcalManager *manager;
@@ -78,7 +79,7 @@ enum
PROP_ACTIVE_DATE
};
-G_DEFINE_TYPE (GcalWeekHeader, gcal_week_header, GTK_TYPE_SCROLLED_WINDOW);
+G_DEFINE_TYPE (GcalWeekHeader, gcal_week_header, GTK_TYPE_GRID);
static GDateTime*
get_start_of_week (GcalWeekHeader *self)
@@ -290,7 +291,8 @@ gcal_week_header_size_allocate (GtkWidget *widget,
gtk_style_context_get (context, state, "font", &bold_font, NULL);
pango_font_description_set_weight (bold_font, PANGO_WEIGHT_SEMIBOLD);
- gtk_widget_set_margin_top (self->grid, (4 * pango_font_description_get_size (bold_font)) / PANGO_SCALE);
+ gtk_widget_set_margin_top (self->scrolledwindow,
+ (4 * pango_font_description_get_size (bold_font)) / PANGO_SCALE);
GTK_WIDGET_CLASS (gcal_week_header_parent_class)->size_allocate (widget, alloc);
}
@@ -456,6 +458,7 @@ gcal_week_header_class_init (GcalWeekHeaderClass *kclass)
gtk_widget_class_bind_template_child (widget_class, GcalWeekHeader, year_label);
gtk_widget_class_bind_template_child (widget_class, GcalWeekHeader, week_label);
gtk_widget_class_bind_template_child (widget_class, GcalWeekHeader, draw_area);
+ gtk_widget_class_bind_template_child (widget_class, GcalWeekHeader, scrolledwindow);
gtk_widget_class_bind_template_callback (widget_class, gcal_week_header_draw);
@@ -513,4 +516,4 @@ gcal_week_header_set_current_date (GcalWeekHeader *self,
update_headers (self);
gtk_widget_queue_draw (self->draw_area);
-}
\ No newline at end of file
+}
diff --git a/src/views/gcal-week-header.h b/src/views/gcal-week-header.h
index db17803..5b60681 100644
--- a/src/views/gcal-week-header.h
+++ b/src/views/gcal-week-header.h
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
#define GCAL_TYPE_WEEK_HEADER (gcal_week_header_get_type())
-G_DECLARE_FINAL_TYPE (GcalWeekHeader, gcal_week_header, GCAL, WEEK_HEADER, GtkScrolledWindow)
+G_DECLARE_FINAL_TYPE (GcalWeekHeader, gcal_week_header, GCAL, WEEK_HEADER, GtkGrid)
void gcal_week_header_set_manager (GcalWeekHeader *self,
GcalManager *manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]