summaryrefslogtreecommitdiff
path: root/dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'dialog.c')
-rw-r--r--dialog.c237
1 files changed, 0 insertions, 237 deletions
diff --git a/dialog.c b/dialog.c
deleted file mode 100644
index 005f42b..0000000
--- a/dialog.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
-
- z80 - Z80 Emulation
-
- Copyright (C) 2006 Ian Cowburn (ianc@noddybox.demon.co.uk)
-
- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- -------------------------------------------------------------------------
-
- Simple dialogs
-
- $Id$
-
-*/
-
-/* ---------------------------------------- INCLUDES
-*/
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "dialog.h"
-
-
-/* ---------------------------------------- CONSTS
-*/
-
-/* ---------------------------------------- GLOBALS
-*/
-static GtkWidget *parent;
-static GtkWidget *dialog;
-
-static int dial_done=FALSE;
-static int selected=FALSE;
-
-static char saved_path[PATH_MAX+1];
-
-
-/* ---------------------------------------- CALLBACKS
-*/
-static void Callback(GtkWidget *w, gpointer data)
-{
- dial_done=TRUE;
- selected=(int)data;
- gtk_widget_destroy(dialog);
-}
-
-
-static gint DestroyCB(GtkWidget *w, GdkEvent *ev, gpointer data)
-{
- Callback(w,data);
- return TRUE;
-}
-
-
-static gint NoDestroyCB(GtkWidget *w, GdkEvent *ev, gpointer data)
-{
- dial_done=TRUE;
- selected=(int)data;
- return TRUE;
-}
-
-
-static void FselCallback(GtkWidget *w, gpointer data)
-{
- dial_done=TRUE;
- selected=(int)data;
-
- if (selected)
- strcpy(saved_path,
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog)));
-}
-
-
-/* ---------------------------------------- DialogParent()
-*/
-void DialogParent(GtkWidget *w)
-{
- parent=w;
-}
-
-
-/* ---------------------------------------- DialogOK()
-*/
-void DialogOK(const char *format, ...)
-{
- va_list va;
- char text[1024];
- GtkWidget *button;
- GtkWidget *label;
-
- va_start(va,format);
- vsnprintf(text,sizeof text,format,va);
- va_end(va);
-
- dialog=gtk_dialog_new();
- button=gtk_button_new_with_label("OK");
- label=gtk_label_new(text);
-
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
- button,TRUE,TRUE,0);
-
- gtk_container_set_border_width(GTK_CONTAINER(dialog),10);
-
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- label,TRUE,TRUE,0);
-
- gtk_signal_connect_object(GTK_OBJECT (button),"clicked",
- GTK_SIGNAL_FUNC (gtk_widget_destroy),
- GTK_OBJECT (dialog));
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent));
- gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
- gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_MOUSE);
-
- gtk_widget_show(button);
- gtk_widget_show(label);
- gtk_widget_show(dialog);
-}
-
-
-/* ---------------------------------------- DialogYesNo()
-*/
-int DialogYesNo(const char *format, ...)
-{
- va_list va;
- char text[1024];
- GtkWidget *yes;
- GtkWidget *no;
- GtkWidget *label;
-
- va_start(va,format);
- vsnprintf(text,sizeof text,format,va);
- va_end(va);
-
- dialog=gtk_dialog_new();
- yes=gtk_button_new_with_label("Yes");
- no=gtk_button_new_with_label("No");
- label=gtk_label_new(text);
-
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
- yes,TRUE,TRUE,0);
-
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
- no,TRUE,TRUE,0);
-
- gtk_container_set_border_width(GTK_CONTAINER(dialog),10);
-
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- label,TRUE,TRUE,0);
-
- gtk_signal_connect(GTK_OBJECT (yes),"clicked",
- GTK_SIGNAL_FUNC (Callback),
- (gpointer)1);
-
- gtk_signal_connect(GTK_OBJECT (no),"clicked",
- GTK_SIGNAL_FUNC (Callback),
- (gpointer)0);
-
- gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
- GTK_SIGNAL_FUNC(DestroyCB), (gpointer)0);
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent));
- gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
- gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_MOUSE);
- /* gtk_object_set(GTK_OBJECT(dialog),"type",GTK_WINDOW_POPUP,NULL); */
-
- gtk_widget_show(yes);
- gtk_widget_show(no);
- gtk_widget_show(label);
- gtk_widget_show(dialog);
-
- dial_done=FALSE;
-
- while(!dial_done)
- gtk_main_iteration();
-
- return selected;
-}
-
-
-/* ---------------------------------------- DialogFSelect()
-*/
-int DialogFSelect(const char *title, char path[])
-{
- dialog=gtk_file_selection_new(title);
-
- if (path[0])
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),path);
-
- gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(dialog)->ok_button),
- "clicked",
- GTK_SIGNAL_FUNC (FselCallback),
- (gpointer)1);
-
- gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(dialog)->cancel_button),
- "clicked",
- GTK_SIGNAL_FUNC (FselCallback),
- (gpointer)0);
-
- gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
- GTK_SIGNAL_FUNC(NoDestroyCB), (gpointer)0);
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent));
- gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
- gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_MOUSE);
-
- gtk_widget_show(dialog);
-
- dial_done=FALSE;
-
- while(!dial_done)
- gtk_main_iteration();
-
- if (selected)
- strcpy(path,saved_path);
-
- gtk_widget_destroy(dialog);
-
- return selected;
-}
-
-
-/* END OF FILE */