Compare commits

..

4 Commits

Author SHA1 Message Date
f8d3bb8730 Added recent workspaces list 2017-02-05 15:31:04 +01:00
5fd6f339d3 Fixed memory leak 2017-02-05 15:02:18 +01:00
2b81a67087 Improved icons 2017-02-05 14:47:45 +01:00
538b2c54d9 Added choose Workspace menu 2017-02-05 14:31:17 +01:00
4 changed files with 191 additions and 15 deletions

View File

@ -2,7 +2,72 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkFileChooserWidget" id="chooseDirectoryDialog">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="action">select-folder</property>
</object>
<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>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTreeView" id="treeWorkspace">
<property name="visible">True</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>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonOtherWorkspace">
<property name="label" translatable="yes">Other Workspaces ...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkEntryCompletion" id="searchEntryCompletion"/>
<object class="GtkApplicationWindow" id="mainWindow">
<property name="width_request">720</property>
@ -132,7 +197,6 @@
<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>
@ -159,7 +223,6 @@
<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>
@ -339,12 +402,42 @@
<property name="can_focus">False</property>
<property name="spacing">4</property>
<child>
<object class="GtkButton" id="buttonChooseWorkspace">
<property name="label" translatable="yes">Choose workspace</property>
<object class="GtkMenuButton">
<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"/>
<property name="popover">popoverWorkspace</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Choose Workspace</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">pan-down-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</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 *
@ -245,6 +284,15 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"icon-press",
(GCallback) mainWindow_dateIconPress,
mainWindow);
g_signal_connect(mainWindow->buttonOtherWorkspace,
"clicked",
(GCallback) mainWindow_otherWorkspaceClicked,
mainWindow);
g_signal_connect(mainWindow->workspaceListView,
"row-activated",
(GCallback) mainWindow_workspaceListClicked,
mainWindow);
}
/**
@ -272,7 +320,6 @@ struct mainWindow *mainWindow_new()
mainWindow = malloc(sizeof(struct mainWindow));
mainWindow->mainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow"));
mainWindow->buttonChooseWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "buttonChooseWorkspace"));
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"));
@ -289,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;
@ -300,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;
@ -323,15 +376,14 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_e
}
/**
* @brief mainWindow_chooseWorkspaceClicked is called when the user clicks the Choose Workspace button.
* @brief mainWindow_otherWorkspaceClicked is called when the user clicks the Other Workspace button.
* @param widget N/A
* @param event N/A
* @param user_data struct mainWindow *
*/
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data)
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data)
{
printf("Choose workspace.\n");
fflush(stdout);
g_print("TODO: Show directory browser dialog.\n");
}
/**
@ -438,6 +490,9 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
mainWindow->filterSettings.time_start = g_date_time_to_unix(datetime);
g_date_time_unref(datetime);
}
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget ? widget : mainWindow->dateStart),
GTK_ENTRY_ICON_SECONDARY, "edit-clear-symbolic");
}
if (!widget || widget == mainWindow->dateEnd) {
datetime = mdiary_get_date_from_string((gchar *)gtk_entry_get_text(
@ -446,6 +501,9 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
mainWindow->filterSettings.time_end = g_date_time_to_unix(datetime);
g_date_time_unref(datetime);
}
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget ? widget : mainWindow->dateStart),
GTK_ENTRY_ICON_SECONDARY, "edit-clear-symbolic");
}
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
@ -506,6 +564,8 @@ void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data)
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), temp);
g_date_time_unref(datetime);
g_free(temp);
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget ? widget : mainWindow->dateStart),
GTK_ENTRY_ICON_SECONDARY, "");
}
if (!widget || widget == mainWindow->dateEnd) {
@ -514,6 +574,8 @@ void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data)
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), temp);
g_date_time_unref(datetime);
g_free(temp);
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget ? widget : mainWindow->dateEnd),
GTK_ENTRY_ICON_SECONDARY, "");
}
}
@ -521,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 *buttonChooseWorkspace;
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();
@ -47,7 +53,11 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_e
/* Slots */
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint 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);

View File

@ -436,7 +436,7 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
gtk_list_store_append(entryListStore, &iter);
gtk_list_store_set(entryListStore, &iter,
COL_TITLE, g_strdup(title),
COL_TITLE, title,
COL_DATE_TEXT, date_text,
COL_TAGS_TEXT, taglistString,
COL_TIMESTAMP, datetime_copy,