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
333  int width,
334  int height );
335 
347 void
349  int offset);
350 
358 void
360  struct timeval *tv );
361 
367 void
369 
377 void
379  unsigned char *msg,
380  int timeout);
381 
388 void
390  unsigned char *name);
391 
398 void
400  unsigned char *info);
401 
409 void
411  MBPixbuf *pixbuf,
412  MBPixbufImage *image);
413 
422 void
424  Bool val );
425 
432 Bool
434 
443 Bool
445  int *x,
446  int *y );
447 
454 void
456  void *data );
457 
464 void*
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
499 
507 void
508 mb_tray_app_set_xevent_mask (MBTrayApp *mb_tray_app, long mask);
509 
510 
517 Display*
519 
526 int
528 
535 Window
537 
544 Window
546 
553 int
555 
562 int
564 
571 int
572 mb_tray_app_offset ( MBTrayApp *mb_tray_app ) ;
573 
581 void
583 
589 void
591 
597 void
598 mb_tray_app_hide (MBTrayApp *mb_tray_app );
599 
605 void
607 
608 
614 void
616 
623 void
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
mb_tray_app_set_context_info
void mb_tray_app_set_context_info(MBTrayApp *mb_tray_app, unsigned char *info)
Sets text for extra button in window message.
mb_tray_app_get_session
Bool mb_tray_app_get_session(MBTrayApp *mb_tray_app)
Get session state.
mb_tray_app_set_context_callback
void mb_tray_app_set_context_callback(MBTrayApp *mb_tray_app, MBTrayAppContextCB context_cb)
Sets the 'context' callback.
mb_tray_app_set_paint_callback
void mb_tray_app_set_paint_callback(MBTrayApp *mb_tray_app, MBTrayAppPaintCB paint_cb)
Sets the callback function for panel app paint.
mb_tray_app_set_resize_callback
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.
mb_tray_app_new
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.
mb_tray_app_repaint
void mb_tray_app_repaint(MBTrayApp *mb_tray_app)
Requests the app is repainted - the paint callback will get called.
mb_tray_app_xdisplay
Display * mb_tray_app_xdisplay(MBTrayApp *mb_tray_app)
Gets the tray apps X display.
MBPixbufImage
struct MBPixbufImage MBPixbufImage
Type for representing an mbpixbuf image.
mb_tray_app_set_poll_timeout
void mb_tray_app_set_poll_timeout(MBTrayApp *mb_tray_app, struct timeval *tv)
Set timing for any timeout callbacks.
mb_tray_app_set_icon
void mb_tray_app_set_icon(MBTrayApp *mb_tray_app, MBPixbuf *pixbuf, MBPixbufImage *image)
Sets the tray app icon.
mb_tray_app_xscreen
int mb_tray_app_xscreen(MBTrayApp *mb_tray_app)
Gets the tray app X screen.
mb_tray_app_set_user_data
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.
MBTrayAppThemeChangeCB
void(* MBTrayAppThemeChangeCB)(MBTrayApp *mb_tray_app, char *theme_name)
Callback for a theme change.
Definition: mbtray.h:175
MBTrayAppButtonEventCB
void(* MBTrayAppButtonEventCB)(MBTrayApp *mb_tray_app, int x, int y, Bool is_release)
Callback for a button event.
Definition: mbtray.h:157
mb_tray_app_new_with_display
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.
mb_tray_app_request_size
void mb_tray_app_request_size(MBTrayApp *mb_tray_app, int width, int height)
Requests a new size for the application.
mb_tray_app_set_session
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.
mb_tray_app_get_xevent_mask
long mb_tray_app_get_xevent_mask(MBTrayApp *mb_tray_app)
Returns the current X Event mask used by the tray app.
mb_tray_app_width
int mb_tray_app_width(MBTrayApp *mb_tray_app)
Gets the tray width.
MBTrayAppPaintCB
void(* MBTrayAppPaintCB)(MBTrayApp *mb, Drawable drawable)
Callback for a handling a 'paint' or expose event.
Definition: mbtray.h:139
mb_tray_app_xwin
Window mb_tray_app_xwin(MBTrayApp *mb_tray_app)
Gets the tray app window.
mb_tray_app_get_user_data
void * mb_tray_app_get_user_data(MBTrayApp *mb_tray_app)
Gets any user data to be attached to the tray app instance.
mb_tray_app_set_button_callback
void mb_tray_app_set_button_callback(MBTrayApp *mb_tray_app, MBTrayAppButtonEventCB button_cb)
Sets the callback function for a mouse button press/release.
mb_tray_app_unhide
void mb_tray_app_unhide(MBTrayApp *mb_tray_app)
Unhides ( redocks ) the tray app.
mb_tray_app_main_init
void mb_tray_app_main_init(MBTrayApp *mb_tray_app)
Inits the main loop.
MBTrayAppPollCB
void(* MBTrayAppPollCB)(MBTrayApp *mb_tray_app)
Callback for a Timeout event.
Definition: mbtray.h:182
mb_tray_app_set_theme_change_callback
void mb_tray_app_set_theme_change_callback(MBTrayApp *mb_tray_app, MBTrayAppThemeChangeCB theme_cb)
Sets the callback function for a theme change.
mb_tray_app_offset
int mb_tray_app_offset(MBTrayApp *mb_tray_app)
Gets the apps offset from the panels origin
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.
MBTrayAppXEventCB
void(* MBTrayAppXEventCB)(MBTrayApp *mb_tray_app, XEvent *event)
Callback for an X event.
Definition: mbtray.h:168
mb_tray_app_set_timeout_callback
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.
mb_tray_app_get_background
MBPixbufImage * mb_tray_app_get_background(MBTrayApp *mb_tray_app, MBPixbuf *pixbuf)
Gets the panel background for the area covered by the tray app.
MBPixbuf
struct MBPixbuf MBPixbuf
Opaque structure used for all operations.
mb_tray_app_set_name
void mb_tray_app_set_name(MBTrayApp *mb_tray_app, unsigned char *name)
Sets the tray app name.
mb_tray_app_hide
void mb_tray_app_hide(MBTrayApp *mb_tray_app)
Hides ( undocks ) the tray app.
mb_tray_app_xrootwin
Window mb_tray_app_xrootwin(MBTrayApp *mb_tray_app)
Gets the tray app root window.
mb_tray_app_request_offset
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.
mb_tray_app_set_xevent_mask
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.
MBTrayAppResizeCB
void(* MBTrayAppResizeCB)(MBTrayApp *mb, int width, int height)
Callback for a resize.
Definition: mbtray.h:125
mb_tray_handle_xevent
void mb_tray_handle_xevent(MBTrayApp *mb_tray_app, XEvent *xevent)
Runs a single iteration of the mainloop.
mb_tray_app_height
int mb_tray_app_height(MBTrayApp *mb_tray_app)
Gets the tray height.
mb_tray_app_get_theme_name
char * mb_tray_app_get_theme_name(MBTrayApp *mb_tray_app)
Returns the current theme.
mb_tray_app_tray_send_message
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.
mb_tray_app_set_xevent_callback
void mb_tray_app_set_xevent_callback(MBTrayApp *mb_tray_app, MBTrayAppXEventCB xevent_cb)
Sets the callback function for any extra x event processing.
MBTrayApp
struct MBTrayApp MBTrayApp
Opaque structure used for representing a tray app.
Definition: mbtray.h:114
mb_tray_app_get_absolute_coords
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.
mb_tray_app_main_quit
void mb_tray_app_main_quit(MBTrayApp *mb_tray_app)
Stops mb_tray_app_main.