changeset 3371:973cf1ae043a trunk

it's now possible to add plugin menuentries in playlist add, del, select and misc popup menus
author Giacomo Lozito <james@develia.org>
date Sun, 19 Aug 2007 14:39:05 +0200
parents dbca6c49bdff
children 1b0db603df9d
files src/audacious/ui/playlist.ui src/audacious/ui_manager.c src/audacious/ui_plugin_menu.h
diffstat 3 files changed, 49 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui/playlist.ui	Sun Aug 19 14:10:50 2007 +0200
+++ b/src/audacious/ui/playlist.ui	Sun Aug 19 14:39:05 2007 +0200
@@ -17,6 +17,8 @@
 		<menu action="dummy" name="add-menu">
 			<menuitem action="playlist add url" />
 			<menuitem action="playlist add files" />
+			<separator />
+			<menuitem action="plugins-menu" />
 		</menu>
 
 		<menu action="dummy" name="del-menu">
@@ -32,6 +34,8 @@
 			<menuitem action="playlist remove all" />
 			<menuitem action="playlist remove unselected" />
 			<menuitem action="playlist remove selected" />
+			<separator />
+			<menuitem action="plugins-menu" />
 		</menu>
 
 		<menu action="dummy" name="select-menu">
@@ -41,6 +45,8 @@
 			<separator />
 			<menuitem action="playlist select none" />
 			<menuitem action="playlist select all" />
+			<separator />
+			<menuitem action="plugins-menu" />
 		</menu>
 
 		<menu action="dummy" name="misc-menu">
@@ -65,6 +71,8 @@
 				<menuitem action="playlist sort selected by track number" />
 				<menuitem action="playlist sort selected by playlist entry" />
 			</menu>
+			<separator />
+			<menuitem action="plugins-menu" />
 		</menu>
 
 		<menu action="dummy" name="playlist-menu">
--- a/src/audacious/ui_manager.c	Sun Aug 19 14:10:50 2007 +0200
+++ b/src/audacious/ui_manager.c	Sun Aug 19 14:39:05 2007 +0200
@@ -629,12 +629,14 @@
 static void
 ui_manager_create_menus_init_pmenu( gchar * path )
 {
-  GtkWidget *plugins_menu_item;
-  plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , path );
-  /* initially set count of items under plugins_menu_item to 0 */
-  g_object_set_data( G_OBJECT(plugins_menu_item) , "ic" , GINT_TO_POINTER(0) );
-  /* and since it's 0, hide the plugins_menu_item */
-  gtk_widget_hide( plugins_menu_item );
+  GtkWidget *plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , path );
+  if ( plugins_menu_item )
+  {
+    /* initially set count of items under plugins_menu_item to 0 */
+    g_object_set_data( G_OBJECT(plugins_menu_item) , "ic" , GINT_TO_POINTER(0) );
+    /* and since it's 0, hide the plugins_menu_item */
+    gtk_widget_hide( plugins_menu_item );
+  }
   return;
 }
 
@@ -684,6 +686,10 @@
 
   /* initialize plugins-menu for playlist-menus */
   ui_manager_create_menus_init_pmenu( "/playlist-menus/playlist-menu/plugins-menu" );
+  ui_manager_create_menus_init_pmenu( "/playlist-menus/add-menu/plugins-menu" );
+  ui_manager_create_menus_init_pmenu( "/playlist-menus/del-menu/plugins-menu" );
+  ui_manager_create_menus_init_pmenu( "/playlist-menus/select-menu/plugins-menu" );
+  ui_manager_create_menus_init_pmenu( "/playlist-menus/misc-menu/plugins-menu" );
   ui_manager_create_menus_init_pmenu( "/playlist-menus/playlist-rightclick-menu/plugins-menu" );
 
   gtk_ui_manager_add_ui_from_file( ui_manager , DATA_DIR "/ui/equalizer.ui" , &gerr );
@@ -757,6 +763,32 @@
 /******************************/
 /* plugin-available functions */
 
