~ubuntu-branches/ubuntu/dapper/newt/dapper

« back to all changes in this revision

Viewing changes to buttonbar.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2005-03-22 12:44:37 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050322124437-nuhl0pqjcijjno9z
Tags: 0.51.6-20ubuntu3
Add Xhosa translation (thanks, Adi Attar).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdarg.h>
2
 
 
3
 
#include "newt.h"
4
 
 
5
 
/* if they try and pack more then 50 buttons, screw 'em */
6
 
newtGrid newtButtonBarv(char * button1, newtComponent * b1comp, va_list args) {
7
 
    newtGrid grid;
8
 
    struct buttonInfo {
9
 
        char * name;
10
 
        newtComponent * compPtr;
11
 
    } buttons[50];
12
 
    int num;
13
 
    int i;
14
 
 
15
 
    buttons[0].name = button1, buttons[0].compPtr = b1comp, num = 1;
16
 
    while (1) {
17
 
        buttons[num].name = va_arg(args, char *);
18
 
        if (!buttons[num].name) break;
19
 
        buttons[num].compPtr = va_arg(args, newtComponent *);
20
 
        num++;
21
 
    }
22
 
 
23
 
    grid = newtCreateGrid(num, 1);
24
 
 
25
 
    for (i = 0; i < num; i++) {
26
 
        *buttons[i].compPtr = newtButton(-1, -1, buttons[i].name);
27
 
        newtGridSetField(grid, i, 0, NEWT_GRID_COMPONENT, 
28
 
                         *buttons[i].compPtr,
29
 
                         num ? 1 : 0, 0, 0, 0, 0, 0);
30
 
    }
31
 
 
32
 
    return grid;
33
 
}
34
 
 
35
 
newtGrid newtButtonBar(char * button1, newtComponent * b1comp, ...) {
36
 
    va_list args;
37
 
    newtGrid grid;
38
 
 
39
 
    va_start(args, b1comp);
40
 
 
41
 
    grid = newtButtonBarv(button1, b1comp, args);
42
 
 
43
 
    va_end(args);
44
 
 
45
 
    return grid;
46
 
}