gtkdialog1-1.4

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#136 Post by disciple »

goingnuts wrote:Also saved 73K by making a multicall binary of the 4 progs in the cdtool package
Out of interest: is that a standard option, or does it involve some trickery?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

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

#137 Post by technosaurus »

disciple wrote:Out of interest: is that a standard option, or does it involve some trickery?
not standard, but the principle is straightforward - change the main() for each program to program_main() and make a new main() that calls the appropriate program_main() based on the basename of agv[0] (the /path/name of the binary as executed) or argv[1] if for instance the first arg is busybox - see the latest release of mupdf for an example that I contributed to (mubusy).

Now this is also applicable to scripts, but using $0 instead of argv[0]
for example

Code: Select all

cdplayer(){
: code here
}

processinfo(){
: code here
}

multicall(){
$@
}

mycommand=`basename $0`
$mycommand $@
(this will run the function cdplayer if you run the script as ./cdplayer or multicall cdplayer, and is much more compressible than several small files)
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].

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#138 Post by disciple »

Oh, so you're actually doing it to reduce the number of executables, rather than to avoid compiling multiple copies of shared code?
Do you need to post the modified source?
What license is it under?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#139 Post by goingnuts »

Main purpose of doing mcb is to reduce total size...
I do not know about the license stuff and if source must be shipped along with the binary but as always source is available upon request. I seldom ship the modified source code as only very few seems interested in that...

Attached an other demo - gtkrdesktop - including rdesktop-1.2.0 static build.

The purpose of making the demos is to exercise gtkdialog1 and find missing features etc. The gtkrdesktop is a launcher for the remote desktop application rdesktop, used to connect to various windows desktops. I would have liked to include possibilities for saving/loading profiles but are missing some features in the gtkdialog1 like setting status of checkboxes via script/variable and the append action to comboboxes - added to the TODO list in first post.
Attachments
snap0001.png
(17.26 KiB) Downloaded 819 times
gtkrdesktop-0.1.pet
gtkdialog1 front end to rdesktop-1.2.0
(123.91 KiB) Downloaded 482 times

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#140 Post by disciple »

goingnuts wrote:Main purpose of doing mcb is to reduce total size...
Yeah, I was really asking about how it reduces the total size.
I do not know about the license stuff and if source must be shipped along with the binary
OK, looking at http://packages.debian.org/changelogs/p ... .copyright it seems to be under the GPL, and therefore it must.
but as always source is available upon request.
Please provide it. Thanks.
I seldom ship the modified source code as only very few seems interested in that...
What if someone comes along in future who wants it, but you're not around anymore? Your effort would have been wasted, as someone else would need to redo it.
I know of a case where someone released a couple of Windows builds of a program that they were working on based on a GPL library, promising to release the source when it was "finished" (a number of people want it, mostly to build on Linux). But then they disappeared from the forum it was released on, without providing the source. There are still people finding it years later, but all we can do is use the binary with Wine :(
Attached an other demo - gtkrdesktop - including rdesktop-1.2.0 static build.
Cool.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#141 Post by goingnuts »

disciple wrote: Please provide it. Thanks
...
What if someone comes along in future who wants it, but you're not around anymore? Your effort would have been wasted, as someone else would need to redo it.
...
Is a patch OK?

The mcb is more a technique and it is described other places in this forum - but as it involves some specific new code for every binary you apply it too - I guess you are right - and I do see your point
Attachments
cdtool-2.1.8.mcb.tar.gz
modified source
(116.66 KiB) Downloaded 493 times
cdtool-2.1.8_mcb_patch.txt.gz
fake .gz-file - just rename to cdtool-2.1.8_mcb_patch.txt
run "patch -p0<cdtool-2.1.8_mcb_patch.txt"
run "./configure"
run ./build_mcb.sh"
(7.33 KiB) Downloaded 512 times

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#142 Post by disciple »

Yes, thanks, I generally prefer patches.

Actually, I think I wasn't 100% correct when I said you need to post the source with the binary. You need to either post the source or a written offer to provide the source to anyone who has the binary. (I also saw someone say that the source needs to be distributed with the binary, but not necessarily by you, and that if you provided a link to the original source that would suffice, along with patches for any changes. I'm not sure how true this is.)
Anyway, I think technically we should be distributing source with every .pet, in which case the GPL compliance around here is terrible. Providing patches should make most people happy though.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#143 Post by goingnuts »

