Add basic framework for uicb_widget_tell. For now, it does nothing, but stay

tuned.
This commit is contained in:
Aldo Cortesi 2007-12-16 20:25:13 +11:00 committed by Julien Danjou
parent 3af4117039
commit 7385815927
4 changed files with 48 additions and 5 deletions

View File

@ -25,7 +25,7 @@
#include "config.h" #include "config.h"
/** Common prototype definition for ui_callback functions */ /** Common prototype definition for ui_callback functions */
#define UICB_PROTO(name) void name(int, const char *) #define UICB_PROTO(name) void name(int, char *)
/** Common prototype definition for layouts function */ /** Common prototype definition for layouts function */
#define LAYOUT_PROTO(name) void name(int) #define LAYOUT_PROTO(name) void name(int)

16
uicb.c
View File

@ -28,6 +28,7 @@
#include "layout.h" #include "layout.h"
#include "mouse.h" #include "mouse.h"
#include "statusbar.h" #include "statusbar.h"
#include "widget.h"
#include "focus.h" #include "focus.h"
#include "layouts/tile.h" #include "layouts/tile.h"
@ -80,6 +81,8 @@ const NameFuncLink UicbList[] =
{"client_resizemouse", uicb_client_resizemouse}, {"client_resizemouse", uicb_client_resizemouse},
/* focus.c */ /* focus.c */
{"focus_history", uicb_focus_history}, {"focus_history", uicb_focus_history},
/* widgets.c */
{"widget_tell", uicb_widget_tell},
{NULL, NULL} {NULL, NULL}
}; };
@ -88,6 +91,7 @@ run_uicb(char *cmd, awesome_config *awesomeconf)
{ {
char *p; char *p;
const char *arg; const char *arg;
char *argcpy;
int screen, len; int screen, len;
void (*uicb) (int, const char *); void (*uicb) (int, const char *);
@ -115,11 +119,16 @@ run_uicb(char *cmd, awesome_config *awesomeconf)
} }
if (p+strlen(p) < cmd+len) if (p+strlen(p) < cmd+len)
{
arg = p + strlen(p) + 1; arg = p + strlen(p) + 1;
/* Allow our callees to modify this string. */
argcpy = p_new(char, strlen(arg)+1);
strncpy(argcpy, arg, strlen(arg));
uicb(screen, argcpy);
p_delete(&argcpy);
}
else else
arg = NULL; uicb(screen, NULL);
uicb(screen, arg);
return 0; return 0;
} }
@ -137,7 +146,6 @@ parse_control(char *cmd)
run_uicb(curcmd, &globalconf); run_uicb(curcmd, &globalconf);
curcmd = p + 1; curcmd = p + 1;
} }
return 0; return 0;
} }

View File

@ -1,6 +1,8 @@
#include "util.h" #include "util.h"
#include "widget.h" #include "widget.h"
extern awesome_config globalconf;
const NameFuncLink WidgetList[] = const NameFuncLink WidgetList[] =
{ {
{"taglist", taglist_new}, {"taglist", taglist_new},
@ -41,6 +43,17 @@ calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
} }
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 void
common_new(Widget *widget, Statusbar *statusbar, const char *name) common_new(Widget *widget, Statusbar *statusbar, const char *name)
{ {
@ -49,5 +62,24 @@ common_new(Widget *widget, Statusbar *statusbar, const char *name)
strncpy(widget->name, name, strlen(name)); 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -3,6 +3,7 @@
#include "config.h" #include "config.h"
#include "draw.h" #include "draw.h"
#include "common.h"
enum { AlignLeft, AlignRight, AlignFlex }; enum { AlignLeft, AlignRight, AlignFlex };
@ -17,6 +18,8 @@ WidgetConstructor taglist_new;
WidgetConstructor textbox_new; WidgetConstructor textbox_new;
WidgetConstructor focustitle_new; WidgetConstructor focustitle_new;
UICB_PROTO(uicb_widget_tell);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99