1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// Voici la déclaration de la combo box
entry_musician_style = gtk_combo_box_new_text();
gtk_widget_set_size_request(entry_musician_style, 300, -1);
gtk_widget_show(entry_musician_style);
gtk_table_attach_defaults(GTK_TABLE(table_1), entry_musician_style, 1, 2, 2, 3);
// Fill combo box (from SQL database)
fill_list_1d("select style from musician_style", entry_musician_style);
//avec la fonction fill_list_1d :
void fill_list_1d(char* SQL_request, GtkWidget* list) {
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open("data_base/database.db", &db);
rc = sqlite3_exec(db, SQL_request, add_to_list, (void *) list, &zErrMsg);
sqlite3_close(db);
}
static int add_to_list(void *liste, int argc, char **argv, char **azColName) {
int i;
for(i=0; i<argc; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(liste), argv[i]);
return 0;
} |
Partager