chiark / gitweb /
doxygen fixes
[disorder] / disobedience / control.c
index d3c4e18a3a09a6388a77dd6534093565c611d045..e1f44f28fcea9102aee9d42b1940575d5b154df5 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "disobedience.h"
+#include "mixer.h"
 
 /* Forward declarations ---------------------------------------------------- */
 
@@ -66,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
  *
@@ -113,20 +114,20 @@ static struct icon icons[] = {
   {
     "pause.png",                        /* icon */
     "Pause playing track",              /* tip */
-    0,                                  /* menuitem */
+    "<GdisorderMain>/Control/Playing",  /* menuitem */
     update_pause,                       /* update */
     disorder_eclient_pause,             /* action */
-    ICON_INACTIVE,                      /* flags */
+    ICON_ACTIVE,                        /* flags */
     0,                                  /* button */
     0                                   /* item */
   },
   {
     "play.png",                         /* icon */
     "Resume playing track",             /* tip */
-    0,                                  /* menuitem */
+    "<GdisorderMain>/Control/Playing",  /* menuitem */
     update_play,                        /* update */
     disorder_eclient_resume,            /* action */
-    ICON_ACTIVE,                        /* flags */
+    ICON_INACTIVE,                      /* flags */
     0,                                  /* button */
     0                                   /* item */
   },
@@ -183,7 +184,7 @@ static struct icon icons[] = {
   {
     "speaker.png",                      /* icon */
     "Play network stream",              /* tip */
-    0,                                  /* menuitem */
+    "<GdisorderMain>/Control/Network player", /* menuitem */
     update_rtp,                         /* update */
     enable_rtp,                         /* action */
     ICON_INACTIVE,                      /* flags */
@@ -193,7 +194,7 @@ static struct icon icons[] = {
   {
     "speakercross.png",                 /* icon */
     "Stop playing network stream",      /* tip */
-    0,                                  /* menuitem */
+    "<GdisorderMain>/Control/Network player", /* menuitem */
     update_nortp,                       /* update */
     disable_rtp,                        /* action */
     ICON_ACTIVE,                        /* flags */
@@ -220,8 +221,6 @@ void control_monitor(void attribute((unused)) *u) {
 /** @brief Create the control bar */
 GtkWidget *control_widget(void) {
   GtkWidget *hbox = gtk_hbox_new(FALSE, 1), *vbox;
-  GtkWidget *content;
-  GdkPixbuf *pb;
   GtkWidget *v, *b;
   int n;
 
@@ -230,16 +229,7 @@ GtkWidget *control_widget(void) {
   assert(mainmenufactory);              /* ordering must be right */
   for(n = 0; n < NICONS; ++n) {
     NW(button);
-    icons[n].button = gtk_button_new();
-    if((pb = find_image(icons[n].icon))) {
-      NW(image);
-      content = gtk_image_new_from_pixbuf(pb);
-    } else {
-      NW(label);
-      content = gtk_label_new(icons[n].icon);
-    }
-    gtk_container_add(GTK_CONTAINER(icons[n].button), content);
-    gtk_tooltips_set_tip(tips, icons[n].button, icons[n].tip, "");
+    icons[n].button = iconbutton(icons[n].icon, icons[n].tip);
     g_signal_connect(G_OBJECT(icons[n].button), "clicked",
                      G_CALLBACK(clicked_icon), &icons[n]);
     /* pop the icon in a vbox so it doesn't get vertically stretch if there are
@@ -279,6 +269,8 @@ GtkWidget *control_widget(void) {
   v = gtk_hscale_new(volume_adj);
   NW(hscale);
   b = gtk_hscale_new(balance_adj);
+  gtk_widget_set_style(v, tool_style);
+  gtk_widget_set_style(b, tool_style);
   gtk_scale_set_digits(GTK_SCALE(v), 10);
   gtk_scale_set_digits(GTK_SCALE(b), 10);
   gtk_widget_set_size_request(v, 192, -1);
@@ -311,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
@@ -407,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,
@@ -422,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. */
@@ -439,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;
@@ -449,10 +445,15 @@ static void volume_adjusted(GtkAdjustment attribute((unused)) *a,
   b = nearbyint(5 * b) / 5;
   /* Set the volume.  We don't want a reply, we'll get the actual new volume
    * from the log. */
-  disorder_eclient_volume(client, 0,
-                          nearbyint(left(v, b) * 100),
-                          nearbyint(right(v, b) * 100),
-                          0);
+  if(rtp_supported) {
+    int l = nearbyint(left(v, b) * 100), r = nearbyint(right(v, b) * 100);
+    mixer_control(&l, &r, 1);
+  } else
+    /* We don't want a reply, we'll get the actual new volume from the log. */
+    disorder_eclient_volume(client, 0,
+                            nearbyint(left(v, b) * 100),
+                            nearbyint(right(v, b) * 100),
+                            0);
 }
 
 /** @brief Formats the volume value */