summaryrefslogtreecommitdiff
path: root/gtkutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtkutil.c')
-rw-r--r--gtkutil.c220
1 files changed, 0 insertions, 220 deletions
diff --git a/gtkutil.c b/gtkutil.c
deleted file mode 100644
index cbcf2f4..0000000
--- a/gtkutil.c
+++ /dev/null
@@ -1,220 +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 "gtkutil.h"
-
-
-/* ---------------------------------------- CONSTS
-*/
-
-/* ---------------------------------------- GLOBALS
-*/
-static GtkWidget *parent;
-static GtkWidget *dialog;
-
-static int dial_done=FALSE;
-static int selected=FALSE;
-
-
-/* ---------------------------------------- PRIVATE FUNCTIONS
-*/
-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;
-}
-
-
-/* ---------------------------------------- EXPORTED FUNCTIONS
-*/
-void DialogParent(GtkWidget *w)
-{
- parent=w;
-}
-
-
-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();
- gtk_window_set_title (GTK_WINDOW (dialog), "GEMMA -- Alert");
- 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_CENTER_ON_PARENT);
-
- gtk_widget_show(button);
- gtk_widget_show(label);
- gtk_widget_show(dialog);
-}
-
-
-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();
- gtk_window_set_title (GTK_WINDOW (dialog), "GEMMA -- Question");
- 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_CENTER_ON_PARENT);
- /* 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;
-}
-
-
-int DialogFSelect(const char *title, const char *filter_name,
- const char *filter, char path[])
-{
- GtkWidget *fsel;
- int ret=FALSE;
-
- fsel=gtk_file_chooser_dialog_new(title,
- GTK_WINDOW(parent),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- if (path[0])
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fsel),path);
-
- if (filter_name && filter)
- {
- GtkFileFilter *f=gtk_file_filter_new();
- gtk_file_filter_set_name(GTK_FILE_FILTER(f),filter_name);
- gtk_file_filter_add_pattern(GTK_FILE_FILTER(f),filter);
- gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fsel),
- GTK_FILE_FILTER(f));
- }
-
- if (gtk_dialog_run(GTK_DIALOG(fsel))==GTK_RESPONSE_ACCEPT)
- {
- strcpy(path,gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fsel)));
- ret=TRUE;
- }
-
- gtk_widget_destroy(fsel);
-
- return ret;
-}
-
-
-void AppendText(GtkWidget *w, const char *text)
-{
- GtkTextBuffer *buff;
- GtkTextIter end;
-
- buff=gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
- gtk_text_buffer_get_end_iter(buff,&end);
- gtk_text_buffer_insert(buff,&end,text,-1);
-}
-
-
-/* END OF FILE */