EXPORT void mlpgui_jump_to_track (void) { bool_t create = (! jump_to_track_win); if (create) create_window (); g_return_if_fail (filter_entry); if (mlp_get_bool ("mlpgui", "remember_jtf_entry")) gtk_editable_select_region ((GtkEditable *) filter_entry, 0, -1); else gtk_entry_set_text ((GtkEntry *) filter_entry, ""); if (! watching) { fill_list (); hook_associate ("playlist update", update_cb, NULL); hook_associate ("playlist activate", activate_cb, NULL); watching = TRUE; } if (create) gtk_widget_show_all (jump_to_track_win); else gtk_window_present ((GtkWindow *) jump_to_track_win); gtk_widget_grab_focus (filter_entry); }
void equalizerwin_create(void) { equalizer_presets = aud_equalizer_read_presets("eq.preset"); equalizer_auto_presets = aud_equalizer_read_presets("eq.auto_preset"); if (! equalizer_presets) equalizer_presets = index_new (); if (! equalizer_auto_presets) equalizer_auto_presets = index_new (); equalizerwin_create_window(); gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() ); equalizerwin_create_widgets(); window_show_all (equalizerwin); g_signal_connect (equalizerwin, "destroy", (GCallback) equalizerwin_destroyed, NULL); hook_associate ("set equalizer_active", (HookFunction) update_from_config, NULL); hook_associate ("set equalizer_bands", (HookFunction) update_from_config, NULL); hook_associate ("set equalizer_preamp", (HookFunction) update_from_config, NULL); int playlist = aud_playlist_get_playing (); /* Load preset for the first song. FIXME: Doing this at interface load is really too late as the song may already be started. Really, this stuff shouldn't be in the interface plugin at all but in core. -jlindgren */ if (playlist != -1) position_cb (GINT_TO_POINTER (playlist), NULL); hook_associate ("playlist position", position_cb, NULL); }
void audgui_queue_manager_show (void) { if (qm_win) { gtk_window_present ((GtkWindow *) qm_win); return; } qm_win = gtk_dialog_new_with_buttons (_("Queue Manager"), NULL, 0, GTK_STOCK_REMOVE, RESPONSE_REMOVE, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_window_set_default_size ((GtkWindow *) qm_win, 250, 250); GtkWidget * vbox = gtk_dialog_get_content_area ((GtkDialog *) qm_win); GtkWidget * scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start ((GtkBox *) vbox, scrolled, TRUE, TRUE, 0); gint count = aud_playlist_queue_count (aud_playlist_get_active ()); qm_list = audgui_list_new (& callbacks, NULL, count); gtk_tree_view_set_headers_visible ((GtkTreeView *) qm_list, FALSE); audgui_list_add_column (qm_list, NULL, 0, G_TYPE_INT, FALSE); audgui_list_add_column (qm_list, NULL, 1, G_TYPE_STRING, TRUE); gtk_container_add ((GtkContainer *) scrolled, qm_list); hook_associate ("playlist activate", update_hook, NULL); hook_associate ("playlist update", update_hook, NULL); g_signal_connect (qm_win, "destroy", (GCallback) destroy_cb, NULL); g_signal_connect (qm_win, "key-press-event", (GCallback) keypress_cb, NULL); g_signal_connect (qm_win, "response", (GCallback) response_cb, NULL); gtk_widget_show_all (qm_win); }
void start(void) { sc_going = 1; gchar * username = mlp_get_string ("audioscrobbler", "username"); gchar * password = mlp_get_string ("audioscrobbler", "password"); gchar * sc_url = mlp_get_string ("audioscrobbler", "sc_url"); if ((!username || !password) || (!*username || !*password)) { AUDDBG("username/password not found - not starting last.fm support"); sc_going = 0; } else sc_init(username, password, sc_url); g_free (username); g_free (password); g_free (sc_url); m_scrobbler = g_mutex_new(); hook_associate("playback begin", mlp_hook_playback_begin, NULL); hook_associate("playback stop", mlp_hook_playback_end, NULL); AUDDBG("plugin started"); sc_idle(m_scrobbler); }
static GtkWidget * create_slider (const char * name, int band) { GtkWidget * vbox, * slider, * label; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); label = gtk_label_new (name); gtk_label_set_angle ((GtkLabel *) label, 90); gtk_box_pack_start ((GtkBox *) vbox, label, TRUE, FALSE, 0); slider = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, -EQUALIZER_MAX_GAIN, EQUALIZER_MAX_GAIN, 1); gtk_scale_set_draw_value ((GtkScale *) slider, TRUE); gtk_scale_set_value_pos ((GtkScale *) slider, GTK_POS_BOTTOM); gtk_widget_set_size_request (slider, -1, 120); g_object_set_data ((GObject *) slider, "band", GINT_TO_POINTER (band)); g_signal_connect ((GObject *) slider, "format-value", (GCallback) format_value, NULL); g_signal_connect ((GObject *) slider, "value-changed", (GCallback) slider_moved, NULL); slider_update (NULL, (GtkRange *) slider); if (band == -1) hook_associate ("set equalizer_preamp", (HookFunction) slider_update, slider); else hook_associate ("set equalizer_bands", (HookFunction) slider_update, slider); gtk_box_pack_start ((GtkBox *) vbox, slider, FALSE, FALSE, 0); return vbox; }
static GtkWidget * create_playlist_manager (void) { GtkWidget * playman_win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_type_hint ((GtkWindow *) playman_win, GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_title ((GtkWindow *) playman_win, _("Playlist Manager")); gtk_container_set_border_width ((GtkContainer *) playman_win, 6); gtk_widget_set_size_request (playman_win, 400, 250); g_signal_connect (playman_win, "destroy", (GCallback) destroy_cb, NULL); audgui_destroy_on_escape (playman_win); GtkWidget * playman_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add ((GtkContainer *) playman_win, playman_vbox); /* ListView */ GtkWidget * playman_pl_lv = audgui_list_new (& callbacks, NULL, aud_playlist_count ()); audgui_list_add_column (playman_pl_lv, _("Title"), 0, G_TYPE_STRING, -1); audgui_list_add_column (playman_pl_lv, _("Entries"), 1, G_TYPE_INT, 7); audgui_list_set_highlight (playman_pl_lv, aud_playlist_get_playing ()); gtk_tree_view_set_search_equal_func ((GtkTreeView *) playman_pl_lv, search_cb, NULL, NULL); hook_associate ("playlist update", update_hook, playman_pl_lv); hook_associate ("playlist activate", activate_hook, playman_pl_lv); hook_associate ("playlist set playing", position_hook, playman_pl_lv); GtkWidget * playman_pl_lv_sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) playman_pl_lv_sw, GTK_SHADOW_IN); gtk_scrolled_window_set_policy ((GtkScrolledWindow *) playman_pl_lv_sw, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add ((GtkContainer *) playman_pl_lv_sw, playman_pl_lv); gtk_box_pack_start ((GtkBox *) playman_vbox, playman_pl_lv_sw, TRUE, TRUE, 0); /* ButtonBox */ GtkWidget * playman_button_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); GtkWidget * new_button = audgui_button_new (_("_New"), "document-new", new_cb, NULL); GtkWidget * delete_button = audgui_button_new (_("_Remove"), "edit-delete", delete_cb, NULL); GtkWidget * rename_button = audgui_button_new (_("Ren_ame"), "insert-text", rename_cb, NULL); GtkWidget * play_button = audgui_button_new (_("_Play"), "media-playback-start", play_cb, NULL); gtk_container_add ((GtkContainer *) playman_button_hbox, new_button); gtk_container_add ((GtkContainer *) playman_button_hbox, delete_button); gtk_box_pack_end ((GtkBox *) playman_button_hbox, play_button, FALSE, FALSE, 0); gtk_box_pack_end ((GtkBox *) playman_button_hbox, rename_button, FALSE, FALSE, 0); gtk_container_add ((GtkContainer *) playman_vbox, playman_button_hbox); /* CheckButton */ GtkWidget * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) playman_vbox, hbox, FALSE, FALSE, 0); GtkWidget * check_button = gtk_check_button_new_with_mnemonic (_("_Close dialog on activating playlist")); gtk_box_pack_start ((GtkBox *) hbox, check_button, FALSE, FALSE, 0); gtk_toggle_button_set_active ((GtkToggleButton *) check_button, aud_get_bool ("audgui", "playlist_manager_close_on_activate")); g_signal_connect (check_button, "toggled", (GCallback) close_on_activate_cb, NULL); return playman_win; }
static gboolean init (void) { hook_associate("title change", (HookFunction) lyricwiki_playback_began, NULL); hook_associate("playback ready", (HookFunction) lyricwiki_playback_began, NULL); build_widget(); lyricwiki_playback_began(); return TRUE; }
static void si_enable(gboolean enable) { static GtkStatusIcon *si_applet = NULL; if (enable && ! si_applet) { GtkWidget *si_smenu; si_applet = si_create(); if (si_applet == NULL) { g_warning("StatusIcon plugin: unable to create a status icon.\n"); return; } g_object_set_data(G_OBJECT(si_applet), "timer_id", GINT_TO_POINTER(0)); g_object_set_data(G_OBJECT(si_applet), "timer_active", GINT_TO_POINTER(0)); g_object_set_data(G_OBJECT(si_applet), "popup_active", GINT_TO_POINTER(0)); g_signal_connect(G_OBJECT(si_applet), "button-press-event", G_CALLBACK(si_cb_btpress), NULL); g_signal_connect(G_OBJECT(si_applet), "scroll-event", G_CALLBACK(si_cb_btscroll), NULL); g_signal_connect(G_OBJECT(si_applet), "query-tooltip", G_CALLBACK(si_cb_tooltip), NULL); gtk_status_icon_set_has_tooltip(si_applet, TRUE); gtk_status_icon_set_visible(si_applet, TRUE); /* small menu that can be used in place of the audacious standard one */ si_smenu = si_smallmenu_create(); g_object_set_data(G_OBJECT(si_applet), "smenu", si_smenu); hook_associate("title change", si_popup_reshow, si_applet); hook_associate("window close", si_window_close, NULL); } if (! enable && si_applet) { /* Prevent accidentally hiding of the interface * by disabling the plugin while Audacious is closed to the tray. */ extern GeneralPlugin _aud_plugin_self; PluginHandle *si = aud_plugin_by_header(&_aud_plugin_self); if (! aud_plugin_get_enabled(si) && ! aud_interface_is_shown()) aud_interface_show(TRUE); GtkWidget *si_smenu = g_object_get_data(G_OBJECT(si_applet), "smenu"); si_popup_timer_stop(si_applet); /* just in case the timer is active */ gtk_widget_destroy(si_smenu); g_object_unref(si_applet); si_applet = NULL; hook_dissociate("title change", si_popup_reshow); hook_dissociate("window close", si_window_close); } }
static void * album_get_widget (void) { GtkWidget * widget = gtk_drawing_area_new (); gtk_widget_set_size_request (widget, 96, 96); g_signal_connect (widget, "draw", (GCallback) album_draw, NULL); g_signal_connect (widget, "configure-event", (GCallback) album_configure, NULL); g_signal_connect (widget, "destroy", (GCallback) album_cleanup, NULL); hook_associate ("playback begin", (HookFunction) album_update, widget); hook_associate ("current art ready", (HookFunction) album_update, widget); hook_associate ("playback stop", (HookFunction) album_clear, widget); return widget; }
static gboolean init (void) { read_config(); hook_associate("playback begin", songchange_playback_begin, NULL); hook_associate("playback end", songchange_playback_end, NULL); hook_associate("playlist end reached", songchange_playlist_eof, NULL); ttc_prevs = g_malloc0(sizeof(songchange_playback_ttc_prevs_t)); ttc_prevs->title = NULL; ttc_prevs->filename = NULL; // hook_associate( "playlist set info" , songchange_playback_ttc , ttc_prevs ); return TRUE; }
static void aosd_trigger_func_pb_titlechange_onoff ( gboolean turn_on ) { static aosd_pb_titlechange_prevs_t *prevs = NULL; if ( turn_on == TRUE ) { prevs = g_malloc0(sizeof(aosd_pb_titlechange_prevs_t)); prevs->title = NULL; prevs->filename = NULL; hook_associate( "title change" , aosd_trigger_func_pb_titlechange_cb , prevs ); } else { hook_dissociate( "title change" , aosd_trigger_func_pb_titlechange_cb ); if ( prevs != NULL ) { if ( prevs->title != NULL ) g_free( prevs->title ); if ( prevs->filename != NULL ) g_free( prevs->filename ); g_free( prevs ); prevs = NULL; } } return; }
void load_playlists (void) { load_playlists_real (); playlist_load_state (); state_changed = FALSE; if (! hooks_added) { hook_associate ("playlist update", update_cb, NULL); hook_associate ("playlist activate", state_cb, NULL); hook_associate ("playlist position", state_cb, NULL); hooks_added = TRUE; } }
static bool_t search_init (void) { find_playlist (); search_terms = index_new (); items = index_new (); selection = g_array_new (FALSE, FALSE, 1); update_database (); hook_associate ("playlist add complete", add_complete_cb, NULL); hook_associate ("playlist scan complete", scan_complete_cb, NULL); hook_associate ("playlist update", playlist_update_cb, NULL); return TRUE; }
static void aosd_trigger_func_pb_start_onoff(gboolean turn_on) { if (turn_on == TRUE) hook_associate("playback begin", aosd_trigger_func_pb_start_cb, NULL); else hook_dissociate("playback begin", aosd_trigger_func_pb_start_cb); return; }
static void aosd_trigger_func_vol_change_onoff ( gboolean turn_on ) { if ( turn_on == TRUE ) hook_associate( "volume set" , aosd_trigger_func_vol_change_cb , NULL ); else hook_dissociate( "volume set" , aosd_trigger_func_vol_change_cb ); return; }
static void aosd_trigger_func_pb_pauseoff_onoff ( gboolean turn_on ) { if ( turn_on == TRUE ) hook_associate( "playback unpause" , aosd_trigger_func_pb_pauseoff_cb , NULL ); else hook_dissociate( "playback unpause" , aosd_trigger_func_pb_pauseoff_cb ); return; }
static GtkWidget * create_on_off (void) { GtkWidget * on_off = gtk_check_button_new_with_mnemonic (_("_Enable")); g_signal_connect ((GObject *) on_off, "toggled", (GCallback) on_off_cb, NULL); hook_associate ("set equalizer_active", (HookFunction) on_off_update, on_off); on_off_update (NULL, on_off); return on_off; }
static GtkWidget * create_window (void) { const char * const names[AUD_EQUALIZER_NBANDS] = {N_("31 Hz"), N_("63 Hz"), N_("125 Hz"), N_("250 Hz"), N_("500 Hz"), N_("1 kHz"), N_("2 kHz"), N_("4 kHz"), N_("8 kHz"), N_("16 kHz")}; GtkWidget * window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title ((GtkWindow *) window, _("Equalizer")); gtk_window_set_type_hint ((GtkWindow *) window, GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_resizable ((GtkWindow *) window, FALSE); gtk_container_set_border_width ((GtkContainer *) window, 6); audgui_destroy_on_escape (window); GtkWidget * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add ((GtkContainer *) window, vbox); gtk_box_pack_start ((GtkBox *) vbox, create_on_off (), FALSE, FALSE, 0); GtkWidget * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0); GtkWidget * preamp = create_slider (_("Preamp"), -1, hbox); g_object_set_data ((GObject *) window, "preamp", preamp); gtk_box_pack_start ((GtkBox *) hbox, gtk_separator_new (GTK_ORIENTATION_VERTICAL), FALSE, FALSE, 0); for (int i = 0; i < AUD_EQUALIZER_NBANDS; i ++) { GtkWidget * slider = create_slider (_(names[i]), i, hbox); SPRINTF (slider_id, "slider%d", i); g_object_set_data ((GObject *) window, slider_id, slider); } update_sliders (NULL, window); hook_associate ("set equalizer_preamp", (HookFunction) update_sliders, window); hook_associate ("set equalizer_bands", (HookFunction) update_sliders, window); g_signal_connect (window, "destroy", (GCallback) destroy_cb, NULL); return window; }
GtkWidget * ui_infoarea_new (void) { g_return_val_if_fail (! area, NULL); area = g_slice_new0 (UIInfoArea); area->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); area->main = gtk_drawing_area_new (); gtk_widget_set_size_request (area->main, ICON_SIZE + 2 * SPACING, HEIGHT); gtk_box_pack_start ((GtkBox *) area->box, area->main, TRUE, TRUE, 0); g_signal_connect (area->main, "draw", (GCallback) draw_cb, NULL); hook_associate ("playlist update", (HookFunction) ui_infoarea_set_title, NULL); hook_associate ("playback begin", (HookFunction) ui_infoarea_playback_start, NULL); hook_associate ("playback stop", (HookFunction) ui_infoarea_playback_stop, NULL); hook_associate ("current art ready", (HookFunction) album_art_ready, NULL); g_signal_connect (area->box, "destroy", (GCallback) destroy_cb, NULL); if (aud_drct_get_playing ()) { ui_infoarea_playback_start (); /* skip fade-in */ area->alpha = 1; if (area->fade_timeout) { g_source_remove (area->fade_timeout); area->fade_timeout = 0; } } GtkWidget * frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type ((GtkFrame *) frame, GTK_SHADOW_IN); gtk_container_add ((GtkContainer *) frame, area->box); return frame; }
void aosd_trigger_start ( aosd_cfg_osd_trigger_t * cfg_trigger ) { gint i = 0; for ( i = 0 ; i < cfg_trigger->active->len ; i++ ) { gint trig_code = g_array_index( cfg_trigger->active , gint , i ); aosd_triggers[trig_code].onoff_func( TRUE ); } /* When called, this hook will display the text of the user pointer or the current playing song, if NULL */ hook_associate( "aosd toggle" , aosd_trigger_func_hook_cb , NULL ); return; }
void mpris_signals_init (void) { #ifdef USE_DBUS hook_associate ("playback begin", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_PLAY)); hook_associate ("playback pause", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_PAUSE)); hook_associate ("playback unpause", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_PLAY)); hook_associate ("playback stop", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_STOP)); hook_associate ("set shuffle", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_INVALID)); hook_associate ("set repeat", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_INVALID)); hook_associate ("set no_playlist_advance", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_INVALID)); #endif }
void mpris_tracklist_init(MprisTrackList * object) { dbus_g_object_type_install_info(mpris_tracklist_get_type(), &dbus_glib_mpris_tracklist_object_info); // Register DBUS path dbus_g_connection_register_g_object(dbus_conn, AUDACIOUS_DBUS_PATH_MPRIS_TRACKLIST, G_OBJECT(object)); // Add signals DBusGProxy *proxy = object->proxy; if (proxy != NULL) { dbus_g_proxy_add_signal(proxy, "TrackListChange", G_TYPE_INT, G_TYPE_INVALID); } else { /* XXX / FIXME: Why does this happen? -- ccr */ AUDDBG ("object->proxy == NULL, not adding some signals.\n"); } hook_associate("playlist update", (HookFunction) mpris_playlist_update_hook, object); }
static void playback_start (int playlist, int entry, int seek_time, bool_t pause) { g_return_if_fail (! playing); current_filename = playlist_entry_get_filename (playlist, entry); g_return_if_fail (current_filename); playing = TRUE; playback_error = FALSE; ready_flag = FALSE; current_entry = -1; current_title = NULL; current_length = 0; initial_seek = seek_time; paused = pause; hook_associate ("playlist update", update_cb, NULL); pthread_create (& playback_thread_handle, NULL, playback_thread, NULL); hook_call ("playback begin", NULL); }
void ui_main_evlistener_init(void) { hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL); hook_associate("playback begin", ui_main_evlistener_playback_begin, NULL); hook_associate("playback ready", ui_main_evlistener_playback_begin, NULL); hook_associate("playback stop", ui_main_evlistener_playback_stop, NULL); hook_associate("playback pause", ui_main_evlistener_playback_pause, NULL); hook_associate("playback unpause", ui_main_evlistener_playback_unpause, NULL); hook_associate ("title change", (HookFunction) title_change, NULL); hook_associate ("info change", (HookFunction) info_change, NULL); hook_associate("playback seek", (HookFunction) mainwin_update_song_info, NULL); hook_associate ("set repeat", repeat_toggled, NULL); hook_associate ("set shuffle", shuffle_toggled, NULL); hook_associate ("set no_playlist_advance", no_advance_toggled, NULL); hook_associate ("set stop_after_current_song", stop_after_song_toggled, NULL); }
static void ui_hooks_associate(void) { hook_associate ("title change", (HookFunction) title_change_cb, NULL); hook_associate ("playback begin", (HookFunction) ui_playback_begin, NULL); hook_associate ("playback ready", (HookFunction) ui_playback_ready, NULL); hook_associate ("playback pause", (HookFunction) pause_cb, NULL); hook_associate ("playback unpause", (HookFunction) pause_cb, NULL); hook_associate ("playback stop", (HookFunction) ui_playback_stop, NULL); hook_associate("playlist update", ui_playlist_notebook_update, NULL); hook_associate ("playlist activate", ui_playlist_notebook_activate, NULL); hook_associate ("playlist set playing", ui_playlist_notebook_set_playing, NULL); hook_associate ("playlist position", ui_playlist_notebook_position, NULL); hook_associate ("set shuffle", update_toggles, NULL); hook_associate ("set repeat", update_toggles, NULL); hook_associate ("config save", (HookFunction) config_save, NULL); }
bool_t mpris2_init (void) { GError * error = NULL; bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, & error); if (! bus) { fprintf (stderr, "mpris2: %s\n", error->message); g_error_free (error); return FALSE; } g_bus_own_name_on_connection (bus, "org.mpris.MediaPlayer2.audacious", 0, NULL, NULL, NULL, NULL); object_core = (GObject *) mpris_media_player2_skeleton_new (); g_object_set (object_core, "can-quit", TRUE, "can-raise", TRUE, "desktop-entry", "audacious", "identity", "Audacious", NULL); g_signal_connect (object_core, "handle-quit", (GCallback) quit_cb, NULL); g_signal_connect (object_core, "handle-raise", (GCallback) raise_cb, NULL); object_player = (GObject *) mpris_media_player2_player_skeleton_new (); g_object_set (object_player, "can-control", TRUE, "can-go-next", TRUE, "can-go-previous", TRUE, "can-pause", TRUE, "can-play", TRUE, "can-seek", TRUE, NULL); update_timer = g_timeout_add (250, (GSourceFunc) update, object_player); update_playback_status (NULL, object_player); if (aud_drct_get_playing () && aud_drct_get_ready ()) emit_seek (NULL, object_player); hook_associate ("playback begin", (HookFunction) update_playback_status, object_player); hook_associate ("playback pause", (HookFunction) update_playback_status, object_player); hook_associate ("playback stop", (HookFunction) update_playback_status, object_player); hook_associate ("playback unpause", (HookFunction) update_playback_status, object_player); hook_associate ("playlist set playing", (HookFunction) update_metadata, object_player); hook_associate ("playlist position", (HookFunction) update_metadata, object_player); hook_associate ("playlist update", (HookFunction) update_metadata, object_player); hook_associate ("playback ready", (HookFunction) emit_seek, object_player); hook_associate ("playback seek", (HookFunction) emit_seek, object_player); g_signal_connect (object_player, "handle-next", (GCallback) next_cb, NULL); g_signal_connect (object_player, "handle-pause", (GCallback) pause_cb, NULL); g_signal_connect (object_player, "handle-play", (GCallback) play_cb, NULL); g_signal_connect (object_player, "handle-play-pause", (GCallback) play_pause_cb, NULL); g_signal_connect (object_player, "handle-previous", (GCallback) previous_cb, NULL); g_signal_connect (object_player, "handle-seek", (GCallback) seek_cb, NULL); g_signal_connect (object_player, "handle-set-position", (GCallback) set_position_cb, NULL); g_signal_connect (object_player, "handle-stop", (GCallback) stop_cb, NULL); g_signal_connect (object_player, "notify::volume", (GCallback) volume_changed, NULL); if (! g_dbus_interface_skeleton_export ((GDBusInterfaceSkeleton *) object_core, bus, "/org/mpris/MediaPlayer2", & error) || ! g_dbus_interface_skeleton_export ((GDBusInterfaceSkeleton *) object_player, bus, "/org/mpris/MediaPlayer2", & error)) { mpris2_cleanup (); fprintf (stderr, "mpris2: %s\n", error->message); g_error_free (error); return FALSE; } return TRUE; }
EXPORT void audgui_playlist_manager (void) { GtkWidget * playman_vbox; GtkWidget * playman_pl_lv, * playman_pl_lv_sw; GtkWidget * playman_button_hbox; GtkWidget * new_button, * delete_button, * rename_button, * play_button; GtkWidget * hbox, * check_button; GdkGeometry playman_win_hints; if (playman_win) { gtk_window_present ((GtkWindow *) playman_win); return; } playman_win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_type_hint ((GtkWindow *) playman_win, GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_title ((GtkWindow *) playman_win, _("Playlist Manager")); gtk_container_set_border_width ((GtkContainer *) playman_win, 6); playman_win_hints.min_width = 400; playman_win_hints.min_height = 250; gtk_window_set_geometry_hints ((GtkWindow *) playman_win, playman_win, &playman_win_hints , GDK_HINT_MIN_SIZE); int x = aud_get_int ("audgui", "playlist_manager_x"); int y = aud_get_int ("audgui", "playlist_manager_y"); int w = aud_get_int ("audgui", "playlist_manager_w"); int h = aud_get_int ("audgui", "playlist_manager_h"); if (w && h) { gtk_window_move ((GtkWindow *) playman_win, x, y); gtk_window_set_default_size ((GtkWindow *) playman_win, w, h); } g_signal_connect (playman_win, "delete-event", (GCallback) hide_cb, NULL); audgui_hide_on_escape (playman_win); playman_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add ((GtkContainer *) playman_win, playman_vbox); /* ListView */ playman_pl_lv = audgui_list_new (& callbacks, NULL, aud_playlist_count ()); audgui_list_add_column (playman_pl_lv, _("Title"), 0, G_TYPE_STRING, -1); audgui_list_add_column (playman_pl_lv, _("Entries"), 1, G_TYPE_INT, 7); audgui_list_set_highlight (playman_pl_lv, aud_playlist_get_playing ()); gtk_tree_view_set_search_equal_func ((GtkTreeView *) playman_pl_lv, search_cb, NULL, NULL); hook_associate ("playlist update", update_hook, playman_pl_lv); hook_associate ("playlist activate", activate_hook, playman_pl_lv); hook_associate ("playlist set playing", position_hook, playman_pl_lv); playman_pl_lv_sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) playman_pl_lv_sw, GTK_SHADOW_IN); gtk_scrolled_window_set_policy ((GtkScrolledWindow *) playman_pl_lv_sw, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add ((GtkContainer *) playman_pl_lv_sw, playman_pl_lv); gtk_box_pack_start ((GtkBox *) playman_vbox, playman_pl_lv_sw, TRUE, TRUE, 0); /* ButtonBox */ playman_button_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); new_button = gtk_button_new_from_stock (GTK_STOCK_NEW); delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE); rename_button = gtk_button_new_with_mnemonic (_("_Rename")); gtk_button_set_image ((GtkButton *) rename_button, gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON)); play_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); gtk_container_add ((GtkContainer *) playman_button_hbox, new_button); gtk_container_add ((GtkContainer *) playman_button_hbox, delete_button); gtk_box_pack_end ((GtkBox *) playman_button_hbox, play_button, FALSE, FALSE, 0); gtk_box_pack_end ((GtkBox *) playman_button_hbox, rename_button, FALSE, FALSE, 0); gtk_container_add ((GtkContainer *) playman_vbox, playman_button_hbox); g_signal_connect (new_button, "clicked", (GCallback) new_cb, NULL); g_signal_connect (delete_button, "clicked", (GCallback) delete_cb, NULL); g_signal_connect (rename_button, "clicked", (GCallback) rename_cb, NULL); g_signal_connect (play_button, "clicked", (GCallback) play_cb, NULL); /* CheckButton */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) playman_vbox, hbox, FALSE, FALSE, 0); check_button = gtk_check_button_new_with_mnemonic (_("_Close dialog on activating playlist")); gtk_box_pack_start ((GtkBox *) hbox, check_button, FALSE, FALSE, 0); gtk_toggle_button_set_active ((GtkToggleButton *) check_button, aud_get_bool ("audgui", "playlist_manager_close_on_activate")); g_signal_connect (check_button, "toggled", (GCallback) close_on_activate_cb, NULL); gtk_widget_show_all (playman_win); hook_associate ("config save", save_config_cb, playman_win); }
static void populate_menu (GtkWidget * shell, const struct MenuItem * items, gint n_items, GtkAccelGroup * accel) { for (gint i = 0; i < n_items; i ++) { const struct MenuItem * item = & items[i]; GtkWidget * widget = NULL; if (item->name && item->func) /* normal widget */ { widget = gtk_image_menu_item_new_with_mnemonic (_(item->name)); g_signal_connect (widget, "activate", item->func, NULL); if (item->icon) gtk_image_menu_item_set_image ((GtkImageMenuItem *) widget, gtk_image_new_from_stock (item->icon, GTK_ICON_SIZE_MENU)); } else if (item->name && item->get && item->set) /* toggle widget */ { widget = gtk_check_menu_item_new_with_mnemonic (_(item->name)); gtk_check_menu_item_set_active ((GtkCheckMenuItem *) widget, item->get ()); g_signal_connect (widget, "toggled", (GCallback) toggled_cb, (void *) item); if (item->hook) { g_object_set_data ((GObject *) widget, "item", (void *) item); hook_associate (item->hook, (HookFunction) hook_cb, widget); g_signal_connect (widget, "destroy", (GCallback) unhook_cb, (void *) item); } } else if (item->name && (item->items || item->get_sub)) /* submenu */ { widget = gtk_image_menu_item_new_with_mnemonic (_(item->name)); if (item->icon) gtk_image_menu_item_set_image ((GtkImageMenuItem *) widget, gtk_image_new_from_stock (item->icon, GTK_ICON_SIZE_MENU)); GtkWidget * sub; if (item->get_sub) sub = item->get_sub (); else { sub = gtk_menu_new (); populate_menu (sub, item->items, item->n_items, accel); } gtk_menu_item_set_submenu ((GtkMenuItem *) widget, sub); } else if (item->sep) /* separator */ widget = gtk_separator_menu_item_new (); if (! widget) continue; if (item->key) gtk_widget_add_accelerator (widget, "activate", accel, item->key, item->mod, GTK_ACCEL_VISIBLE); gtk_widget_show (widget); gtk_menu_shell_append ((GtkMenuShell *) shell, widget); } }