Skip to content

Commit c1cc4fa

Browse files
committed
attempt at a dynamic togglebutton
1 parent 50e1014 commit c1cc4fa

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/Views/NoteView.vala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
emojichooser_popover.show.connect (randomize_emote_button);
6969
emojichooser_popover.emoji_picked.connect (on_emoji_picked);
7070
//Application.gsettings.bind ("hide-bar", actionbar, "revealed", SettingsBindFlags.INVERT_BOOLEAN);
71+
72+
//textview.bind_property ("on_list_item", actionbar.list_button, "active", GLib.BindingFlags.DEFAULT);
7173
}
7274

7375
// Randomize the button emoji when clicked

src/Widgets/ActionBar.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class Jorts.ActionBar : Granite.Bin {
1313

1414
public Gtk.ActionBar actionbar;
15-
private Gtk.Button list_button;
15+
public Gtk.Button list_button;
1616
public Gtk.MenuButton emoji_button;
1717
public Gtk.EmojiChooser emojichooser_popover;
1818
public Gtk.MenuButton menu_button;

src/Widgets/TextView.vala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class Jorts.TextView : Granite.HyperTextView {
1313

1414
private Gtk.EventControllerKey keyboard;
1515
private string list_item_start;
16+
public bool on_list_item {public get; private set;}
1617

1718
public string text {
1819
owned get {return buffer.text;}
@@ -31,14 +32,16 @@ public class Jorts.TextView : Granite.HyperTextView {
3132
set_wrap_mode (Gtk.WrapMode.WORD_CHAR);
3233

3334
list_item_start = Application.gsettings.get_string ("list-item-start");
34-
//Application.gsettings.bind ("list-item-start", this, "list-item-start", GLib.SettingsBindFlags.GET);
35+
Application.gsettings.changed["list-item-start"].connect (on_prefix_changed);
3536

3637
keyboard = new Gtk.EventControllerKey ();
3738
add_controller (keyboard);
3839
keyboard.key_pressed.connect (on_key_pressed);
3940

40-
move_cursor.connect (on_cursor_changed);
41-
Application.gsettings.changed["list-item-start"].connect (on_prefix_changed);
41+
//TODO: Buggy. Clicking anywhere brings it out of whack
42+
// on_cursor_changed ();
43+
// move_cursor.connect_after (on_cursor_changed);
44+
4245
}
4346

4447
public void paste () {
@@ -203,11 +206,10 @@ public class Jorts.TextView : Granite.HyperTextView {
203206
private void on_cursor_changed () {
204207
Gtk.TextIter start, end;
205208
buffer.get_selection_bounds (out start, out end);
206-
start.backward_line ();
207209
var line_number = (uint8)start.get_line ();
208210

209-
if (this.has_prefix (line_number)) {
210-
print ("YES THIS IS LIST");
211-
}
211+
on_list_item = this.has_prefix (line_number);
212+
213+
print ("THIS IS LIST. HAS " + on_list_item.to_string () + "ON LINE " + line_number.to_string ());
212214
}
213215
}

0 commit comments

Comments
 (0)