create some stock buttons with the default accel group (create_image):

2000-10-04  Havoc Pennington  <hp@redhat.com>

	* gtk/testgtk.c (create_buttons): create some stock buttons
	with the default accel group
	(create_image): test some new GtkImage features
	(make_message_dialog): test GtkMessageDialog
	(create_modal_window): fix someone's bizzarro indentation

        * gtk/gtkwindow.h, gtk/gtkwindow.c: Implement
	GTK_WIN_POS_CENTER_ON_PARENT.
	Add "destroy with parent" setting, which means the window goes
	away with its transient parent.
	(gtk_window_get_default_accel_group): get the default accel group
	for the window.
	(gtk_window_set_destroy_with_parent): set/unset destroy with
	parent flag
	(gtk_window_read_rcfiles): invalidate icon set caches
	after reloading rcfiles

	* gtk/gtkenums.h (GtkWindowPosition): add
	GTK_WIN_POS_CENTER_ON_PARENT, which centers a dialog
	on its parent window when the dialog is mapped for the first time.

        * gtk/gtkmessagedialog.h, gtk/gtkmessagedialog.c: Add
	a simple message dialog class

	* gtk/gtkdialog.c (gtk_dialog_init): Connect delete event
	handler to emit response signal, and maybe later it would
	honor a hide_on_delete flag - though that isn't there yet.
	Set border width on the vbox to 2, so we get some padding.
	Use a button box for the action area.
	(gtk_dialog_key_press): synthesize a delete event if Esc
	is pressed and the GtkWidget key press handler didn't
	handle the escape key.
	(gtk_dialog_new_with_buttons): new function creates a dialog
	with some default buttons in it.
	(gtk_dialog_add_action_widget): add an activatable widget
	as a button in the dialog - you can also add a non-activatable
	widget by accessing the action area directly.
	(gtk_dialog_add_button): add a simple button - stock ID or
	label - to the action area
	(gtk_dialog_response): emit response signal
	(gtk_dialog_run): block waiting for the dialog, return
	the response. Override normal delete_event behavior, so that
	delete_event does nothing inside gtk_dialog_run().

	* gtk/gtkdialog.h, gtk/gtkdialog.c: Add "response" signal
	emitted when an action widget is clicked or the dialog gets
	delete_event

	* gtk/gtk.h: add gtkmessagedialog.h

	* gtk/Makefile.am: add gtkmessagedialog.[hc]

2000-10-20  Havoc Pennington  <hp@redhat.com>

	* gtk/gtk-sections.txt: Add dialog docs
This commit is contained in:
Havoc Pennington
2000-10-20 23:14:41 +00:00
committed by Havoc Pennington
parent 779e461e89
commit 1c9f0c0bac
29 changed files with 1990 additions and 122 deletions

View File

@ -605,8 +605,14 @@ GTK_DATA_GET_CLASS
<FILE>gtkdialog</FILE>
GtkDialog
<TITLE>GtkDialog</TITLE>
GtkDialogButton
GtkDialogFlags
gtk_dialog_new
gtk_dialog_new_with_buttons
gtk_dialog_run
gtk_dialog_response
gtk_dialog_add_button
gtk_dialog_add_buttons
gtk_dialog_add_action_widget
<SUBSECTION Standard>
GTK_DIALOG
GTK_IS_DIALOG
@ -1295,6 +1301,23 @@ GTK_IS_MENU_SHELL_CLASS
GTK_MENU_SHELL_GET_CLASS
</SECTION>
<SECTION>
<FILE>gtkmessagedialog</FILE>
GtkMessageDialog
<TITLE>GtkMessageDialog</TITLE>
GtkMessageType
GtkButtonsType
gtk_message_dialog_new
<SUBSECTION Standard>
GTK_MESSAGE_DIALOG
GTK_IS_MESSAGE_DIALOG
GTK_TYPE_MESSAGE_DIALOG
gtk_message_dialog_get_type
GTK_MESSAGE_DIALOG_CLASS
GTK_IS_MESSAGE_DIALOG_CLASS
GTK_MESSAGE_DIALOG_GET_CLASS
</SECTION>
<SECTION>
<FILE>gtkmisc</FILE>
<TITLE>GtkMisc</TITLE>
@ -2590,6 +2613,7 @@ gtk_window_set_default_size
gtk_window_set_geometry_hints
gtk_window_set_position
gtk_window_set_transient_for
gtk_window_set_destroy_with_parent
gtk_window_list_toplevels
<SUBSECTION Standard>
GTK_WINDOW

