simple icon tray

Window managers, icon programs, widgets, etc.
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#151 Post by musher0 »

technosaurus wrote:(...)
FWIW GTK devs do this a lot (add extra code that reduces functionality)
... another example of such is GtkIconView. It could make a perfect desktop icon replacement in ~10 lines except that they added code to the widget itself that makes the background solid white... you can only change the color, not add a background image.
A bureaucratic process has to be involved; otherwise the world be heading nowhere. :twisted: :wink:
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#152 Post by Argolance »

Bonsoir,
Thanks.
technosaurus wrote:FWIW GTK devs do this a lot (add extra code that reduces functionality)
Why? Very strange indeed!: It is a pity...
Only by completely rewriting an alternative statusicon widget.
Perhaps 'yad' could be used to make such a 'simple icon tray' and should offer more capabilities?
musher0 wrote:A bureaucratic process has to be involved; otherwise the world be heading nowhere
?? :roll:
It is already the case and this is why the world is "heading nowhere"!
(I'm probably missing something, but I don't really see the connection with the subject of this thread). :oops:

Cordialement.

User avatar
torios
Posts: 28
Joined: Fri 05 Dec 2014, 23:21

#153 Post by torios »

I like FLTK quite a bit, it keeps improving and making things easier, rather than removing functionality.
You can make very small programs easily with FLUID to design the UX.

Might be something for other posters here to consider.

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

#154 Post by technosaurus »

Argolance wrote:Perhaps 'yad' could be used to make such a 'simple icon tray' and should offer more capabilities?
Yad is also gtk based, so no.
torios wrote:I like FLTK quite a bit, it keeps improving and making things easier, rather than removing functionality.
You can make very small programs easily with FLUID to design the UX.

Might be something for other posters here to consider.
Fltk doesn't have a tray icon widget.

tcl/tk does
qt does

I did find an old X11 example here :

Code: Select all

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <stdio.h>

typedef enum systray_opcode_tag {
        SYSTEM_TRAY_REQUEST_DOCK   = 0,
        SYSTEM_TRAY_BEGIN_MESSAGE  = 1,
        SYSTEM_TRAY_CANCEL_MESSAGE = 2
} systray_opcode_t;

void send_message(
        Display *disp,
        Window dest,
        systray_opcode_t message,
        long data1,
        long data2,
        long data3)
{
        XEvent ev;

        memset( &ev, 0, sizeof(ev)) ;
        ev.xclient.type = ClientMessage ;
        ev.xclient.window = dest;
        ev.xclient.message_type = XInternAtom( disp, "_NET_SYSTEM_TRAY_OPCODE", False );
        ev.xclient.format = 32 ;
        ev.xclient.data.l[0] = CurrentTime ;
        ev.xclient.data.l[1] = message ;
        ev.xclient.data.l[2] = data1 ;
        ev.xclient.data.l[3] = data2 ;
        ev.xclient.data.l[4] = data3 ;
/* XXX handle error XXX */
        XSendEvent( disp, dest, False, NoEventMask, &ev) ;
        XSync( disp, False) ;
}


