weeks/view: Add anonymous struct for selection
Same as the grid view.
This commit is contained in:
@@ -104,8 +104,10 @@ struct _GcalWeekHeader
|
|||||||
|
|
||||||
GDateTime *active_date;
|
GDateTime *active_date;
|
||||||
|
|
||||||
gint selection_start;
|
struct {
|
||||||
gint selection_end;
|
gint start;
|
||||||
|
gint end;
|
||||||
|
} selection;
|
||||||
gint dnd_cell;
|
gint dnd_cell;
|
||||||
|
|
||||||
/* Array of nullable weather infos for each day, starting with Sunday. */
|
/* Array of nullable weather infos for each day, starting with Sunday. */
|
||||||
@@ -262,8 +264,8 @@ on_button_pressed (GtkGestureClick *click_gesture,
|
|||||||
column_width = width / 7.0;
|
column_width = width / 7.0;
|
||||||
column = ltr ? (x / column_width) : (7 - x / column_width);
|
column = ltr ? (x / column_width) : (7 - x / column_width);
|
||||||
|
|
||||||
self->selection_start = column;
|
self->selection.start = column;
|
||||||
self->selection_end = column;
|
self->selection.end = column;
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
|
||||||
@@ -287,7 +289,7 @@ on_motion_notify (GtkEventControllerMotion *motion_event,
|
|||||||
column_width = width / 7.0;
|
column_width = width / 7.0;
|
||||||
column = ltr ? (x / column_width) : (7 - x / column_width);
|
column = ltr ? (x / column_width) : (7 - x / column_width);
|
||||||
|
|
||||||
self->selection_end = column;
|
self->selection.end = column;
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
@@ -317,15 +319,15 @@ on_button_released (GtkGestureClick *click_gesture,
|
|||||||
column_width = width / 7.0;
|
column_width = width / 7.0;
|
||||||
column = ltr ? (x / column_width) : (7 - x / column_width);
|
column = ltr ? (x / column_width) : (7 - x / column_width);
|
||||||
|
|
||||||
self->selection_end = column;
|
self->selection.end = column;
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
|
||||||
/* Fake the week view's event so we can control the X and Y values */
|
/* Fake the week view's event so we can control the X and Y values */
|
||||||
weekview = gtk_widget_get_ancestor (GTK_WIDGET (self), GCAL_TYPE_WEEK_VIEW);
|
weekview = gtk_widget_get_ancestor (GTK_WIDGET (self), GCAL_TYPE_WEEK_VIEW);
|
||||||
|
|
||||||
start = self->selection_start;
|
start = self->selection.start;
|
||||||
end = self->selection_end;
|
end = self->selection.end;
|
||||||
|
|
||||||
if (start > end)
|
if (start > end)
|
||||||
{
|
{
|
||||||
@@ -1410,14 +1412,14 @@ gcal_week_header_snapshot (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the selection background */
|
/* Draw the selection background */
|
||||||
if (self->selection_start != -1 && self->selection_end != -1)
|
if (self->selection.start != -1 && self->selection.end != -1)
|
||||||
{
|
{
|
||||||
gint selection_width;
|
gint selection_width;
|
||||||
gint selection_x;
|
gint selection_x;
|
||||||
gint start, end;
|
gint start, end;
|
||||||
|
|
||||||
start = self->selection_start;
|
start = self->selection.start;
|
||||||
end = self->selection_end;
|
end = self->selection.end;
|
||||||
|
|
||||||
if (start > end)
|
if (start > end)
|
||||||
{
|
{
|
||||||
@@ -1547,8 +1549,8 @@ gcal_week_header_init (GcalWeekHeader *self)
|
|||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
self->expanded = FALSE;
|
self->expanded = FALSE;
|
||||||
self->selection_start = -1;
|
self->selection.start = -1;
|
||||||
self->selection_end = -1;
|
self->selection.end = -1;
|
||||||
self->dnd_cell = -1;
|
self->dnd_cell = -1;
|
||||||
self->first_weekday = get_first_weekday ();
|
self->first_weekday = get_first_weekday ();
|
||||||
|
|
||||||
@@ -1783,8 +1785,8 @@ gcal_week_header_clear_marks (GcalWeekHeader *self)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
|
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
|
||||||
|
|
||||||
self->selection_start = -1;
|
self->selection.start = -1;
|
||||||
self->selection_end = -1;
|
self->selection.end = -1;
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user