rename uicb_toggletag to uicb_client_toggletag
[awesome.git] / uicb.c
blob6f3172c2c26d4e049404171ea2a83b48391b02b1
1 /*
2 * uicb.c - user interface callbacks management
4 * Copyright © 2007 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <string.h>
24 #include "util.h"
25 #include "uicb.h"
26 #include "screen.h"
28 extern const NameFuncLink UicbList[];
30 int
31 parse_control(char *cmd, awesome_config *awesomeconf)
33 char *p, *curcmd = cmd;
35 if(!a_strlen(cmd))
36 return -1;
38 while((p = strchr(curcmd, '\n')))
40 *p = '\0';
41 run_uicb(curcmd, awesomeconf);
42 curcmd = p + 1;
45 return 0;
48 int
49 run_uicb(char *cmd, awesome_config *awesomeconf)
51 char *p, *uicb_name;
52 const char *arg;
53 int screen;
54 void (*uicb) (awesome_config *, const char *);
56 if(!a_strlen(cmd))
57 return -1;
59 if(!(p = strchr(cmd, ' ')))
60 return -1;
62 *p++ = '\0';
64 if((screen = atoi(cmd)) >= get_screen_count(awesomeconf->display))
65 return -1;
67 uicb_name = p;
69 if(!(p = strchr(p, ' ')))
70 arg = "";
71 else
73 *p++ = '\0';
74 arg = p;
77 if((p = strchr(arg, '\n')))
78 *p = '\0';
80 uicb = name_func_lookup(uicb_name, UicbList);
82 if(uicb)
83 uicb(&awesomeconf[screen], arg);
84 else
85 return -1;
87 return 0;
89 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99