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 all actions on widgets
20 #include "shared/sockets.h"
21 #include "shared/report.h"
26 #include "drivers/lcd.h"
45 {ICON_BLOCK_FILLED
, "BLOCK_FILLED"},
46 {ICON_HEART_OPEN
, "HEART_OPEN"},
47 {ICON_HEART_FILLED
, "HEART_FILLED"},
48 {ICON_ARROW_UP
, "ARROW_UP"},
49 {ICON_ARROW_DOWN
, "ARROW_DOWN"},
50 {ICON_ARROW_LEFT
, "ARROW_LEFT"},
51 {ICON_ARROW_RIGHT
, "ARROW_RIGHT"},
52 {ICON_CHECKBOX_OFF
, "CHECKBOX_OFF"},
53 {ICON_CHECKBOX_ON
, "CHECKBOX_ON"},
54 {ICON_CHECKBOX_GRAY
, "CHECKBOX_GRAY"},
55 {ICON_SELECTOR_AT_LEFT
, "SELECTOR_AT_LEFT"},
56 {ICON_SELECTOR_AT_RIGHT
, "SELECTOR_AT_RIGHT"},
57 {ICON_ELLIPSIS
, "ELLIPSIS"},
59 {ICON_PAUSE
, "PAUSE"},
61 {ICON_PLAYR
, "PLAYR"},
72 widget_create(char *id
, WidgetType type
, Screen
*screen
)
76 debug(RPT_DEBUG
, "%s(id=\"%s\", type=%d, screen=[%s])", __FUNCTION__
, id
, type
, screen
->id
);
79 w
= malloc(sizeof(Widget
));
81 report(RPT_DEBUG
, "%s: Error allocating", __FUNCTION__
);
87 report(RPT_DEBUG
, "%s: Error allocating", __FUNCTION__
);
106 if (w
->type
== WID_FRAME
) {
107 /* create a screen for the frame widget */
109 frame_name
= malloc(strlen("frame_") + strlen(id
) + 1);
110 strcpy(frame_name
, "frame_");
111 strcat(frame_name
, id
);
113 w
->frame_screen
= screen_create(frame_name
, screen
->client
);
115 free(frame_name
); /* not needed anymore */
121 widget_destroy(Widget
*w
)
123 debug(RPT_DEBUG
, "%s(w=[%s])", __FUNCTION__
, w
->id
);
133 /* Free subscreen of frame widget too */
134 if (w
->type
== WID_FRAME
) {
135 screen_destroy(w
->frame_screen
);
144 widget_typename_to_type(char *typename
)
146 WidgetType wid_type
= WID_NONE
;
149 for (i
= 0; typenames
[i
]; i
++) {
150 if (strcmp(typenames
[i
], typename
) == 0) {
152 break; /* it's valid: skip out...*/
159 widget_type_to_typename(WidgetType t
)
165 widget_search_subs(Widget
*w
, char *id
)
167 if (w
->type
== WID_FRAME
) {
168 return screen_find_widget(w
->frame_screen
, id
);
170 return NULL
; /* no kids */
174 char *widget_icon_to_iconname(int icon
)
178 for (i
= 0; icontable
[i
].iconname
; i
++) {
179 if (icontable
[i
].icon
== icon
) {
180 return icontable
[i
].iconname
;
187 int widget_iconname_to_icon(char *iconname
)
191 for (i
= 0; icontable
[i
].iconname
; i
++) {
192 if (strcasecmp(icontable
[i
].iconname
, iconname
) == 0) {
193 return icontable
[i
].icon
;