cosmetics and add copyright
This commit is contained in:
parent
5dfd96a3f2
commit
9df4429ae3
40
widget.c
40
widget.c
|
@ -1,4 +1,25 @@
|
||||||
#include <confuse.h>
|
/*
|
||||||
|
* widget.c - widget managing
|
||||||
|
*
|
||||||
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
||||||
|
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
@ -46,7 +67,6 @@ calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
|
||||||
return barwidth - offset - widgetwidth;
|
return barwidth - offset - widgetwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Widget *
|
static Widget *
|
||||||
find_widget(char *name, int screen)
|
find_widget(char *name, int screen)
|
||||||
{
|
{
|
||||||
|
@ -58,27 +78,24 @@ find_widget(char *name, int screen)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
common_tell(Widget *widget, char *command __attribute__ ((unused)))
|
common_tell(Widget *widget, char *command __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
warn("%s widget does not accept commands.\n", widget->name);
|
warn("%s widget does not accept commands.\n", widget->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
common_new(Widget *widget, Statusbar *statusbar, cfg_t* config)
|
common_new(Widget *widget, Statusbar *statusbar, cfg_t* config)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
widget->statusbar = statusbar;
|
|
||||||
|
|
||||||
|
widget->statusbar = statusbar;
|
||||||
name = cfg_title(config);
|
name = cfg_title(config);
|
||||||
widget->name = p_new(char, strlen(name)+1);
|
widget->name = p_new(char, strlen(name)+1);
|
||||||
widget->tell = common_tell;
|
widget->tell = common_tell;
|
||||||
strncpy(widget->name, name, strlen(name));
|
strncpy(widget->name, name, strlen(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Send command to widget
|
/** Send command to widget
|
||||||
* \param screen Screen ID
|
* \param screen Screen ID
|
||||||
* \param arg Widget command. Syntax depends on specific widget.
|
* \param arg Widget command. Syntax depends on specific widget.
|
||||||
|
@ -91,19 +108,23 @@ uicb_widget_tell(int screen, char *arg)
|
||||||
char *p, *command;
|
char *p, *command;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!arg){
|
if (!arg)
|
||||||
|
{
|
||||||
warn("Must specify a widget.\n");
|
warn("Must specify a widget.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(arg);
|
len = strlen(arg);
|
||||||
p = strtok(arg, " ");
|
p = strtok(arg, " ");
|
||||||
if (!p){
|
if (!p)
|
||||||
|
{
|
||||||
warn("Ignoring malformed widget command.\n");
|
warn("Ignoring malformed widget command.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = find_widget(p, screen);
|
widget = find_widget(p, screen);
|
||||||
if (!widget){
|
if (!widget)
|
||||||
|
{
|
||||||
warn("No such widget: %s\n", p);
|
warn("No such widget: %s\n", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +139,7 @@ uicb_widget_tell(int screen, char *arg)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
widget->tell(widget, NULL);
|
widget->tell(widget, NULL);
|
||||||
|
|
||||||
statusbar_draw(screen);
|
statusbar_draw(screen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
28
widget.h
28
widget.h
|
@ -1,3 +1,25 @@
|
||||||
|
/*
|
||||||
|
* widget.h - widget managing header
|
||||||
|
*
|
||||||
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
||||||
|
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef AWESOME_WIDGET_H
|
#ifndef AWESOME_WIDGET_H
|
||||||
#define AWESOME_WIDGET_H
|
#define AWESOME_WIDGET_H
|
||||||
|
|
||||||
|
@ -8,11 +30,11 @@
|
||||||
|
|
||||||
enum { AlignLeft, AlignRight, AlignFlex };
|
enum { AlignLeft, AlignRight, AlignFlex };
|
||||||
|
|
||||||
typedef Widget *(WidgetConstructor)(Statusbar*, cfg_t*);
|
typedef Widget *(WidgetConstructor)(Statusbar *, cfg_t *);
|
||||||
|
|
||||||
int calculate_offset(int, int, int, int);
|
int calculate_offset(int, int, int, int);
|
||||||
void calculate_alignments(Widget *widget);
|
void calculate_alignments(Widget *);
|
||||||
void common_new(Widget*, Statusbar*, cfg_t*);
|
void common_new(Widget*, Statusbar *, cfg_t *);
|
||||||
|
|
||||||
WidgetConstructor layoutinfo_new;
|
WidgetConstructor layoutinfo_new;
|
||||||
WidgetConstructor taglist_new;
|
WidgetConstructor taglist_new;
|
||||||
|
|
Loading…
Reference in New Issue