static void render_multi_pcm (const gfloat * pcm, gint channels)
{
    /* "VU meter" */
    if (config.vis_type != VIS_VOICEPRINT || ! aud_get_bool ("skins", "player_shaded"))
        return;

    guchar data[512];

    gint level = 38 + calc_peak_level (pcm, channels);
    data[0] = CLAMP (level, 0, 38);

    if (channels >= 2)
    {
        level = 38 + calc_peak_level (pcm + 1, channels);
        data[1] = CLAMP (level, 0, 38);
    }
    else
        data[1] = data[0];

    ui_svis_timeout_func (mainwin_svis, data);
}
示例#2
0
void show_infoarea (gboolean show)
{
    aud_set_bool ("gtkui", "infoarea_visible", show);

    if (show && ! infoarea)
    {
        infoarea = ui_infoarea_new ();
        g_signal_connect (infoarea, "destroy", (GCallback) gtk_widget_destroyed, & infoarea);
        gtk_box_pack_end ((GtkBox *) vbox, infoarea, FALSE, FALSE, 0);
        gtk_widget_show_all (infoarea);

        /* only turn on visualization if interface is shown */
        if (ui_is_shown ())
            ui_infoarea_show_vis (aud_get_bool ("gtkui", "infoarea_show_vis"));
    }

    if (! show && infoarea)
    {
        gtk_widget_destroy (infoarea);
        infoarea = NULL;
    }
}
示例#3
0
void resample_start (int * channels, int * rate)
{
    if (state)
    {
        src_delete (state);
        state = NULL;
    }

    int new_rate = 0;

    if (aud_get_bool ("resample", "use-mappings"))
    {
        char rate_s[16];
        str_itoa (* rate, rate_s, sizeof rate_s);
        new_rate = aud_get_int ("resample", rate_s);
    }

    if (! new_rate)
        new_rate = aud_get_int ("resample", "default-rate");

    new_rate = CLAMP (new_rate, MIN_RATE, MAX_RATE);

    if (new_rate == * rate)
        return;

    int method = aud_get_int ("resample", "method");
    int error;

    if ((state = src_new (method, * channels, & error)) == NULL)
    {
        RESAMPLE_ERROR (error);
        return;
    }

    stored_channels = * channels;
    ratio = (double) new_rate / * rate;
    * rate = new_rate;
}
示例#4
0
static void ui_show (gboolean show)
{
    if (show)
    {
        if (! ui_is_shown ())
            restore_window_size ();

        gtk_window_present ((GtkWindow *) window);

        /* turn visualization back on if necessary */
        ui_infoarea_show_vis (aud_get_bool ("gtkui", "infoarea_show_vis"));
    }
    else
    {
        if (ui_is_shown ())
            save_window_size ();

        gtk_widget_hide (window);

        /* turn visualization off to reduce CPU usage */
        ui_infoarea_show_vis (FALSE);
    }
}
示例#5
0
/* Initialize necessary things */
static bool_t jack_init (void)
{
  aud_config_set_defaults ("jack", jack_defaults);

  jack_cfg.isTraceEnabled = aud_get_bool ("jack", "isTraceEnabled");
  jack_cfg.volume_left = aud_get_int ("jack", "volume_left");
  jack_cfg.volume_right = aud_get_int ("jack", "volume_right");

  TRACE("initializing\n");
  JACK_Init(); /* initialize the driver */

  /* set the bio2jack name so users will see xmms-jack in their */
  /* jack client list */
  JACK_SetClientName("audacious-jack");

  /* set the port connection mode */
  jack_set_port_connection_mode();

  output_opened = FALSE;

  /* Always return OK, as we don't know about physical devices here */
  return TRUE;
}
示例#6
0
int oss_open_audio(int aud_format, int rate, int channels)
{
    AUDDBG("Opening audio.\n");

    int format;
    int vol_left, vol_right;
    audio_buf_info buf_info;

    CHECK_NOISY(oss_data->fd = open_device);

    format = oss_convert_aud_format(aud_format);

    if (!set_format(format, rate, channels))
        goto FAILED;

    CHECK_NOISY(ioctl, oss_data->fd, SNDCTL_DSP_GETOSPACE, &buf_info);

    AUDDBG("Buffer information, fragstotal: %d, fragsize: %d, bytes: %d.\n",
        buf_info.fragstotal,
        buf_info.fragsize,
        buf_info.bytes);

    oss_time = 0;
    oss_paused = FALSE;
    oss_paused_time = 0;
    oss_delay = oss_bytes_to_frames(buf_info.fragstotal * buf_info.fragsize) * 1000 / oss_data->rate;
    oss_ioctl_vol = TRUE;

    AUDDBG("Internal OSS buffer size: %dms.\n", oss_delay);

    if (aud_get_bool("oss4", "save_volume"))
    {
        vol_right = (aud_get_int("oss4", "volume") & 0xFF00) >> 8;
        vol_left  = (aud_get_int("oss4", "volume") & 0x00FF);
        oss_set_volume(vol_left, vol_right);
    }
示例#7
0
void osd_setup_buttons (NotifyNotification *notification)
{
    notify_notification_clear_actions (notification);

    if (! aud_get_bool ("notify", "actions"))
        return;

    notify_notification_add_action (notification, "default", _("Show"),
     NOTIFY_ACTION_CALLBACK (show_cb), NULL, NULL);

    bool_t playing = aud_drct_get_playing ();
    bool_t paused = aud_drct_get_paused ();

    if (playing && ! paused)
        notify_notification_add_action (notification, "media-playback-pause",
         _("Pause"), NOTIFY_ACTION_CALLBACK (aud_drct_pause), NULL, NULL);
    else
        notify_notification_add_action (notification, "media-playback-start",
         _("Play"), NOTIFY_ACTION_CALLBACK (aud_drct_play), NULL, NULL);

    if (playing)
        notify_notification_add_action (notification, "media-skip-forward",
         _("Next"), NOTIFY_ACTION_CALLBACK (aud_drct_pl_next), NULL, NULL);
}
示例#8
0
static void set_time_label (int time, int len)
{
    char s[128] = "<b>";

    if (len && aud_get_bool ("gtkui", "show_remaining_time"))
        append_time_str (s, sizeof s, len - time);
    else
        append_time_str (s, sizeof s, time);

    if (len)
    {
        append_str (s, sizeof s, " / ");
        append_time_str (s, sizeof s, len);

        int a, b;
        aud_drct_get_ab_repeat (& a, & b);

        if (a >= 0)
        {
            append_str (s, sizeof s, " A=");
            append_time_str (s, sizeof s, a);
        }

        if (b >= 0)
        {
            append_str (s, sizeof s, " B=");
            append_time_str (s, sizeof s, b);
        }
    }

    append_str (s, sizeof s, "</b>");

    /* only update label if necessary */
    if (strcmp (gtk_label_get_label ((GtkLabel *) label_time), s))
        gtk_label_set_markup ((GtkLabel *) label_time, s);
}
示例#9
0
static int open_handle (struct neon_handle * handle, uint64_t startbyte)
{
    int ret;
    char * proxy_host = NULL;
    int proxy_port = 0;

    bool_t use_proxy = aud_get_bool (NULL, "use_proxy");
    bool_t use_proxy_auth = aud_get_bool (NULL, "use_proxy_auth");

    if (use_proxy)
    {
        proxy_host = aud_get_str (NULL, "proxy_host");
        proxy_port = aud_get_int (NULL, "proxy_port");
    }

    handle->redircount = 0;

    _DEBUG ("<%p> Parsing URL", handle);

    if (ne_uri_parse (handle->url, handle->purl) != 0)
    {
        _ERROR ("<%p> Could not parse URL '%s'", (void *) handle, handle->url);
        return -1;
    }

    while (handle->redircount < 10)
    {
        if (! handle->purl->port)
            handle->purl->port = ne_uri_defaultport (handle->purl->scheme);

        _DEBUG ("<%p> Creating session to %s://%s:%d", handle,
         handle->purl->scheme, handle->purl->host, handle->purl->port);
        handle->session = ne_session_create (handle->purl->scheme,
         handle->purl->host, handle->purl->port);
        ne_redirect_register (handle->session);
        ne_add_server_auth (handle->session, NE_AUTH_BASIC, server_auth_callback, (void *) handle);
        ne_set_session_flag (handle->session, NE_SESSFLAG_ICYPROTO, 1);
        ne_set_session_flag (handle->session, NE_SESSFLAG_PERSIST, 0);

#ifdef HAVE_NE_SET_CONNECT_TIMEOUT
        ne_set_connect_timeout (handle->session, 10);
#endif

        ne_set_read_timeout (handle->session, 10);
        ne_set_useragent (handle->session, "Audacious/" PACKAGE_VERSION);

        if (use_proxy)
        {
            _DEBUG ("<%p> Using proxy: %s:%d", handle, proxy_host, proxy_port);
            ne_session_proxy (handle->session, proxy_host, proxy_port);

            if (use_proxy_auth)
            {
                _DEBUG ("<%p> Using proxy authentication", handle);
                ne_add_proxy_auth (handle->session, NE_AUTH_BASIC,
                 neon_proxy_auth_cb, (void *) handle);
            }
        }

        if (! strcmp ("https", handle->purl->scheme))
        {
            ne_ssl_trust_default_ca (handle->session);
            ne_ssl_set_verify (handle->session,
             neon_vfs_verify_environment_ssl_certs, handle->session);
        }

        _DEBUG ("<%p> Creating request", handle);
        ret = open_request (handle, startbyte);

        if (! ret)
        {
            str_unref (proxy_host);
            return 0;
        }

        if (ret == -1)
        {
            ne_session_destroy (handle->session);
            handle->session = NULL;
            str_unref (proxy_host);
            return -1;
        }

        _DEBUG ("<%p> Following redirect...", handle);
        ne_session_destroy (handle->session);
        handle->session = NULL;
    }

    /* If we get here, our redirect count exceeded */
    _ERROR ("<%p> Redirect count exceeded for URL %s", (void *) handle, handle->url);

    str_unref (proxy_host);
    return 1;
}
示例#10
0
static gboolean status_bar_get (void) {return aud_get_bool ("gtkui", "statusbar_visible"); }
static void repeat_toggled (void * data, void * user)
{
    button_set_active (mainwin_repeat, aud_get_bool (NULL, "repeat"));
}
示例#12
0
static gboolean autoscroll_get (void) {return aud_get_bool ("gtkui", "autoscroll"); }
static void no_advance_toggled (void * data, void * user)
{
    bool_t no_advance = aud_get_bool (NULL, "no_playlist_advance");
    check_set (toggleaction_group_others, "playback no playlist advance", no_advance);
}
示例#14
0
gint
aosd_cfg_load ( aosd_cfg_t * cfg )
{
  aud_config_set_defaults ("aosd", aosd_defaults);

  gint i = 0;
  gint max_numcol;
  gchar *trig_active_str;

  /* position */
  cfg->osd->position.placement = aud_get_int ("aosd", "position_placement");
  cfg->osd->position.offset_x = aud_get_int ("aosd", "position_offset_x");
  cfg->osd->position.offset_y = aud_get_int ("aosd", "position_offset_y");
  cfg->osd->position.maxsize_width = aud_get_int ("aosd", "position_maxsize_width");
  cfg->osd->position.multimon_id = aud_get_int ("aosd", "position_multimon_id");

  /* animation */
  cfg->osd->animation.timing_display = aud_get_int ("aosd", "animation_timing_display");
  cfg->osd->animation.timing_fadein = aud_get_int ("aosd", "animation_timing_fadein");
  cfg->osd->animation.timing_fadeout = aud_get_int ("aosd", "animation_timing_fadeout");

  /* text */
  for ( i = 0 ; i < AOSD_TEXT_FONTS_NUM ; i++ )
  {
    gchar *color_str = NULL;
    gchar *key_str = NULL;

    key_str = g_strdup_printf( "text_fonts_name_%i" , i );
    cfg->osd->text.fonts_name[i] = aud_get_string ("aosd", key_str);
    g_free( key_str );

    key_str = g_strdup_printf( "text_fonts_color_%i" , i );
    color_str = aud_get_string ("aosd", key_str);
    aosd_cfg_util_str_to_color( color_str , &(cfg->osd->text.fonts_color[i]) );
    g_free( key_str );
    g_free( color_str );

    key_str = g_strdup_printf( "text_fonts_draw_shadow_%i" , i );
    cfg->osd->text.fonts_draw_shadow[i] = aud_get_bool ("aosd", key_str);
    g_free( key_str );

    key_str = g_strdup_printf( "text_fonts_shadow_color_%i" , i );
    color_str = aud_get_string ("aosd", key_str);
    aosd_cfg_util_str_to_color( color_str , &(cfg->osd->text.fonts_shadow_color[i]) );
    g_free( key_str );
    g_free( color_str );
  }

  cfg->osd->text.utf8conv_disable = aud_get_bool ("aosd", "text_utf8conv_disable");

  /* decoration */
  cfg->osd->decoration.code = aud_get_int ("aosd", "decoration_code");

  /* TODO not implemented yet
  if ( !aud_cfg_db_get_string( cfgfile , "aosd" ,
       "decoration_skin_file" , &(cfg->osd->decoration.skin_file) ) )
    cfg->osd->decoration.skin_file = g_strdup( "" );
  */

  /* decoration - colors */
  max_numcol = aosd_deco_style_get_max_numcol();
  for ( i = 0 ; i < max_numcol ; i++ )
  {
    gchar *key_str = NULL;
    gchar *color_str = NULL;
    aosd_color_t color;
    key_str = g_strdup_printf( "decoration_color_%i" , i );
    color_str = aud_get_string ("aosd", key_str);
    aosd_cfg_util_str_to_color( color_str , &color );
    g_array_insert_val( cfg->osd->decoration.colors , i , color );
  }

  /* trigger */
  trig_active_str = aud_get_string ("aosd", "trigger_active");

  if (strcmp (trig_active_str, "x"))
  {
    gchar **trig_active_strv = g_strsplit( trig_active_str , "," , 0 );
    gint j = 0;
    while ( trig_active_strv[j] != NULL )
    {
      gint trig_active_val = strtol( trig_active_strv[j] , NULL , 10 );
      g_array_append_val( cfg->osd->trigger.active , trig_active_val );
      j++;
    }
    g_strfreev( trig_active_strv );
  }

  g_free (trig_active_str);

  /* miscellanous */
  cfg->osd->misc.transparency_mode = aud_get_int ("aosd", "transparency_mode");

  /* the config object has been filled with information */
  cfg->set = TRUE;

  return 0;
}
示例#15
0
static gboolean infoarea_get (void) {return aud_get_bool ("gtkui", "infoarea_visible"); }
示例#16
0
/* handle keys */
gboolean handle_keyevent (EVENT event)
{
    gint current_volume, old_volume;
    static gint volume_static = 0;
    gboolean play, mute;

    /* playing or not */
    play = aud_drct_get_playing ();

    /* get current volume */
    aud_drct_get_volume_main (&current_volume);
    old_volume = current_volume;
    if (current_volume)
    {
        /* volume is not mute */
        mute = FALSE;
    } else {
        /* volume is mute */
        mute = TRUE;
    }

    /* mute the playback */
    if (event == EVENT_MUTE)
    {
        if (!mute)
        {
            volume_static = current_volume;
            aud_drct_set_volume_main (0);
            mute = TRUE;
        } else {
            aud_drct_set_volume_main (volume_static);
            mute = FALSE;
        }
        return TRUE;
    }

    /* decreace volume */
    if (event == EVENT_VOL_DOWN)
    {
        if (mute)
        {
            current_volume = old_volume;
            old_volume = 0;
            mute = FALSE;
        }

        if ((current_volume -= plugin_cfg.vol_decrement) < 0)
        {
            current_volume = 0;
        }

        if (current_volume != old_volume)
        {
            aud_drct_set_volume_main (current_volume);
        }

        old_volume = current_volume;
        return TRUE;
    }

    /* increase volume */
    if (event == EVENT_VOL_UP)
    {
        if (mute)
        {
            current_volume = old_volume;
            old_volume = 0;
            mute = FALSE;
        }

        if ((current_volume += plugin_cfg.vol_increment) > 100)
        {
            current_volume = 100;
        }

        if (current_volume != old_volume)
        {
            aud_drct_set_volume_main (current_volume);
        }

        old_volume = current_volume;
        return TRUE;
    }

    /* play */
    if (event == EVENT_PLAY)
    {
        aud_drct_play ();
        return TRUE;
    }

    /* pause */
    if (event == EVENT_PAUSE)
    {
        if (!play) aud_drct_play ();
        else aud_drct_pause ();

        return TRUE;
    }

    /* stop */
    if (event == EVENT_STOP)
    {
        aud_drct_stop ();
        return TRUE;
    }

    /* prev track */
    if (event == EVENT_PREV_TRACK)
    {
        aud_drct_pl_prev ();
        return TRUE;
    }

    /* next track */
    if (event == EVENT_NEXT_TRACK)
    {
        aud_drct_pl_next ();
        return TRUE;
    }

    /* forward */
    if (event == EVENT_FORWARD)
    {
        aud_drct_seek (aud_drct_get_time () + 5000);
        return TRUE;
    }

    /* backward */
    if (event == EVENT_BACKWARD)
    {
        gint time = aud_drct_get_time ();
        if (time > 5000) time -= 5000; /* Jump 5s back */
            else time = 0;
        aud_drct_seek (time);
        return TRUE;
    }

    /* Open Jump-To-File dialog */
    if (event == EVENT_JUMP_TO_FILE)
    {
        aud_interface_show_jump_to_track ();
        return TRUE;
    }

    /* Toggle Windows */
    if (event == EVENT_TOGGLE_WIN)
    {
        aud_interface_show (! (aud_interface_is_shown () && aud_interface_is_focused ()));
        return TRUE;
    }

    /* Show OSD through AOSD plugin*/
    if (event == EVENT_SHOW_AOSD)
    {
        hook_call("aosd toggle", NULL);
        return TRUE;
    }

    if (event == EVENT_TOGGLE_REPEAT)
    {
        aud_set_bool (NULL, "repeat", ! aud_get_bool (NULL, "repeat"));
        return TRUE;
    }

    if (event == EVENT_TOGGLE_SHUFFLE)
    {
        aud_set_bool (NULL, "shuffle", ! aud_get_bool (NULL, "shuffle"));
        return TRUE;
    }

    if (event == EVENT_TOGGLE_STOP)
    {
        aud_set_bool (NULL, "stop_after_current_song", ! aud_get_bool (NULL, "stop_after_current_song"));
        return TRUE;
    }

    if (event == EVENT_RAISE)
    {
        aud_interface_show (TRUE);
        return TRUE;
    }

    return FALSE;
}
示例#17
0
static void
equalizerwin_create_widgets(void)
{
    equalizerwin_on = button_new_toggle (25, 12, 10, 119, 128, 119, 69, 119, 187, 119, SKIN_EQMAIN, SKIN_EQMAIN);
    window_put_widget (equalizerwin, FALSE, equalizerwin_on, 14, 18);
    button_set_active (equalizerwin_on, aud_get_bool (NULL, "equalizer_active"));
    button_on_release (equalizerwin_on, eq_on_cb);

    equalizerwin_auto = button_new_toggle (33, 12, 35, 119, 153, 119, 94, 119, 212, 119, SKIN_EQMAIN, SKIN_EQMAIN);
    window_put_widget (equalizerwin, FALSE, equalizerwin_auto, 39, 18);
    button_set_active (equalizerwin_auto, aud_get_bool (NULL, "equalizer_autoload"));
    button_on_release (equalizerwin_auto, eq_auto_cb);

    equalizerwin_presets = button_new (44, 12, 224, 164, 224, 176, SKIN_EQMAIN, SKIN_EQMAIN);
    window_put_widget (equalizerwin, FALSE, equalizerwin_presets, 217, 18);
    button_on_release (equalizerwin_presets, eq_presets_cb);

    equalizerwin_close = button_new (9, 9, 0, 116, 0, 125, SKIN_EQMAIN, SKIN_EQMAIN);
    window_put_widget (equalizerwin, FALSE, equalizerwin_close, 264, 3);
    button_on_release (equalizerwin_close, (ButtonCB) equalizerwin_close_cb);

    equalizerwin_shade = button_new (9, 9, 254, 137, 1, 38, SKIN_EQMAIN, SKIN_EQ_EX);
    window_put_widget (equalizerwin, FALSE, equalizerwin_shade, 254, 3);
    button_on_release (equalizerwin_shade, (ButtonCB) equalizerwin_shade_toggle);

    equalizerwin_shaded_close = button_new (9, 9, 11, 38, 11, 47, SKIN_EQ_EX, SKIN_EQ_EX);
    window_put_widget (equalizerwin, TRUE, equalizerwin_shaded_close, 264, 3);
    button_on_release (equalizerwin_shaded_close, (ButtonCB) equalizerwin_close_cb);

    equalizerwin_shaded_shade = button_new (9, 9, 254, 3, 1, 47, SKIN_EQ_EX, SKIN_EQ_EX);
    window_put_widget (equalizerwin, TRUE, equalizerwin_shaded_shade, 254, 3);
    button_on_release (equalizerwin_shaded_shade, (ButtonCB) equalizerwin_shade_toggle);

    equalizerwin_graph = eq_graph_new ();
    window_put_widget (equalizerwin, FALSE, equalizerwin_graph, 86, 17);

    equalizerwin_preamp = eq_slider_new (_("Preamp"));
    window_put_widget (equalizerwin, FALSE, equalizerwin_preamp, 21, 38);
    eq_slider_set_val (equalizerwin_preamp, aud_get_double (NULL, "equalizer_preamp"));

    const gchar * const bandnames[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")
                                                          };
    gdouble bands[AUD_EQUALIZER_NBANDS];
    aud_eq_get_bands (bands);

    for (gint i = 0; i < AUD_EQUALIZER_NBANDS; i ++)
    {
        equalizerwin_bands[i] = eq_slider_new (_(bandnames[i]));
        window_put_widget (equalizerwin, FALSE, equalizerwin_bands[i], 78 + 18 * i, 38);
        eq_slider_set_val (equalizerwin_bands[i], bands[i]);
    }

    equalizerwin_volume = hslider_new (0, 94, SKIN_EQ_EX, 97, 8, 61, 4, 3, 7, 1, 30, 1, 30);
    window_put_widget (equalizerwin, TRUE, equalizerwin_volume, 61, 4);
    hslider_on_motion (equalizerwin_volume, eqwin_volume_motion_cb);
    hslider_on_release (equalizerwin_volume, eqwin_volume_release_cb);

    equalizerwin_balance = hslider_new (0, 39, SKIN_EQ_EX, 42, 8, 164, 4, 3, 7, 11, 30, 11, 30);
    window_put_widget (equalizerwin, TRUE, equalizerwin_balance, 164, 4);
    hslider_on_motion (equalizerwin_balance, eqwin_balance_motion_cb);
    hslider_on_release (equalizerwin_balance, eqwin_balance_release_cb);
}
示例#18
0
static gboolean stop_after_get (void) {return aud_get_bool (NULL, "stop_after_current_song"); }
示例#19
0
static gboolean no_advance_get (void) {return aud_get_bool (NULL, "no_playlist_advance"); }
示例#20
0
static gboolean shuffle_get (void) {return aud_get_bool (NULL, "shuffle"); }
示例#21
0
static gboolean repeat_get (void) {return aud_get_bool (NULL, "repeat"); }
示例#22
0
static void on_off_update (void * unused, GtkWidget * on_off)
{
    gtk_toggle_button_set_active ((GtkToggleButton *) on_off, aud_get_bool
     (NULL, "equalizer_active"));
}
示例#23
0
static gboolean infoarea_vis_get (void) {return aud_get_bool ("gtkui", "infoarea_show_vis"); }
示例#24
0
文件: confirm.c 项目: i-tek/audacious
EXPORT void audgui_confirm_playlist_delete (int playlist)
{
    GtkWidget * window, * vbox, * hbox, * label, * button;
    char * message;

    if (aud_get_bool ("audgui", "no_confirm_playlist_delete"))
    {
        aud_playlist_delete (playlist);
        if (playlist > 0)
            aud_playlist_set_active (playlist - 1);
        return;
    }

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_type_hint ((GtkWindow *) window,
     GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_set_title ((GtkWindow *) window, _("Close Playlist"));
    gtk_window_set_resizable ((GtkWindow *) window, FALSE);
    gtk_container_set_border_width ((GtkContainer *) window, 6);
    audgui_destroy_on_escape (window);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_container_add ((GtkContainer *) window, vbox);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,  6);
    gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

    gtk_box_pack_start ((GtkBox *) hbox, gtk_image_new_from_stock
     (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);

    char * title = aud_playlist_get_title (playlist);
    message = g_strdup_printf (_("Are you sure you want to close %s?  If you "
     "do, any changes made since the playlist was exported will be lost."),
     title);
    str_unref (title);
    label = gtk_label_new (message);
    g_free (message);
    gtk_label_set_line_wrap ((GtkLabel *) label, TRUE);
    gtk_widget_set_size_request (label, 320, -1);
    gtk_box_pack_start ((GtkBox *) hbox, label, TRUE, FALSE, 0);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,  6);
    gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

    button = gtk_check_button_new_with_mnemonic (_("_Don't show this message again"));
    gtk_box_pack_start ((GtkBox *) hbox, button, FALSE, FALSE, 0);
    g_signal_connect (button, "toggled", (GCallback) no_confirm_cb, NULL);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,  6);
    gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

    button = gtk_button_new_from_stock (GTK_STOCK_NO);
    gtk_box_pack_end ((GtkBox *) hbox, button, FALSE, FALSE, 0);
    g_signal_connect_swapped (button, "clicked", (GCallback)
     gtk_widget_destroy, window);

    button = gtk_button_new_from_stock (GTK_STOCK_YES);
    gtk_box_pack_end ((GtkBox *) hbox, button, FALSE, FALSE, 0);
    gtk_widget_set_can_default (button, TRUE);
    gtk_widget_grab_default (button);
    gtk_widget_grab_focus (button);
    g_signal_connect ((GObject *) button, "clicked", (GCallback)
     confirm_delete_cb, GINT_TO_POINTER (aud_playlist_get_unique_id (playlist)));
    g_signal_connect_swapped ((GObject *) button, "clicked", (GCallback)
     gtk_widget_destroy, window);

    gtk_widget_show_all (window);
}
示例#25
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;
}
static void shuffle_toggled (void * data, void * user)
{
    button_set_active (mainwin_shuffle, aud_get_bool (NULL, "shuffle"));
}
static void shuffle_toggled (void * data, void * user)
{
    bool_t shuffle = aud_get_bool (NULL, "shuffle");
    check_set (toggleaction_group_others, "playback shuffle", shuffle);
}
static void stop_after_song_toggled (void * hook_data, void * user_data)
{
    if (aud_get_bool (NULL, "stop_after_current_song"))
        mainwin_show_status_message (_("Stopping after song."));
}
static void repeat_toggled (void * data, void * user)
{
    bool_t repeat = aud_get_bool (NULL, "repeat");
    check_set (toggleaction_group_others, "playback repeat", repeat);
}
示例#30
0
static gboolean column_headers_get (void) {return aud_get_bool ("gtkui", "playlist_headers"); }