diff --git a/build-utils/widgetgen.sh b/build-utils/widgetgen.sh index b317d897..037d3dbd 100755 --- a/build-utils/widgetgen.sh +++ b/build-utils/widgetgen.sh @@ -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 diff --git a/event.c b/event.c index e28d8ac8..c29b9fdd 100644 --- a/event.c +++ b/event.c @@ -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; diff --git a/structs.h b/structs.h index 62b8618d..5c986fcd 100644 --- a/structs.h +++ b/structs.h @@ -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; diff --git a/systray.c b/systray.c index fb05f133..f957e497 100644 --- a/systray.c +++ b/systray.c @@ -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; } diff --git a/wibox.c b/wibox.c index fc4be328..eb7bde1f 100644 --- a/wibox.c +++ b/wibox.c @@ -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]; diff --git a/widget.c b/widget.c index b5c4d318..c8ce4660 100644 --- a/widget.c +++ b/widget.c @@ -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; diff --git a/widget.h b/widget.h index 73f79e55..58c423bb 100644 --- a/widget.h +++ b/widget.h @@ -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. diff --git a/widgets/graph.c b/widgets/graph.c index 731db5e3..52c657a3 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -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; diff --git a/widgets/imagebox.c b/widgets/imagebox.c index 518ccae3..e3dfecd3 100644 --- a/widgets/imagebox.c +++ b/widgets/imagebox.c @@ -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; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index c6adb7fb..271e2811 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -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; diff --git a/widgets/systray.c b/widgets/systray.c index 7383bf02..fdff41f7 100644 --- a/widgets/systray.c +++ b/widgets/systray.c @@ -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; diff --git a/widgets/textbox.c b/widgets/textbox.c index 28a494a8..ffe93c3e 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -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;