Re: Updating a ListStore



Hey Andrew:

Insert the following into your "while (location != string::npos)" loop after you update the list:

while(Gtk::Main::instance()->events_pending())
    Gtk::Main::instance()->iteration();


This will allow the framework to update the screen between row additions to your liststore.

Best regards,
Bob Caryl

On Thu, 2005-02-10 at 21:47, Andrew Krause wrote:
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!
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Robert L. Caryl Jr.
Fiscal Systems Inc.
102 Commerce Circle
Madison  AL 35758


256.772.8920 ext. 108 -- Office
256.527.7855 -- Cell

This email message may contain privileged or confidential information. If you are not the recipient, you may not disclose, use, disseminate, distribute, copy or rely on this message or attachment in any way. If you received this email message in error, please return by forwarding the message and its attachment to the sender and then delete the message and its attachment from your computer.  Fiscal Systems, Inc. and its affiliates do not accept liability for any errors, omissions, corruption or virus in the contents of this message or any attachments that arise as a result of e-mail transmission.


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