LibMB  1.9
mbtray.h
1 /* libmb
2  * Copyright (C) 2002 Matthew Allum
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _MB_TRAY_H_
21 #define _MB_TRAY_H_
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <sys/types.h>
26 #include <unistd.h>
27 #include <X11/Xlib.h>
28 #include <X11/Xutil.h>
29 #include <X11/Xatom.h>
30 #include <X11/Xmd.h>
31 
32 #include "libmb/mb.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
114 typedef struct MBTrayApp MBTrayApp;
115 
116 /* TOGO ? */
117 typedef void (*MBTrayBackgroundCB)( void *user_data ) ;
118 
125 typedef void (*MBTrayAppResizeCB)( MBTrayApp *mb, int width, int height ) ;
126 
139 typedef void (*MBTrayAppPaintCB)( MBTrayApp *mb, Drawable drawable ) ;
140 
150 typedef void (*MBTrayAppContextCB)( MBTrayApp *mb ) ;
151 
157 typedef void (*MBTrayAppButtonEventCB)( MBTrayApp *mb_tray_app,
158  int x,
159  int y,
160  Bool is_release ) ;
161 
168 typedef void (*MBTrayAppXEventCB)( MBTrayApp *mb_tray_app, XEvent *event ) ;
169 
175 typedef void (*MBTrayAppThemeChangeCB)( MBTrayApp *mb_tray_app, char *theme_name ) ;
176 
182 typedef void (*MBTrayAppPollCB)( MBTrayApp *mb_tray_app) ;
183 
184 
216 MBTrayApp*
217 mb_tray_app_new (unsigned char *app_name,
218  MBTrayAppResizeCB resize_cb,
219  MBTrayAppPaintCB paint_cb,
220  int *argc,
221  char ***argv);
222 
238 MBTrayApp*
239 mb_tray_app_new_with_display ( unsigned char *app_name,
240  MBTrayAppResizeCB resize_cb,
241  MBTrayAppPaintCB paint_cb,
242  int *argc,
243  char ***argv,
244  Display *display);
245 
253 void
255  MBTrayAppXEventCB xevent_cb );
256 
263 void
265  MBTrayAppButtonEventCB button_cb );
266 
273 void
275  MBTrayAppThemeChangeCB theme_cb );
276 
284 void
286  MBTrayAppPollCB poll_cb,
287  struct timeval *tv);
288 
295 void
297  MBTrayAppResizeCB resize_cb );
298 
305 void
307  MBTrayAppPaintCB paint_cb );
308 
315 void
317  MBTrayAppContextCB context_cb );
318 
331 void
332 mb_tray_app_request_size (MBTrayApp *mb_tray_app,
333  int width,
334  int height );
335 
347 void
349  int offset);
350 
358 void
360  struct timeval *tv );
361 
367 void
368 mb_tray_app_repaint (MBTrayApp *mb_tray_app);
369 
377 void
379  unsigned char *msg,
380  int timeout);
381 
388 void
389 mb_tray_app_set_name (MBTrayApp *mb_tray_app,
390  unsigned char *name);
391 
398 void
400  unsigned char *info);
401 
409 void
410 mb_tray_app_set_icon(MBTrayApp *mb_tray_app,
411  MBPixbuf *pixbuf,
412  MBPixbufImage *image);
413 
422 void
423 mb_tray_app_set_session ( MBTrayApp *mb_tray_app,
424  Bool val );
425 
432 Bool
433 mb_tray_app_get_session ( MBTrayApp *mb_tray_app );
434 
443 Bool
445  int *x,
446  int *y );
447 
454 void
455 mb_tray_app_set_user_data (MBTrayApp *mb_tray_app,
456  void *data );
457 
464 void*
465 mb_tray_app_get_user_data (MBTrayApp *mb_tray_app);
466 
467 
468 Bool
469 mb_tray_app_tray_is_vertical (MBTrayApp *mb_tray_app );
470 
480  MBPixbuf *pixbuf);
481 
488 char *
490 
497 long
498 mb_tray_app_get_xevent_mask (MBTrayApp *mb_tray_app );
499 
507 void
508 mb_tray_app_set_xevent_mask (MBTrayApp *mb_tray_app, long mask);
509 
510 
517 Display*
518 mb_tray_app_xdisplay (MBTrayApp *mb_tray_app);
519 
526 int
527 mb_tray_app_xscreen (MBTrayApp *mb_tray_app);
528 
535 Window
536 mb_tray_app_xrootwin(MBTrayApp *mb_tray_app);
537 
544 Window
545 mb_tray_app_xwin (MBTrayApp *mb_tray_app);
546 
553 int
554 mb_tray_app_width (MBTrayApp *mb_tray_app);
555 
562 int
563 mb_tray_app_height (MBTrayApp *mb_tray_app);
564 
571 int
572 mb_tray_app_offset ( MBTrayApp *mb_tray_app ) ;
573 
581 void
582 mb_tray_app_main_init ( MBTrayApp *mb_tray_app );
583 
589 void
590 mb_tray_app_main (MBTrayApp *mb_tray_app);
591 
597 void
598 mb_tray_app_hide (MBTrayApp *mb_tray_app );
599 
605 void
606 mb_tray_app_unhide (MBTrayApp *mb_tray_app );
607 
608 
614 void
615 mb_tray_app_main_quit (MBTrayApp *mb_tray_app);
616 
623 void
624 mb_tray_handle_xevent (MBTrayApp *mb_tray_app,
625  XEvent *xevent);
626 
627 
628 
629 /* ---------- Older stuff below ----------------------------------------- */
630 
631 
632 int mb_tray_init(Display* dpy, Window win);
633 
634 Window mb_tray_get_window(void);
635 
636 void mb_tray_init_session_info(Display *d, Window win, char **argv, int argc);
637 
638 void mb_tray_handle_event(Display *dpy, Window win, XEvent *an_event);
639 
640 void mb_tray_send_message(Display *d, Window win,
641  unsigned char* msg, int timeout);
642 
643 void mb_tray_map_window (Display* dpy, Window win);
644 
645 void
646 mb_tray_bg_change_cb_set(MBTrayBackgroundCB bg_changed_cb, void *user_data);
647 
648 Bool mb_tray_get_bg_col(Display *dpy, XColor *xcol);
649 
650 void
651 mb_tray_window_icon_set(Display *dpy, Window win_panel, MBPixbufImage *img);
652 
653 void mb_tray_unmap_window (Display* dpy, Window win);
654 
655 MBPixbufImage *mb_tray_get_bg_img(MBPixbuf *pb, Window win);
656 
659 #ifdef __cplusplus
660 }
661 #endif
662 
663 #endif
Window mb_tray_app_xrootwin(MBTrayApp *mb_tray_app)
Gets the tray app root window.
void mb_tray_app_tray_send_message(MBTrayApp *mb_tray_app, unsigned char *msg, int timeout)
Sends a messsage to the tray, used to visually inform or notify the user.
struct MBPixbufImage MBPixbufImage
Type for representing an mbpixbuf image.
void mb_tray_app_hide(MBTrayApp *mb_tray_app)
Hides ( undocks ) the tray app.
void mb_tray_app_set_button_callback(MBTrayApp *mb_tray_app, MBTrayAppButtonEventCB button_cb)
Sets the callback function for a mouse button press/release.
void mb_tray_app_set_theme_change_callback(MBTrayApp *mb_tray_app, MBTrayAppThemeChangeCB theme_cb)
Sets the callback function for a theme change.
void(* MBTrayAppPollCB)(MBTrayApp *mb_tray_app)
Callback for a Timeout event.
Definition: mbtray.h:182
void mb_tray_app_set_user_data(MBTrayApp *mb_tray_app, void *data)
Set any user data to be attached to the tray app instance.
void(* MBTrayAppPaintCB)(MBTrayApp *mb, Drawable drawable)
Callback for a handling a 'paint' or expose event.
Definition: mbtray.h:139
void(* MBTrayAppXEventCB)(MBTrayApp *mb_tray_app, XEvent *event)
Callback for an X event.
Definition: mbtray.h:168
long mb_tray_app_get_xevent_mask(MBTrayApp *mb_tray_app)
Returns the current X Event mask used by the tray app.
Display * mb_tray_app_xdisplay(MBTrayApp *mb_tray_app)
Gets the tray apps X display.
int mb_tray_app_width(MBTrayApp *mb_tray_app)
Gets the tray width.
void mb_tray_app_main_quit(MBTrayApp *mb_tray_app)
Stops mb_tray_app_main.
void mb_tray_app_main(MBTrayApp *mb_tray_app)
Runs the tray app main loop until mb_tray_app_main_quit is called.
void mb_tray_app_set_name(MBTrayApp *mb_tray_app, unsigned char *name)
Sets the tray app name.
MBPixbufImage * mb_tray_app_get_background(MBTrayApp *mb_tray_app, MBPixbuf *pixbuf)
Gets the panel background for the area covered by the tray app.
Bool mb_tray_app_get_absolute_coords(MBTrayApp *mb_tray_app, int *x, int *y)
Gets the tray app co-ordinates relative to the root window.
void mb_tray_app_set_poll_timeout(MBTrayApp *mb_tray_app, struct timeval *tv)
Set timing for any timeout callbacks.
void mb_tray_app_set_context_callback(MBTrayApp *mb_tray_app, MBTrayAppContextCB context_cb)
Sets the 'context' callback.
void mb_tray_app_set_session(MBTrayApp *mb_tray_app, Bool val)
Enable app to show session data so tray can 'remember it' for future sessions.
void mb_tray_app_set_xevent_mask(MBTrayApp *mb_tray_app, long mask)
Safely sets the X Event mask used to select what events the xevent callback recieves.
void mb_tray_app_main_init(MBTrayApp *mb_tray_app)
Inits the main loop.
void mb_tray_app_set_resize_callback(MBTrayApp *mb_tray_app, MBTrayAppResizeCB resize_cb)
Sets the callback function to be notifed when the panel app is resized.
Bool mb_tray_app_get_session(MBTrayApp *mb_tray_app)
Get session state.
void(* MBTrayAppResizeCB)(MBTrayApp *mb, int width, int height)
Callback for a resize.
Definition: mbtray.h:125
MBTrayApp * mb_tray_app_new(unsigned char *app_name, MBTrayAppResizeCB resize_cb, MBTrayAppPaintCB paint_cb, int *argc, char ***argv)
Constructs a new tray app instance.
void(* MBTrayAppButtonEventCB)(MBTrayApp *mb_tray_app, int x, int y, Bool is_release)
Callback for a button event.
Definition: mbtray.h:157
void mb_tray_app_set_xevent_callback(MBTrayApp *mb_tray_app, MBTrayAppXEventCB xevent_cb)
Sets the callback function for any extra x event processing.
void mb_tray_app_set_context_info(MBTrayApp *mb_tray_app, unsigned char *info)
Sets text for extra button in window message.
int mb_tray_app_height(MBTrayApp *mb_tray_app)
Gets the tray height.
void mb_tray_handle_xevent(MBTrayApp *mb_tray_app, XEvent *xevent)
Runs a single iteration of the mainloop.
int mb_tray_app_xscreen(MBTrayApp *mb_tray_app)
Gets the tray app X screen.
struct MBTrayApp MBTrayApp
Opaque structure used for representing a tray app.
Definition: mbtray.h:114
struct MBPixbuf MBPixbuf
Opaque structure used for all operations.
void(* MBTrayAppThemeChangeCB)(MBTrayApp *mb_tray_app, char *theme_name)
Callback for a theme change.
Definition: mbtray.h:175
void mb_tray_app_set_icon(MBTrayApp *mb_tray_app, MBPixbuf *pixbuf, MBPixbufImage *image)
Sets the tray app icon.
void mb_tray_app_set_timeout_callback(MBTrayApp *mb_tray_app, MBTrayAppPollCB poll_cb, struct timeval *tv)
Sets the callback function for a theme change.
char * mb_tray_app_get_theme_name(MBTrayApp *mb_tray_app)
Returns the current theme.
void mb_tray_app_unhide(MBTrayApp *mb_tray_app)
Unhides ( redocks ) the tray app.
void mb_tray_app_repaint(MBTrayApp *mb_tray_app)
Requests the app is repainted - the paint callback will get called.
MBTrayApp * mb_tray_app_new_with_display(unsigned char *app_name, MBTrayAppResizeCB resize_cb, MBTrayAppPaintCB paint_cb, int *argc, char ***argv, Display *display)
Constructs a new tray app instance.
void mb_tray_app_request_offset(MBTrayApp *mb_tray_app, int offset)
Requests the app positional offset in terms of the panels orientation from the origin of the tray...
void mb_tray_app_request_size(MBTrayApp *mb_tray_app, int width, int height)
Requests a new size for the application.
void mb_tray_app_set_paint_callback(MBTrayApp *mb_tray_app, MBTrayAppPaintCB paint_cb)
Sets the callback function for panel app paint.
int mb_tray_app_offset(MBTrayApp *mb_tray_app)
Gets the apps offset from the panels origin.
void * mb_tray_app_get_user_data(MBTrayApp *mb_tray_app)
Gets any user data to be attached to the tray app instance.
Window mb_tray_app_xwin(MBTrayApp *mb_tray_app)
Gets the tray app window.