Browse Source

Added View all button

newfile
Markus Koch 5 years ago
parent
commit
57623e464e
  1. 24
      glade/mainWindow.glade
  2. 50
      src/mainwindow.c
  3. 2
      src/mainwindow.h

24
glade/mainWindow.glade

@ -171,6 +171,30 @@
<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>

50
src/mainwindow.c

@ -229,6 +229,23 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"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);
}
/**
@ -256,6 +273,7 @@ struct mainWindow *mainWindow_new()
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"));
@ -270,16 +288,9 @@ struct mainWindow *mainWindow_new()
mainWindow_configure_treeView(mainWindow);
mainWindow_connect_signals(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);
mainWindow_init_to_default(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");
mainWindow_clearSearch(NULL, mainWindow);
return mainWindow;
}
@ -379,7 +390,7 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
g_free(temp);
} else {
gtk_text_buffer_set_text(mainWindow->textBuffer, "", 0);
gtk_label_set_text(GTK_LABEL(mainWindow->labelSummary), "");
gtk_label_set_text(GTK_LABEL(mainWindow->labelSummary), "Please select an entry in the list above.");
}
}
@ -443,3 +454,22 @@ 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");
}

2
src/mainwindow.h

@ -19,6 +19,7 @@ struct mainWindow {
GtkWidget *checkSearchTags;
GtkWidget *checkSearchText;
GtkWidget *labelSummary;
GtkWidget *buttonClearSearch;
GtkTreeView *entryListView;
GtkTreeSelection *entryListSelection;
GtkTextBuffer *textBuffer;
@ -42,6 +43,7 @@ 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);

Loading…
Cancel
Save