+#define _MP_GWID(y) gtk_ui_manager_get_widget( ui_manager , y )
+
+static GtkWidget*
+audacious_menu_plugin_menuwid( menu_id )
+{
+  switch (menu_id)
+  {
+    case AUDACIOUS_MENU_MAIN:
+      return _MP_GWID("/mainwin-menus/main-menu/plugins-menu");
+    case AUDACIOUS_MENU_PLAYLIST:
+      return _MP_GWID("/playlist-menus/playlist-menu/plugins-menu");
+    case AUDACIOUS_MENU_PLAYLIST_RCLICK:
+      return _MP_GWID("/playlist-menus/playlist-rightclick-menu/plugins-menu");
+    case AUDACIOUS_MENU_PLAYLIST_ADD:
+      return _MP_GWID("/playlist-menus/add-menu/plugins-menu");
+    case AUDACIOUS_MENU_PLAYLIST_REMOVE:
+      return _MP_GWID("/playlist-menus/del-menu/plugins-menu");
+    case AUDACIOUS_MENU_PLAYLIST_SELECT:
+      return _MP_GWID("/playlist-menus/select-menu/plugins-menu");
+    case AUDACIOUS_MENU_PLAYLIST_MISC:
+      return _MP_GWID("/playlist-menus/misc-menu/plugins-menu");
+    default:
+      return NULL;
+  }
+}
+
 
 gint
 audacious_menu_plugin_item_add( gint menu_id , GtkWidget * item )
@@ -764,28 +796,7 @@
   if ( menu_created )
   {
     GtkWidget *plugins_menu = NULL;
-    GtkWidget *plugins_menu_item = NULL;
-
-    switch (menu_id)
-    {
-      case AUDACIOUS_MENU_MAIN:
-        plugins_menu_item = gtk_ui_manager_get_widget( ui_manager ,
-          "/mainwin-menus/main-menu/plugins-menu" );
-        break;
-
-      case AUDACIOUS_MENU_PLAYLIST:
-        plugins_menu_item = gtk_ui_manager_get_widget( ui_manager ,
-          "/playlist-menus/playlist-menu/plugins-menu" );
-        break;
-
-      case AUDACIOUS_MENU_PLAYLIST_RCLICK:
-        plugins_menu_item = gtk_ui_manager_get_widget( ui_manager ,
-          "/playlist-menus/playlist-rightclick-menu/plugins-menu" );
-        break;
-
-      default:
-        return -1;
-    }
+    GtkWidget *plugins_menu_item = audacious_menu_plugin_menuwid( menu_id );
 
     if ( plugins_menu_item )
     {
@@ -819,28 +830,7 @@
   if ( menu_created )
   {
     GtkWidget *plugins_menu = NULL;
-    GtkWidget *plugins_menu_item = NULL;
-
-    switch (menu_id)
-    {
-      case AUDACIOUS_MENU_MAIN:
-        plugins_menu_item = gtk_ui_manager_get_widget( ui_manager ,
-          "/mainwin-menus/main-menu/plugins-menu" );
-        break;
-
-      case AUDACIOUS_MENU_PLAYLIST:
-        plugins_menu_item = gtk_ui_manager_get_widget( ui_manager ,
-          "/playlist-menus/playlist-menu/plugins-menu" );
-        break;
-
-      case AUDACIOUS_MENU_PLAYLIST_RCLICK:
-        plugins_menu_item = gtk_ui_manager_get_widget( ui_manager ,
-          "/playlist-menus/playlist-rightclick-menu/plugins-menu" );
-        break;
-
-      default:
-        return -1;
-    }
+    GtkWidget *plugins_menu_item = audacious_menu_plugin_menuwid( menu_id );
 
     if ( plugins_menu_item )
     {
--- a/src/audacious/ui_plugin_menu.h	Sun Aug 19 14:10:50 2007 +0200
+++ b/src/audacious/ui_plugin_menu.h	Sun Aug 19 14:39:05 2007 +0200
@@ -34,7 +34,7 @@
 #define AUDACIOUS_MENU_PLAYLIST_ADD     3
 #define AUDACIOUS_MENU_PLAYLIST_REMOVE  4
 #define AUDACIOUS_MENU_PLAYLIST_SELECT  5
-#define AUDACIOUS_MENU_PLAYLIST_SORT    6
+#define AUDACIOUS_MENU_PLAYLIST_MISC    6
 
 gint audacious_menu_plugin_item_add( gint , GtkWidget * );
 gint audacious_menu_plugin_item_remove( gint , GtkWidget * );