chiark / gitweb /
Some more Disobedience work
[disorder] / disobedience / control.c
index c51205966057c1aae229cdedd6a3abd4d0bb45a7..e371ca9f687a6cded66140498fe676a646625fb8 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include "disobedience.h"
-#include "mixer.h"
 
 /* Forward declarations ---------------------------------------------------- */
 
@@ -52,6 +51,9 @@ static void icon_changed(const char *event,
 static void volume_changed(const char *event,
                            void *eventdata,
                            void *callbackdata);
+static void control_minimode(const char *event,
+                             void *eventdata,
+                             void *callbackdata);
 
 /* Control bar ------------------------------------------------------------- */
 
@@ -290,8 +292,8 @@ GtkWidget *control_widget(void) {
   gtk_scale_set_digits(GTK_SCALE(balance_widget), 10);
   gtk_widget_set_size_request(volume_widget, 192, -1);
   gtk_widget_set_size_request(balance_widget, 192, -1);
-  gtk_tooltips_set_tip(tips, volume_widget, "Volume", "");
-  gtk_tooltips_set_tip(tips, balance_widget, "Balance", "");
+  gtk_widget_set_tooltip_text(volume_widget, "Volume");
+  gtk_widget_set_tooltip_text(balance_widget, "Balance");
   gtk_box_pack_start(GTK_BOX(hbox), volume_widget, FALSE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(hbox), balance_widget, FALSE, TRUE, 0);
   /* space updates rather than hammering the server */
@@ -309,27 +311,28 @@ GtkWidget *control_widget(void) {
                    G_CALLBACK(format_balance), 0);
   event_register("volume-changed", volume_changed, 0);
   event_register("rtp-changed", volume_changed, 0);
+  event_register("mini-mode-changed", control_minimode, 0);
   return hbox;
 }
 
+/** @brief Return TRUE if volume setting is supported */
+static int volume_supported(void) {
+  /* TODO: if the server doesn't know how to set the volume [but isn't using
+   * network play] then we should have volume_supported = FALSE */
+  return (!rtp_supported
+          || (rtp_supported && backend && backend->set_volume));
+}
+
 /** @brief Update the volume control when it changes */
 static void volume_changed(const char attribute((unused)) *event,
                            void attribute((unused)) *eventdata,
                            void attribute((unused)) *callbackdata) {
   double l, r;
-  gboolean volume_supported;
 
   D(("volume_changed"));
   ++suppress_actions;
   /* Only display volume/balance controls if they will work */
-  if(!rtp_supported
-     || (rtp_supported && mixer_supported(DEFAULT_BACKEND)))
-    volume_supported = TRUE;
-  else
-    volume_supported = FALSE;
-  /* TODO: if the server doesn't know how to set the volume [but isn't using
-   * network play] then we should have volume_supported = FALSE */
-  if(volume_supported) {
+  if(volume_supported()) {
     gtk_widget_show(volume_widget);
     gtk_widget_show(balance_widget);
     l = volume_l / 100.0;
@@ -375,8 +378,8 @@ static void icon_changed(const char attribute((unused)) *event,
    * state is immediately displayed.  sensitive and GTK_WIDGET_SENSITIVE show
    * it to be in the correct state, so I think this is may be a GTK+ bug. */
   if(icon->tip_on)
-    gtk_tooltips_set_tip(tips, icon->button,
-                           on ? icon->tip_on : icon->tip_off, "");
+    gtk_widget_set_tooltip_text(icon->button,
+                                on ? icon->tip_on : icon->tip_off);
   gtk_widget_set_sensitive(icon->button, sensitive);
   /* Icons with an associated menu item */
   if(icon->item) {
@@ -444,7 +447,8 @@ static void volume_adjusted(GtkAdjustment attribute((unused)) *a,
    * from the log. */
   if(rtp_supported) {
     int l = nearbyint(left(v, b) * 100), r = nearbyint(right(v, b) * 100);
-    mixer_control(DEFAULT_BACKEND, &l, &r, 1);
+    if(backend && backend->set_volume)
+      backend->set_volume(&l, &r);
   } else
     disorder_eclient_volume(client, volume_completed,
                             nearbyint(left(v, b) * 100),
@@ -559,6 +563,15 @@ static int disable_rtp(disorder_eclient attribute((unused)) *c,
   return 0;
 }
 
+static void control_minimode(const char attribute((unused)) *event,
+                             void attribute((unused)) *evendata,
+                             void attribute((unused)) *callbackdata) {
+  if(full_mode && volume_supported())
+    gtk_widget_show(balance_widget);
+  else
+    gtk_widget_hide(balance_widget);
+}
+
 /*
 Local Variables:
 c-basic-offset:2