Constants editing.

This commit is contained in:
gyboth 2009-03-09 20:56:16 +00:00
parent 0f99a20978
commit aeb6c714e2
2 changed files with 22 additions and 28 deletions

View File

@ -727,7 +727,7 @@ enum
};
GtkTreeModel*
treeview2_create_constants(const GArray *list, gint type)
treeview2_create_constants(const GPtrArray *list, gint type)
{
#ifdef DEBUG
printf("treeview2_create_constants\n");
@ -761,20 +761,20 @@ treeview2_create_constants(const GArray *list, gint type)
if(type == CONSTANTS_TYPE_INT)
gtk_list_store_set(ls, &iter,
0, i,
1, g_array_index(list, Option, i).name,
2, g_array_index(list, Option, i).value,
1, ((Option*)g_ptr_array_index(list, i))->name,
2, ((Option*)g_ptr_array_index(list, i))->value,
-1);
else if(type == CONSTANTS_TYPE_FLOAT)
gtk_list_store_set(ls, &iter,
0, i,
1, g_array_index(list, Option, i).name,
2, (gfloat)g_array_index(list, Option, i).value / OPTION_FLOAT_DIVISOR,
1, ((Option*)g_ptr_array_index(list, i))->name,
2, (gfloat)((Option*)g_ptr_array_index(list, i))->value / OPTION_FLOAT_DIVISOR,
-1);
else
gtk_list_store_set(ls, &iter,
0, i,
1, g_array_index(list, Option, i).name,
2, g_array_index(list, Option, i).string_value,
1, ((Option*)g_ptr_array_index(list, i))->name,
2, ((Option*)g_ptr_array_index(list, i))->string_value,
-1);
}
@ -821,26 +821,29 @@ treeview2_show_constants(void)
printf("treeview2_show_constants\n");
#endif
gint i, j;
gint i;
GtkTreeView *treeview[4] =
{GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_integer")),
GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_float")),
GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_float")),
GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_string")),
GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_app"))};
GtkTreeModel *model;
GArray *list[4] =
{g_array_new(FALSE, FALSE, sizeof(Option)),
g_array_new(FALSE, FALSE, sizeof(Option)),
g_array_new(FALSE, FALSE, sizeof(Option)),
constants_app.list};
GPtrArray *list[4] =
{g_ptr_array_new(),
g_ptr_array_new(),
g_ptr_array_new(),
g_ptr_array_new()};
for(i = 0; i < constants.list->len; i++)
if(g_str_has_prefix(g_array_index(constants.list, Option, i).name, "int_"))
g_array_append_val(list[CONSTANTS_TYPE_INT], g_array_index(constants.list, Option, i));
g_ptr_array_add(list[CONSTANTS_TYPE_INT], &g_array_index(constants.list, Option, i));
else if(g_str_has_prefix(g_array_index(constants.list, Option, i).name, "float_"))
g_array_append_val(list[CONSTANTS_TYPE_FLOAT], g_array_index(constants.list, Option, i));
g_ptr_array_add(list[CONSTANTS_TYPE_FLOAT], &g_array_index(constants.list, Option, i));
else
g_array_append_val(list[CONSTANTS_TYPE_STRING], g_array_index(constants.list, Option, i));
g_ptr_array_add(list[CONSTANTS_TYPE_STRING], &g_array_index(constants.list, Option, i));
for(i = 0; i < constants_app.list->len; i++)
g_ptr_array_add(list[CONSTANTS_TYPE_APP], &g_array_index(constants_app.list, Option, i));
for(i = 0; i < 4; i++)
{
@ -850,15 +853,6 @@ treeview2_show_constants(void)
gtk_tree_view_set_model(treeview[i], model);
g_object_unref(model);
/* if(i < 4) */
/* { */
/* for(j = 0; j < list[i]->len; j++) */
/* { */
/* g_free(g_array_index(list[i], Option, j).name); */
/* g_free(g_array_index(list[i], Option, j).string_value); */
/* } */
/* g_array_free(list[i], TRUE); */
/* } */
g_ptr_array_free(list[i], TRUE);
}
}

View File

@ -83,7 +83,7 @@ void
treeview2_show_news(void);
GtkTreeModel*
treeview2_create_constants(const GArray *list, gint type);
treeview2_create_constants(const GPtrArray *list, gint type);
void
treeview2_set_up_constants(GtkTreeView *treeview);