GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 01, 2014 1:43 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: GTK+ with shell code Linux
PostPosted: Sun Jan 08, 2012 9:24 pm 
Offline
Familiar Face

Joined: Sun Jan 08, 2012 8:55 pm
Posts: 6
HI all!

I am a simple user Linux.
I do not know programming languages​​, but I know basic Linux commands in shell.
But many users, even those basic commands do not know. But they know how to push buttons with the mouse.
Therefore, GTK+ is very topical issue in Linux for simple users.

Help please advice how to use GTK+ witch shell/bash scripting.
Any help, links, howto, tips, personal experiences, real-world examples, anything.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Jan 08, 2012 10:14 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
This is something I saw aske about a while back. If you do your GTK programming in C then you can run shell commands with the system() function. One thing to note is that GTK is designed to be cross platform and if you want this to be the case for your app then it will take some work to ensure that the commands can be used cross platform too.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Jan 08, 2012 10:24 pm 
Offline
Familiar Face

Joined: Sun Jan 08, 2012 8:55 pm
Posts: 6
I'm doing a program only for Linux.
I want to push the button to execute commands on shell bash.
I know about Zenity, but I want to use the full power of GTK +, but not one small component.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Mon Jan 09, 2012 10:07 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Take a look at the g_spawn_* functions from GLib: http://developer.gnome.org/glib/stable/glib-Spawning-Processes.html.

I wrote an example way back (uses some obsolete code) which used g_spawn_command_line_sync() to execute a command and show the results in a GtkTextView widget: http://www.gtkforums.com/viewtopic.php?t=906

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Jan 22, 2012 6:53 pm 
Offline
Familiar Face

Joined: Sun Jan 01, 2012 7:28 pm
Posts: 14
Location: Québec
Simpleuser, I don't know if you solved you problem yet. I am on Linux too.
I know two simple thing you can do:
Code:
system(gvim); //Starts gvim

Code:
execl("/usr/bin/pcmanfm-mod", "pcmanfm-mod", NULL); //Starts pcmanfm-mod file manager

For exec, there is a whole family of those functions. Take a look at the man.
One thing with exec, is that the process will overtake your gtk application. i.e. your gtk application will disappear and will be replaced by the executed application. Not sure I am saying this clearly... But you can try it.

I haven't read Micah's suggestion, but I will have to look into this.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Thu Jan 26, 2012 1:38 pm 
Offline
Familiar Face

Joined: Sun Jan 08, 2012 8:55 pm
Posts: 6
It's all too complicated for me. :(


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Thu Jan 26, 2012 5:43 pm 
Offline
Familiar Face

Joined: Sun Jan 01, 2012 7:28 pm
Posts: 14
Location: Québec
Simpleuser wrote:
It's all too complicated for me. :(

What did you try that did not work? What was the problem?
Did you skim through Gtk+ Tutorials & Resources? It is pretty hard to provide more than that.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Thu Jan 26, 2012 6:58 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
I do not think that you will get any better than Zenity to show basic dialogs as most shells do not have enough structure to take advantage of GTK. If you want to use more of GTK and want to stay with a script of some sort and do not mind learning a bit then there are Python or Perl.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Feb 05, 2012 5:44 pm 
Offline
Familiar Face

Joined: Sun Jan 08, 2012 8:55 pm
Posts: 6
errol, If I will know python or perl, then i will not need gtk. it lose its meaning!


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Feb 05, 2012 5:49 pm 
Offline
Familiar Face

Joined: Sun Jan 08, 2012 8:55 pm
Posts: 6
mariostg, thanks!
Will I can use the full power of gtk with shell scripts if I learn the basic course of gtk?
It will be more powerful than Zenity?


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Feb 05, 2012 6:07 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
I think you are missing the point of programming with GTK+, first it is not a programming language but a programming interface to to create a graphical user interface. You can use many programming languages including C, C++, Python, Perl, C# and many others to create your application and use GTK+ as a library of functions to create the graphical user interface.

Zenity was created to allow a basic interface to simple dialogue boxes for shell scripts. So simple things like error dialogues, question dialogues, file selection. But nothing more powerful than that as a shell can not hold the data that GTK+ requires to store.

If you want to use GTK+ to its full and create applications then you will have to learn a programming language in addition to learning GTK+. A shell script is really not powerful enough or portable.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GTK+ with shell code Linux
PostPosted: Sun Feb 05, 2012 6:16 pm 
Offline
Familiar Face

Joined: Sun Jan 08, 2012 8:55 pm
Posts: 6
errol, Thank you! I'll take your advice into consideration.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group