3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "eggtrayicon.h"
27 // this gets called regularly by gtk
29 stdin_callback(GIOChannel *channel, GIOCondition cond, gpointer data) {
36 widget = GTK_WIDGET(data);
38 if (widget->window == NULL) {
42 ret = g_io_channel_read_line(
44 &(playing[playing_i]),
49 if (ret == G_IO_STATUS_ERROR) {
50 g_error ("Error reading: %s\n", error->message);
59 playing[playing_i][terminator_pos] = 0;
63 if(strcmp(playing[0], playing[1])) {
64 gtk_label_set_text(GTK_LABEL(widget), playing[playing_i]);
67 playing_i = 1 - playing_i;
68 g_free(playing[playing_i]);
70 // gtk_widget_queue_draw(widget);
76 main(int argc, char *argv[]) {
83 gtk_init(&argc, &argv);
87 playing[1] = g_strdup("");
90 label = gtk_label_new("");
91 egg = egg_tray_icon_new("what's this string do?");
92 // nest and display the widget
93 gtk_container_add(GTK_CONTAINER(egg), label);
94 gtk_widget_show_all(GTK_WIDGET(egg));
97 channel = g_io_channel_unix_new(fileno(stdin));
98 g_io_channel_set_encoding(channel, NULL, NULL); // kiss
99 g_io_add_watch(channel, G_IO_IN, stdin_callback, (gpointer)label);