GTK+ development configuration

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

GTK+ development configuration

#1 Post by captnemo »

I have an app of my own making that I haven't done any work on in two years that I want to pick up again. It's standard C and GTK-2.0 The last time it was worked on was on a Ubuntu system. I installed the Puppy devx package, recreated the app's directory structure, and ran the makefile to see what would happen. The result was better than I expected. But it can't find the include files for gtk, gdk, etc.

My question has to do with the path to include files. On the Ubuntu system the following invocations worked:

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <libgnome/libgnome.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
etc.

I looked at the .pc file for gtk-2.0 and it looked like I needed to use the following syntax:

#include <gtk-2.0/gtk/gtk.h>

And indeed this works. It finds gtk.h. But I'd rather stick with the shorter version. Is it okay to modify the .pc file from:

includedir=${prefix}/include

to:

includedir=${prefix}/include/gtk-2.0

so that in the C source I can simply say gtk/gtk.h ?

Or is there a better way to solve this?

Also, I believe that gtk.h contains some more includes and will it be able to find those?

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

pkg-config --cflags gtk+-2.0
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#3 Post by captnemo »

technosaurus wrote:pkg-config --cflags gtk+-2.0
Good suggestion but the makefile already contains that. Here's the contents of my makefile that worked under my old Ubuntu setup and that I'm using now:

CC = gcc

CFLAGS = -Wall -lao `pkg-config --cflags gtk+-2.0 libgnome-2.0 gmodule-2.0`
LDFLAGS = -lao `pkg-config --libs gtk+-2.0 libgnome-2.0 gmodule-2.0`

OBJECTS = dal.o utilities.o draw.o confparse.o sounds.o commands.o features.o objects.o
PROG = dal

$(PROG): $(OBJECTS)
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)

clean:
rm -f *.o $(PROG)

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#4 Post by technosaurus »

do you actually use libgnome? Puppy doesn't have it and that is breaking your pkg-config line

run that line in a terminal to check the output - its great that its in the makefile but that doesn't tell you that it actually works

then try removing libgnome and see if it will build, for puppy it would be better to avoid the mostly superfluos gnome bits ... and looking at the names of the object files, gmodule is probably unnecessary too.

Unless you have over 100 or so files to compile, there is no need for a makefile. A basic gtk app that isn't a buggy p.o.s. should compile with:

Code: Select all

gcc `pkg-config --cflags gtk+-2.0` *.c -o myapp -lgtk-x11-2.0
if that works you can add optimization flags like -pipe -combine -Os (optimise and minimize size)

a universal makefile for a gtk-only app would look like

Code: Select all

