Learning GtkDialog (hopefully) -- and I have questions...

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

Learning GtkDialog (hopefully) -- and I have questions...

#1 Post by starhawk »

Let me start by saying that programming is not a strength of mine! I have a hard time with this stuff... but I'm determined :twisted:

The ultimate goal here is to create an LXLauncher style "netbook interface" for Puppy, using GtkDialog... I realize that I'm well away from achieving that, but I'd like to see how far I can get.

Eventually what I want is for this interface to sit on top of JWM, replacing the bottom tray. The interface will have tabs...
Home
Filesystem
Graphics
Internet
Productivity
Entertainment
Utility
Config
More specifically... Internet also contains the "Network" submenu; Productivity combines Document, Business, and Personal; Entertainment combines (most of) Multimedia and Fun; CD burning tools and the like are (if possible) merged into Utility, and Config incorporates Desktop, System, and Setup.

"Home" is a special tab which contains quick links to commonly needed items -- it serves as the desktop, if you will. It links to the ConnectWizard, defaultbrowser, defaultwordprocessor, and rxvt (Terminal), as well as showing the currently-available drives and partitions (sda1,sda2,sdb1,sr0,etc). The drive icons hot-update lets say every five seconds (this can very easily change -- but they must update without restarting JWM or X).

Program icons displayed within the interface's tabs should change the same way that the JWM PuppyMenu changes -- running "fixmenus" in a terminal should update things.

*ahem*

So the first question is --

I want the interface to be fullscreen, with no titlebar and no frame/border around the window. I know that I want to use a GtkNotebook widget as the primary component -- that widget will implement the tabs and contain the icons.

What I don't know is how to actually /do/ that. I have an idea but I don't know if it's permissible... basically, embed a widget inside another widget. In this case, create a GtkWindow that has no 'decorations' (titlebar,frame/border,etc) and is fullscreen, and then stick the GtkNotebook inside the GtkWindow.

Can I do that? and in either case, is there a better way?

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#2 Post by starhawk »

Help? :(

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

#3 Post by amigo »

"I want the interface to be fullscreen, with no titlebar and no frame/border around the window."
Instead of running "on top of JWM", simply run your program without any WM at all -on bare X, that is.
OTOH, JWM can maybe disable all window decoration.

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#4 Post by starhawk »

I still need a WM of some sort -- after all, the launcher I'm (hopefully) making is only a launcher, and not a WM itself. It could be one of the 'trayless' WMs (IIRC OpenBox is like that) but I do need a WM.

What I'm wanting is basically LXLauncher, but configurable in meaningful ways. (IIRC LXLauncher was basically abandoned mid-development.)

EDIT: to be more clear -- the 'notebook' widget in GtkDialog is what I'm wanting to be fullscreen and undecorated -- and the only thing that I want that way. That's the launcher. Anything it launches needs to have the decorations -- title bar, min/max/close buttons, and window frame/border -- the works.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

Re: Learning GtkDialog (hopefully) -- and I have questions...

#5 Post by sc0ttman »

I want the interface to be fullscreen, with no titlebar and no frame/border around the window.
Do this in your /root/.jwm/jwm-personal, to give the option to disable that stuff to any app:

<Group>
<Class>my_classname</Class>
<Option>noborder</Option>
<Option>notitle</Option>
</Group>

(... note... gtkdialog also can use 'decorated="false"' (see below) ... )

Then you need to force your GUI to fill the screen... So use xwininfo to get the screen height and width:

Code: Select all

export WIDTH=`xwininfo -root | grep Width | cut -f2 -d':' `
export HEIGHT=`xwininfo -root | grep Height | cut -f2 -d':' `
...

Then in the top of your gtkdialog GUI you can add this (height and width are reduced a little from actual screen size, and decorated=false hides the window title etc):

Code: Select all

export GUI='<window height-request="'$((HEIGHT-25))'" width-request="'$((WIDTH-25))'" decorated="false">
... blah ...
</window>'
NOTE: if the GUI freezes when you run it, make the $HEIGHT and $WIDTH smaller - do $((HEIGHT-50)) or something ...

Then at the end of the script, when you load up the GUI and run gtkdialog, add this class stuff at the end:

Code: Select all

gtkdialog --program MYGUI --class=my_classname
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#6 Post by starhawk »

Thanks, sc0ttman, that looks quite helpful. I'll look it over when I'm not so sleepy (quarter to midnight here) ;)

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#7 Post by starhawk »

