plist: Move liststore into lib/

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-07-27 11:24:22 -04:00
parent 32bb1c670b
commit 97a8646977
4 changed files with 71 additions and 23 deletions

View File

@ -2,10 +2,11 @@
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/playlist.h>
#include <lib/plist.h>
#include <gui/tabs.h>
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<std::string> plist_col_name;
} plist_cols;
static Glib::RefPtr<Gtk::ListStore> 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<Gtk::ListStore>("o_playlists");
playlist_tv = lib :: get_widget<Gtk::TreeView>("o_playlist_treeview");
playlist_tv->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));

19
include/lib/plist.h Normal file
View File

@ -0,0 +1,19 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#ifndef OCARINA_LIB_PLIST_H
#define OCARINA_LIB_PLIST_H
#include <gtkmm.h>
#include <string>
namespace plist
{
void init();
Glib::ustring get_path(const Gtk::TreePath &);
}
#endif /* OCARINA_LIB_PLIST_H */

32
lib/plist.cpp Normal file
View File

@ -0,0 +1,32 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <lib/lib.h>
#include <lib/plist.h>
class PlaylistColumns : public Gtk::TreeModelColumnRecord {
public:
Gtk::TreeModelColumn<Glib::ustring> p_name;
PlaylistColumns()
{
add(p_name);
}
};
static PlaylistColumns p_cols;
static Glib::RefPtr<Gtk::ListStore> p_list;
void plist :: init()
{
p_list = lib :: get_object<Gtk::ListStore>("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];
}

View File

@ -195,7 +195,12 @@
</object>
</child>
</object>
<object class="GtkListStore" id="o_playlists">
<object class="GtkAdjustment" id="o_progress">
<property name="upper">100000000000</property>
<property name="step_increment">1000000000</property>
<property name="page_increment">10000000000</property>
</object>
<object class="GtkListStore" id="plist_list">
<columns>
<!-- column-name Playlists -->
<column type="gchararray"/>
@ -209,11 +214,6 @@
</row>
</data>
</object>
<object class="GtkAdjustment" id="o_progress">
<property name="upper">100000000000</property>
<property name="step_increment">1000000000</property>
<property name="page_increment">10000000000</property>
</object>
<object class="GtkWindow" id="o_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -819,7 +819,7 @@
<object class="GtkTreeView" id="o_playlist_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">o_playlists</property>
<property name="model">plist_list</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<child internal-child="selection">