Added Title/Summary header

This commit is contained in:
Markus Koch 2017-02-04 18:31:05 +01:00
parent a3c4b3164d
commit d42a0ffc2e
3 changed files with 87 additions and 14 deletions

View File

@ -208,22 +208,80 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="shadow_type">in</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkTextView" id="entryText"> <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">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="editable">False</property> <property name="shadow_type">in</property>
<property name="wrap_mode">word-char</property> <child>
<property name="left_margin">4</property> <object class="GtkTextView" id="entryText">
<property name="right_margin">4</property> <property name="visible">True</property>
<property name="top_margin">4</property> <property name="can_focus">True</property>
<property name="bottom_margin">4</property> <property name="editable">False</property>
<property name="buffer">entryTextBuffer</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>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>

View File

@ -243,6 +243,7 @@ struct mainWindow *mainWindow_new()
mainWindow->checkSearchTitle = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTitle")); mainWindow->checkSearchTitle = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTitle"));
mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags")); mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags"));
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText")); mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary"));
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView")); mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection")); mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer")); mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
@ -345,14 +346,27 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
gchar *text;
gchar *title;
gchar *summary;
gchar *temp; gchar *temp;
selection = gtk_tree_view_get_selection(mainWindow->entryListView); selection = gtk_tree_view_get_selection(mainWindow->entryListView);
if (gtk_tree_selection_get_selected(selection, &model, &iter)) { if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_tree_model_get(model, &iter, COL_TEXT, &temp, -1); gtk_tree_model_get(model, &iter, COL_TEXT, &text, -1);
gtk_text_buffer_set_text(mainWindow->textBuffer, temp, g_utf8_strlen(temp, -1)); gtk_text_buffer_set_text(mainWindow->textBuffer, text, g_utf8_strlen(text, -1));
fflush(stdout); 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);
g_free(temp); g_free(temp);
} else {
gtk_text_buffer_set_text(mainWindow->textBuffer, "", 0);
gtk_label_set_text(GTK_LABEL(mainWindow->labelSummary), "");
} }
} }

View File

@ -17,6 +17,7 @@ struct mainWindow {
GtkWidget *checkSearchTitle; GtkWidget *checkSearchTitle;
GtkWidget *checkSearchTags; GtkWidget *checkSearchTags;
GtkWidget *checkSearchText; GtkWidget *checkSearchText;
GtkWidget *labelSummary;
GtkTreeView *entryListView; GtkTreeView *entryListView;
GtkTreeSelection *entryListSelection; GtkTreeSelection *entryListSelection;
GtkTextBuffer *textBuffer; GtkTextBuffer *textBuffer;