Re: What is the minimum number of lines to update a gui window without user clicking a button
- From: "L. D. James" <ljames apollo3 com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: What is the minimum number of lines to update a gui window without user clicking a button
- Date: Sat, 10 Aug 2013 19:41:33 -0400
On 08/10/2013 07:09 PM, Chris Vine wrote:
This appears to be just a batch job calling popen() which brings up a
ppp connection. There is no program loop anywhere and the while loop
for fgets() in runit() will block until EOF is reached, which equates
to the call to pppd ending and the process in which it is running
closing its stdout. Presumably you run this as a cron job, or
something like that? Or, since you say, "while it's running and
checking the connection it outputs either starts '*' or dots '.' at 10
second interval while it checks some of the file and connection
status", possibly you have excised the loop logic, which is the
interesting part for present purposes. (As it happens, it will not
compile because the prototype for runit() is not in namespace scope,
but that is no doubt just a matter of transcription.) To call up an
executable (in this case pppd) in this kind of usage using glib you
would normally use Glib::spawn_async_with_pipes() and connect to the
standard_output and standard_error file descriptors with
Glib::signal_io().connect(). The problem you have got here though is
that you call setuid(0) on a binary which presumably has its suid bit
set in order to launch pppd. You should definitely not do that
directly with a GTK+ program. You would need to have a small wrapper
with suid set which calls up pppd, which is launched by your GTK+
program using Glib::spawn_async_with_pipes(). (Yuck.) As it happens,
if you want a short cut for a batch job like this which provides a
GTK+ user interface, I would consider a shell script and zenity, which
is what zenity was intended for. A google search will tell you more.
However you would still need to circumvent your setuid problem. Chris
Hi, Chris. I stripped down a 500 line C++ program and included some
system calls to give you and example of my many C++ programs. Many C++
programs use calls to the system shell. I can tell that happening with
a number of driver installations.
This application would not work as a bash script. I mentioned to you
that you can not set the suid bit on a bash script.
I'm familiar with cron jobs, and have no problems with cronjobs. In
fact some of my applications are run by cron.
The particular VPN connection application is run currently added to the
Ubuntu dash and shows a black screen for the status when it's run.
By the way, there are gui applications for batch files, perl files and
just about any other programming concept.
I appreciate your interest and your questions and suggestions. I
understand that I don't have to use or learn gtkmm. But I hope you
don't mind my interest in the facility.
Some of my applications do not use any system calls. Some of them use
some system calls. But I would like for most of them to output to a gui
window where than a console. I understand how complicated you think
this will be. But it can be done with C++ just as with just about any
programming application.
By the way, the program does compile. I've already started to add the
gui interface. I did it with the gtk label with the help of Alan. I
posted the example in a different thread. I ran into problems when I
tried to change the label widget into a textview widget because I was
having problems understanding the full gist of the gtkmm tools. When
Kjell posted his resolution, I saw the light. So I started this thread
on trying to break down Kjell's program into components (namely to
eliminated the unneeded widgets).
I'm getting there with some of the in-between the line suggestions from
this new thread. I'm starting to understand more and more how to use
gtkmm, of which I'm trying to do. I really don't think it's as
complicated and some users are suggesting. I believe it's just a matter
of getting a grip of a few vague concepts.
While I'm having problems just sending text to a window, you're
suggesting that I dive figure and use gtkmm for my other calls. I might
get to that at some time. But at present, I just want to use gtkmm to
output to a gui screen instead of a black screen.
-- L. James
--
L. D. James
ljames apollo3 com
www.apollo3.com/~ljames
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]