Freya  0.0.1
A Gtk3 MPD Client
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
src/Browser/PlaylistManager/PlaylistManager.hh
Go to the documentation of this file.
00001 /***********************************************************
00002 * This file is part of Freya
00003 * - A free MPD Gtk3 MPD Client -
00004 *
00005 * Authors: Christopher Pahl, Christoph Piechula,
00006 *          Eduard Schneider
00007 *
00008 * Copyright (C) [2011-2012]
00009 * Hosted at: https://github.com/studentkittens/Freya
00010 *
00011 *              __..--''``---....___   _..._    __
00012 *    /// //_.-'    .-/";  `        ``<._  ``.''_ `. / // /
00013 *   ///_.-' _..--.'_                        `( ) ) // //
00014 *   / (_..-' // (< _     ;_..__               ; `' / ///
00015 *    / // // //  `-._,_)' // / ``--...____..-' /// / //
00016 *  Ascii-Art by Felix Lee <flee@cse.psu.edu>
00017 *
00018 * Freya is free software: you can redistribute it and/or modify
00019 * it under the terms of the GNU General Public License as published by
00020 * the Free Software Foundation, either version 3 of the License, or
00021 * (at your option) any later version.
00022 *
00023 * Freya is distributed in the hope that it will be useful,
00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00026 * GNU General Public License for more details.
00027 *
00028 * You should have received a copy of the GNU General Public License
00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>.
00030 **************************************************************/
00031 #ifndef PLAYLISTMANAGER_LUYIHGVL
00032 #define PLAYLISTMANAGER_LUYIHGVL
00033 
00034 #include <gtkmm.h>
00035 #include "../../MPD/AbstractItemlist.hh"
00036 #include "../../MPD/AbstractClientUser.hh"
00037 #include "../../MPD/Client.hh"
00038 #include "../../MPD/Playlist.hh"
00039 
00040 #include "../AbstractBrowser.hh"
00041 #include "PlaylistManagerPopup.hh"
00042 
00043 namespace Browser
00044 {
00051     class PlaylistManager :
00052         public Gtk::Frame,
00053         public AbstractBrowser,
00054         public MPD::AbstractItemlist,
00055         public MPD::AbstractClientUser
00056     {
00057     public:
00058         PlaylistManager(MPD::Client& client, Glib::RefPtr<Gtk::Builder>& builder);
00059         virtual ~PlaylistManager();
00060 
00066         Gtk::Widget * get_container();
00067 
00068     private:
00069 
00070         /* Menu Popup */
00071         void on_menu_append_clicked();
00072         void on_menu_replace_clicked();
00073         void on_menu_del_clicked();
00074         void selection_helper(bool load_or_remove);
00075 
00076         /* Other */
00077         bool on_row_double_click(GdkEventButton * event);
00078 
00079         /* Clear list (frees memory) */
00080         void clear();
00081 
00082         /* Implemented from AbstractItemlist */
00083         void add_item(MPD::AbstractComposite * pPlaylist);
00084 
00085         /* Implemented from AbstractClientUser */
00086         void on_client_update(enum mpd_idle event, MPD::NotifyData& data);
00087         void on_connection_change(bool server_changed, bool is_connected);
00088 
00089         void on_cell_edited(const Glib::ustring& path_string,const Glib::ustring& new_text);
00090         void on_cell_get_data(Gtk::CellRenderer*, const Gtk::TreeModel::iterator& iter);
00091 
00092         /* Tree model columns: */
00093         class ModelColumns : public Gtk::TreeModel::ColumnRecord
00094         {
00095         public:
00096 
00097             ModelColumns()
00098             {
00099                 add(m_col_icon);
00100                 add(m_col_plist);
00101                 add(m_col_name);
00102                 add(m_col_last_modfied);
00103             }
00104 
00105             Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>> m_col_icon;
00106             Gtk::TreeModelColumn<MPD::Playlist*> m_col_plist;
00107             Gtk::TreeModelColumn<Glib::ustring> m_col_name;
00108             Gtk::TreeModelColumn<Glib::ustring> m_col_last_modfied;
00109         };
00110 
00111         /* Treeview related */
00112         ModelColumns m_Columns;
00113 
00114         Gtk::TreeView * mp_TreeView;
00115         Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
00116         Glib::RefPtr<Gtk::TreeSelection> m_Selection;
00117 
00118         /* We need to validate renames of playlists
00119          * Therefore we render the cell on our own
00120          * Taken from:
00121          * http://developer.gnome.org/gtkmm-tutorial/stable/sec-treeview-examples.html.de
00122          */
00123         Gtk::CellRendererText m_PlaylistCellRender;
00124         Gtk::TreeView::Column m_PlaylistTreeViewCol;
00125 
00126         /* Status label */
00127         Gtk::Label * mp_StatusLabel;
00128 
00129         /* Popup menu */
00130         PlaylistManagerPopup * mp_Popup;
00131 
00132         /* Playlist Icon */
00133         Glib::RefPtr<Gdk::Pixbuf> m_PlaylistIcon;
00134     };
00135 }
00136 
00137 #endif /* end of include guard: PLAYLISTMANAGER_LUYIHGVL */