int main()
{
        Display  *disp ;
        Window  tray ;
        Window  icon ;
        Window  container = None ;
        GC  gc ;
        XEvent  ev ;
        int  icon_size = 22 ;

        disp = XOpenDisplay(NULL) ;

/* get system tray(as a embedder). */
/* XXX exec tray if it is nonexistent */
/* XXX assuming screen is 0 */
        tray = XGetSelectionOwner( disp,
                                  XInternAtom(disp, "_NET_SYSTEM_TRAY_S0", True) );
        printf("tray window = %p\n", tray) ;

/* create system tray icon window */
        icon = XCreateSimpleWindow( disp, DefaultRootWindow(disp),
                                    0,0, icon_size,icon_size, 0, 0xFF,0x0);
        printf("icon window = %p\n", icon) ;

/* select all of masks for debugging */
        XSelectInput( disp, icon, (OwnerGrabButtonMask << 1) -1 );

/* create GC */
        gc = XCreateGC( disp, icon, 0, NULL);
        XSetForeground( disp, gc, 0xFF) ;

/* set minimum size */
        {
                XSizeHints *hints;

                hints = XAllocSizeHints() ;
                hints->flags = PMinSize ;
                hints->min_width=icon_size;
                hints->min_height=icon_size;
                XSetWMNormalHints( disp, icon, hints);
                XFree( hints);
        }

/* set xembed infos */
        {
                Atom xa_xembed_info ;
                unsigned int buffer[2];

                xa_xembed_info = XInternAtom( disp, "_XEMBED_INFO", False) ;

                buffer[0]=0; /* ver 0 (0:0?) */
                buffer[1]=1; /* request mapping */
                XChangeProperty( disp, icon, xa_xembed_info,
                                 xa_xembed_info, 32, PropModeReplace,
                                 (unsigned char *)buffer, 2);
        }

/* request embedding */
        send_message( disp, tray, SYSTEM_TRAY_REQUEST_DOCK, icon,0,0);

        while(1){
                XNextEvent( disp, &ev);
                printf("type %d\n", ev.type);
                switch(ev.type)
                {
                case Expose:           /*12*/
                        XClearWindow( disp, icon);
                        XDrawLine( disp, icon, gc, 1,1, icon_size-1,icon_size-1) ;
                        printf("\texpose\n");
                        break;
                case VisibilityNotify: /*15*/
                        printf("\tvisible\n");
                        break;
                case MapNotify:        /*19*/
                        printf("\tmapped\n");
                        break;
                case ReparentNotify:    /*21*/
                        printf("\twindow %p\n", ev.xreparent.parent);
                        break;
                case ResizeRequest:    /*25*/
                        printf("\twidth %d\n", ev.xresizerequest.width);
                        printf("\theight %d\n", ev.xresizerequest.height);
                        if( ev.xresizerequest.width > ev.xresizerequest.height)
                                icon_size = ev.xresizerequest.height ;
                        else
                                icon_size = ev.xresizerequest.width ;
                        XResizeWindow( disp, icon, icon_size, icon_size);
                        if(container)
                                XResizeWindow( disp, container, icon_size, icon_size);
                        break;
                case PropertyNotify:    /*29*/
                        printf("\tatom %s\n", XGetAtomName( disp, ev.xproperty.atom));
                        break;
                case ClientMessage:    /*33*/
                        printf("\twindow %p\n", ev.xclient.window);
                        printf("\ttype %s\n", XGetAtomName( disp, ev.xclient.message_type));

                        printf("\ttime 0x%X\n", ev.xclient.data.l[0]);
                        printf("\tmajor 0x%X\n", ev.xclient.data.l[1]);
                        printf("\tdetail 0x%X\n", ev.xclient.data.l[2]);
                        printf("\tdata1 0x%X\n", ev.xclient.data.l[3]);
                        printf("\tdata2 0x%X\n", ev.xclient.data.l[4]);
/* container window could be got from ReparentNotify */
                        if( ev.xclient.data.l[1] == 0)
                                container = ev.xclient.data.l[3] ;
                        break;
                default:
                        ;
                };
        }
}
It would be a good exercise to adapt this to xcb or netsurf framebuffer and possibly use stb_image and libtinysvg for the images.
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
torios
Posts: 28
Joined: Fri 05 Dec 2014, 23:21

#155 Post by torios »

Hi,
I simply meant that FLTK is great for making simple programs to use with sdesk. It is very easy to mockup a design and keep all the code in FLUID. This makes it very simple for others to adapt the UX for their own purposes, or change it.
I have taken to causing my programs to read the .jwmrc file to set colors.

sdesk does all the work to set the tray icon, so FLTK does not need to :)

Plus FLTK is not as crazy as GTK. It seems like more and more things change and become more complex (for no reason?) with each release.

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

#156 Post by technosaurus »

I'm thinking about adding support for apps similar to:
http://pipeglade.boundp.org

Any thoughts
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
torios
Posts: 28
Joined: Fri 05 Dec 2014, 23:21

#157 Post by torios »

