Create an IDLE_ADD notification
Used for setting up g_idle_add(). Without this, banning songs will save but unbanning them won't. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
e9f8c34e5a
commit
9801e9335b
|
@ -3,6 +3,7 @@
|
|||
#define LIBSARIA_NOTIFY_H
|
||||
|
||||
enum notify_t {
|
||||
IDLE_ADD, // NULL
|
||||
TRACK_CHANGED, // libsaria::Track *
|
||||
PATH_ADDED, // libsaria::library::Path *
|
||||
PATH_DELETED, // libsaria::library::Path *
|
||||
|
|
|
@ -19,6 +19,7 @@ void on_notify(notify_t, void *);
|
|||
|
||||
/* ocarina.cpp */
|
||||
string lib_file(const string &);
|
||||
gboolean ocarina_idle(gpointer);
|
||||
GObject *get_object(const string &);
|
||||
GtkWidget *get_widget(const string &);
|
||||
void connect_signal(const string &, const string &, GCallback, void *);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker.
|
||||
#include <libsaria/notify.h>
|
||||
#include <libsaria/idle.h>
|
||||
#include <libsaria/list.h>
|
||||
#include <libsaria/print.h>
|
||||
|
@ -55,6 +56,7 @@ namespace libsaria
|
|||
else
|
||||
idle_queue.push_back(task);
|
||||
queued += 1.0;
|
||||
notify(IDLE_ADD, NULL);
|
||||
}
|
||||
|
||||
void idle::cancel_all(void *data)
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
#include <libsaria/idle.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
|
||||
static void idle_add()
|
||||
{
|
||||
if (libsaria::idle::size() == 1) {
|
||||
println("Adding idle callback");
|
||||
g_idle_add(ocarina_idle, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void on_notify(notify_t event, void *data)
|
||||
{
|
||||
/* TODO: Array of function pointers */
|
||||
switch (event) {
|
||||
case IDLE_ADD:
|
||||
idle_add();
|
||||
break;
|
||||
case TRACK_CHANGED:
|
||||
update_labels((libsaria::Track *)data);
|
||||
break;
|
||||
|
|
|
@ -53,26 +53,14 @@ string lib_file(const string &path)
|
|||
return res;
|
||||
}
|
||||
|
||||
static gboolean ocarina_idle(gpointer data)
|
||||
gboolean ocarina_idle(gpointer data)
|
||||
{
|
||||
int size = libsaria::idle::run_task();
|
||||
return update_idle_bar(size);
|
||||
}
|
||||
|
||||
static void idle_add()
|
||||
{
|
||||
static int size = 0;
|
||||
int cur = libsaria::idle::size();
|
||||
if ((cur > 0) && (cur > size)) {
|
||||
println("Adding idle callback");
|
||||
g_idle_add(ocarina_idle, NULL);
|
||||
size = cur;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean timeout_poll(gpointer data)
|
||||
{
|
||||
idle_add();
|
||||
update_progress();
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue