mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
87684f9549
2001-05-25 Havoc Pennington <hp@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): get sizes an icon set can render without falling back to missing image icon * gtk/gtktextview.c (gtk_text_view_size_request): request full size of text, instead of random values * gtk/gtktreeview.c (gtk_tree_view_size_request): request full size of tree view, instead of random values * gtk/gtkiconfactory.c (gtk_icon_set_render_icon): render fallback image in an appropriate size * gtk/gtkstock.h: Rename the stock items including _BUTTON_, etc. not to include that. i.e. s/GTK_STOCK_BUTTON_OK/GTK_STOCK_OK/ Throughout: fix GTK_STOCK_BUTTON_ instances * gtk/gtkstock.h, gtk/gtkstock.c, gtk/gtkiconfactory.h, gtk/gtkiconfactory.c, gtk/stock-icons/Makefile.am: Add a bunch of new stock items/icons * gtk/gtktreeview.c (gtk_tree_view_insert_column_with_data_func): new function, convenience for inserting columns with a data func * gtk/gtkiconfactory.c: keep a list of all existing icon factories (_gtk_icon_factory_list_ids): use list of all factories to generate a list of all known IDs * gtk/gtkstock.c (gtk_stock_list_ids): replace gtk_stock_list_items() with a function that returns all IDs known including those for GtkIconFactory.
177 lines
5.5 KiB
C
177 lines
5.5 KiB
C
/* Dialog and Message Boxes
|
|
*
|
|
* Dialog widgets are used to pop up a transient window for user feedback.
|
|
*/
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
static GtkWidget *window = NULL;
|
|
static GtkWidget *entry1 = NULL;
|
|
static GtkWidget *entry2 = NULL;
|
|
|
|
static void
|
|
message_dialog_clicked (GtkButton *button,
|
|
gpointer user_data)
|
|
{
|
|
GtkWidget *dialog;
|
|
static gint i = 1;
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
GTK_MESSAGE_INFO,
|
|
GTK_BUTTONS_OK,
|
|
"This message box has been popped up the following\n"
|
|
"number of times:\n\n"
|
|
"%d", i);
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
gtk_widget_destroy (dialog);
|
|
i++;
|
|
}
|
|
|
|
static void
|
|
interactive_dialog_clicked (GtkButton *button,
|
|
gpointer user_data)
|
|
{
|
|
GtkWidget *dialog;
|
|
GtkWidget *hbox;
|
|
GtkWidget *stock;
|
|
GtkWidget *table;
|
|
GtkWidget *local_entry1;
|
|
GtkWidget *local_entry2;
|
|
GtkWidget *label;
|
|
gint response;
|
|
|
|
dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
|
|
GTK_WINDOW (window),
|
|
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
GTK_STOCK_OK,
|
|
GTK_RESPONSE_OK,
|
|
NULL);
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
stock = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
|
|
gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 0);
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
|
|
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
|
label,
|
|
0, 1, 0, 1);
|
|
local_entry1 = gtk_entry_new ();
|
|
gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1)));
|
|
gtk_table_attach_defaults (GTK_TABLE (table), local_entry1, 1, 2, 0, 1);
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry1);
|
|
|
|
label = gtk_label_new_with_mnemonic ("E_ntry 2");
|
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
|
label,
|
|
0, 1, 1, 2);
|
|
|
|
local_entry2 = gtk_entry_new ();
|
|
gtk_entry_set_text (GTK_ENTRY (local_entry2), gtk_entry_get_text (GTK_ENTRY (entry2)));
|
|
gtk_table_attach_defaults (GTK_TABLE (table), local_entry2, 1, 2, 1, 2);
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry2);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
|
|
|
if (response == GTK_RESPONSE_OK)
|
|
{
|
|
gtk_entry_set_text (GTK_ENTRY (entry1), gtk_entry_get_text (GTK_ENTRY (local_entry1)));
|
|
gtk_entry_set_text (GTK_ENTRY (entry2), gtk_entry_get_text (GTK_ENTRY (local_entry2)));
|
|
}
|
|
|
|
gtk_widget_destroy (dialog);
|
|
}
|
|
|
|
GtkWidget *
|
|
do_dialog (void)
|
|
{
|
|
GtkWidget *frame;
|
|
GtkWidget *vbox;
|
|
GtkWidget *vbox2;
|
|
GtkWidget *hbox;
|
|
GtkWidget *button;
|
|
GtkWidget *table;
|
|
GtkWidget *label;
|
|
|
|
if (!window)
|
|
{
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
gtk_window_set_title (GTK_WINDOW (window), "Dialogs");
|
|
|
|
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
|
|
|
frame = gtk_frame_new ("Dialogs");
|
|
gtk_container_add (GTK_CONTAINER (window), frame);
|
|
|
|
vbox = gtk_vbox_new (FALSE, 8);
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
/* Standard message dialog */
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
button = gtk_button_new_with_mnemonic ("_Message Dialog");
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
GTK_SIGNAL_FUNC (message_dialog_clicked), NULL);
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
|
|
|
|
/* Interactive dialog*/
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
vbox2 = gtk_vbox_new (FALSE, 0);
|
|
|
|
button = gtk_button_new_with_mnemonic ("_Interactive Dialog");
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
GTK_SIGNAL_FUNC (interactive_dialog_clicked), NULL);
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
|
|
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
|
|
|
|
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
|
label,
|
|
0, 1, 0, 1);
|
|
|
|
entry1 = gtk_entry_new ();
|
|
gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1);
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry1);
|
|
|
|
label = gtk_label_new_with_mnemonic ("E_ntry 2");
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
|
label,
|
|
0, 1, 1, 2);
|
|
|
|
entry2 = gtk_entry_new ();
|
|
gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry2);
|
|
}
|
|
|
|
if (!GTK_WIDGET_VISIBLE (window))
|
|
{
|
|
gtk_widget_show_all (window);
|
|
}
|
|
else
|
|
{
|
|
gtk_widget_destroy (window);
|
|
window = NULL;
|
|
}
|
|
|
|
return window;
|
|
}
|