parent
e7ba99c1b6
commit
85f228fe9e
@ -0,0 +1,59 @@
|
|||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* error.h is part of SimpleSkyCam.
|
||||||
|
*
|
||||||
|
*****************************************************************************************/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "gui.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
extern GtkBuilder *_builder_; // work around for threads
|
||||||
|
|
||||||
|
gboolean errormessage_thread (gpointer data) {
|
||||||
|
struct ErrorMessage *em = (struct ErrorMessage*) data;
|
||||||
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_),
|
||||||
|
em->window));
|
||||||
|
|
||||||
|
if (window == NULL) window = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_),
|
||||||
|
"window-main"));
|
||||||
|
|
||||||
|
GtkWidget *dialog;
|
||||||
|
dialog = gtk_message_dialog_new(GTK_WINDOW(window),
|
||||||
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
GTK_MESSAGE_ERROR,
|
||||||
|
GTK_BUTTONS_OK,
|
||||||
|
"%s", em->message);
|
||||||
|
gtk_window_set_title(GTK_WINDOW(dialog), em->title);
|
||||||
|
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
|
gtk_widget_destroy(dialog);
|
||||||
|
|
||||||
|
free (em);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void errormessage_display (char *window, char *title, char *fmt,...) {
|
||||||
|
struct ErrorMessage *em = (struct ErrorMessage *) malloc (sizeof (struct ErrorMessage));
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
char buffer[ERRORMSG_LEN];
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
vsnprintf (buffer, (ERRORMSG_LEN-1), fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
buffer[ERRORMSG_LEN-1] = 0;
|
||||||
|
strncpy(em->title, title, ERRORMSG_LEN); em->title[ERRORMSG_LEN-1] = 0;
|
||||||
|
strncpy(em->message, buffer, ERRORMSG_LEN); em->message[ERRORMSG_LEN-1] = 0;
|
||||||
|
strncpy(em->window, window, ERRORMSG_LEN); em->window[ERRORMSG_LEN-1] = 0;
|
||||||
|
|
||||||
|
gdk_threads_add_idle(errormessage_thread, em);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* error.h is part of SimpleSkyCam.
|
||||||
|
*
|
||||||
|
*****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _ERROR_H_
|
||||||
|
#define _ERROR_H_
|
||||||
|
|
||||||
|
#define ERRORMSG_LEN 2048
|
||||||
|
struct ErrorMessage {
|
||||||
|
char window[ERRORMSG_LEN];
|
||||||
|
char title[ERRORMSG_LEN];
|
||||||
|
char message[ERRORMSG_LEN];
|
||||||
|
};
|
||||||
|
|
||||||
|
void errormessage_display (char *windowname, char *title, char *fmt,...);
|
||||||
|
|
||||||
|
#endif // _ERROR_H_
|
Loading…
Reference in new issue