View File

@ -149,13 +149,6 @@ A structure used to return values from @gtk_type_query.
@object_size:
@class_size:
<!-- ##### MACRO gtk_widget_pop_visual ##### -->
<para>
</para>
@v:
<!-- ##### FUNCTION gtk_text_buffer_get_clipboard_contents ##### -->
<para>
@ -164,6 +157,13 @@ A structure used to return values from @gtk_type_query.
@buffer:
@Returns:
<!-- ##### MACRO gtk_widget_pop_visual ##### -->
<para>
</para>
@v:
<!-- ##### FUNCTION gtk_marshal_NONE__C_CALLBACK ##### -->
<para>
@ -443,6 +443,12 @@ will not be used again.
@textview: the object which received the signal.
<!-- ##### STRUCT GtkDialogButton ##### -->
<para>
Deprecated.
</para>
<!-- ##### FUNCTION gtk_marshal_BOOL__POINTER ##### -->
<para>
@ -612,16 +618,6 @@ will not be used again.
@func_data:
@args:
<!-- ##### FUNCTION gtk_paned_compute_position ##### -->
<para>
Internal function used by #GtkHPaned and #GtkVPaned
</para>
@paned:
@allocation:
@child1_req:
@child2_req:
<!-- ##### FUNCTION gtk_marshal_NONE__INT_FLOAT_BOOL ##### -->
<para>
@ -632,6 +628,16 @@ Internal function used by #GtkHPaned and #GtkVPaned
@func_data:
@args:
<!-- ##### FUNCTION gtk_paned_compute_position ##### -->
<para>
Internal function used by #GtkHPaned and #GtkVPaned
</para>
@paned:
@allocation:
@child1_req:
@child2_req:
<!-- ##### MACRO gtk_marshal_NONE__POINTER_STRING_STRING ##### -->
<para>
@ -719,14 +725,6 @@ Register a new set of flags @values and give them the name in
@values: GtkFlagValue*
@Returns:
<!-- ##### SIGNAL GtkTextView::scroll-text ##### -->
<para>
</para>
@textview: the object which received the signal.
@arg1:
<!-- ##### FUNCTION gtk_selection_clear_targets ##### -->
<para>
@ -735,6 +733,14 @@ Register a new set of flags @values and give them the name in
@widget:
@selection:
<!-- ##### SIGNAL GtkTextView::scroll-text ##### -->
<para>
</para>
@textview: the object which received the signal.
@arg1:
<!-- ##### ENUM GtkPrivateFlags ##### -->
<para>
@ -949,8 +955,7 @@ Get the varargs type associated with @foreign_type
</para>
@clipboard:
@Returns:
<!--
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gtk-docs.sgml" "book" "refsect2" "")
@ -1325,14 +1330,6 @@ gtkenums.sgml
@func_data:
@args:
<!-- ##### USER_FUNCTION GtkMenuCallback ##### -->
<para>
</para>
@widget:
@user_data:
<!-- ##### FUNCTION gtk_type_check_object_cast ##### -->
<para>
Given a pointer to a GtkTypeObject @type_object, and a GtkType @cast_type,
@ -1343,6 +1340,14 @@ make sure that it's okay to cast @type_object into a @cast_type.
@cast_type: GtkType
@Returns: the same GtkTypeObject* as @type_object
<!-- ##### USER_FUNCTION GtkMenuCallback ##### -->
<para>
</para>
@widget:
@user_data:
<!-- ##### FUNCTION gtk_themes_exit ##### -->
<para>
@ -1381,13 +1386,13 @@ will be informed that the attempt to get the data failed.
@user_data_or_owner: the @user_data argument passed to gtk_clipboard_set_with_data(), or
the @owner argument passed to gtk_clipboard_set_owner()
<!-- ##### SECTION ./tmpl/gtkmenufactory.sgml:Long_Description ##### -->
<!-- ##### MACRO gtk_marshal_NONE__OBJECT ##### -->
<para>
</para>
<!-- ##### MACRO gtk_marshal_NONE__OBJECT ##### -->
<!-- ##### SECTION ./tmpl/gtkmenufactory.sgml:Long_Description ##### -->
<para>
</para>
@ -1637,13 +1642,12 @@ Internal function.
</para>
<!-- ##### MACRO gtk_widget_push_visual ##### -->
<!-- ##### FUNCTION gtk_container_register_toplevel ##### -->
<para>
</para>
@v:
@visual:
@container:
<!-- ##### MACRO gtk_marshal_ENUM__ENUM ##### -->
<para>
@ -1651,12 +1655,13 @@ Internal function.
</para>
<!-- ##### FUNCTION gtk_container_register_toplevel ##### -->
<!-- ##### MACRO gtk_widget_push_visual ##### -->
<para>
</para>
@container:
@v:
@visual:
<!-- ##### SECTION ./tmpl/gtkimcontextsimple.sgml:Title ##### -->
GtkIMContextSimple

View File

@ -6,56 +6,91 @@ GtkDialog
create popup windows.
<!-- ##### SECTION Long_Description ##### -->
<para>
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.
input, eg. to display a message, ask a question, or anything else that does not
require extensive effort on the user's part.
</para>
<para>
Gtk+ treats a dialog as a window split horizontally. The top section is a
#GtkVBox, and is where widgets such as a #GtkLabel or a #GtkEntry should be
packed. The second area is known as the <structfield>action_area</structfield>. 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 #GtkHSeparator.
packed. The second area is known as the
<structfield>action_area</structfield>. 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 #GtkHSeparator.
</para>
<para>
#GtkDialog boxes are created with a call to gtk_dialog_new().
#GtkDialog boxes are created with a call to gtk_dialog_new() or
gtk_dialog_new_with_buttons(). gtk_dialog_new_with_buttons() is recommended; it
allows you to set the dialog title, some convenient flags, and add simple
buttons.
</para>
<para>
If 'dialog' is a newly created dialog, the two primary areas of the window
can be accessed as GTK_DIALOG(dialog)->vbox and GTK_DIALOG(dialog)->action_area,
as can be seen from the example, below.
</para>
<para>
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. Use the
GTK_WINDOW() macro to cast the widget returned from gtk_dialog_new() into a
#GtkWindow.
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. Use
the GTK_WINDOW() macro to cast the widget returned from gtk_dialog_new() into a
#GtkWindow. When using gtk_dialog_new_with_buttons() you can also pass the
GTK_DIALOG_MODAL flag to make a dialog modal.
</para>
<para>
If you add buttons to #GtkDialog using gtk_dialog_new_with_buttons(),
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. 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.
</para>
<para>
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.
</para>
<para>
For the simple dialog in the following example, in reality you'd probably use
#GtkMessageDialog 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.
<example>
<title>Using a #GtkDialog to keep the user informed.</title>
<title>Simple #GtkDialog usage.</title>
<programlisting>
/* Function to open a dialog box displaying the message provided. */
void quick_message(#gchar *message) {
#GtkWidget *dialog, *label, *okay_button;
#GtkWidget *dialog, *label;
/* Create the widgets */
dialog = gtk_dialog_new();
dialog = gtk_dialog_new_with_buttons ("Message",
main_application_window,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_BUTTON_OK,
GTK_RESPONSE_NONE,
NULL);
label = gtk_label_new (message);
okay_button = gtk_button_new_with_label("Okay");
/* Ensure that the dialog box is destroyed when the user clicks ok. */
/* Ensure that the dialog box is destroyed when the user responds. */
gtk_signal_connect_object (GTK_OBJECT (okay_button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy), dialog);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
okay_button);
gtk_signal_connect_object (GTK_OBJECT (dialog), "response",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (dialog));
/* Add the label, and show everything we've added to the dialog. */
@ -102,11 +137,13 @@ gtk_window_set_title(). See the #GtkWindow section for more).
</para>
<!-- ##### STRUCT GtkDialogButton ##### -->
<!-- ##### ENUM GtkDialogFlags ##### -->
<para>
Deprecated.
</para>
@GTK_DIALOG_MODAL:
@GTK_DIALOG_DESTROY_WITH_PARENT:
<!-- ##### FUNCTION gtk_dialog_new ##### -->
<para>
@ -117,3 +154,77 @@ directly, but into the vbox and action_area, as described above.
@Returns: a #GtkWidget - the newly created dialog box.
<!-- ##### FUNCTION gtk_dialog_new_with_buttons ##### -->
<para>
</para>
@title:
@parent:
@flags:
@first_button_text:
@Varargs:
@Returns:
<!-- ##### FUNCTION gtk_dialog_run ##### -->
<para>
</para>
@dialog:
@Returns:
<!-- ##### FUNCTION gtk_dialog_response ##### -->
<para>
</para>
@dialog:
@response_id:
<!-- ##### FUNCTION gtk_dialog_add_button ##### -->
<para>
</para>
@dialog:
@button_text:
@response_id:
<!-- ##### FUNCTION gtk_dialog_add_buttons ##### -->
<para>
</para>
@dialog:
@first_button_text:
@Varargs:
<!-- ##### FUNCTION gtk_dialog_add_action_widget ##### -->
<para>
</para>
@dialog:
@child:
@response_id:
<!-- # Unused Parameters # -->
@widget:
<!-- ##### SIGNAL GtkDialog::response ##### -->
<para>
Emitted when an action widget is clicked, the dialog receives a delete event, or
the application programmer calls gtk_dialog_response(). On a delete event, the
response ID is GTK_RESPONSE_NONE. Otherwise, it depends on which action widget
was clicked.
</para>
@dialog: the object which received the signal.
@arg1: the response ID

