Ejemplo n.º 1
0
static void load_enabled_from_config (void)
{
    int count = aud_get_int ("ladspa", "plugin_count");

    for (int i = 0; i < count; i ++)
    {
        char key[32];

        snprintf (key, sizeof key, "plugin%d_path", i);
        char * path = aud_get_string ("ladspa", key);

        snprintf (key, sizeof key, "plugin%d_label", i);
        char * label = aud_get_string ("ladspa", key);

        PluginData * plugin = find_plugin (path, label);
        if (plugin)
        {
            LoadedPlugin * loaded = enable_plugin_locked (plugin);

            int ccount = index_count (loaded->plugin->controls);
            for (int ci = 0; ci < ccount; ci ++)
            {
                snprintf (key, sizeof key, "plugin%d_control%d", i, ci);
                loaded->values[ci] = aud_get_double ("ladspa", key);
            }
        }

        g_free (path);
        g_free (label);
    }
}
Ejemplo n.º 2
0
static int open_device(void)
{
    int res = -1;
    int flags = O_WRONLY;
    char *device = aud_get_string("oss4", "device");
    char *alt_device = aud_get_string("oss4", "alt_device");

    if (aud_get_bool("oss4", "exclusive"))
    {
        AUDDBG("Enabled exclusive mode.\n");
        flags |= O_EXCL;
    }

    if (aud_get_bool("oss4", "use_alt_device") && alt_device != NULL)
        res = open(alt_device, flags);
    else if (device != NULL)
        res = open(device, flags);
    else
        res = open(DEFAULT_DSP, flags);

    free(device);
    free(alt_device);

    return res;
}
Ejemplo n.º 3
0
static void read_config(void)
{
    cmd_line = aud_get_string("song_change", "cmd_line");
    cmd_line_after = aud_get_string("song_change", "cmd_line_after");
    cmd_line_end = aud_get_string("song_change", "cmd_line_end");
    cmd_line_ttc = aud_get_string("song_change", "cmd_line_ttc");
}
Ejemplo n.º 4
0
static char * select_file (bool_t save, const char * default_filename)
{
    GtkWidget * dialog = gtk_file_chooser_dialog_new (save ?
     _("Export Playlist") : _("Import Playlist"), NULL, save ?
     GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL);

    if (default_filename)
        gtk_file_chooser_set_uri ((GtkFileChooser *) dialog, default_filename);

    gtk_dialog_add_button ((GtkDialog *) dialog, GTK_STOCK_CANCEL,
     GTK_RESPONSE_REJECT);
    gtk_dialog_add_button ((GtkDialog *) dialog, save ? GTK_STOCK_SAVE :
     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT);

    gtk_dialog_set_default_response ((GtkDialog *) dialog, GTK_RESPONSE_ACCEPT);

    char * path = aud_get_string ("audgui", "playlist_path");
    if (path[0])
        gtk_file_chooser_set_current_folder_uri ((GtkFileChooser *) dialog, path);
    g_free (path);

    char * filename = NULL;
    if (gtk_dialog_run ((GtkDialog *) dialog) == GTK_RESPONSE_ACCEPT)
        filename = gtk_file_chooser_get_uri ((GtkFileChooser *) dialog);

    path = gtk_file_chooser_get_current_folder_uri ((GtkFileChooser *) dialog);
    aud_set_string ("audgui", "playlist_path", path);
    g_free (path);

    gtk_widget_destroy (dialog);
    return filename;
}
// This is a sister function of scrobbler_request_session, using the getMobileSession
//API call, for migrating from the old config
//returns:
// FALSE if there was a network problem OR a session_key was not obtained
// TRUE if a new session_key was obtained
static bool_t treat_migrate_config() {

    char *password = aud_get_string("audioscrobbler","password");
    if (password == NULL || strlen(password) == 0) {
        g_free(password);
        return FALSE;
    }

    char *username = aud_get_string("audioscrobbler","username");
    if (username == NULL || strlen(username) == 0) {
        g_free(password);
        g_free(username);
        return FALSE;
    }

    gchar *checksumThis = g_strdup_printf("%s%s", username, password);
    gchar *authToken = g_compute_checksum_for_string(G_CHECKSUM_MD5, checksumThis, -1);

    gchar *sessionmsg = create_message_to_lastfm("auth.getMobileSession",
                                                 3,
                                                 "authToken", authToken,
                                                 "username", username,
                                                 "api_key", SCROBBLER_API_KEY);
    g_free(username);
    g_free(password);
    g_free(checksumThis);
    g_free(authToken);

    if (send_message_to_lastfm(sessionmsg) == FALSE) {
        g_free(sessionmsg);
        return FALSE;
    }

    g_free(sessionmsg);

    if (update_session_key() == TRUE) {
        if(session_key != NULL && strlen(session_key) != 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
Ejemplo n.º 6
0
static void load_auto_preset (const gchar * filename)
{
    gchar * ext = aud_get_string (NULL, "eqpreset_extension");
    if (ext[0])
    {
        gchar * eq_file = g_strconcat (filename, ".", ext, NULL);
        gboolean success = equalizerwin_read_aud_preset (eq_file);
        g_free (eq_file);

        if (success)
        {
            g_free (ext);
            return;
        }
    }
    g_free (ext);

    gchar * deffile = aud_get_string (NULL, "eqpreset_default_file");
    if (deffile[0])
    {
        gchar * folder = g_path_get_dirname (filename);
        gchar * eq_file = g_build_filename (folder, deffile, NULL);
        gboolean success = equalizerwin_read_aud_preset (eq_file);
        g_free (folder);
        g_free (eq_file);

        if (success)
        {
            g_free (deffile);
            return;
        }
    }
    g_free (deffile);

    gchar * base = g_path_get_basename (filename);

    if (! equalizerwin_load_preset (equalizer_auto_presets, base))
    {
        if (! equalizerwin_load_preset (equalizer_presets, "Default"))
            action_equ_zero_preset ();
    }

    g_free (base);
}
Ejemplo n.º 7
0
static int init (void)
{
    pthread_mutex_lock (& mutex);

    modules = index_new ();
    plugins = index_new ();
    loadeds = index_new ();

    aud_config_set_defaults ("ladspa", ladspa_defaults);

    module_path = aud_get_string ("ladspa", "module_path");

    open_modules ();
    load_enabled_from_config ();

    pthread_mutex_unlock (& mutex);
    return 1;
}
Ejemplo n.º 8
0
void pw_col_init (void)
{
    pw_num_cols = 0;

    gchar * columns = aud_get_string ("gtkui", "playlist_columns");
    gchar * * split = g_strsplit (columns, " ", -1);

    for (gchar * * elem = split; * elem && pw_num_cols < PW_COLS; elem ++)
    {
        gint i = 0;
        while (i < PW_COLS && strcmp (* elem, pw_col_keys[i]))
            i ++;

        if (i == PW_COLS)
            break;

        pw_cols[pw_num_cols ++] = i;
    }

    g_strfreev (split);
    g_free (columns);
}
Ejemplo n.º 9
0
static gboolean file_init (void)
{
    aud_config_set_defaults ("filewriter", filewriter_defaults);

    fileext = aud_get_int ("filewriter", "fileext");
    filenamefromtags = aud_get_bool ("filewriter", "filenamefromtags");
    file_path = aud_get_string ("filewriter", "file_path");
    prependnumber = aud_get_bool ("filewriter", "prependnumber");
    save_original = aud_get_bool ("filewriter", "save_original");
    use_suffix = aud_get_bool ("filewriter", "use_suffix");

    if (! file_path[0])
    {
        g_return_val_if_fail (getenv ("HOME") != NULL, FALSE);
        file_path = g_filename_to_uri (getenv ("HOME"), NULL, NULL);
        g_return_val_if_fail (file_path != NULL, FALSE);
    }

    set_plugin();
    if (plugin->init)
        plugin->init(&file_write_output);

    return TRUE;
}
Ejemplo n.º 10
0
void
action_equ_save_preset_file(void)
{
    GtkWidget *dialog;
    gchar *file_uri;
    gint i;

    dialog = make_filebrowser(_("Save equalizer preset"), TRUE);
    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
    {
        file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
        EqualizerPreset *preset = g_new0(EqualizerPreset, 1);
        preset->name = g_strdup(file_uri);
        preset->preamp = equalizerwin_get_preamp();
        for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
            preset->bands[i] = equalizerwin_get_band(i);
        aud_save_preset_file(preset, file_uri);
        equalizer_preset_free(preset);
        g_free(file_uri);
    }

    char * songname = aud_drct_get_filename ();

    if (songname != NULL)
    {
        gchar * ext = aud_get_string (NULL, "eqpreset_extension");
        gchar * eqname = g_strdup_printf ("%s.%s", songname, ext);
        gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
                                      eqname);
        g_free (eqname);
        g_free (ext);
        str_unref (songname);
    }

    gtk_widget_destroy(dialog);
}
Ejemplo n.º 11
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.port_connection_mode = aud_get_string ("jack", "port_connection_mode");
  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;
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
/* Generated by glade, sorta. */
static void *
create_cfgdlg(void)
{
  GtkWidget *vbox2;
  GtkWidget *table1;
  GtkWidget *label3;
  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *label4;
  GtkWidget *align1;
  GtkWidget *notebook1;

  vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  label1 = gtk_label_new (_("<b>Services</b>"));
  gtk_widget_show (label1);
  gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);

  gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 0);

  notebook1 = gtk_notebook_new();
  gtk_widget_show (notebook1);


  // last fm
  align1 = gtk_alignment_new(0, 0, 0, 0);
  gtk_widget_show (align1);
  gtk_alignment_set_padding(GTK_ALIGNMENT(align1), 0, 0, 12, 0);

  table1 = gtk_table_new (2, 2, FALSE);
  gtk_widget_show (table1);
  gtk_container_add(GTK_CONTAINER(align1), table1);
  gtk_table_set_row_spacings (GTK_TABLE(table1), 6);
  gtk_table_set_col_spacings (GTK_TABLE(table1), 6);

  label2 = gtk_label_new (_("Username:"******"Password:"******"Scrobbler URL:"));
  gtk_widget_show (label4);
  gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_RIGHT);
  gtk_misc_set_alignment (GTK_MISC (label4), 1, 0.5);

  entry1 = gtk_entry_new ();
  gtk_widget_show (entry1);
  gtk_table_attach_defaults (GTK_TABLE (table1), entry1, 1, 2, 2, 3);

  entry2 = gtk_entry_new ();
  gtk_entry_set_text(GTK_ENTRY(entry2), _("Change password"));
  g_signal_connect(G_OBJECT(entry2), "focus-in-event",
                   G_CALLBACK(entry_focus_in),
                   NULL);
  g_signal_connect(G_OBJECT(entry2), "focus-out-event",
                   G_CALLBACK(entry_focus_out),
                   NULL);
  gtk_widget_show (entry2);
  gtk_table_attach_defaults (GTK_TABLE (table1), entry2, 1, 2, 3, 4);

  entry3 = gtk_entry_new ();
  gtk_widget_show (entry3);
  gtk_table_attach_defaults (GTK_TABLE (table1), entry3, 1, 2, 4, 5);

  label1 = gtk_label_new (_("<b>Last.FM</b>"));
  gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
  gtk_notebook_append_page(GTK_NOTEBOOK(notebook1), GTK_WIDGET(align1), label1);

  // common
  gtk_box_pack_start (GTK_BOX (vbox2), notebook1, TRUE, TRUE, 6);

  gchar * username = aud_get_string ("audioscrobbler", "username");
  gtk_entry_set_text ((GtkEntry *) entry1, username);
  g_free (username);

  gchar * sc_url = aud_get_string ("audioscrobbler", "sc_url");
  gtk_entry_set_text ((GtkEntry *) entry3, sc_url);
  g_free (sc_url);

  g_signal_connect(entry1, "changed", G_CALLBACK(entry_changed), NULL);
  g_signal_connect(entry3, "changed", G_CALLBACK(entry_changed), NULL);

  return vbox2;
}
Ejemplo n.º 14
0
static void
run_filebrowser_gtk2style(gboolean play_button, gboolean show)
{
    static GtkWidget *window = NULL;
    GtkWidget *vbox, *hbox, *bbox;
    GtkWidget *chooser;
    GtkWidget *action_button, *close_button;
    GtkWidget *toggle;
    gchar *window_title, *toggle_text;
    gpointer action_stock, storage;

    if (!show) {
        if (window){
            gtk_widget_hide(window);
            return;
        }
        else
            return;
    }
    else {
        if (window) {
            gtk_window_present(GTK_WINDOW(window)); /* raise filebrowser */
            return;
        }
    }

    window_title = play_button ? _("Open Files") : _("Add Files");
    toggle_text = play_button ?
        _("Close dialog on Open") : _("Close dialog on Add");
    action_stock = play_button ? GTK_STOCK_OPEN : GTK_STOCK_ADD;

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_set_title(GTK_WINDOW(window), window_title);
    gtk_window_set_default_size(GTK_WINDOW(window), 700, 450);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), TRUE);

    gchar * path = aud_get_string ("audgui", "filesel_path");
    if (path[0])
        gtk_file_chooser_set_current_folder ((GtkFileChooser *) chooser, path);
    g_free (path);

    gtk_box_pack_start(GTK_BOX(vbox), chooser, TRUE, TRUE, 3);

    hbox = gtk_hbox_new(TRUE, 0);
    gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);

    toggle = gtk_check_button_new_with_label(toggle_text);
    gtk_toggle_button_set_active ((GtkToggleButton *) toggle, aud_get_bool
     ("audgui", "close_dialog_open"));
    gtk_box_pack_start(GTK_BOX(hbox), toggle, TRUE, TRUE, 3);

    bbox = gtk_hbutton_box_new();
    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
    gtk_box_set_spacing(GTK_BOX(bbox), 6);
    gtk_box_pack_end(GTK_BOX(hbox), bbox, TRUE, TRUE, 3);

    close_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    action_button = gtk_button_new_from_stock(action_stock);
    gtk_container_add(GTK_CONTAINER(bbox), close_button);
    gtk_container_add(GTK_CONTAINER(bbox), action_button);

    gtk_widget_set_can_default (action_button, TRUE);
    gtk_widget_grab_default (action_button);

    /* this storage object holds several other objects which are used in the
     * callback functions
     */
    storage = g_object_new(G_TYPE_OBJECT, NULL);
    g_object_set_data(storage, "window", window);
    g_object_set_data(storage, "chooser", chooser);
    g_object_set_data(storage, "toggle-button", toggle);
    g_object_set_data(storage, "play-button", GINT_TO_POINTER(play_button));

    g_signal_connect(chooser, "file-activated",
                     G_CALLBACK(action_button_cb), storage);
    g_signal_connect(action_button, "clicked",
                     G_CALLBACK(action_button_cb), storage);
    g_signal_connect(close_button, "clicked",
                     G_CALLBACK(close_button_cb), window);
    g_signal_connect(window, "destroy",
                     G_CALLBACK(gtk_widget_destroyed), &window);

    audgui_destroy_on_escape (window);
    gtk_widget_show_all (window);
}