Added popover dialog for dat entry using calendar
This commit is contained in:
parent
ae843c384d
commit
37afe16a7a
@ -64,8 +64,8 @@
|
||||
<object class="GtkEntry" id="dateStart">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="width_chars">9</property>
|
||||
<property name="text" translatable="yes">00.00.0000</property>
|
||||
<property name="width_chars">10</property>
|
||||
<property name="text" translatable="yes">0000-00-00</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
@ -89,8 +89,8 @@
|
||||
<object class="GtkEntry" id="dateEnd">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="width_chars">9</property>
|
||||
<property name="text" translatable="yes">00.00.0000</property>
|
||||
<property name="width_chars">10</property>
|
||||
<property name="text" translatable="yes">0000-00-00</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
@ -185,6 +185,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="mainWindow_chooseWorkspaceClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -197,4 +198,17 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="popoverDate">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="relative_to">dateStart</property>
|
||||
<child>
|
||||
<object class="GtkCalendar" id="calendarRange">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="year">2017</property>
|
||||
<property name="month">1</property>
|
||||
<property name="day">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -63,6 +63,20 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
|
||||
COL_TAGS, "F",
|
||||
COL_TIMESTAMP, 11,
|
||||
-1);
|
||||
|
||||
/* debug 2 code here */
|
||||
g_signal_connect(mainWindow->dateStart,
|
||||
"focus-in-event",
|
||||
mainWindow_showPopover,
|
||||
mainWindow);
|
||||
g_signal_connect(mainWindow->dateEnd,
|
||||
"focus-in-event",
|
||||
mainWindow_showPopover,
|
||||
mainWindow);
|
||||
g_signal_connect(mainWindow->calendarRange,
|
||||
"day-selected",
|
||||
mainWindow_calendarSelected,
|
||||
mainWindow);
|
||||
}
|
||||
|
||||
struct mainWindow *mainWindow_new()
|
||||
@ -79,6 +93,8 @@ struct mainWindow *mainWindow_new()
|
||||
mainWindow->dateStart = GTK_WIDGET(gtk_builder_get_object(builder, "dateStart"));
|
||||
mainWindow->dateEnd = GTK_WIDGET(gtk_builder_get_object(builder, "dateEnd"));
|
||||
mainWindow->entryText = GTK_WIDGET(gtk_builder_get_object(builder, "entryText"));
|
||||
mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate"));
|
||||
mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange"));
|
||||
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
||||
mainWindow->entryListStore = GTK_LIST_STORE(gtk_builder_get_object(builder, "entryListStore"));
|
||||
|
||||
@ -90,3 +106,34 @@ struct mainWindow *mainWindow_new()
|
||||
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data)
|
||||
{
|
||||
printf("Choose workspace.\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
||||
{
|
||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
||||
|
||||
mainWindow->selectedDateEntry = widget;
|
||||
|
||||
if (!gtk_widget_get_visible(mainWindow->popoverDate))
|
||||
gtk_popover_popup(GTK_POPOVER(mainWindow->popoverDate));
|
||||
gtk_popover_set_relative_to(GTK_POPOVER(mainWindow->popoverDate), widget);
|
||||
}
|
||||
|
||||
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
||||
guint year, month, day;
|
||||
gchar *text;
|
||||
|
||||
gtk_calendar_get_date(GTK_CALENDAR(mainWindow->calendarRange), &year, &month, &day);
|
||||
text = g_strdup_printf("%d-%02d-%02d", year, month, day);
|
||||
gtk_entry_set_text(GTK_ENTRY(mainWindow->selectedDateEntry), text);
|
||||
g_free(text);
|
||||
|
||||
gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverDate));
|
||||
}
|
||||
|
@ -11,10 +11,19 @@ struct mainWindow {
|
||||
GtkWidget *dateStart;
|
||||
GtkWidget *dateEnd;
|
||||
GtkWidget *entryText;
|
||||
GtkWidget *popoverDate;
|
||||
GtkWidget *calendarRange;
|
||||
GtkTreeView *entryListView;
|
||||
GtkListStore *entryListStore;
|
||||
|
||||
GtkWidget *selectedDateEntry;
|
||||
};
|
||||
|
||||
struct mainWindow *mainWindow_new();
|
||||
|
||||
/* Slots */
|
||||
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
||||
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data);
|
||||
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
||||
|
||||
#endif /* MAINWINDOW_H */
|
||||
|
Loading…
Reference in New Issue
Block a user