static gboolean skins_init (void) { plugin_is_active = TRUE; g_log_set_handler(NULL, G_LOG_LEVEL_WARNING, g_log_default_handler, NULL); skins_init_paths(); skins_cfg_load(); audgui_set_default_icon(); audgui_register_stock_icons(); ui_manager_init(); ui_manager_create_menus(); init_skins(config.skin); mainwin_setup_menus(); if (aud_drct_get_playing ()) { ui_main_evlistener_playback_begin (NULL, NULL); if (aud_drct_get_paused ()) ui_main_evlistener_playback_pause (NULL, NULL); } else mainwin_update_song_info (); update_source = g_timeout_add (250, update_cb, NULL); return TRUE; }
static gboolean init (void) { search_tool = aud_plugin_lookup_basename ("search-tool"); aud_config_set_defaults ("gtkui", gtkui_defaults); audgui_set_default_icon(); audgui_register_stock_icons(); pw_col_init (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip ((GtkWindow *) window, FALSE); g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(window_delete), NULL); accel = gtk_accel_group_new (); gtk_window_add_accel_group ((GtkWindow *) window, accel); vbox_outer = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add ((GtkContainer *) window, vbox_outer); menu_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start ((GtkBox *) vbox_outer, menu_box, FALSE, FALSE, 0); toolbar = gtk_toolbar_new (); gtk_toolbar_set_style ((GtkToolbar *) toolbar, GTK_TOOLBAR_ICONS); GtkStyleContext * context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); gtk_box_pack_start ((GtkBox *) vbox_outer, toolbar, FALSE, FALSE, 0); /* search button */ if (search_tool) { search_button = toggle_button_new (GTK_STOCK_FIND, NULL, toggle_search_tool); gtk_toolbar_insert ((GtkToolbar *) toolbar, search_button, -1); gtk_toggle_tool_button_set_active ((GtkToggleToolButton *) search_button, aud_plugin_get_enabled (search_tool)); aud_plugin_add_watch (search_tool, search_tool_toggled, NULL); } /* playback buttons */ toolbar_button_add (toolbar, button_open_pressed, GTK_STOCK_OPEN); toolbar_button_add (toolbar, button_add_pressed, GTK_STOCK_ADD); button_play = toolbar_button_add (toolbar, aud_drct_play_pause, GTK_STOCK_MEDIA_PLAY); button_stop = toolbar_button_add (toolbar, aud_drct_stop, GTK_STOCK_MEDIA_STOP); toolbar_button_add (toolbar, aud_drct_pl_prev, GTK_STOCK_MEDIA_PREVIOUS); toolbar_button_add (toolbar, aud_drct_pl_next, GTK_STOCK_MEDIA_NEXT); /* time slider and label */ GtkToolItem * boxitem1 = gtk_tool_item_new (); gtk_tool_item_set_expand (boxitem1, TRUE); gtk_toolbar_insert ((GtkToolbar *) toolbar, boxitem1, -1); GtkWidget * box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add ((GtkContainer *) boxitem1, box1); slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL); gtk_range_set_increments ((GtkRange *) slider, 5000, 5000); gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE); gtk_widget_set_size_request(slider, 120, -1); gtk_widget_set_valign (slider, GTK_ALIGN_CENTER); gtk_widget_set_can_focus(slider, FALSE); gtk_box_pack_start ((GtkBox *) box1, slider, TRUE, TRUE, 6); label_time = markup_label_new(NULL); gtk_box_pack_end ((GtkBox *) box1, label_time, FALSE, FALSE, 6); gtk_widget_set_no_show_all (slider, TRUE); gtk_widget_set_no_show_all (label_time, TRUE); /* repeat and shuffle buttons */ button_repeat = toggle_button_new ("media-playlist-repeat", "RP", toggle_repeat); gtk_toolbar_insert ((GtkToolbar *) toolbar, button_repeat, -1); button_shuffle = toggle_button_new ("media-playlist-shuffle", "SF", toggle_shuffle); gtk_toolbar_insert ((GtkToolbar *) toolbar, button_shuffle, -1); /* volume button */ GtkToolItem * boxitem2 = gtk_tool_item_new (); gtk_toolbar_insert ((GtkToolbar *) toolbar, boxitem2, -1); GtkWidget * box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add ((GtkContainer *) boxitem2, box2); volume = gtk_volume_button_new(); gtk_button_set_relief(GTK_BUTTON(volume), GTK_RELIEF_NONE); gtk_scale_button_set_adjustment(GTK_SCALE_BUTTON(volume), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 100, 1, 5, 0))); gtk_widget_set_can_focus(volume, FALSE); gint lvol = 0, rvol = 0; aud_drct_get_volume(&lvol, &rvol); gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume), (lvol + rvol) / 2); gtk_box_pack_start ((GtkBox *) box2, volume, FALSE, FALSE, 0); /* main UI layout */ layout_load (); GtkWidget * layout = layout_new (); gtk_box_pack_start ((GtkBox *) vbox_outer, layout, TRUE, TRUE, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); layout_add_center (vbox); ui_playlist_notebook_new (); gtk_box_pack_start ((GtkBox *) vbox, (GtkWidget *) UI_PLAYLIST_NOTEBOOK, TRUE, TRUE, 0); /* optional UI elements */ show_menu (aud_get_bool ("gtkui", "menu_visible")); show_infoarea (aud_get_bool ("gtkui", "infoarea_visible")); if (aud_get_bool ("gtkui", "statusbar_visible")) { statusbar = ui_statusbar_new (); gtk_box_pack_end ((GtkBox *) vbox_outer, statusbar, FALSE, FALSE, 0); } AUDDBG("hooks associate\n"); ui_hooks_associate(); AUDDBG("playlist associate\n"); ui_playlist_notebook_populate(); g_signal_connect(slider, "change-value", G_CALLBACK(ui_slider_change_value_cb), NULL); g_signal_connect(slider, "button-press-event", G_CALLBACK(ui_slider_button_press_cb), NULL); g_signal_connect(slider, "button-release-event", G_CALLBACK(ui_slider_button_release_cb), NULL); volume_change_handler_id = g_signal_connect(volume, "value-changed", G_CALLBACK(ui_volume_value_changed_cb), NULL); g_signal_connect(volume, "pressed", G_CALLBACK(ui_volume_pressed_cb), NULL); g_signal_connect(volume, "released", G_CALLBACK(ui_volume_released_cb), NULL); update_volume_timeout_source = g_timeout_add(250, (GSourceFunc) ui_volume_slider_update, volume); g_signal_connect (window, "map-event", (GCallback) window_mapped_cb, NULL); g_signal_connect (window, "key-press-event", (GCallback) window_keypress_cb, NULL); g_signal_connect (UI_PLAYLIST_NOTEBOOK, "key-press-event", (GCallback) playlist_keypress_cb, NULL); if (aud_drct_get_playing ()) { ui_playback_begin (); if (aud_drct_get_ready ()) ui_playback_ready (); } else ui_playback_stop (); title_change_cb (); gtk_widget_show_all (vbox_outer); update_toggles (NULL, NULL); menu_rclick = make_menu_rclick (accel); menu_tab = make_menu_tab (accel); return TRUE; }