awesome/widget.c

86 lines
1.9 KiB
C
Raw Normal View History

2007-12-15 18:21:02 +01:00
#include "util.h"
#include "widget.h"
extern awesome_config globalconf;
2007-12-15 18:21:02 +01:00
const NameFuncLink WidgetList[] =
{
{"taglist", taglist_new},
{"layoutinfo", layoutinfo_new},
{"focustitle", focustitle_new},
2007-12-15 20:22:20 +01:00
{"textbox", textbox_new},
{NULL, NULL}
2007-12-15 18:21:02 +01:00
};
void
calculate_alignments(Widget *widget)
{
2007-12-15 13:37:34 +01:00
for(; widget; widget = widget->next)
{
if(widget->alignment == AlignFlex)
{
widget = widget->next;
break;
}
widget->alignment = AlignLeft;
}
2007-12-15 13:37:34 +01:00
if(widget)
2007-12-16 04:28:29 +01:00
for(; widget; widget = widget->next){
if (widget->alignment == AlignFlex)
warn("Multiple flex widgets in panel -"
" ignoring flex for all but the first.");
widget->alignment = AlignRight;
2007-12-16 04:28:29 +01:00
}
}
int
calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
{
if (alignment == AlignLeft || alignment == AlignFlex)
return offset;
2007-12-15 13:37:34 +01:00
return barwidth - offset - widgetwidth;
}
static Widget *
find_widget(char *name, int screen)
{
Widget *widget;
widget = globalconf.screens[screen].statusbar.widgets;
for(; widget; widget = widget->next)
if (strcmp(name, widget->name) == 0)
return widget;
return NULL;
}
void
common_new(Widget *widget, Statusbar *statusbar, const char *name)
{
widget->statusbar = statusbar;
widget->name = p_new(char, strlen(name)+1);
strncpy(widget->name, name, strlen(name));
}
void
uicb_widget_tell(int screen, char *arg)
{
Widget *widget;
char *p;
p = strtok(arg, " ");
if (!p){
warn("Ignoring malformed widget command.");
return;
}
widget = find_widget(p, screen);
if (!widget){
warn("No such widget: %s\n", p);
return;
}
/* To be continued... */
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99