LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-28-2007, 03:23 PM   #1
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
Gtkmm main loop


So, I have a gtkmm application in which one class is responsible for encapsulating what comes out of a pipe. All the data isn't going to hit the pipe at once though, so I can't just do a bunch of blocking fgetc()'s. I tried some awkward solution about spawning off a separate thread which watched the file descriptor, but that eventually led to needing to update the GUI in this separate thread, which is a big no-no since gtkmm is not threadsafe.

I've done a fair amount of work with gtk and in gtk I would just have the main loop poll the file descriptor for me. I would like to do the same thing in gtkmm, however the function to instruct the main loop to poll a file descriptor was a method of the glib main loop. In gtk this wasn't a problem because the gtk main loop was just a glib main loop. However, in the gtkmm documentation the Gtk::Main claims to inherit only from sigc::trackable, not Glib::Main, and the method I need is a method of Glib::MainContext.

So is Gtk::Main a child of Glib::Main and it's not documented or is there another way to get the main loop to poll a file descriptor for you?
 
Old 09-29-2007, 12:59 AM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Original Poster
Rep: Reputation: 48
Okay, so I just tried it so what did and did not work. I used this line to register my callback and file descriptor
Code:
Glib::signal_io().connect(sigc::mem_fun(*this, &Action::onPoll), from, Glib::IO_IN | Glib::IO_HUP);
Which should, as I understand it, read something like this.
"Glib::signal_io()" Get the default signal-io object
"connect" Connect a file descriptor
"sigc::mem_fun(*this, &Action:nPoll)" The slot referring to the callback method.
"from" the name of the file descriptor
"Glib::IO_IN | Glib::IO_HUP" call the callback when there is data to read or the file descriptor closes

This works partially, the callback is being called for the HUP, but not when there's new I/O.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 8 04-05-2011 10:18 AM
bash loop within a loop for mysql ops br8kwall Programming 10 04-30-2008 04:50 AM
converting shell while loop to for loop farkus888 Programming 8 09-12-2007 03:30 AM
Exception in thread "main" java.lang.ClassFormatError: onmyown.Main (unrecognized cla zimboney Fedora 4 07-20-2007 02:00 PM
for loop only works properly on first loop symo0009 Programming 1 12-25-2005 06:17 PM


All times are GMT -5. The time now is 01:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration