From fb44b59ebf9398f9b0759e2e760542c73c2d29c3 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 16 Nov 2007 13:24:49 +0000 Subject: [PATCH] more systematic elimination of feedback from the gui Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/control.c | 18 +++++++++++------- disobedience/disobedience.c | 5 +++++ disobedience/disobedience.h | 2 ++ disobedience/log.c | 8 +++++++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/disobedience/control.c b/disobedience/control.c index ecdc1a6..e1f44f2 100644 --- a/disobedience/control.c +++ b/disobedience/control.c @@ -67,8 +67,8 @@ static gchar *format_balance(GtkScale *scale, gdouble value); /* Control bar ------------------------------------------------------------- */ -/** @brief Guard against feedback loop in volume control */ -static int suppress_set_volume; +/** @brief Guard against feedback */ +int suppress_actions = 1; /** @brief Definition of an icon * @@ -303,10 +303,10 @@ void volume_update(void) { D(("volume_update")); l = volume_l / 100.0; r = volume_r / 100.0; - ++suppress_set_volume; + ++suppress_actions; gtk_adjustment_set_value(volume_adj, volume(l, r) * goesupto); gtk_adjustment_set_value(balance_adj, balance(l, r)); - --suppress_set_volume; + --suppress_actions; } /** @brief Update the state of one of the control icons @@ -399,14 +399,16 @@ static void clicked_icon(GtkButton attribute((unused)) *button, gpointer userdata) { const struct icon *icon = userdata; - icon->action(client, 0, 0); + if(!suppress_actions) + icon->action(client, 0, 0); } static void clicked_menu(GtkMenuItem attribute((unused)) *menuitem, gpointer userdata) { const struct icon *icon = userdata; - icon->action(client, 0, 0); + if(!suppress_actions) + icon->action(client, 0, 0); } static void toggled_menu(GtkCheckMenuItem *menuitem, @@ -414,6 +416,8 @@ static void toggled_menu(GtkCheckMenuItem *menuitem, const struct icon *icon = userdata; size_t n; + if(suppress_actions) + return; /* This is a bit fiddlier than the others, we need to find the action for the * new state. If the new state is active then we want the ICON_INACTIVE * version and vica versa. */ @@ -431,7 +435,7 @@ static void volume_adjusted(GtkAdjustment attribute((unused)) *a, double v = gtk_adjustment_get_value(volume_adj) / goesupto; double b = gtk_adjustment_get_value(balance_adj); - if(suppress_set_volume) + if(suppress_actions) /* This is the result of an update from the server, not a change from the * user. Don't feedback! */ return; diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 54b6be8..d6b346d 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -350,20 +350,24 @@ static gboolean maybe_send_nop(gpointer attribute((unused)) data) { static void got_rtp_address(void attribute((unused)) *v, int attribute((unused)) nvec, char attribute((unused)) **vec) { + ++suppress_actions; rtp_address_in_flight = 0; rtp_supported = 1; rtp_is_running = rtp_running(); control_monitor(0); + --suppress_actions; } /** @brief Called when a rtp-address command fails */ static void no_rtp_address(struct callbackdata attribute((unused)) *cbd, int attribute((unused)) code, const char attribute((unused)) *msg) { + ++suppress_actions; rtp_address_in_flight = 0; rtp_supported = 0; rtp_is_running = 0; control_monitor(0); + --suppress_actions; } /** @brief Called to check whether RTP play is available */ @@ -487,6 +491,7 @@ int main(int argc, char **argv) { disorder_eclient_log(logclient, &log_callbacks, 0); /* See if RTP play supported */ check_rtp_address(); + suppress_actions = 0; D(("enter main loop")); MTAG("misc"); g_main_loop_run(mainloop); diff --git a/disobedience/disobedience.h b/disobedience/disobedience.h index ea5d095..999ef31 100644 --- a/disobedience/disobedience.h +++ b/disobedience/disobedience.h @@ -194,6 +194,8 @@ void volume_update(void); void control_monitor(void *u); +extern int suppress_actions; + /* Queue/Recent/Added */ GtkWidget *queue_widget(void); diff --git a/disobedience/log.c b/disobedience/log.c index af38643..b0aaace 100644 --- a/disobedience/log.c +++ b/disobedience/log.c @@ -83,10 +83,12 @@ static struct monitor *monitors; /** @brief Update everything */ void all_update(void) { + ++suppress_actions; queue_update(); recent_update(); volume_update(); added_update(); + --suppress_actions; } /** @brief Called when the client connects @@ -167,7 +169,8 @@ static void log_state(void attribute((unused)) *v, const struct monitor *m; unsigned long changes = state ^ last_state; static int first = 1; - + + ++suppress_actions; if(first) { changes = -1UL; first = 0; @@ -182,6 +185,7 @@ static void log_state(void attribute((unused)) *v, if(changes & m->mask) m->callback(m->u); } + --suppress_actions; } /** @brief Called when volume changes */ @@ -190,7 +194,9 @@ static void log_volume(void attribute((unused)) *v, if(!rtp_supported && (volume_l != l || volume_r != r)) { volume_l = l; volume_r = r; + ++suppress_actions; volume_update(); + --suppress_actions; } } -- [mdw]