/* * Copyright 2004, 2005 Mark Raddatz * Copyright 2000, 2001, 2002 Ian Campbell * * 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 * (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. * * 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 */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include #include #include #include "eggtrayicon.h" #include "bmp_player.xpm" #include "about.h" #include "tooltips.h" #include "menu.h" #include "mixer.h" static void docklet_plugin_init (void); static void docklet_plugin_cleanup (void); GeneralPlugin docklet_plugin = { NULL, NULL, -1, "Docklet Plugin", docklet_plugin_init, docklet_plugin_about, NULL, docklet_plugin_cleanup }; EggTrayIcon *docklet = NULL; GtkWidget *docklet_box; gboolean playlist_was_shown; gboolean eq_was_shown; GeneralPlugin * get_gplugin_info (void) { return &docklet_plugin; } void toggle_all_windows (void) { gboolean window_shown; window_shown = xmms_remote_is_main_win (docklet_plugin.xmms_session); if (window_shown) { // hide windows playlist_was_shown = xmms_remote_is_pl_win (docklet_plugin.xmms_session); eq_was_shown = xmms_remote_is_eq_win (docklet_plugin.xmms_session); if (playlist_was_shown) xmms_remote_pl_win_toggle (docklet_plugin.xmms_session, !playlist_was_shown); if (eq_was_shown) xmms_remote_eq_win_toggle (docklet_plugin.xmms_session, !eq_was_shown); xmms_remote_main_win_toggle (docklet_plugin.xmms_session, !window_shown); } else { // restore windows xmms_remote_main_win_toggle (docklet_plugin.xmms_session, !window_shown); if (eq_was_shown) xmms_remote_eq_win_toggle (docklet_plugin.xmms_session, eq_was_shown); if (playlist_was_shown) xmms_remote_pl_win_toggle (docklet_plugin.xmms_session, playlist_was_shown); } } void docklet_clicked_cb (GtkWidget * button, GdkEventButton * event, void *data) { switch (event->button) { case 1: toggle_all_windows (); break; case 3: docklet_menu_show (event); break; } } static void docklet_plugin_init (void) { GdkPixbuf *icon, *icon_small; GtkWidget *image; #ifdef ENABLE_NLS setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALE_DIR); bind_textdomain_codeset (PACKAGE, "UTF-8"); textdomain (PACKAGE); #endif docklet = egg_tray_icon_new ("bmp"); /* create icon image */ icon = gdk_pixbuf_new_from_xpm_data ((const gchar **) bmp_player_icon); icon_small = gdk_pixbuf_scale_simple (icon, 22, 22, GDK_INTERP_BILINEAR); image = gtk_image_new_from_pixbuf (icon_small); g_object_unref (G_OBJECT (icon)); g_object_unref (G_OBJECT (icon_small)); docklet_box = gtk_event_box_new (); g_signal_connect (G_OBJECT (docklet_box), "button-press-event", G_CALLBACK (docklet_clicked_cb), NULL); gtk_container_add (GTK_CONTAINER (docklet_box), image); gtk_container_add (GTK_CONTAINER (docklet), docklet_box); docklet_tooltips_init (); docklet_mixer_init (); gtk_widget_show_all (GTK_WIDGET (docklet)); } static void docklet_plugin_cleanup (void) { docklet_tooltips_cleanup (); docklet_menu_cleanup (); if (docklet != NULL) { gtk_widget_destroy (GTK_WIDGET (docklet)); docklet = NULL; } }