CC = gcc
PROG = myapp
CFLAGS = -g -pipe -combine -Os
LDFLAGS = -Wl,--as-needed,-s
$(CC) `pkg-config --cflags gtk+-2.0` $(CFLAGS) *.c -o $(PROG) `pkg-config --libs gtk+-2.0` $(LDFLAGS)
(if your c files are in src then src/*.c instead of *.c)

p.s. next time you get an error message it would be helpful to report it - does this ring a bell?
Package libgnome-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libgnome-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libgnome-2.0' found
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#5 Post by captnemo »

Thanks for the tips. I'll investigate your suggestions.

I've been using makefiles for 30 years so it's an old habit. I always use make, even for a single source file.

And yes, I did see the lib error message, but I figured first things first. Not finding the gtk includes prevents compilation. Sort that out first and get it to compile, then worry about linking and libraries. But your point is well taken. I can't remember off-hand why I added libgnome but I'll find out.

Thanks again.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#6 Post by technosaurus »

captnemo wrote: Not finding the gtk includes prevents compilation. Sort that out first and get it to compile, then worry about linking and libraries.
when you call pkg-config with multiple entries (gtk and gnome) if any one of them is unavailable, none of the include are output because pkg-config just outputs the error (and nothing else) and it will keep doing so until every .pc file is found (see /usr/lib/pkg-config), basically its about as crappy as the rest of the autotools garbage.

rather than an whole separate ridiculous system, packages could just have a file that could be sourced directly the same way shells include files for extra variables and functions

for example:

. $FLAGCONFIGPATH/gtk+-2.0.flags || echo warning can't find gtk2

similarly the same could be done by system libraries that provide any of the 5million things that configure checks in triplicate

. $FLAGCONFIGPATH/snprintf.flags || MISSING_SNPRINTF=1

(you don't want to see how it actually happens)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#7 Post by captnemo »

technosaurus: Thank you very much for the tips. And I apologize because part of my question was "dumb". After being away from programming for a bit, I had become rusty on how makefiles worked. Duh.

All is straightened out now, including the libao stuff which works perfectly. The reason libgnome was in there was because this application makes extensive use of configuration files in INI format and I was using the functions for that in libgnome. That's now deprecated so I wrote my own suite of functions to manipulate INI files and eliminated libgnome.

Next, I have to track down an interesting problem that's been there since day one but never manifested before. This app is multithreaded and somewhere I'm doing something that's not thread-safe. It never crashed on other platforms but on Puppy it crashes with a seg fault after about 10 seconds of operation, so I'm glad to have discovered the problem. The threads communicate with each other via FIFOs, which I assumed would avoid most problems but I'm doing something dumb somewhere. Should be fun to track down.

Anyway, thanks again for the guidance.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#8 Post by technosaurus »

Puppy doesn't come with strace, but you can get it here:
http://landley.net/aboriginal/bin/
It's useful for rudimentary debugging, or you could post the code.
BTW if one of the pipes is stdin, gtk is likely the problem, however Gio has a file monitor that can watch a file for changes (on linux it uses inotify as a backend) My simple icon tray uses it to watch image files that get changed by shell scripts, but works for other situations.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#9 Post by captnemo »

Technosaurus: I wanted to thank you again for the info. All is working great. I knocked together an application I've been threatening to write for about 15 years. haha.

Back around 1990 there was a DOS program called InfoSelect that was close to ideal for organizing bits of information and quickly accessing it. It was a DOS TSR program that became obsolete when DOS went away. The company that made InfoSelect developed the program into a clumsy Windows app that was no longer useful to me and I've missed the old InfoSelect ever since.

So now I have it back again. Simple, fast, does what I need and nothing more.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#10 Post by technosaurus »

Is it something that could replace puppy's Notecase (which is no longer supported upstream)?
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#11 Post by captnemo »

technosaurus wrote:Is it something that could replace puppy's Notecase (which is no longer supported upstream)?
I sent a couple of PMs with the code attached (it's all in one file) and some comments on how it's supposed to work. I figure it's easier to show than tell.

The app is unpolished but I'm using it for my work already. It's a completely different paradigm from Notecase so I don't know whether it would be appropriate for replacing it. On the other hand, it does quite a lot for a tiny program.

Each day I'm making little fixes and improvements. For example, I just fixed an oversight (that's less than a bug, haha) where it was possible to open more than one search dialog at once.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#12 Post by jamesbond »

If you're being generous and you like using SCM (version control), you can get a free account at github.com (if you use git SCM) or chiselapp.com (if you use fossil SCM) or bitbucket.org (if you use mercurial SCM) and upload your repository / code there. As a benefit, people can contribute to that code too and make it better.

Googling for "DOS InfoSelect" gives a few result but having no experience with it, I have no idea how it works.

PS: My favorite DOS TSR was Borland Sidekick; I spent many hours writing assembly language programs in its editor 8)
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#13 Post by captnemo »

Yes, I plan to put it out there for people to play with if there's any interest. It might be useful to somebody.

It's still pretty crude, although I'm using it every day for my work now. I'm still making fixes and improvements every day and one important function is missing.

I've never published anything on github or sourceforge before.

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#14 Post by captnemo »

Okay, I've opened an account on github and created a repository for it. Next I need to create a readme file and I ran info YADM (yet another damned format). :shock:

Puppy doesn't seem to have a markdown editor. Is there a format converter or quick way to generate an md file from text or whatever?

I'm running Slacko 5.3.3 here.

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#15 Post by captnemo »

Solved the markdown format problem.

There is now a repo on Github that contains a readme file and the C source code for the NoteSelect gizmo.

Not sure exactly how to refer to it. I suppose it's https://github.com/shuttersparks/NoteSelect (?)

I must say that Github is one of the most opaque and unfriendly contraptions I've ever run into.

Please let me know if the above reference to the repo is incorrect.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#16 Post by seaside »

captnemo wrote:Solved the markdown format problem.

There is now a repo on Github that contains a readme file and the C source code for the NoteSelect gizmo.

Not sure exactly how to refer to it. I suppose it's https://github.com/shuttersparks/NoteSelect (?)

I must say that Github is one of the most opaque and unfriendly contraptions I've ever run into.

Please let me know if the above reference to the repo is incorrect.
captnemo,

Good work.

I downloaded and compiled the source and all is working as you mentioned.

Thanks for making it available.

Cheers,
s
(Be nice to have shortcut keys for menu items :) )

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#17 Post by technosaurus »

captnemo wrote:I must say that Github is one of the most opaque and unfriendly contraptions I've ever run into
... And slow too, do they really need flash for every commit info button? Damn web programmers. ( I say tongue in cheek as that is my current bent of the week )
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

captnemo
Posts: 40
Joined: Tue 11 Sep 2012, 15:41

#18 Post by captnemo »

seaside wrote:
captnemo wrote: (Be nice to have shortcut keys for menu items :) )
Yes indeed! Funny you should mention that because that's a major thing for me. The main reason I've not implemented any "accelerators" or shortcuts is I'm still thinking about exactly how I want to do it. I want to get close to how InfoSelect worked (fast single character keyboard commands to do everything) and still keep use of the mouse. (With DOS InfoSelect, there was no mouse, of course.)

Here's a rough description of how I envision it working at the moment: There are two modes, mouse(?) and command. If you use only the mouse you never get into command mode, you do it all with the pointing device. To get into command mode you hit ESCape. In command mode, hitting N creates a new note, hitting D deletes a note, E drops you into edit on the currently selected note, R resizes, S saves, F finds, etc. Navigation among notes is done with TAB, backTAB, and arrow keys.

Exactly how to do the above is still a thought experiment. There probably needs to be a mode indicator somewhere.

For maximum speed and efficiency (for a good typist) it's best if you don't have to remove your hands from the keyboard and mess with a mouse or pointing device. InfoSelect was like that. Once you got the hang of it, it was extremely fast to use. I'd like to implement something like that for NoteSelect yet keep the mouse interface as well.

I'm glad to hear that Git worked. As you can see, the program is rude and crude but shows the idea of the thing. :lol:

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#19 Post by seaside »

captnemo wrote:
seaside wrote:
captnemo wrote: (Be nice to have shortcut keys for menu items :) )
Here's a rough description of how I envision it working at the moment: There are two modes, mouse(?) and command. If you use only the mouse you never get into command mode, you do it all with the pointing device. To get into command mode you hit ESCape. In command mode, hitting N creates a new note, hitting D deletes a note, E drops you into edit on the currently selected note, R resizes, S saves, F finds, etc. Navigation among notes is done with TAB, backTAB, and arrow keys.

Exactly how to do the above is still a thought experiment. There probably needs to be a mode indicator somewhere.

For maximum speed and efficiency (for a good typist) it's best if you don't have to remove your hands from the keyboard and mess with a mouse or pointing device. InfoSelect was like that. Once you got the hang of it, it was extremely fast to use. I'd like to implement something like that for NoteSelect yet keep the mouse interface as well.

I'm glad to hear that Git worked. As you can see, the program is rude and crude but shows the idea of the thing. :lol:
captnemo,

Not much more thinking required. Coming from the "touch-type" perspective, an "Alt-Ctrl-F" is not exactly a combination to look forward to, or any mouse operation either.

Cheers,
s
(I didn't find your program in the least bit "rude", at all :) )

Post Reply