rem: combo_box_model = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING); for (idx0 =  0; idx0 < MAX_FILES; idx0++) {  if (screen.file[idx0] == NULL) { gtk_list_store_append(combo_box_model, &iter); gtk_list_store_set (combo_box_model, &iter, 0, idx0, -1); } } gtk_combo_box_set_model(GTK_COMBO_BOX(interface.layer_active), GTK_TREE_MODEL(combo_box_model)); gtk_tree_model_get_iter_first(GTK_TREE_MODEL(combo_box_model), &iter); gtk_combo_box_set_active_iter   (GTK_COMBO_BOX(interface.layer_active), &iter); click_layer_active_cb(GTK_WIDGET(interface.layer_active), NULL); }
add: combo_box_model = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING); for (idx0 =  0; idx0 < MAX_FILES; idx0++) { if (screen.file[idx0] == NULL) { gtk_list_store_append(combo_box_model, &iter); gtk_list_store_set (combo_box_model, &iter, 0, idx0, -1); } } gtk_combo_box_set_model(GTK_COMBO_BOX(interface.layer_active), GTK_TREE_MODEL(combo_box_model)); if (screen.curr_index == interface.layer_select_active) { gtk_tree_model_get_iter_first(GTK_TREE_MODEL(combo_box_model), &iter); g_signal_emit_by_name ((GTK_COMBO_BOX(interface.layer_active)), "changed"); gtk_combo_box_set_active_iter   (GTK_COMBO_BOX(interface.layer_active), &iter); click_layer_active_cb(GTK_WIDGET(interface.layer_active), NULL); } }
context: open_image(char *filename, int idx, int reload){    gerb_file_t *fd;    int r, g, b;    GtkStyle *defstyle, *newstyle;    gerb_image_t *parsed_image;    gerb_verify_error_t error = GERB_IMAGE_OK;    char *cptr;#ifdef USE_GTK2           int          idx0;    GtkTreeIter  iter;#endif    if (idx >= MAX_FILES) {	GERB_MESSAGE("Couldn't open %s. Maximum number of files opened.\n",		     filename);	return -1;    }    fd = gerb_fopen(filename);    if (fd == NULL) {	GERB_MESSAGE("Trying to open %s:%s\n", filename, strerror(errno));	return -1;    }        if(drill_file_p(fd))	parsed_image = parse_drillfile(fd);    else 	parsed_image = parse_gerb(fd);    gerb_fclose(fd);    /*     * Do error check before continuing     */    error = gerb_image_verify(parsed_image);    if (error) {	GERB_COMPILE_ERROR("%s: Parse error:\n", filename);	if (error & GERB_IMAGE_MISSING_NETLIST)	    GERB_COMPILE_ERROR("* Missing netlist\n");	if (error & GERB_IMAGE_MISSING_FORMAT)	    GERB_COMPILE_ERROR("* Missing format\n");	if (error & GERB_IMAGE_MISSING_APERTURES) 	    GERB_COMPILE_ERROR("* Missing apertures/drill sizes\n");	if (error & GERB_IMAGE_MISSING_INFO)	    GERB_COMPILE_ERROR("* Missing info\n");	GERB_COMPILE_ERROR("\n");	GERB_COMPILE_ERROR("You probably tried to read an RS-274D file, which gerbv doesn't support\n");	free_gerb_image(parsed_image);	return -1;    }    /* Used to debug parser */    if (screen.dump_parsed_image)	gerb_image_dump(parsed_image);    /*     * If reload, just exchange the image. Else we have to allocate     * a new memory before we define anything more.     */    if (reload) {	free_gerb_image(screen.file[idx]->image);	screen.file[idx]->image = parsed_image;	return 0;    } else {	screen.file[idx] = (gerbv_fileinfo_t *)malloc(sizeof(gerbv_fileinfo_t));	memset((void *)screen.file[idx], 0, sizeof(gerbv_fileinfo_t));	screen.file[idx]->image = parsed_image;    }    /*     * Store filename for eventual reload     * XXX Really should check retval from malloc!!! And use strncpy     */    screen.file[idx]->name = (char *)malloc(strlen(filename) + 1);    strcpy(screen.file[idx]->name, filename);    /*     * Try to get a basename for the file     */    cptr = strrchr(filename, '/');    if (cptr) {	int len;	len = strlen(cptr);	screen.file[idx]->basename = (char *)malloc(len + 1);	if (screen.file[idx]->basename) {	    strncpy(screen.file[idx]->basename, cptr+1, len);	    screen.file[idx]->basename[len] = '\0';	} else {	    screen.file[idx]->basename = screen.file[idx]->name;	}    } else {	screen.file[idx]->basename = screen.file[idx]->name;    }    /*     * Calculate a "clever" random color based on index.     */    r = (12341 + 657371 * idx) % (int)(MAX_COLOR_RESOLUTION);    g = (23473 + 434382 * idx) % (int)(MAX_COLOR_RESOLUTION);    b = (90341 + 123393 * idx) % (int)(MAX_COLOR_RESOLUTION);    screen.file[idx]->color = alloc_color(r, g, b, NULL);    /*      * Set color on layer button     */    defstyle = gtk_widget_get_default_style();    newstyle = gtk_style_copy(defstyle);    newstyle->bg[GTK_STATE_NORMAL] = *(screen.file[idx]->color);    newstyle->bg[GTK_STATE_ACTIVE] = *(screen.file[idx]->color);    newstyle->bg[GTK_STATE_PRELIGHT] = *(screen.file[idx]->color);    gtk_widget_set_style(screen.layer_button[idx], newstyle);    /*      * Tool tips on button is the file name      */    gtk_tooltips_set_tip(screen.tooltips, screen.layer_button[idx],			 filename, NULL);#ifdef USE_GTK2                         //#if 0    if ((interface.main_window) && (!reload) && gtk_tree_model_get_iter_first(GTK_TREE_MODEL(combo_box_model), &iter)) {                                  combo_box_model = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);         for (idx0 =  0; idx0 < MAX_FILES; idx0++) {            if (screen.file[idx0] == NULL) {                gtk_list_store_append(combo_box_model, &iter);                gtk_list_store_set (combo_box_model, &iter, 0, idx0, -1);            }         }        gtk_combo_box_set_model(GTK_COMBO_BOX(interface.layer_active), GTK_TREE_MODEL(combo_box_model));        gtk_tree_model_get_iter_first(GTK_TREE_MODEL(combo_box_model), &iter);        gtk_combo_box_set_active_iter   (GTK_COMBO_BOX(interface.layer_active), &iter);        click_layer_active_cb(GTK_WIDGET(interface.layer_active), NULL);                                                }                                     #endif                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON				     (screen.layer_button[idx]),TRUE);    return 0;} /* open_image */