1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "gmpc-extras.h"
23 #include "playlist3.h"
25 #include "status_icon.h"
30 static GtkWidget
*si_repeat
= NULL
;
31 static GtkWidget
*si_consume
= NULL
;
32 static GtkWidget
*si_repeat_single
= NULL
;
33 static GtkWidget
*si_random
= NULL
;
35 void main_window_update_status_icons(void)
39 GtkWidget
*image
= gtk_bin_get_child(GTK_BIN(si_repeat_single
));
40 if (mpd_check_connected(connection
) && mpd_player_get_single(connection
))
42 gtk_widget_set_sensitive(GTK_WIDGET(image
), TRUE
);
43 gtk_widget_set_tooltip_text(si_repeat_single
, _("Single Mode enabled"));
46 gtk_widget_set_sensitive(GTK_WIDGET(image
), FALSE
);
47 gtk_widget_set_tooltip_text(si_repeat_single
, _("Single Mode disabled"));
52 GtkWidget
*image
= gtk_bin_get_child(GTK_BIN(si_consume
));
53 if (mpd_check_connected(connection
) && mpd_player_get_consume(connection
))
55 gtk_widget_set_sensitive(GTK_WIDGET(image
), TRUE
);
56 gtk_widget_set_tooltip_text(si_consume
, _("Consume Mode enabled"));
59 gtk_widget_set_sensitive(GTK_WIDGET(image
), FALSE
);
60 gtk_widget_set_tooltip_text(si_consume
, _("Consume Mode disabled"));
65 GtkWidget
*image
= gtk_bin_get_child(GTK_BIN(si_repeat
));
66 if (mpd_check_connected(connection
) && mpd_player_get_repeat(connection
))
68 gtk_widget_set_sensitive(GTK_WIDGET(image
), TRUE
);
69 gtk_widget_set_tooltip_text(si_repeat
, _("Repeat enabled"));
72 gtk_widget_set_sensitive(GTK_WIDGET(image
), FALSE
);
73 gtk_widget_set_tooltip_text(si_repeat
, _("Repeat disabled"));
78 GtkWidget
*image
= gtk_bin_get_child(GTK_BIN(si_random
));
79 if (mpd_check_connected(connection
) && mpd_player_get_random(connection
))
81 gtk_widget_set_sensitive(GTK_WIDGET(image
), TRUE
);
82 gtk_widget_set_tooltip_text(si_random
, _("Random enabled"));
85 gtk_widget_set_sensitive(GTK_WIDGET(image
), FALSE
);
86 gtk_widget_set_tooltip_text(si_random
, _("Random disabled"));
92 void main_window_add_status_icon(GtkWidget
* icon
)
94 GtkWidget
*hbox
= GTK_WIDGET(gtk_builder_get_object(pl3_xml
, "status_icon_box"));
95 g_return_if_fail(icon
!= NULL
);
96 // gtk_box_pack_end(GTK_BOX(hbox), icon, FALSE, TRUE, 0);
97 gtk_container_add(GTK_CONTAINER(hbox
), icon
);
98 gtk_widget_show(icon
);
99 gtk_widget_show(hbox
);
102 void main_window_init_default_status_icons(void)
104 si_repeat
= gtk_event_box_new();
106 g_signal_connect(G_OBJECT(si_repeat
), "button-release-event", G_CALLBACK(repeat_toggle
), NULL
);
107 gtk_container_add(GTK_CONTAINER(si_repeat
), gtk_image_new_from_icon_name("stock_repeat", GTK_ICON_SIZE_MENU
));
108 gtk_widget_show_all(si_repeat
);
109 main_window_add_status_icon(si_repeat
);
111 si_random
= gtk_event_box_new();
114 g_signal_connect(G_OBJECT(si_random
), "button-release-event", G_CALLBACK(random_toggle
), NULL
);
115 gtk_container_add(GTK_CONTAINER(si_random
), gtk_image_new_from_icon_name("stock_shuffle", GTK_ICON_SIZE_MENU
));
116 gtk_widget_show_all(si_random
);
117 main_window_add_status_icon(si_random
);
119 si_repeat_single
= gtk_event_box_new();
122 g_signal_connect(G_OBJECT(si_repeat_single
), "button-release-event", G_CALLBACK(repeat_single_toggle
), NULL
);
123 gtk_container_add(GTK_CONTAINER(si_repeat_single
),
124 gtk_image_new_from_icon_name("media-repeat-single", GTK_ICON_SIZE_MENU
));
125 gtk_widget_show_all(si_repeat_single
);
126 main_window_add_status_icon(si_repeat_single
);
128 si_consume
= gtk_event_box_new();
130 g_signal_connect(G_OBJECT(si_consume
), "button-release-event", G_CALLBACK(consume_toggle
), NULL
);
131 gtk_container_add(GTK_CONTAINER(si_consume
), gtk_image_new_from_icon_name("media-consume", GTK_ICON_SIZE_MENU
));
132 gtk_widget_show_all(si_consume
);
133 main_window_add_status_icon(si_consume
);