Audacious
$Id:Doxyfile42802007-03-2104:39:00Znenolod$
|
00001 /* 00002 * ui_plugin_menu.c 00003 * Copyright 2009-2010 John Lindgren 00004 * 00005 * This file is part of Audacious. 00006 * 00007 * Audacious is free software: you can redistribute it and/or modify it under 00008 * the terms of the GNU General Public License as published by the Free Software 00009 * Foundation, version 3 of the License. 00010 * 00011 * Audacious is distributed in the hope that it will be useful, but WITHOUT ANY 00012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00013 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along with 00016 * Audacious. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 * The Audacious team does not consider modular code linking to Audacious or 00019 * using our public API to be a derived work. 00020 */ 00021 00022 #include <glib.h> 00023 #include <gtk/gtk.h> 00024 00025 #include "misc.h" 00026 00027 static void destroy_warning (void) 00028 { 00029 fprintf (stderr, "Interface destroyed a plugin services menu!\n"); 00030 } 00031 00032 /* GtkWidget * get_plugin_menu (gint id) */ 00033 void * get_plugin_menu (gint id) 00034 { 00035 static gboolean initted = FALSE; 00036 static GtkWidget * menus[TOTAL_PLUGIN_MENUS]; 00037 00038 if (! initted) 00039 { 00040 memset (menus, 0, sizeof menus); 00041 initted = TRUE; 00042 } 00043 00044 if (menus[id] == NULL) 00045 { 00046 menus[id] = gtk_menu_new (); 00047 g_object_ref ((GObject *) menus[id]); 00048 g_signal_connect (menus[id], "destroy", (GCallback) destroy_warning, 00049 NULL); 00050 gtk_widget_show (menus[id]); 00051 } 00052 00053 return menus[id]; 00054 } 00055 00056 /* gint menu_plugin_item_add (gint id, GtkWidget * item) */ 00057 gint menu_plugin_item_add (gint id, void * item) 00058 { 00059 gtk_menu_shell_append ((GtkMenuShell *) get_plugin_menu (id), item); 00060 return 0; 00061 } 00062 00063 /* gint menu_plugin_item_remove (gint id, GtkWidget * item) */ 00064 gint menu_plugin_item_remove (gint id, void * item) 00065 { 00066 gtk_container_remove ((GtkContainer *) get_plugin_menu (id), item); 00067 return 0; 00068 }