That's definitely useful. I think that will answer that question.

Next: this is a kinda basic one that the documents online don't go into. I've looked, and they just don't explain.

How do I do the beginning part of the GtkDialog script, so that it will open the GtkNotebook with the proper tabs and such, and then populate it with icons?

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#8 Post by sc0ttman »

Gtkdialog needs a string passed to it, and that *is* the GUI - it doesnt need to be populated or manipulated after creating it - it just needs to be executed by gtkdialog...

The easiest way to do it (IMHO) is something like this:

Code: Select all

#!/bin/sh

#set some variables ... just as examples of how to customise the GUI before it loads
export mytitle="My program name"
export version=0.1
export tab=1   #will load the 2nd tab, the 1st tab is zero
export button_label_1="Click Me!"
export button_label_2="Click Me Too!"
export WIDTH=300

# create the GUI string .. 

export MY_GUI_STRING='<window title="'$mytitle' '$version'" width-request="'$WIDTH'">
<vbox>
	<notebook labels="first|second" page="'$tab'">
		<frame>
			<text><label>"first tab"</label></text>
			<button>
				<label>'$button_label_1'</label>
				<input file>/usr/local/lib/X11/pixmaps/draw24.png</input>
			</button>
		</frame>
		<frame>
			<text><label>"second tab"</label></text>
			<button>
				<label>'$button_label_2'</label>
				<input file stock="gtk-execute"></input>
			</button>
		</frame>
	</notebook>
	<button cancel></button>
</vbox>
</window>'


#run gtkdialog, using the GUI string above

gtkdialog --program MY_GUI_STRING


#gui is now closed

exit 0
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#9 Post by starhawk »

Wow, that's half the app written there, just about -- thank you SO MUCH!!

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#10 Post by starhawk »

