示例#1
0
static void
add_event_clicked_cb (GcalYearView *year_view,
                      GtkButton    *button)
{
  GcalYearViewPrivate *priv = year_view->priv;
  icaltimetype *start_date, *end_date = NULL;

  if (priv->popover_mode)
    gtk_widget_hide (priv->popover);

  if (priv->start_selected_date->day == 0)
    {
      start_date = gcal_dup_icaltime (priv->current_date);
    }
  else
    {
      start_date = gcal_dup_icaltime (priv->start_selected_date);
      end_date = gcal_dup_icaltime (priv->end_selected_date);
      end_date->day += 1;
      *end_date = icaltime_normalize (*end_date);
      end_date->is_date = 1;
    }

  start_date->is_date = 1;
  g_signal_emit_by_name (GCAL_VIEW (year_view), "create-event-detailed", start_date, end_date);
  g_free (start_date);
  if (end_date != NULL)
    g_free (end_date);
}
示例#2
0
static void
gcal_month_view_set_property (GObject       *object,
                              guint          property_id,
                              const GValue  *value,
                              GParamSpec    *pspec)
{
  GcalMonthViewPrivate *priv = GCAL_MONTH_VIEW (object)->priv;

  switch (property_id)
    {
    case PROP_DATE:
      {
        icaltimetype *first_of_month;

        if (priv->date != NULL)
          g_free (priv->date);

        priv->date = g_value_dup_boxed (value);

        first_of_month = gcal_dup_icaltime (priv->date);
        first_of_month->day = 1;
        priv->days_delay =  - icaltime_day_of_week (*first_of_month) + 2;
        g_free (first_of_month);
        break;
      }
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
示例#3
0
/**
 * gcal_month_view_get_final_date:
 *
 * Since: 0.1
 * Return value: the last day of the month
 * Returns: (transfer full): Release with g_free
 **/
icaltimetype*
gcal_month_view_get_final_date (GcalMonthView *view)
{
  GcalMonthViewPrivate *priv;
  icaltimetype *new_date;

  priv = view->priv;
  new_date = gcal_dup_icaltime (priv->date);
  new_date->day = icaltime_days_in_month (priv->date->month, priv->date->year);
  return new_date;
}
示例#4
0
/**
 * gcal_month_view_get_initial_date:
 *
 * Since: 0.1
 * Return value: the first day of the month
 * Returns: (transfer full): Release with g_free
 **/
icaltimetype*
gcal_month_view_get_initial_date (GcalMonthView *view)
{
  GcalMonthViewPrivate *priv;
  icaltimetype *new_date;

  priv = view->priv;
  new_date = gcal_dup_icaltime (priv->date);
  new_date->day = 1;

  return new_date;
}
static void
gcal_week_view_set_date (GcalView     *view,
                         icaltimetype *date)
{
  GcalWeekView *self = GCAL_WEEK_VIEW (view);

  GCAL_ENTRY;

  g_clear_pointer (&self->date, g_free);
  self->date = gcal_dup_icaltime (date);

  /* Propagate the new date */
  gcal_week_grid_set_date (GCAL_WEEK_GRID (self->week_grid), date);
  gcal_week_header_set_date (GCAL_WEEK_HEADER (self->header), date);

  schedule_position_scroll (self);

  GCAL_EXIT;
}