Skip to content

Commit 7cb06d8

Browse files
committed
Make AddTagDialog modal and improve tag editing flow
1 parent acb8eb8 commit 7cb06d8

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/dialogs/AddTagDialog.vala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace Notejot {
4343
public AddTagDialog(Gtk.Window parent, bool editing = false) {
4444
Object(
4545
parent : parent,
46+
modal: true,
4647
default_width: 440,
4748
resizable: false
4849
);

src/views/Sidebar.vala

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,38 @@ namespace Notejot {
198198
this.refresh_tags ();
199199
});
200200
row.edit_requested.connect ((uuid) => {
201-
edit_tag_requested (uuid);
201+
// Find the tag by uuid
202+
Tag? found = null;
203+
foreach (var t in this.data_manager.get_tags ()) {
204+
if (t.uuid == uuid) { found = t; break; }
205+
}
206+
if (found == null)return;
207+
208+
var dialog = new AddTagDialog (this.get_root () as Gtk.Window, true);
209+
dialog.name_entry.get_internal_entry ().text = found.name;
210+
dialog.set_selected_color (found.color);
211+
dialog.set_selected_icon_name (found.icon_name);
212+
dialog.present ();
213+
dialog.response.connect ((response_id) => {
214+
if (response_id == Gtk.ResponseType.ACCEPT) {
215+
var new_name = dialog.name_entry.get_internal_entry ().text;
216+
if (new_name != "") {
217+
found.name = new_name;
218+
var chosen_color = dialog.get_selected_color ();
219+
found.color = chosen_color;
220+
221+
var chosen_icon = dialog.get_selected_icon_name ();
222+
if (chosen_icon == null && found.icon_name != null) {
223+
chosen_icon = found.icon_name;
224+
}
225+
found.icon_name = chosen_icon;
226+
this.data_manager.save_data ();
227+
this.refresh_tags ();
228+
this.update_stats ();
229+
}
230+
}
231+
dialog.destroy ();
232+
});
202233
});
203234
this.tag_list_box.append (row);
204235
this.setup_tag_dnd (row);

0 commit comments

Comments
 (0)