/* Forward declarations ---------------------------------------------------- */
-WT(adjustment);
-WT(hscale);
-WT(hbox);
-WT(button);
-WT(image);
-WT(label);
-WT(vbox);
-
struct icon;
static void clicked_icon(GtkButton *, gpointer);
GtkWidget *image_off;
};
-/* TODO: Add rights into the mix below */
-
static int pause_resume_on(void) {
return !(last_state & DISORDER_TRACK_PAUSED);
}
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));
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);
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);
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));
gtk_container_add(GTK_CONTAINER(icon->button), newchild);
gtk_widget_show(newchild);
}
+ /* 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 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, "");
}
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,
/** @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 */
}