Re: What is the minimum number of lines to update a gui window without user clicking a button



On Sat, 10 Aug 2013 12:16:16 -0400
"L. D. James" <ljames apollo3 com> wrote:
[snip]
The VPN application currently have 500 lines.  I'll strip it down to
50, making sure it retains functionality and post it.

One of the reasons I didn't post it before, but posted "sleep(10)" to
represent the application was doing something, because the program is
designed to make changes to the system.  But, I'm sure I'll be able to
comment and have such a flow that you might be able to easily follow
it just by looking at it, or, on your own, comment out the parts that
makes changes.

If an outline of your code just consists of:

void check_stuff() {
  if (vpn_connections_changed()) std::cout << "XXX changed\n";
}

int main(int argc, char* argv[]) {
  for (;;) {
    sleep(10);
    check_stuff();
  }
  return 0;
}

Then in gtkmm this just becomes:

bool check_stuff() {
  if (vpn_connections_changed()) std::cout << "XXX changed\n";
  return true;
}

int main(int argc, char* argv[]) {
  Gtk::Main app(argc, argv);
  Glib::signal_timeout().connect_seconds(sigc::ptr_fun(&check_stuff), 10);
  app.run();
  return 0;
}

You can go from there and add your graphical interface to check_stuff()
in place of the call to std::cout.  You might, for example, want to
display a Gtk::MessageDialog object.  With gtkmm-3.0, you might want
to use Gtk::Application instead of Gtk::Main.  But first things first.

Chris


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