Updating a ListStore



In my code, I run different commands such as autogen & make by using fopen. I
then use fgets to get the output and then split the buffer into lines. Each
line is added to the ListStore as it is parsed, but my problem is that the
ListStore does not update until after the command is run. How could I update
the ListStore as the output is added. This is an excerpt of the code:

  /* Begin Code */
  FILE *in;
  char buff[128];
  unsigned int location;
  string text = "\0", line;
  ModelColumns build_columns;
  RefPtr<ListStore> build_model;
  
  /* Make new model & set it to the List Store */
  build_box.remove_all_columns();
  build_model = ListStore::create(build_columns);
  build_box.set_model(build_model);

  /* Append command to the ListStore & add column */
  TreeModel::Row row = *(build_model->append());
  row[build_columns.col_text] = command;
  build_box.set_model(build_model);
  build_box.append_column(COMP_OUTPUT, build_columns.col_text);
   
  /* Run command */
  in = popen(command.c_str(), "r");
  while (fgets(buff, sizeof(buff), in)) {
    /* Set buffer to string & split if an endl is found */
    text += buff;
    location = text.find("\n",0);
    /* Append output line & erase it from the text string */
    while (location != string::npos) {
      line = text.substr(0,location);
      row = *(build_model->append());
      row[build_columns.col_text] = line;
      text.erase(0,location+1);
      location = text.find("\n",0);
    }
  }

Thanks for the help!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]