View File

@ -322,6 +322,7 @@ Window placement can be influenced using this enumeration.
@GTK_WIN_POS_CENTER: Windows should be placed in the center of the screen.
@GTK_WIN_POS_MOUSE: Windows should be placed at the current mouse position.
@GTK_WIN_POS_CENTER_ALWAYS:
@GTK_WIN_POS_CENTER_ON_PARENT:
<!-- ##### ENUM GtkWindowType ##### -->
<para>

View File

@ -266,7 +266,7 @@ elements are:
</listitem>
</varlistentry>
<varlistentry>
<term><literal>stock[<replaceable>"stock-id"</replaceable>]</literal> = { <replaceable>icon source specifications</replaceable> }</literal></term>
<term><literal>stock[<replaceable>"stock-id"</replaceable>] = { <replaceable>icon source specifications</replaceable> }</literal></term>
<listitem>
<para>
Defines the icon for a stock item.
@ -327,7 +327,7 @@ state of the widget. The states are:
<listitem>
<para>
A color used for the background of widgets that have
been set insenstivie with gtk_widget_set_senstive()
been set insensitive with gtk_widget_set_sensitive()
</para>
</listitem>
</varlistentry>

View File

@ -55,3 +55,12 @@ gtktextmark
@mark:
<!-- ##### FUNCTION gtk_text_mark_get_deleted ##### -->
<para>
</para>
@mark:
@Returns:

View File

@ -219,6 +219,15 @@ it's larger
@parent:
<!-- ##### FUNCTION gtk_window_set_destroy_with_parent ##### -->
<para>
</para>
@window:
@setting:
<!-- ##### FUNCTION gtk_window_list_toplevels ##### -->
<para>
@ -280,3 +289,8 @@ The position of the window.
</para>
<!-- ##### ARG GtkWindow:destroy_with_parent ##### -->
<para>
</para>