~ubuntu-branches/ubuntu/karmic/sanduhr/karmic

« back to all changes in this revision

Viewing changes to src/winutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Voss
  • Date: 2002-04-12 16:33:03 UTC
  • Revision ID: james.westby@ubuntu.com-20020412163303-xn0v3utm5xcyux60
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* winutil.c - window/dialog related helper functions
 
2
 *
 
3
 * Copyright (C) 2002  Jochen Voss.  */
 
4
 
 
5
static const  char  rcsid[] = "$Id: winutil.c,v 1.1 2002/02/22 19:03:21 voss Rel $";
 
6
 
 
7
#ifdef HAVE_CONFIG_H
 
8
#  include <config.h>
 
9
#endif
 
10
 
 
11
#include <gnome.h>
 
12
 
 
13
#include "sandcommon.h"
 
14
 
 
15
 
 
16
/**********************************************************************
 
17
 * callback functions
 
18
 */
 
19
 
 
20
void
 
21
window_show_cb (GtkObject *obj, gpointer data)
 
22
/* A wrapper for 'main_loop_ref'.
 
23
 * This may be used as a "show" signal handler.  */
 
24
{
 
25
  main_loop_ref ();
 
26
}
 
27
 
 
28
void
 
29
window_destroy_cb (GtkObject *obj, gpointer data)
 
30
/* A wrapper for 'main_loop_unref'.
 
31
 * This may be used as a "destroy" signal handler.  */
 
32
{
 
33
  main_loop_unref ();
 
34
}
 
35
 
 
36
gint
 
37
window_close_cb (GtkObject *obj, gpointer data)
 
38
/* A wrapper for 'main_loop_unref'.
 
39
 * This may be used as a "close" signal handler
 
40
 * for GnomeDialog objects.  */
 
41
{
 
42
  main_loop_unref ();
 
43
  return  0;
 
44
}
 
45
 
 
46
/**********************************************************************
 
47
 * dialog helpers
 
48
 */
 
49
 
 
50
void
 
51
display_error_message (const char *str, GtkWindow *parent)
 
52
/* Create a modal dialog to display the error message STR.
 
53
 * If PARENT is non-null, create a parented dialog.  */
 
54
{
 
55
  GtkWidget *dialog;
 
56
  
 
57
  if (parent) {
 
58
    dialog = gnome_error_dialog_parented (str, parent);
 
59
  } else {
 
60
    dialog = gnome_error_dialog (str);
 
61
  }
 
62
  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 
63
 
 
64
  main_loop_ref ();
 
65
  gtk_signal_connect (GTK_OBJECT (dialog),
 
66
                      "close",
 
67
                      GTK_SIGNAL_FUNC (window_close_cb),
 
68
                      NULL);
 
69
  gtk_widget_show (dialog);
 
70
  gdk_beep ();
 
71
}
 
72
 
 
73
gint
 
74
ask_yes_no_question (const char *str, GtkWindow *parent)
 
75
/* Display a modal dialog with question STR.
 
76
 * Return 0, if the user clicks YES,
 
77
 *        1, if the user clicks NO, and
 
78
 *       -1, if the user closes the dialog.  */
 
79
{
 
80
  GtkWidget *dialog;
 
81
 
 
82
  dialog = gnome_message_box_new (str, GNOME_MESSAGE_BOX_QUESTION,
 
83
                                  GNOME_STOCK_BUTTON_YES,
 
84
                                  GNOME_STOCK_BUTTON_NO,
 
85
                                  NULL);
 
86
  if (parent)  gnome_dialog_set_parent (GNOME_DIALOG(dialog), parent);
 
87
  gtk_widget_show_all (dialog);
 
88
  return  gnome_dialog_run (GNOME_DIALOG (dialog));
 
89
}