Home grown error dialog
- From: Bob Caryl <bob fis-cal com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Home grown error dialog
- Date: Thu, 08 Dec 2005 14:36:45 -0600
Hey guys:
I created my own little version of Gtk::MessageDialog that uses
stdargs.h to create its message string. It is part of a little dynamic
library I link into my applications.
Code follows:
ErrorDialog.h contains:
#ifndef __FISCAL_ERRORDIALOG_
#define __FISCAL_ERRORDIALOG_
#include <gtkmm.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
class ErrorDialog
{
public:
ErrorDialog(gint type, char *formatstr, ... );
gint run(void);
enum { ERROR, QUESTION };
protected:
Gtk::MessageDialog *db;
}; // ====== > line 22
#endif
ErrorDialog.cpp contains:
#include "ErrorDialog.h"
#include "fiscal.c"
int ErrorDialog::run(void)
{
int response = db->run();
delete db;
return response;
}
ErrorDialog::ErrorDialog(gint type, char *fmt, ...)
{
Glib::RefPtr<Gdk::Pixbuf> fis_icon =
Gdk::Pixbuf::create_from_inline(-1,fisicon_inline,FALSE);
int n, size = 100;
char *p, *np;
va_list ap;
p = (char *)malloc(size);
while (1)
{
va_start(ap, fmt);
n = vsnprintf (p, size, fmt, ap);
va_end(ap);
if (n > -1 && n < size)
break;
if (n > -1)
size = n+1;
else
size *= 2; /* twice the old size */
np = (char *)realloc (p, size);
p = np;
}
db = new Gtk::MessageDialog(p,
FALSE,
(type==ErrorDialog::QUESTION?Gtk::MESSAGE_QUESTION:Gtk::MESSAGE_ERROR),
(type==ErrorDialog::QUESTION?Gtk::BUTTONS_YES_NO:Gtk::BUTTONS_OK)
);
free(p);
db->set_icon(fis_icon);
db->set_position(Gtk::WIN_POS_CENTER_ALWAYS);
}
I'm getting this error when this is linked into my application:
/home/bob/Projects/fiscal/include/ErrorDialog.h:22: error: multiple
types in one declaration
Any ideas on what I've done wrong here?
Bob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]