# HG changeset patch # User William Pitcock # Date 1186760789 18000 # Node ID 4400659c1ea68bf224ad2ddeaa28c16de03a5a42 # Parent 2aed30eaca87d692194c1b8a58a6e5740f32bed5# Parent b5b2573db5c2622d4f9cba031e97335167a0f126 Automated merge with ssh://hg.atheme.org//hg/audacious diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/Makefile --- a/src/audacious/Makefile Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/Makefile Fri Aug 10 10:46:29 2007 -0500 @@ -55,6 +55,7 @@ tuple_formatter.h \ ui_fileinfopopup.h \ ui_lastfm.h\ + ui_plugin_menu.h \ ui_preferences.h \ util.h \ vfs.h \ diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/main.c --- a/src/audacious/main.c Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/main.c Fri Aug 10 10:46:29 2007 -0500 @@ -1193,6 +1193,16 @@ init_dbus(); #endif mowgli_init(); + + if (options.headless != 1) + { + /* UIManager + NOTE: this needs to be called before plugin init, cause + plugin init functions may want to add custom menu entries */ + ui_manager_init(); + ui_manager_create_menus(); + } + plugin_system_init(); /* Initialize the playlist system. */ @@ -1207,10 +1217,6 @@ gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); - /* uimanager */ - ui_manager_init(); - ui_manager_create_menus(); - if (!init_skins(cfg.skin)) { run_load_skin_error_dialog(cfg.skin); exit(EXIT_FAILURE); diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/skin.c --- a/src/audacious/skin.c Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/skin.c Fri Aug 10 10:46:29 2007 -0500 @@ -173,6 +173,11 @@ playlistwin_update_list(playlist_get_active()); + SkinPixmap *pixmap; + pixmap = &bmp_active_skin->pixmaps[SKIN_POSBAR]; + /* last 59 pixels of SKIN_POSBAR are knobs (normal and selected) */ + gtk_widget_set_size_request(mainwin_position, pixmap->width - 59, pixmap->height); + return TRUE; } @@ -1639,9 +1644,6 @@ gdk_draw_drawable(drawable, gc, skin_get_pixmap(bmp_active_skin, SKIN_MAIN)->pixmap, 212 + xdest, 41, xdest, ydest, width, height); height = pixmap->height/2; - } else if (pixmap_id == SKIN_POSBAR) { - /* last 59 pixels of SKIN_POSBAR are knobs (normal and selected) */ - gtk_widget_set_size_request(mainwin_position, pixmap->width - 59, pixmap->height); } else return; } diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/ui/mainwin.ui --- a/src/audacious/ui/mainwin.ui Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/ui/mainwin.ui Fri Aug 10 10:46:29 2007 -0500 @@ -128,6 +128,10 @@ + + + + diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/ui/playlist.ui --- a/src/audacious/ui/playlist.ui Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/ui/playlist.ui Fri Aug 10 10:46:29 2007 -0500 @@ -78,6 +78,11 @@ + + + + + diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/ui_manager.c --- a/src/audacious/ui_manager.c Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/ui_manager.c Fri Aug 10 10:46:29 2007 -0500 @@ -26,6 +26,9 @@ #include "actions-playlist.h" #include "actions-equalizer.h" +/* this header contains prototypes for plugin-available menu functions */ +#include "ui_plugin_menu.h" + /* TODO ui_main.h is only included because ui_manager.c needs the values of TimerMode enum; move that enum elsewhere so we can get rid of this include */ #include "ui_main.h" @@ -33,7 +36,8 @@ #include "icons-stock.h" -static GtkUIManager *ui_manager; +static GtkUIManager *ui_manager = NULL; +static gboolean menu_created = FALSE; /* toggle action entries */ @@ -396,6 +400,8 @@ { "lastfm", NULL, N_("Last.fm radio"), "L", N_("Play Last.fm radio"), G_CALLBACK(action_lastfm) }, + { "plugins", NULL , N_("Plugins") }, + { "preferences", GTK_STOCK_PREFERENCES , N_("Preferences"), "P", N_("Open preferences window"), G_CALLBACK(action_preferences) }, @@ -625,6 +631,29 @@ } +static void +ui_manager_create_menus_init_pmenu( gchar * path ) +{ + GtkWidget *plugins_menu, *plugins_menu_item, *plugins_dummy_item; + GList *plugins_menu_children = NULL; + gchar *path_dummy = g_strjoin( NULL , path , "/plugins-menu-dummy" , NULL ); + /* remove the dummy item placed in plugins-menu as a workaround */ + plugins_dummy_item = gtk_ui_manager_get_widget( ui_manager , path_dummy ); + if ( plugins_dummy_item ) + gtk_widget_destroy( plugins_dummy_item ); + /* take note of the initial count of items in the "empty" plugins-menu */ + plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , path ); + plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + plugins_menu_children = gtk_container_get_children( GTK_CONTAINER(plugins_menu) ); + g_object_set_data( G_OBJECT(plugins_menu) , "ic" , GINT_TO_POINTER(g_list_length(plugins_menu_children)) ); + g_list_free( plugins_menu_children ); + /* last, hide the plugins-menu by default */ + gtk_widget_hide( plugins_menu_item ); + g_free( path_dummy ); + return; +} + + void ui_manager_create_menus ( void ) { @@ -648,6 +677,9 @@ mainwin_view_menu = ui_manager_get_popup_menu( ui_manager , "/mainwin-menus/main-menu/view" ); mainwin_general_menu = ui_manager_get_popup_menu( ui_manager , "/mainwin-menus/main-menu" ); + /* initialize plugins-menu for mainwin-menus */ + ui_manager_create_menus_init_pmenu( "/mainwin-menus/main-menu/plugins-menu" ); + gtk_ui_manager_add_ui_from_file( ui_manager , DATA_DIR "/ui/playlist.ui" , &gerr ); if ( gerr != NULL ) @@ -665,6 +697,9 @@ playlistwin_plsort_menu = ui_manager_get_popup_menu(ui_manager, "/playlist-menus/misc-menu"); playlistwin_pllist_menu = ui_manager_get_popup_menu(ui_manager, "/playlist-menus/playlist-menu"); + /* initialize plugins-menu for playlist-menus */ + ui_manager_create_menus_init_pmenu( "/playlist-menus/playlist-menu/plugins-menu" ); + gtk_ui_manager_add_ui_from_file( ui_manager , DATA_DIR "/ui/equalizer.ui" , &gerr ); if ( gerr != NULL ) @@ -676,6 +711,8 @@ equalizerwin_presets_menu = ui_manager_get_popup_menu(ui_manager, "/equalizer-menus/preset-menu"); + menu_created = TRUE; + return; } @@ -728,3 +765,96 @@ gtk_menu_popup( menu , NULL , NULL , (GtkMenuPositionFunc) menu_popup_pos_func , pos , button , time ); } + + + +/******************************/ +/* plugin-available functions */ + + +gint +audacious_menu_plugin_item_add( gint menu_id , GtkWidget * item ) +{ + if ( menu_created ) + { + switch (menu_id) + { + case AUDACIOUS_MENU_MAIN: + { + GtkWidget *plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , + "/mainwin-menus/main-menu/plugins-menu" ); + GtkWidget *plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + gtk_menu_shell_append( GTK_MENU_SHELL(plugins_menu) , item ); + gtk_widget_show( plugins_menu_item ); + return 0; + } + + case AUDACIOUS_MENU_PLAYLIST: + { + GtkWidget *plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , + "/playlist-menus/playlist-menu/plugins-menu" ); + GtkWidget *plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + gtk_menu_shell_append( GTK_MENU_SHELL(plugins_menu) , item ); + gtk_widget_show( plugins_menu_item ); + return 0; + } + + default: + return -1; + } + } + else + return -1; +} + + +gint +audacious_menu_plugin_item_remove( gint menu_id , GtkWidget * item ) +{ + if ( menu_created ) + { + GtkWidget *plugins_menu = NULL; + GtkWidget *plugins_menu_item = NULL; + GList *plugins_menu_children = NULL; + + switch (menu_id) + { + case AUDACIOUS_MENU_MAIN: + { + plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , + "/mainwin-menus/main-menu/plugins-menu" ); + plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + gtk_container_remove( GTK_CONTAINER(plugins_menu) , item ); + break; + } + + case AUDACIOUS_MENU_PLAYLIST: + { + plugins_menu_item = gtk_ui_manager_get_widget( ui_manager , + "/playlist-menus/playlist-menu/plugins-menu" ); + plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + gtk_container_remove( GTK_CONTAINER(plugins_menu) , item ); + break; + } + + default: + return -1; + } + + if ( plugins_menu ) + { + /* check the current number of items in plugins-menu against its initial count + of items; if these are equal, it means that the menu is "empty", so hide it */ + gint ic = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(plugins_menu),"ic")); + plugins_menu_children = gtk_container_get_children( GTK_CONTAINER(plugins_menu) ); + if ( ic == g_list_length(plugins_menu_children) ) + gtk_widget_hide( plugins_menu_item ); + g_list_free( plugins_menu_children ); + return 0; + } + else + return -1; + } + else + return -1; +} diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/ui_plugin_menu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_plugin_menu.h Fri Aug 10 10:46:29 2007 -0500 @@ -0,0 +1,38 @@ +/* Audacious - Cross-platform multimedia player + * Copyright (C) 2005-2007 Audacious development team. + * + * 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; under version 3 of the License. + * + * 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, see . + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +/* these functions are currently implemented in ui_manager.c */ + +#ifndef AUD_UIPLUGINMENU_H +#define AUD_UIPLUGINMENU_H + + +#include +#include +#include + + +#define AUDACIOUS_MENU_MAIN 0 +#define AUDACIOUS_MENU_PLAYLIST 1 + +gint audacious_menu_plugin_item_add( gint , GtkWidget * ); +gint audacious_menu_plugin_item_remove( gint , GtkWidget * ); + + +#endif /* AUD_UIPLUGINMENU_H */ diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/ui_skinned_horizontal_slider.c --- a/src/audacious/ui_skinned_horizontal_slider.c Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/ui_skinned_horizontal_slider.c Fri Aug 10 10:46:29 2007 -0500 @@ -219,6 +219,11 @@ widget->allocation = *allocation; widget->allocation.x *= (1+priv->double_size); widget->allocation.y *= (1+priv->double_size); + if (priv->knob_height == priv->height) + priv->knob_height = allocation->height; + priv->width = allocation->width; + priv->height = allocation->height; + if (GTK_WIDGET_REALIZED (widget)) gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); diff -r 2aed30eaca87 -r 4400659c1ea6 src/audacious/util.h --- a/src/audacious/util.h Fri Aug 10 10:46:22 2007 -0500 +++ b/src/audacious/util.h Fri Aug 10 10:46:29 2007 -0500 @@ -115,8 +115,10 @@ gchar *audacious_get_localdir(void); +/* menu-related function */ void audacious_menu_main_show(gint x, gint y, guint button, guint time); + G_END_DECLS #endif