GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
mrd
Posts: 124
Joined: Wed 28 Nov 2007, 02:04

where to find window icons

#571 Post by mrd »

I can't seem to get a window icon to appear on my apps. Can some tell me where the icon image files needs to be located to work on a dialog as below.

<window title=\"NASViewer\" icon-name=\"NASviewer16.xpm\">

I've tried the full path as well and that didn't work.

Thanks!

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

#572 Post by 8-bit »

If you click on ROX, the house icon on your desktop and then on Puppy Reference, there will be a number of icon directory links shown.
You can put your icon in any of them although I would suggest /usr/share/mini-icons.
Or you can create a link to it.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#573 Post by thunor »

8-bit wrote:When one is writing a gtkdialog script, there seems to be no reference one can refer to as to words that are reserved for gtkdialog.
A list of those words would be nice so one knows not to use them as variables or other areas where they might conflict with reserved words.

Good idea or bad?
You create a shell script to construct a Gtkdialog XML-like structure which is stored within a shell variable that's passed to the gtkdialog binary. The variable names that Gtkdialog exports to the shell are those that you've instructed it to use e.g. <variable>LABEL1</variable> (widgets containing multiple items also export additional variables with an "_ALL" suffix on exit). Recently I found within an example a Gtkdialog exported shell variable named BUTTON which holds the mouse button id (if applicable) that triggered an action, but I'm not aware of anything else (I searched the code for "setenv" and "putenv"). Therefore other than MAIN_DIALOG, the <variable> names that you store within the XML and BUTTON that Gtkdialog may export, what else is there to conflict with? If you give me an example I can assist you with it.
Dave_G wrote:I've just started coding with gtkdialog and have to agree 100% with 8-bit.

Unfortunately this lack of documentation is not unique to gtkdialog, it seems
to be pretty common in the Linux world.
A very big stumbling block for newbies like myself.

Dave.
  • Widget Reference - it's not completely populated but it's a good start.
  • GTK+ 2 Reference Manual for the GtkEntry Widget - the <entry> widget within Gtkdialog (the GTK+ read/write properties are the Gtkdialog tag attributes).
  • Use the GTK+ 2 Reference Manual to find other properties for other widgets or use Gtkdialog's Widget Reference which already includes the links.
  • There's a very useful Widget Construction section with links to GTK+ widget properties (tag attributes) within the main post of the Gtkdialog Development thread.
  • The same post includes a list of comprehensive examples for the newly added or extended widgets.
  • You can browse the original but recently updated examples within the repository or you can checkout the source code; examples included.
  • There's a Documentation section on the project page.
If there's something that you think is lacking in documentation then let me know and I'll address the issue :)

Regards,
Thunor

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#574 Post by thunor »

Issue 8 within the issue tracker (zigberts issues) has a request for "supporting <item stock=gtk-open>coloumn1|coloumn2</item> from an input file". I came across an example named 09.03-tree_icon_columns that supports <input stock_column="0"> which accepts a stock_id as the first column (icon_column="0" also works for theme icons). Therefore the ability to input stock or theme icons into tree rows from a file already exists and you can do it like this:

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

function inputfile() {
	echo "gtk-open | | gtk-open | 2
	gtk-about | | gtk-about | 2
	gtk-add | | gtk-add | 2
	gtk-apply | | gtk-apply | 2
	gtk-bold | | gtk-bold | 2
	gtk-cancel | | gtk-cancel | 2
	gtk-cdrom | | gtk-cdrom | 2
	gtk-clear | | gtk-clear | 2
	gtk-close | | gtk-close | 2
	gtk-color-picker | | gtk-color-picker | 2
	gtk-convert | | gtk-convert | 2 " > inputfile
	ifs="$IFS"
	IFS=
	echo $(<inputfile)
	IFS="$ifs"
}; export -f inputfile

export MAIN_DIALOG='
<vbox>
	<frame Stock icons from file via input command>
		<tree>
			<variable>TREE1</variable>
			<label>0 | 1 | 2</label>
			<height>300</height><width>250</width>
			<input stock_column="0">inputfile</input>
		</tree>
	</frame>
	<button ok></button>
</vbox>
'

$GTKDIALOG --program=MAIN_DIALOG 
Regards,
Thunor

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

#575 Post by technosaurus »

Jwm will automatically look for an icon with the _same_ name as your program in its icon path (name.png or name.xpm) ... no 16, case must match etc...just make a symlink without the description of size etc... most wm's do the same.
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].

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

#576 Post by 8-bit »

thunor,
Speaking of examples, what is it with an included example in gtkdialog/examples/09.12-tree-one-column

It is written with an incorrect path to gtkdialog and even though the executable property is set on it, it shows the same as a text file would and not an executable script.
It looks like it is supposed to populate itself with files from the working directory, but does not.
Is it a "fix it yourself" example?
I am just curious as to what it is supposed to display.

Also!! Thank you for the references of documentation for gtkdialog.
It all helps as does this offering by seaside.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#577 Post by thunor »

8-bit wrote:...what is it with an included example in gtkdialog/examples/09.12-tree-one-column
Fixed now, and 09.00-tree as well.

They use "ls" to build rows using theme icons but the commands weren't working properly and the icons didn't exist.

Regards,
Thunor

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

#578 Post by 8-bit »

Again, I know it has been said many times, but I will say it again.

Thank you thunor!!!

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#579 Post by jpeps »

Is there any way to add a filter to gtk-open "fileselect" for specific filetypes?

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

