# HG changeset patch # User Tomasz Mon # Date 1211366260 -7200 # Node ID 7cd898f08f31d259b0382e49eaaf1a007aec7089 # Parent f9ccfae6a5f63477cd4d5b79c9517f2152df8cdb work in progress - add ui_manager and ui_main_evlisteners diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/Makefile --- a/src/skins/Makefile Wed May 21 09:08:05 2008 +0300 +++ b/src/skins/Makefile Wed May 21 12:37:40 2008 +0200 @@ -17,13 +17,16 @@ ui_skinned_number.c \ ui_skinned_horizontal_slider.c \ ui_skinned_equalizer_graph.c \ - ui_main.c + ui_main.c \ + ui_main_evlisteners.c \ + ui_manager.c \ + icons-stock.c include ../../buildsys.mk include ../../extra.mk plugindir := ${plugindir}/${GENERAL_PLUGIN_DIR} -CFLAGS += ${PLUGIN_CFLAGS} -DDATA_DIR="/usr/local/share/audacious" +CFLAGS += ${PLUGIN_CFLAGS} CPPFLAGS += ${PLUGIN_CPPFLAGS} ${MOWGLI_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${PANGO_CFLAGS} ${CAIRO_CFLAGS} ${PANGOCAIRO_CFLAGS} ${XRENDER_CFLAGS} ${XCOMPOSITE_CFLAGS} -I../.. LIBS += ${GTK_LIBS} ${GLIB_LIBS} ${PANGO_LIBS} ${CAIRO_LIBS} ${PANGOCAIRO_LIBS} ${XRENDER_LIBS} ${XCOMPOSITE_LIBS} diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/actions-equalizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/actions-equalizer.h Wed May 21 12:37:40 2008 +0200 @@ -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. + */ + +#ifndef AUDACIOUS_ACTIONS_EQUALIZER_H +#define AUDACIOUS_ACTIONS_EQUALIZER_H + +void action_equ_load_preset(void); +void action_equ_load_auto_preset(void); +void action_equ_load_default_preset(void); +void action_equ_zero_preset(void); +void action_equ_load_preset_file(void); +void action_equ_load_preset_eqf(void); +void action_equ_import_winamp_presets(void); +void action_equ_save_preset(void); +void action_equ_save_auto_preset(void); +void action_equ_save_default_preset(void); +void action_equ_save_preset_file(void); +void action_equ_save_preset_eqf(void); +void action_equ_delete_preset(void); +void action_equ_delete_auto_preset(void); + +#endif /* AUDACIOUS_ACTIONS_EQUALIZER_H */ diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/actions-mainwin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/actions-mainwin.h Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,76 @@ +/* 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. + */ + +#ifndef AUDACIOUS_ACTIONS_MAINWIN_H +#define AUDACIOUS_ACTIONS_MAINWIN_H + +#include +#include + +/* actions below are handled in mainwin.c */ + + +/* toggle actions */ +void action_anamode_peaks(GtkToggleAction*); +void action_autoscroll_songname(GtkToggleAction*); +void action_playback_noplaylistadvance(GtkToggleAction*); +void action_playback_repeat(GtkToggleAction*); +void action_playback_shuffle(GtkToggleAction*); +void action_stop_after_current_song(GtkToggleAction*); +void action_view_always_on_top(GtkToggleAction*); +void action_view_scaled(GtkToggleAction*); +void action_view_easymove(GtkToggleAction*); +void action_view_on_all_workspaces(GtkToggleAction*); +void action_roll_up_equalizer(GtkToggleAction*); +void action_roll_up_player(GtkToggleAction*); +void action_roll_up_playlist_editor(GtkToggleAction*); +void action_show_equalizer(GtkToggleAction*); +void action_show_player(GtkToggleAction*); +void action_show_playlist_editor(GtkToggleAction*); + +/* radio actions (one for each radio action group) */ +void action_anafoff(GtkAction*,GtkRadioAction*); +void action_anamode(GtkAction*,GtkRadioAction*); +void action_anatype(GtkAction*,GtkRadioAction*); +void action_peafoff(GtkAction*,GtkRadioAction*); +void action_refrate(GtkAction*,GtkRadioAction*); +void action_scomode(GtkAction*,GtkRadioAction*); +void action_vismode(GtkAction*,GtkRadioAction*); +void action_vprmode(GtkAction*,GtkRadioAction*); +void action_wshmode(GtkAction*,GtkRadioAction*); +void action_viewtime(GtkAction*,GtkRadioAction*); + +/* normal actions */ +void action_about_audacious(void); +void action_ab_clear(void); +void action_ab_set(void); +void action_jump_to_file(void); +void action_jump_to_playlist_start(void); +void action_jump_to_time(void); +void action_play_file(void); +void action_play_location(void); +void action_playback_next(void); +void action_playback_pause(void); +void action_playback_play(void); +void action_playback_previous(void); +void action_playback_stop(void); +void action_preferences(void); +void action_quit(void); +void action_current_track_info(void); +#endif /* AUDACIOUS_ACTIONS_MAINWIN_H */ diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/actions-playlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/actions-playlist.h Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,74 @@ +/* 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. + */ + +#ifndef AUDACIOUS_ACTIONS_PLAYLIST_H +#define AUDACIOUS_ACTIONS_PLAYLIST_H + +void action_playlist_load_list(void); +void action_playlist_save_list(void); +void action_playlist_save_default_list(void); +void action_playlist_refresh_list(void); +void action_open_list_manager(void); + +void action_playlist_prev(void); +void action_playlist_new(void); +void action_playlist_next(void); +void action_playlist_delete(void); + +void action_playlist_search_and_select(void); +void action_playlist_invert_selection(void); +void action_playlist_select_all(void); +void action_playlist_select_none(void); + +void action_playlist_clear_queue(void); +void action_playlist_remove_unavailable(void); +void action_playlist_remove_dupes_by_title(void); +void action_playlist_remove_dupes_by_filename(void); +void action_playlist_remove_dupes_by_full_path(void); +void action_playlist_remove_all(void); +void action_playlist_remove_selected(void); +void action_playlist_remove_unselected(void); + +/* void action_playlist_add_cd(void); - this is no longer needed, as the respective menu entry is added from within the cdaudio plugin */ +void action_playlist_add_url(void); +void action_playlist_add_files(void); + +void action_playlist_randomize_list(void); +void action_playlist_reverse_list(void); + +void action_playlist_sort_by_title(void); +void action_playlist_sort_by_artist(void); +void action_playlist_sort_by_filename(void); +void action_playlist_sort_by_full_path(void); +void action_playlist_sort_by_date(void); +void action_playlist_sort_by_track_number(void); +void action_playlist_sort_by_playlist_entry(void); + +void action_playlist_sort_selected_by_title(void); +void action_playlist_sort_selected_by_artist(void); +void action_playlist_sort_selected_by_filename(void); +void action_playlist_sort_selected_by_full_path(void); +void action_playlist_sort_selected_by_date(void); +void action_playlist_sort_selected_by_track_number(void); +void action_playlist_sort_selected_by_playlist_entry(void); + +void action_playlist_track_info(void); +void action_queue_toggle(void); + +#endif /* AUDACIOUS_ACTIONS_PLAYLIST_H */ diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/icons-stock.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/icons-stock.c Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,61 @@ +/* Audacious - Cross-platform multimedia player + * Copyright (C) 2005-2008 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. + */ + + +#include "icons-stock.h" +#include "plugin.h" +#include +#include + + +static void +load_stock_icon(gchar *id, gchar *filename, GtkIconFactory *iconfactory) +{ + GtkIconSet *iconset; + GdkPixbuf *pixbuf; + + pixbuf = gdk_pixbuf_new_from_file(filename, NULL); + if (pixbuf == NULL) + return; + + iconset = gtk_icon_set_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); + + gtk_icon_factory_add(iconfactory, id, iconset); +} + +void +register_aud_stock_icons(void) +{ + GtkIconFactory *iconfactory = gtk_icon_factory_new(); + + load_stock_icon(AUD_STOCK_PLAYLIST, + DATA_DIR "/images/menu_playlist.png", iconfactory); + load_stock_icon(AUD_STOCK_PLUGIN, + DATA_DIR "/images/menu_plugin.png", iconfactory); + load_stock_icon(AUD_STOCK_QUEUETOGGLE, + DATA_DIR "/images/menu_queue_toggle.png", iconfactory); + load_stock_icon(AUD_STOCK_RANDOMIZEPL, + DATA_DIR "/images/menu_randomize_playlist.png", iconfactory); + + + gtk_icon_factory_add_default( iconfactory ); + g_object_unref( iconfactory ); +} + diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/icons-stock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/icons-stock.h Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,32 @@ +/* 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. + */ + +#ifndef AUDACIOUS_ICONS_STOCK_H +#define AUDACIOUS_ICONS_STOCK_H + +void register_aud_stock_icons(void); + +/* this header contains macro defines for Audacious stock icons */ + +#define AUD_STOCK_PLAYLIST "aud-playlist" +#define AUD_STOCK_PLUGIN "aud-plugin" +#define AUD_STOCK_QUEUETOGGLE "aud-queuetoggle" +#define AUD_STOCK_RANDOMIZEPL "aud-randomizepl" + +#endif /* AUDACIOUS_ICONS_STOCK_H */ diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/plugin.c --- a/src/skins/plugin.c Wed May 21 09:08:05 2008 +0300 +++ b/src/skins/plugin.c Wed May 21 12:37:40 2008 +0200 @@ -23,6 +23,8 @@ #include "skins_cfg.h" #include "ui_skin.h" #include "ui_skinned_window.h" +#include "ui_manager.h" +#include "icons-stock.h" #include #include @@ -48,6 +50,11 @@ skins_cfg_load(); + register_aud_stock_icons(); + ui_manager_init(); + ui_manager_create_menus(); + mainwin_setup_menus(); + init_skins(config.skin); mainwin_real_show(); diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/plugin.h --- a/src/skins/plugin.h Wed May 21 09:08:05 2008 +0300 +++ b/src/skins/plugin.h Wed May 21 12:37:40 2008 +0200 @@ -25,6 +25,8 @@ #include #include "skins_cfg.h" +#define PACKAGE_NAME "audacious-plugins" +#define DATA_DIR "/usr/local/share/audacious/" extern GtkWidget *mainwin; void skins_init(void); diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/skins_cfg.c --- a/src/skins/skins_cfg.c Wed May 21 09:08:05 2008 +0300 +++ b/src/skins/skins_cfg.c Wed May 21 12:37:40 2008 +0200 @@ -32,6 +32,7 @@ .scaled = FALSE, .autoscroll = TRUE, .always_on_top = FALSE, + .sticky = FALSE, .scale_factor = 2.0, .always_show_cb = TRUE, .skin = NULL, @@ -87,6 +88,7 @@ static skins_cfg_boolent skins_boolents[] = { {"always_show_cb", &config.always_show_cb, TRUE}, {"always_on_top", &config.always_on_top, TRUE}, + {"sticky", &config.sticky, TRUE}, {"always_show_cb", &config.always_show_cb, TRUE}, {"scaled", &config.scaled, TRUE}, {"autoscroll_songname", &config.autoscroll, TRUE}, diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/skins_cfg.h --- a/src/skins/skins_cfg.h Wed May 21 09:08:05 2008 +0300 +++ b/src/skins/skins_cfg.h Wed May 21 12:37:40 2008 +0200 @@ -41,7 +41,7 @@ gint snap_distance; gboolean snap_windows, save_window_position; gboolean scaled, autoscroll; - gboolean always_on_top; + gboolean always_on_top, sticky; gfloat scale_factor; gboolean always_show_cb; gchar *skin; diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/ui_main.c --- a/src/skins/ui_main.c Wed May 21 09:08:05 2008 +0300 +++ b/src/skins/ui_main.c Wed May 21 12:37:40 2008 +0200 @@ -50,9 +50,10 @@ #include "ui_main.h" #include "ui_dock.h" -#if 0 #include "icons-stock.h" #include "actions-mainwin.h" +#include "ui_manager.h" +#if 0 #include "configdb.h" #include "dnd.h" #include "input.h" @@ -69,7 +70,6 @@ #include "ui_hints.h" #include "ui_jumptotrack.h" #include "ui_main_evlisteners.h" -#include "ui_manager.h" #include "ui_playlist.h" #include "ui_preferences.h" #include "ui_skinselector.h" @@ -175,21 +175,17 @@ void mainwin_set_always_on_top(gboolean always) { -#if 0 GtkAction *action = gtk_action_group_get_action(toggleaction_group_others, "view always on top"); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , always ); -#endif } static void mainwin_set_shade(gboolean shaded) { -#if 0 GtkAction *action = gtk_action_group_get_action(toggleaction_group_others, "roll up player"); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); -#endif } static void @@ -245,7 +241,6 @@ void mainwin_vis_set_type(VisType mode) { -#if 0 GtkAction *action; switch ( mode ) @@ -270,7 +265,6 @@ } gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE ); -#endif } static void @@ -305,14 +299,12 @@ static void mainwin_menubtn_cb(void) { -#if 0 gint x, y; gtk_window_get_position(GTK_WINDOW(mainwin), &x, &y); ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), x + 6 * MAINWIN_SCALE_FACTOR , y + MAINWIN_SHADED_HEIGHT * MAINWIN_SCALE_FACTOR, 1, GDK_CURRENT_TIME); -#endif } void @@ -350,11 +342,9 @@ mainwin_vis_set_type(config.vis_type); } else if (event->button == 3) { -#if 0 ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu), event->x_root, event->y_root, 3, event->time); -#endif } return TRUE; } @@ -818,11 +808,11 @@ mainwin_widget_contained(event, aud_active_skin->properties.mainwin_next_x, aud_active_skin->properties.mainwin_next_y, 23, 18)) { -#if 0 + ui_manager_popup_menu_show(GTK_MENU(mainwin_playback_menu), event->x_root, event->y_root, 3, event->time); -#endif + } else { /* * Pop up the main menu a few pixels down. @@ -833,11 +823,11 @@ ***MD I think the above is stupid, people don't expect this * */ -#if 0 + ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, event->y_root, 3, event->time); -#endif + } return TRUE; } @@ -1425,9 +1415,7 @@ void mainwin_shuffle_pushed(gboolean toggled) { -#if 0 check_set( toggleaction_group_others , "playback shuffle" , toggled ); -#endif } void mainwin_shuffle_pushed_cb(void) { @@ -1710,9 +1698,9 @@ mainwin_real_show(void) { config.player_visible = TRUE; -#if 0 + check_set( toggleaction_group_others , "show player" , TRUE ); -#endif + if (config.player_shaded) ui_vis_clear_data(mainwin_vis); @@ -1734,9 +1722,9 @@ void mainwin_real_hide(void) { -#if 0 + check_set( toggleaction_group_others , "show player", FALSE); -#endif + if (config.player_shaded) ui_svis_clear_data(mainwin_svis); @@ -1808,10 +1796,10 @@ guint action, GtkWidget * item) { -#if 0 Playlist *playlist = aud_playlist_get_active(); switch (action) { +#if 0 case MAINWIN_GENERAL_PREFS: show_prefs_window(); break; @@ -1845,6 +1833,7 @@ else equalizerwin_real_hide(); break; +#endif case MAINWIN_GENERAL_PREV: aud_playlist_prev(playlist); break; @@ -1860,16 +1849,18 @@ case MAINWIN_GENERAL_NEXT: aud_playlist_next(playlist); break; +#if 0 case MAINWIN_GENERAL_BACK5SEC: if (audacious_drct_get_playing() && aud_playlist_get_current_length(playlist) != -1) - audacious_drct_seek_relative(-5); + playback_seek_relative(-5); break; case MAINWIN_GENERAL_FWD5SEC: if (audacious_drct_get_playing() && aud_playlist_get_current_length(playlist) != -1) - audacious_drct_seek_relative(5); + playback_seek_relative(5); break; +#endif case MAINWIN_GENERAL_START: aud_playlist_set_position(playlist, 0); break; @@ -1877,7 +1868,9 @@ mainwin_jump_to_time(); break; case MAINWIN_GENERAL_JTF: +#if 0 ui_jump_to_track(); +#endif break; case MAINWIN_GENERAL_EXIT: mainwin_quit_cb(); @@ -1908,19 +1901,18 @@ break; case MAINWIN_GENERAL_NEW_PL: { - Playlist *new_pl = playlist_new(); - playlist_add_playlist(new_pl); - playlist_select_playlist(new_pl); + Playlist *new_pl = aud_playlist_new(); + aud_playlist_add_playlist(new_pl); + aud_playlist_select_playlist(new_pl); } break; case MAINWIN_GENERAL_PREV_PL: - playlist_select_prev(); + aud_playlist_select_prev(); break; case MAINWIN_GENERAL_NEXT_PL: - playlist_select_next(); + aud_playlist_select_next(); break; } -#endif } static void @@ -1956,7 +1948,6 @@ static void mainwin_mr_release(GtkWidget *widget, MenuRowItem i, GdkEventButton *event) { -#if 0 switch (i) { case MENUROW_OPTIONS: ui_manager_popup_menu_show(GTK_MENU(mainwin_view_menu), @@ -1970,7 +1961,9 @@ UI_SKINNED_MENUROW(mainwin_menurow)->always_selected ); break; case MENUROW_FILEINFOBOX: +#if 0 ui_fileinfo_show_current(aud_playlist_get_active()); +#endif break; case MENUROW_SCALE: gtk_toggle_action_set_active( @@ -1986,7 +1979,7 @@ case MENUROW_NONE: break; } -#endif + mainwin_release_info_text(); } @@ -2042,12 +2035,10 @@ static void set_timer_mode(TimerMode mode) { -#if 0 if (mode == TIMER_ELAPSED) check_set(radioaction_group_viewtime, "view time elapsed", TRUE); else check_set(radioaction_group_viewtime, "view time remaining", TRUE); -#endif } static void @@ -2094,7 +2085,7 @@ set_timer_mode(config.timer_mode); /* View menu */ -#if 0 + check_set(toggleaction_group_others, "view always on top", config.always_on_top); check_set(toggleaction_group_others, "view put on all workspaces", config.sticky); check_set(toggleaction_group_others, "roll up player", config.player_shaded); @@ -2255,7 +2246,6 @@ check_set(radioaction_group_peafoff, "peafoff slowest", TRUE); break; } -#endif } static void mainwin_info_double_clicked_cb(void) { @@ -2267,10 +2257,8 @@ static void mainwin_info_right_clicked_cb(GtkWidget *widget, GdkEventButton *event) { -#if 0 ui_manager_popup_menu_show(GTK_MENU(mainwin_songname_menu), event->x_root, event->y_root, 3, event->time); -#endif } static void @@ -2492,18 +2480,17 @@ g_signal_connect(mainwin, "key_press_event", G_CALLBACK(mainwin_keypress), NULL); - +#endif ui_main_evlistener_init(); -#endif } void mainwin_create(void) { mainwin_create_window(); -#if 0 + gtk_window_add_accel_group( GTK_WINDOW(mainwin) , ui_manager_get_accel_group() ); -#endif + mainwin_create_widgets(); } @@ -2966,10 +2953,8 @@ void util_menu_main_show( gint x , gint y , guint button , guint time ) { -#if 0 /* convenience function that shows the main popup menu wherever requested */ ui_manager_popup_menu_show( GTK_MENU(mainwin_general_menu), x , y , button , time ); return; -#endif } diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/ui_main_evlisteners.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/ui_main_evlisteners.c Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,354 @@ +/* + * Audacious + * Copyright (c) 2006-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. + */ +#if 0 +#include "ui_playlist_evlisteners.h" +#endif +#include +#include +#if 0 +#include "hook.h" +#include "playback.h" +#include "playlist.h" +#include "playlist_evmessages.h" +#include "visualization.h" +#endif +#include +#if 0 +#include "ui_credits.h" +#include "ui_equalizer.h" +#include "ui_fileopener.h" +#include "ui_jumptotrack.h" +#endif +#include "ui_main.h" +#if 0 +#include "ui_playlist.h" +#include "ui_preferences.h" +#endif +#include "ui_skinned_playstatus.h" +#include "ui_skinned_textbox.h" +#include "ui_skinned_window.h" +#include "skins_cfg.h" + +static gint song_info_timeout_source = 0; +static gint update_vis_timeout_source = 0; + +/* XXX: there has to be a better way than polling here! */ +/* also: where should this function go? should it stay here? --mf0102 */ +static gboolean +update_vis_func(gpointer unused) +{ + if (!audacious_drct_get_playing()) + return FALSE; +#if 0 + input_update_vis(audacious_drct_get_time()); +#endif + return TRUE; +} + +static void +ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data) +{ + gchar *text = (gchar *) hook_data; + + ui_skinned_textbox_set_text(mainwin_info, text); +#if 0 + playlistwin_update_list(playlist_get_active()); +#endif + g_free(text); +} + +static void +ui_main_evlistener_hide_seekbar(gpointer hook_data, gpointer user_data) +{ + mainwin_disable_seekbar(); +} + +static void +ui_main_evlistener_volume_change(gpointer hook_data, gpointer user_data) +{ + gint *h_vol = (gint *) hook_data; + gint vl, vr, b, v; + + vl = CLAMP(h_vol[0], 0, 100); + vr = CLAMP(h_vol[1], 0, 100); + v = MAX(vl, vr); + if (vl > vr) + b = (gint) rint(((gdouble) vr / vl) * 100) - 100; + else if (vl < vr) + b = 100 - (gint) rint(((gdouble) vl / vr) * 100); + else + b = 0; + + mainwin_set_volume_slider(v); +#if 0 + equalizerwin_set_volume_slider(v); +#endif + mainwin_set_balance_slider(b); +#if 0 + equalizerwin_set_balance_slider(b); +#endif +} + +static void +ui_main_evlistener_playback_initiate(gpointer hook_data, gpointer user_data) +{ +#if 0 + playback_initiate(); +#endif +} + +static void +ui_main_evlistener_playback_begin(gpointer hook_data, gpointer user_data) +{ + + PlaylistEntry *entry = (PlaylistEntry*)hook_data; + g_return_if_fail(entry != NULL); +#if 0 + equalizerwin_load_auto_preset(entry->filename); + input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, + cfg.equalizer_bands); + output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, + cfg.equalizer_bands); +#endif + ui_vis_clear_data(mainwin_vis); + ui_svis_clear_data(mainwin_svis); + mainwin_disable_seekbar(); + mainwin_update_song_info(); + + if (config.player_shaded) { + gtk_widget_show(mainwin_stime_min); + gtk_widget_show(mainwin_stime_sec); + gtk_widget_show(mainwin_sposition); + } else { + gtk_widget_show(mainwin_minus_num); + gtk_widget_show(mainwin_10min_num); + gtk_widget_show(mainwin_min_num); + gtk_widget_show(mainwin_10sec_num); + gtk_widget_show(mainwin_sec_num); + gtk_widget_show(mainwin_position); + } + + song_info_timeout_source = + g_timeout_add_seconds(1, (GSourceFunc) mainwin_update_song_info, NULL); + + update_vis_timeout_source = + g_timeout_add(10, (GSourceFunc) update_vis_func, NULL); +#if 0 + vis_playback_start(); +#endif + ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); +} + +static void +ui_main_evlistener_playback_stop(gpointer hook_data, gpointer user_data) +{ + if (song_info_timeout_source) + g_source_remove(song_info_timeout_source); +#if 0 + vis_playback_stop(); + free_vis_data(); +#endif + ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE); +} + +static void +ui_main_evlistener_playback_pause(gpointer hook_data, gpointer user_data) +{ + ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); +} + +static void +ui_main_evlistener_playback_unpause(gpointer hook_data, gpointer user_data) +{ + ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); +} + +static void +ui_main_evlistener_playback_seek(gpointer hook_data, gpointer user_data) +{ +#if 0 + free_vis_data(); +#endif +} + +static void +ui_main_evlistener_playback_play_file(gpointer hook_data, gpointer user_data) +{ +#if 0 + if (cfg.random_skin_on_play) + skin_set_random_skin(); +#endif +} + +static void +ui_main_evlistener_playlist_end_reached(gpointer hook_data, gpointer user_data) +{ + mainwin_clear_song_info(); +#if 0 + if (cfg.stopaftersong) + mainwin_set_stopaftersong(FALSE); +#endif +} + +static void +ui_main_evlistener_playlist_info_change(gpointer hook_data, gpointer user_data) +{ +#if 0 + PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data; + + mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels); + + g_free(msg); +#endif +} + +static void +ui_main_evlistener_mainwin_set_always_on_top(gpointer hook_data, gpointer user_data) +{ + gboolean *ontop = (gboolean*)hook_data; + mainwin_set_always_on_top(*ontop); +} + +static void +ui_main_evlistener_mainwin_show(gpointer hook_data, gpointer user_data) +{ + gboolean *show = (gboolean*)hook_data; + mainwin_show(*show); +} + +static void +ui_main_evlistener_equalizerwin_show(gpointer hook_data, gpointer user_data) +{ +#if 0 + gboolean *show = (gboolean*)hook_data; + equalizerwin_show(*show); +#endif +} + +static void +ui_main_evlistener_prefswin_show(gpointer hook_data, gpointer user_data) +{ +#if 0 + gboolean *show = (gboolean*)hook_data; + if (*show == TRUE) + show_prefs_window(); + else + hide_prefs_window(); +#endif +} + +static void +ui_main_evlistener_aboutwin_show(gpointer hook_data, gpointer user_data) +{ +#if 0 + gboolean *show = (gboolean*)hook_data; + if (*show == TRUE) + show_about_window(); + else + hide_about_window(); +#endif +} + + +static void +ui_main_evlistener_ui_jump_to_track_show(gpointer hook_data, gpointer user_data) +{ +#if 0 + gboolean *show = (gboolean*)hook_data; + if (*show == TRUE) + ui_jump_to_track(); + else + ui_jump_to_track_hide(); +#endif +} + +static void +ui_main_evlistener_filebrowser_show(gpointer hook_data, gpointer user_data) +{ +#if 0 + gboolean *play_button = (gboolean*)hook_data; + run_filebrowser(*play_button); +#endif +} + +static void +ui_main_evlistener_filebrowser_hide(gpointer hook_data, gpointer user_data) +{ +#if 0 + hide_filebrowser(); +#endif +} + +static void +ui_main_evlistener_visualization_timeout(gpointer hook_data, gpointer user_data) +{ + if (config.player_shaded && config.player_visible) + ui_svis_timeout_func(mainwin_svis, hook_data); + else + ui_vis_timeout_func(mainwin_vis, hook_data); +} + +static void +ui_main_evlistener_config_save(gpointer hook_data, gpointer user_data) +{ + ConfigDb *db = (ConfigDb *) hook_data; + + if (SKINNED_WINDOW(mainwin)->x != -1 && + SKINNED_WINDOW(mainwin)->y != -1 ) + { + aud_cfg_db_set_int(db, "skins", "player_x", SKINNED_WINDOW(mainwin)->x); + aud_cfg_db_set_int(db, "skins", "player_y", SKINNED_WINDOW(mainwin)->y); + } + + aud_cfg_db_set_bool(db, "skins", "mainwin_use_bitmapfont", + config.mainwin_use_bitmapfont); +} + +void +ui_main_evlistener_init(void) +{ +#if 0 + aud_hook_associate("title change", ui_main_evlistener_title_change, NULL); + aud_hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL); + aud_hook_associate("volume set", ui_main_evlistener_volume_change, NULL); + aud_hook_associate("playback initiate", ui_main_evlistener_playback_initiate, NULL); +#endif + aud_hook_associate("playback begin", ui_main_evlistener_playback_begin, NULL); + aud_hook_associate("playback stop", ui_main_evlistener_playback_stop, NULL); + aud_hook_associate("playback pause", ui_main_evlistener_playback_pause, NULL); + aud_hook_associate("playback unpause", ui_main_evlistener_playback_unpause, NULL); + aud_hook_associate("playback seek", ui_main_evlistener_playback_seek, NULL); +#if 0 + aud_hook_associate("playback play file", ui_main_evlistener_playback_play_file, NULL); + aud_hook_associate("playlist end reached", ui_main_evlistener_playlist_end_reached, NULL); + aud_hook_associate("playlist info change", ui_main_evlistener_playlist_info_change, NULL); + aud_hook_associate("mainwin set always on top", ui_main_evlistener_mainwin_set_always_on_top, NULL); + aud_hook_associate("mainwin show", ui_main_evlistener_mainwin_show, NULL); + aud_hook_associate("equalizerwin show", ui_main_evlistener_equalizerwin_show, NULL); + aud_hook_associate("prefswin show", ui_main_evlistener_prefswin_show, NULL); + aud_hook_associate("aboutwin show", ui_main_evlistener_aboutwin_show, NULL); + aud_hook_associate("ui jump to track show", ui_main_evlistener_ui_jump_to_track_show, NULL); + aud_hook_associate("filebrowser show", ui_main_evlistener_filebrowser_show, NULL); + aud_hook_associate("filebrowser hide", ui_main_evlistener_filebrowser_hide, NULL); +#endif + aud_hook_associate("visualization timeout", ui_main_evlistener_visualization_timeout, NULL); + aud_hook_associate("config save", ui_main_evlistener_config_save, NULL); +} + diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/ui_main_evlisteners.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/ui_main_evlisteners.h Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,28 @@ +/* + * Audacious + * Copyright (c) 2006-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. + */ + +#include + +#ifndef AUDACIOUS_UI_MAIN_EVLISTENERS_H +#define AUDACIOUS_UI_MAIN_EVLISTENERS_H + +void ui_main_evlistener_init(void); + +#endif /* AUDACIOUS_UI_MAIN_EVLISTENERS_H */ diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/ui_manager.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/ui_manager.c Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,877 @@ +/* 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "ui_manager.h" +#include "actions-mainwin.h" +#include "actions-playlist.h" +#include "actions-equalizer.h" + +#if 0 +/* this header contains prototypes for plugin-available menu functions */ +#include "ui_plugin_menu.h" +#endif + +/* 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" + +#include "icons-stock.h" +#if 0 +#include "sync-menu.h" +#endif +#include "plugin.h" +#include + +static GtkUIManager *ui_manager = NULL; +static gboolean menu_created = FALSE; + + +/* toggle action entries */ + +static GtkToggleActionEntry toggleaction_entries_others[] = { + + { "autoscroll songname", NULL , N_("Autoscroll Songname"), NULL, + N_("Autoscroll Songname"), G_CALLBACK(action_autoscroll_songname) , FALSE }, + + { "stop after current song", NULL , N_("Stop after Current Song"), "M", + N_("Stop after Current Song"), G_CALLBACK(action_stop_after_current_song) , FALSE }, + + { "anamode peaks", NULL , N_("Peaks"), NULL, + N_("Peaks"), G_CALLBACK(action_anamode_peaks) , FALSE }, + + { "playback repeat", NULL , N_("Repeat"), "R", + N_("Repeat"), G_CALLBACK(action_playback_repeat) , FALSE }, + + { "playback shuffle", NULL , N_("Shuffle"), "S", + N_("Shuffle"), G_CALLBACK(action_playback_shuffle) , FALSE }, + + { "playback no playlist advance", NULL , N_("No Playlist Advance"), "N", + N_("No Playlist Advance"), G_CALLBACK(action_playback_noplaylistadvance) , FALSE }, + + { "show player", NULL , N_("Show Player"), "M", + N_("Show Player"), G_CALLBACK(action_show_player) , FALSE }, + + { "show playlist editor", NULL , N_("Show Playlist Editor"), "E", + N_("Show Playlist Editor"), G_CALLBACK(action_show_playlist_editor) , FALSE }, + + { "show equalizer", NULL , N_("Show Equalizer"), "G", + N_("Show Equalizer"), G_CALLBACK(action_show_equalizer) , FALSE }, + + { "view always on top", NULL , N_("Always on Top"), "O", + N_("Always on Top"), G_CALLBACK(action_view_always_on_top) , FALSE }, + + { "view put on all workspaces", NULL , N_("Put on All Workspaces"), "S", + N_("Put on All Workspaces"), G_CALLBACK(action_view_on_all_workspaces) , FALSE }, + + { "roll up player", NULL , N_("Roll up Player"), "W", + N_("Roll up Player"), G_CALLBACK(action_roll_up_player) , FALSE }, + + { "roll up playlist editor", NULL , N_("Roll up Playlist Editor"), "W", + N_("Roll up Playlist Editor"), G_CALLBACK(action_roll_up_playlist_editor) , FALSE }, + + { "roll up equalizer", NULL , N_("Roll up Equalizer"), "W", + N_("Roll up Equalizer"), G_CALLBACK(action_roll_up_equalizer) , FALSE }, + + { "view scaled", NULL , N_("Scale"), "D", + N_("DoubleSize"), G_CALLBACK(action_view_scaled) , FALSE }, + + { "view easy move", NULL , N_("Easy Move"), "E", + N_("Easy Move"), G_CALLBACK(action_view_easymove) , FALSE } +}; + + + +/* radio action entries */ + +static GtkRadioActionEntry radioaction_entries_vismode[] = { + { "vismode analyzer", NULL , N_("Analyzer"), NULL, N_("Analyzer"), VIS_ANALYZER }, + { "vismode scope", NULL , N_("Scope"), NULL, N_("Scope"), VIS_SCOPE }, + { "vismode voiceprint", NULL , N_("Voiceprint"), NULL, N_("Voiceprint"), VIS_VOICEPRINT }, + { "vismode off", NULL , N_("Off"), NULL, N_("Off"), VIS_OFF } +}; + +static GtkRadioActionEntry radioaction_entries_anamode[] = { + { "anamode normal", NULL , N_("Normal"), NULL, N_("Normal"), ANALYZER_NORMAL }, + { "anamode fire", NULL , N_("Fire"), NULL, N_("Fire"), ANALYZER_FIRE }, + { "anamode vertical lines", NULL , N_("Vertical Lines"), NULL, N_("Vertical Lines"), ANALYZER_VLINES } +}; + +static GtkRadioActionEntry radioaction_entries_anatype[] = { + { "anatype lines", NULL , N_("Lines"), NULL, N_("Lines"), ANALYZER_LINES }, + { "anatype bars", NULL , N_("Bars"), NULL, N_("Bars"), ANALYZER_BARS } +}; + +static GtkRadioActionEntry radioaction_entries_scomode[] = { + { "scomode dot", NULL , N_("Dot Scope"), NULL, N_("Dot Scope"), SCOPE_DOT }, + { "scomode line", NULL , N_("Line Scope"), NULL, N_("Line Scope"), SCOPE_LINE }, + { "scomode solid", NULL , N_("Solid Scope"), NULL, N_("Solid Scope"), SCOPE_SOLID } +}; + +static GtkRadioActionEntry radioaction_entries_vprmode[] = { + { "vprmode normal", NULL , N_("Normal"), NULL, N_("Normal"), VOICEPRINT_NORMAL }, + { "vprmode fire", NULL , N_("Fire"), NULL, N_("Fire"), VOICEPRINT_FIRE }, + { "vprmode ice", NULL , N_("Ice"), NULL, N_("Ice"), VOICEPRINT_ICE } +}; + +static GtkRadioActionEntry radioaction_entries_wshmode[] = { + { "wshmode normal", NULL , N_("Normal"), NULL, N_("Normal"), VU_NORMAL }, + { "wshmode smooth", NULL , N_("Smooth"), NULL, N_("Smooth"), VU_SMOOTH } +}; + +static GtkRadioActionEntry radioaction_entries_refrate[] = { + { "refrate full", NULL , N_("Full (~50 fps)"), NULL, N_("Full (~50 fps)"), REFRESH_FULL }, + { "refrate half", NULL , N_("Half (~25 fps)"), NULL, N_("Half (~25 fps)"), REFRESH_HALF }, + { "refrate quarter", NULL , N_("Quarter (~13 fps)"), NULL, N_("Quarter (~13 fps)"), REFRESH_QUARTER }, + { "refrate eighth", NULL , N_("Eighth (~6 fps)"), NULL, N_("Eighth (~6 fps)"), REFRESH_EIGTH } +}; + +static GtkRadioActionEntry radioaction_entries_anafoff[] = { + { "anafoff slowest", NULL , N_("Slowest"), NULL, N_("Slowest"), FALLOFF_SLOWEST }, + { "anafoff slow", NULL , N_("Slow"), NULL, N_("Slow"), FALLOFF_SLOW }, + { "anafoff medium", NULL , N_("Medium"), NULL, N_("Medium"), FALLOFF_MEDIUM }, + { "anafoff fast", NULL , N_("Fast"), NULL, N_("Fast"), FALLOFF_FAST }, + { "anafoff fastest", NULL , N_("Fastest"), NULL, N_("Fastest"), FALLOFF_FASTEST } +}; + +static GtkRadioActionEntry radioaction_entries_peafoff[] = { + { "peafoff slowest", NULL , N_("Slowest"), NULL, N_("Slowest"), FALLOFF_SLOWEST }, + { "peafoff slow", NULL , N_("Slow"), NULL, N_("Slow"), FALLOFF_SLOW }, + { "peafoff medium", NULL , N_("Medium"), NULL, N_("Medium"), FALLOFF_MEDIUM }, + { "peafoff fast", NULL , N_("Fast"), NULL, N_("Fast"), FALLOFF_FAST }, + { "peafoff fastest", NULL , N_("Fastest"), NULL, N_("Fastest"), FALLOFF_FASTEST } +}; + +static GtkRadioActionEntry radioaction_entries_viewtime[] = { + { "view time elapsed", NULL , N_("Time Elapsed"), "E", N_("Time Elapsed"), TIMER_ELAPSED }, + { "view time remaining", NULL , N_("Time Remaining"), "R", N_("Time Remaining"), TIMER_REMAINING } +}; + + + +/* normal actions */ + +static GtkActionEntry action_entries_playback[] = { + + { "playback", NULL, N_("Playback") }, + + { "playback play", GTK_STOCK_MEDIA_PLAY , N_("Play"), "X", + N_("Play"), G_CALLBACK(action_playback_play) }, + + { "playback pause", GTK_STOCK_MEDIA_PAUSE , N_("Pause"), "C", + N_("Pause"), G_CALLBACK(action_playback_pause) }, + + { "playback stop", GTK_STOCK_MEDIA_STOP , N_("Stop"), "V", + N_("Stop"), G_CALLBACK(action_playback_stop) }, + + { "playback previous", GTK_STOCK_MEDIA_PREVIOUS , N_("Previous"), "Z", + N_("Previous"), G_CALLBACK(action_playback_previous) }, + + { "playback next", GTK_STOCK_MEDIA_NEXT , N_("Next"), "B", + N_("Next"), G_CALLBACK(action_playback_next) } +}; + + +static GtkActionEntry action_entries_visualization[] = { + { "visualization", NULL, N_("Visualization") }, + { "vismode", NULL, N_("Visualization Mode") }, + { "anamode", NULL, N_("Analyzer Mode") }, + { "scomode", NULL, N_("Scope Mode") }, + { "vprmode", NULL, N_("Voiceprint Mode") }, + { "wshmode", NULL, N_("WindowShade VU Mode") }, + { "refrate", NULL, N_("Refresh Rate") }, + { "anafoff", NULL, N_("Analyzer Falloff") }, + { "peafoff", NULL, N_("Peaks Falloff") } +}; +#if 0 +static GtkActionEntry action_entries_playlist[] = { + + { "playlist", NULL, N_("Playlist") }, + + { "playlist new", GTK_STOCK_NEW , N_("New Playlist"), "N", + N_("New Playlist"), G_CALLBACK(action_playlist_new) }, + + { "playlist select next", GTK_STOCK_MEDIA_NEXT, N_("Select Next Playlist"), "P", + N_("Select Next Playlist"), G_CALLBACK(action_playlist_next) }, + + { "playlist select previous", GTK_STOCK_MEDIA_PREVIOUS, N_("Select Previous Playlist"), "P", + N_("Select Previous Playlist"), G_CALLBACK(action_playlist_prev) }, + + { "playlist delete", GTK_STOCK_DELETE , N_("Delete Playlist"), "D", + N_("Delete Playlist"), G_CALLBACK(action_playlist_delete) }, + + { "playlist load", GTK_STOCK_OPEN, N_("Load List"), "O", + N_("Loads a playlist file into the selected playlist."), G_CALLBACK(action_playlist_load_list) }, + + { "playlist save", GTK_STOCK_SAVE, N_("Save List"), "S", + N_("Saves the selected playlist."), G_CALLBACK(action_playlist_save_list) }, + + { "playlist save default", GTK_STOCK_SAVE, N_("Save Default List"), "S", + N_("Saves the selected playlist to the default location."), + G_CALLBACK(action_playlist_save_default_list) }, + + { "playlist refresh", GTK_STOCK_REFRESH, N_("Refresh List"), "F5", + N_("Refreshes metadata associated with a playlist entry."), + G_CALLBACK(action_playlist_refresh_list) }, + + { "playlist manager", AUD_STOCK_PLAYLIST , N_("List Manager"), "P", + N_("Opens the playlist manager."), + G_CALLBACK(action_open_list_manager) } +}; + +static GtkActionEntry action_entries_view[] = { + + { "view", NULL, N_("View") } +}; + +static GtkActionEntry action_entries_playlist_add[] = { + { "playlist add url", GTK_STOCK_NETWORK, N_("Add Internet Address..."), "H", + N_("Adds a remote track to the playlist."), + G_CALLBACK(action_playlist_add_url) }, + + { "playlist add files", GTK_STOCK_ADD, N_("Add Files..."), "F", + N_("Adds files to the playlist."), + G_CALLBACK(action_playlist_add_files) }, +}; + +static GtkActionEntry action_entries_playlist_select[] = { + { "playlist search and select", GTK_STOCK_FIND, N_("Search and Select"), "F", + N_("Searches the playlist and selects playlist entries based on specific criteria."), + G_CALLBACK(action_playlist_search_and_select) }, + + { "playlist invert selection", NULL , N_("Invert Selection"), NULL, + N_("Inverts the selected and unselected entries."), + G_CALLBACK(action_playlist_invert_selection) }, + + { "playlist select all", NULL , N_("Select All"), "A", + N_("Selects all of the playlist entries."), + G_CALLBACK(action_playlist_select_all) }, + + { "playlist select none", NULL , N_("Select None"), "A", + N_("Deselects all of the playlist entries."), + G_CALLBACK(action_playlist_select_none) }, +}; + +static GtkActionEntry action_entries_playlist_delete[] = { + { "playlist remove all", GTK_STOCK_CLEAR, N_("Remove All"), NULL, + N_("Removes all entries from the playlist."), + G_CALLBACK(action_playlist_remove_all) }, + + { "playlist clear queue", GTK_STOCK_CLEAR, N_("Clear Queue"), "Q", + N_("Clears the queue associated with this playlist."), + G_CALLBACK(action_playlist_clear_queue) }, + + { "playlist remove unavailable", GTK_STOCK_DIALOG_ERROR , N_("Remove Unavailable Files"), NULL, + N_("Removes unavailable files from the playlist."), + G_CALLBACK(action_playlist_remove_unavailable) }, + + { "playlist remove dups menu", NULL , N_("Remove Duplicates") }, + + { "playlist remove dups by title", NULL , N_("By Title"), NULL, + N_("Removes duplicate entries from the playlist by title."), + G_CALLBACK(action_playlist_remove_dupes_by_title) }, + + { "playlist remove dups by filename", NULL , N_("By Filename"), NULL, + N_("Removes duplicate entries from the playlist by filename."), + G_CALLBACK(action_playlist_remove_dupes_by_filename) }, + + { "playlist remove dups by full path", NULL , N_("By Path + Filename"), NULL, + N_("Removes duplicate entries from the playlist by their full path."), + G_CALLBACK(action_playlist_remove_dupes_by_full_path) }, + + { "playlist remove unselected", GTK_STOCK_REMOVE, N_("Remove Unselected"), NULL, + N_("Remove unselected entries from the playlist."), + G_CALLBACK(action_playlist_remove_unselected) }, + + { "playlist remove selected", GTK_STOCK_REMOVE, N_("Remove Selected"), "Delete", + N_("Remove selected entries from the playlist."), + G_CALLBACK(action_playlist_remove_selected) }, +}; + +static GtkActionEntry action_entries_playlist_sort[] = { + { "playlist randomize list", AUD_STOCK_RANDOMIZEPL , N_("Randomize List"), "R", + N_("Randomizes the playlist."), + G_CALLBACK(action_playlist_randomize_list) }, + + { "playlist reverse list", GTK_STOCK_GO_UP , N_("Reverse List"), NULL, + N_("Reverses the playlist."), + G_CALLBACK(action_playlist_reverse_list) }, + + { "playlist sort menu", GTK_STOCK_GO_DOWN , N_("Sort List") }, + + { "playlist sort by title", NULL , N_("By Title"), NULL, + N_("Sorts the list by title."), + G_CALLBACK(action_playlist_sort_by_title) }, + + { "playlist sort by artist", NULL , N_("By Artist"), NULL, + N_("Sorts the list by artist."), + G_CALLBACK(action_playlist_sort_by_artist) }, + + { "playlist sort by filename", NULL , N_("By Filename"), NULL, + N_("Sorts the list by filename."), + G_CALLBACK(action_playlist_sort_by_filename) }, + + { "playlist sort by full path", NULL , N_("By Path + Filename"), NULL, + N_("Sorts the list by full pathname."), + G_CALLBACK(action_playlist_sort_by_full_path) }, + + { "playlist sort by date", NULL , N_("By Date"), NULL, + N_("Sorts the list by modification time."), + G_CALLBACK(action_playlist_sort_by_date) }, + + { "playlist sort by track number", NULL , N_("By Track Number"), NULL, + N_("Sorts the list by track number."), + G_CALLBACK(action_playlist_sort_by_track_number) }, + + { "playlist sort by playlist entry", NULL , N_("By Playlist Entry"), NULL, + N_("Sorts the list by playlist entry."), + G_CALLBACK(action_playlist_sort_by_playlist_entry) }, + + { "playlist sort selected menu", GTK_STOCK_GO_DOWN , N_("Sort Selected") }, + + { "playlist sort selected by title", NULL , N_("By Title"), NULL, + N_("Sorts the list by title."), + G_CALLBACK(action_playlist_sort_selected_by_title) }, + + { "playlist sort selected by artist", NULL, N_("By Artist"), NULL, + N_("Sorts the list by artist."), + G_CALLBACK(action_playlist_sort_selected_by_artist) }, + + { "playlist sort selected by filename", NULL , N_("By Filename"), NULL, + N_("Sorts the list by filename."), + G_CALLBACK(action_playlist_sort_selected_by_filename) }, + + { "playlist sort selected by full path", NULL , N_("By Path + Filename"), NULL, + N_("Sorts the list by full pathname."), + G_CALLBACK(action_playlist_sort_selected_by_full_path) }, + + { "playlist sort selected by date", NULL , N_("By Date"), NULL, + N_("Sorts the list by modification time."), + G_CALLBACK(action_playlist_sort_selected_by_date) }, + + { "playlist sort selected by track number", NULL , N_("By Track Number"), NULL, + N_("Sorts the list by track number."), + G_CALLBACK(action_playlist_sort_selected_by_track_number) }, + + { "playlist sort selected by playlist entry", NULL, N_("By Playlist Entry"), NULL, + N_("Sorts the list by playlist entry."), + G_CALLBACK(action_playlist_sort_selected_by_playlist_entry) }, +}; +#endif +static GtkActionEntry action_entries_others[] = { + + { "dummy", NULL, "dummy" }, + + /* XXX Carbon support */ + { "file", NULL, N_("File") }, + { "help", NULL, N_("Help") }, + + { "plugins-menu", AUD_STOCK_PLUGIN, N_("Plugin Services") }, + + { "current track info", GTK_STOCK_INFO , N_("View Track Details"), "I", + N_("View track details"), G_CALLBACK(action_current_track_info) }, + + { "playlist track info", GTK_STOCK_INFO , N_("View Track Details"), "I", + N_("View track details"), G_CALLBACK(action_playlist_track_info) }, + + { "about audacious", GTK_STOCK_DIALOG_INFO , N_("About Audacious"), NULL, + N_("About Audacious"), G_CALLBACK(action_about_audacious) }, + + { "play file", GTK_STOCK_OPEN , N_("Play File"), "L", + N_("Load and play a file"), G_CALLBACK(action_play_file) }, + + { "play location", GTK_STOCK_NETWORK , N_("Play Location"), "L", + N_("Play media from the selected location"), G_CALLBACK(action_play_location) }, + + { "plugins", NULL , N_("Plugin services") }, + + { "preferences", GTK_STOCK_PREFERENCES , N_("Preferences"), "P", + N_("Open preferences window"), G_CALLBACK(action_preferences) }, + + { "quit", GTK_STOCK_QUIT , N_("_Quit"), NULL, + N_("Quit Audacious"), G_CALLBACK(action_quit) }, + + { "ab set", NULL , N_("Set A-B"), "A", + N_("Set A-B"), G_CALLBACK(action_ab_set) }, + + { "ab clear", NULL , N_("Clear A-B"), "A", + N_("Clear A-B"), G_CALLBACK(action_ab_clear) }, + + { "jump to playlist start", GTK_STOCK_GOTO_TOP , N_("Jump to Playlist Start"), "Z", + N_("Jump to Playlist Start"), G_CALLBACK(action_jump_to_playlist_start) }, + + { "jump to file", GTK_STOCK_JUMP_TO , N_("Jump to File"), "J", + N_("Jump to File"), G_CALLBACK(action_jump_to_file) }, + + { "jump to time", GTK_STOCK_JUMP_TO , N_("Jump to Time"), "J", + N_("Jump to Time"), G_CALLBACK(action_jump_to_time) }, + + { "queue toggle", AUD_STOCK_QUEUETOGGLE , N_("Queue Toggle"), "Q", + N_("Enables/disables the entry in the playlist's queue."), + G_CALLBACK(action_queue_toggle) }, +}; + + +static GtkActionEntry action_entries_equalizer[] = { + + { "equ preset load menu", NULL, N_("Load") }, + { "equ preset import menu", NULL, N_("Import") }, + { "equ preset save menu", NULL, N_("Save") }, + { "equ preset delete menu", NULL, N_("Delete") }, + + { "equ load preset", NULL, N_("Preset"), NULL, + N_("Load preset"), G_CALLBACK(action_equ_load_preset) }, + + { "equ load auto preset", NULL, N_("Auto-load preset"), NULL, + N_("Load auto-load preset"), G_CALLBACK(action_equ_load_auto_preset) }, + + { "equ load default preset", NULL, N_("Default"), NULL, + N_("Load default preset into equalizer"), G_CALLBACK(action_equ_load_default_preset) }, + + { "equ zero preset", NULL, N_("Zero"), NULL, + N_("Set equalizer preset levels to zero"), G_CALLBACK(action_equ_zero_preset) }, + + { "equ load preset file", NULL, N_("From file"), NULL, + N_("Load preset from file"), G_CALLBACK(action_equ_load_preset_file) }, + + { "equ load preset eqf", NULL, N_("From WinAMP EQF file"), NULL, + N_("Load preset from WinAMP EQF file"), G_CALLBACK(action_equ_load_preset_eqf) }, + + { "equ import winamp presets", NULL, N_("WinAMP Presets"), NULL, + N_("Import WinAMP presets"), G_CALLBACK(action_equ_import_winamp_presets) }, + + { "equ save preset", NULL, N_("Preset"), NULL, + N_("Save preset"), G_CALLBACK(action_equ_save_preset) }, + + { "equ save auto preset", NULL, N_("Auto-load preset"), NULL, + N_("Save auto-load preset"), G_CALLBACK(action_equ_save_auto_preset) }, + + { "equ save default preset", NULL, N_("Default"), NULL, + N_("Save default preset"), G_CALLBACK(action_equ_save_default_preset) }, + + { "equ save preset file", NULL, N_("To file"), NULL, + N_("Save preset to file"), G_CALLBACK(action_equ_save_preset_file) }, + + { "equ save preset eqf", NULL, N_("To WinAMP EQF file"), NULL, + N_("Save preset to WinAMP EQF file"), G_CALLBACK(action_equ_save_preset_eqf) }, + + { "equ delete preset", NULL, N_("Preset"), NULL, + N_("Delete preset"), G_CALLBACK(action_equ_delete_preset) }, + + { "equ delete auto preset", NULL, N_("Auto-load preset"), NULL, + N_("Delete auto-load preset"), G_CALLBACK(action_equ_delete_auto_preset) } +}; + + + +/* ***************************** */ + + +static GtkActionGroup * +ui_manager_new_action_group( const gchar * group_name ) +{ + GtkActionGroup *group = gtk_action_group_new( group_name ); + gtk_action_group_set_translation_domain( group , PACKAGE_NAME ); + return group; +} + +void +ui_manager_init ( void ) +{ + /* toggle actions */ + toggleaction_group_others = ui_manager_new_action_group("toggleaction_others"); + gtk_action_group_add_toggle_actions( + toggleaction_group_others , toggleaction_entries_others , + G_N_ELEMENTS(toggleaction_entries_others) , NULL ); + + /* radio actions */ + radioaction_group_anamode = ui_manager_new_action_group("radioaction_anamode"); + gtk_action_group_add_radio_actions( + radioaction_group_anamode , radioaction_entries_anamode , + G_N_ELEMENTS(radioaction_entries_anamode) , 0 , G_CALLBACK(action_anamode) , NULL ); + + radioaction_group_anatype = ui_manager_new_action_group("radioaction_anatype"); + gtk_action_group_add_radio_actions( + radioaction_group_anatype , radioaction_entries_anatype , + G_N_ELEMENTS(radioaction_entries_anatype) , 0 , G_CALLBACK(action_anatype) , NULL ); + + radioaction_group_scomode = ui_manager_new_action_group("radioaction_scomode"); + gtk_action_group_add_radio_actions( + radioaction_group_scomode , radioaction_entries_scomode , + G_N_ELEMENTS(radioaction_entries_scomode) , 0 , G_CALLBACK(action_scomode) , NULL ); + + radioaction_group_vprmode = ui_manager_new_action_group("radioaction_vprmode"); + gtk_action_group_add_radio_actions( + radioaction_group_vprmode , radioaction_entries_vprmode , + G_N_ELEMENTS(radioaction_entries_vprmode) , 0 , G_CALLBACK(action_vprmode) , NULL ); + + radioaction_group_wshmode = ui_manager_new_action_group("radioaction_wshmode"); + gtk_action_group_add_radio_actions( + radioaction_group_wshmode , radioaction_entries_wshmode , + G_N_ELEMENTS(radioaction_entries_wshmode) , 0 , G_CALLBACK(action_wshmode) , NULL ); + + radioaction_group_refrate = ui_manager_new_action_group("radioaction_refrate"); + gtk_action_group_add_radio_actions( + radioaction_group_refrate , radioaction_entries_refrate , + G_N_ELEMENTS(radioaction_entries_refrate) , 0 , G_CALLBACK(action_refrate) , NULL ); + + radioaction_group_anafoff = ui_manager_new_action_group("radioaction_anafoff"); + gtk_action_group_add_radio_actions( + radioaction_group_anafoff , radioaction_entries_anafoff , + G_N_ELEMENTS(radioaction_entries_anafoff) , 0 , G_CALLBACK(action_anafoff) , NULL ); + + radioaction_group_peafoff = ui_manager_new_action_group("radioaction_peafoff"); + gtk_action_group_add_radio_actions( + radioaction_group_peafoff , radioaction_entries_peafoff , + G_N_ELEMENTS(radioaction_entries_peafoff) , 0 , G_CALLBACK(action_peafoff) , NULL ); + + radioaction_group_vismode = ui_manager_new_action_group("radioaction_vismode"); + gtk_action_group_add_radio_actions( + radioaction_group_vismode , radioaction_entries_vismode , + G_N_ELEMENTS(radioaction_entries_vismode) , 0 , G_CALLBACK(action_vismode) , NULL ); + + radioaction_group_viewtime = ui_manager_new_action_group("radioaction_viewtime"); + gtk_action_group_add_radio_actions( + radioaction_group_viewtime , radioaction_entries_viewtime , + G_N_ELEMENTS(radioaction_entries_viewtime) , 0 , G_CALLBACK(action_viewtime) , NULL ); + + /* normal actions */ + action_group_playback = ui_manager_new_action_group("action_playback"); + gtk_action_group_add_actions( + action_group_playback , action_entries_playback , + G_N_ELEMENTS(action_entries_playback) , NULL ); +#if 0 + action_group_playlist = ui_manager_new_action_group("action_playlist"); + gtk_action_group_add_actions( + action_group_playlist , action_entries_playlist , + G_N_ELEMENTS(action_entries_playlist) , NULL ); +#endif + action_group_visualization = ui_manager_new_action_group("action_visualization"); + gtk_action_group_add_actions( + action_group_visualization , action_entries_visualization , + G_N_ELEMENTS(action_entries_visualization) , NULL ); +#if 0 + action_group_view = ui_manager_new_action_group("action_view"); + gtk_action_group_add_actions( + action_group_view , action_entries_view , + G_N_ELEMENTS(action_entries_view) , NULL ); + + action_group_others = ui_manager_new_action_group("action_others"); + gtk_action_group_add_actions( + action_group_others , action_entries_others , + G_N_ELEMENTS(action_entries_others) , NULL ); + + action_group_playlist_add = ui_manager_new_action_group("action_playlist_add"); + gtk_action_group_add_actions( + action_group_playlist_add, action_entries_playlist_add, + G_N_ELEMENTS(action_entries_playlist_add), NULL ); + + action_group_playlist_select = ui_manager_new_action_group("action_playlist_select"); + gtk_action_group_add_actions( + action_group_playlist_select, action_entries_playlist_select, + G_N_ELEMENTS(action_entries_playlist_select), NULL ); + + action_group_playlist_delete = ui_manager_new_action_group("action_playlist_delete"); + gtk_action_group_add_actions( + action_group_playlist_delete, action_entries_playlist_delete, + G_N_ELEMENTS(action_entries_playlist_delete), NULL ); + + action_group_playlist_sort = ui_manager_new_action_group("action_playlist_sort"); + gtk_action_group_add_actions( + action_group_playlist_sort, action_entries_playlist_sort, + G_N_ELEMENTS(action_entries_playlist_sort), NULL ); + + action_group_equalizer = ui_manager_new_action_group("action_equalizer"); + gtk_action_group_add_actions( + action_group_equalizer, action_entries_equalizer, + G_N_ELEMENTS(action_entries_equalizer), NULL); +#endif + /* ui */ + ui_manager = gtk_ui_manager_new(); + gtk_ui_manager_insert_action_group( ui_manager , toggleaction_group_others , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_anamode , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_anatype , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_scomode , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_vprmode , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_wshmode , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_refrate , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_anafoff , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_peafoff , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_vismode , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , radioaction_group_viewtime , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_playback , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_playlist , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_visualization , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_view , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_others , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_playlist_add , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_playlist_select , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_playlist_delete , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_playlist_sort , 0 ); + gtk_ui_manager_insert_action_group( ui_manager , action_group_equalizer , 0 ); + + return; +} + +#ifdef GDK_WINDOWING_QUARTZ +static GtkWidget *carbon_menubar; +#endif + +static void +ui_manager_create_menus_init_pmenu( gchar * path ) +{ + 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; +} + + +void +ui_manager_create_menus ( void ) +{ + GError *gerr = NULL; + + /* attach xml menu definitions */ + gtk_ui_manager_add_ui_from_file( ui_manager , DATA_DIR "/ui/mainwin.ui" , &gerr ); + + if ( gerr != NULL ) + { + g_critical( "Error creating UI: %s" , gerr->message ); + g_error_free( gerr ); + return; + } + + /* create GtkMenu widgets using path from xml definitions */ + mainwin_songname_menu = ui_manager_get_popup_menu( ui_manager , "/mainwin-menus/songname-menu" ); + mainwin_visualization_menu = ui_manager_get_popup_menu( ui_manager , "/mainwin-menus/main-menu/visualization" ); + mainwin_playback_menu = ui_manager_get_popup_menu( ui_manager , "/mainwin-menus/main-menu/playback" ); + mainwin_playlist_menu = ui_manager_get_popup_menu( ui_manager , "/mainwin-menus/main-menu/playlist" ); + 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" ); + +#ifdef GDK_WINDOWING_QUARTZ + gtk_ui_manager_add_ui_from_file( ui_manager , DATA_DIR "/ui/carbon-menubar.ui" , &gerr ); + + if ( gerr != NULL ) + { + g_critical( "Error creating UI: %s" , gerr->message ); + g_error_free( gerr ); + return; + } + + carbon_menubar = ui_manager_get_popup_menu( ui_manager , "/carbon-menubar/main-menu" ); + sync_menu_takeover_menu(GTK_MENU_SHELL(carbon_menubar)); +#endif + + gtk_ui_manager_add_ui_from_file( ui_manager , DATA_DIR "/ui/playlist.ui" , &gerr ); + + if ( gerr != NULL ) + { + g_critical( "Error creating UI: %s" , gerr->message ); + g_error_free( gerr ); + return; + } + + playlistwin_popup_menu = ui_manager_get_popup_menu(ui_manager, "/playlist-menus/playlist-rightclick-menu"); + + playlistwin_pladd_menu = ui_manager_get_popup_menu(ui_manager, "/playlist-menus/add-menu"); + playlistwin_pldel_menu = ui_manager_get_popup_menu(ui_manager, "/playlist-menus/del-menu"); + playlistwin_plsel_menu = ui_manager_get_popup_menu(ui_manager, "/playlist-menus/select-menu"); + 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" ); + 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 ); + + if ( gerr != NULL ) + { + g_critical( "Error creating UI: %s" , gerr->message ); + g_error_free( gerr ); + return; + } + + equalizerwin_presets_menu = ui_manager_get_popup_menu(ui_manager, "/equalizer-menus/preset-menu"); + + menu_created = TRUE; + + return; +} + + +GtkAccelGroup * +ui_manager_get_accel_group ( void ) +{ + return gtk_ui_manager_get_accel_group( ui_manager ); +} + + +GtkWidget * +ui_manager_get_popup_menu ( GtkUIManager * self , const gchar * path ) +{ + GtkWidget *menu_item = gtk_ui_manager_get_widget( self , path ); + + if (GTK_IS_MENU_ITEM(menu_item)) + return gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item)); + else + return NULL; +} + + +static void +menu_popup_pos_func (GtkMenu * menu , gint * x , gint * y , gboolean * push_in , gint * point ) +{ + GtkRequisition requisition; + gint screen_width; + gint screen_height; + + gtk_widget_size_request(GTK_WIDGET(menu), &requisition); + + screen_width = gdk_screen_width(); + screen_height = gdk_screen_height(); + + *x = CLAMP(point[0] - 2, 0, MAX(0, screen_width - requisition.width)); + *y = CLAMP(point[1] - 2, 0, MAX(0, screen_height - requisition.height)); + + *push_in = FALSE; +} + + +void +ui_manager_popup_menu_show ( GtkMenu * menu , gint x , gint y , guint button , guint time ) +{ + gint pos[2]; + pos[0] = x; + pos[1] = y; + + gtk_menu_popup( menu , NULL , NULL , + (GtkMenuPositionFunc) menu_popup_pos_func , pos , button , time ); +} + + + +/******************************/ +/* 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 +menu_plugin_item_add( gint menu_id , GtkWidget * item ) +{ + if ( menu_created ) + { + GtkWidget *plugins_menu = NULL; + GtkWidget *plugins_menu_item = audacious_menu_plugin_menuwid( menu_id ); + if ( plugins_menu_item ) + { + gint ic = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(plugins_menu_item),"ic")); + if ( ic == 0 ) /* no items under plugins_menu_item, create the submenu */ + { + plugins_menu = gtk_menu_new(); + gtk_menu_item_set_submenu( GTK_MENU_ITEM(plugins_menu_item), plugins_menu ); + } + else /* items available under plugins_menu_item, pick the existing submenu */ + { + plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + if ( !plugins_menu ) return -1; + } + gtk_menu_shell_append( GTK_MENU_SHELL(plugins_menu) , item ); + gtk_widget_show( plugins_menu_item ); + g_object_set_data( G_OBJECT(plugins_menu_item) , "ic" , GINT_TO_POINTER(++ic) ); + return 0; /* success */ + } + } + return -1; /* failure */ +} + + +gint +menu_plugin_item_remove( gint menu_id , GtkWidget * item ) +{ + if ( menu_created ) + { + GtkWidget *plugins_menu = NULL; + GtkWidget *plugins_menu_item = audacious_menu_plugin_menuwid( menu_id ); + if ( plugins_menu_item ) + { + gint ic = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(plugins_menu_item),"ic")); + if ( ic > 0 ) + { + plugins_menu = gtk_menu_item_get_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + if ( plugins_menu ) + { + /* remove the plugin-added entry */ + gtk_container_remove( GTK_CONTAINER(plugins_menu) , item ); + g_object_set_data( G_OBJECT(plugins_menu_item) , "ic" , GINT_TO_POINTER(--ic) ); + if ( ic == 0 ) /* if the menu is empty now, destroy it */ + { + gtk_menu_item_remove_submenu( GTK_MENU_ITEM(plugins_menu_item) ); + gtk_widget_destroy( plugins_menu ); + gtk_widget_hide( plugins_menu_item ); + } + return 0; /* success */ + } + } + } + } + return -1; /* failure */ +} diff -r f9ccfae6a5f6 -r 7cd898f08f31 src/skins/ui_manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/skins/ui_manager.h Wed May 21 12:37:40 2008 +0200 @@ -0,0 +1,77 @@ +/* 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. + */ + +#ifndef AUDACIOUS_UI_MANAGER_H +#define AUDACIOUS_UI_MANAGER_H + +#include +#include +#include + +G_BEGIN_DECLS + +GtkWidget *mainwin_songname_menu; +GtkWidget *mainwin_general_menu; +GtkWidget *mainwin_visualization_menu; +GtkWidget *mainwin_playback_menu; +GtkWidget *mainwin_playlist_menu; +GtkWidget *mainwin_view_menu; + +GtkWidget *playlistwin_pladd_menu; +GtkWidget *playlistwin_pldel_menu; +GtkWidget *playlistwin_plsel_menu; +GtkWidget *playlistwin_plsort_menu; +GtkWidget *playlistwin_pllist_menu; +GtkWidget *playlistwin_popup_menu; + +GtkWidget *equalizerwin_presets_menu; + +GtkActionGroup *toggleaction_group_others; +GtkActionGroup *radioaction_group_anamode; /* Analyzer mode */ +GtkActionGroup *radioaction_group_anatype; /* Analyzer type */ +GtkActionGroup *radioaction_group_scomode; /* Scope mode */ +GtkActionGroup *radioaction_group_vprmode; /* Voiceprint mode */ +GtkActionGroup *radioaction_group_wshmode; /* WindowShade VU mode */ +GtkActionGroup *radioaction_group_refrate; /* Refresh rate */ +GtkActionGroup *radioaction_group_anafoff; /* Analyzer Falloff */ +GtkActionGroup *radioaction_group_peafoff; /* Peak Falloff */ +GtkActionGroup *radioaction_group_vismode; /* Visualization mode */ +GtkActionGroup *radioaction_group_viewtime; /* View time (remaining/elapsed) */ +GtkActionGroup *action_group_playback; +GtkActionGroup *action_group_visualization; +GtkActionGroup *action_group_view; +GtkActionGroup *action_group_others; +GtkActionGroup *action_group_playlist; +GtkActionGroup *action_group_playlist_add; +GtkActionGroup *action_group_playlist_select; +GtkActionGroup *action_group_playlist_delete; +GtkActionGroup *action_group_playlist_sort; +GtkActionGroup *action_group_equalizer; + + +void ui_manager_init ( void ); +void ui_manager_create_menus ( void ); +GtkAccelGroup * ui_manager_get_accel_group ( void ); +GtkWidget * ui_manager_get_popup_menu ( GtkUIManager * , const gchar * ); +void ui_manager_popup_menu_show( GtkMenu * , gint , gint , guint , guint ); +#define popup_menu_show(x1,x2,x3,x4,x5) ui_manager_popup_menu_show(x1,x2,x3,x4,x5) + +G_END_DECLS + +#endif /* AUDACIOUS_UI_MANAGER_H */