Calendar now selects the appropriate date before displayed
This commit is contained in:
parent
a02a4b1614
commit
1fa1a10a10
@ -52,8 +52,8 @@
|
|||||||
<object class="GtkEntry" id="dateStart">
|
<object class="GtkEntry" id="dateStart">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="max_length">10</property>
|
||||||
<property name="width_chars">10</property>
|
<property name="width_chars">10</property>
|
||||||
<property name="text" translatable="yes">0000-00-00</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
@ -77,8 +77,8 @@
|
|||||||
<object class="GtkEntry" id="dateEnd">
|
<object class="GtkEntry" id="dateEnd">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="max_length">10</property>
|
||||||
<property name="width_chars">10</property>
|
<property name="width_chars">10</property>
|
||||||
<property name="text" translatable="yes">0000-00-00</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
|
@ -347,6 +347,12 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow_configure_treeView(mainWindow);
|
mainWindow_configure_treeView(mainWindow);
|
||||||
mainWindow_connect_signals(mainWindow);
|
mainWindow_connect_signals(mainWindow);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These need to be set to oldest and newest after indexing date
|
||||||
|
*/
|
||||||
|
gtk_entry_set_text(mainWindow->dateStart, "2016-01-01");
|
||||||
|
gtk_entry_set_text(mainWindow->dateEnd, "2017-01-01");
|
||||||
|
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +365,24 @@ void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer u
|
|||||||
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
||||||
|
GDateTime *datetime;
|
||||||
|
|
||||||
|
|
||||||
|
mainWindow->selectedDateEntry = NULL;
|
||||||
|
|
||||||
|
datetime = g_date_time_new_from_unix_local((widget == mainWindow->dateStart
|
||||||
|
? mainWindow->filterSettings.time_start
|
||||||
|
: mainWindow->filterSettings.time_end));
|
||||||
|
if (datetime) {
|
||||||
|
gtk_calendar_select_month(GTK_CALENDAR(mainWindow->calendarRange),
|
||||||
|
g_date_time_get_month(datetime) - 1,
|
||||||
|
g_date_time_get_year(datetime));
|
||||||
|
gtk_calendar_select_day(GTK_CALENDAR(mainWindow->calendarRange),
|
||||||
|
g_date_time_get_day_of_month(datetime));
|
||||||
|
g_date_time_unref(datetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* gtk_editable_select_region(GTK_EDITABLE(widget), 0, 255); */
|
||||||
mainWindow->selectedDateEntry = widget;
|
mainWindow->selectedDateEntry = widget;
|
||||||
|
|
||||||
if (!gtk_widget_get_visible(mainWindow->popoverDate))
|
if (!gtk_widget_get_visible(mainWindow->popoverDate))
|
||||||
@ -373,11 +396,13 @@ void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data)
|
|||||||
guint year, month, day;
|
guint year, month, day;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
|
if (mainWindow->selectedDateEntry) {
|
||||||
gtk_calendar_get_date(GTK_CALENDAR(mainWindow->calendarRange), &year, &month, &day);
|
gtk_calendar_get_date(GTK_CALENDAR(mainWindow->calendarRange), &year, &month, &day);
|
||||||
text = g_strdup_printf("%d-%02d-%02d", year, month, day);
|
text = g_strdup_printf("%d-%02d-%02d", year, month + 1, day);
|
||||||
gtk_entry_set_text(GTK_ENTRY(mainWindow->selectedDateEntry), text);
|
gtk_entry_set_text(GTK_ENTRY(mainWindow->selectedDateEntry), text);
|
||||||
g_free(text);
|
g_free(text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
|
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user