You are not logged in.

#1 2014-02-03 18:39:38

spiritech
Member
Registered: 2013-11-27
Posts: 63

Learing GTk

hi i would like to start learing GTK 2. i have started the tutorial. however i get stuck when compiling the code. any hints or tips appreciated. also how difficult would it be to write a file mananger in GTK. and maybe a music mananger player.

am i right in saying that once i specify a widget. do i just specify a command to carry out when i press that widget, or are all widgets predifined. or are they customizable.

after all a widget is still only a widget.

any input appreciated.

spiritech

Offline

#2 2014-02-03 18:43:40

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Learing GTk

If you want help, post the code in question.
It's not exactly Arch-related, you can ask about it on general Linux and programming forums too.

Offline

#3 2014-02-03 18:52:43

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,346

Re: Learing GTk

Moving to Programming and Scripting.

I might point out that it is a non-trivial journey from the first experiments trying to get pre-written tutorials to run to a full-blown window manager.  Best of luck.  (sincerely, not sarcastically)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2014-02-03 18:53:13

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Learing GTk

spiritech wrote:

i get stuck when compiling the code.

In what way do you get stuck when compiling the code? What command are you using to compile the code? Is there an error message?

also how difficult would it be to write a file mananger in GTK. and maybe a music mananger player.

It will be very very very difficult. sad

Offline

#5 2014-02-03 19:24:41

spiritech
Member
Registered: 2013-11-27
Posts: 63

Re: Learing GTk

drcouzelis wrote:
spiritech wrote:

i get stuck when compiling the code.

In what way do you get stuck when compiling the code? What command are you using to compile the code? Is there an error message?

also how difficult would it be to write a file mananger in GTK. and maybe a music mananger player.

It will be very very very difficult. sad

well after i have writen the tutorial code. i save it as a file.c. then i open a terminal where the file.c is, and run the compile instructions in the tuorial.

link here https://developer.gnome.org/gtk-tutoria … HELLOWORLD

#include <gtk/gtk.h>

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    
    gtk_init (&argc, &argv);
    
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);
    
    gtk_main ();
    
    return 0;
}

You can compile the above program with gcc using:

gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`

not sure what to do after this. how do i run the file.

Last edited by spiritech (2014-02-03 19:25:34)

Offline

#6 2014-02-03 19:29:28

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Learing GTk

Run

./base

Offline

#7 2014-02-03 19:45:59

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Learing GTk

Would it be correct to say that you've kinda skipped some basic steps, and jumped straight into this gtk tutorial? It seems to me that it assumes some elementary knowledge, such as how to run stuff that you've just compiled etc.

Re the difficulty of coding a gtk file manager, music player, or whatever, there are shedloads of such apps already. A quck glance over the source code will give you an idea of how difficult it might be for you.

Offline

#8 2014-02-03 19:59:30

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: Learing GTk

Also, you might want to think about whether or not you really want to start out by writing GTK2 applications in C. If you are new to UI programming, I recommend starting out in a higher level language (such as Python/Vala) unless you are really comfortable in C (I get the impression that you aren't). Furthermore, you might want to consider a different toolkit such as QT5 or GTK3 as GTK2 has been superseded by GTK3. While GTK2 isn't obsolete, it probably isn't worth learning (although it isn't that much different than GTK3). In my personal experience, programming in QT (specifically, python3 with pyqt5) is a much more pleasant experience altogether.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#9 2014-02-03 22:48:07

spiritech
Member
Registered: 2013-11-27
Posts: 63

Re: Learing GTk

tomk wrote:

Would it be correct to say that you've kinda skipped some basic steps, and jumped straight into this gtk tutorial? It seems to me that it assumes some elementary knowledge, such as how to run stuff that you've just compiled etc.

Re the difficulty of coding a gtk file manager, music player, or whatever, there are shedloads of such apps already. A quck glance over the source code will give you an idea of how difficult it might be for you.

guess i better start learning more then. i would really like to start being able to make my own apps for linux. i will continue with and trying to pick up gtk for now. everything i have learnt, i have learnt from forums and just trying to get under the hood of my OS. i have learnt bash, studied some html and now gtk.

Last edited by spiritech (2014-02-03 22:49:53)

Offline

#10 2014-02-03 23:10:49

spiritech
Member
Registered: 2013-11-27
Posts: 63

Re: Learing GTk

well for whats its worth i rote and compiled my first gtk script. and while we are on the subject, and before i sign up with a gtk forum. can i give buttons, widgets or icons custom commands when clicked on in a gtk interface?

Offline

#11 2014-02-03 23:21:25

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Learing GTk

spiritech wrote:

guess i better start learning more then. i would really like to start being able to make my own apps for linux. i will continue with and trying to pick up gtk for now. everything i have learnt, i have learnt from forums and just trying to get under the hood of my OS. i have learnt bash, studied some html and now gtk.

As others have said, you are trying to run before you can crawl. Whatever language you're working in, you should first try to become really comfortable with that language before thinking about doing GUI work. If you want to call GTK from a C program, you first need to make sure you're reasonably good with C. You should be pretty comfortable with using pointers, allocating and freeing memory, and debugging and profiling your code from the command line. Start with writing something that you can use entirely on the command line, without any graphics.

Remember, it takes 10,000 hours to become an expert in anything. If you think you're going to become lead developer on a big Linux GUI app overnight, you're putting too much pressure on yourself. I've been using Linux and programming in various languages for years, but I would still hesitate to dive into a big GTK project or try to develop a really complicated app from scratch.

This is a fun exercise you might want to consider: How to write a roguelike in 15 steps.

It will teach you a lot about how to write a reasonably complicated program from scratch. Assuming you use ncurses as the interface library, you will learn some concepts that generalise to GUIs.

Offline

#12 2014-02-04 00:41:53

spiritech
Member
Registered: 2013-11-27
Posts: 63

Re: Learing GTk

/dev/zero wrote:
spiritech wrote:

guess i better start learning more then. i would really like to start being able to make my own apps for linux. i will continue with and trying to pick up gtk for now. everything i have learnt, i have learnt from forums and just trying to get under the hood of my OS. i have learnt bash, studied some html and now gtk.

As others have said, you are trying to run before you can crawl. Whatever language you're working in, you should first try to become really comfortable with that language before thinking about doing GUI work. If you want to call GTK from a C program, you first need to make sure you're reasonably good with C. You should be pretty comfortable with using pointers, allocating and freeing memory, and debugging and profiling your code from the command line. Start with writing something that you can use entirely on the command line, without any graphics.

Remember, it takes 10,000 hours to become an expert in anything. If you think you're going to become lead developer on a big Linux GUI app overnight, you're putting too much pressure on yourself. I've been using Linux and programming in various languages for years, but I would still hesitate to dive into a big GTK project or try to develop a really complicated app from scratch.

This is a fun exercise you might want to consider: How to write a roguelike in 15 steps.

It will teach you a lot about how to write a reasonably complicated program from scratch. Assuming you use ncurses as the interface library, you will learn some concepts that generalise to GUIs.

thank you for your input. in regards to command line stuff with no graphics i have written some simple user input terminal scripts for ffmpeg and imagemagick. the program runs in a terminal asks the user for the ext they would like to convert to mp4 jpg png etc. then asks the useer for there options, -resize -bitrate -aspectratio etc. it then displays the ext and options and asks if this is correct y or n. then processes the files from a list.

i dont have any intentions of writing full blown suits from the ground up. only to write graphical front ends to console based programs that already exsist, like mplayer audio players and ffmpeg.

i will have a look at the link you gave me How to write a roguelike in 15 steps.

thankyou.

Offline

#13 2014-02-04 01:19:26

mmix
Member
Registered: 2014-01-11
Posts: 33

Re: Learing GTk

official gtk tutorial not good, this link is better.
http://zetcode.com/tutorials/gtktutorial/

when you have done, take loot at gtk application source code.
http://gtk-apps.org/

--
PS: gtk forum.
http://www.gtkforums.com/

Last edited by mmix (2014-02-04 01:21:20)

Offline

Board footer

Powered by FluxBB