date-selector: use GDateTime internally
Using a GDateTime improves consistency with the other components (ideally, we'll move completely to GDateTime) and simplifies the code. This commit adds a new property GcalDateSelector::date and adapts the API to use GDateTime.
This commit is contained in:
@@ -229,7 +229,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||||
<signal name="modified" handler="update_date" object="GcalEditDialog" swapped="no"/>
|
<signal name="notify::date" handler="update_date" object="GcalEditDialog" swapped="yes"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
@@ -265,7 +265,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||||
<signal name="modified" handler="update_date" object="GcalEditDialog" swapped="no"/>
|
<signal name="notify::date" handler="update_date" object="GcalEditDialog" swapped="yes"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
|
|||||||
+123
-89
@@ -44,9 +44,7 @@ struct _GcalDateSelector
|
|||||||
GtkWidget *entries[NUM_ENTRIES];
|
GtkWidget *entries[NUM_ENTRIES];
|
||||||
|
|
||||||
/* date */
|
/* date */
|
||||||
gint day;
|
GDateTime *date;
|
||||||
gint month;
|
|
||||||
gint year;
|
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
const gchar *mask;
|
const gchar *mask;
|
||||||
@@ -59,12 +57,11 @@ struct _GcalDateSelector
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MODIFIED,
|
PROP_0,
|
||||||
NUM_SIGNALS
|
PROP_DATE,
|
||||||
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
static guint signals[NUM_SIGNALS] = { 0, };
|
|
||||||
|
|
||||||
static void calendar_day_selected (GtkCalendar *calendar,
|
static void calendar_day_selected (GtkCalendar *calendar,
|
||||||
GcalDateSelector *selector);
|
GcalDateSelector *selector);
|
||||||
|
|
||||||
@@ -91,19 +88,24 @@ static void
|
|||||||
calendar_day_selected (GtkCalendar *calendar,
|
calendar_day_selected (GtkCalendar *calendar,
|
||||||
GcalDateSelector *selector)
|
GcalDateSelector *selector)
|
||||||
{
|
{
|
||||||
|
GDateTime *new_date;
|
||||||
guint day, month, year;
|
guint day, month, year;
|
||||||
|
|
||||||
gtk_calendar_get_date (calendar, &year, &month, &day);
|
gtk_calendar_get_date (calendar, &year, &month, &day);
|
||||||
|
|
||||||
|
new_date = g_date_time_new_local (year, month + 1, day, 0, 0, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block signal handler to avoid an infinite
|
* Block signal handler to avoid an infinite
|
||||||
* recursion, exploding the proccess stack.
|
* recursion, exploding the proccess stack.
|
||||||
*/
|
*/
|
||||||
g_signal_handlers_block_by_func (selector->calendar, calendar_day_selected, selector);
|
g_signal_handlers_block_by_func (selector->calendar, calendar_day_selected, selector);
|
||||||
|
|
||||||
gcal_date_selector_set_date (selector, day, month + 1, year);
|
gcal_date_selector_set_date (selector, new_date);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (selector->calendar, calendar_day_selected, selector);
|
g_signal_handlers_unblock_by_func (selector->calendar, calendar_day_selected, selector);
|
||||||
|
|
||||||
|
g_clear_pointer (&new_date, g_date_time_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -125,18 +127,23 @@ entry_activated (GtkEntry *entry,
|
|||||||
static void
|
static void
|
||||||
parse_entries (GcalDateSelector *selector)
|
parse_entries (GcalDateSelector *selector)
|
||||||
{
|
{
|
||||||
|
GDateTime *new_date;
|
||||||
gint day, month, year;
|
gint day, month, year;
|
||||||
|
|
||||||
day = atoi (gtk_entry_get_text (GTK_ENTRY (selector->entries[DAY])));
|
day = atoi (gtk_entry_get_text (GTK_ENTRY (selector->entries[DAY])));
|
||||||
month = atoi (gtk_entry_get_text (GTK_ENTRY (selector->entries[MONTH])));
|
month = atoi (gtk_entry_get_text (GTK_ENTRY (selector->entries[MONTH])));
|
||||||
year = atoi (gtk_entry_get_text (GTK_ENTRY (selector->entries[YEAR])));
|
year = atoi (gtk_entry_get_text (GTK_ENTRY (selector->entries[YEAR])));
|
||||||
|
|
||||||
|
new_date = g_date_time_new_local (year, month, day, 0, 0, 0);
|
||||||
|
|
||||||
/* select the date */
|
/* select the date */
|
||||||
g_signal_handlers_block_by_func (selector->calendar, calendar_day_selected, selector);
|
g_signal_handlers_block_by_func (selector->calendar, calendar_day_selected, selector);
|
||||||
|
|
||||||
gcal_date_selector_set_date (selector, day, month, year);
|
gcal_date_selector_set_date (selector, new_date);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (selector->calendar, calendar_day_selected, selector);
|
g_signal_handlers_unblock_by_func (selector->calendar, calendar_day_selected, selector);
|
||||||
|
|
||||||
|
g_clear_pointer (&new_date, g_date_time_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -187,6 +194,44 @@ text_inserted (GtkEditable *editable,
|
|||||||
g_free (new_label);
|
g_free (new_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gcal_date_selector_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GcalDateSelector *self = (GcalDateSelector*) object;
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_DATE:
|
||||||
|
g_value_set_boxed (value, self->date);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gcal_date_selector_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GcalDateSelector *self = (GcalDateSelector*) object;
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_DATE:
|
||||||
|
gcal_date_selector_set_date (self, g_value_get_boxed (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_date_selector_class_init (GcalDateSelectorClass *klass)
|
gcal_date_selector_class_init (GcalDateSelectorClass *klass)
|
||||||
{
|
{
|
||||||
@@ -194,13 +239,21 @@ gcal_date_selector_class_init (GcalDateSelectorClass *klass)
|
|||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
object_class->constructed = gcal_date_selector_constructed;
|
object_class->constructed = gcal_date_selector_constructed;
|
||||||
|
object_class->get_property = gcal_date_selector_get_property;
|
||||||
|
object_class->set_property = gcal_date_selector_set_property;
|
||||||
|
|
||||||
signals[MODIFIED] = g_signal_new ("modified",
|
/**
|
||||||
GCAL_TYPE_DATE_SELECTOR,
|
* GcalDateSelector::date:
|
||||||
G_SIGNAL_RUN_LAST,
|
*
|
||||||
0,
|
* The current date of the selector.
|
||||||
NULL, NULL, NULL,
|
*/
|
||||||
G_TYPE_NONE, 0);
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_DATE,
|
||||||
|
g_param_spec_boxed ("date",
|
||||||
|
"Date of the selector",
|
||||||
|
"The current date of the selector",
|
||||||
|
G_TYPE_DATE_TIME,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/calendar/date-selector.ui");
|
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/calendar/date-selector.ui");
|
||||||
|
|
||||||
@@ -217,15 +270,18 @@ gcal_date_selector_class_init (GcalDateSelectorClass *klass)
|
|||||||
static void
|
static void
|
||||||
gcal_date_selector_init (GcalDateSelector *self)
|
gcal_date_selector_init (GcalDateSelector *self)
|
||||||
{
|
{
|
||||||
|
GDateTime *now;
|
||||||
gint i, d_index, max;
|
gint i, d_index, max;
|
||||||
|
|
||||||
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
|
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
self->day = 1;
|
now = g_date_time_new_now_local ();
|
||||||
self->month = 1;
|
self->date = g_date_time_new_local (g_date_time_get_year (now),
|
||||||
self->year = 1970;
|
g_date_time_get_month (now),
|
||||||
|
g_date_time_get_day_of_month (now),
|
||||||
|
0, 0, 0);
|
||||||
|
|
||||||
/* This string represents day/month/year order for each of the different
|
/* This string represents day/month/year order for each of the different
|
||||||
* languages. It could possibly be default value, %m/%d/%y placing the month
|
* languages. It could possibly be default value, %m/%d/%y placing the month
|
||||||
@@ -281,9 +337,6 @@ gcal_date_selector_init (GcalDateSelector *self)
|
|||||||
|
|
||||||
/* year */
|
/* year */
|
||||||
case 'y':
|
case 'y':
|
||||||
self->year_pos = d_index++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Y':
|
case 'Y':
|
||||||
self->year_pos = d_index++;
|
self->year_pos = d_index++;
|
||||||
break;
|
break;
|
||||||
@@ -344,99 +397,80 @@ gcal_date_selector_new (void)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gcal_date_selector_set_date:
|
* gcal_date_selector_set_date:
|
||||||
* @selector:
|
* @selector: a #GcalDateSelector
|
||||||
* @day: (nullable): The day number.
|
* @date: a valid #GDateTime
|
||||||
* @month: (nullable): The month number starting with 1
|
|
||||||
* @year: (nullable): The year number
|
|
||||||
*
|
*
|
||||||
* Set the value of the date shown
|
* Set the value of the shown date.
|
||||||
**/
|
*/
|
||||||
void
|
void
|
||||||
gcal_date_selector_set_date (GcalDateSelector *selector,
|
gcal_date_selector_set_date (GcalDateSelector *selector,
|
||||||
gint day,
|
GDateTime *date)
|
||||||
gint month,
|
|
||||||
gint year)
|
|
||||||
{
|
{
|
||||||
GDateTime *dt;
|
|
||||||
gchar *label;
|
|
||||||
|
|
||||||
g_return_if_fail (GCAL_IS_DATE_SELECTOR (selector));
|
g_return_if_fail (GCAL_IS_DATE_SELECTOR (selector));
|
||||||
day = CLAMP (day, 1, 31);
|
|
||||||
month = CLAMP (month, 1, 12);
|
|
||||||
/* since we're dealing only with the date, the tz shouldn't be a problem */
|
|
||||||
dt = g_date_time_new_local (year, month, day, 0, 0, 0);
|
|
||||||
|
|
||||||
/**
|
if (selector->date != date)
|
||||||
* When it fails to be instances, it's
|
{
|
||||||
* because edit dialog is cleaning it's
|
gchar *label;
|
||||||
* data. Thus, we should stop here.
|
|
||||||
*/
|
|
||||||
if (dt == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
selector->day = day;
|
g_clear_pointer (&selector->date, g_date_time_unref);
|
||||||
selector->month = month;
|
selector->date = g_date_time_new_local (g_date_time_get_year (date),
|
||||||
selector->year = year;
|
g_date_time_get_month (date),
|
||||||
|
g_date_time_get_day_of_month (date),
|
||||||
|
0, 0, 0);
|
||||||
|
|
||||||
month = CLAMP (month - 1, 0, 11);
|
/* set calendar's date */
|
||||||
|
g_signal_handlers_block_by_func (selector->calendar, calendar_day_selected, selector);
|
||||||
|
|
||||||
/* set calendar's date */
|
g_object_set (selector->calendar,
|
||||||
g_signal_handlers_block_by_func (selector->calendar, calendar_day_selected, selector);
|
"day", g_date_time_get_day_of_month (date),
|
||||||
g_object_set (selector->calendar, "day", day, "month", month, "year", year, NULL);
|
"month", g_date_time_get_month (date) - 1,
|
||||||
g_signal_handlers_unblock_by_func (selector->calendar, calendar_day_selected, selector);
|
"year", g_date_time_get_year (date),
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* rebuild the date label */
|
g_signal_handlers_unblock_by_func (selector->calendar, calendar_day_selected, selector);
|
||||||
label = g_date_time_format (dt, selector->mask);
|
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (selector->date_label), label);
|
/* rebuild the date label */
|
||||||
g_free (label);
|
label = g_date_time_format (date, selector->mask);
|
||||||
|
|
||||||
/* set date entries' text */
|
gtk_label_set_label (GTK_LABEL (selector->date_label), label);
|
||||||
/* day entry */
|
g_free (label);
|
||||||
label = g_strdup_printf ("%.2d", day);
|
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (selector->entries[DAY]), label);
|
/* set date entries' text */
|
||||||
g_free (label);
|
/* day entry */
|
||||||
|
label = g_date_time_format (date, "%d");
|
||||||
|
|
||||||
/* month entry */
|
gtk_entry_set_text (GTK_ENTRY (selector->entries[DAY]), label);
|
||||||
label = g_strdup_printf ("%.2d", selector->month);
|
g_free (label);
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (selector->entries[MONTH]), label);
|
/* month entry */
|
||||||
g_free (label);
|
label = g_date_time_format (date, "%m");
|
||||||
|
|
||||||
/* year entry */
|
gtk_entry_set_text (GTK_ENTRY (selector->entries[MONTH]), label);
|
||||||
label = g_strdup_printf ("%.4d", year);
|
g_free (label);
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (selector->entries[YEAR]), label);
|
/* year entry */
|
||||||
|
label = g_date_time_format (date, "%Y");
|
||||||
|
|
||||||
/* emit the MODIFIED signal */
|
gtk_entry_set_text (GTK_ENTRY (selector->entries[YEAR]), label);
|
||||||
g_signal_emit (selector, signals[MODIFIED], 0);
|
g_free (label);
|
||||||
|
|
||||||
g_free (label);
|
/* emit the MODIFIED signal */
|
||||||
g_date_time_unref (dt);
|
g_object_notify (G_OBJECT (selector), "date");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gcal_date_selector_get_date:
|
* gcal_date_selector_get_date:
|
||||||
* @selector:
|
* @selector: a #GcalDateSelector
|
||||||
* @day: (nullable): An out argument to hold the day number
|
|
||||||
* @month: (nullable): An out argument to hold the month number starting with 1
|
|
||||||
* @year: (nullable): An out argument to hold the year number
|
|
||||||
*
|
*
|
||||||
* Get the value of the date shown
|
* Get the value of the date shown
|
||||||
**/
|
*
|
||||||
void
|
* Returns: (transfer none): the date of the selector.
|
||||||
gcal_date_selector_get_date (GcalDateSelector *selector,
|
*/
|
||||||
gint *day,
|
GDateTime*
|
||||||
gint *month,
|
gcal_date_selector_get_date (GcalDateSelector *selector)
|
||||||
gint *year)
|
|
||||||
{
|
{
|
||||||
g_return_if_fail (GCAL_IS_DATE_SELECTOR (selector));
|
g_return_val_if_fail (GCAL_IS_DATE_SELECTOR (selector), NULL);
|
||||||
|
|
||||||
if (day != NULL)
|
return selector->date;
|
||||||
*day = selector->day;
|
|
||||||
if (month != NULL)
|
|
||||||
*month = selector->month;
|
|
||||||
if (year != NULL)
|
|
||||||
*year = selector->year;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,15 +30,10 @@ G_DECLARE_FINAL_TYPE (GcalDateSelector, gcal_date_selector, GCAL, DATE_SELECTOR,
|
|||||||
|
|
||||||
GtkWidget* gcal_date_selector_new (void);
|
GtkWidget* gcal_date_selector_new (void);
|
||||||
|
|
||||||
void gcal_date_selector_set_date (GcalDateSelector *selector,
|
GDateTime* gcal_date_selector_get_date (GcalDateSelector *selector);
|
||||||
gint day,
|
|
||||||
gint month,
|
|
||||||
gint year);
|
|
||||||
|
|
||||||
void gcal_date_selector_get_date (GcalDateSelector *selector,
|
void gcal_date_selector_set_date (GcalDateSelector *selector,
|
||||||
gint *day,
|
GDateTime *date);
|
||||||
gint *month,
|
|
||||||
gint *year);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
+24
-38
@@ -74,8 +74,7 @@ static void on_calendar_selected (GtkWidget *me
|
|||||||
GVariant *value,
|
GVariant *value,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
static void update_date (GtkEntry *entry,
|
static void update_date (GcalEditDialog *dialog);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
static void update_location (GtkEntry *entry,
|
static void update_location (GtkEntry *entry,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
@@ -217,20 +216,16 @@ on_calendar_selected (GtkWidget *menu_item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_date (GtkEntry *entry,
|
update_date (GcalEditDialog *dialog)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GcalEditDialog *dialog;
|
|
||||||
GDateTime *start_date;
|
GDateTime *start_date;
|
||||||
GDateTime *end_date;
|
GDateTime *end_date;
|
||||||
|
|
||||||
dialog = GCAL_EDIT_DIALOG (user_data);
|
|
||||||
|
|
||||||
if (dialog->setting_event)
|
if (dialog->setting_event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
start_date = gcal_edit_dialog_get_date_start (GCAL_EDIT_DIALOG (user_data));
|
start_date = gcal_edit_dialog_get_date_start (dialog);
|
||||||
end_date = gcal_edit_dialog_get_date_end (GCAL_EDIT_DIALOG (user_data));
|
end_date = gcal_edit_dialog_get_date_end (dialog);
|
||||||
|
|
||||||
/* update component */
|
/* update component */
|
||||||
gcal_event_set_date_start (dialog->event, start_date);
|
gcal_event_set_date_start (dialog->event, start_date);
|
||||||
@@ -553,9 +548,7 @@ gcal_edit_dialog_clear_data (GcalEditDialog *dialog)
|
|||||||
dialog);
|
dialog);
|
||||||
|
|
||||||
/* date and time */
|
/* date and time */
|
||||||
gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->start_date_selector), 0, 0, 0);
|
|
||||||
gcal_time_selector_set_time (GCAL_TIME_SELECTOR (dialog->start_time_selector), 0, 0);
|
gcal_time_selector_set_time (GCAL_TIME_SELECTOR (dialog->start_time_selector), 0, 0);
|
||||||
gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->end_date_selector), 0, 0, 0);
|
|
||||||
gcal_time_selector_set_time (GCAL_TIME_SELECTOR (dialog->end_time_selector), 0, 0);
|
gcal_time_selector_set_time (GCAL_TIME_SELECTOR (dialog->end_time_selector), 0, 0);
|
||||||
|
|
||||||
/* location */
|
/* location */
|
||||||
@@ -707,18 +700,11 @@ gcal_edit_dialog_set_event (GcalEditDialog *dialog,
|
|||||||
date_start = gcal_event_get_date_start (event);
|
date_start = gcal_event_get_date_start (event);
|
||||||
date_end = gcal_event_get_date_end (event);
|
date_end = gcal_event_get_date_end (event);
|
||||||
|
|
||||||
/* start date */
|
/* date */
|
||||||
gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->start_date_selector),
|
gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->start_date_selector), date_start);
|
||||||
g_date_time_get_day_of_month (date_start),
|
gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->end_date_selector), date_end);
|
||||||
g_date_time_get_month (date_start),
|
|
||||||
g_date_time_get_year (date_start));
|
|
||||||
|
|
||||||
gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->end_date_selector),
|
/* time */
|
||||||
g_date_time_get_day_of_month (date_end),
|
|
||||||
g_date_time_get_month (date_end),
|
|
||||||
g_date_time_get_year (date_end));
|
|
||||||
|
|
||||||
/* start time */
|
|
||||||
if (!gcal_event_get_all_day (event))
|
if (!gcal_event_get_all_day (event))
|
||||||
{
|
{
|
||||||
gcal_time_selector_set_time (GCAL_TIME_SELECTOR (dialog->start_time_selector),
|
gcal_time_selector_set_time (GCAL_TIME_SELECTOR (dialog->start_time_selector),
|
||||||
@@ -764,20 +750,20 @@ gcal_edit_dialog_set_manager (GcalEditDialog *dialog,
|
|||||||
GDateTime*
|
GDateTime*
|
||||||
gcal_edit_dialog_get_date_start (GcalEditDialog *dialog)
|
gcal_edit_dialog_get_date_start (GcalEditDialog *dialog)
|
||||||
{
|
{
|
||||||
GDateTime *date;
|
GDateTime *date, *aux;
|
||||||
gint year, month, day;
|
|
||||||
gint hour, minute;
|
gint hour, minute;
|
||||||
|
|
||||||
gcal_date_selector_get_date (GCAL_DATE_SELECTOR (dialog->start_date_selector),
|
|
||||||
&day,
|
|
||||||
&month,
|
|
||||||
&year);
|
|
||||||
|
|
||||||
gcal_time_selector_get_time (GCAL_TIME_SELECTOR (dialog->start_time_selector),
|
gcal_time_selector_get_time (GCAL_TIME_SELECTOR (dialog->start_time_selector),
|
||||||
&hour,
|
&hour,
|
||||||
&minute);
|
&minute);
|
||||||
|
|
||||||
date = g_date_time_new_local (year, month, day, hour, minute, 0);
|
aux = gcal_date_selector_get_date (GCAL_DATE_SELECTOR (dialog->start_date_selector));
|
||||||
|
|
||||||
|
date = g_date_time_new (gcal_event_get_timezone (dialog->event),
|
||||||
|
g_date_time_get_year (aux),
|
||||||
|
g_date_time_get_month (aux),
|
||||||
|
g_date_time_get_day_of_month (aux),
|
||||||
|
hour, minute, 0);
|
||||||
|
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
@@ -785,20 +771,20 @@ gcal_edit_dialog_get_date_start (GcalEditDialog *dialog)
|
|||||||
GDateTime*
|
GDateTime*
|
||||||
gcal_edit_dialog_get_date_end (GcalEditDialog *dialog)
|
gcal_edit_dialog_get_date_end (GcalEditDialog *dialog)
|
||||||
{
|
{
|
||||||
GDateTime *date;
|
GDateTime *date, *aux;
|
||||||
gint year, month, day;
|
|
||||||
gint hour, minute;
|
gint hour, minute;
|
||||||
|
|
||||||
gcal_date_selector_get_date (GCAL_DATE_SELECTOR (dialog->end_date_selector),
|
|
||||||
&day,
|
|
||||||
&month,
|
|
||||||
&year);
|
|
||||||
|
|
||||||
gcal_time_selector_get_time (GCAL_TIME_SELECTOR (dialog->end_time_selector),
|
gcal_time_selector_get_time (GCAL_TIME_SELECTOR (dialog->end_time_selector),
|
||||||
&hour,
|
&hour,
|
||||||
&minute);
|
&minute);
|
||||||
|
|
||||||
date = g_date_time_new_local (year, month, day, hour, minute, 0);
|
aux = gcal_date_selector_get_date (GCAL_DATE_SELECTOR (dialog->end_date_selector));
|
||||||
|
|
||||||
|
date = g_date_time_new (gcal_event_get_timezone (dialog->event),
|
||||||
|
g_date_time_get_year (aux),
|
||||||
|
g_date_time_get_month (aux),
|
||||||
|
g_date_time_get_day_of_month (aux),
|
||||||
|
hour, minute, 0);
|
||||||
|
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user