Remove PLAYLIST_FILTER notification
It's easier to refilter automatically after setting the filter text, rather than going through a bunch of function pointers to change the filter. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
0290ea8710
commit
9fb1d05376
|
@ -19,7 +19,6 @@ enum notify_t {
|
|||
PLAYLIST_RM, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_UPDATE, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_SIZE, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_FILTER, // libsaria::PlaylistNotification *
|
||||
NOTIFY_SIZE,
|
||||
};
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ namespace libsaria
|
|||
void Playlist::set_filter_text(string &text)
|
||||
{
|
||||
index.do_filter(text);
|
||||
notify_ui(PLAYLIST_FILTER, NULL, 0);
|
||||
}
|
||||
|
||||
bool Playlist::is_visible(libsaria::Track *track)
|
||||
|
|
|
@ -43,7 +43,6 @@ void on_notify(notify_t event, void *data)
|
|||
case PLAYLIST_ADD:
|
||||
case PLAYLIST_RM:
|
||||
case PLAYLIST_SIZE:
|
||||
case PLAYLIST_FILTER:
|
||||
case PLAYLIST_UPDATE:
|
||||
update_playlist(event, (libsaria::PlaylistNotification *)data);
|
||||
default:
|
||||
|
|
|
@ -83,13 +83,6 @@ static void set_playlist_size(libsaria::Playlist *plist)
|
|||
update_length_label();
|
||||
}
|
||||
|
||||
static void playlist_refilter(libsaria::Playlist *plist)
|
||||
{
|
||||
struct PlaylistWidgets *widgets = find_playlist_widgets(plist);
|
||||
if (widgets)
|
||||
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->filter));
|
||||
}
|
||||
|
||||
void update_playlist(notify_t event, libsaria::PlaylistNotification *data)
|
||||
{
|
||||
if (event == PLAYLIST_ADD)
|
||||
|
@ -100,8 +93,6 @@ void update_playlist(notify_t event, libsaria::PlaylistNotification *data)
|
|||
playlist_update(data->plist, data->track, data->index);
|
||||
else if (event == PLAYLIST_SIZE)
|
||||
set_playlist_size(data->plist);
|
||||
else if (event == PLAYLIST_FILTER)
|
||||
playlist_refilter(data->plist);
|
||||
}
|
||||
|
||||
static gboolean is_visible(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
|
||||
|
@ -113,11 +104,13 @@ static gboolean is_visible(GtkTreeModel *model, GtkTreeIter *iter, gpointer data
|
|||
return plist->is_visible(track);
|
||||
}
|
||||
|
||||
static void do_filter(GtkWidget *entry, gpointer d)
|
||||
static void do_filter(GtkWidget *entry, gpointer data)
|
||||
{
|
||||
struct PlaylistWidgets *widgets = (struct PlaylistWidgets *)data;
|
||||
string text = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
libsaria::Playlist *plist = (libsaria::Playlist *)d;
|
||||
plist->set_filter_text(text);
|
||||
|
||||
widgets->playlist->set_filter_text(text);
|
||||
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->filter));
|
||||
}
|
||||
|
||||
static void track_selected(GtkWidget *treeview, GtkTreePath *path,
|
||||
|
@ -260,7 +253,7 @@ void setup_widgets(struct PlaylistWidgets *widgets, libsaria::Playlist *playlist
|
|||
|
||||
g_signal_connect(widgets->treeview, "row-activated", G_CALLBACK(track_selected), NULL);
|
||||
g_signal_connect(widgets->treeview, "key-press-event", G_CALLBACK(key_pressed), widgets);
|
||||
g_signal_connect(widgets->entry, "changed", G_CALLBACK(do_filter), widgets->playlist);
|
||||
g_signal_connect(widgets->entry, "changed", G_CALLBACK(do_filter), widgets);
|
||||
g_signal_connect(widgets->entry, "key-press-event", G_CALLBACK(entry_keypress), widgets);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue