Skip to content

Commit

Permalink
Show New Notebook option on right-clicking the Notebooks expandable (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dar5hak authored and Philip-Scott committed Mar 16, 2018
1 parent 46a0ec9 commit 855d213
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ vala_precompile(VALA_C

src/Widgets/Sidebar/Sidebar.vala
src/Widgets/Sidebar/SidebarItem.vala
src/Widgets/Sidebar/NotebookList.vala
src/Widgets/Sidebar/NotebookItem.vala
src/Widgets/Sidebar/BookmarkItem.vala
src/Widgets/Sidebar/TrashItem.vala
Expand Down
46 changes: 46 additions & 0 deletions src/Widgets/Sidebar/NotebookList.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2011-2018 Felipe Escoto (https://github.com/Philip-Scott/Notes-up)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authored by: Darshak Parikh <darshak@protonmail.com>
*/

public class ENotes.NotebookList : Granite.Widgets.SourceList.ExpandableItem {
private Gtk.Menu menu;
private Gtk.MenuItem new_notebook_item;

public NotebookList (string name) {
Object (name: name);
}

construct {
menu = new Gtk.Menu ();
new_notebook_item = new Gtk.MenuItem.with_label (_("New Notebook"));

menu.add (new_notebook_item);
menu.show_all ();

new_notebook_item.activate.connect (() => {
var dialog = new NotebookDialog ();
dialog.run ();
});
}

public override Gtk.Menu? get_context_menu () {
return menu;
}
}
2 changes: 1 addition & 1 deletion src/Widgets/Sidebar/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
public class ENotes.Sidebar : Granite.Widgets.SourceList {
private static Sidebar? instance = null;

private Granite.Widgets.SourceList.ExpandableItem notebooks = new Granite.Widgets.SourceList.ExpandableItem (_("Notebooks"));
private Granite.Widgets.SourceList.ExpandableItem bookmarks = new Granite.Widgets.SourceList.ExpandableItem (_("Bookmarks"));
private Granite.Widgets.SourceList.ExpandableItem trash = new Granite.Widgets.SourceList.ExpandableItem (_("Trash"));
private Granite.Widgets.SourceList.Item? previous_selection = null;
private NotebookList notebooks = new NotebookList (_("Notebooks"));

private Gee.HashMap<int, NotebookItem> added_notebooks;

Expand Down

0 comments on commit 855d213

Please sign in to comment.