#endif
#define GTK_ENABLE_BROKEN
-#include "gtk.h"
+#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
GtkWidget *omenu;
GtkWidget *menu;
GtkWidget *menu_item;
+ GSList *group;
gint i;
omenu = gtk_option_menu_new ();
menu = gtk_menu_new ();
+ group = NULL;
for (i = 0; i < num_items; i++)
{
- menu_item = gtk_menu_item_new_with_label (items[i].name);
+ menu_item = gtk_radio_menu_item_new_with_label (group, items[i].name);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) items[i].func, data);
+ group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menu_item));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ if (i == history)
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
gtk_widget_show (menu_item);
}
if (!window)
{
- GtkAccelGroup *accel_group;
-
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- accel_group = gtk_window_get_default_accel_group (GTK_WINDOW (window));
-
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&window);
gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);
button[0] = gtk_button_new_with_label ("button1");
- button[1] = gtk_button_new_accel ("_button2", accel_group);
- button[2] = gtk_button_new_with_label ("button3");
- button[3] = gtk_button_new_stock (GTK_STOCK_BUTTON_OK, NULL);
+ button[1] = gtk_button_new_with_mnemonic ("_button2");
+ button[2] = gtk_button_new_with_mnemonic ("_button3");
+ button[3] = gtk_button_new_from_stock (GTK_STOCK_BUTTON_OK);
button[4] = gtk_button_new_with_label ("button5");
button[5] = gtk_button_new_with_label ("button6");
button[6] = gtk_button_new_with_label ("button7");
- button[7] = gtk_button_new_stock (GTK_STOCK_BUTTON_CLOSE, accel_group);
+ button[7] = gtk_button_new_from_stock (GTK_STOCK_BUTTON_CLOSE);
button[8] = gtk_button_new_with_label ("button9");
gtk_signal_connect (GTK_OBJECT (button[0]), "clicked",
gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
- button = gtk_check_button_new_with_label ("button1");
+ button = gtk_check_button_new_with_mnemonic ("_button1");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
button = gtk_check_button_new_with_label ("button2");
return wpixmap;
}
+
+static void
+set_toolbar_small_stock (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR (data), GTK_ICON_SIZE_SMALL_TOOLBAR);
+}
+
+static void
+set_toolbar_large_stock (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR (data), GTK_ICON_SIZE_LARGE_TOOLBAR);
+}
+
static void
set_toolbar_horizontal (GtkWidget *widget,
gpointer data)
gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH_HORIZ);
}
-static void
-set_toolbar_small_space (GtkWidget *widget,
- gpointer data)
-{
- gtk_toolbar_set_space_size (GTK_TOOLBAR (data), 5);
-}
-
-static void
-set_toolbar_big_space (GtkWidget *widget,
- gpointer data)
-{
- gtk_toolbar_set_space_size (GTK_TOOLBAR (data), 10);
-}
-
static void
set_toolbar_enable (GtkWidget *widget,
gpointer data)
gtk_toolbar_set_tooltips (GTK_TOOLBAR (data), FALSE);
}
-static void
-set_toolbar_borders (GtkWidget *widget,
- gpointer data)
-{
- gtk_toolbar_set_button_relief (GTK_TOOLBAR (data), GTK_RELIEF_NORMAL);
-}
-
-static void
-set_toolbar_borderless (GtkWidget *widget,
- gpointer data)
-{
- gtk_toolbar_set_button_relief (GTK_TOOLBAR (data), GTK_RELIEF_NONE);
-}
-
-static void
-set_toolbar_space_style_empty (GtkWidget *widget,
- gpointer data)
-{
- gtk_toolbar_set_space_style (GTK_TOOLBAR (data), GTK_TOOLBAR_SPACE_EMPTY);
-}
-
-static void
-set_toolbar_space_style_line (GtkWidget *widget,
- gpointer data)
-{
- gtk_toolbar_set_space_style (GTK_TOOLBAR (data), GTK_TOOLBAR_SPACE_LINE);
-}
-
static void
create_toolbar (void)
{
gtk_widget_realize (window);
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
- gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE);
+ gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
+ GTK_STOCK_NEW,
+ "Stock icon: New", "Toolbar/New",
+ (GtkSignalFunc) set_toolbar_small_stock, toolbar, -1);
+
+ gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
+ GTK_STOCK_OPEN,
+ "Stock icon: Open", "Toolbar/Open",
+ (GtkSignalFunc) set_toolbar_large_stock, toolbar, -1);
+
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
"Horizontal", "Horizontal toolbar layout", "Toolbar/Horizontal",
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
- gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Small", "Use small spaces", "Toolbar/Small",
- new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_small_space, toolbar);
- gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Big", "Use big spaces", "Toolbar/Big",
- new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_big_space, toolbar);
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Borders", "Show Borders", NULL,
+ "Frobate", "Frobate tooltip", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_borders, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Borderless", "Hide Borders", NULL,
+ "Baz", "Baz tooltip", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_borderless, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Empty", "Empty spaces", NULL,
+ "Blah", "Blah tooltip", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_space_style_empty, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Lines", "Lines in spaces", NULL,
+ "Bar", "Bar tooltip", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_space_style_line, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_container_add (GTK_CONTAINER (window), toolbar);
}
gtk_widget_realize (window);
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
- gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
"Horizontal", "Horizontal toolbar layout", NULL,
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Small", "Use small spaces", NULL,
+ "Woot", "Woot woot woot", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_small_space, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Big", "Use big spaces", "Toolbar/Big",
+ "Blah", "Blah blah blah", "Toolbar/Big",
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_big_space, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Borders", "Show Borders", NULL,
+ "Hoo", "Hoo tooltip", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_borders, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
- "Borderless", "Hide Borders", NULL,
+ "Woo", "Woo tooltip", NULL,
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
- (GtkSignalFunc) set_toolbar_borderless, toolbar);
+ (GtkSignalFunc) NULL, toolbar);
return toolbar;
}
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (box5), label, FALSE, TRUE, 0);
- adj = (GtkAdjustment *) gtk_adjustment_new ((gfloat)DEFAULT_NUMBER_OF_ITEM, 1.0, 255.0, 1.0,
+ adj = (GtkAdjustment *) gtk_adjustment_new (DEFAULT_NUMBER_OF_ITEM, 1.0, 255.0, 1.0,
5.0, 0.0);
spinner = gtk_spin_button_new (adj, 0, 0);
gtk_box_pack_start (GTK_BOX (box5), spinner, FALSE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (box5), label, FALSE, TRUE, 0);
- adj = (GtkAdjustment *) gtk_adjustment_new ((gfloat)DEFAULT_RECURSION_LEVEL, 0.0, 255.0, 1.0,
+ adj = (GtkAdjustment *) gtk_adjustment_new (DEFAULT_RECURSION_LEVEL, 0.0, 255.0, 1.0,
5.0, 0.0);
spinner = gtk_spin_button_new (adj, 0, 0);
gtk_box_pack_start (GTK_BOX (box5), spinner, FALSE, TRUE, 0);
gtk_widget_show (handle_box);
toolbar = make_toolbar (window);
- gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NORMAL);
+
gtk_container_add (GTK_CONTAINER (handle_box), toolbar);
gtk_widget_show (toolbar);
if (!window)
{
- guint keyval;
-
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
/* There's also a gtk_label_set_markup() without accel if you
* don't have an accelerator key
*/
- keyval =
- gtk_label_set_markup_with_accel (GTK_LABEL (label),
- "This <span foreground=\"blue\" background=\"orange\">label</span> has "
- "<b>markup</b> _such as "
- "<big><i>Big Italics</i></big>\n"
- "<tt>Monospace font</tt>\n"
- "<u>Underline!</u>\n"
- "foo\n"
- "<span foreground=\"green\" background=\"red\">Ugly colors</span>\n"
- "and nothing on this line,\n"
- "or this.\n"
- "or this either\n"
- "or even on this one\n"
- "la <big>la <big>la <big>la <big>la</big></big></big></big>\n"
- "but this _word is <span foreground=\"purple\"><big>purple</big></span>\n"
- "<span underline=\"double\">We like <sup>superscript</sup> and <sub>subscript</sub> too</span>");
-
- g_return_if_fail (keyval == GDK_s);
+ gtk_label_set_markup_with_mnemonic (GTK_LABEL (label),
+ "This <span foreground=\"blue\" background=\"orange\">label</span> has "
+ "<b>markup</b> _such as "
+ "<big><i>Big Italics</i></big>\n"
+ "<tt>Monospace font</tt>\n"
+ "<u>Underline!</u>\n"
+ "foo\n"
+ "<span foreground=\"green\" background=\"red\">Ugly colors</span>\n"
+ "and nothing on this line,\n"
+ "or this.\n"
+ "or this either\n"
+ "or even on this one\n"
+ "la <big>la <big>la <big>la <big>la</big></big></big></big>\n"
+ "but this _word is <span foreground=\"purple\"><big>purple</big></span>\n"
+ "<span underline=\"double\">We like <sup>superscript</sup> and <sub>subscript</sub> too</span>");
+
+ g_assert (gtk_label_get_mnemonic_keyval (GTK_LABEL (label)) == GDK_s);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
GtkObject *window)
{
if (toggle->active)
- gtk_signal_handler_block_by_func (window, uposition_configure, NULL);
+ gtk_signal_handler_block_by_func (window, GTK_SIGNAL_FUNC (uposition_configure), NULL);
else
- gtk_signal_handler_unblock_by_func (window, uposition_configure, NULL);
+ gtk_signal_handler_unblock_by_func (window, GTK_SIGNAL_FUNC (uposition_configure), NULL);
}
static void
GdkBitmap *mask;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ /* this is bogus for testing drawing when allocation < request,
+ * don't copy into real code
+ */
+ gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
menu = create_menu (1, 5, FALSE);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
+ menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, accel_group);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_widget_show (menuitem);
+
menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
g_message ("ItemFactory: activated \"%s\"", gtk_item_factory_path_from_widget (widget));
}
+/* This file was automatically generated by the make-inline-pixbuf program.
+ * It contains inline RGB image data.
+ */
+static const guchar apple[] =
+{
+ /* File magic (1197763408) */
+ 0x47, 0x64, 0x6b, 0x50,
+ /* Format of following stuff (0) */
+ 0x00, 0x00, 0x00, 0x00,
+ /* Rowstride (64) */
+ 0x00, 0x00, 0x00, 0x40,
+ /* Width (16) */
+ 0x00, 0x00, 0x00, 0x10,
+ /* Height (16) */
+ 0x00, 0x00, 0x00, 0x10,
+ /* Has an alpha channel (TRUE) */
+ 0x01,
+ /* Colorspace (0 == RGB, no other options implemented) (0) */
+ 0x00, 0x00, 0x00, 0x00,
+ /* Number of channels (4) */
+ 0x00, 0x00, 0x00, 0x04,
+ /* Bits per sample (8) */
+ 0x00, 0x00, 0x00, 0x08,
+ /* Image data */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x14, 0x0f, 0x04,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x61, 0x6d, 0x5b, 0x2b, 0x6e, 0x7c, 0x61, 0xd9,
+ 0x71, 0x80, 0x63, 0xd7, 0x5f, 0x6b, 0x5b, 0x35, 0x00, 0x00, 0x00, 0x00,
+ 0x3a, 0x35, 0x28, 0x8f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x6c, 0x5c, 0x07, 0x6d, 0x7b, 0x61, 0xd8,
+ 0x75, 0x84, 0x65, 0xf6, 0x76, 0x86, 0x66, 0xf7, 0x6a, 0x77, 0x60, 0xec,
+ 0x5e, 0x6a, 0x58, 0x47, 0x1c, 0x1a, 0x13, 0xa2, 0x4b, 0x47, 0x30, 0x07,
+ 0x55, 0x4e, 0x33, 0x21, 0x48, 0x3e, 0x2a, 0x08, 0xd0, 0xb8, 0x84, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0x76, 0x5f, 0x74,
+ 0x75, 0x84, 0x65, 0xf3, 0x67, 0x75, 0x5e, 0xc4, 0x69, 0x62, 0x55, 0x75,
+ 0x94, 0x50, 0x50, 0x69, 0x75, 0x5c, 0x52, 0xb2, 0x69, 0x38, 0x34, 0xa2,
+ 0xa7, 0x5b, 0x53, 0xea, 0xa3, 0x52, 0x4f, 0xff, 0x90, 0x47, 0x42, 0xfa,
+ 0x76, 0x44, 0x36, 0xb9, 0x59, 0x38, 0x29, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x6b, 0x5a, 0x09,
+ 0x69, 0x76, 0x5e, 0xb0, 0x5f, 0x6b, 0x59, 0x57, 0x9a, 0x4b, 0x4d, 0x5b,
+ 0xb8, 0x5f, 0x63, 0xfa, 0xcc, 0x7d, 0x7e, 0xff, 0xc5, 0x69, 0x68, 0xff,
+ 0xc7, 0x6b, 0x67, 0xff, 0xc5, 0x6f, 0x67, 0xff, 0xba, 0x5e, 0x5a, 0xff,
+ 0xb1, 0x4d, 0x4d, 0xff, 0x92, 0x4b, 0x42, 0xff, 0x6a, 0x3e, 0x30, 0xfc,
+ 0x5c, 0x3b, 0x27, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5d, 0x69, 0x57, 0x09, 0x5d, 0x69, 0x57, 0x09, 0x92, 0x47, 0x46, 0x1e,
+ 0xba, 0x65, 0x64, 0xf4, 0xe7, 0xbf, 0xc0, 0xff, 0xdf, 0xa5, 0xa3, 0xff,
+ 0xd4, 0x84, 0x81, 0xff, 0xd1, 0x7c, 0x76, 0xff, 0xc9, 0x78, 0x6d, 0xff,
+ 0xbb, 0x6a, 0x5d, 0xff, 0xb3, 0x5a, 0x52, 0xff, 0x9f, 0x4b, 0x47, 0xff,
+ 0x78, 0x45, 0x35, 0xff, 0x5f, 0x3c, 0x28, 0xfa, 0x53, 0x5a, 0x38, 0x24,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xa1, 0x54, 0x4d, 0x8c, 0xcf, 0x8e, 0x89, 0xff, 0xe3, 0xb1, 0xae, 0xff,
+ 0xd8, 0x94, 0x8e, 0xff, 0xd3, 0x8a, 0x82, 0xff, 0xcf, 0x80, 0x76, 0xff,
+ 0xc4, 0x75, 0x67, 0xff, 0xb7, 0x6c, 0x5c, 0xff, 0xab, 0x5e, 0x51, 0xff,
+ 0x9c, 0x4c, 0x46, 0xff, 0x7e, 0x4a, 0x3a, 0xff, 0x5c, 0x3c, 0x26, 0xff,
+ 0x58, 0x3d, 0x28, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xa2, 0x59, 0x4f, 0xc3, 0xcd, 0x8e, 0x88, 0xff,
+ 0xd3, 0x93, 0x8c, 0xff, 0xd0, 0x8c, 0x83, 0xff, 0xcc, 0x84, 0x79, 0xff,
+ 0xc7, 0x7c, 0x6e, 0xff, 0xbc, 0x73, 0x61, 0xff, 0xb1, 0x6b, 0x59, 0xff,
+ 0xa3, 0x5f, 0x4f, 0xff, 0x93, 0x50, 0x44, 0xff, 0x78, 0x48, 0x35, 0xff,
+ 0x59, 0x3b, 0x25, 0xff, 0x4f, 0x3d, 0x28, 0x4f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9b, 0x5b, 0x4d, 0xbc,
+ 0xbd, 0x7e, 0x72, 0xff, 0xc6, 0x86, 0x7a, 0xff, 0xc5, 0x7f, 0x72, 0xff,
+ 0xc2, 0x7b, 0x6c, 0xff, 0xbf, 0x77, 0x63, 0xff, 0xb7, 0x72, 0x5b, 0xff,
+ 0xa9, 0x6b, 0x53, 0xff, 0x9a, 0x60, 0x4b, 0xff, 0x8b, 0x56, 0x41, 0xff,
+ 0x6a, 0x44, 0x2e, 0xff, 0x53, 0x38, 0x21, 0xfd, 0x42, 0x4b, 0x2e, 0x1a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x8e, 0x57, 0x48, 0x6e, 0xa6, 0x6b, 0x5a, 0xff, 0xb3, 0x74, 0x62, 0xff,
+ 0xb8, 0x75, 0x61, 0xff, 0xba, 0x76, 0x61, 0xff, 0xb7, 0x74, 0x5c, 0xff,
+ 0xae, 0x6e, 0x54, 0xff, 0x9f, 0x67, 0x4c, 0xff, 0x90, 0x5d, 0x43, 0xff,
+ 0x79, 0x4d, 0x38, 0xff, 0x5c, 0x3d, 0x25, 0xff, 0x50, 0x39, 0x23, 0xb8,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x52, 0x43, 0x07, 0x92, 0x5c, 0x47, 0xdc,
+ 0x9e, 0x64, 0x4e, 0xff, 0xa8, 0x6b, 0x52, 0xff, 0xaa, 0x6d, 0x53, 0xff,
+ 0xa7, 0x6d, 0x50, 0xff, 0x9c, 0x67, 0x4a, 0xff, 0x8e, 0x5d, 0x41, 0xff,
+ 0x7d, 0x54, 0x3a, 0xff, 0x6a, 0x4b, 0x32, 0xff, 0x51, 0x39, 0x23, 0xff,
+ 0x28, 0x20, 0x12, 0x77, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x6f, 0x4a, 0x37, 0x2a, 0x81, 0x54, 0x3d, 0xec, 0x8b, 0x5a, 0x41, 0xff,
+ 0x8b, 0x5a, 0x3f, 0xff, 0x85, 0x56, 0x3c, 0xff, 0x7d, 0x52, 0x38, 0xff,
+ 0x77, 0x51, 0x33, 0xff, 0x6f, 0x4e, 0x34, 0xff, 0x5f, 0x45, 0x2c, 0xff,
+ 0x2e, 0x21, 0x14, 0xff, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x92,
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x11, 0x0b, 0x08, 0xb4,
+ 0x50, 0x37, 0x25, 0xfe, 0x6d, 0x49, 0x2f, 0xff, 0x52, 0x37, 0x22, 0xff,
+ 0x50, 0x37, 0x21, 0xff, 0x66, 0x45, 0x2b, 0xff, 0x60, 0x46, 0x2c, 0xff,
+ 0x2d, 0x22, 0x16, 0xff, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xd2,
+ 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x64, 0x09, 0x0a, 0x07, 0xa4,
+ 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xc4,
+ 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x6c,
+ 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0d,
+ 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+
+static void
+dump_accels (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ gtk_item_factory_dump_items (NULL, FALSE, gtk_item_factory_print_func, stdout);
+}
+
static GtkItemFactoryEntry menu_items[] =
{
- { "/_File", NULL, 0, 0, "<Branch>" },
- { "/File/tearoff1", NULL, gtk_ifactory_cb, 0, "<Tearoff>" },
- { "/File/_New", "<control>N", gtk_ifactory_cb, 0 },
- { "/File/_Open", "<control>O", gtk_ifactory_cb, 0 },
- { "/File/_Save", "<control>S", gtk_ifactory_cb, 0 },
- { "/File/Save _As...", NULL, gtk_ifactory_cb, 0 },
- { "/File/sep1", NULL, gtk_ifactory_cb, 0, "<Separator>" },
- { "/File/_Quit", "<control>Q", gtk_ifactory_cb, 0 },
+ { "/_File", NULL, 0, 0, "<Branch>" },
+ { "/File/tearoff1", NULL, gtk_ifactory_cb, 0, "<Tearoff>" },
+ { "/File/_New", NULL, gtk_ifactory_cb, 0, "<StockItem>", GTK_STOCK_NEW },
+ { "/File/_Open", NULL, gtk_ifactory_cb, 0, "<StockItem>", GTK_STOCK_OPEN },
+ { "/File/_Save", NULL, gtk_ifactory_cb, 0, "<StockItem>", GTK_STOCK_SAVE },
+ { "/File/Save _As...", "<control>A", gtk_ifactory_cb, 0, "<StockItem>", GTK_STOCK_SAVE },
+ { "/File/_Dump \"_Accels\"", NULL, dump_accels, 0 },
+ { "/File/\\/Test__Escaping/And\\/\n\tWei\\\\rdly",
+ NULL, gtk_ifactory_cb, 0 },
+ { "/File/sep1", NULL, gtk_ifactory_cb, 0, "<Separator>" },
+ { "/File/_Quit", NULL, gtk_ifactory_cb, 0, "<StockItem>", GTK_STOCK_QUIT },
{ "/_Preferences", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
{ "/_Preferences/Shape/_Oval", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Rectangle" },
{ "/_Preferences/Shape/_Rectangle", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Square" },
{ "/_Preferences/Shape/_Oval", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Rectangle" },
+ { "/_Preferences/Shape/_Image", NULL, gtk_ifactory_cb, 0, "<ImageItem>", (gchar**) apple, sizeof(apple) },
/* For testing deletion of menus */
{ "/_Preferences/Should_NotAppear", NULL, 0, 0, "<Branch>" },
{ "/Preferences/ShouldNotAppear/SubItem2", NULL, gtk_ifactory_cb, 0 },
{ "/_Help", NULL, 0, 0, "<LastBranch>" },
+ { "/Help/_Help", NULL, gtk_ifactory_cb, 0, "<StockItem>", GTK_STOCK_HELP},
{ "/Help/_About", NULL, gtk_ifactory_cb, 0 },
};
csd=gtk_color_selection_dialog_new ("This is a modal color selection dialog");
+ gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (csd)->colorsel),
+ TRUE);
+
/* Set as modal */
gtk_window_set_modal (GTK_WINDOW(csd),TRUE);
cb = gtk_combo_new ();
gtk_combo_set_popdown_strings (GTK_COMBO (cb), cbitems);
- gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(cb)->entry), "hello world");
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(cb)->entry), "hello world \n\n\n foo");
gtk_editable_select_region (GTK_EDITABLE (GTK_COMBO(cb)->entry),
0, -1);
gtk_box_pack_start (GTK_BOX (box2), cb, TRUE, TRUE, 0);
gtk_label_set_text (label, buf);
}
+static void
+get_spin_value (GtkWidget *widget, gpointer data)
+{
+ gchar *buffer;
+ GtkLabel *label;
+ GtkSpinButton *spin;
+
+ spin = GTK_SPIN_BUTTON (widget);
+ label = GTK_LABEL (data);
+
+ buffer = g_strdup_printf ("%0.*f", spin->digits,
+ gtk_spin_button_get_value_as_float (spin));
+ gtk_label_set_text (label, buffer);
+
+ g_free (buffer);
+}
+
static gint
spin_button_time_output_func (GtkSpinButton *spin_button)
{
static gchar buf[6];
- gfloat hours;
- gfloat minutes;
+ gdouble hours;
+ gdouble minutes;
hours = spin_button->adjustment->value / 60.0;
minutes = (fabs(floor (hours) - hours) < 1e-5) ? 0.0 : 30;
static gint
spin_button_month_input_func (GtkSpinButton *spin_button,
- gfloat *new_val)
+ gdouble *new_val)
{
gint i;
static gchar *month[12] = { "January", "February", "March", "April",
*new_val = 0.0;
return GTK_INPUT_ERROR;
}
- *new_val = (gfloat) i;
+ *new_val = (gdouble) i;
return TRUE;
}
static gint
spin_button_hex_input_func (GtkSpinButton *spin_button,
- gfloat *new_val)
+ gdouble *new_val)
{
gchar *buf;
gchar *err;
- gfloat res;
+ gdouble res;
buf = gtk_entry_get_text (GTK_ENTRY (spin_button));
- res = (gfloat)(strtol(buf, &err, 16));
+ res = strtol(buf, &err, 16);
*new_val = res;
if (*err)
return GTK_INPUT_ERROR;
gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
gtk_label_set_text (GTK_LABEL (val_label), "0");
+ frame = gtk_frame_new ("Using Convenience Constructor");
+ gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_container_add (GTK_CONTAINER (frame), hbox);
+
+ val_label = gtk_label_new ("0.0");
+
+ spinner = gtk_spin_button_new_with_range (0.0, 10.0, 0.009);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinner), 0.0);
+ gtk_signal_connect (GTK_OBJECT (spinner), "value_changed",
+ GTK_SIGNAL_FUNC (get_spin_value), val_label);
+ gtk_box_pack_start (GTK_BOX (hbox), spinner, TRUE, TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (hbox), val_label, TRUE, TRUE, 5);
+
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
c &= 0xfe;
label = gtk_object_get_user_data (GTK_OBJECT (spinner));
- vals = gtk_type_enum_get_values (GTK_TYPE_GDK_CURSOR_TYPE);
+ vals = gtk_type_enum_get_values (GDK_TYPE_CURSOR_TYPE);
while (vals && vals->value != c)
vals++;
if (vals)
static OptionMenuItem items[] =
{
- { "Single", list_toggle_sel_mode },
- { "Browse", list_toggle_sel_mode },
- { "Multiple", list_toggle_sel_mode },
- { "Extended", list_toggle_sel_mode }
+ { "Single", GTK_SIGNAL_FUNC (list_toggle_sel_mode) },
+ { "Browse", GTK_SIGNAL_FUNC (list_toggle_sel_mode) },
+ { "Multiple", GTK_SIGNAL_FUNC (list_toggle_sel_mode) },
+ { "Extended", GTK_SIGNAL_FUNC (list_toggle_sel_mode) }
};
if (!window)
static OptionMenuItem items[] =
{
- { "Single", clist_toggle_sel_mode },
- { "Browse", clist_toggle_sel_mode },
- { "Multiple", clist_toggle_sel_mode },
- { "Extended", clist_toggle_sel_mode }
+ { "Single", GTK_SIGNAL_FUNC (clist_toggle_sel_mode) },
+ { "Browse", GTK_SIGNAL_FUNC (clist_toggle_sel_mode) },
+ { "Multiple", GTK_SIGNAL_FUNC (clist_toggle_sel_mode) },
+ { "Extended", GTK_SIGNAL_FUNC (clist_toggle_sel_mode) }
};
char text[TESTGTK_CLIST_COLUMNS][50];
static OptionMenuItem items1[] =
{
- { "No lines", ctree_toggle_line_style },
- { "Solid", ctree_toggle_line_style },
- { "Dotted", ctree_toggle_line_style },
- { "Tabbed", ctree_toggle_line_style }
+ { "No lines", GTK_SIGNAL_FUNC (ctree_toggle_line_style) },
+ { "Solid", GTK_SIGNAL_FUNC (ctree_toggle_line_style) },
+ { "Dotted", GTK_SIGNAL_FUNC (ctree_toggle_line_style) },
+ { "Tabbed", GTK_SIGNAL_FUNC (ctree_toggle_line_style) }
};
static OptionMenuItem items2[] =
{
- { "None", ctree_toggle_expander_style },
- { "Square", ctree_toggle_expander_style },
- { "Triangle", ctree_toggle_expander_style },
- { "Circular", ctree_toggle_expander_style }
+ { "None", GTK_SIGNAL_FUNC (ctree_toggle_expander_style) },
+ { "Square", GTK_SIGNAL_FUNC (ctree_toggle_expander_style) },
+ { "Triangle", GTK_SIGNAL_FUNC (ctree_toggle_expander_style) },
+ { "Circular", GTK_SIGNAL_FUNC (ctree_toggle_expander_style) }
};
static OptionMenuItem items3[] =
{
- { "Left", ctree_toggle_justify },
- { "Right", ctree_toggle_justify }
+ { "Left", GTK_SIGNAL_FUNC (ctree_toggle_justify) },
+ { "Right", GTK_SIGNAL_FUNC (ctree_toggle_justify) }
};
static OptionMenuItem items4[] =
{
- { "Single", ctree_toggle_sel_mode },
- { "Browse", ctree_toggle_sel_mode },
- { "Multiple", ctree_toggle_sel_mode },
- { "Extended", ctree_toggle_sel_mode }
+ { "Single", GTK_SIGNAL_FUNC (ctree_toggle_sel_mode) },
+ { "Browse", GTK_SIGNAL_FUNC (ctree_toggle_sel_mode) },
+ { "Multiple", GTK_SIGNAL_FUNC (ctree_toggle_sel_mode) },
+ { "Extended", GTK_SIGNAL_FUNC (ctree_toggle_sel_mode) }
};
if (!window)
GtkColorSelection *colorsel;
colorsel = GTK_COLOR_SELECTION (cs->colorsel);
- gtk_color_selection_set_use_opacity (colorsel,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)));
+ gtk_color_selection_set_has_opacity_control (colorsel,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)));
}
static void
GtkColorSelection *colorsel;
colorsel = GTK_COLOR_SELECTION (cs->colorsel);
- gtk_color_selection_set_use_palette (colorsel,
+ gtk_color_selection_set_has_palette (colorsel,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)));
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
- flipping_toggled_cb, FALSE);
+ GTK_SIGNAL_FUNC (flipping_toggled_cb), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (check_button), 10);
gtk_widget_destroy (window);
}
+/*
+ * Focus test
+ */
+
+static GtkWidget*
+make_focus_table (GList **list)
+{
+ GtkWidget *table;
+ gint i, j;
+
+ table = gtk_table_new (5, 5, FALSE);
+
+ i = 0;
+ j = 0;
+
+ while (i < 5)
+ {
+ j = 0;
+ while (j < 5)
+ {
+ GtkWidget *widget;
+
+ if ((i + j) % 2)
+ widget = gtk_entry_new ();
+ else
+ widget = gtk_button_new_with_label ("Foo");
+
+ *list = g_list_prepend (*list, widget);
+
+ gtk_table_attach (GTK_TABLE (table),
+ widget,
+ i, i + 1,
+ j, j + 1,
+ GTK_EXPAND | GTK_FILL,
+ GTK_EXPAND | GTK_FILL,
+ 5, 5);
+
+ ++j;
+ }
+
+ ++i;
+ }
+
+ *list = g_list_reverse (*list);
+
+ return table;
+}
+
+static void
+create_focus (void)
+{
+ static GtkWidget *window = NULL;
+
+ if (!window)
+ {
+ GtkWidget *table;
+ GtkWidget *frame;
+ GList *list = NULL;
+
+ window = gtk_dialog_new_with_buttons ("Keyboard focus navigation",
+ NULL, 0,
+ GTK_STOCK_BUTTON_CLOSE,
+ GTK_RESPONSE_NONE,
+ NULL);
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroyed),
+ &window);
+
+ gtk_signal_connect (GTK_OBJECT (window), "response",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ NULL);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Keyboard Focus Navigation");
+
+ frame = gtk_frame_new ("Weird tab focus chain");
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox),
+ frame, TRUE, TRUE, 0);
+
+ table = make_focus_table (&list);
+
+ gtk_container_add (GTK_CONTAINER (frame), table);
+
+ gtk_container_set_focus_chain (GTK_CONTAINER (table),
+ list);
+
+ g_list_free (list);
+
+ frame = gtk_frame_new ("Default tab focus chain");
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox),
+ frame, TRUE, TRUE, 0);
+
+ list = NULL;
+ table = make_focus_table (&list);
+
+ g_list_free (list);
+
+ gtk_container_add (GTK_CONTAINER (frame), table);
+ }
+
+ if (!GTK_WIDGET_VISIBLE (window))
+ gtk_widget_show_all (window);
+ else
+ gtk_widget_destroy (window);
+}
+
/*
* GtkFontSelection
*/
GtkWidget *pixwid;
gint i;
char buffer[32];
+ char accel_buffer[32];
for (i = start; i <= end; i++)
{
sprintf (buffer, "Page %d", i);
+ sprintf (accel_buffer, "Page _%d", i);
child = gtk_frame_new (buffer);
gtk_container_set_border_width (GTK_CONTAINER (child), 10);
gtk_box_pack_start (GTK_BOX (label_box), pixwid, FALSE, TRUE, 0);
gtk_misc_set_padding (GTK_MISC (pixwid), 3, 1);
- label = gtk_label_new (buffer);
+ label = gtk_label_new_with_mnemonic (accel_buffer);
gtk_box_pack_start (GTK_BOX (label_box), label, FALSE, TRUE, 0);
gtk_widget_show_all (label_box);
-
+
menu_box = gtk_hbox_new (FALSE, 0);
pixwid = gtk_pixmap_new (book_closed, book_closed_mask);
static OptionMenuItem items[] =
{
- { "Standard", standard_notebook },
- { "No tabs", notabs_notebook },
- { "Borderless", borderless_notebook },
- { "Scrollable", scrollable_notebook },
+ { "Standard", GTK_SIGNAL_FUNC (standard_notebook) },
+ { "No tabs", GTK_SIGNAL_FUNC (notabs_notebook) },
+ { "Borderless", GTK_SIGNAL_FUNC (borderless_notebook) },
+ { "Scrollable", GTK_SIGNAL_FUNC (scrollable_notebook) },
};
if (!window)
label);
button = gtk_button_new_with_label ("Deiconify");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_deiconify),
GTK_OBJECT (window));
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Iconify");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_iconify),
GTK_OBJECT (window));
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Present");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_present),
GTK_OBJECT (window));
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Show");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_widget_show),
GTK_OBJECT (window));
vbox = gtk_vbox_new (FALSE, 0);
button = gtk_button_new_with_label ("Stick");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_stick),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Unstick");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_unstick),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Maximize");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_maximize),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Unmaximize");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_unmaximize),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Iconify");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_iconify),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Hide (withdraw)");
- gtk_signal_connect_object (GTK_WIDGET (button),
+ gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_widget_hide),
GTK_OBJECT (window));
gtk_container_add (GTK_CONTAINER (window), box1);
iconified = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_iconify (iconified);
+ gtk_window_iconify (GTK_WINDOW (iconified));
gtk_window_set_title (GTK_WINDOW (iconified), "Iconified initially");
controls = get_state_controls (iconified);
gtk_container_add (GTK_CONTAINER (iconified), controls);
gtk_widget_destroy (window);
}
+/*
+ * Window sizing
+ */
+
+static gint
+configure_event_callback (GtkWidget *widget,
+ GdkEventConfigure *event,
+ gpointer data)
+{
+ GtkWidget *label = data;
+ gchar *msg;
+ gint x, y;
+
+ x = widget->allocation.x;
+ y = widget->allocation.y;
+
+ msg = g_strdup_printf ("event: %d,%d %d x %d\n"
+ "location: %d, %d",
+ event->x, event->y, event->width, event->height,
+ x, y);
+
+ gtk_label_set_text (GTK_LABEL (label), msg);
+
+ g_free (msg);
+
+ return FALSE;
+}
+
+static void
+get_ints (GtkWidget *window,
+ gint *a,
+ gint *b)
+{
+ GtkWidget *spin1;
+ GtkWidget *spin2;
+
+ spin1 = g_object_get_data (G_OBJECT (window), "spin1");
+ spin2 = g_object_get_data (G_OBJECT (window), "spin2");
+
+ *a = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin1));
+ *b = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin2));
+}
+
+static void
+set_size_callback (GtkWidget *widget,
+ gpointer data)
+{
+ gint w, h;
+
+ get_ints (data, &w, &h);
+
+ gtk_window_set_default_size (GTK_WINDOW (g_object_get_data (data, "target")), w, h);
+}
+
+static void
+set_default_size_callback (GtkWidget *widget,
+ gpointer data)
+{
+ gint w, h;
+
+ get_ints (data, &w, &h);
+
+ gtk_window_set_default_size (g_object_get_data (data, "target"),
+ w, h);
+}
+
+static void
+set_usize_callback (GtkWidget *widget,
+ gpointer data)
+{
+ gint w, h;
+
+ get_ints (data, &w, &h);
+
+ gtk_widget_set_usize (g_object_get_data (data, "target"),
+ w, h);
+}
+
+static void
+set_location_callback (GtkWidget *widget,
+ gpointer data)
+{
+ gint x, y;
+
+ get_ints (data, &x, &y);
+
+ gtk_widget_set_uposition (g_object_get_data (data, "target"), x, y);
+}
+
+static void
+allow_shrink_callback (GtkWidget *widget,
+ gpointer data)
+{
+ g_object_set (G_OBJECT (g_object_get_data (data, "target")),
+ "allow_shrink",
+ GTK_TOGGLE_BUTTON (widget)->active,
+ NULL);
+}
+
+static void
+allow_grow_callback (GtkWidget *widget,
+ gpointer data)
+{
+ g_object_set (G_OBJECT (g_object_get_data (data, "target")),
+ "allow_grow",
+ GTK_TOGGLE_BUTTON (widget)->active,
+ NULL);
+}
+
+static void
+auto_shrink_callback (GtkWidget *widget,
+ gpointer data)
+{
+ g_object_set (G_OBJECT (g_object_get_data (data, "target")),
+ "auto_shrink",
+ GTK_TOGGLE_BUTTON (widget)->active,
+ NULL);
+}
+
+static void
+gravity_selected (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_window_set_gravity (GTK_WINDOW (g_object_get_data (data, "target")),
+ gtk_option_menu_get_history (GTK_OPTION_MENU (widget)) + GDK_GRAVITY_NORTH_WEST);
+}
+
+static GtkWidget*
+window_controls (GtkWidget *window)
+{
+ GtkWidget *control_window;
+ GtkWidget *label;
+ GtkWidget *vbox;
+ GtkWidget *button;
+ GtkWidget *spin;
+ GtkAdjustment *adj;
+ GtkWidget *om;
+ GtkWidget *menu;
+ gint i;
+
+ control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_title (GTK_WINDOW (control_window), "Size controls");
+
+ g_object_set_data (G_OBJECT (control_window),
+ "target",
+ window);
+
+ gtk_signal_connect_object (GTK_OBJECT (control_window),
+ "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ GTK_OBJECT (window));
+
+ vbox = gtk_vbox_new (FALSE, 5);
+
+ gtk_container_add (GTK_CONTAINER (control_window), vbox);
+
+ label = gtk_label_new ("<no configure events>");
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ gtk_signal_connect (GTK_OBJECT (window),
+ "configure_event",
+ GTK_SIGNAL_FUNC (configure_event_callback),
+ label);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (10.0, -3.0, 800.0, 1.0,
+ 5.0, 0.0);
+ spin = gtk_spin_button_new (adj, 0, 0);
+
+ gtk_box_pack_start (GTK_BOX (vbox), spin, FALSE, FALSE, 0);
+
+ g_object_set_data (G_OBJECT (control_window), "spin1", spin);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (10.0, -3.0, 800.0, 1.0,
+ 5.0, 0.0);
+ spin = gtk_spin_button_new (adj, 0, 0);
+
+ gtk_box_pack_start (GTK_BOX (vbox), spin, FALSE, FALSE, 0);
+
+ g_object_set_data (G_OBJECT (control_window), "spin2", spin);
+
+ button = gtk_button_new_with_label ("Queue resize");
+ gtk_signal_connect_object (GTK_WIDGET (button),
+ "clicked",
+ GTK_SIGNAL_FUNC (gtk_widget_queue_resize),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_button_new_with_label ("Set size");
+ gtk_signal_connect (GTK_WIDGET (button),
+ "clicked",
+ GTK_SIGNAL_FUNC (set_size_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_button_new_with_label ("Set default size");
+ gtk_signal_connect (GTK_WIDGET (button),
+ "clicked",
+ GTK_SIGNAL_FUNC (set_default_size_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_button_new_with_label ("Set usize");
+ gtk_signal_connect (GTK_WIDGET (button),
+ "clicked",
+ GTK_SIGNAL_FUNC (set_usize_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_button_new_with_label ("Set location");
+ gtk_signal_connect (GTK_WIDGET (button),
+ "clicked",
+ GTK_SIGNAL_FUNC (set_location_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_check_button_new_with_label ("Allow shrink");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
+ gtk_signal_connect (GTK_WIDGET (button),
+ "toggled",
+ GTK_SIGNAL_FUNC (allow_shrink_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_check_button_new_with_label ("Allow grow");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_signal_connect (GTK_WIDGET (button),
+ "toggled",
+ GTK_SIGNAL_FUNC (allow_grow_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ button = gtk_check_button_new_with_label ("Auto shrink");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
+ gtk_signal_connect (GTK_WIDGET (button),
+ "toggled",
+ GTK_SIGNAL_FUNC (auto_shrink_callback),
+ GTK_OBJECT (control_window));
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+ menu = gtk_menu_new ();
+
+ i = 0;
+ while (i < 10)
+ {
+ GtkWidget *mi;
+ static gchar *names[] = {
+ "GDK_GRAVITY_NORTH_WEST",
+ "GDK_GRAVITY_NORTH",
+ "GDK_GRAVITY_NORTH_EAST",
+ "GDK_GRAVITY_WEST",
+ "GDK_GRAVITY_CENTER",
+ "GDK_GRAVITY_EAST",
+ "GDK_GRAVITY_SOUTH_WEST",
+ "GDK_GRAVITY_SOUTH",
+ "GDK_GRAVITY_SOUTH_EAST",
+ "GDK_GRAVITY_STATIC",
+ NULL
+ };
+
+ g_assert (names[i]);
+
+ mi = gtk_menu_item_new_with_label (names[i]);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+ ++i;
+ }
+
+ gtk_widget_show_all (menu);
+
+ om = gtk_option_menu_new ();
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu);
+
+
+ gtk_signal_connect (GTK_OBJECT (om),
+ "changed",
+ GTK_SIGNAL_FUNC (gravity_selected),
+ control_window);
+
+ gtk_box_pack_end (GTK_BOX (vbox), om, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (vbox);
+
+ return control_window;
+}
+
+void
+create_window_sizing (void)
+{
+ static GtkWidget *window = NULL;
+
+ if (!window)
+ {
+ GtkWidget *label;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), "<span foreground=\"purple\"><big>Window being resized</big></span>\nBlah blah blah blah\nblah blah blah\nblah blah blah blah blah");
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show (label);
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+ &window);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Window to size");
+
+ gtk_widget_show (window_controls (window));
+ }
+
+ if (!GTK_WIDGET_VISIBLE (window))
+ gtk_widget_show (window);
+ else
+ gtk_widget_destroy (window);
+}
+
/*
* GtkProgressBar
*/
gint
progress_timeout (gpointer data)
{
- gfloat new_val;
+ gdouble new_val;
GtkAdjustment *adj;
adj = GTK_PROGRESS (data)->adjustment;
static OptionMenuItem items1[] =
{
- { "Left-Right", progressbar_toggle_orientation },
- { "Right-Left", progressbar_toggle_orientation },
- { "Bottom-Top", progressbar_toggle_orientation },
- { "Top-Bottom", progressbar_toggle_orientation }
+ { "Left-Right", GTK_SIGNAL_FUNC (progressbar_toggle_orientation) },
+ { "Right-Left", GTK_SIGNAL_FUNC (progressbar_toggle_orientation) },
+ { "Bottom-Top", GTK_SIGNAL_FUNC (progressbar_toggle_orientation) },
+ { "Top-Bottom", GTK_SIGNAL_FUNC (progressbar_toggle_orientation) }
};
static OptionMenuItem items2[] =
{
- { "Continuous", progressbar_toggle_bar_style },
- { "Discrete", progressbar_toggle_bar_style }
+ { "Continuous", GTK_SIGNAL_FUNC (progressbar_toggle_bar_style) },
+ { "Discrete", GTK_SIGNAL_FUNC (progressbar_toggle_bar_style) }
};
if (!pdata)
*/
static int scroll_test_pos = 0.0;
-static GdkGC *scroll_test_gc = NULL;
static gint
scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
scroll_test_scroll (GtkWidget *widget, GdkEventScroll *event,
GtkAdjustment *adj)
{
- gfloat new_value = adj->value + ((event->direction == GDK_SCROLL_UP) ?
- -adj->page_increment / 2:
- adj->page_increment / 2);
+ gdouble new_value = adj->value + ((event->direction == GDK_SCROLL_UP) ?
+ -adj->page_increment / 2:
+ adj->page_increment / 2);
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{
gint source_min = (int)adj->value - scroll_test_pos;
- gint source_max = source_min + widget->allocation.height;
- gint dest_min = 0;
- gint dest_max = widget->allocation.height;
- GdkRectangle rect;
- GdkEvent *event;
+ gint dy;
+ dy = scroll_test_pos - (int)adj->value;
scroll_test_pos = adj->value;
if (!GTK_WIDGET_DRAWABLE (widget))
return;
-
- if (source_min < 0)
- {
- rect.x = 0;
- rect.y = 0;
- rect.width = widget->allocation.width;
- rect.height = -source_min;
- if (rect.height > widget->allocation.height)
- rect.height = widget->allocation.height;
-
- source_min = 0;
- dest_min = rect.height;
- }
- else
- {
- rect.x = 0;
- rect.y = 2*widget->allocation.height - source_max;
- if (rect.y < 0)
- rect.y = 0;
- rect.width = widget->allocation.width;
- rect.height = widget->allocation.height - rect.y;
-
- source_max = widget->allocation.height;
- dest_max = rect.y;
- }
-
- if (source_min != source_max)
- {
- if (scroll_test_gc == NULL)
- {
- scroll_test_gc = gdk_gc_new (widget->window);
- gdk_gc_set_exposures (scroll_test_gc, TRUE);
- }
-
- gdk_draw_pixmap (widget->window,
- scroll_test_gc,
- widget->window,
- 0, source_min,
- 0, dest_min,
- widget->allocation.width,
- source_max - source_min);
-
- /* Make sure graphics expose events are processed before scrolling
- * again */
-
- while ((event = gdk_event_get_graphics_expose (widget->window)) != NULL)
- {
- gtk_widget_event (widget, event);
- if (event->expose.count == 0)
- {
- gdk_event_free (event);
- break;
- }
- gdk_event_free (event);
- }
- }
-
- if (rect.height != 0)
- gtk_widget_draw (widget, &rect);
+ gdk_window_scroll (widget->window, 0, dy);
+ gdk_window_process_updates (widget->window, FALSE);
}
{ "event watcher", create_event_watcher },
{ "file selection", create_file_selection },
{ "flipping", create_flipping },
+ { "focus", create_focus },
{ "font selection", create_font_selection },
{ "gamma curve", create_gamma_curve },
{ "handle box", create_handle_box },
{ "tooltips", create_tooltips },
{ "tree", create_tree_mode_window},
{ "WM hints", create_wmhints },
+ { "window sizing", create_window_sizing },
{ "window states", create_window_states }
};
int nbuttons = sizeof (buttons) / sizeof (buttons[0]);
gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
- button = gtk_button_new_with_label ("close");
+ button = gtk_button_new_with_mnemonic ("_Close");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (do_exit),
window);
if (file_exists ("../gdk-pixbuf/.libs/libpixbufloader-pnm.so"))
{
putenv ("GDK_PIXBUF_MODULEDIR=../gdk-pixbuf/.libs");
- putenv ("GTK_IM_MODULE_FILE=./gtk.immodules");
+ putenv ("GTK_IM_MODULE_FILE=../modules/input/gtk.immodules");
}
}
{
while (g_main_pending ())
g_main_iteration (FALSE);
+#if 0
sleep (1);
while (g_main_pending ())
g_main_iteration (FALSE);
+#endif
}
return 0;