ruby-****@lists*****
ruby-****@lists*****
2003年 4月 1日 (火) 14:17:26 JST
------------------------- REMOTE_ADDR = 61.204.181.66 REMOTE_HOST = ------------------------- = class Gtk::Dialog Dialog boxes are a convenient way to prompt the user for a small amount of input, eg. to display a message, ask a question, or anything else that does not require extensive effort on the user's part. Ruby/GTK treats a dialog as a window split vertically. The top section is a Gtk::VBox, and is where widgets such as a Gtk::Label or a Gtk::Entry should be packed. The bottom area is known as the action_area. This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a Gtk::HSeparator. Gtk::Dialog boxes are created with a call to Gtk::Dialog.new. If 'dialog' is a newly created dialog, the two primary areas of the window can be accessed as Gtk::Dialog#vbox and Gtk::Dialog#action_area, as can be seen from the example, below. A 'modal' dialog (that is, one which freezes the rest of the application from user input), can be created by calling Gtk::Window#set_modal on the dialog. When using Gtk::Dialog.new you can also pass the Gtk::Dialog::MODAL flag to make a dialog modal. If you add buttons to Gtk::Dialog using Gtk::Dialog.new, Gtk::Dialog#add_button, Gtk::Dialog#add_buttons, or Gtk::Dialog#add_action_widget, clicking the button will emit a signal called "response" with a response ID that you specified. Ruby/GTK will never assign a meaning to positive response IDs; these are entirely user-defined. But for convenience, you can use the response IDs in the GtkResponseType enumeration (these all have values less than zero). If a dialog receives a delete event, the "response" signal will be emitted with a response ID of Gtk::RESPONSE_NONE. If you want to block waiting for a dialog to return before returning control flow to your code, you can call Gtk::Dialog#run. This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked. For the simple dialog in the following example, in reality you'd probably use Gtk::MessageDialog to save yourself some effort. But you'd need to create the dialog contents manually if you had more than a simple message in the dialog. == super class * Gtk::Window == class methods --- Gtk::Dialog.new(title = nil, parent = nil, flags = nil, [button_face1, response_id1], [button_face2, response_id2], .....) Creates a new Gtk::Dialog with title title (or nil for the default title; see * title : Title of the dialog, or nil * parent : Transient parent of the dialog, or nil * flags : From GtkDialogFlags. The flags argument can be used to make the dialog modal (Gtk::Dialog::MODAL) and/or to have it destroyed along with its transient parent (Gtk::Dialog::DESTROY_WITH_PARENT). * [button_face1, response_id1], [button_face2, response_id2], ...: Button face/response ID pairs should be listed. * button_face: Button face can be either a stock ID<Gtk::Stock constants) such as Gtk::Stock::OK, or some arbitrary text. * response_id: A response ID can be any positive number, or one of the values in the GtkResponseType enumeration. If the user clicks one of these dialog buttons, Gtk::Dialog will emit the "response" signal with the corresponding response ID. If a Gtk::Dialog receives the "delete_event" signal, it will emit "response" with a response ID of Gtk::Dialog::RESPONSE_DELETE_EVENT. However, destroying a dialog does not emit the "response" signal; so be careful relying on "response" when using the Gtk::Dialog::DESTROY_WITH_PARENT flag. Buttons are from left to right, so the first button in the list will be the leftmost button in the dialog. * Returns : a new Gtk::Dialog dialog = Gtk::Dialog.new("My dialog", main_app_window, Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT, [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stcok::CANCEL, Gtk::Dialog::RESPONSE_REJECT]) == public instance methods --- run Blocks in a recursive main loop until the dialog either emits the response signal, or is destroyed. If the dialog is destroyed during the call to Gtk::Dialog#run, Gtk::Dialog returns Gtk::Dialog::RESPONSE_NONE. Otherwise, it returns the response ID from the "response" signal emission. Before entering the recursive main loop, Gtk::Dialog#run calls Gtk::Widget#show on the dialog for you. Note that you still need to show any children of the dialog yourself. During Gtk::Dialog#run, the default behavior of "delete_event" is disabled; if the dialog receives "delete_event", it will not be destroyed as windows usually are, and Gtk::Dialog#run() will return Gtk::Dialog#RESPONSE_DELETE_EVENT. Also, during Gtk::Dialog#run the dialog will be modal. You can force Gtk::Dialog#run to return at any time by calling Gtk::Dialog#response to emit the "response" signal. Destroying the dialog during Gtk::Dialog#run is a very bad idea, because your post-run code won't know whether the dialog was destroyed or not. After Gtk::Dialog#run returns, you are responsible for hiding or destroying the dialog if you wish to do so. Typical usage of this function might be: result = dialog.run case result when Gtk::RESPONSE_ACCEPT do_application_specific_something() else do_nothing_since_dialog_was_cancelled() end dialog.destroy * Returns : response ID --- response(response_id) Emits the "response" signal with the given response ID. Used to indicate that the user has responded to the dialog in some way; typically either you or Gtk::Dialog#run will be monitoring the "response" signal and take appropriate action. * response_id : response ID * Returns: self --- add_button(button_face, response_id) Adds a button with the given text (or a stock button, if button_face is a stock ID<Gtk::Stock constants)) and sets things up so that clicking the button will emit the "response" signal with the given response_id. The button is appended to the end of the dialog's action area. The button widget is returned, but usually you don't need it. * button_face: text of button, or stock ID * response_id: response ID for the button * Returns : the button widget that was added --- add_buttons([button_face1, response_id1], [button_face2, response_id2], ...) Adds more buttons, same as calling Gtk::Dialog#add_button repeatedly. * button_face: text of button, or stock ID * response_id: response ID for the button * Returns: self --- add_action_widget(child, response_id) Adds an activatable widget to the action area of a Gtk::Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated. The widget is appended to the end of the dialog's action area. If you want to add a non-activatable widget, simply pack it into the action_area field of the Gtk::Dialog struct. * child: an activatable widget * response_id: response ID for child * Returns: self. --- has_separator? Accessor for whether the dialog has a separator. * Returns: true if the dialog has a separator --- has_separator=(setting) Sets whether the dialog has a separator above the buttons. true by default. * setting: true to have a separator * Returns: setting --- set_has_separator(setting) Same as has_separator=. * setting: true to have a separator * Returns: self --- set_response_sensitive(response_id, setting) Calls Gtk::Widget#set_sensitive for each widget in the dialog's action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons. * response_id : a response ID * setting: true for sensitive * Returns: self --- default_response=(response_id) Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog. Pressing "Enter" normally activates the default widget. * response_id: a response ID * Returns: response_id --- set_default_response(response_id) Same as default_response=. * response_id: a response ID * Returns: self --- vbox vbox is a Gtk::VBox - the main part of the dialog box. * Returns: vbox --- action_area action_area is a Gtk::HButtonBox packed below the dividing Gtk::HSeparator in the dialog. It is treated exactly the same as any other. * Returns: action_area == constants === GtkDialogFlags --- MODAL Call Gtk::Window#set_modal(true). --- DESTROY_WITH_PARENT Call Gtk::Window#set_destroy_with_parent. --- NO_SEPARATOR No separator bar above buttons. === GtkResponseType These are returned from Ruby/GTK dialogs, and you can also use them yourself if you like. --- RESPONSE_NONE Ruby/GTK returns this if a response widget has no response_id, or if the dialog gets programmatically hidden or destroyed. --- RESPONSE_REJECT --- RESPONSE_ACCEPT --- RESPONSE_DELETE_EVENT the dialog is deleted. --- RESPONSE_OK --- RESPONSE_CANCEL --- RESPONSE_CLOSE --- RESPONSE_YES --- RESPONSE_NO --- RESPONSE_APPLY --- RESPONSE_HELP == signals --- close: self * self: Gtk::Dialog --- response: self, response_id * self: Gtk::Dialog * response_id: the response_id - ((<Masao>)) ------------------------- = class Gtk::Dialog Dialog boxes are a convenient way to prompt the user for a small amount of input, eg. to display a message, ask a question, or anything else that does not require extensive effort on the user's part. Ruby/GTK treats a dialog as a window split vertically. The top section is a Gtk::VBox, and is where widgets such as a Gtk::Label or a Gtk::Entry should be packed. The bottom area is known as the action_area. This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a Gtk::HSeparator. Gtk::Dialog boxes are created with a call to Gtk::Dialog.new. If 'dialog' is a newly created dialog, the two primary areas of the window can be accessed as Gtk::Dialog#vbox and Gtk::Dialog#action_area, as can be seen from the example, below. A 'modal' dialog (that is, one which freezes the rest of the application from user input), can be created by calling Gtk::Window#set_modal on the dialog. When using Gtk::Dialog.new you can also pass the Gtk::Dialog::MODAL flag to make a dialog modal. If you add buttons to Gtk::Dialog using Gtk::Dialog.new, Gtk::Dialog#add_button, Gtk::Dialog#add_buttons, or Gtk::Dialog#add_action_widget, clicking the button will emit a signal called "response" with a response ID that you specified. Ruby/GTK will never assign a meaning to positive response IDs; these are entirely user-defined. But for convenience, you can use the response IDs in the ((<GtkResponseType|Gtk::Dialog#GtkResponseType>)) enumeration (these all have values less than zero). If a dialog receives a delete event, the "response" signal will be emitted with a response ID of Gtk::Dialog::RESPONSE_NONE. If you want to block waiting for a dialog to return before returning control flow to your code, you can call Gtk::Dialog#run. This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked. For the simple dialog in the following example, in reality you'd probably use Gtk::MessageDialog to save yourself some effort. But you'd need to create the dialog contents manually if you had more than a simple message in the dialog. == super class * Gtk::Window == class methods --- Gtk::Dialog.new(title = nil, parent = nil, flags = nil, [button_face1, response_id1], [button_face2, response_id2], .....) Creates a new Gtk::Dialog with title title (or nil for the default title; see * title : Title of the dialog, or nil * parent : Transient parent of the dialog, or nil * flags : From ((<GtkDialogFlags|Gtk::Dialog#GtkDialogFlags>)). The flags argument can be used to make the dialog modal (Gtk::Dialog::MODAL) and/or to have it destroyed along with its transient parent (Gtk::Dialog::DESTROY_WITH_PARENT). * [button_face1, response_id1], [button_face2, response_id2], ...: Button face/response ID pairs should be listed. * button_face: Button face can be either a stock ID(Gtk::Stock constants) such as Gtk::Stock::OK, or some arbitrary text. * response_id: A response ID can be any positive number, or one of the values in the ((<GtkResponseType|Gtk::Dialog#GtkResponseType>)) enumeration. If the user clicks one of these dialog buttons, Gtk::Dialog will emit the "response" signal with the corresponding response ID. If a Gtk::Dialog receives the "delete_event" signal, it will emit "response" with a response ID of Gtk::Dialog::RESPONSE_DELETE_EVENT. However, destroying a dialog does not emit the "response" signal; so be careful relying on "response" when using the Gtk::Dialog::DESTROY_WITH_PARENT flag. Buttons are from left to right, so the first button in the list will be the leftmost button in the dialog. * Returns : a new Gtk::Dialog dialog = Gtk::Dialog.new("My dialog", main_app_window, Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT, [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stcok::CANCEL, Gtk::Dialog::RESPONSE_REJECT]) == public instance methods --- run Blocks in a recursive main loop until the dialog either emits the response signal, or is destroyed. If the dialog is destroyed during the call to Gtk::Dialog#run, Gtk::Dialog returns Gtk::Dialog::RESPONSE_NONE. Otherwise, it returns the response ID from the "response" signal emission. Before entering the recursive main loop, Gtk::Dialog#run calls Gtk::Widget#show on the dialog for you. Note that you still need to show any children of the dialog yourself. During Gtk::Dialog#run, the default behavior of "delete_event" is disabled; if the dialog receives "delete_event", it will not be destroyed as windows usually are, and Gtk::Dialog#run will return Gtk::Dialog#RESPONSE_DELETE_EVENT. Also, during Gtk::Dialog#run the dialog will be modal. You can force Gtk::Dialog#run to return at any time by calling Gtk::Dialog#response to emit the "response" signal. Destroying the dialog during Gtk::Dialog#run is a very bad idea, because your post-run code won't know whether the dialog was destroyed or not. After Gtk::Dialog#run returns, you are responsible for hiding or destroying the dialog if you wish to do so. Typical usage of this function might be: result = dialog.run case result when Gtk::RESPONSE_ACCEPT do_application_specific_something() else do_nothing_since_dialog_was_cancelled() end dialog.destroy * Returns : response ID --- response(response_id) Emits the "response" signal with the given response ID. Used to indicate that the user has responded to the dialog in some way; typically either you or Gtk::Dialog#run will be monitoring the "response" signal and take appropriate action. * response_id : response ID * Returns: self --- add_button(button_face, response_id) Adds a button with the given text (or a stock button, if button_face is a stock ID<Gtk::Stock constants)) and sets things up so that clicking the button will emit the "response" signal with the given response_id. The button is appended to the end of the dialog's action area. The button widget is returned, but usually you don't need it. * button_face: text of button, or stock ID * response_id: response ID for the button * Returns : the button widget that was added --- add_buttons([button_face1, response_id1], [button_face2, response_id2], ...) Adds more buttons, same as calling Gtk::Dialog#add_button repeatedly. * button_face: text of button, or stock ID * response_id: response ID for the button * Returns: self --- add_action_widget(child, response_id) Adds an activatable widget to the action area of a Gtk::Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated. The widget is appended to the end of the dialog's action area. If you want to add a non-activatable widget, simply pack it into the action_area field of the Gtk::Dialog struct. * child: an activatable widget * response_id: response ID for child * Returns: self. --- has_separator? Accessor for whether the dialog has a separator. * Returns: true if the dialog has a separator --- has_separator=(setting) Sets whether the dialog has a separator above the buttons. true by default. * setting: true to have a separator * Returns: setting --- set_has_separator(setting) Same as has_separator=. * setting: true to have a separator * Returns: self --- set_response_sensitive(response_id, setting) Calls Gtk::Widget#set_sensitive for each widget in the dialog's action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons. * response_id : a response ID * setting: true for sensitive * Returns: self --- default_response=(response_id) Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog. Pressing "Enter" normally activates the default widget. * response_id: a response ID * Returns: response_id --- set_default_response(response_id) Same as default_response=. * response_id: a response ID * Returns: self --- vbox vbox is a Gtk::VBox - the main part of the dialog box. * Returns: vbox --- action_area action_area is a Gtk::HButtonBox packed below the dividing Gtk::HSeparator in the dialog. It is treated exactly the same as any other. * Returns: action_area == constants === GtkDialogFlags --- MODAL Call Gtk::Window#set_modal(true). --- DESTROY_WITH_PARENT Call Gtk::Window#set_destroy_with_parent. --- NO_SEPARATOR No separator bar above buttons. === GtkResponseType These are returned from Ruby/GTK dialogs, and you can also use them yourself if you like. --- RESPONSE_NONE Ruby/GTK returns this if a response widget has no response_id, or if the dialog gets programmatically hidden or destroyed. --- RESPONSE_REJECT --- RESPONSE_ACCEPT --- RESPONSE_DELETE_EVENT the dialog is deleted. --- RESPONSE_OK --- RESPONSE_CANCEL --- RESPONSE_CLOSE --- RESPONSE_YES --- RESPONSE_NO --- RESPONSE_APPLY --- RESPONSE_HELP == signals --- close: self * self: Gtk::Dialog --- response: self, response_id * self: Gtk::Dialog * response_id: the response_id - ((<Masao>))