views/week: Cleanup line rendering code
Remove copied style context calls, pass less arguments.
This commit is contained in:
@@ -618,35 +618,22 @@ gcal_week_grid_snapshot (GtkWidget *widget,
|
|||||||
GtkSnapshot *snapshot)
|
GtkSnapshot *snapshot)
|
||||||
{
|
{
|
||||||
g_autoptr (GPtrArray) widgets = NULL;
|
g_autoptr (GPtrArray) widgets = NULL;
|
||||||
GtkStyleContext *context;
|
|
||||||
GcalWeekGrid *self;
|
GcalWeekGrid *self;
|
||||||
GtkBorder padding;
|
|
||||||
GdkRGBA color;
|
|
||||||
guint i;
|
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
self = GCAL_WEEK_GRID (widget);
|
self = GCAL_WEEK_GRID (widget);
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
|
||||||
gtk_style_context_add_class (context, "lines");
|
|
||||||
gtk_style_context_get_color (context, &color);
|
|
||||||
gtk_style_context_get_padding (context, &padding);
|
|
||||||
|
|
||||||
width = gtk_widget_get_width (widget);
|
width = gtk_widget_get_width (widget);
|
||||||
height = gtk_widget_get_height (widget);
|
height = gtk_widget_get_height (widget);
|
||||||
|
|
||||||
gcal_week_view_common_snapshot_hour_lines (widget, snapshot, GTK_ORIENTATION_HORIZONTAL, &color, width, height);
|
gcal_week_view_common_snapshot_hour_lines (widget, snapshot, GTK_ORIENTATION_HORIZONTAL, width, height);
|
||||||
gcal_week_view_common_snapshot_hour_lines (widget, snapshot, GTK_ORIENTATION_VERTICAL, &color, width, height);
|
gcal_week_view_common_snapshot_hour_lines (widget, snapshot, GTK_ORIENTATION_VERTICAL, width, height);
|
||||||
|
|
||||||
gtk_style_context_restore (context);
|
|
||||||
|
|
||||||
/* First, draw the selection */
|
/* First, draw the selection */
|
||||||
gtk_widget_snapshot_child (widget, self->selection.widget, snapshot);
|
gtk_widget_snapshot_child (widget, self->selection.widget, snapshot);
|
||||||
gtk_widget_snapshot_child (widget, self->dnd.widget, snapshot);
|
gtk_widget_snapshot_child (widget, self->dnd.widget, snapshot);
|
||||||
|
|
||||||
widgets = gcal_range_tree_get_all_data (self->events);
|
widgets = gcal_range_tree_get_all_data (self->events);
|
||||||
for (i = 0; i < widgets->len; i++)
|
for (guint i = 0; i < widgets->len; i++)
|
||||||
{
|
{
|
||||||
ChildData *child_data = g_ptr_array_index (widgets, i);
|
ChildData *child_data = g_ptr_array_index (widgets, i);
|
||||||
|
|
||||||
|
|||||||
@@ -1324,7 +1324,6 @@ gcal_week_header_snapshot (GtkWidget *widget,
|
|||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GcalWeekHeader *self;
|
GcalWeekHeader *self;
|
||||||
GtkStateFlags state;
|
GtkStateFlags state;
|
||||||
GdkRGBA color;
|
|
||||||
int alloc_width;
|
int alloc_width;
|
||||||
int alloc_height;
|
int alloc_height;
|
||||||
GDateTime *week_start, *week_end;
|
GDateTime *week_start, *week_end;
|
||||||
@@ -1421,14 +1420,9 @@ gcal_week_header_snapshot (GtkWidget *widget,
|
|||||||
width = gtk_widget_get_width (widget) - start_x;
|
width = gtk_widget_get_width (widget) - start_x;
|
||||||
height = gtk_widget_get_height (widget) - start_y;
|
height = gtk_widget_get_height (widget) - start_y;
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
|
||||||
gtk_style_context_add_class (context, "lines");
|
|
||||||
gtk_style_context_get_color (context, &color);
|
|
||||||
gtk_style_context_restore (context);
|
|
||||||
|
|
||||||
gtk_snapshot_save (snapshot);
|
gtk_snapshot_save (snapshot);
|
||||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||||
gcal_week_view_common_snapshot_hour_lines (widget, snapshot, GTK_ORIENTATION_HORIZONTAL, &color, width, height);
|
gcal_week_view_common_snapshot_hour_lines (widget, snapshot, GTK_ORIENTATION_HORIZONTAL, width, height);
|
||||||
gtk_snapshot_restore (snapshot);
|
gtk_snapshot_restore (snapshot);
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (gcal_week_header_parent_class)->snapshot (widget, snapshot);
|
GTK_WIDGET_CLASS (gcal_week_header_parent_class)->snapshot (widget, snapshot);
|
||||||
|
|||||||
@@ -65,25 +65,13 @@ static void
|
|||||||
gcal_week_hour_bar_snapshot (GtkWidget *widget,
|
gcal_week_hour_bar_snapshot (GtkWidget *widget,
|
||||||
GtkSnapshot *snapshot)
|
GtkSnapshot *snapshot)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
|
||||||
GtkWidget *child;
|
|
||||||
GdkRGBA color;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
|
||||||
gtk_style_context_add_class (context, "lines");
|
|
||||||
gtk_style_context_get_color (context, &color);
|
|
||||||
gtk_style_context_restore (context);
|
|
||||||
|
|
||||||
gcal_week_view_common_snapshot_hour_lines (widget,
|
gcal_week_view_common_snapshot_hour_lines (widget,
|
||||||
snapshot,
|
snapshot,
|
||||||
GTK_ORIENTATION_VERTICAL,
|
GTK_ORIENTATION_VERTICAL,
|
||||||
&color,
|
|
||||||
gtk_widget_get_width (widget),
|
gtk_widget_get_width (widget),
|
||||||
gtk_widget_get_height (widget));
|
gtk_widget_get_height (widget));
|
||||||
|
|
||||||
for (child = gtk_widget_get_first_child (widget);
|
for (GtkWidget *child = gtk_widget_get_first_child (widget);
|
||||||
child;
|
child;
|
||||||
child = gtk_widget_get_next_sibling (child))
|
child = gtk_widget_get_next_sibling (child))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,17 +25,22 @@ void
|
|||||||
gcal_week_view_common_snapshot_hour_lines (GtkWidget *widget,
|
gcal_week_view_common_snapshot_hour_lines (GtkWidget *widget,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot,
|
||||||
GtkOrientation orientation,
|
GtkOrientation orientation,
|
||||||
const GdkRGBA *line_color,
|
|
||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
gboolean ltr;
|
gboolean ltr;
|
||||||
gdouble column_width;
|
gdouble column_width;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
|
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
|
||||||
color = *line_color;
|
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_add_class (context, "lines");
|
||||||
|
gtk_style_context_get_color (context, &color);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
|
||||||
column_width = width / 7.0;
|
column_width = width / 7.0;
|
||||||
|
|
||||||
@@ -63,7 +68,7 @@ gcal_week_view_common_snapshot_hour_lines (GtkWidget *widget,
|
|||||||
for (i = 1; i < 24; i++)
|
for (i = 1; i < 24; i++)
|
||||||
{
|
{
|
||||||
gtk_snapshot_append_color (snapshot,
|
gtk_snapshot_append_color (snapshot,
|
||||||
line_color,
|
&color,
|
||||||
&GRAPHENE_RECT_INIT (0.f,
|
&GRAPHENE_RECT_INIT (0.f,
|
||||||
ALIGNED ((height / 24.0) * i),
|
ALIGNED ((height / 24.0) * i),
|
||||||
width,
|
width,
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ G_BEGIN_DECLS
|
|||||||
void gcal_week_view_common_snapshot_hour_lines (GtkWidget *widget,
|
void gcal_week_view_common_snapshot_hour_lines (GtkWidget *widget,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot,
|
||||||
GtkOrientation orientation,
|
GtkOrientation orientation,
|
||||||
const GdkRGBA *line_color,
|
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user