Browse Source

Cleanup

master
cancel 5 years ago
parent
commit
deaedbb837
  1. 52
      tui_main.c

52
tui_main.c

@ -2224,6 +2224,14 @@ void push_portmidi_output_device_menu(Midi_mode const *midi_mode) {
}
#endif
oso *get_nonempty_singular_form_text(Qform *qf) {
oso *s = NULL;
if (qform_get_text_line(qf, Single_form_item_id, &s) && osolen(s) > 0)
return s;
osofree(s);
return NULL;
}
//
// Misc utils
//
@ -3268,11 +3276,10 @@ int main(int argc, char **argv) {
case Qform_action_type_submitted: {
switch (qform_id(qf)) {
case Open_form_id: {
oso *temp_name = NULL;
if (qform_get_text_line(qf, Single_form_item_id, &temp_name) &&
osolen(temp_name) > 0) {
undo_history_push(&t.ged.undo_hist, &t.ged.field,
t.ged.tick_num);
oso *temp_name = get_nonempty_singular_form_text(qf);
if (!temp_name)
break;
undo_history_push(&t.ged.undo_hist, &t.ged.field, t.ged.tick_num);
Field_load_error fle =
field_load_file(osoc(temp_name), &t.ged.field);
if (fle == Field_load_error_ok) {
@ -3291,40 +3298,35 @@ int main(int argc, char **argv) {
undo_history_pop(&t.ged.undo_hist, &t.ged.field,
&t.ged.tick_num);
qmsg_printf_push("Error Loading File", "%s:\n%s",
osoc(temp_name),
field_load_error_string(fle));
}
osoc(temp_name), field_load_error_string(fle));
}
osofree(temp_name);
} break;
case Save_as_form_id: {
oso *temp_name = NULL;
if (qform_get_text_line(qf, Single_form_item_id, &temp_name) &&
osolen(temp_name) > 0) {
oso *temp_name = get_nonempty_singular_form_text(qf);
if (!temp_name)
break;
qnav_stack_pop();
bool saved_ok = try_save_with_msg(&t.ged.field, temp_name);
if (saved_ok) {
if (saved_ok)
osoputoso(&t.file_name, temp_name);
}
}
osofree(temp_name);
} break;
case Set_tempo_form_id: {
oso *tmpstr = NULL;
if (qform_get_text_line(qf, Single_form_item_id, &tmpstr) &&
osolen(tmpstr) > 0) {
oso *tmpstr = get_nonempty_singular_form_text(qf);
if (!tmpstr)
break;
int newbpm = atoi(osoc(tmpstr));
if (newbpm > 0) {
t.ged.bpm = (Usz)newbpm;
qnav_stack_pop();
}
}
osofree(tmpstr);
} break;
case Set_grid_dims_form_id: {
oso *tmpstr = NULL;
if (qform_get_text_line(qf, Single_form_item_id, &tmpstr) &&
osolen(tmpstr) > 0) {
oso *tmpstr = get_nonempty_singular_form_text(qf);
if (!tmpstr)
break;
int newheight, newwidth;
if (sscanf(osoc(tmpstr), "%dx%d", &newwidth, &newheight) == 2 &&
newheight > 0 && newwidth > 0 && newheight < ORCA_Y_MAX &&
@ -3342,13 +3344,12 @@ int main(int argc, char **argv) {
}
qnav_stack_pop();
}
}
osofree(tmpstr);
} break;
case Set_soft_margins_form_id: {
oso *tmpstr = NULL;
if (qform_get_text_line(qf, Soft_margins_text_line_id, &tmpstr) &&
osolen(tmpstr) > 0) {
oso *tmpstr = get_nonempty_singular_form_text(qf);
if (!tmpstr)
break;
bool do_save = false;
int newy, newx;
if (read_nxn_or_n(osoc(tmpstr), &newx, &newy) && newy >= 0 &&
@ -3364,7 +3365,6 @@ int main(int argc, char **argv) {
// Might push message, so gotta pop old guy first
if (do_save)
tui_save_prefs(&t);
}
osofree(tmpstr);
} break;
}

Loading…
Cancel
Save