disciple: Thanks for info!

Attached another demo: gtkman
Find man pages present on your system and text-format them for view in edit-widget. Need original man - busybox man will not work - so static build of man-1.6e also included.
Attachments
gtkman-0.1.pet
gtkdialog1 front end for man pages -
static build of man included
(26.91 KiB) Downloaded 537 times

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

#144 Post by technosaurus »

Here is a static build with my musl toolkit (all pixbuff loaders are working except tiff ,... but only because it is kindof irrelevant here), I modified stringman.c to speed up the file search - you can now just export GTKDIALOG_PIXMAP_DIR and it will look there.

Code: Select all

char *find_pixmap(char *filename)
{
	char tmp[128];
	static char *line = NULL;
	static uint length = 0;
	FILE *locate;

	if (access(filename, R_OK) == 0)
		return filename;

	//snprintf(tmp, 127, "/usr/share/icons/Bluecurve/16x16/stock/%s",
	snprintf(tmp, 127, "/usr/share/pixmaps/%s", filename);
	tmp[127] = '\0';
	if (access(tmp, R_OK) == 0)
		return strdup(tmp);

	snprintf(tmp, 127, "/usr/share/mini-icons/%s", filename);
	tmp[127] = '\0';
	if (access(tmp, R_OK) == 0)
		return strdup(tmp);


	snprintf(tmp, 127, "%s/%s",getenv("GTKDIALOG_PIXMAP_DIR"), filename);
	tmp[127] = '\0';
	if (access(tmp, R_OK) == 0)
		return strdup(tmp);

	return 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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#145 Post by goingnuts »

Thanks for the patch for the find_pixmap!
Did you use the last source of gtkdialog1 (GtkDialog1-1.1)? Your binary has some problems with setting the wmclass I think - app name wont show in window title which make the app crash if you move mouse over jwm buttonbar. Might just be my jwm that has the problem - its P412 std jwm.
The button images also seems odd - no right margin.
Below same script running with your bin left and mine right.
A second thought: I think the wmclass is gdk/gtk/tinyX11 related. I think I made a hack for it - try look into my gdk/gtk-sources and search for wmclass...
Attachments
snap0004.png
(94.96 KiB) Downloaded 718 times

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

#146 Post by technosaurus »

It was probably just a badly patched toolchain - I left out some extra utf8 stuff from tinyX11 and probably hacked something to make it compile. (I lost patience after fixing most of the compile errors and warnings in gdk, so the gtk side just got quick, hacky patches)
Btw, you can make the static gdk_pixbuf easier to work with by doing:

Code: Select all

ar x *.a (on the loaders)
and then adding those objects to libgdk_pixbuf.a with

Code: Select all

ar cru libgdk_pixbuf.a *.o
Side note: the gdk-pixbuf stuff reminded me that rox-1.2.2 can use imlib if available, it should work pretty similar. (the vfs stuff was interesting too)
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].

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#147 Post by amigo »

Techonosaurus, "rox-1.2.2 can use imlib if available" The older rox-1.0.0 used only imlib, but I didn't even know that 1.2.2 could use it. It may speed up loading of desktop icons and/or improve their rendering. Have you noticed either of these?

"the vfs stuff was interesting too" -Did you get this working? I always wanted it but couldn't get it to work.

About your patch to find_pixmap, There is a note in the TODO file about this function. What we really need there is to be using the users' chosen theme, if available. We now have gtkrc file being read, so 'themedir' gets set(hopefully).
The original code:

Code: Select all

