widget: change widget initialization code

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-11-12 14:55:30 +01:00
parent f556c04868
commit ccc6452d49
12 changed files with 39 additions and 54 deletions

View File

@ -9,7 +9,7 @@ do
echo " /* $file */"
grep '^widget_constructor_t ' "$file" | cut -d' ' -f2 | cut -d\; -f1 | while read widget
do
shortname=`echo $widget | cut -d_ -f1`
shortname=`echo $widget | cut -d_ -f2`
echo " {\"$shortname\", $widget},"
done
done

View File

@ -355,7 +355,7 @@ event_handle_destroynotify(void *data __attribute__ ((unused)),
{
xembed_window_list_detach(&globalconf.embedded, emwin);
for(int i = 0; i < globalconf.nscreen; i++)
widget_invalidate_bytype(i, systray_new);
widget_invalidate_bytype(i, widget_systray);
}
return 0;
@ -660,7 +660,7 @@ event_handle_unmapnotify(void *data __attribute__ ((unused)),
{
xembed_window_list_detach(&globalconf.embedded, em);
for(int i = 0; i < globalconf.nscreen; i++)
widget_invalidate_bytype(i, systray_new);
widget_invalidate_bytype(i, widget_systray);
}
return 0;

View File

@ -64,7 +64,7 @@ typedef struct client_t client_t;
typedef struct client_node client_node_t;
typedef struct tag tag_t;
typedef struct tag_client_node_t tag_client_node_t;
typedef widget_t *(widget_constructor_t)(alignment_t);
typedef widget_t *(widget_constructor_t)(widget_t *);
typedef void (widget_destructor_t)(widget_t *);
typedef struct awesome_t awesome_t;

View File

@ -173,7 +173,7 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
MIN(XEMBED_VERSION, em->info.version));
for(i = 0; i < globalconf.nscreen; i++)
widget_invalidate_bytype(i, systray_new);
widget_invalidate_bytype(i, widget_systray);
return 0;
}

View File

@ -120,7 +120,7 @@ wibox_systray_refresh(wibox_t *wibox)
for(int i = 0; i < wibox->widgets.len; i++)
{
widget_node_t *systray = &wibox->widgets.tab[i];
if(systray->widget->type == systray_new)
if(systray->widget->type == widget_systray)
{
uint32_t config_back[] = { wibox->sw.ctx.bg.pixel };
uint32_t config_win_vals[4];

View File

@ -322,21 +322,21 @@ widget_invalidate_bywidget(widget_t *widget)
static int
luaA_widget_new(lua_State *L)
{
const char *buf, *type;
widget_t *w = NULL;
const char *align, *type;
widget_t *w;
widget_constructor_t *wc;
alignment_t align;
size_t len;
luaA_checktable(L, 2);
buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
align = draw_align_fromstr(buf, len);
align = luaA_getopt_lstring(L, 2, "align", "left", &len);
type = luaA_getopt_string(L, 2, "type", NULL);
if((wc = name_func_lookup(type, WidgetList)))
w = wc(align);
{
w = p_new(widget_t, 1);
wc(w);
}
else
{
luaA_warn(L, "unkown widget type: %s", type);
@ -344,8 +344,8 @@ luaA_widget_new(lua_State *L)
}
w->type = wc;
w->align_supported |= AlignLeft | AlignRight;
w->align = draw_align_fromstr(align, len);
/* Set visible by default. */
w->isvisible = true;

View File

@ -45,11 +45,11 @@ void luaA_table2widgets(lua_State *, widget_node_array_t *);
void widget_invalidate_bywidget(widget_t *);
void widget_invalidate_bytype(int, widget_constructor_t *);
widget_constructor_t textbox_new;
widget_constructor_t progressbar_new;
widget_constructor_t graph_new;
widget_constructor_t systray_new;
widget_constructor_t imagebox_new;
widget_constructor_t widget_textbox;
widget_constructor_t widget_progressbar;
widget_constructor_t widget_graph;
widget_constructor_t widget_systray;
widget_constructor_t widget_imagebox;
/** Delete a widget node structure.
* \param node The node to destroy.

View File

@ -578,24 +578,19 @@ graph_destructor(widget_t *widget)
}
/** Create a brand new graph.
* \param align The widget alignment.
* \return A graph widget.
* \param w The widget to initialize.
* \return The same widget.
*/
widget_t *
graph_new(alignment_t align)
widget_graph(widget_t *w)
{
widget_t *w;
graph_data_t *d;
w = p_new(widget_t, 1);
w->draw = graph_draw;
w->index = luaA_graph_index;
w->newindex = luaA_graph_newindex;
w->destructor = graph_destructor;
w->align = align;
w->geometry = graph_geometry;
d = w->data = p_new(graph_data_t, 1);
graph_data_t *d = w->data = p_new(graph_data_t, 1);
d->width = 80;
d->height = 0.80;

View File

@ -210,15 +210,13 @@ luaA_imagebox_newindex(lua_State *L, awesome_token_t token)
/** Create a new imagebox widget.
* \param align Widget alignment.
* \param w The widget to initialize.
* \return A brand new widget.
*/
widget_t *
imagebox_new(alignment_t align)
widget_imagebox(widget_t *w)
{
widget_t *w = p_new(widget_t, 1);
imagebox_data_t *d;
w->align = align;
w->draw = imagebox_draw;
w->index = luaA_imagebox_index;
w->newindex = luaA_imagebox_newindex;

View File

@ -636,23 +636,19 @@ progressbar_destructor(widget_t *widget)
}
/** Create a new progressbar.
* \param align Alignment of the widget.
* \param w The widget to initialize.
* \return A brand new progressbar.
*/
widget_t *
progressbar_new(alignment_t align)
widget_progressbar(widget_t *w)
{
widget_t *w;
progressbar_data_t *d;
w = p_new(widget_t, 1);
w->align = align;
w->draw = progressbar_draw;
w->index = luaA_progressbar_index;
w->newindex = luaA_progressbar_newindex;
w->destructor = progressbar_destructor;
w->geometry = progressbar_geometry;
d = w->data = p_new(progressbar_data_t, 1);
progressbar_data_t *d = w->data = p_new(progressbar_data_t, 1);
d->height = 0.80;
d->width = 80;

View File

@ -74,13 +74,13 @@ systray_draw(widget_t *widget, draw_context_t *ctx,
_NET_SYSTEM_TRAY_ORIENTATION, CARDINAL, 32, 1, &orient);
}
/** Initialize a systray widget.
* \param w The widget to initialize.
* \return The same widget.
*/
widget_t *
systray_new(alignment_t align)
widget_systray(widget_t *w)
{
widget_t *w;
w = p_new(widget_t, 1);
w->align = align;
w->draw = systray_draw;
w->geometry = systray_geometry;

View File

@ -231,24 +231,20 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
}
/** Create a new textbox widget.
* \param align Widget alignment.
* \param w The widget to initialize.
* \return A brand new widget.
*/
widget_t *
textbox_new(alignment_t align)
widget_textbox(widget_t *w)
{
widget_t *w;
textbox_data_t *d;
w = p_new(widget_t, 1);
w->align = align;
w->align_supported |= AlignFlex;
w->draw = textbox_draw;
w->index = luaA_textbox_index;
w->newindex = luaA_textbox_newindex;
w->destructor = textbox_destructor;
w->geometry = textbox_geometry;
w->data = d = p_new(textbox_data_t, 1);
textbox_data_t *d = w->data = p_new(textbox_data_t, 1);
d->ellip = PANGO_ELLIPSIZE_END;
return w;