From 97a864697751df0105e68f9f13a91842ce1198fb Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 27 Jul 2014 11:24:22 -0400 Subject: [PATCH] plist: Move liststore into lib/ Signed-off-by: Anna Schumaker --- gui/playlist.cpp | 29 +++++++++++++---------------- include/lib/plist.h | 19 +++++++++++++++++++ lib/plist.cpp | 32 ++++++++++++++++++++++++++++++++ share/ocarina/ocarina6.glade | 14 +++++++------- 4 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 include/lib/plist.h create mode 100644 lib/plist.cpp diff --git a/gui/playlist.cpp b/gui/playlist.cpp index ba78c35b..ab8007f2 100644 --- a/gui/playlist.cpp +++ b/gui/playlist.cpp @@ -2,10 +2,11 @@ * Copyright 2014 (c) Anna Schumaker. */ #include +#include #include -static const std::string current_playlist(); +static Glib::ustring current_playlist(); /** * Playlist tab stuff @@ -53,26 +54,21 @@ bool PlaylistTab :: on_key_press_event(const std::string &key) * Playlist "sidebar" stuff */ -static class PlaylistColumns : public Gtk::TreeModelColumnRecord { -public: - PlaylistColumns() - { add(plist_col_name); } - - Gtk::TreeModelColumn plist_col_name; -} plist_cols; - -static Glib::RefPtr playlist_ls; static Gtk::TreeView *playlist_tv; -static const std::string current_playlist() +static bool find_cur_path(Gtk::TreePath &path) { - Gtk::TreePath path; Gtk::TreeViewColumn *col; playlist_tv->get_cursor(path, col); + return !path.empty(); +} - Gtk::TreeModel::Row row = *(playlist_ls->get_iter(path)); - std::string res = row[plist_cols.plist_col_name]; - return res; +static Glib::ustring current_playlist() +{ + Gtk::TreePath path; + if (find_cur_path(path)) + return plist :: get_path(path); + return ""; } @@ -94,8 +90,9 @@ static PlaylistTab *playlist_tab; void init_playlist_tab() { + plist :: init(); + playlist_tab = new PlaylistTab; - playlist_ls = lib :: get_object("o_playlists"); playlist_tv = lib :: get_widget("o_playlist_treeview"); playlist_tv->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed)); diff --git a/include/lib/plist.h b/include/lib/plist.h new file mode 100644 index 00000000..4dfecdf8 --- /dev/null +++ b/include/lib/plist.h @@ -0,0 +1,19 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#ifndef OCARINA_LIB_PLIST_H +#define OCARINA_LIB_PLIST_H + +#include +#include + +namespace plist +{ + + void init(); + + Glib::ustring get_path(const Gtk::TreePath &); + +} + +#endif /* OCARINA_LIB_PLIST_H */ diff --git a/lib/plist.cpp b/lib/plist.cpp new file mode 100644 index 00000000..5cb3b088 --- /dev/null +++ b/lib/plist.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#include +#include + + +class PlaylistColumns : public Gtk::TreeModelColumnRecord { +public: + Gtk::TreeModelColumn p_name; + + PlaylistColumns() + { + add(p_name); + } +}; + + +static PlaylistColumns p_cols; +static Glib::RefPtr p_list; + + +void plist :: init() +{ + p_list = lib :: get_object("plist_list"); +} + +Glib::ustring plist :: get_path(const Gtk::TreePath &path) +{ + Gtk::TreeModel::Row row = *(p_list->get_iter(path)); + return row[p_cols.p_name]; +} diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 33feba53..1e410656 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -195,7 +195,12 @@ - + + 100000000000 + 1000000000 + 10000000000 + + @@ -209,11 +214,6 @@ - - 100000000000 - 1000000000 - 10000000000 - True False @@ -819,7 +819,7 @@ True True - o_playlists + plist_list False 0