snprintf(tmp, 127, "/usr/share/icons/Bluecurve/16x16/stock/%s",
should be getting 'themedir' from the rc file and subsituting that name for the original 'Bluecurve'.

I think it's okay to be able to set the environmental variable GTKDIALOG_PIXMAP_DIR and use that first if set. But, next it should try to use the themedir from the rc file. We now can specify the rcfile on the command-line, so that should be the second choice. Otherwise, the users' default ~/.gtkrc should be read. If themedir has still not been set, then it should look under /usr/share/pixmaps or /usr/share/mini-icons. Common practice would have only *.xpm images under /usr/share/pixmaps and only *.png (or *.svg) under /usr/share/mini-icons.

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

#148 Post by technosaurus »

@amigo - imlib and gdkpixbuf are much better suited to a shared library toolchain, so I have been trying to avoid them lately while playing with my static musl toolchain. However the way the modules work reduces the memory footprint significantly in a traditional shared library system (on par with the static builds) if you want to support multiple image types. ...btw before I forget ...
@goingnuts - do you still have the pre-gdk_pixbuf sources for gtkdialog 1?
Re: VFS in ROX-Filer, I did get it to work in the 2.X series - never tried it in 1.X IIRC it needed fuse, libavfs and lib{x,t}ar and was missing support for a widely used format (don't remember which)
Re:Themedir: I _think_ glade does that too ... I will check, it may be a simple cut/paste job.

Edit:... the gtkrc stuff seemed straight forward in the tutorial, but I didn't see anything in glade1 (glade2 may be backportable, but now I'm not sure where I saw gtkrc code)
http://www.gtk.org/tutorial1.2/gtk_tut-21.html#ss21.3
Edit2: AVFS-1.0.1 was released with xz support = good time to try a rox rebuild
Last edited by technosaurus on Wed 13 Jun 2012, 16:32, edited 1 time in total.
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#149 Post by goingnuts »

technosaurus: don't know if this is what you need?
Attachments
gtkdlg1_source_020212.tar.gz
pre -gdkpixbuf gtkdialog 0.5.8.11 source
(157.61 KiB) Downloaded 492 times

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

swallow

#150 Post by goingnuts »

Coming back to the gtk-swallow-widget - present source below. Needs window ID of the window to swallow passed as argument - at the moment found by using xwininfo. Attached image of static mplayer (diet build found here) playing 2001-A_Space_Odyssey.avi and swallowed by the gtk-app.
Main problem now is to have the swallow-widget to launch the program you want to swallow and swallow it. Code below mainly produced by technosaurus:

Code: Select all

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <stdio.h>

void destroy(GtkWidget *widget, gpointer data){ gtk_main_quit (); }   

int main (int argc, char *argv[]) {
   int wid;   char command[255];
   ///below takes passed windowID from argument ex. 0x400063
   sprintf(command,"echo %s", argv[1]);
   fscanf(popen(command, "r"),"%x",&wid);
   g_print ("The window ID is %i\n", wid);
  
   gtk_init (&argc, &argv);
/// Create a new window
   GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy), NULL);
/// Create main container
   GtkWidget* vbox1 = gtk_vbox_new(FALSE, 0);
   gtk_container_add(GTK_CONTAINER(window), vbox1);
   //below just some playing around
    GtkWidget* toolbar;
    GtkWidget* icon;
    GtkWidget* button;
    
    toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,GTK_TOOLBAR_BOTH);
    gtk_box_pack_start(GTK_BOX(vbox1), toolbar, FALSE, FALSE, 0);
    gtk_widget_show(toolbar);
 
/// Create socket
   GtkWidget* gtk_socket = gtk_socket_new ();       
   gtk_widget_set_usize (gtk_socket, 400, 400);       
/// Pack socket in vbox container
   gtk_box_pack_start(GTK_BOX(vbox1), GTK_WIDGET(gtk_socket), TRUE, TRUE, 0);      
   gtk_widget_realize (gtk_socket);
   
   gtk_socket_steal (GTK_SOCKET (gtk_socket), wid);
/// Show the window and all widgets now that everything is ready
   gtk_widget_show_all(window);
   gtk_main ();       
   return 0;       
}
Attachments
snap0007.png
(161.44 KiB) Downloaded 591 times

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#151 Post by goingnuts »

Another demo: gtkmplayer - very simple frontend for mplayer.
Contains also code for some more advanced functions (select audio and video driver + set audio speed) - change flag in gtkmplayer source to view.
Using "mplayer -slave" and fifo /tmp/mplayer-control to pass commands from gtk-frontend to mplayer.
Attachments
gtkmplayer-0.1.pet
demo for gtkdialog1 - simple frontend for mplayer
(11.59 KiB) Downloaded 697 times

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#152 Post by goingnuts »

