aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/bugzilla_email_append.pl
Commit message (Expand)AuthorAgeFilesLines
* Bug 338375: Use Bugzilla->params everywhere instead of Param().mkanat%bugzilla.org2006-07-041-1/+0
* Bug 282121: Remove globals.pl from scripts that no longer use it - Patch by F...lpsolit%gmail.com2006-06-211-42/+43
* Bug 303708: Eliminate deprecated Bugzilla::DB routines from BugzillaEmail.pm,...lpsolit%gmail.com2006-05-151-8/+8
* Bug 106386 Correct misspellings in source codetimeless%mozdev.org2005-11-261-1/+1
* Bug 285695: [PostgreSQL] Username checks for login, etc. need to be case inse...mkanat%kerio.com2005-07-081-1/+4
* Bug 237638: make bugzilla_email_append.pl work with BugMail.pm instead of pro...justdave%syndicomm.com2004-04-151-1/+2
* Fix for bug 234175: Remove deprecated ConnectToDatabase() andkiko%async.com.br2004-03-271-2/+0
* Bug 208604 - Make data/template dir locations configurablebbaetz%acm.org2003-11-221-7/+11
* bug 163024 - bugzilla_email_append calls processmail incorrectlybbaetz%student.usyd.edu.au2002-09-031-1/+1
* Bug 76923 - Don't |use diagnostics| (its really expensive at startup time)bbaetz%student.usyd.edu.au2002-08-261-1/+0
* Fix for bug 154008: some basic (but incomplete) maintenance on bug_email.pl, ...justdave%syndicomm.com2002-07-251-4/+7
* Added a bugzilla.procmailrc as a sample procmailrc fileseth%cs.brandeis.edu2000-03-161-1/+3
* A few changes ...seth%cs.brandeis.edu2000-03-161-0/+187
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
#include <slang.h>
#include <stdlib.h>
#include <string.h>

#include "newt.h"
#include "newt_pr.h"

struct button {
    char * text;
    int compact;
};

static void buttonDrawIt(newtComponent co, int active, int pushed);
static void buttonDrawText(newtComponent co, int active, int pushed);

static void buttonDraw(newtComponent c);
static void buttonDestroy(newtComponent co);
static struct eventResult buttonEvent(newtComponent c,
				      struct event ev);
static void buttonPlace(newtComponent co, int newLeft, int newTop);

static struct componentOps buttonOps = {
    buttonDraw,
    buttonEvent,
    buttonDestroy,
    buttonPlace,
    newtDefaultMappedHandler,
} ;

static newtComponent createButton(int left, int row, const char * text, int compact) {
    newtComponent co;
    struct button * bu;

    co = malloc(sizeof(*co));
    bu = malloc(sizeof(struct button));
    co->data = bu;

    bu->text = strdup(text);
    bu->compact = compact;
    co->ops = &buttonOps;

    if (bu->compact) {
	co->height = 1;
	co->width = strlen(text) + 3;
    } else {
	co->height = 4;
	co->width = strlen(text) + 5;
    }

    co->top = row;
    co->left = left;
    co->takesFocus = 1;
    co->isMapped = 0;

    newtGotorc(co->top, co->left);

    return co;
}

newtComponent newtCompactButton(int left, int row, const char * text) {
    return createButton(left, row, text, 1);
}

newtComponent newtButton(int left, int row, const char * text) {
    return createButton(left, row, text, 0);
}

static void buttonDestroy(newtComponent co) {
    struct button * bu = co->data;

    free(bu->text);
    free(bu);
    free(co);
}

static void buttonPlace(newtComponent co, int newLeft, int newTop) {
    co->top = newTop;
    co->left = newLeft;

    newtGotorc(co->top, co->left);
}

static void buttonDraw(newtComponent co) {
    buttonDrawIt(co, 0, 0);
}

static void buttonDrawIt(newtComponent co, int active, int pushed) {
    struct button * bu = co->data;

    if (!co->isMapped) return;

    SLsmg_set_color(NEWT_COLORSET_BUTTON);

    if (bu->compact) {
	if (active)
	    SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
	else
	    SLsmg_set_color(NEWT_COLORSET_BUTTON);
	newtGotorc(co->top+ pushed, co->left + 1 + pushed);
	SLsmg_write_char('<');
	SLsmg_write_string(bu->text);
	SLsmg_write_char('>');
    } else {
	if (pushed) {
	    SLsmg_set_color(NEWT_COLORSET_BUTTON);
	    newtDrawBox(co->left + 1, co->top + 1, co->width - 1, 3, 0);

	    SLsmg_set_color(NEWT_COLORSET_WINDOW);
	    newtClearBox(co->left, co->top, co->width, 1);
	    newtClearBox(co->left, co->top, 1, co->height);
	} else {
	    newtDrawBox(co->left, co->top, co->width - 1, 3, 1);
	}

	buttonDrawText(co, active, pushed);
    }
}

static void buttonDrawText(newtComponent co, int active, int pushed) {
    struct button * bu = co->data;

    if (pushed) pushed = 1;

    if (active)
	SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
    else
	SLsmg_set_color(NEWT_COLORSET_BUTTON);

    newtGotorc(co->top + 1 + pushed, co->left + 1 + pushed);
    SLsmg_write_char(' ');
    SLsmg_write_string(bu->text);
    SLsmg_write_char(' ');
}

static struct eventResult buttonEvent(newtComponent co,
				      struct event ev) {
    struct eventResult er;
    struct button * bu = co->data;

    if (ev.when == EV_NORMAL) {
	switch (ev.event) {
	  case EV_FOCUS:
	    buttonDrawIt(co, 1, 0);
	    er.result = ER_SWALLOWED;
	    break;

	  case EV_UNFOCUS:
	    buttonDrawIt(co, 0, 0);
	    er.result = ER_SWALLOWED;
	    break;

	  case EV_KEYPRESS:
	    if (ev.u.key == ' ' || ev.u.key == '\r') {
		if (!bu->compact) {
		    /* look pushed */
		    buttonDrawIt(co, 1, 1);
		    newtRefresh();
		    newtDelay(150000);
		    buttonDrawIt(co, 1, 0);
		    newtRefresh();
		    newtDelay(150000);
		}

		er.result = ER_EXITFORM;
	    } else
		er.result = ER_IGNORED;
	    break;
	  case EV_MOUSE:
	      if (ev.u.mouse.type == MOUSE_BUTTON_DOWN &&
		  co->top <= ev.u.mouse.y &&
		  co->top + co->height - !bu->compact > ev.u.mouse.y &&
		  co->left <= ev.u.mouse.x &&
		  co->left + co->width - !bu->compact > ev.u.mouse.x) {
		  if (!bu->compact) {
		      buttonDrawIt(co, 1, 1);
		      newtRefresh();
		      newtDelay(150000);
		      buttonDrawIt(co, 1, 0);
		      newtRefresh();
		      newtDelay(150000);
		  }
		  er.result = ER_EXITFORM;
	      }
	    break;
	}
    } else
	er.result = ER_IGNORED;

    return er;
}