Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit b1bdd51

Browse files
Merge branch 'dynamic-searchbar'
2 parents a38ec93 + 1006e75 commit b1bdd51

File tree

12 files changed

+62
-24
lines changed

12 files changed

+62
-24
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
src/Constants.vala
7171
src/Bookmark.vala
7272
src/StackManager.vala
73-
src/BookmarkListManager.vala
7473
src/Dialogs/Preferences.vala
7574
src/Dialogs/DeleteConfirm.vala
7675
src/Dialogs/Alert.vala

data/com.github.bartzaalberg.bookmark-manager.appdata.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
</ul>
1818
</description>
1919
<releases>
20+
<release version="1.3.5" date="2017-11-10">
21+
<description>
22+
<p>1.3.5</p>
23+
<ul>
24+
<li>HeaderBar is now dynamic</li>
25+
<li>Searchbar is disabled when no bookmarks are found</li>
26+
<li>Added a cool dynamic cancel button in the headerBar</li>
27+
</ul>
28+
</description>
29+
</release>
2030
<release version="1.3.4" date="2017-10-30">
2131
<description>
2232
<p>1.3.4</p>

debian/changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
com.github.bartzaalberg.bookmark-manager (1.3.5) UNSTABLE; urgency=low
2+
3+
* HeaderBar is now dynamic.
4+
* Searchbar is disabled when no bookmarks are found
5+
* Added a cool dynamic cancel button in the headerBar
6+
7+
-- Bart Zaalberg <bartzaalberg@gmail.com> Fri, 10 Nov 2017 09:17:00 +0200
8+
19
com.github.bartzaalberg.bookmark-manager (1.3.4) UNSTABLE; urgency=low
210

311
* fixed a bug where first screen would be empty

