site: end of line message, adesklets is not dead.
[adesklets.git] / src / adesklets.h
blobaa68fdbe4b4e3d9861fad62b2cccf0980736f2e4
1 /*--- adesklets.h --------------------------------------------------------------
2 Copyright (C) 2004, 2005, 2006 Sylvain Fourmanoit <syfou@users.sourceforge.net>
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to
6 deal in the Software without restriction, including without limitation the
7 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 sell copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies of the Software and its documentation and acknowledgment shall be
13 given in the documentation and software packages that this Software was
14 used.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 ------------------------------------------------------------------------------*/
23 #ifndef HAVE_ADESKLETS_H
24 #define HAVE_ADESKLETS_H
26 #ifndef HAVE_CONFIG_H
27 #error Autogenerated config.h should be used.
28 #endif
30 /*----------------------------------------------------------------------------*/
31 #include "config.h" /* Autoconf */
33 #include "command.h" /* ID related includes */
34 #include "event.h"
36 #include "xwindow.h" /* All graphics-related includes */
38 #ifdef HAVE_SYS_TYPES_H /* stat() */
39 #include <sys/types.h>
40 #endif
42 #ifdef HAVE_SYS_STAT_H
43 #include <sys/stat.h>
44 #endif
46 #ifdef HAVE_UNISTD_H /* Fork(), exec*(), isatty(), */
47 #include <unistd.h> /* getppid() and other system calls */
48 #endif
50 #ifdef HAVE_SIGNAL_H /* kill() */
51 #include <signal.h>
52 #endif
54 #ifdef HAVE_TIME_H
55 #include <time.h>
56 #endif
58 #ifdef HAVE_LIBGEN_H /* basename() */
59 #include <libgen.h>
60 #endif
62 #ifdef HAVE_STRING_H /* strncpy(), strlen(), etc */
63 #include <string.h>
64 #endif
66 #ifdef HAVE_STDARG_H /* va_start(), va_arg(), etc */
67 #include <stdarg.h>
68 #endif
70 #ifdef HAVE_MATH_H /* lrint(), lrintf(), round() */
71 #include <math.h>
72 #endif
74 #include "types.h" /* Various typedef */
75 #include "error.h" /* Error wrapper */
76 #include "vector.h" /* Small vector API */
77 #include "vector_free.h" /* Vector free functions */
78 #include "tree.h" /* Small tree API */
80 #include "xmenu.h" /* X Windows menu API */
82 #include "cfgfile.h" /* Configuration file management */
83 #include "variable.h" /* Textual variable functions */
85 /*----------------------------------------------------------------------------*/
86 #define MENU(i) ((xmenu*)adesklets.menus->content[i])
88 /*----------------------------------------------------------------------------*/
89 typedef struct s_adesklets {
90 pid_t ppid; /* Parent process ID */
91 Display * display; /* Display handle */
92 Visual * visual; /* Visual handle */
93 Window root; /* Root window */
94 Window window; /* Window ID */
95 int depth; /* Visual depth */
96 int polling; /* Polling period in microseconds */
97 int transparency; /* Set up auto transparency */
98 int background_grab; /* Set up auto background grab */
99 int user_background_image;/* Set up user background image */
100 int managed; /* Set up managed/unmanaged status */
101 long event_mask; /* Main window event mask */
102 long user_event_mask; /* Mask of events sent back to user */
103 cfgfile_item * params; /* Configuration information:
104 id, screen,x,y */
105 vector * menus; /* Vector of menus ref. */
106 vector * images; /* Vector of Imlib_Images ref. */
107 vector * fonts; /* Vector of Imlib_Font ref. */
108 vector * color_ranges; /* Vector of Imlib_Color_Range ref. */
109 vector * color_modifiers; /* Vector of Imlib_Color_Modifier */
110 vector * filters; /* Vector of Imlib_Filter */
111 vector * polygons; /* Vector of ImlibPolygon ref. */
112 vector * variables; /* Vector of var_item ref. */
113 char
114 lock_filename[CFGFILE_NAME_SIZE]; /* File name of the lock */
115 FILE * lock; /* Lock file */
116 int quit_flag; /* Signal urge to quit */
117 int restart_flag; /* Signal urge to restart */
118 int user_quit_flag; /* Signal quit was triggered
119 by the user */
120 } t_adesklets;
122 /*----------------------------------------------------------------------------*/
123 extern t_adesklets adesklets;
125 /*----------------------------------------------------------------------------*/
126 /* Global interpreter initialisation: display, window, fonts
128 int adesklets_init(int,char**);
130 /*----------------------------------------------------------------------------*/
131 /* Event loop for the main window.
132 NOTE: this function is espected to be run if an only if adesklets_init()
133 has been successful.
135 void adesklets_events_loop(void);
137 /*----------------------------------------------------------------------------*/
138 /* Global interpreter cleanup: display, lock file, window, fonts
139 The restart flag passed to this function makes adesklets
140 send a SIG_KILL to parent process if applicable (presence
141 of a lock file).
143 int adesklets_free(void);
145 /*----------------------------------------------------------------------------*/
146 /* Test if a given filename is referring to an existing,
147 executable file for current user; if integer flag is given,
148 also verify that filename is absolute.
149 Returns 1 on success, 0 on failure.
151 Warning: This function requires the file to be r+x for adesklets:
152 this is a simple way to avoid executable but unreadable scripts.
154 int adesklets_valid_desklet(char*,int);
156 /*----------------------------------------------------------------------------*/
157 #endif