1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/* confirm.c: Confirmation dialog box
Copyright (c) 2000-2003 Philip Kendall, Russell Marks
$Id: confirm.c 4012 2009-04-16 12:42:14Z fredm $
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Author contact information:
E-mail: philip-fuse@shadowmagic.org.uk
*/
#include <config.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "compat.h"
#include "fuse.h"
#include "gtkinternals.h"
#include "settings.h"
#include "ui/ui.h"
static void set_confirmed( GtkButton *button, gpointer user_data );
static void set_save( GtkButton *button, gpointer user_data );
static void set_dont_save( GtkButton *button, gpointer user_data );
int
gtkui_confirm( const char *string )
{
GtkWidget *dialog, *label;
int confirm;
/* Return value isn't an error code, but signifies whether to undertake
the action */
if( !settings_current.confirm_actions ) return 1;
fuse_emulation_pause();
confirm = 0;
dialog = gtkstock_dialog_new( "Fuse - Confirm", NULL );
label = gtk_label_new( string );
gtk_box_pack_start( GTK_BOX( GTK_DIALOG( dialog )->vbox ), label,
TRUE, TRUE, 5 );
gtkstock_create_ok_cancel( dialog, NULL, GTK_SIGNAL_FUNC( set_confirmed ),
&confirm, NULL );
gtk_widget_show_all( dialog );
gtk_main();
fuse_emulation_unpause();
return confirm;
}
static void
set_confirmed( GtkButton *button GCC_UNUSED, gpointer user_data )
{
int *ptr = user_data;
*ptr = 1;
}
ui_confirm_save_t
ui_confirm_save_specific( const char *message )
{
GtkWidget *dialog, *label;
ui_confirm_save_t confirm;
if( !settings_current.confirm_actions ) return UI_CONFIRM_SAVE_DONTSAVE;
fuse_emulation_pause();
confirm = UI_CONFIRM_SAVE_CANCEL;
dialog = gtkstock_dialog_new( "Fuse - Confirm", NULL );
label = gtk_label_new( message );
gtk_box_pack_start( GTK_BOX( GTK_DIALOG( dialog )->vbox ), label,
TRUE, TRUE, 5 );
{
static gtkstock_button btn[] = {
{ GTK_STOCK_NO, GTK_SIGNAL_FUNC( set_dont_save ), NULL, DEFAULT_DESTROY, 0, 0, GDK_VoidSymbol, 0 }, /* override Escape */
{ GTK_STOCK_CANCEL, NULL, NULL, DEFAULT_DESTROY, 0, 0, 0, 0 },
{ GTK_STOCK_SAVE, GTK_SIGNAL_FUNC( set_save ), NULL, DEFAULT_DESTROY, 0, 0, 0, 0 }
};
btn[0].actiondata = btn[2].actiondata = &confirm;
gtkstock_create_buttons( dialog, NULL, btn,
sizeof( btn ) / sizeof( btn[0] ) );
}
gtk_widget_show_all( dialog );
gtk_main();
fuse_emulation_unpause();
return confirm;
}
int
ui_query( const char *message )
{
return gtkui_confirm( message );
}
static void
set_save( GtkButton *button GCC_UNUSED, gpointer user_data )
{
ui_confirm_save_t *ptr = user_data;
*ptr = UI_CONFIRM_SAVE_SAVE;
}
static void
set_dont_save( GtkButton *button GCC_UNUSED, gpointer user_data )
{
ui_confirm_save_t *ptr = user_data;
*ptr = UI_CONFIRM_SAVE_DONTSAVE;
}
|