1 /* Hey EMACS -*- linux-c -*- */
2 /* $Id: scroptions.c 2268 2006-11-06 17:18:51Z roms $ */
3 
4 /*  TiEmu - Tiemu Is an EMUlator
5  *
6  *  Copyright (c) 2000-2001, Thomas Corvazier, Romain Lievin
7  *  Copyright (c) 2001-2003, Romain Lievin
8  *  Copyright (c) 2003, Julien Blache
9  *  Copyright (c) 2004, Romain Li�vin
10  *  Copyright (c) 2005, Romain Li�vin
11  *  Copyright (c) 2007, Kevin Kofler
12  *
13  *  This program is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU General Public License as published by
15  *  the Free Software Foundation; either version 2 of the License, or
16  *  (at your option) any later version.
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details. *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
24  */
25 
26 
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif				/*  */
30 
31 #include <gtk/gtk.h>
32 #include <glade/glade.h>
33 #include <string.h>
34 
35 #include "intl.h"
36 #include "support.h"
37 #include "paths.h"
38 #include "struct.h"
39 #include "ti68k_int.h"
40 #include "dboxes.h"
41 
42 static char *tmp_file = NULL;
43 static int tmp_enabled = 0;
44 
45 static GtkWidget *fcb = NULL;
46 
display_quicksend_dbox()47 gint display_quicksend_dbox()
48 {
49 	GladeXML *xml;
50 	GtkWidget *dbox;
51 	GtkWidget *data;
52 	gint result;
53 
54 	xml = glade_xml_new
55 		(tilp_paths_build_glade("quicksend-2.glade"),
56 		 "quicksend_dbox",
57 		 PACKAGE);
58 	if (!xml)
59 		g_error(_("%s: GUI loading failed!\n"), __FILE__);
60 	glade_xml_signal_autoconnect(xml);
61 
62 	dbox = glade_xml_get_widget(xml, "quicksend_dbox");
63 	gtk_dialog_set_alternative_button_order(GTK_DIALOG(dbox), GTK_RESPONSE_OK,
64 	                                        GTK_RESPONSE_CANCEL,-1);
65 
66 	tmp_enabled = options.qs_enabled;
67 	tmp_file = g_strdup(options.qs_file);
68 
69 	fcb = glade_xml_get_widget(xml, "filechooserbutton1");
70 	gtk_widget_set_sensitive(fcb, tmp_enabled && tmp_file);
71 	if(tmp_file && strlen(tmp_file))
72 		gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fcb), tmp_file);
73 	// filter wildcards to set
74 	//"*.89?;*.92?;*.9x?;*.9X?;*.v2?;*.V2?;*.tig"
75 
76 	data = glade_xml_get_widget(xml, "checkbutton1");
77 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), tmp_enabled);
78 
79 	result = gtk_dialog_run(GTK_DIALOG(dbox));
80 	switch (result)
81 	{
82 	case GTK_RESPONSE_OK:
83 		options.qs_enabled = tmp_enabled;
84 
85 		g_free(options.qs_file);
86 		options.qs_file = tmp_file;
87 		break;
88 	default:
89 		break;
90 	}
91 
92 	gtk_widget_destroy(dbox);
93 
94 	return 0;
95 }
96 
97 GLADE_CB void
qs_checkbutton1_toggled(GtkToggleButton * togglebutton,gpointer user_data)98 qs_checkbutton1_toggled                (GtkToggleButton *togglebutton,
99                                         gpointer         user_data)
100 {
101 	tmp_enabled = gtk_toggle_button_get_active(togglebutton);
102 	if(fcb)
103 		gtk_widget_set_sensitive(fcb, tmp_enabled);
104 }
105 
106 GLADE_CB void
qs_filechooserbutton1_current_folder_changed(GtkFileChooser * filechooser,gpointer user_data)107 qs_filechooserbutton1_current_folder_changed
108                                         (GtkFileChooser  *filechooser,
109                                         gpointer         user_data)
110 {
111 	gchar *fname = gtk_file_chooser_get_filename (filechooser);
112 
113 	if(!fname)
114 		return;
115 
116 	if(!tifiles_file_is_ti(fname) || !tifiles_calc_is_ti9x(tifiles_file_get_model(fname)) ||
117 		!tifiles_file_test(fname, TIFILE_REGULAR, CALC_NONE))
118 	{
119 		g_free(tmp_file); tmp_file = NULL;
120 		msg_box1(_("Error"), _("This file is not a valid TI file."));
121 		return;
122 	}
123 
124 	g_free(tmp_file);
125 	tmp_file = g_strdup(fname); // dup or copy???
126 }
127 
128 /* */
129