1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
4 /*----------------------------------------------------------------------
6 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
9 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
12 This file is part of gpiv.
14 Gpiv is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2, or (at your option)
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 ----------------------------------------------------------------------*/
31 * $Id: dialog_interface.c,v 1.1 2008-09-16 11:19:37 gerber Exp $
40 #include "dialog_interface.h"
47 /*-----------------------------------------------------------------------------
51 GdkPixbuf
*logo
= NULL
;
52 const gchar
*authors
[] = {
53 "Gerber van der Graaf <gerber_graaf@users.sourceforge.net>",
56 #endif /* ENABLE_TRIG */
61 logo
= gdk_pixbuf_new_from_file(PIXMAPSDIR
"gpiv_logo.png", NULL
);
64 GdkPixbuf
*temp_logo
= NULL
;
66 temp_logo
= gdk_pixbuf_scale_simple (logo
,
67 gdk_pixbuf_get_width (logo
),
68 gdk_pixbuf_get_height (logo
),
70 g_object_unref (logo
);
75 about
= g_object_new (GTK_TYPE_ABOUT_DIALOG
,
78 "copyright", _("Copyright G. Van der Graaf"),
79 "comments", _("GPIV is a program for (Digital) \
80 Particle Image Velocimetry. It \
81 interrogates images (pairs) of a fluid flow that has been seeded \
82 with tracer particles, resulting into the velocity field of \
89 gtk_object_set_data (GTK_OBJECT (about
),
93 g_signal_connect_swapped (GTK_DIALOG (about
),
95 G_CALLBACK (gtk_widget_destroy
),
98 gtk_widget_show(GTK_WIDGET(about
));
99 if (logo
!= NULL
) g_object_unref (logo
);
106 *create_exit_dialog (/* GtkWidget *console */
108 /*-----------------------------------------------------------------------------
111 GtkDialog
*exit_dialog
;
112 GtkWidget
*dialog_vbox1
;
116 GdkPixbuf
*logo
= NULL
;
118 GtkWidget
*exit_message_label
;
119 gchar
*message
= _("There are unsaved data that will be lost.\nAre you sure you want to quit?");
125 /* logo = gdk_pixbuf_new_from_file(PIXMAPSDIR "gpiv_logo.png", NULL); */
126 exit_dialog
= GTK_DIALOG( gtk_dialog_new_with_buttons
129 GTK_DIALOG_DESTROY_WITH_PARENT
,
130 GTK_STOCK_NO
, GTK_RESPONSE_REJECT
,
131 GTK_STOCK_YES
, GTK_RESPONSE_ACCEPT
,
134 gtk_dialog_set_default_response(exit_dialog
,
135 GTK_RESPONSE_REJECT
);
136 g_signal_connect( exit_dialog
,
138 G_CALLBACK (on_button_quit_gpiv_clicked
),
141 gtk_window_set_icon(GTK_WINDOW( exit_dialog
), logo
);
142 if (logo
!= NULL
) g_object_unref (logo
);
146 hbox
= g_object_new(GTK_TYPE_HBOX
,
149 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(exit_dialog
)->vbox
),
151 gtk_widget_show(GTK_WIDGET (hbox
));
156 icon
= g_object_new(GTK_TYPE_IMAGE
,
157 "stock", /* GTK_STOCK_DIALOG_QUESTION */ GTK_STOCK_DIALOG_WARNING
,
158 "icon-size", GTK_ICON_SIZE_DIALOG
,
162 gtk_box_pack_start (GTK_BOX(hbox
),
167 gtk_widget_show(GTK_WIDGET (icon
));
172 text
= g_object_new(GTK_TYPE_LABEL
,
177 gtk_box_pack_start (GTK_BOX(hbox
),
182 gtk_widget_show(GTK_WIDGET (text
));
190 *create_message_dialog (gchar
* message
192 /*-----------------------------------------------------------------------------
195 GtkDialog
*message_dialog
;
199 GdkPixbuf
*logo
= NULL
;
204 message_dialog
= GTK_DIALOG( gtk_dialog_new_with_buttons
207 GTK_DIALOG_DESTROY_WITH_PARENT
,
208 GTK_STOCK_OK
, GTK_RESPONSE_NONE
,
211 g_signal_connect_swapped (GTK_DIALOG (message_dialog
),
213 G_CALLBACK (gtk_widget_destroy
),
217 gtk_window_set_icon(GTK_WINDOW( message_dialog
), logo
);
218 if (logo
!= NULL
) g_object_unref (logo
);
220 hbox
= g_object_new(GTK_TYPE_HBOX
,
223 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(message_dialog
)->vbox
),
225 gtk_widget_show(GTK_WIDGET (hbox
));
230 icon
= g_object_new(GTK_TYPE_IMAGE
,
231 "stock", GTK_STOCK_DIALOG_INFO
,
232 "icon-size", GTK_ICON_SIZE_DIALOG
,
236 gtk_box_pack_start (GTK_BOX(hbox
),
241 gtk_widget_show(GTK_WIDGET (icon
));
245 text
= g_object_new(GTK_TYPE_LABEL
,
250 gtk_box_pack_start (GTK_BOX(hbox
),
255 gtk_widget_show(GTK_WIDGET (text
));
256 gtk_widget_show(GTK_WIDGET (text
));
259 return message_dialog
;
265 *create_warning_dialog (gchar
* message
267 /*-----------------------------------------------------------------------------
270 GtkDialog
*warning_dialog
;
274 GdkPixbuf
*logo
= NULL
;
279 warning_dialog
= GTK_DIALOG( gtk_dialog_new_with_buttons
282 GTK_DIALOG_DESTROY_WITH_PARENT
,
283 GTK_STOCK_OK
, GTK_RESPONSE_NONE
,
286 g_signal_connect_swapped (GTK_DIALOG (warning_dialog
),
288 G_CALLBACK (gtk_widget_destroy
),
292 gtk_window_set_icon(GTK_WINDOW( warning_dialog
), logo
);
293 if (logo
!= NULL
) g_object_unref (logo
);
295 hbox
= g_object_new(GTK_TYPE_HBOX
,
298 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(warning_dialog
)->vbox
),
300 gtk_widget_show(GTK_WIDGET (hbox
));
305 icon
= g_object_new(GTK_TYPE_IMAGE
,
306 "stock", GTK_STOCK_DIALOG_WARNING
,
307 "icon-size", GTK_ICON_SIZE_DIALOG
,
311 gtk_box_pack_start (GTK_BOX(hbox
),
316 gtk_widget_show(GTK_WIDGET (icon
));
320 text
= g_object_new(GTK_TYPE_LABEL
,
325 gtk_box_pack_start (GTK_BOX(hbox
),
330 gtk_widget_show(GTK_WIDGET (text
));
331 /* gtk_container_add (GTK_CONTAINER (GTK_DIALOG(warning_dialog)->vbox), */
332 /* GTK_WIDGET (text)); */
333 gtk_widget_show(GTK_WIDGET (text
));
336 return warning_dialog
;
342 *create_error_dialog (gchar
* message
344 /*-----------------------------------------------------------------------------
347 GtkDialog
*error_dialog
;
353 error_dialog
= GTK_DIALOG( gtk_dialog_new_with_buttons
357 | GTK_DIALOG_DESTROY_WITH_PARENT
,
358 GTK_STOCK_OK
, GTK_RESPONSE_NONE
,
361 g_signal_connect_swapped (GTK_DIALOG (error_dialog
),
363 G_CALLBACK (gtk_widget_destroy
),
367 * BUGFIX: probably not necessary as OK button connect with
369 /* g_signal_connect( error_box, */
371 /* G_CALLBACK(on_error_response), */
375 hbox
= g_object_new(GTK_TYPE_HBOX
,
378 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(error_dialog
)->vbox
),
380 gtk_widget_show(GTK_WIDGET (hbox
));
385 icon
= g_object_new(GTK_TYPE_IMAGE
,
386 "stock", GTK_STOCK_DIALOG_ERROR
,
387 "icon-size", GTK_ICON_SIZE_DIALOG
,
391 gtk_box_pack_start (GTK_BOX (hbox
),
396 gtk_widget_show(GTK_WIDGET (icon
));
401 text
= g_object_new(GTK_TYPE_LABEL
,
406 gtk_box_pack_start (GTK_BOX (hbox
),
411 gtk_widget_show(GTK_WIDGET (text
));
419 *create_close_buffer_dialog (GpivConsole
* gpiv
,
423 /*-----------------------------------------------------------------------------
426 GtkDialog
*close_buffer_dialog
;
431 close_buffer_dialog
= GTK_DIALOG(gtk_dialog_new_with_buttons
432 ("gpiv close_buffer",
433 GTK_WINDOW (gpiv
->console
),
434 GTK_DIALOG_DESTROY_WITH_PARENT
,
435 GTK_STOCK_NO
, GTK_RESPONSE_REJECT
,
436 GTK_STOCK_YES
, GTK_RESPONSE_ACCEPT
,
439 g_signal_connect (close_buffer_dialog
,
441 G_CALLBACK (on_close_buffer_response
),
444 g_signal_connect_swapped (GTK_DIALOG (close_buffer_dialog
),
446 G_CALLBACK (gtk_widget_destroy
),
447 close_buffer_dialog
);
450 hbox
= g_object_new(GTK_TYPE_HBOX
,
453 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(close_buffer_dialog
)->vbox
),
455 gtk_widget_show(GTK_WIDGET (hbox
));
460 icon
= g_object_new(GTK_TYPE_IMAGE
,
461 "stock", /* GTK_STOCK_DIALOG_QUESTION */ GTK_STOCK_DIALOG_WARNING
,
462 "icon-size", GTK_ICON_SIZE_DIALOG
,
466 gtk_box_pack_start (GTK_BOX(hbox
),
471 gtk_widget_show(GTK_WIDGET (icon
));
476 text
= g_object_new(GTK_TYPE_LABEL
,
481 gtk_box_pack_start (GTK_BOX(hbox
),
486 gtk_widget_show(GTK_WIDGET (text
));
488 gtk_object_set_data (GTK_OBJECT (close_buffer_dialog
),
491 gtk_object_set_data (GTK_OBJECT (close_buffer_dialog
),
496 return close_buffer_dialog
;