ocarina: Remove old playlist code
ocarina/playlist/ was the last subdirectory remaining in the ocarina code, and I can finally remove it. Thank you GtkBuilder! At this point, there is only one ocarina header file, so I move it to the main ocarina directory. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
ef55c2f44a
commit
5f1fb2290a
|
@ -1,42 +0,0 @@
|
|||
#ifndef OCARINA_PLAYLIST_H
|
||||
#define OCARINA_PLAYLIST_H
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <libsaria/playlist.h>
|
||||
#include <libsaria/renderer.h>
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
class Playlist : public libsaria::PlaylistRenderer {
|
||||
private:
|
||||
bool visible;
|
||||
GtkWidget *name;
|
||||
GtkWidget *number;
|
||||
GtkWidget *box;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *treeview;
|
||||
GtkWidget *disable_button;
|
||||
GtkListStore *liststore;
|
||||
GtkTreeModel *filter;
|
||||
GtkTreeSelection *treesel;
|
||||
|
||||
void setup_treeview();
|
||||
GtkWidget *make_disable_button();
|
||||
|
||||
public:
|
||||
Playlist(unsigned int);
|
||||
Playlist(libsaria::Playlist *);
|
||||
~Playlist();
|
||||
|
||||
void right_click(guint, guint64);
|
||||
void list_selected_tracks(list<libsaria::Track *> &);
|
||||
void list_selected_indices(list<unsigned int> &);
|
||||
|
||||
void set_playlist(libsaria::Playlist *);
|
||||
void on_disable(bool);
|
||||
};
|
||||
|
||||
}; /* Namespace: ocarina */
|
||||
|
||||
#endif /* OCARINA_PLAYLIST_H */
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <libsaria/library.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
static inline GtkListStore *get_list()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
#include <libsaria/idle.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
static void idle_add()
|
||||
{
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include <libsaria/deck.h>
|
||||
#include <libsaria/idle.h>
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/playlist.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
static string lib_path;
|
||||
static GtkBuilder *builder;
|
||||
|
|
|
@ -52,7 +52,7 @@ void setup_playlist_page(struct PlaylistWidgets *, int);
|
|||
|
||||
/* status.cpp */
|
||||
bool update_idle_bar(int);
|
||||
void update_length_label();
|
||||
void update_length_label(libsaria::Playlist *);
|
||||
void update_labels(libsaria::Track *);
|
||||
void update_buttons(notify_t);
|
||||
void update_progress();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <libsaria/track.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <stdlib.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
static GType types[] = {
|
||||
G_TYPE_POINTER, // libsaria::Track *
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/playlist.h>
|
||||
#include "playlist.h"
|
||||
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/deck.h>
|
||||
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#define BUTTON_RIGHT 3
|
||||
|
||||
struct PlaylistData {
|
||||
libsaria::Playlist *playlist;
|
||||
ocarina::Playlist *renderer;
|
||||
};
|
||||
|
||||
static PlaylistData plist_data[MAX_PLAYLISTS];
|
||||
|
||||
/*static GtkWidget *menu_item(const char *text, void (*func)(GtkMenuItem *, gpointer),
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget = gtk_menu_item_new_with_label(text);
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(func), data);
|
||||
return widget;
|
||||
}*/
|
||||
|
||||
void show_rc_menu(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
ocarina::Playlist *plist = (ocarina::Playlist *)data;
|
||||
|
||||
if (event->button.button != BUTTON_RIGHT)
|
||||
return;
|
||||
plist->right_click(event->button.button, event->button.time);
|
||||
}
|
||||
|
||||
static gboolean delete_banned(list<libsaria::Track *> &tracks, bool state)
|
||||
{
|
||||
list<libsaria::Track *>::iterator it;
|
||||
|
||||
if (tracks.size() == 0)
|
||||
return FALSE;
|
||||
|
||||
for (it = tracks.begin(); it != tracks.end(); it++)
|
||||
(*it)->set_banned(state);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean delete_from_playlist(list<unsigned int> &indices, ocarina::Playlist *plist)
|
||||
{
|
||||
if (indices.size() == 0)
|
||||
return FALSE;
|
||||
|
||||
plist->get_playlist()->remove_indices(indices);
|
||||
libsaria::deck::garbage_collect();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
list<libsaria::Track *> tracks;
|
||||
list<unsigned int> indices;
|
||||
string key = gdk_keyval_name(event->key.keyval);
|
||||
ocarina::Playlist *plist = (ocarina::Playlist *)data;
|
||||
println("Treeview handling key press");
|
||||
|
||||
if (key == "Delete") {
|
||||
string name = plist->get_playlist()->get_name();
|
||||
if (name == "Library" || name == "Banned") {
|
||||
plist->list_selected_tracks(tracks);
|
||||
return delete_banned(tracks, name == "Library");
|
||||
} else {
|
||||
plist->list_selected_indices(indices);
|
||||
return delete_from_playlist(indices, plist);
|
||||
}
|
||||
} else
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void make_playlist_items(GtkWidget *menu, ocarina::Playlist *renderer)
|
||||
{
|
||||
//GtkWidget *plist_menu, *sep;
|
||||
unsigned int i = 0;
|
||||
libsaria::Playlist *plist = libsaria::deck::get_playlist(i);
|
||||
|
||||
while (plist != NULL) {
|
||||
stringstream s;
|
||||
s << "Add to " << plist->get_name() << " " << i;
|
||||
|
||||
plist_data[i].playlist = plist;
|
||||
plist_data[i].renderer = renderer;
|
||||
|
||||
//plist_menu = menu_item(s.str().c_str(), add_to_plist, &plist_data[i]);
|
||||
//gtk_menu_append(GTK_MENU(menu), plist_menu);
|
||||
i++;
|
||||
plist = libsaria::deck::get_playlist(i);
|
||||
}
|
||||
|
||||
/*if (i != 0) {
|
||||
sep = gtk_separator_menu_item_new();
|
||||
gtk_menu_append(GTK_MENU(menu), sep);;
|
||||
}*/
|
||||
}
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
void Playlist::right_click(guint button, guint64 time)
|
||||
{
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
GtkWidget *sep = gtk_separator_menu_item_new();
|
||||
|
||||
gtk_menu_append(GTK_MENU(menu), sep);
|
||||
|
||||
make_playlist_items(menu, this);
|
||||
|
||||
gtk_widget_show_all(menu);
|
||||
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/playlist.h>
|
||||
|
||||
#include <libsaria/format.h>
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/deck.h>
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
/*static void disable_playlist(GtkWidget *button, gpointer d)
|
||||
{
|
||||
libsaria::Playlist *plist = (libsaria::Playlist *)d;
|
||||
plist->set_disabled(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
|
||||
}
|
||||
|
||||
static void delete_playlist(GtkWidget *button, gpointer d)
|
||||
{
|
||||
libsaria::Playlist *plist = (libsaria::Playlist *)d;
|
||||
libsaria::deck::delete_playlist(plist);
|
||||
}*/
|
||||
|
||||
static void selected_foreach_list(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
libsaria::Track *track;
|
||||
list<libsaria::Track *> *tracks = (list<libsaria::Track *> *)data;
|
||||
|
||||
gtk_tree_model_get(model, iter, 0, &track, -1);
|
||||
tracks->push_back(track);
|
||||
}
|
||||
|
||||
static void selected_foreach_index(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
list<unsigned int> *indices = (list<unsigned int> *)data;
|
||||
unsigned int *index = (unsigned int *)gtk_tree_path_get_indices(path);
|
||||
indices->push_back(*index);
|
||||
}
|
||||
|
||||
static void do_filter(GtkWidget *entry, gpointer d)
|
||||
{
|
||||
string text = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
ocarina::Playlist *plist = (ocarina::Playlist *)d;
|
||||
plist->get_playlist()->set_filter_text(text);
|
||||
}
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
Playlist::Playlist(unsigned int f) : libsaria::PlaylistRenderer(f)
|
||||
{
|
||||
visible = false;
|
||||
}
|
||||
|
||||
Playlist::Playlist(libsaria::Playlist *plist): libsaria::PlaylistRenderer(PL_NONE)
|
||||
{
|
||||
set_playlist(plist);
|
||||
}
|
||||
|
||||
Playlist::~Playlist()
|
||||
{
|
||||
}
|
||||
|
||||
void Playlist::list_selected_tracks(list<libsaria::Track *> &tracks)
|
||||
{
|
||||
gtk_tree_selection_selected_foreach(treesel, selected_foreach_list, &tracks);
|
||||
}
|
||||
|
||||
void Playlist::list_selected_indices(list<unsigned int> &indices)
|
||||
{
|
||||
gtk_tree_selection_selected_foreach(treesel, selected_foreach_index, &indices);
|
||||
}
|
||||
|
||||
void Playlist::set_playlist(libsaria::Playlist *p)
|
||||
{
|
||||
GtkWidget *label_box = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *entry_box = gtk_hbox_new(FALSE, 0);
|
||||
//GtkWidget *close_button;
|
||||
|
||||
libsaria::PlaylistRenderer::set_playlist(p);
|
||||
|
||||
number = gtk_label_new("");
|
||||
name = gtk_label_new("");
|
||||
box = gtk_vbox_new(FALSE, 0);
|
||||
|
||||
gtk_label_set_justify(GTK_LABEL(name), GTK_JUSTIFY_RIGHT);
|
||||
gtk_misc_set_alignment(GTK_MISC(name), 1.0, 0.0);
|
||||
|
||||
entry = gtk_entry_new();
|
||||
g_signal_connect(entry, "changed", G_CALLBACK(do_filter), this);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(entry_box), entry, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(box), entry_box, FALSE, FALSE, 0);
|
||||
|
||||
//setup_treeview();
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(label_box), number, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(label_box), name, TRUE, TRUE, 0);
|
||||
|
||||
if (!p->is_static()) {
|
||||
/* Make disable button for playlists */
|
||||
/*disable_button = make_toggle_button_data(GTK_STOCK_YES,
|
||||
disable_playlist,
|
||||
p, true);*/
|
||||
gtk_box_pack_start(GTK_BOX(entry_box), disable_button, FALSE, FALSE, 0);
|
||||
|
||||
/* Make close button for tabs */
|
||||
//close_button = make_button_data(GTK_STOCK_CLOSE, delete_playlist, p, true);
|
||||
//gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
|
||||
gtk_rc_parse_string(
|
||||
"style \"close-button-style\"\n"
|
||||
"{\n"
|
||||
" GtkButton::inner-border = {0,0,0,0}\n"
|
||||
"}\n"
|
||||
"widget \"*.ocarina-close-button\" style \"close-button-style\"");
|
||||
//gtk_widget_set_name(close_button, "ocarina-close-button");
|
||||
//gtk_box_pack_start(GTK_BOX(label_box), close_button, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
gtk_widget_show_all(label_box);
|
||||
gtk_widget_show_all(entry_box);
|
||||
|
||||
//body::add_page(p->get_number(), box, label_box, p);
|
||||
}
|
||||
|
||||
void Playlist::on_disable(bool disabled)
|
||||
{
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_button), disabled);
|
||||
gtk_widget_set_sensitive(entry, !disabled);
|
||||
gtk_widget_set_sensitive(treeview, !disabled);
|
||||
gtk_widget_set_sensitive(name, !disabled);
|
||||
gtk_widget_set_sensitive(number, !disabled);
|
||||
|
||||
/*if (disabled)
|
||||
change_button_image(disable_button, GTK_STOCK_NO);
|
||||
else
|
||||
change_button_image(disable_button, GTK_STOCK_YES);*/
|
||||
}
|
||||
|
||||
}; /* Namespace: ocarina */
|
|
@ -1,3 +0,0 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
void show_rc_menu(GtkWidget *widget, GdkEvent *event, gpointer data);
|
||||
gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data);
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <libsaria/format.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/deck.h>
|
||||
#include <libsaria/idle.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <libsaria/deck.h>
|
||||
#include <libsaria/ban.h>
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <version.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/prefs.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include "ocarina.h"
|
||||
|
||||
static int old_w, old_h;
|
||||
static bool ignore_configure_event = false;
|
||||
|
|
Loading…
Reference in New Issue