static void save_and_close(gchar * cmd, gchar * cmd_after, gchar * cmd_end, gchar * cmd_ttc) { aud_set_str("song_change", "cmd_line", cmd); aud_set_str("song_change", "cmd_line_after", cmd_after); aud_set_str("song_change", "cmd_line_end", cmd_end); aud_set_str("song_change", "cmd_line_ttc", cmd_ttc); str_unref(cmd_line); str_unref(cmd_line_after); str_unref(cmd_line_end); str_unref(cmd_line_ttc); cmd_line = str_get(cmd); cmd_line_after = str_get(cmd_after); cmd_line_end = str_get(cmd_end); cmd_line_ttc = str_get(cmd_ttc); }
static void response_cb (GtkWidget * widget, int response, void * unused) { if (response == GTK_RESPONSE_ACCEPT) { int cols = index_count (chosen); g_return_if_fail (cols <= PW_COLS); ui_playlist_notebook_empty (); for (pw_num_cols = 0; pw_num_cols < cols; pw_num_cols ++) pw_cols[pw_num_cols] = ((Column *) index_get (chosen, pw_num_cols))->column; aud_set_str ("gtkui", "column_widths", ""); aud_set_str ("gtkui", "column_expand", ""); ui_playlist_notebook_populate (); } gtk_widget_destroy (window); }
void pw_col_save (void) { Index * index = index_new (); for (int i = 0; i < pw_num_cols; i ++) index_insert (index, -1, (void *) pw_col_keys[pw_cols[i]]); char * columns = index_to_str_list (index, " "); aud_set_str ("gtkui", "playlist_columns", columns); str_unref (columns); index_free (index); }
static void begin_add (const char * path) { int list = get_playlist (FALSE, FALSE); if (list < 0) list = create_playlist (); aud_set_str ("search-tool", "path", path); char * uri = filename_to_uri (path); g_return_if_fail (uri); if (! g_str_has_suffix (uri, "/")) { SCONCAT2 (temp, uri, "/"); str_unref (uri); uri = str_get (temp); } destroy_added_table (); added_table = g_hash_table_new_full ((GHashFunc) str_hash, (GEqualFunc) str_equal, (GDestroyNotify) str_unref, NULL); int entries = aud_playlist_entry_count (list); for (int entry = 0; entry < entries; entry ++) { char * filename = aud_playlist_entry_get_filename (list, entry); if (g_str_has_prefix (filename, uri) && ! g_hash_table_contains (added_table, filename)) { aud_playlist_entry_set_selected (list, entry, FALSE); g_hash_table_insert (added_table, filename, NULL); } else { aud_playlist_entry_set_selected (list, entry, TRUE); str_unref (filename); } } aud_playlist_delete_selected (list); aud_playlist_remove_failed (list); Index * add = index_new (); index_insert (add, -1, uri); aud_playlist_entry_insert_filtered (list, -1, add, NULL, filter_cb, NULL, FALSE); adding = TRUE; }
/* "destroy" callback; do not call directly */ static void cleanup_job (void * data) { ImportExportJob * job = data; char * folder = gtk_file_chooser_get_current_folder_uri ((GtkFileChooser *) job->selector); aud_set_str ("audgui", "playlist_path", folder); g_free (folder); if (job->confirm) gtk_widget_destroy (job->confirm); g_free (job->filename); g_slice_free (ImportExportJob, job); }
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_str ("ladspa", key); snprintf (key, sizeof key, "plugin%d_label", i); char * label = aud_get_str ("ladspa", key); PluginData * plugin = find_plugin (path, label); if (plugin) { LoadedPlugin * loaded = enable_plugin_locked (plugin); snprintf (key, sizeof key, "plugin%d_controls", i); int ccount = index_count (loaded->plugin->controls); double temp[ccount]; char * controls = aud_get_str ("ladspa", key); if (str_to_double_array (controls, temp, ccount)) { for (int ci = 0; ci < ccount; ci ++) loaded->values[ci] = temp[ci]; } else { /* migrate from old config format */ 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); aud_set_str ("ladspa", key, ""); } } str_unref (controls); } str_unref (path); str_unref (label); } }
static void configure_response_cb (void) { fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); char * temp = gtk_file_chooser_get_uri ((GtkFileChooser *) path_dirbrowser); str_unref (file_path); file_path = str_get (temp); g_free (temp); use_suffix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle)); prependnumber = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prependnumber_toggle)); aud_set_int ("filewriter", "fileext", fileext); aud_set_bool ("filewriter", "filenamefromtags", filenamefromtags); aud_set_str ("filewriter", "file_path", file_path); aud_set_bool ("filewriter", "prependnumber", prependnumber); aud_set_bool ("filewriter", "save_original", save_original); aud_set_bool ("filewriter", "use_suffix", use_suffix); }
static void save_enabled_to_config (void) { int count = index_count (loadeds); int old_count = aud_get_int ("ladspa", "plugin_count"); aud_set_int ("ladspa", "plugin_count", count); for (int i = 0; i < count; i ++) { LoadedPlugin * loaded = index_get (loadeds, 0); char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); aud_set_str ("ladspa", key, loaded->plugin->path); snprintf (key, sizeof key, "plugin%d_label", i); aud_set_str ("ladspa", key, loaded->plugin->desc->Label); snprintf (key, sizeof key, "plugin%d_controls", i); int ccount = index_count (loaded->plugin->controls); double temp[ccount]; for (int ci = 0; ci < ccount; ci ++) temp[ci] = loaded->values[ci]; char * controls = double_array_to_str (temp, ccount); aud_set_str ("ladspa", key, controls); str_unref (controls); disable_plugin_locked (0); } for (int i = count; i < old_count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); aud_set_str ("ladspa", key, ""); snprintf (key, sizeof key, "plugin%d_label", i); aud_set_str ("ladspa", key, ""); snprintf (key, sizeof key, "plugin%d_controls", i); aud_set_str ("ladspa", key, ""); } }
static void cleanup (void) { if (config_win) gtk_widget_destroy (config_win); pthread_mutex_lock (& mutex); aud_set_str ("ladspa", "module_path", module_path); save_enabled_to_config (); close_modules (); index_free (modules); modules = NULL; index_free (plugins); plugins = NULL; index_free (loadeds); loadeds = NULL; str_unref (module_path); module_path = NULL; pthread_mutex_unlock (& mutex); }
/* * the callback function that is called when the save button is * pressed saves configuration to ~/.bmp/alarmconfig */ void alarm_save(void) { int daynum = 0; // used to identify day number /* * update the live values and write them out */ alarm_h = alarm_conf.default_hour = gtk_spin_button_get_value_as_int (alarm_conf.alarm_h); aud_set_int ("alarm", "alarm_h", alarm_h); alarm_m = alarm_conf.default_min = gtk_spin_button_get_value_as_int (alarm_conf.alarm_m); aud_set_int ("alarm", "alarm_m", alarm_m); stop_h = gtk_spin_button_get_value_as_int (alarm_conf.stop_h); stop_m = gtk_spin_button_get_value_as_int (alarm_conf.stop_m); stop_on = gtk_toggle_button_get_active (alarm_conf.stop_on); /* days of the week */ for(; daynum < 7; daynum++) { if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb))) alarm_conf.day[daynum].flags = 0; else alarm_conf.day[daynum].flags = ALARM_OFF; if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb_def))) alarm_conf.day[daynum].flags |= ALARM_DEFAULT; alarm_conf.day[daynum].hour = gtk_spin_button_get_value_as_int(alarm_conf.day[daynum].spin_hr); alarm_conf.day[daynum].min = gtk_spin_button_get_value_as_int(alarm_conf.day[daynum].spin_min); aud_set_int ("alarm", day_flags[daynum], alarm_conf.day[daynum].flags); aud_set_int ("alarm", day_h[daynum], alarm_conf.day[daynum].hour); aud_set_int ("alarm", day_m[daynum], alarm_conf.day[daynum].min); } /* END: days of week */ volume = gtk_range_get_value (alarm_conf.volume); aud_set_int ("alarm", "volume", volume); quietvol = gtk_range_get_value (alarm_conf.quietvol); aud_set_int ("alarm", "quietvol", quietvol); fading = gtk_spin_button_get_value_as_int (alarm_conf.fading); /* write the new values */ aud_set_int ("alarm", "stop_h", stop_h); aud_set_int ("alarm", "stop_m", stop_m); aud_set_int ("alarm", "fading", fading); aud_set_bool ("alarm", "stop_on", stop_on); char * cmdstr = gtk_editable_get_chars ((GtkEditable *) alarm_conf.cmdstr, 0, -1); aud_set_str ("alarm", "cmdstr", cmdstr); g_free (cmdstr); cmd_on = gtk_toggle_button_get_active (alarm_conf.cmd_on); aud_set_bool ("alarm", "cmd_on", cmd_on); char * playlist = gtk_editable_get_chars ((GtkEditable *) alarm_conf.playlist, 0, -1); aud_set_str ("alarm", "playlist", playlist); g_free (playlist); /* reminder */ char * reminder_msg = gtk_editable_get_chars ((GtkEditable *) alarm_conf.reminder, 0, -1); aud_set_str ("alarm", "reminder_msg", reminder_msg); g_free (reminder_msg); alarm_conf.reminder_on = gtk_toggle_button_get_active (alarm_conf.reminder_cb); aud_set_bool ("alarm", "reminder_on", alarm_conf.reminder_on); }