Skip to content

Commit 553507b

Browse files
committed
refine hide button thingy
1 parent e19a805 commit 553507b

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/Widgets/ActionBar.vala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
public class Jorts.ActionBar : Granite.Bin {
1313

1414
public Gtk.ActionBar actionbar;
15+
private Gtk.Button list_button;
1516
public Gtk.MenuButton emoji_button;
1617
public Gtk.EmojiChooser emojichooser_popover;
1718
public Gtk.MenuButton menu_button;
@@ -45,7 +46,7 @@
4546
delete_item.action_name = StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_DELETE;
4647

4748
/* **** RIGHT **** */
48-
var list_button = new Gtk.Button () {
49+
list_button = new Gtk.Button () {
4950
icon_name = "view-list-symbolic",
5051
width_request = 32,
5152
height_request = 32,
@@ -57,10 +58,6 @@
5758
list_button.add_css_class ("themedbutton");
5859
list_button.action_name = StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_TOGGLE_LIST;
5960

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") != "");});
63-
6461
emojichooser_popover = new Gtk.EmojiChooser ();
6562

6663
emoji_button = new Gtk.MenuButton () {
@@ -106,6 +103,11 @@
106103

107104
// Randomize-skip emoji icon
108105
emojichooser_popover.show.connect (on_emoji_popover);
106+
107+
// Hide the list button if user has specified no list item symbol
108+
on_prefix_changed ();
109+
Application.gsettings.changed["list-item-start"].connect (on_prefix_changed);
110+
109111
}
110112

111113
/**
@@ -126,4 +128,8 @@
126128
)
127129
);
128130
}
131+
132+
private void on_prefix_changed () {
133+
list_button.visible = (Application.gsettings.get_string ("list-item-start") != "");
134+
}
129135
}

src/Widgets/TextView.vala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ 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-
3936
keyboard = new Gtk.EventControllerKey ();
4037
add_controller (keyboard);
4138
keyboard.key_pressed.connect (on_key_pressed);
4239
keyboard.key_released.connect (on_key_released);
4340

4441
buffer.notify["cursor_position"].connect (on_cursor_changed);
42+
Application.gsettings.changed["list-item-start"].connect (on_prefix_changed);
4543
}
4644

4745
public void paste () {
@@ -199,14 +197,18 @@ public class Jorts.TextView : Granite.HyperTextView {
199197
}
200198
}
201199

200+
private void on_prefix_changed () {
201+
list_item_start = Application.gsettings.get_string ("list-item-start");
202+
}
203+
202204
private void on_cursor_changed () {
203205
Gtk.TextIter start, end;
204206
buffer.get_selection_bounds (out start, out end);
205207
start.backward_line ();
206208
var line_number = (uint8)start.get_line ();
207209

208-
if (this.has_prefix (line_number)) {
209-
print ("YES THIS IS LIST");
210-
}
210+
if (this.has_prefix (line_number)) {
211+
print ("YES THIS IS LIST");
212+
}
211213
}
212214
}

0 commit comments

Comments
 (0)