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

Commit

Permalink
Merge branch 'dynamic-searchbar'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Zaalberg committed Nov 10, 2017
2 parents a38ec93 + 1006e75 commit b1bdd51
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 24 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
src/Constants.vala
src/Bookmark.vala
src/StackManager.vala
src/BookmarkListManager.vala
src/Dialogs/Preferences.vala
src/Dialogs/DeleteConfirm.vala
src/Dialogs/Alert.vala
Expand Down
10 changes: 10 additions & 0 deletions data/com.github.bartzaalberg.bookmark-manager.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
</ul>
</description>
<releases>
<release version="1.3.5" date="2017-11-10">
<description>
<p>1.3.5</p>
<ul>
<li>HeaderBar is now dynamic</li>
<li>Searchbar is disabled when no bookmarks are found</li>
<li>Added a cool dynamic cancel button in the headerBar</li>
</ul>
</description>
</release>
<release version="1.3.4" date="2017-10-30">
<description>
<p>1.3.4</p>
Expand Down
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
com.github.bartzaalberg.bookmark-manager (1.3.5) UNSTABLE; urgency=low

* HeaderBar is now dynamic.
* Searchbar is disabled when no bookmarks are found
* Added a cool dynamic cancel button in the headerBar

-- Bart Zaalberg <[email protected]> Fri, 10 Nov 2017 09:17:00 +0200

com.github.bartzaalberg.bookmark-manager (1.3.4) UNSTABLE; urgency=low