that looks pretty interesting!
I'll have to look more into that, but it seems like a really useful program.

User avatar
torios
Posts: 28
Joined: Fri 05 Dec 2014, 23:21

#158 Post by torios »

technosaurus, I think it would be cool to modify the -t portion to allow checking for the icon theme icons, using:
gtk_icon_theme_load_icon ("icon_name")
it would be nice if this could be modified during runtime, as then things like a battery/wifi/wtc... could update the icon at will using a generic icon name that could be changed to fit the icon theme used.

So a few questions..
Is this possible in Puppy?

Would this be too hard to implement for you?

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

#159 Post by technosaurus »

It may be easier to just try that if the image file fails to load normally, just use the contents of the file as the name.

It already allows this to be changed at run time though, just touch the symlink or change it.
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].

tele1234567891
Posts: 13
Joined: Sat 15 Nov 2014, 20:53

#160 Post by tele1234567891 »

1. Is this last source code of sit ?
http://www.murga-linux.com/puppy/viewto ... 677#714677

2. Can you put 64 bit support to " build " file ?
For example:

Code: Select all

#!/bin/sh
#compile

if [ `getconf LONG_BIT` = "64" ]; then
	echo "ARCH: 64-bit"

	#compile
	gcc `pkg-config gtk+-x11-2.0 --cflags` -DGTK_NO_CHECK_CASTS -DG_DISABLE_CAST_CHECKS \
	sdesk.c -o sdesk `pkg-config gtk+-x11-2.0 --libs` && strip --strip-all -R .note -R .comment sdesk

else
	echo "ARCH: 32-bit"

	#compile
	gcc `pkg-config gtk+-x11-2.0 --cflags` -DGTK_NO_CHECK_CASTS -DG_DISABLE_CAST_CHECKS \
	-Os -fmerge-all-constants -mno-accumulate-outgoing-args -march=i486 -mtune=i686 \
	-Wl,-O2,--gc-sections,--as-needed,--sort-common,-s sdesk.c -o sdesk \
	-lgtk-x11-2.0 -lgdk-x11-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

	strip --strip-all -R .note -R .comment sdesk

fi
3. Can you put or move source code to first post ?
4. Can you add version to source code ?


Edit:
From X11 http://murga-linux.com/puppy/viewtopic. ... 027#828027

Code: Select all

$ ./buildsit
ARCH: 64-bit
sit.c: In function ‘send_message’:
sit.c:23:9: warning: incompatible implicit declaration of built-in function ‘memset’
         memset( &ev, 0, sizeof(ev)) ;
         ^
/usr/bin/ld: /tmp/cclQRUt1.o: undefined reference to symbol 'XSetForeground'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Edit:
sit-1.0.tar.gz from http://murga-linux.com/puppy/viewtopic.php?t=76431
I upgraded to sit-1.0-2.tele.tar.gz ( is in attachment )
- added own example with icon ( left click , right click icon tray )
- added support for 64bit in "build" script ( I get help for this on other forum )