src/Components/BookmarkForm.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace BookmarkManager {
22
public class BookmarkForm : Gtk.Grid{
33

44
StackManager stackManager = StackManager.get_instance();
5-
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
5+
private ListBox listBox = ListBox.get_instance();
66

77
protected HeaderLabel general_header = new HeaderLabel ("A bookmark form");
88

src/Components/HeaderBar.vala

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@ using Granite.Widgets;
22

33
namespace BookmarkManager {
44
public class HeaderBar : Gtk.HeaderBar {
5+
6+
static HeaderBar? instance;
57

68
StackManager stackManager = StackManager.get_instance();
7-
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
9+
ListBox listBox = ListBox.get_instance();
810
public Gtk.SearchEntry searchEntry = new Gtk.SearchEntry ();
9-
Gtk.Button return_button = new Gtk.Button ();
11+
public Gtk.Button return_button = new Gtk.Button ();
1012
Gtk.Button add_button = new Gtk.Button.from_icon_name ("document-new", Gtk.IconSize.LARGE_TOOLBAR);
1113
Gtk.MenuButton menu_button = new Gtk.MenuButton ();
1214

13-
public HeaderBar(){
14-
15+
HeaderBar() {
1516
Granite.Widgets.Utils.set_color_primary (this, Constants.BRAND_COLOR);
1617

1718
searchEntry.set_placeholder_text("Search Bookmarks");
1819
searchEntry.set_tooltip_text("Search for bookmarks");
20+
searchEntry.sensitive = true;
1921
searchEntry.search_changed.connect (() => {
2022
showReturnButton(false);
2123
showAddButton(true);
22-
bookmarkListManager.getList().getBookmarks(searchEntry.text);
24+
listBox.getBookmarks(searchEntry.text);
2325
});
2426

2527
generateAddButton();
@@ -50,6 +52,13 @@ public class HeaderBar : Gtk.HeaderBar {
5052
this.pack_end (menu_button);
5153
this.pack_end (searchEntry);
5254
}
55+
56+
public static HeaderBar get_instance() {
57+
if (instance == null) {
58+
instance = new HeaderBar();
59+
}
60+
return instance;
61+
}
5362

5463
private void generateMenuButton(){
5564
menu_button.has_tooltip = true;
@@ -75,7 +84,7 @@ public class HeaderBar : Gtk.HeaderBar {
7584
showReturnButton(false);
7685
showAddButton(true);
7786
stackManager.getStack().visible_child_name = "list-view";
78-
bookmarkListManager.getList().getBookmarks("");
87+
listBox.getBookmarks("");
7988
});
8089
}
8190

src/Dialogs/DeleteConfirm.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace BookmarkManager {
22
public class DeleteConfirm : Gtk.Dialog {
33

4-
private BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
4+
private ListBox listBox = ListBox.get_instance();
55
private StackManager stackManager = StackManager.get_instance();
66

77
// public DeleteConfirm(Bookmark deletedBookmark){
@@ -94,7 +94,7 @@ public class DeleteConfirm : Gtk.Dialog {
9494
ConfigFileReader.writeToFile(newBookmarksList);
9595

9696
stackManager.getStack().visible_child_name = "list-view";
97-
bookmarkListManager.getList().getBookmarks("");
97+
listBox.getBookmarks("");
9898
}
9999

100100

src/Dialogs/Preferences.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace BookmarkManager {
22
public class Preferences : Gtk.Dialog {
33

44
private Settings settings = new Settings ("com.github.bartzaalberg.bookmark-manager");
5-
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
5+
private ListBox listBox = ListBox.get_instance();
66

77
public Preferences(){
88
title = "Preferences";
@@ -38,7 +38,7 @@ public class Preferences : Gtk.Dialog {
3838
settings.set_string("sshname", usernameEntry.text);
3939
}
4040

41-
bookmarkListManager.getList().getBookmarks("");
41+
listBox.getBookmarks("");
4242
this.destroy ();
4343
});
4444

src/ListBox.vala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@ using Granite.Widgets;
33
namespace BookmarkManager {
44
public class ListBox : Gtk.ListBox{
55

6+
static ListBox? instance;
7+
68
private ConfigFileReader configFileReader = new ConfigFileReader ();
79
private StackManager stackManager = StackManager.get_instance();
810

11+
ListBox() {
12+
}
13+
14+
public static ListBox get_instance() {
15+
if (instance == null) {
16+
instance = new ListBox();
17+
}
18+
return instance;
19+
}
20+
921
public void emptyList(){
1022
this.foreach ((ListBoxRow) => {
1123
this.remove(ListBoxRow);
@@ -15,17 +27,19 @@ public class ListBox : Gtk.ListBox{
1527
public void getBookmarks(string searchWord = ""){
1628
emptyList();
1729

30+
HeaderBar.get_instance().searchEntry.sensitive = true;
1831
stackManager.getStack().visible_child_name = "list-view";
1932

2033
var bookmarks = configFileReader.getBookmarks();
2134

2235
if(listisEmpty(bookmarks)) {
36+
HeaderBar.get_instance().searchEntry.sensitive = false;
2337
stackManager.getStack().visible_child_name = "empty-view";
2438
return;
2539
}
2640

2741
if(searchWordDoesntMatchAnyInList(searchWord, bookmarks)) {
28-
stackManager.getStack().visible_child_name = "not-found-view";
42+
stackManager.getStack().visible_child_name = "not-found-view";
2943
return;
3044
}
3145

src/MainWindow.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ public class MainWindow : Gtk.Window{
55

66
private Settings settings = new Settings ("com.github.bartzaalberg.bookmark-manager");
77

8-
private BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
8+
private ListBox listBox = ListBox.get_instance();
99
private StackManager stackManager = StackManager.get_instance();
10-
private HeaderBar headerBar = new HeaderBar();
10+
private HeaderBar headerBar = HeaderBar.get_instance();
1111

1212
construct {
1313
if(settings.get_string ("sshname") == ""){
@@ -19,7 +19,7 @@ public class MainWindow : Gtk.Window{
1919

2020
stackManager.loadViews(this);
2121

22-
bookmarkListManager.getList().getBookmarks("");
22+
listBox.getBookmarks("");
2323

2424
addShortcuts();
2525

src/Views/AddBookmark.vala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace BookmarkManager {
22
public class AddBookmark : BookmarkForm{
33

44
StackManager stackManager = StackManager.get_instance();
5-
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
5+
private ListBox listBox = ListBox.get_instance();
66
ConfigFileReader configFileReader = new ConfigFileReader();
77

88
public AddBookmark(){
@@ -47,8 +47,7 @@ public class AddBookmark : BookmarkForm{
4747

4848
configFileReader.writeToFile(bookmarks);
4949

50-
stackManager.getStack().visible_child_name = "list-view";
51-
bookmarkListManager.getList().getBookmarks("");
50+
listBox.getBookmarks("");
5251
}
5352

5453
public bool alreadyExists(Bookmark newBookmark, Bookmark[] bookmarks){

0 commit comments

Comments
 (0)