Compare commits

..

2 Commits

Author SHA1 Message Date
3ef29f1b98 wip 2021-05-16 17:56:58 +02:00
94bd96fb66 Rewrite Glade-file with newer revision 2021-05-16 17:01:37 +02:00
5 changed files with 385 additions and 236 deletions

View File

@ -1,32 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkTextBuffer" id="entryTextBuffer"/>
<object class="GtkImage" id="imageDecrypt">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">changes-prevent-symbolic.symbolic</property>
<property name="can-focus">False</property>
<property name="icon-name">changes-prevent-symbolic.symbolic</property>
</object>
<object class="GtkImage" id="imageUpdateGpg">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">edit-copy</property>
</object>
<object class="GtkPopover" id="popoverWorkspace">
<property name="can_focus">False</property>
<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="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>
<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>
@ -37,16 +42,16 @@
<child>
<object class="GtkTreeView" id="treeWorkspace">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscroll_policy">natural</property>
<property name="vscroll_policy">natural</property>
<property name="headers_visible">False</property>
<property name="enable_search">False</property>
<property name="fixed_height_mode">True</property>
<property name="hover_selection">True</property>
<property name="show_expanders">False</property>
<property name="enable_grid_lines">horizontal</property>
<property name="activate_on_single_click">True</property>
<property name="can-focus">True</property>
<property name="hscroll-policy">natural</property>
<property name="vscroll-policy">natural</property>
<property name="headers-visible">False</property>
<property name="enable-search">False</property>
<property name="fixed-height-mode">True</property>
<property name="hover-selection">True</property>
<property name="show-expanders">False</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>
@ -61,8 +66,8 @@
<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>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -75,122 +80,35 @@
</object>
<object class="GtkEntryCompletion" id="searchEntryCompletion"/>
<object class="GtkApplicationWindow" id="mainWindow">
<property name="width_request">720</property>
<property name="height_request">405</property>
<property name="can_focus">False</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">MDiary</property>
<property name="subtitle">No workspace opened.</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<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>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonNew">
<property name="label" translatable="yes">New Entry</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">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonDecrypt">
<property name="label" translatable="yes">Decrypt GPG</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">imageDecrypt</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<property name="width-request">720</property>
<property name="height-request">405</property>
<property name="can-focus">False</property>
<child>
<object class="GtkPaned" id="mainPane">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">2</property>
<property name="margin_right">2</property>
<property name="margin_top">2</property>
<property name="margin_bottom">2</property>
<property name="wide_handle">True</property>
<property name="can-focus">True</property>
<property name="margin-left">2</property>
<property name="margin-right">2</property>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkBox" id="leftPaneBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">2</property>
<property name="margin_right">2</property>
<property name="margin_top">2</property>
<property name="margin_bottom">2</property>
<property name="can-focus">False</property>
<property name="margin-left">2</property>
<property name="margin-right">2</property>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkSearchEntry" id="searchEntry">
<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>
<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>
<property name="completion">searchEntryCompletion</property>
</object>
<packing>
@ -202,14 +120,14 @@
<child>
<object class="GtkBox" id="searchInBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<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>
<property name="draw_indicator">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -221,9 +139,9 @@
<object class="GtkCheckButton" id="checkSearchSummary">
<property name="label" translatable="yes">Summary</property>
<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">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -235,9 +153,9 @@
<object class="GtkCheckButton" id="checkSearchTags">
<property name="label" translatable="yes">Tags</property>
<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">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -249,9 +167,9 @@
<object class="GtkCheckButton" id="checkSearchText">
<property name="label" translatable="yes">Text</property>
<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">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -269,7 +187,7 @@
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
@ -280,15 +198,15 @@
<child>
<object class="GtkBox" id="boxDateEntry">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="spacing">4</property>
<child>
<object class="GtkEntry" id="dateStart">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">10</property>
<property name="width_chars">10</property>
<property name="secondary_icon_tooltip_text" translatable="yes">fg</property>
<property name="can-focus">True</property>
<property name="max-length">10</property>
<property name="width-chars">10</property>
<property name="secondary-icon-tooltip-text" translatable="yes">fg</property>
</object>
<packing>
<property name="expand">True</property>
@ -299,9 +217,9 @@
<child>
<object class="GtkLabel" id="label_date_to_date">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;a href=""&gt;to&lt;/a&gt;</property>
<property name="use_markup">True</property>
<property name="use-markup">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -312,9 +230,9 @@
<child>
<object class="GtkEntry" id="dateEnd">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">10</property>
<property name="width_chars">10</property>
<property name="can-focus">True</property>
<property name="max-length">10</property>
<property name="width-chars">10</property>
</object>
<packing>
<property name="expand">True</property>
@ -332,7 +250,7 @@
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
@ -344,8 +262,8 @@
<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>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -362,24 +280,24 @@
<child>
<object class="GtkPaned" id="rightPane">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">2</property>
<property name="margin_right">2</property>
<property name="margin_top">2</property>
<property name="margin_bottom">2</property>
<property name="can-focus">True</property>
<property name="margin-left">2</property>
<property name="margin-right">2</property>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
<property name="orientation">vertical</property>
<property name="wide_handle">True</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<property name="propagate_natural_height">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkTreeView" id="entryListView">
<property name="height_request">300</property>
<property name="height-request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can-focus">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="entryListSelection"/>
</child>
@ -394,24 +312,24 @@
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</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>
<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="GtkEventBox" id="summaryEventBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel" id="labelSummary">
<property name="visible">True</property>
<property name="can_focus">False</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>
<attributes>
@ -439,7 +357,7 @@
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
@ -450,22 +368,22 @@
<child>
<object class="GtkStack" id="stackRenderMode">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkScrolledWindow" id="entryTextScrollArea">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</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="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="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>
@ -496,14 +414,118 @@
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="title">MDiary</property>
<property name="subtitle">No workspace opened.</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<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>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonDecrypt">
<property name="label" translatable="yes">Decrypt GPG</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">imageDecrypt</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonNew">
<property name="label" translatable="yes">New Entry</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">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonUpdateGpg">
<property name="label" translatable="yes">Update GPG</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">imageUpdateGpg</property>
<property name="always-show-image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="popoverDate">
<property name="can_focus">False</property>
<property name="relative_to">dateStart</property>
<property name="can-focus">False</property>
<property name="relative-to">dateStart</property>
<child>
<object class="GtkCalendar" id="calendarRange">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can-focus">True</property>
<property name="year">2017</property>
<property name="month">1</property>
<property name="day">1</property>
@ -511,84 +533,72 @@
</child>
</object>
<object class="GtkWindow" id="settingsDialog">
<property name="can_focus">False</property>
<property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Preferences</property>
<property name="has_subtitle">False</property>
<property name="show_close_button">True</property>
<property name="decoration_layout">close:</property>
<child>
<placeholder/>
</child>
</object>
</child>
<property name="can-focus">False</property>
<property name="window-position">center</property>
<property name="destroy-with-parent">True</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">4</property>
<property name="margin_bottom">4</property>
<property name="can-focus">False</property>
<property name="margin-left">4</property>
<property name="margin-right">4</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">4</property>
<property name="column_spacing">4</property>
<property name="can-focus">False</property>
<property name="row-spacing">4</property>
<property name="column-spacing">4</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Entry display mode:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="comboDisplayMode">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">New entry date format:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkStack" id="stackNewDateFormat">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkComboBoxText" id="comboNewDateFormat">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="name">page0</property>
@ -598,7 +608,7 @@
<child>
<object class="GtkEntry" id="entryNewDateFormat">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="name">page1</property>
@ -617,9 +627,9 @@
<object class="GtkButton" id="buttonCustomNewFileDateFormat">
<property name="label" translatable="yes">...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Use custom format</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Use custom format</property>
</object>
<packing>
<property name="expand">False</property>
@ -629,10 +639,25 @@
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -644,8 +669,8 @@
<object class="GtkButton" id="buttonOpenWorkspaceFolder">
<property name="label" translatable="yes">Open Workspace in File Browser</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -655,5 +680,18 @@
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="title">Preferences</property>
<property name="has-subtitle">False</property>
<property name="show-close-button">True</property>
<property name="decoration-layout">close:</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>

