The ConfigureScreen now shows the current screen resolution if it is not in the combo box.

This commit is contained in:
David Capello 2010-03-07 23:48:01 -02:00
parent 0a7136a0b4
commit f1128336f4
3 changed files with 27 additions and 1 deletions

View File

@ -155,11 +155,13 @@ void ConfigureScreen::show_dialog(Context* context)
void ConfigureScreen::load_resolutions(JWidget resolution, JWidget color_depth, JWidget pixel_scale)
{
char buf[512];
bool old_res_selected = false;
m_resolutions.clear();
m_colordepths.clear();
m_pixelscale.clear();
// Read from gui.xml
DIRS* dirs = filename_in_datadir("gui.xml");
for (DIRS* dir=dirs; dir; dir=dir->next) {
@ -196,8 +198,10 @@ void ConfigureScreen::load_resolutions(JWidget resolution, JWidget color_depth,
sprintf(buf, "%dx%d", w, h, aspect);
jcombobox_add_string(resolution, buf, NULL);
if (old_w == w && old_h == h)
if (old_w == w && old_h == h) {
old_res_selected = true;
jcombobox_select_index(resolution, jcombobox_get_count(resolution)-1);
}
}
}
else if (strcmp(xmlElement->Value(), "colordepth") == 0) {
@ -230,6 +234,15 @@ void ConfigureScreen::load_resolutions(JWidget resolution, JWidget color_depth,
}
dirs_free(dirs);
// Current screen size
if (!old_res_selected) {
m_resolutions.insert(m_resolutions.begin(), std::make_pair(old_w, old_h));
sprintf(buf, "%dx%d (Current)", m_resolutions[0].first, m_resolutions[0].second);
jcombobox_insert_string(resolution, 0, buf, NULL);
jcombobox_select_index(resolution, 0);
}
}
static bool try_new_gfx_mode(Context* context)

View File

@ -173,6 +173,18 @@ void jcombobox_add_string(JWidget widget, const char *string, void *data)
jcombobox_select_index(widget, 0);
}
void jcombobox_insert_string(JWidget widget, int index, const char *string, void *data)
{
ComboBox* combobox = reinterpret_cast<ComboBox*>(jwidget_get_data(widget, JI_COMBOBOX));
bool sel_first = jlist_empty(combobox->items);
ComboItem *item = comboitem_new(string, data);
jlist_insert(combobox->items, item, index);
if (sel_first)
jcombobox_select_index(widget, 0);
}
void jcombobox_del_string(JWidget widget, const char *string)
{
jcombobox_del_index(widget, jcombobox_get_index(widget, string));

View File

@ -45,6 +45,7 @@ bool jcombobox_is_clickopen(JWidget combobox);
bool jcombobox_is_casesensitive(JWidget combobox);
void jcombobox_add_string(JWidget combobox, const char *string, void *data);
void jcombobox_insert_string(JWidget combobox, int index, const char *string, void *data);
void jcombobox_del_string(JWidget combobox, const char *string);
void jcombobox_del_index(JWidget combobox, int index);
void jcombobox_clear(JWidget combobox);