Пример #1
0
static void settings_cb (GtkMenuItem * settings, PluginHandle * plugin)
{
    if (! aud_plugin_get_enabled (plugin))
        return;

    aud_plugin_do_configure (plugin);
}
Пример #2
0
void activate_search_tool (void)
{
    if (! search_tool)
        return;

    if (! aud_plugin_get_enabled (search_tool))
        aud_plugin_enable (search_tool, TRUE);

    aud_plugin_send_message (search_tool, "grab focus", NULL, 0);
}
Пример #3
0
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);
    }
}
Пример #4
0
static bool_t watch_cb (PluginHandle * plugin, GtkCheckMenuItem * item)
{
    bool_t enabled = aud_plugin_get_enabled (plugin);
    gtk_check_menu_item_set_active (item, enabled);

    GtkWidget * settings = g_object_get_data ((GObject *) item, "settings");
    if (settings != NULL)
        gtk_widget_set_sensitive (settings, enabled);

    return TRUE;
}
Пример #5
0
static gboolean add_item_cb (PluginHandle * plugin, IfaceMenuAddState * state)
{
    GtkWidget * item = gtk_radio_menu_item_new_with_label (state->group,
     aud_plugin_get_name (plugin));
    state->group = gtk_radio_menu_item_get_group ((GtkRadioMenuItem *) item);
    if (aud_plugin_get_enabled (plugin))
        gtk_check_menu_item_set_active ((GtkCheckMenuItem *) item, TRUE);
    gtk_menu_shell_append ((GtkMenuShell *) state->menu, item);
    g_signal_connect (item, "activate", (GCallback) switch_cb, plugin);
    gtk_widget_show (item);
    return TRUE;
}
Пример #6
0
static bool_t add_item_cb (PluginHandle * plugin, GtkWidget * menu)
{
    GtkWidget * item = gtk_check_menu_item_new_with_label (aud_plugin_get_name
     (plugin));
    gtk_check_menu_item_set_active ((GtkCheckMenuItem *) item,
     aud_plugin_get_enabled (plugin));
    gtk_menu_shell_append ((GtkMenuShell *) menu, item);
    aud_plugin_add_watch (plugin, (PluginForEachFunc) watch_cb, item);
    g_signal_connect (item, "toggled", (GCallback) enable_cb, plugin);
    g_signal_connect (item, "destroy", (GCallback) destroy_cb, plugin);
    gtk_widget_show (item);

    if (aud_plugin_has_configure (plugin))
    {
        GtkWidget * settings = gtk_menu_item_new_with_label (_("settings ..."));
        gtk_widget_set_sensitive (settings, aud_plugin_get_enabled (plugin));
        g_object_set_data ((GObject *) item, "settings", settings);
        gtk_menu_shell_append ((GtkMenuShell *) menu, settings);
        g_signal_connect (settings, "activate", (GCallback) settings_cb, plugin);
        gtk_widget_show (settings);
    }

    return TRUE;
}
Пример #7
0
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;
}
Пример #8
0
static gboolean search_tool_toggled (PluginHandle * plugin, void * unused)
{
    gtk_toggle_tool_button_set_active ((GtkToggleToolButton *) search_button,
     aud_plugin_get_enabled (plugin));
    return TRUE;
}