X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/7392b131424322234159283e35fcccefa31f5ff2..34fe753171d9b0ae90090565e4043ffaf2b02a52:/disobedience/control.c diff --git a/disobedience/control.c b/disobedience/control.c index c41673a..931746a 100644 --- a/disobedience/control.c +++ b/disobedience/control.c @@ -2,38 +2,27 @@ * This file is part of DisOrder. * Copyright (C) 2006-2008 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . */ /** @file disobedience/control.c * @brief Volume control and buttons */ #include "disobedience.h" -#include "mixer.h" /* Forward declarations ---------------------------------------------------- */ -WT(adjustment); -WT(hscale); -WT(hbox); -WT(button); -WT(image); -WT(label); -WT(vbox); - struct icon; static void clicked_icon(GtkButton *, gpointer); @@ -136,8 +125,6 @@ struct icon { GtkWidget *image_off; }; -/* TODO: Add rights into the mix below */ - static int pause_resume_on(void) { return !(last_state & DISORDER_TRACK_PAUSED); } @@ -179,9 +166,9 @@ static int rtp_sensitive(void) { /** @brief Table of all icons */ static struct icon icons[] = { { - icon_on: "pause.png", + icon_on: "pause32.png", tip_on: "Pause playing track", - icon_off: "play.png", + icon_off: "play32.png", tip_off: "Resume playing track", menuitem: "/Control/Playing", on: pause_resume_on, @@ -191,7 +178,7 @@ static struct icon icons[] = { events: "pause-changed playing-changed rights-changed", }, { - icon_on: "cross.png", + icon_on: "cross32.png", tip_on: "Cancel playing track", menuitem: "/Control/Scratch", sensitive: scratch_sensitive, @@ -199,9 +186,9 @@ static struct icon icons[] = { events: "playing-track-changed rights-changed", }, { - icon_on: "randomcross.png", + icon_on: "randomenabled32.png", tip_on: "Disable random play", - icon_off: "random.png", + icon_off: "randomdisabled32.png", tip_off: "Enable random play", menuitem: "/Control/Random play", on: random_enabled, @@ -211,9 +198,9 @@ static struct icon icons[] = { events: "random-changed rights-changed", }, { - icon_on: "notescross.png", + icon_on: "playenabled32.png", tip_on: "Disable play", - icon_off: "notes.png", + icon_off: "playdisabled32.png", tip_off: "Enable play", on: playing_enabled, sensitive: playing_sensitive, @@ -222,9 +209,9 @@ static struct icon icons[] = { events: "enabled-changed rights-changed", }, { - icon_on: "speakercross.png", + icon_on: "rtpenabled32.png", tip_on: "Stop playing network stream", - icon_off: "speaker.png", + icon_off: "rtpdisabled32.png", tip_off: "Play network stream", menuitem: "/Control/Network player", on: rtp_enabled, @@ -248,12 +235,10 @@ GtkWidget *control_widget(void) { GtkWidget *hbox = gtk_hbox_new(FALSE, 1), *vbox; int n; - NW(hbox); D(("control_widget")); assert(mainmenufactory); /* ordering must be right */ for(n = 0; n < NICONS; ++n) { /* Create the button */ - NW(button); icons[n].button = gtk_button_new(); gtk_widget_set_style(icons[n].button, tool_style); icons[n].image_on = gtk_image_new_from_pixbuf(find_image(icons[n].icon_on)); @@ -269,7 +254,6 @@ GtkWidget *control_widget(void) { G_CALLBACK(clicked_icon), &icons[n]); /* pop the icon in a vbox so it doesn't get vertically stretch if there are * taller things in the control bar */ - NW(vbox); vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), icons[n].button, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); @@ -288,19 +272,16 @@ GtkWidget *control_widget(void) { char **events = split(icons[n].events, 0, 0, 0, 0); while(*events) event_register(*events++, icon_changed, &icons[n]); + event_register("connected-changed", icon_changed, &icons[n]); } /* create the adjustments for the volume control */ - NW(adjustment); volume_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, goesupto, goesupto / 20, goesupto / 20, 0)); - NW(adjustment); balance_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.2, 0.2, 0)); /* the volume control */ - NW(hscale); volume_widget = gtk_hscale_new(volume_adj); - NW(hscale); balance_widget = gtk_hscale_new(balance_adj); gtk_widget_set_style(volume_widget, tool_style); gtk_widget_set_style(balance_widget, tool_style); @@ -308,8 +289,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 */ @@ -341,7 +322,7 @@ static void volume_changed(const char attribute((unused)) *event, ++suppress_actions; /* Only display volume/balance controls if they will work */ if(!rtp_supported - || (rtp_supported && mixer_supported(DEFAULT_BACKEND))) + || (rtp_supported && backend && backend->set_volume)) volume_supported = TRUE; else volume_supported = FALSE; @@ -366,15 +347,18 @@ static void volume_changed(const char attribute((unused)) *event, static void icon_changed(const char attribute((unused)) *event, void attribute((unused)) *evendata, void *callbackdata) { + //fprintf(stderr, "icon_changed (%s)\n", event); const struct icon *const icon = callbackdata; int on = icon->on ? icon->on() : 1; int sensitive = icon->sensitive ? icon->sensitive() : 1; + //fprintf(stderr, "sensitive->%d\n", sensitive); GtkWidget *child, *newchild; ++suppress_actions; /* If the connection is down nothing is ever usable */ if(!(last_state & DISORDER_CONNECTED)) sensitive = 0; + //fprintf(stderr, "(checked connected) sensitive->%d\n", sensitive); /* Replace the child */ newchild = on ? icon->image_on : icon->image_off; child = gtk_bin_get_child(GTK_BIN(icon->button)); @@ -386,12 +370,12 @@ static void icon_changed(const char attribute((unused)) *event, } /* If you disable play or random play NOT via the icon (for instance, via the * edit menu or via a completely separate command line invocation) then the - * icon shows up as insensitive. Hover the mouse over it and the corrcet + * icon shows up as insensitive. Hover the mouse over it and the correct * 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) { @@ -403,9 +387,9 @@ static void icon_changed(const char attribute((unused)) *event, } static void icon_action_completed(void attribute((unused)) *v, - const char *error) { - if(error) - popup_protocol_error(0, error); + const char *err) { + if(err) + popup_protocol_error(0, err); } static void clicked_icon(GtkButton attribute((unused)) *button, @@ -432,11 +416,11 @@ static void toggled_menu(GtkCheckMenuItem attribute((unused)) *menuitem, /** @brief Called when a volume command completes */ static void volume_completed(void attribute((unused)) *v, - const char *error, + const char *err, int attribute((unused)) l, int attribute((unused)) r) { - if(error) - popup_protocol_error(0, error); + if(err) + popup_protocol_error(0, err); /* We don't set the UI's notion of the volume here, it is set from the log * regardless of the reason it changed */ } @@ -459,7 +443,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),