diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-02-19 21:48:56 +0100 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-02-19 21:48:56 +0100 |
commit | 441f1363d70d68b21ffa8ef7387f4647f6b3764d (patch) | |
tree | 2f3f83f06cf2e85acf3a4232c2f68a84835019ac /plugins/gtkui | |
parent | 6f3f80c89aa75d98ca4ed09dc4e74fd63bafd579 (diff) |
gtkui: respect gui refresh fps in seekbar
Diffstat (limited to 'plugins/gtkui')
-rw-r--r-- | plugins/gtkui/gtkui.c | 34 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.h | 3 | ||||
-rw-r--r-- | plugins/gtkui/prefwin.c | 2 | ||||
-rw-r--r-- | plugins/gtkui/widgets.c | 43 |
4 files changed, 44 insertions, 38 deletions
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index e2495082..d6d45f81 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -81,6 +81,8 @@ GtkWidget *theme_button; static int gtkui_accept_messages = 0; +static gint refresh_timeout = 0; + int fileadded_listener_id; int fileadd_beginend_listener_id; // overriden API methods @@ -553,6 +555,19 @@ gtkui_get_curr_playlist_mod (void) { return res; } +void +gtkui_setup_gui_refresh (void) { + int tm = 1000/gtkui_get_gui_refresh_rate (); + + if (refresh_timeout) { + g_source_remove (refresh_timeout); + refresh_timeout = 0; + } + + refresh_timeout = g_timeout_add (tm, gtkui_on_frameupdate, NULL); +} + + static gboolean gtkui_on_configchanged (void *data) { // order and looping @@ -587,6 +602,9 @@ gtkui_on_configchanged (void *data) { // tray icon gtkui_update_status_icon (NULL); + // statusbar refresh + gtkui_setup_gui_refresh (); + return FALSE; } @@ -686,8 +704,6 @@ gtkui_add_new_playlist (void) { return -1; } -static gint refresh_timeout = 0; - int gtkui_get_gui_refresh_rate () { int fps = deadbeef->conf_get_int ("gtkui.refresh_rate", 10); @@ -700,18 +716,6 @@ gtkui_get_gui_refresh_rate () { return fps; } -void -gtkui_setup_gui_refresh (void) { - int tm = 1000/gtkui_get_gui_refresh_rate (); - - if (refresh_timeout) { - g_source_remove (refresh_timeout); - refresh_timeout = 0; - } - - refresh_timeout = g_timeout_add (tm, gtkui_on_frameupdate, NULL); -} - static void send_messages_to_widgets (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { for (ddb_gtkui_widget_t *c = w->children; c; c = c->next) { @@ -1038,8 +1042,6 @@ gtkui_thread (void *ctx) { init_widget_layout (); - gtkui_setup_gui_refresh (); - char fmt[500]; char str[600]; deadbeef->conf_get_str ("gtkui.titlebar_stopped", "DeaDBeeF-%V", fmt, sizeof (fmt)); diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index da0882b2..bf60c7d3 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -123,9 +123,6 @@ gtkui_set_progress_text_idle (gpointer data); void gtkui_playlist_set_curr (int playlist); -void -gtkui_setup_gui_refresh (); - int gtkui_get_curr_playlist_mod (void); diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index 40f9b475..e59ca6df 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -1050,7 +1050,7 @@ on_gui_fps_value_changed (GtkRange *range, { int val = gtk_range_get_value (range); deadbeef->conf_set_int ("gtkui.refresh_rate", val); - gtkui_setup_gui_refresh (); + deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); } void diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index ac389edf..2d499464 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -613,9 +613,6 @@ w_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_da if (GTK_IS_CONTAINER (widget)) { // hide all children gtk_widget_size_request (widget, &prev_req); - - GtkAllocation a; - gtk_widget_get_allocation (widget, &a); gtk_container_foreach (GTK_CONTAINER (widget), hide_widget, NULL); gtk_widget_set_size_request (widget, prev_req.width, prev_req.height); } @@ -3491,20 +3488,6 @@ redraw_seekbar_cb (gpointer data) { return FALSE; } -static int -w_seekbar_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { - switch (id) { - case DB_EV_SONGCHANGED: - case DB_EV_CONFIGCHANGED: - { - ddb_event_trackchange_t *ev = (ddb_event_trackchange_t *)ctx; - g_idle_add (redraw_seekbar_cb, w); - } - break; - } - return 0; -} - static gboolean seekbar_frameupdate (gpointer data) { w_seekbar_t *w = data; @@ -3535,6 +3518,30 @@ seekbar_frameupdate (gpointer data) { } static void +w_seekbar_init (ddb_gtkui_widget_t *base) { + w_seekbar_t *w = (w_seekbar_t *)base; + if (w->timer) { + g_source_remove (w->timer); + w->timer = 0; + } + + w->timer = g_timeout_add (1000/gtkui_get_gui_refresh_rate (), seekbar_frameupdate, w); +} + +static int +w_seekbar_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { + switch (id) { + case DB_EV_SONGCHANGED: + g_idle_add (redraw_seekbar_cb, w); + break; + case DB_EV_CONFIGCHANGED: + w_seekbar_init (w); + break; + } + return 0; +} + +static void w_seekbar_destroy (ddb_gtkui_widget_t *wbase) { w_seekbar_t *w = (w_seekbar_t *)wbase; if (w->timer) { @@ -3550,6 +3557,7 @@ w_seekbar_create (void) { w->base.widget = gtk_event_box_new (); w->base.message = w_seekbar_message; w->base.destroy = w_seekbar_destroy; + w->base.init = w_seekbar_init; w->seekbar = ddb_seekbar_new (); gtk_widget_set_size_request (w->base.widget, 20, 16); w->last_songpos = -1; @@ -3557,7 +3565,6 @@ w_seekbar_create (void) { gtk_widget_show (w->seekbar); gtk_container_add (GTK_CONTAINER (w->base.widget), w->seekbar); w_override_signals (w->base.widget, w); - w->timer = g_timeout_add (1000/gtkui_get_gui_refresh_rate (), seekbar_frameupdate, w); return (ddb_gtkui_widget_t*)w; } |