Yet another demo - backport/hack of SNS - Simple Network Setup - to use Gtkdialog1. Based on SNS from Puplite 5.0 kindly supplied by starhawk.
Attached pet is the first try and may not work and be buggy.
A bunch of helping progs attached as well, everything put in /bin to give preference for these applications and ease removal...
You will need Gtkdialog1 - get it in the first post.
Attachments
snap0008.png
(19.95 KiB) Downloaded 1402 times

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

Re: Backport gtkdialog 0.59.8 to use gtk1/gtk2: gtkdialog1-1.0

#153 Post by technosaurus »

goingnuts wrote:TODOS:
* <text> accept <input>command
* quotes in <action>command
* combobox <default>, accept <action append> and fill with command
* checkboxes: set value from variable/script[/url][/url]
* revise help text for --geometry
just checking on the TODOS
* quotes in <action>command
g_strescape(); ?
* revise help text for --geometry
from wary's gtkdialogX
Usage:
gtkdialog [OPTION...]
Create dialog boxes and windows according to the given dialog description.For more information try 'info gtkdialog'.

Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options

GTK+ Options
--class=CLASS Program class as used by the window manager
--name=NAME Program name as used by the window manager
--screen=SCREEN X screen to use
--sync Make X calls synchronous
--gtk-module=MODULES Load additional GTK+ modules
--g-fatal-warnings Make all warnings fatal

Application Options:
-v, --version Print version information and exit.
-d, --debug Debug mode prints the processed characters.
-p, --program=variable Get the GUI description from the environment.
-g, --glade-xml=filename Get the GUI description from this Glade file.
-f, --file=filename Get the GUI description from a regular file.
-i, --include=filename Include the given file when executing.
-e, --event-driven=filename Execute the file as an event driven program.
-s, --stdin Get the GUI description from standard input.
-w, --no-warning Suppress warning messages.
-G, --geometry=[XxY][+W+H] The placement and the size of the window.
-c, --center Center the windows on the screen.
--print-ir Print the internal representation and exit.
--space-expand=state The "expand" state for packing all widgets.
--space-fill=state The "fill" state for packing all widgets.
--display=DISPLAY X display to use
thats the lowest hanging fruit, for the rest I'd have to compare Xdialog (the unpatched gtk1 version) and gtkdialog2-4 (my sdialog program may help too)
another TODO?
SVG capability via librsvg's included gdkpixbuf-loader (its one of the only ones that isn't distributed with gdkpixbuf)
SVG would add a ton of capabilities

also I submitted a patch to gtkdialog-trunk that used some gtk2 builtins for refreshing, that Thunor cleaned up, but I had previously used native inotify (may require a kernel update though ... Edit: nope - inotify was introduce in 2.6.13) if anyone is interested in that.
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#154 Post by goingnuts »

Thx for looking at this!
The quotes in <action>command seems to be related to the parser. gtkdialog-0.58.11 accepts

Code: Select all

<action>echo "You pressed the button with the label."</action>
whereas gtkdialog-0.59.8 does not (errors out with "Error in line 6, near token 'quoted string': syntax error").

This might be a nice way to force separation of the gktdialog GUI-code and the shell-code but makes translation of existing scripts somewhat more challenging. Looking into lexer.l and the difference between the two version is still black magic to me...

The

Code: Select all

-g,--geometry                     Set the position and/or size of the
                                   window, [XxY][+W+H].

is wrong for present version as the XxY sets the widthxheight and the +W+H sets position...

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#155 Post by 8-bit »

How compatible is this version of gtkdialog1 with programs written to use gtkdialog that comes with puppy?
I ask because I tried running a few of the examples that come with gtkdialog by first copying them to a temporary directory and then editing them to use gtkdialog1.
I did not find any that worked.
Most had syntax errors.
So will this fork of gtkdialog be compatible with the gtkdialog scripts that permeate puppy?

And is this mod a matter of lessening CPU load?

Post Reply