* fixed a bug where first screen would be empty
Expand Down
2 changes: 1 addition & 1 deletion src/Components/BookmarkForm.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BookmarkManager {
public class BookmarkForm : Gtk.Grid{

StackManager stackManager = StackManager.get_instance();
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
private ListBox listBox = ListBox.get_instance();

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

Expand Down
21 changes: 15 additions & 6 deletions src/Components/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ using Granite.Widgets;

namespace BookmarkManager {
public class HeaderBar : Gtk.HeaderBar {

static HeaderBar? instance;

StackManager stackManager = StackManager.get_instance();
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
ListBox listBox = ListBox.get_instance();
public Gtk.SearchEntry searchEntry = new Gtk.SearchEntry ();
Gtk.Button return_button = new Gtk.Button ();
public Gtk.Button return_button = new Gtk.Button ();
Gtk.Button add_button = new Gtk.Button.from_icon_name ("document-new", Gtk.IconSize.LARGE_TOOLBAR);
Gtk.MenuButton menu_button = new Gtk.MenuButton ();

public HeaderBar(){

HeaderBar() {
Granite.Widgets.Utils.set_color_primary (this, Constants.BRAND_COLOR);

searchEntry.set_placeholder_text("Search Bookmarks");
searchEntry.set_tooltip_text("Search for bookmarks");
searchEntry.sensitive = true;
searchEntry.search_changed.connect (() => {
showReturnButton(false);
showAddButton(true);
bookmarkListManager.getList().getBookmarks(searchEntry.text);
listBox.getBookmarks(searchEntry.text);
});

generateAddButton();
Expand Down Expand Up @@ -50,6 +52,13 @@ public class HeaderBar : Gtk.HeaderBar {
this.pack_end (menu_button);
this.pack_end (searchEntry);
}

public static HeaderBar get_instance() {
if (instance == null) {
instance = new HeaderBar();
}
return instance;
}

private void generateMenuButton(){
menu_button.has_tooltip = true;
Expand All @@ -75,7 +84,7 @@ public class HeaderBar : Gtk.HeaderBar {
showReturnButton(false);
showAddButton(true);
stackManager.getStack().visible_child_name = "list-view";
bookmarkListManager.getList().getBookmarks("");
listBox.getBookmarks("");
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/DeleteConfirm.vala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace BookmarkManager {
public class DeleteConfirm : Gtk.Dialog {

private BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
private ListBox listBox = ListBox.get_instance();
private StackManager stackManager = StackManager.get_instance();

// public DeleteConfirm(Bookmark deletedBookmark){
Expand Down Expand Up @@ -94,7 +94,7 @@ public class DeleteConfirm : Gtk.Dialog {
ConfigFileReader.writeToFile(newBookmarksList);

stackManager.getStack().visible_child_name = "list-view";
bookmarkListManager.getList().getBookmarks("");
listBox.getBookmarks("");
}


Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BookmarkManager {
public class Preferences : Gtk.Dialog {

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

public Preferences(){
title = "Preferences";
Expand Down Expand Up @@ -38,7 +38,7 @@ public class Preferences : Gtk.Dialog {
settings.set_string("sshname", usernameEntry.text);
}

bookmarkListManager.getList().getBookmarks("");
listBox.getBookmarks("");
this.destroy ();
});

Expand Down
16 changes: 15 additions & 1 deletion src/ListBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ using Granite.Widgets;
namespace BookmarkManager {
public class ListBox : Gtk.ListBox{

static ListBox? instance;

private ConfigFileReader configFileReader = new ConfigFileReader ();
private StackManager stackManager = StackManager.get_instance();

ListBox() {
}

public static ListBox get_instance() {
if (instance == null) {
instance = new ListBox();
}
return instance;
}

public void emptyList(){
this.foreach ((ListBoxRow) => {
this.remove(ListBoxRow);
Expand All @@ -15,17 +27,19 @@ public class ListBox : Gtk.ListBox{
public void getBookmarks(string searchWord = ""){
emptyList();

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

var bookmarks = configFileReader.getBookmarks();

if(listisEmpty(bookmarks)) {
HeaderBar.get_instance().searchEntry.sensitive = false;
stackManager.getStack().visible_child_name = "empty-view";
return;
}

if(searchWordDoesntMatchAnyInList(searchWord, bookmarks)) {
stackManager.getStack().visible_child_name = "not-found-view";
stackManager.getStack().visible_child_name = "not-found-view";
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ public class MainWindow : Gtk.Window{

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

private BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
private ListBox listBox = ListBox.get_instance();
private StackManager stackManager = StackManager.get_instance();
private HeaderBar headerBar = new HeaderBar();
private HeaderBar headerBar = HeaderBar.get_instance();

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

stackManager.loadViews(this);

bookmarkListManager.getList().getBookmarks("");
listBox.getBookmarks("");

addShortcuts();

Expand Down
5 changes: 2 additions & 3 deletions src/Views/AddBookmark.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BookmarkManager {
public class AddBookmark : BookmarkForm{

StackManager stackManager = StackManager.get_instance();
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
private ListBox listBox = ListBox.get_instance();
ConfigFileReader configFileReader = new ConfigFileReader();

public AddBookmark(){
Expand Down Expand Up @@ -47,8 +47,7 @@ public class AddBookmark : BookmarkForm{

configFileReader.writeToFile(bookmarks);

stackManager.getStack().visible_child_name = "list-view";
bookmarkListManager.getList().getBookmarks("");
listBox.getBookmarks("");
}

public bool alreadyExists(Bookmark newBookmark, Bookmark[] bookmarks){
Expand Down
5 changes: 2 additions & 3 deletions src/Views/EditBookmark.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BookmarkManager {
public class EditBookmark : BookmarkForm{

StackManager stackManager = StackManager.get_instance();
BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
private ListBox listBox = ListBox.get_instance();

public EditBookmark(){

Expand Down Expand Up @@ -88,8 +88,7 @@ public class EditBookmark : BookmarkForm{

ConfigFileReader.writeToFile(bookmarks);

stackManager.getStack().visible_child_name = "list-view";
bookmarkListManager.getList().getBookmarks("");
listBox.getBookmarks("");
}

public int getCorrectBookmarkIndex(Bookmark editedBookmark, Bookmark[] bookmarks){
Expand Down
4 changes: 2 additions & 2 deletions src/Views/ListBookmarks.vala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace BookmarkManager {
public class ListBookmarks : Gtk.ScrolledWindow {

BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance();
private ListBox listBox = ListBox.get_instance();

public ListBookmarks(){

var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
box.add(bookmarkListManager.getList());
box.add(listBox);

this.hscrollbar_policy = Gtk.PolicyType.NEVER;
this.add (box);
Expand Down

0 comments on commit b1bdd51

Please sign in to comment.