1 /* gmpc-dynamic-playlist (GMPC plugin)
2 * Copyright (C) 2009 Andre Klitzing <andre@incubo.de>
3 * Homepage: http://www.incubo.de
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.
23 #include <glib/gi18n-lib.h>
24 #include <gmpc/status_icon.h>
27 static GtkWidget
* m_box
= NULL
;
28 static GtkWidget
* m_image
= NULL
;
30 gboolean
icon_clicked(G_GNUC_UNUSED GtkWidget
* l_widget
, GdkEventButton
* l_event
, G_GNUC_UNUSED gpointer l_data
)
32 if(l_event
->button
== 1) // left mouse button
33 set_search_active(!get_search_active());
34 else if(l_event
->button
== 2) // middle mouse button
36 else if(l_event
->button
== 3) // right mouse button
37 g_debug("todo: open popup menu");
44 static void refresh_icon_state()
46 g_assert(m_image
!= NULL
);
47 gtk_widget_set_sensitive(m_image
, get_search_active());
50 gboolean
icon_integration(G_GNUC_UNUSED gpointer l_data
)
52 g_assert(m_box
== NULL
);
53 g_assert(m_image
== NULL
);
55 m_box
= gtk_event_box_new();
56 m_image
= gtk_image_new_from_stock(GTK_STOCK_INDEX
, GTK_ICON_SIZE_MENU
);
57 gtk_container_add(GTK_CONTAINER(m_box
), m_image
);
58 gtk_widget_set_tooltip_text(m_box
, _("Dynamic Playlist"));
59 g_signal_connect(G_OBJECT(m_box
), "button-release-event", G_CALLBACK(icon_clicked
), NULL
);
62 gtk_widget_show_all(m_box
);
63 main_window_add_status_icon(m_box
);
68 gboolean
is_icon_added()
73 gboolean
is_grayed_out()
75 g_assert(m_image
!= NULL
);
76 return gtk_widget_get_sensitive(m_image
);
81 icon_integration(NULL
);
86 g_assert(m_box
!= NULL
);
87 g_assert(m_image
!= NULL
);
89 gtk_widget_destroy(m_box
);
103 else if(is_icon_added())
109 icon_integration(NULL
);
112 /* vim:set ts=4 sw=4: */