Added recent workspaces list

This commit is contained in:
Markus Koch 2017-02-05 15:31:04 +01:00
parent 5fd6f339d3
commit f8d3bb8730
3 changed files with 91 additions and 11 deletions

View File

@ -7,13 +7,19 @@
<property name="can_focus">False</property>
<property name="action">select-folder</property>
</object>
<object class="GtkPopover" id="chooseWorkspacePopover">
<object class="GtkTextBuffer" id="entryTextBuffer"/>
<object class="GtkPopover" id="popoverWorkspace">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">8</property>
<property name="margin_right">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkSearchEntry" id="searchWorkspace">
<property name="visible">True</property>
@ -29,9 +35,16 @@
</packing>
</child>
<child>
<object class="GtkListBox" id="listWorkspace">
<object class="GtkTreeView" id="treeWorkspace">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="hover_selection">True</property>
<property name="enable_grid_lines">horizontal</property>
<property name="activate_on_single_click">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeWorkspaceSelection"/>
</child>
</object>
<packing>
<property name="expand">True</property>
@ -55,7 +68,6 @@
</object>
</child>
</object>
<object class="GtkTextBuffer" id="entryTextBuffer"/>
<object class="GtkEntryCompletion" id="searchEntryCompletion"/>
<object class="GtkApplicationWindow" id="mainWindow">
<property name="width_request">720</property>
@ -394,7 +406,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popover">chooseWorkspacePopover</property>
<property name="popover">popoverWorkspace</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>

View File

@ -102,6 +102,45 @@ static gint mainWindow_sort_date_compare_func(GtkTreeModel *model,
return -1;
}
/**
* @brief mainWindow_wschooser_configure_treeView configures the GtkTreeView for workspace selection
* @param mainWindow
*/
static void mainWindow_configure_workspaceTreeView(struct mainWindow *mainWindow)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
mainWindow->workspaceListStore = gtk_list_store_new(1, G_TYPE_STRING);
/*
* TODO:
* gtk_tree_model_filter_set_visible_func(mainWindow->workspaceListStore,
* (GtkTreeModelFilterVisibleFunc) mainWindow_list_entry_visible,
* mainWindow, NULL);
*/
gtk_tree_view_set_model(mainWindow->workspaceListView, GTK_TREE_MODEL(mainWindow->workspaceListStore));
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(mainWindow->workspaceListView, -1, "", renderer,
"markup", 0, NULL);
/* Test entry for debugging */
GtkTreeIter iter;
gtk_list_store_append(mainWindow->workspaceListStore, &iter);
gtk_list_store_set(mainWindow->workspaceListStore, &iter,
0, "<b>testworkspace</b>\n\n<span weight=\"ultralight\">/home/user/Documents</span>",
-1);
gtk_list_store_append(mainWindow->workspaceListStore, &iter);
gtk_list_store_set(mainWindow->workspaceListStore, &iter,
0, "<b>testworkspace</b>\n\n<span weight=\"ultralight\">/home/user/Documents</span>",
-1);
}
/**
* @brief mainWindow_configure_treeView configures GtkTreeView
* @param mainWindow struct mainWindow *
@ -250,6 +289,10 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"clicked",
(GCallback) mainWindow_otherWorkspaceClicked,
mainWindow);
g_signal_connect(mainWindow->workspaceListView,
"row-activated",
(GCallback) mainWindow_workspaceListClicked,
mainWindow);
}
/**
@ -277,7 +320,6 @@ struct mainWindow *mainWindow_new()
mainWindow = malloc(sizeof(struct mainWindow));
mainWindow->mainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow"));
mainWindow->buttonOtherWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "buttonOtherWorkspace"));
mainWindow->searchEntry = GTK_WIDGET(gtk_builder_get_object(builder, "searchEntry"));
mainWindow->dateStart = GTK_WIDGET(gtk_builder_get_object(builder, "dateStart"));
mainWindow->dateEnd = GTK_WIDGET(gtk_builder_get_object(builder, "dateEnd"));
@ -294,6 +336,13 @@ struct mainWindow *mainWindow_new()
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
mainWindow->buttonOtherWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "buttonOtherWorkspace"));
mainWindow->searchWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "searchWorkspace"));
mainWindow->popoverWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "popoverWorkspace"));
mainWindow->workspaceListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeWorkspace"));
mainWindow->workspaceListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder,
"treeWorkspaceSelection"));
mainWindow->filterSettings.time_start = 0;
mainWindow->filterSettings.time_end = -1;
mainWindow->time_earliest = 0;
@ -305,9 +354,8 @@ struct mainWindow *mainWindow_new()
mainWindow_configure_treeView(mainWindow);
mainWindow_connect_signals(mainWindow);
mainWindow_configure_workspaceTreeView(mainWindow);
mainWindow_init_to_default(mainWindow);
mainWindow_clearSearch(NULL, mainWindow);
return mainWindow;
@ -335,8 +383,7 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_e
*/
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data)
{
printf("TODO: Show directory browser dialog.\n");
fflush(stdout);
g_print("TODO: Show directory browser dialog.\n");
}
/**
@ -536,3 +583,14 @@ void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpoi
{
mainWindow_clearSearch(widget, user_data);
}
void mainWindow_workspaceListClicked(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverWorkspace));
g_print("TODO: Workspace list clicked.\n");
}

View File

@ -8,7 +8,6 @@
struct mainWindow {
GtkWidget *mainWindow;
GtkWidget *buttonOtherWorkspace;
GtkWidget *searchEntry;
GtkWidget *dateStart;
GtkWidget *dateEnd;
@ -40,6 +39,13 @@ struct mainWindow {
gboolean search_summary;
gboolean search_text;
} filterSettings;
GtkWidget *buttonOtherWorkspace;
GtkWidget *searchWorkspace;
GtkWidget *popoverWorkspace;
GtkTreeView *workspaceListView;
GtkTreeSelection *workspaceListSelection;
GtkListStore *workspaceListStore;
};
struct mainWindow *mainWindow_new();
@ -48,6 +54,10 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_e
/* Slots */
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data);
void mainWindow_workspaceListClicked(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data);
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);