week-header: simplify and extend moving column events
This commit is contained in:
@@ -104,6 +104,12 @@ enum
|
|||||||
PROP_ACTIVE_DATE
|
PROP_ACTIVE_DATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
UP,
|
||||||
|
DOWN
|
||||||
|
} MoveDirection;
|
||||||
|
|
||||||
G_DEFINE_TYPE (GcalWeekHeader, gcal_week_header, GTK_TYPE_GRID);
|
G_DEFINE_TYPE (GcalWeekHeader, gcal_week_header, GTK_TYPE_GRID);
|
||||||
|
|
||||||
static GDateTime*
|
static GDateTime*
|
||||||
@@ -386,14 +392,17 @@ split_event_widget_at_column (GcalWeekHeader *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
move_events_at_column (GcalWeekHeader *self,
|
move_events_at_column (GcalWeekHeader *self,
|
||||||
|
MoveDirection direction,
|
||||||
gint column,
|
gint column,
|
||||||
gint start_at,
|
gint start_at)
|
||||||
gint n_events)
|
|
||||||
{
|
{
|
||||||
GList *found_widgets, *l;
|
GList *found_widgets, *l;
|
||||||
|
gint n_events;
|
||||||
gint counter;
|
gint counter;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
n_events = g_list_length (self->events[column]) - start_at;
|
||||||
|
|
||||||
if (n_events == 0)
|
if (n_events == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -452,7 +461,7 @@ move_events_at_column (GcalWeekHeader *self,
|
|||||||
/* And move it to position + 1 */
|
/* And move it to position + 1 */
|
||||||
gtk_container_child_set (GTK_CONTAINER (self->grid),
|
gtk_container_child_set (GTK_CONTAINER (self->grid),
|
||||||
l->data,
|
l->data,
|
||||||
"top_attach", top_attach + 1,
|
"top_attach", top_attach + (direction == DOWN ? 1 : -1),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,7 +505,7 @@ add_event_to_grid (GcalWeekHeader *self,
|
|||||||
g_message (" - - adding event to column %d", start);
|
g_message (" - - adding event to column %d", start);
|
||||||
g_message (" - - - there are %d events in this column", events_at_weekday);
|
g_message (" - - - there are %d events in this column", events_at_weekday);
|
||||||
|
|
||||||
move_events_at_column (self, start, position, events_at_weekday - position + 1);
|
move_events_at_column (self, DOWN, start, position);
|
||||||
|
|
||||||
/* Add the event to the grid */
|
/* Add the event to the grid */
|
||||||
widget = gcal_event_widget_new (event);
|
widget = gcal_event_widget_new (event);
|
||||||
@@ -548,7 +557,7 @@ add_event_to_grid (GcalWeekHeader *self,
|
|||||||
|
|
||||||
g_message (" - - - adding event to position %d", new_position);
|
g_message (" - - - adding event to position %d", new_position);
|
||||||
|
|
||||||
move_events_at_column (self, i, new_position, events_at_weekday - new_position + 1);
|
move_events_at_column (self, DOWN, i, new_position);
|
||||||
|
|
||||||
/* Add the event to the grid */
|
/* Add the event to the grid */
|
||||||
if (new_position == position)
|
if (new_position == position)
|
||||||
|
|||||||
Reference in New Issue
Block a user