Skip to content

Commit e19a805

Browse files
committed
hide button if no prefix
1 parent f92f858 commit e19a805

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/Views/PreferencesView.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444
halign = Gtk.Align.END,
4545
hexpand = false,
4646
valign = Gtk.Align.CENTER,
47+
max_length = 5,
4748
max_width_chars = 5
4849
};
4950

5051
var list_label = new Granite.HeaderLabel (_("List item symbol")) {
5152
mnemonic_widget = list_entry,
52-
secondary_text = _("Prefix by which to begin each item in a list"),
53+
secondary_text = _("Prefix by which to begin each item in a list. If there is no prefix, the toggle list button will be hidden"),
5354
hexpand = true
5455
};
5556

src/Widgets/ActionBar.vala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
list_button.add_css_class ("themedbutton");
5858
list_button.action_name = StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_TOGGLE_LIST;
5959

60+
// Hide the list button if user has specified no list item symbol
61+
Application.gsettings.changed["list-item-start"].connect (
62+
() => {list_button.visible = (Application.gsettings.get_string ("list-item-start") != "");});
6063

6164
emojichooser_popover = new Gtk.EmojiChooser ();
6265

src/Widgets/TextView.vala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ public class Jorts.TextView : Granite.HyperTextView {
3333
list_item_start = Application.gsettings.get_string ("list-item-start");
3434
//Application.gsettings.bind ("list-item-start", this, "list-item-start", GLib.SettingsBindFlags.GET);
3535

36+
Application.gsettings.changed["list-item-start"].connect (
37+
() => {list_item_start = Application.gsettings.get_string ("list-item-start");});
38+
3639
keyboard = new Gtk.EventControllerKey ();
3740
add_controller (keyboard);
38-
3941
keyboard.key_pressed.connect (on_key_pressed);
4042
keyboard.key_released.connect (on_key_released);
43+
44+
buffer.notify["cursor_position"].connect (on_cursor_changed);
4145
}
4246

4347
public void paste () {
@@ -181,7 +185,6 @@ public class Jorts.TextView : Granite.HyperTextView {
181185

182186
// User did Enter
183187
if (keyval == Gdk.Key.Return) {
184-
185188
Gtk.TextIter start, end;
186189
buffer.get_selection_bounds (out start, out end);
187190
start.backward_line ();
@@ -194,7 +197,16 @@ public class Jorts.TextView : Granite.HyperTextView {
194197
buffer.end_user_action ();
195198
}
196199
}
200+
}
197201

202+
private void on_cursor_changed () {
203+
Gtk.TextIter start, end;
204+
buffer.get_selection_bounds (out start, out end);
205+
start.backward_line ();
206+
var line_number = (uint8)start.get_line ();
198207

208+
if (this.has_prefix (line_number)) {
209+
print ("YES THIS IS LIST");
210+
}
199211
}
200212
}

0 commit comments

Comments
 (0)