Compare commits

..

No commits in common. "57623e464e707ebbc3a8de506a2b03a7975091b2" and "a3c4b3164d4406cdd9d2add4d1441371841e6647" have entirely different histories.

3 changed files with 33 additions and 181 deletions

View File

@ -48,12 +48,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="checkSearchTitle">
<property name="label" translatable="yes">Title</property>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">search in: </property>
</object>
<packing>
<property name="expand">False</property>
@ -62,8 +60,8 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkSearchSummary">
<property name="label" translatable="yes">Summary</property>
<object class="GtkCheckButton" id="checkSearchTitle">
<property name="label" translatable="yes">Title</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -171,30 +169,6 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonClearSearch">
<property name="label" translatable="yes">View all</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">5</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
@ -234,80 +208,22 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">4</property>
<property name="margin_right">4</property>
<property name="margin_top">2</property>
<property name="margin_bottom">2</property>
<child>
<object class="GtkLabel" id="labelSummary">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Please select an entry in the list above.</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<attributes>
<attribute name="scale" value="1.3999999999999999"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<object class="GtkTextView" id="entryText">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="entryText">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="wrap_mode">word-char</property>
<property name="left_margin">4</property>
<property name="right_margin">4</property>
<property name="top_margin">4</property>
<property name="bottom_margin">4</property>
<property name="buffer">entryTextBuffer</property>
</object>
</child>
<property name="editable">False</property>
<property name="wrap_mode">word-char</property>
<property name="left_margin">4</property>
<property name="right_margin">4</property>
<property name="top_margin">4</property>
<property name="bottom_margin">4</property>
<property name="buffer">entryTextBuffer</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>

View File

@ -41,13 +41,6 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GtkTreeIter *
search_matched = 1;
g_free(temp);
gtk_tree_model_get(model, iter, COL_SUMMARY, &temp, -1);
if (!search_matched &&
mainWindow->filterSettings.search_summary &&
g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
search_matched = 1;
g_free(temp);
gtk_tree_model_get(model, iter, COL_TEXT, &temp, -1);
if (!search_matched &&
mainWindow->filterSettings.search_text &&
@ -225,27 +218,6 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"toggled",
(GCallback) mainWindow_filterChanged,
mainWindow);
g_signal_connect(mainWindow->checkSearchSummary,
"toggled",
(GCallback) mainWindow_filterChanged,
mainWindow);
g_signal_connect(mainWindow->buttonClearSearch,
"clicked",
(GCallback) mainWindow_clearSearch,
mainWindow);
}
/**
* @brief mainWindow_init_to_default initializes all non-date related UI elements to sensible values.
* @param mainWindow
*/
static void mainWindow_init_to_default(struct mainWindow *mainWindow)
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchText), 0);
}
/**
@ -269,11 +241,8 @@ struct mainWindow *mainWindow_new()
mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate"));
mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange"));
mainWindow->checkSearchTitle = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTitle"));
mainWindow->checkSearchSummary = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchSummary"));
mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags"));
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary"));
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
@ -288,9 +257,15 @@ struct mainWindow *mainWindow_new()
mainWindow_configure_treeView(mainWindow);
mainWindow_connect_signals(mainWindow);
mainWindow_init_to_default(mainWindow);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchText), 0);
mainWindow_clearSearch(NULL, mainWindow);
/**
* These need to be set to oldest and newest after indexing date
*/
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), "2016-01-01");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), "2018-01-01");
return mainWindow;
}
@ -370,27 +345,14 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *text;
gchar *title;
gchar *summary;
gchar *temp;
selection = gtk_tree_view_get_selection(mainWindow->entryListView);
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_tree_model_get(model, &iter, COL_TEXT, &text, -1);
gtk_text_buffer_set_text(mainWindow->textBuffer, text, g_utf8_strlen(text, -1));
g_free(text);
gtk_tree_model_get(model, &iter, COL_SUMMARY, &summary, -1);
gtk_tree_model_get(model, &iter, COL_TITLE, &title, -1);
temp = g_strdup_printf("<b>%s</b>: %s", title, summary);
gtk_label_set_markup(GTK_LABEL(mainWindow->labelSummary), temp);
g_free(title);
g_free(summary);
gtk_tree_model_get(model, &iter, COL_TEXT, &temp, -1);
gtk_text_buffer_set_text(mainWindow->textBuffer, temp, g_utf8_strlen(temp, -1));
fflush(stdout);
g_free(temp);
} else {
gtk_text_buffer_set_text(mainWindow->textBuffer, "", 0);
gtk_label_set_text(GTK_LABEL(mainWindow->labelSummary), "Please select an entry in the list above.");
}
}
@ -421,14 +383,12 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
}
}
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle));
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags));
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(mainWindow->checkSearchText));
mainWindow->filterSettings.search_summary = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary));
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
mainWindow->checkSearchTitle));
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
mainWindow->checkSearchTags));
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
mainWindow->checkSearchText));
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
}
@ -454,22 +414,3 @@ void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data)
}
g_date_time_unref(datetime);
}
/**
* @brief mainWindow_clearSearch resets all search UI elements
* @param widget
* @param event
* @param user_data
*/
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
gtk_entry_set_text(GTK_ENTRY(mainWindow->searchEntry), "");
/**
* These need to be set to oldest and newest after indexing date
*/
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), "2016-01-01");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), "2018-01-01");
}

View File

@ -15,11 +15,8 @@ struct mainWindow {
GtkWidget *popoverDate;
GtkWidget *calendarRange;
GtkWidget *checkSearchTitle;
GtkWidget *checkSearchSummary;
GtkWidget *checkSearchTags;
GtkWidget *checkSearchText;
GtkWidget *labelSummary;
GtkWidget *buttonClearSearch;
GtkTreeView *entryListView;
GtkTreeSelection *entryListSelection;
GtkTextBuffer *textBuffer;
@ -33,7 +30,6 @@ struct mainWindow {
guint time_end;
gboolean search_title;
gboolean search_tags;
gboolean search_summary;
gboolean search_text;
} filterSettings;
};
@ -43,7 +39,6 @@ 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_clearSearch(GtkWidget *widget, gpointer user_data);
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);