#580 Post by seaside »

jpeps wrote:Is there any way to add a filter to gtk-open "fileselect" for specific filetypes?
Jpeps,

I have not seen any way, although there is the "complete" function, but I don't think it's available.

You could perhaps call Zenity/Yad or maybe Xdialog (not sure about Xdialog) with a "yad --file-selection --file-filter" option.

Regards,
s
EDIT: I suppose you could also do a "ls *.jpg" action to a tmpfile and then pick from there.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#581 Post by jpeps »

I'm sure I must be doing something wrong, but when importing a file to the "list" widget and selecting an item, it wasn't linking with the widget "variable"

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#582 Post by smokey01 »

Is there any way to set a background colour or image in a gtkdialog window?

Thanks

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#583 Post by 01micko »

smokey01 wrote:Is there any way to set a background colour or image in a gtkdialog window?

Thanks
Not image as far as I know but any background colour is possible..

it's a case of running a unique gtk+ theme for that app.

Code: Select all

echo "style "slideshow"

{
	bg[NORMAL]		= "$COLOUR"
}

class "*" style "slideshow"" > /tmp/gtkrc

export GTK2_RC_FILES=/tmp/gtkrc:/root/.gtkrc-2.0
Slideshow was a silly little app I wrote ages ago, but that code should give you the gist of it, obviously the COLOUR variable must be set, it can be any defined colour or in the #000000 format

HTH
Puppy Linux Blog - contact me for access

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#584 Post by jpeps »

seaside wrote:
jpeps wrote:Is there any way to add a filter to gtk-open "fileselect" for specific filetypes?
Jpeps,

I have not seen any way, although there is the "complete" function, but I don't think it's available.

You could perhaps call Zenity/Yad or maybe Xdialog (not sure about Xdialog) with a "yad --file-selection --file-filter" option.

Regards,
s
EDIT: I suppose you could also do a "ls *.jpg" action to a tmpfile and then pick from there.
TCL-TK works nicely. I got sick of sloppy work-arounds.
Attachments
petch.png
(19.35 KiB) Downloaded 1143 times

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

#585 Post by disciple »

What about gnocl? Because it would be much nicer to have GTK dialogues etc, as this is the standard for everything in Puppy.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#586 Post by jpeps »

disciple wrote:What about gnocl? Because it would be much nicer to have GTK dialogues etc, as this is the standard for everything in Puppy.
That's why I was trying to use Gtkdialog3. Seems like GTK has LOTS of bindings in many languages. Gnocl is one of them (which I don't know much about).

Some things I'd be looking for:

Good run-time interaction for widgets; basic properties (like filters, etc); variables I can use for selected items of widgets (lists, etc); active community of developers/extensive documentation. I google searched for a tcltk combobox that a user can update (try this for gtkdialog3):

Code: Select all

#!/usr/bin/env wish
set ff [frame .f]
set label [label $ff.label -text "Name:" ]
set name [ttk::combobox $ff.name -textvariable name]
set addButton [button $ff.addButton -text "+" -width 1 \
    -command [list addNameToComboBox $name]]
set removeButton [button $ff.removeButton -text "-" -width 1 \
    -command [list removeNameFromComboBox $name]]
grid $label $name
grid $ff.addButton -row 0 -column 2 -sticky w 
grid $ff.removeButton -row 0 -column 3 -sticky sw -padx 5
pack $ff -side top -fill both -expand true

proc addNameToComboBox {name} {
    set values [$name cget -values]
    set current_value [$name get]
    if {$current_value ni $values} {
        lappend values $current_value
        $name configure -values $values
    }
}

proc removeNameFromComboBox {name} {
    set values [$name cget -values]
    set current_value [$name get]
    if {$current_value in $values} {
        set i [lsearch -exact $values $current_value]
        set values [lreplace $values $i $i]
        $name configure -values $values
    }    
}

Attachments
combobox-tcltk.png
(9.61 KiB) Downloaded 1095 times

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#587 Post by jpeps »

thunar just added fileselect filters :D


http://murga-linux.com/puppy/viewtopic. ... &start=218

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

with Xdialog

#588 Post by jpeps »

Here's a combo I found with Xdialog's logbox, which allows text colors. This example shows (potentially) clobbered files in red. (think I'll put the builtins in another color).

(Thunor's fileselect filter got me inspired to experiment a bit)
Attachments
logbox.png
(61.83 KiB) Downloaded 998 times

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

#589 Post by 8-bit »

jeps,
Do you care to share that script so others can check it out?
It looks interesting and what with installation or removal of a pet package that contains library files that already exist, it would be good to not have those libraries trashed on uninstalling a pet.
And for some reason unknown to us, the library files are not part of /root/.packages/builtin.
That means if a pet is uninstalled that contained library files that already exist they would be removed.
That is not a good thing at all.

Also, if a library file is used by more than one installed PET, and installed by it, uninstalling one PET can break another.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#590 Post by jpeps »

8-bit wrote:jeps,
Do you care to share that script so others can check it out?
I'm having fun making lots of changes. For basic use, probably a cut back version would be suitable. Generating the initial builtin list takes about 9M.. I like it to prioritize (in color! ), but most users just need to see what's installed*. I've always used my own installers/uninstallers, but don't want to step on anyone's toes.

The other problem is that I'm using Thunor's latest gtkdialog3 with the fileselect filters.

* second thought..most users do NOT want to see what's installed

Post Reply