OK, now the doozy -- how can I load applications into this thing...? Ideally I'd pull from JWM's /etc/xdg/menus/*.menu files, but I'm not sure I can do that. Alternatively, how do I read the *.desktop files in /usr/share/applications so that I can drop icons and text into the GtkNotebook?

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#11 Post by Bert »

There are possibly better ways, but this is how I would do it:

Code: Select all

#!/bin/sh

#set some variables ... just as examples of how to customise the GUI before it loads
export mytitle="My program name"
export version=0.1
export tab=1   #will load the 2nd tab, the 1st tab is zero
export button_label_1="Seamonkey Composer"
export button_label_2="Abiword"
export button_label_3="MtPaint"
export WIDTH=500

# create the GUI string ..

export MY_GUI_STRING='<window title="'$mytitle' '$version'" width-request="'$WIDTH'">
<vbox>
   <notebook labels="Document|Graphic" page="'$tab'">
      <frame>
         <text use-markup="true"><label>"<b>Document</b>"</label></text>
         <button>
            <label>'$button_label_1'</label>
            <input file>/usr/local/lib/X11/pixmaps/www24.png</input>
            <action>/usr/local/bin/defaulthtmleditor</action>
         </button>
         <button height-request="30" width-request="30">
            <label>'$button_label_2'</label>
            <input file>/usr/local/lib/X11/pixmaps/word24.png</input>
            <action>/usr/bin/abiword</action>
         </button>
      </frame>
      <frame>
         <text use-markup="true"><label>"<b>Graphic</b>"</label></text>
         <button>
            <label>'$button_label_3'</label>
            <input file>/usr/local/lib/X11/pixmaps/paint24.png</input>
            <action>/usr/bin/mtpaint</action>
         </button>
      </frame>
   </notebook>
   <hbox homogeneous="true">
   <button cancel></button>
   </hbox>
</vbox>
</window>'


#run gtkdialog, using the GUI string above

gtkdialog --program MY_GUI_STRING


#gui is now closed

exit 0
Image
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#12 Post by starhawk »

Yes, but that hard-codes the applications in... with no easy way to change them. I want 'dynamic' loading of the applications -- the same way that the PuppyMenu works -- something (be it the *.menu files or a set of custom shell scripts) polls the *.desktop files and updates the icons in the launcher.

Would be really nifty to have proper icons that can be double-clicked, but that will wait till later... ;)

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#13 Post by RSH »

Maybe these two examples will give any clue?

Remove the '.gz' extension and make executable.
Attachments
apps-in-Xdialog.gz
Remove the '.gz' extension
(1.87 KiB) Downloaded 212 times
apps-in-gtkdialog.gz
Remove the '.gz' extension
(4.15 KiB) Downloaded 223 times
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#14 Post by Bert »

Brilliant, RHS!
(as usual..)

Wouldn't the gtk menu widget be a better option for starhawk's goal than the notebook widget?
Just thinking out loud :wink:
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#15 Post by starhawk »

...except that I *want* the notebook widget. It has a tabbed interface which is what I'm looking for.

RSH, I'll look at your stuff later today... I'm looking forward to checking it out ;)

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#16 Post by starhawk »

OK, RSH, I looked at your script example for GtkDialog... interesting. I get most of how it works, and I think I can put together an app-gathering shell script based on it... I'll bang it out and post the script up for debugging (which I'm sure it'll need plenty of ;) ).

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#17 Post by starhawk »

OK, prototype script attached... let me know what I did wrong :P
Attachments
launcher-refresh.sh.gz
fake *.gz -- remove extension; do not use gunzip...
(7.34 KiB) Downloaded 183 times

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#18 Post by starhawk »

RSH, have you had a chance to look at my script?

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

Program Launcher

#19 Post by seaside »

starhawk,

Technosaurus made a quick parsing utility for Desktop files which I've modified and added an icon finder that you may wish to use. The rest of the program categories could be added for each notebook.

Code: Select all

#!/bin/sh
# Program Launcher

iconfind() {
[ -f /usr/local/lib/X11/mini-icons/$ICON ] && ICON=/usr/local/lib/X11/mini-icons/$ICON 
[ -f /usr/local/lib/X11/pixmaps/$ICON ] && ICON=usr/local/lib/X11/pixmaps/$ICON 
[ -f /usr/share/pixmaps/$ICON ] && ICON=/usr/share/pixmaps/$ICON 
[ -f /usr/local/share/pixmaps/$ICON ] && ICON=/usr/local/share/pixmaps/$ICON 
#ICON=`find /usr -name "$ICON"  -print -quit` 
echo $ICON #exit
}
export -f iconfind


for DESKTOP_FILE in /usr/share/applications/*.desktop ; do
	ICON="" CATS="" NAME="" EXEC="" LINE="" #prevent carryover from previous file
	while read LINE || [ "$LINE" ]; do
		case $LINE in
			Name=*) NAME="${LINE#*=}"'' ;; 
			Icon=*) ICON="${LINE#*=}"'' 
			 [[ ! "$ICON" == */* ]]  &&  iconfind ;;
			Categories=*) CATS="${LINE#*=}"'' ;;
			Exec=*) EXEC="${LINE#*=}"'' ;;
		esac
	done < $DESKTOP_FILE
	
		case "$CATS" in
			FileManager|X-FilesystemMount|X-FilesystemFind|X-FilesystemUtility)	APPLIST_FILESYSTEM="$APPLIST_FILESYSTEM<button><label>$NAME</label><input file>$ICON</input><action>$EXEC</action></button>" ;;
			X-Graphic-paint|RasterGraphics|X-Graphic-draw|VectorGraphics|X-Graphic-flow|Chart|Flowchart|Presentation|X-Graphic-viewer|X-Graphic-camera|Photography|X-Graphic-scanner|Scanning|OCR|X-Graphic-print|X-Graphic-utility|X-GraphicUtility) APPLIST_GRAPHICS="$APPLIST_GRAPHICS<button><label>$NAME</label><input file>$ICON</input><action>$EXEC</action></button>" ;;
		esac
	
done


export LAUNCHER='
<window title="Program Launcher">
<vbox>
   <notebook labels="Filesystem|Graphic">
      <frame>
      <text use-markup="true"><label>"<b>Filesystem</b>"</label></text>
      '"$APPLIST_FILESYSTEM"'
      </frame>
      <frame>
       <text use-markup="true"><label>"<b>Graphic</b>"</label></text>
      '"$APPLIST_GRAPHICS"'
      </frame>
   </notebook>
   <hbox homogeneous="true">
   <button cancel></button>
   </hbox>
</vbox>
</window>'
gtkdialog -p LAUNCHER 
Probably needs work to get the icons lined up nicely.

Cheers,
s

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#20 Post by starhawk »

seaside, that's interesting -- I like the Icon Finder part -- but I'm afraid I don't think it'll work for me. I want the GtkNotebook to update whenever someone runs a "fixmenus" style script -- such as the one attached to my last post. The script you posted doesn't allow for that :(

Can someone PLEASE look at my script and tell me if there are any bugs?

Post Reply