Skip to content

Commit 423a48c

Browse files
committed
feat: add entry editor indicators for tags, location, and images
- Implement visual indicators in the entry editor for tags, location, and image count. - Update CSS styles for indicator layout and appearance. - Enhance the EntryEditorView to manage and display these indicators dynamically.
1 parent 706f2b5 commit 423a48c

3 files changed

Lines changed: 111 additions & 1 deletion

File tree

data/style.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ window {
7474
border-radius: 999px;
7575
}
7676

77+
/* --- Entry Editor Indicators --- */
78+
.entry-indicators {
79+
background: var(--card-bg);
80+
border-radius: 8px;
81+
padding: 8px 12px;
82+
border: 1px solid var(--border-color);
83+
}
84+
85+
.indicator-label {
86+
font-size: 12px;
87+
color: var(--text-secondary);
88+
font-weight: 500;
89+
}
90+
91+
.indicator-label:not(:last-child) {
92+
margin-right: 16px;
93+
}
94+
7795
/* --- Sidebar --- */
7896
.sidebar {
7997
background: var(--sidebar-bg);

data/style_dark.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
background-image: linear-gradient(180deg, #5f7e8a, transparent);
3434
}
3535

36+
/* Entry Editor Indicators */
37+
.entry-indicators {
38+
background: var(--card-bg);
39+
border-radius: 8px;
40+
padding: 8px 12px;
41+
border: 1px solid var(--border-color);
42+
}
43+
44+
.indicator-label {
45+
font-size: 12px;
46+
color: var(--text-secondary);
47+
font-weight: 500;
48+
}
49+
50+
.indicator-label:not(:last-child) {
51+
margin-right: 16px;
52+
}
53+
3654
/* Sidebar */
3755
.sidebar {
3856
background: var(--sidebar-bg);

src/views/EntryEditorView.vala

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace Notejot {
2121

2222
private bool dirty = false;
2323

24+
// Indicator lines
25+
private Gtk.Box indicators_box;
26+
private Gtk.Label tags_indicator;
27+
private Gtk.Label location_indicator;
28+
private Gtk.Label images_indicator;
29+
2430
public EntryEditorView (DataManager data_manager) {
2531
Object (orientation : Gtk.Orientation.VERTICAL, spacing : 0);
2632
this.data_manager = data_manager;
@@ -60,6 +66,7 @@ namespace Notejot {
6066
}
6167
}
6268
reset_dirty ();
69+
update_indicators ();
6370
}
6471

6572
public void preselect_tag (string tag_uuid) {
@@ -141,6 +148,7 @@ namespace Notejot {
141148
}
142149
this.selected_tag_uuids = (owned) rebuilt;
143150
mark_dirty ();
151+
update_indicators ();
144152
}
145153
dlg.destroy ();
146154
});
@@ -163,6 +171,7 @@ namespace Notejot {
163171
}
164172
this.image_paths = (owned) rebuilt_i;
165173
mark_dirty ();
174+
update_indicators ();
166175
}
167176
dlg.destroy ();
168177
});
@@ -184,6 +193,7 @@ namespace Notejot {
184193
var ie = this.location_entry.get_internal_entry ();
185194
if (ie != null) ie.text = dlg.get_location_text ();
186195
mark_dirty ();
196+
update_indicators ();
187197
}
188198
dlg.destroy ();
189199
});
@@ -217,10 +227,30 @@ namespace Notejot {
217227
var editor_scroller = new Gtk.ScrolledWindow () { vexpand = true, hexpand = true };
218228
editor_scroller.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
219229
editor_scroller.set_child (content_view);
220-
// Main editor column: Title + Content
230+
// Main editor column: Indicators + Title + Content
221231
var editor_column = new Gtk.Box (Gtk.Orientation.VERTICAL, 8);
222232
editor_column.set_vexpand (true);
223233
editor_column.set_hexpand (true);
234+
235+
// Indicator lines
236+
indicators_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
237+
indicators_box.set_margin_bottom (8);
238+
indicators_box.add_css_class ("entry-indicators");
239+
240+
tags_indicator = new Gtk.Label ("") { halign = Gtk.Align.START };
241+
tags_indicator.add_css_class ("indicator-label");
242+
indicators_box.append (tags_indicator);
243+
244+
location_indicator = new Gtk.Label ("") { halign = Gtk.Align.START };
245+
location_indicator.add_css_class ("indicator-label");
246+
indicators_box.append (location_indicator);
247+
248+
images_indicator = new Gtk.Label ("") { halign = Gtk.Align.START };
249+
images_indicator.add_css_class ("indicator-label");
250+
indicators_box.append (images_indicator);
251+
252+
editor_column.append (indicators_box);
253+
224254
title_entry = new He.TextField () { placeholder_text = _("Entry Title"), hexpand = true, is_outline = true };
225255
editor_column.append (title_entry);
226256
editor_column.append (editor_scroller);
@@ -274,6 +304,50 @@ namespace Notejot {
274304
reset_dirty ();
275305
}
276306

307+
private void update_indicators () {
308+
// Update tags indicator
309+
if (selected_tag_uuids.length () > 0) {
310+
var tag_names = new GLib.List<string> ();
311+
foreach (var tag in data_manager.get_tags ()) {
312+
for (int i = 0; i < selected_tag_uuids.length (); i++) {
313+
if (selected_tag_uuids.nth_data (i) == tag.uuid) {
314+
tag_names.append (tag.name);
315+
break;
316+
}
317+
}
318+
}
319+
if (tag_names.length () > 0) {
320+
var names_str = "";
321+
for (int i = 0; i < tag_names.length (); i++) {
322+
if (i > 0) names_str += ", ";
323+
names_str += tag_names.nth_data (i);
324+
}
325+
tags_indicator.set_text (@"🏷️ $names_str");
326+
tags_indicator.set_visible (true);
327+
} else {
328+
tags_indicator.set_visible (false);
329+
}
330+
} else {
331+
tags_indicator.set_visible (false);
332+
}
333+
334+
// Update location indicator
335+
var location_text = location_entry.get_internal_entry ().text;
336+
if (location_text != null && location_text.strip () != "") {
337+
location_indicator.set_text (@"📍 $location_text");
338+
location_indicator.set_visible (true);
339+
} else {
340+
location_indicator.set_visible (false);
341+
}
342+
343+
// Update images indicator
344+
if (image_paths.length () > 0) {
345+
images_indicator.set_text (@"🖼️ $(image_paths.length ()) image(s)");
346+
images_indicator.set_visible (true);
347+
} else {
348+
images_indicator.set_visible (false);
349+
}
350+
}
277351

278352
private string get_content () {
279353
Gtk.TextIter start, end;

0 commit comments

Comments
 (0)