3 * This file is part of LCDd, the lcdproc server.
5 * This file is released under the GNU General Public License. Refer to the
6 * COPYING file distributed with this package.
8 * Copyright (c) 1999, William Ferrell, Scott Scriven
12 * Does screen management
20 #include "shared/report.h"
26 #include "screenlist.h"
28 #include "menuscreens.h"
32 int default_duration
= 0;
33 int default_timeout
= -1;
46 screen_create(char *id
, Client
*client
)
50 debug(RPT_DEBUG
, "%s(id=\"%.40s\", client=[%d])", __FUNCTION__
, id
, (client
?client
->sock
:-1));
52 s
= malloc(sizeof(Screen
));
54 report(RPT_ERR
, "%s: Error allocating", __FUNCTION__
);
58 report(RPT_ERR
, "%s: Need id string", __FUNCTION__
);
61 /* Client can be NULL for serverscreens and other client-less screens */
65 report(RPT_ERR
, "%s: Error allocating", __FUNCTION__
);
70 s
->priority
= PRI_INFO
;
71 s
->duration
= default_duration
;
72 s
->backlight
= BACKLIGHT_OPEN
;
73 s
->heartbeat
= HEARTBEAT_OPEN
;
74 s
->width
= display_props
->width
;
75 s
->height
= display_props
->height
;
79 s
->timeout
= default_timeout
; /*ignored unless greater than 0.*/
80 s
->backlight
= BACKLIGHT_OPEN
; /*Lets the screen do it's own*/
81 /*or do what the client says.*/
82 s
->cursor
= CURSOR_OFF
;
86 s
->widgetlist
= LL_new();
88 report(RPT_ERR
, "%s: Error allocating", __FUNCTION__
);
92 menuscreen_add_screen(s
);
98 screen_destroy(Screen
*s
)
102 debug(RPT_DEBUG
, "%s(s=[%.40s])", __FUNCTION__
, s
->id
);
104 menuscreen_remove_screen(s
);
106 screenlist_remove(s
);
108 for (w
= LL_GetFirst(s
->widgetlist
); w
; w
= LL_GetNext(s
->widgetlist
)) {
109 /* Free a widget...*/
112 LL_Destroy(s
->widgetlist
);
125 screen_add_widget(Screen
*s
, Widget
*w
)
127 debug(RPT_DEBUG
, "%s(s=[%.40s], widget=[%.40s])", __FUNCTION__
, s
->id
, w
->id
);
129 LL_Push(s
->widgetlist
, (void *) w
);
135 screen_remove_widget(Screen
*s
, Widget
*w
)
137 debug(RPT_DEBUG
, "%s(s=[%.40s], widget=[%.40s])", __FUNCTION__
, s
->id
, w
->id
);
139 LL_Remove(s
->widgetlist
, (void *) w
);
145 screen_find_widget(Screen
*s
, char *id
)
154 debug(RPT_DEBUG
, "%s(s=[%.40s], id=\"%.40s\")", __FUNCTION__
, s
->id
, id
);
156 for (w
= LL_GetFirst(s
->widgetlist
); w
; w
= LL_GetNext(s
->widgetlist
)) {
157 if (0 == strcmp(w
->id
, id
)) {
158 debug(RPT_DEBUG
, "%s: Found %s", __FUNCTION__
, id
);
161 /* Search subscreens recursively */
162 if (w
->type
== WID_FRAME
) {
163 w
= widget_search_subs(w
, id
);
168 debug(RPT_DEBUG
, "%s: Not found", __FUNCTION__
);
173 screen_pri_name_to_pri(char *priname
)
175 Priority pri
= WID_NONE
;
178 for (i
= 0; pri_names
[i
]; i
++) {
179 if (strcmp(pri_names
[i
], priname
) == 0) {
181 break; /* it's valid: skip out...*/
188 screen_pri_to_pri_name(Priority pri
)
190 return pri_names
[pri
];