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
  
/* -*- C -*- */ 
require gnome; 
class Gnome.Dialog; 
inherit GTK.Window; 
//! Gnome.Dialog gives dialogs a consistent look and feel, while making 
//! them more convenient to program. Gnome.Dialog makes it easy to use 
//! stock buttons, makes it easier to handle delete_event, and adds 
//! some cosmetic touches (such as a separator above the buttons, and a 
//! bevel around the edge of the window). 
 
signal clicked; 
signal close; 
 
member GTK.Vbox vbox; 
 
void create(string title, string ... buttons) 
//! Creates a new Gnome.Dialog, with the given title, and any button 
//! names in the arg list. Buttons can be simple names, such as "My 
//! Button", or gnome-stock defines such as GNOME.StockButtonOK, 
//! etc. The last argument should be NULL to terminate the list. 
//! <p> 
//! Buttons passed to this function are numbered from left to right, 
//! starting with 0. So the first button in the arglist is button 0, 
//! then button 1, etc. These numbers are used throughout the 
//! Gnome.Dialog API. 
//! </p> 
{ 
  gchar *title; 
  gchar **buttons; 
  int i; 
  pgtk2_verify_gnome_setup(); 
  pgtk2_verify_not_inited(); 
  if(!PGTK_ISSTR(Pike_sp - args ) ) 
    Pike_error( "Bad argument 1, expected string (title)\n"); 
  title = PGTK_GETSTR( Pike_sp - args ); 
  buttons = g_malloc( args*sizeof( char *) ); 
  buttons[args-1] = NULL; 
  for( i = 1; i<args; i++ ) 
    if( !PGTK_ISSTR( &Pike_sp[-args+i] ) ) 
    { 
      int j; 
      for( j = 1; j<i; j++ )  PGTK_FREESTR( buttons[j-1] ); 
      PGTK_FREESTR( title ); 
      g_free( buttons ); 
      Pike_error( "Bad argument %d, should be string\n", i ); 
    } 
    else 
      buttons[i-1] = PGTK_GETSTR( &Pike_sp[-args+i] ); 
  THIS->obj = GTK_OBJECT( gnome_dialog_newv( (const gchar *)title, 
                                             (const gchar **)buttons ) ); 
  PGTK_FREESTR( title ); 
  pgtk2__init_object( Pike_fp->current_object ); 
  for( i = 0; i<args-1; i++ ) 
    PGTK_FREESTR( buttons[i] ); 
  g_free( buttons ); 
  pop_n_elems( args ); 
  push_int( 0 ); 
} 
 
void set_parent( GTK.Window parent ); 
//! Dialogs have "parents," usually the main application window which 
//! spawned them. This function will let the window manager know about 
//! the parent-child relationship. Usually this means the dialog must 
//! stay on top of the parent, and will be minimized when the parent 
//! is. Gnome also allows users to request dialog placement above the 
//! parent window (vs. at the mouse position, or at a default window 
//! manger location). 
 
void button_connect( int button, function(callback) callback ); 
//! Simply a signal_connect to the "clicked" signal of the specified button. 
 
int  run( ); 
//! Blocks until the user clicks a button or closes the dialog with 
//! the window manager's close decoration (or by pressing Escape). 
//! <p> 
//! You need to set up the dialog to do the right thing when a button 
//! is clicked or delete_event is received; you must consider both of 
//! those possibilities so that you know the status of the dialog when 
//! run() returns. A common mistake is to forget about Escape and the 
//! window manager close decoration; by default, these call close(), 
//! which by default destroys the dialog. If your button clicks do not 
//! destroy the dialog, you don't know whether the dialog is destroyed 
//! when run() returns. This is bad. 
//! </p><p> 
//! So you should either close the dialog on button clicks as well, or 
//! change the close() behavior to hide instead of destroy. You can do 
//! this with close_hides(). 
//! </p> 
 
int run_and_close( ); 
//! See run(). The only difference is that this function calls close() 
//! before returning if the dialog was not already closed. 
 
void set_default( int button ); 
//! The default button will be activated if the user just presses 
//! return. Usually you should make the least-destructive button the 
//! default. Otherwise, the most commonly-used button. 
 
void set_sensitive( int button, int sensitive ); 
//! Calls set_sensitive() on the specified button number. 
 
void set_accelerator( int button, int accelerator_key, int accelerator_mode); 
 
void close(); 
//! See also close_hides(). This function emits the "close" signal( 
//! which either hides or destroys the dialog (destroy by default). If 
//! you connect to the "close" signal, and your callback returns TRUE, 
//! the hide or destroy will be blocked. You can do this to avoid 
//! closing the dialog if the user gives invalid input, for example. 
//! <p> 
//! Using close() in place of hide() or _destruct() allows you to easily 
//! catch all sources of dialog closure, including delete_event and 
//! button clicks, and handle them in a central location. </p> 
 
void set_close( int click_closes ); 
//! This is a convenience function so you don't have to connect 
//! callbacks to each button just to close the dialog. By default, 
//! Gnome.Dialog has this parameter set the FALSE and it will not close 
//! on any click. (This was a design error.) However, almost all the 
//! Gnome.Dialog subclasses, such as Gnome.MessageBox and 
//! Gnome.PropertyBox, have this parameter set to TRUE by default. 
 
void editable_enters( GTK.Editable widget ); 
//! Normally if there's an editable widget (such as GtkEntry) in your 
//! dialog, pressing Enter will activate the editable rather than the 
//! default dialog button. However, in most cases, the user expects to 
//! type something in and then press enter to close the dialog. This 
//! function enables that behavior. 
 
void append_button_with_pixmap( string name, string pixmap_file );