View File

@ -250,6 +250,8 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
G_TYPE_POINTER,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
mainWindow->entryListFiltered = GTK_TREE_MODEL_FILTER(gtk_tree_model_filter_new(
GTK_TREE_MODEL(mainWindow->entryListStore),
@ -425,6 +427,10 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"clicked",
(GCallback) mainWindow_decrypt_gpg_clicked,
mainWindow);
g_signal_connect(mainWindow->buttonUpdateGpg,
"clicked",
(GCallback) mainWindow_update_gpg_clicked,
mainWindow);
g_signal_connect(mainWindow->summaryEventBox,
"button-press-event",
@ -655,6 +661,7 @@ struct mainWindow *mainWindow_new()
mainWindow->labelDateToDate = GTK_WIDGET(gtk_builder_get_object(builder, "label_date_to_date"));
mainWindow->buttonNew = GTK_WIDGET(gtk_builder_get_object(builder, "buttonNew"));
mainWindow->buttonDecrypt = GTK_WIDGET(gtk_builder_get_object(builder, "buttonDecrypt"));
mainWindow->buttonUpdateGpg = GTK_WIDGET(gtk_builder_get_object(builder, "buttonUpdateGpg"));
mainWindow->stackRenderMode = GTK_WIDGET(gtk_builder_get_object(builder, "stackRenderMode"));
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
@ -854,6 +861,23 @@ static void mainWindow_set_text(struct mainWindow *mainWindow, gchar *text, gcha
}
}
/**
* @brief mainWindow_getTempFile returns the path to the temporary file (may not exist) for the entry generated from its UUID
* @param uuid the UUID
* @return the full path th
*/
gchar *mainWindow_getTempFile(gchar *uuid)
{
GString *tempfile = NULL;
gchar *str = NULL;
tempfile = g_string_new("");
g_string_printf(tempfile, "/tmp/%s.mdiary", uuid);
str = tempfile->str;
g_string_free(tempfile, false);
return str;
}
/**
* @brief mainWindow_entrySelected is the callback when the user selects a diary entry.
* @param widget N/A
@ -870,6 +894,7 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
gchar *title;
gchar *summary;
gchar *temp;
gchar *tempfile;
selection = gtk_tree_view_get_selection(mainWindow->entryListView);
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
@ -887,6 +912,14 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
g_free(title);
g_free(summary);
g_free(temp);
/* Check for GPG update */
gtk_tree_model_get(model, &iter, COL_UUID, &temp, -1);
tempfile = mainWindow_getTempFile(temp);
gtk_widget_set_visible(mainWindow->buttonUpdateGpg,
(g_file_test(tempfile, G_FILE_TEST_EXISTS)));
g_free(tempfile);
g_free(temp);
} else {
mainWindow_set_text(mainWindow, "", "");
gtk_label_set_text(GTK_LABEL(mainWindow->labelSummary), "Please select an entry in the list above.");
@ -904,7 +937,7 @@ void mainWindow_openExternalEditor(gchar *path)
GAppInfo *info;
GList *files = NULL;
g_info("Opening entry in external editor.");
g_warning("Opening entry %s in external editor.", path);
file = g_file_new_for_path(path);
info = g_file_query_default_handler(file, NULL, NULL);
files = g_list_append(files, (gpointer) file);
@ -926,12 +959,54 @@ void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeView
GtkTreeIter iter;
GtkTreeView *treeview = (GtkTreeView*) widget;
gchar *name;
gchar *ext;
gchar *tempfile;
gchar *uuid;
gchar *content;
FILE *fd;
model = gtk_tree_view_get_model(treeview);
if (gtk_tree_model_get_iter(model, &iter, path)) {
gtk_tree_model_get(model, &iter, COL_URL, &name, -1);
mainWindow_openExternalEditor(name);
if (!name)
return;
ext = strrchr(name, '.');
if (!strcmp(ext, ".gpg")) { /* Encrypted file -> Create decrypted copy in /tmp */
gtk_tree_model_get(model, &iter, COL_UUID, &uuid, -1);
if (uuid) {
tempfile = mainWindow_getTempFile(uuid);
fd = fopen(tempfile, "r");
if (false) {
g_warning("Decryption target already exists. Leaving as is and opening.");
fclose(fd);
} else {
fd = fopen(tempfile, "w");
if (fd) {
gtk_tree_model_get(model, &iter, COL_HEADER, &content, -1);
fputs(content, fd);
fputs("\n", fd);
g_free(content);
gtk_tree_model_get(model, &iter, COL_TEXT, &content, -1);
fputs(content, fd);
g_free(content);
fclose(fd);
} else {
g_error("Could not open decryption target.");
}
}
mainWindow_openExternalEditor(tempfile);
g_free(tempfile);
g_free(uuid);
}
} else { /* Regular file -> Open directly */
mainWindow_openExternalEditor(name);
}
g_free(name);
}
}
@ -1283,6 +1358,17 @@ void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data)
}
}
void mainWindow_update_gpg_clicked(GtkWidget *widget, gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
gtk_widget_set_visible(mainWindow->buttonUpdateGpg, false);
g_print("Not yet implemented.");
// Delete <old name>.bak if exists
// Move existing GPG to <old name>.bak
// encrypt tmp/uuid file to <old name>
}
/**
* @brief mainWindow_toggleSummaryWrap toggles line-wrapping and ellipsize on the summary
* @param widget

View File

@ -47,6 +47,7 @@ struct mainWindow {
GtkWidget *labelDateToDate;
GtkWidget *buttonNew;
GtkWidget *buttonDecrypt;
GtkWidget *buttonUpdateGpg;
GtkWidget *webkitView;
GtkWidget *webkitScrollArea;
GtkWidget *stackRenderMode;
@ -122,6 +123,7 @@ void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path,
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gboolean gpg_enabled);
void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data);
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data);
void mainWindow_update_gpg_clicked(GtkWidget *widget, gpointer user_data);
void mainWindow_renderer_set(struct mainWindow *mainWindow, enum renderer_mode state);
void mainWindow_settings_show(struct mainWindow *mainWindow);
gboolean mainWindow_toggleSummaryWrap(GtkWidget *widget, GdkEvent *event, gpointer user_data);

View File

@ -261,6 +261,7 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
GList *tagList = NULL;
gchar *summary = NULL;
GString *text = NULL;
GString *header = NULL;
guint header_state = 0;
GList *l;
@ -284,6 +285,13 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
while (line = (content ? mdiary_get_line_from_string(&content_ptr) :
g_data_input_stream_read_line(G_DATA_INPUT_STREAM(dstream), NULL, NULL, NULL))) {
if (header_state == 0) {
if (header) {
header = g_string_append(header, "\n");
header = g_string_append(header, line);
} else {
header = g_string_new(line);
}
if (!datetime) {
datetime = mdiary_get_date_from_string_ext(line, "Date: ", "");
if (datetime)
@ -331,6 +339,10 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
g_warning("PARSER: Could not find any text in file!\n");
text = g_string_new("No content found.");
}
if (!header) {
g_warning("PARSER: Could not find any header in file!\n");
text = g_string_new("No header found.");
}
if (!summary) {
g_warning("PARSER: Could not detect summary in file!\n");
summary = g_strdup("No summary found.");
@ -354,6 +366,7 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
tagList,
summary,
text->str,
header->str,
filename);
if (g_date_time_to_unix(datetime) > mdiary_scanner->time_latest)
@ -368,7 +381,8 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
}
g_list_free_full(tagList, *g_free);
g_string_free(text, 0);
g_string_free(text, 1);
g_string_free(header, 1);
g_free(summary);
g_free(title);
g_date_time_unref(datetime);
@ -578,6 +592,7 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
GList *tags,
gchar *summary,
gchar *text,
gchar *header,
gchar *file_url)
{
GtkTreeIter iter;
@ -585,6 +600,7 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
GList *taglist_copy;
gchar *date_text;
gchar *taglistString;
gchar *uuid;
GList *l;
struct tag_compare_struct tag_compare_struct = { .text = "", .result = FALSE };
@ -593,6 +609,7 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
date_text = g_date_time_format(datetime_copy, "%A, %e %B %Y %R");
taglist_copy = g_list_copy_deep(tags, (GCopyFunc) g_strdup, NULL);
taglistString = mdiary_taglist_to_string(taglist_copy);
uuid = g_compute_checksum_for_data(G_CHECKSUM_SHA256, (guchar *) file_url, strlen(file_url));
gtk_list_store_append(entryListStore, &iter);
gtk_list_store_set(entryListStore, &iter,
@ -603,9 +620,12 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
COL_TAGLIST, taglist_copy, /* TODO: Verify that the duplication worked! */
COL_SUMMARY, summary, /* Automatically strdupd */
COL_TEXT, text, /* Automatically strdupd */
COL_HEADER, header, /* Automatically strdupd */
COL_URL, file_url, /* Automatically strdupd */
COL_UUID, uuid, /* Automatically strdupd */
-1);
g_free(date_text);
g_free(uuid);
for (l = tags; l != NULL; l = l->next) {
tag_compare_struct.text = l->data;

View File

@ -16,7 +16,9 @@ enum {
COL_TAGLIST, /* GList<gchar *> of the tags */
COL_SUMMARY, /* Summary of the entry */
COL_TEXT, /* Raw text from the file */
COL_HEADER, /* Raw header from the file */
COL_URL, /* Path to the file */
COL_UUID, /* UUID of the file */
COL_COUNT
};
@ -42,6 +44,7 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
GList *tags,
gchar *summary,
gchar *text,
gchar *header,
gchar *file_url);
GDateTime *mdiary_get_date_from_string_ext(gchar *string, gchar *prefix, gchar *suffix);
GDateTime *mdiary_get_date_from_string(gchar *string);