summaryrefslogtreecommitdiff
path: root/plugins/gtkui
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-14 20:50:40 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-14 20:50:40 +0200
commit4e3bdbb0bc8649208400b9eb63751db15bc9bcda (patch)
tree3bfc597a6255a652ce774558bda4bf65c6b6252a /plugins/gtkui
parenta0116d4496107e368b791d86295834c6e844a6e8 (diff)
new event passing system
Diffstat (limited to 'plugins/gtkui')
-rw-r--r--plugins/gtkui/ddblistview.c9
-rw-r--r--plugins/gtkui/gtkui.c119
2 files changed, 45 insertions, 83 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index c50dd9df..1406e95b 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -607,7 +607,6 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) {
ddb_listview_groupcheck (listview);
// find 1st group
DdbListviewGroup *grp = listview->groups;
- printf ("starting to render listview, groups=%p, num_items=%d\n", grp, grp?grp->num_items : 0);
int grp_y = 0;
while (grp && grp_y + grp->height < y + listview->scrollpos) {
grp_y += grp->height;
@@ -919,7 +918,6 @@ ddb_listview_list_drag_data_received (GtkWidget *widget,
guint time,
gpointer user_data)
{
- printf ("target_type: %d, format: %d\n", target_type, data->format);
DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner"));
ps->scroll_direction = 0; // interrupt autoscrolling, if on
ps->scroll_active = 0;
@@ -2907,7 +2905,6 @@ ddb_listview_build_groups (DdbListview *listview) {
memset (grp, 0, sizeof (DdbListviewGroup));
grp->head = it;
grp->num_items = listview->binding->count ();
- printf ("numitems: %d\n", grp->num_items);
listview->grouptitle_height = 0;
grp->height = listview->grouptitle_height + grp->num_items * listview->rowheight;
// if (grp->height < min_height) {
@@ -2953,12 +2950,6 @@ ddb_listview_build_groups (DdbListview *listview) {
}
listview->fullheight += grp->height;
}
- if (!listview->groups) {
- printf ("empty!\n");
- }
- else {
- printf ("groupsize: %d!\n", listview->groups->num_items);
- }
deadbeef->pl_unlock ();
if (old_height != listview->fullheight) {
ddb_listview_refresh (listview, DDB_REFRESH_VSCROLL);
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 0a268a52..22570b87 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -337,12 +337,6 @@ activate_cb (gpointer nothing) {
return FALSE;
}
-static int
-gtkui_on_activate (DB_event_t *ev, uintptr_t data) {
- g_idle_add (activate_cb, NULL);
- return 0;
-}
-
void
redraw_queued_tracks (DdbListview *pl, int list) {
DB_playItem_t *it;
@@ -386,12 +380,6 @@ gtkpl_songchanged_wrapper (DB_playItem_t *from, DB_playItem_t *to) {
g_idle_add (redraw_queued_tracks_cb, NULL);
}
-static int
-gtkui_on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) {
- gtkpl_songchanged_wrapper (ev->from, ev->to);
- return 0;
-}
-
void
gtkui_set_titlebar (DB_playItem_t *it) {
if (!it) {
@@ -450,15 +438,6 @@ trackinfochanged_cb (gpointer data) {
return FALSE;
}
-static int
-gtkui_on_trackinfochanged (DB_event_track_t *ev, uintptr_t data) {
- if (ev->track) {
- deadbeef->pl_item_ref (ev->track);
- }
- g_idle_add (trackinfochanged_cb, ev->track);
- return 0;
-}
-
static gboolean
paused_cb (gpointer nothing) {
DB_playItem_t *curr = deadbeef->streamer_get_playing_track ();
@@ -471,12 +450,6 @@ paused_cb (gpointer nothing) {
return FALSE;
}
-static int
-gtkui_on_paused (DB_event_state_t *ev, uintptr_t data) {
- g_idle_add (paused_cb, NULL);
- return 0;
-}
-
void
playlist_refresh (void) {
DdbListview *ps = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
@@ -495,13 +468,6 @@ gtkui_playlist_changed (void) {
g_idle_add (playlistchanged_cb, NULL);
}
-static int
-gtkui_on_playlistchanged (DB_event_t *ev, uintptr_t data) {
- printf ("gtkui_on_playlistchanged\n");
- gtkui_playlist_changed ();
- return 0;
-}
-
static gboolean
playlistswitch_cb (gpointer none) {
GtkWidget *tabstrip = lookup_widget (mainwin, "tabstrip");
@@ -529,12 +495,6 @@ playlistswitch_cb (gpointer none) {
return FALSE;
}
-static int
-gtkui_on_playlistswitch (DB_event_t *ev, uintptr_t data) {
- g_idle_add (playlistswitch_cb, NULL);
- return 0;
-}
-
static gboolean
gtkui_on_frameupdate (gpointer data) {
update_songinfo (NULL);
@@ -549,13 +509,6 @@ gtkui_volumechanged_cb (gpointer ctx) {
return FALSE;
}
-static int
-gtkui_on_volumechanged (DB_event_t *ev, uintptr_t data) {
- g_idle_add (gtkui_volumechanged_cb, NULL);
-
- return 0;
-}
-
static gboolean
gtkui_update_status_icon (gpointer unused) {
int hide_tray_icon = deadbeef->conf_get_int ("gtkui.hide_tray_icon", 0);
@@ -630,7 +583,7 @@ gtkui_get_curr_playlist_modtime (void) {
}
static int
-gtkui_on_configchanged (DB_event_t *ev, uintptr_t data) {
+gtkui_on_configchanged (ddb_event_t *ev, uintptr_t data) {
// order and looping
const char *w;
@@ -669,12 +622,6 @@ outputchanged_cb (gpointer nothing) {
return FALSE;
}
-static int
-gtkui_on_outputchanged (DB_event_t *ev, uintptr_t nothing) {
- g_idle_add (outputchanged_cb, NULL);
- return 0;
-}
-
char last_playlist_save_name[1024] = "";
void
@@ -992,6 +939,49 @@ gtkui_setup_gui_refresh (void) {
refresh_timeout = g_timeout_add (tm, gtkui_on_frameupdate, NULL);
}
+int
+gtkui_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
+ switch (id) {
+ case DB_EV_ACTIVATE:
+ g_idle_add (activate_cb, NULL);
+ break;
+ case DB_EV_SONGCHANGED:
+ {
+ ddb_event_trackchange_t *ev = (ddb_event_trackchange_t *)ctx;
+ gtkpl_songchanged_wrapper (ev->from, ev->to);
+ }
+ break;
+ case DB_EV_TRACKINFOCHANGED:
+ {
+ ddb_event_track_t *ev = (ddb_event_track_t *)ctx;
+ if (ev->track) {
+ deadbeef->pl_item_ref (ev->track);
+ }
+ g_idle_add (trackinfochanged_cb, ev->track);
+ }
+ break;
+ case DB_EV_PAUSED:
+ g_idle_add (paused_cb, NULL);
+ break;
+ case DB_EV_PLAYLISTCHANGED:
+ gtkui_playlist_changed ();
+ break;
+ case DB_EV_VOLUMECHANGED:
+ g_idle_add (gtkui_volumechanged_cb, NULL);
+ break;
+ case DB_EV_CONFIGCHANGED:
+ gtkui_on_configchanged ((ddb_event_t *)ctx, 0);
+ break;
+ case DB_EV_OUTPUTCHANGED:
+ g_idle_add (outputchanged_cb, NULL);
+ break;
+ case DB_EV_PLAYLISTSWITCH:
+ g_idle_add (playlistswitch_cb, NULL);
+ break;
+ }
+ return 0;
+}
+
void
gtkui_thread (void *ctx) {
// let's start some gtk
@@ -1072,16 +1062,6 @@ gtkui_thread (void *ctx) {
gtk_widget_show (mainwin);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_ACTIVATE, DB_CALLBACK (gtkui_on_activate), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (gtkui_on_songchanged), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_TRACKINFOCHANGED, DB_CALLBACK (gtkui_on_trackinfochanged), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_PAUSED, DB_CALLBACK (gtkui_on_paused), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_PLAYLISTCHANGED, DB_CALLBACK (gtkui_on_playlistchanged), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_VOLUMECHANGED, DB_CALLBACK (gtkui_on_volumechanged), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_CONFIGCHANGED, DB_CALLBACK (gtkui_on_configchanged), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_OUTPUTCHANGED, DB_CALLBACK (gtkui_on_outputchanged), 0);
- deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_PLAYLISTSWITCH, DB_CALLBACK (gtkui_on_playlistswitch), 0);
-
gtkui_setup_gui_refresh ();
char fmt[500];
@@ -1269,16 +1249,6 @@ gtkui_stop (void) {
coverart_plugin->plugin.plugin.stop ();
coverart_plugin = NULL;
}
- trace ("unsubscribing events\n");
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_ACTIVATE, DB_CALLBACK (gtkui_on_activate), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (gtkui_on_songchanged), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_TRACKINFOCHANGED, DB_CALLBACK (gtkui_on_trackinfochanged), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_PAUSED, DB_CALLBACK (gtkui_on_paused), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_PLAYLISTCHANGED, DB_CALLBACK (gtkui_on_playlistchanged), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_VOLUMECHANGED, DB_CALLBACK (gtkui_on_volumechanged), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_CONFIGCHANGED, DB_CALLBACK (gtkui_on_configchanged), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_OUTPUTCHANGED, DB_CALLBACK (gtkui_on_outputchanged), 0);
- deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_PLAYLISTSWITCH, DB_CALLBACK (gtkui_on_playlistswitch), 0);
trace ("quitting gtk\n");
g_idle_add (quit_gtk_cb, NULL);
trace ("waiting for gtk thread to finish\n");
@@ -1342,6 +1312,7 @@ static ddb_gtkui_t plugin = {
.gui.plugin.stop = gtkui_stop,
.gui.plugin.connect = gtkui_connect,
.gui.plugin.configdialog = settings_dlg,
+ .gui.plugin.message = gtkui_message,
.gui.run_dialog = gtkui_run_dialog_root,
.get_mainwin = gtkui_get_mainwin,
};