Added individual clear icons for the date entries

This commit is contained in:
Markus Koch 2017-02-04 20:38:29 +01:00
parent 5fdc302820
commit ae87f0cfa1
3 changed files with 37 additions and 11 deletions

View File

@ -132,6 +132,8 @@
<property name="can_focus">True</property>
<property name="max_length">10</property>
<property name="width_chars">10</property>
<property name="secondary_icon_stock">gtk-clear</property>
<property name="secondary_icon_tooltip_text" translatable="yes">fg</property>
</object>
<packing>
<property name="expand">True</property>
@ -157,6 +159,7 @@
<property name="can_focus">True</property>
<property name="max_length">10</property>
<property name="width_chars">10</property>
<property name="secondary_icon_stock">gtk-clear</property>
</object>
<packing>
<property name="expand">True</property>

View File

@ -236,6 +236,15 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"clicked",
(GCallback) mainWindow_clearSearch,
mainWindow);
g_signal_connect(mainWindow->dateStart,
"icon-press",
(GCallback) mainWindow_dateIconPress,
mainWindow);
g_signal_connect(mainWindow->dateEnd,
"icon-press",
(GCallback) mainWindow_dateIconPress,
mainWindow);
}
/**
@ -485,17 +494,30 @@ void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data)
GDateTime *datetime;
gchar *temp;
gtk_entry_set_text(GTK_ENTRY(mainWindow->searchEntry), "");
if (widget == mainWindow->buttonClearSearch)
widget = NULL;
datetime = g_date_time_new_from_unix_local(mainWindow->time_earliest);
temp = g_date_time_format(datetime, "%Y-%m-%d");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), temp);
g_date_time_unref(datetime);
g_free(temp);
if (!widget || widget == mainWindow->searchEntry)
gtk_entry_set_text(GTK_ENTRY(mainWindow->searchEntry), "");
datetime = g_date_time_new_from_unix_local(mainWindow->time_latest);
temp = g_date_time_format(datetime, "%Y-%m-%d");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), temp);
g_date_time_unref(datetime);
g_free(temp);
if (!widget || widget == mainWindow->dateStart) {
datetime = g_date_time_new_from_unix_local(mainWindow->time_earliest);
temp = g_date_time_format(datetime, "%Y-%m-%d");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), temp);
g_date_time_unref(datetime);
g_free(temp);
}
if (!widget || widget == mainWindow->dateEnd) {
datetime = g_date_time_new_from_unix_local(mainWindow->time_latest);
temp = g_date_time_format(datetime, "%Y-%m-%d");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), temp);
g_date_time_unref(datetime);
g_free(temp);
}
}
void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpointer user_data)
{
mainWindow_clearSearch(widget, user_data);
}

View File

@ -53,5 +53,6 @@ void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data);
void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpointer user_data);
#endif /* MAINWINDOW_H */