But this have bugs:
- "right click" window sometimes is in at the top, bottom
- Working on Debian 8.8 ( Mate 64bit ) , but probably not working on Ubuntu ( I'm not sure )


Edit:
I tried rebuild sdesk to sdesk-1.0-3.tele ( file in attachment )
http://www.murga-linux.com/puppy/viewto ... 677#714677
- added 64bit support
- added test script

but
- I can run function only from file ( this is good )
- I don't know how working <status icon> , can you add example ?


Edited:
I added to sdesk-1.0-3.tele second example ( now it is sdesk-1.0-4.tele
How get sdesk pid to kill only first or second app ?
Attachments
sdesk-1.0-4.tele.tar.gz
(9.32 KiB) Downloaded 541 times
sit-1.0-2.tele.tar.gz
(6.63 KiB) Downloaded 567 times

sfs
Posts: 49
Joined: Sat 02 Nov 2013, 04:49
Location: Russia
Contact:

#161 Post by sfs »

x86_64 gtk3
Attachments
sit-8-2013-patched-gtk3.tar.gz
(8.98 KiB) Downloaded 476 times
sit-1.0-2.tele-gtk3.tar.gz
(6.78 KiB) Downloaded 473 times
sdesk-1.0-4.tele-gtk3.tar.gz
(9.36 KiB) Downloaded 482 times
[url=https://sourceforge.net/projects/puppyrusa/]PuppyRus-Arch[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#162 Post by musher0 »

Hello all.

"Tele", second post up, provided a 64 bit sdesk in his archive.

Here is a 32-bit version. Compiled on xenialPup-7.0.6 (ubuntu's glibc-2.23), using tele's
build script. For those Puppyists who have older machines and do not know how to compile.

You may have to redo the build if you are on a Puppy with a lesser C library.

Enjoy.

~~~~~~~~~~~~~~~~~~

If it may help some Puppyists understand how sdesk works, here is a one-liner that
I wrote using it, followed by sdesk's usage.

Code: Select all

#!/bin/bash
# BoussPart-sdesk.sh
#### set -xe
sdesk -t /root/.aewm/ae/boussole_4a-32x.jpg "Orientation" "/root/.aewm/ae/boussole2.sh" "/root/.aewm/ae/disques-musher0.sh" 2>/dev/null
# 1 ## 2 ###### 3 ######################## 4 ########## 5 ####################### 6 ############################# 7 #
# See explanation of the numbers below.
# set +xe
exit

############

1) the sdesk command 
2)  "-t" stands for "tray utility"
3) the filename of a png icon 
4) the label which will appear as "notification" when the mouse hovers over the icon
5) the 1st app or script, launched by clicking the main mouse button on the left
6) the 2nd app or script, launched by clicking the main mouse button on the right
7) optional, if you wish or need to send whatever warnings there may be to "null".
(Not all systems issue warnings and pseudo-warnings, but Ubuntu just loves 
printing them out.)

############

sdesk usage:
./sdesk [-i files] [-b] -t image tooltip left-action right-action ...
  -i           full path to file(s) with shell functions to include
                   by default it looks in /usr/share/sit/func*
  -b <file>    use image file as desktop background image
  -t           tray icon: must have the following parameters
  image        full path to image file
  tooltip      full path to tooltip file or a "quoted tooltip"
  left-action  action to run when left mouse button is clicked
  right-action action to run when right mouse button is clicked
############
~~~~~~~~~~~~~~~~~~

NOT sorry for being so verbose! Some of you advanced devs do NOT realize that you
are now at a high level of abstract thinking -- and how far removed you are now from
the average user's understanding of things.

How many times do we have to repeat the following:

"IF A DEV DOES NOT WRITE AN UNDERSTANDABLE DOC TO ACCOMPANY HIS /
HER UTILITY, IT IS AS IF (S)HE HAD NOT WRITTEN IT, BECAUSE NO ONE WILL
KNOW HOW TO USE IT." (Capitals intentional.)

Technosaurus' "sit" has been around over 5 years, and its derivatives. How many
people know of them or are using them?

It took me a full day figuring out how to use this sit / sdesk utility, and I am an
ADVANCED user. Will the average or newbie Puppyist be as persevering or as
patient?... I doubt it.

BFN
Attachments
sdesk32.zip
(3.99 KiB) Downloaded 362 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

bobc
Posts: 87
Joined: Wed 14 May 2014, 23:07

What distros come with simple tray icons?

#163 Post by bobc »

I'm looking for good examples of them being used.

What I would like to do would be to have tray icons for drives that are mounted to write to with color and/or text to tell me if they are getting too full.

Thanks...

User avatar
pp4mnklinux
Posts: 375
Joined: Fri 23 Aug 2013, 06:56

#164 Post by pp4mnklinux »

snayak wrote:Dear technosaurus,

I fought a whole day lot to get my CPU temperature on my desktop.
I had to tweak Pwidgets.

Srinivas Nayak

I solved it using CPUTEMP .-

http://www.murga-linux.com/puppy/viewtopic.php?t=98299
Distro: xenialpup64 7.5 XXL
Desktop Panel: JWM ~ FbBox 5.0

Post Reply