testgtk.c 365 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4
/* GTK - The GIMP Toolkit
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10 11
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15 16 17
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
19 20

/*
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22 23 24 25 26
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

27 28
#undef GTK_DISABLE_DEPRECATED

29 30
#include "config.h"

31
#undef	G_LOG_DOMAIN
32

Elliot Lee's avatar
Elliot Lee committed
33 34
#include <stdio.h>
#include <stdlib.h>
35
#include <string.h>
36
#include <sys/stat.h>
37
#include <math.h>
38
#include <time.h>
39
#ifdef HAVE_UNISTD_H
40
#include <unistd.h>
41 42
#endif

43
#define GTK_ENABLE_BROKEN
Owen Taylor's avatar
Owen Taylor committed
44
#include "gtk/gtk.h"
45 46
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
Elliot Lee's avatar
Elliot Lee committed
47

Tor Lillqvist's avatar
Tor Lillqvist committed
48 49 50 51
#ifdef G_OS_WIN32
#define sleep(n) _sleep(n)
#endif

52 53
#include "prop-editor.h"

Owen Taylor's avatar
Owen Taylor committed
54
#include "circles.xbm"
55
#include "test.xpm"
Owen Taylor's avatar
Owen Taylor committed
56

57 58 59 60 61 62 63 64
gboolean
file_exists (const char *filename)
{
  struct stat statbuf;

  return stat (filename, &statbuf) == 0;
}

65
GtkWidget *
66 67 68 69 70 71 72
shape_create_icon (GdkScreen *screen,
		   char      *xpm_file,
		   gint       x,
		   gint       y,
		   gint       px,
		   gint       py,
		   gint       window_type);
73 74

static GtkWidget *
75 76 77 78 79
build_option_menu (gchar           *items[],
		   gint             num_items,
		   gint             history,
		   void           (*func)(GtkWidget *widget, gpointer data),
		   gpointer         data);
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

/* macro, structure and variables used by tree window demos */
#define DEFAULT_NUMBER_OF_ITEM  3
#define DEFAULT_RECURSION_LEVEL 3

struct {
  GSList* selection_mode_group;
  GtkWidget* single_button;
  GtkWidget* browse_button;
  GtkWidget* multiple_button;
  GtkWidget* draw_line_button;
  GtkWidget* view_line_button;
  GtkWidget* no_root_item_button;
  GtkWidget* nb_item_spinner;
  GtkWidget* recursion_spinner;
} sTreeSampleSelection;

typedef struct sTreeButtons {
  guint nb_item_add;
  GtkWidget* add_button;
  GtkWidget* remove_button;
101
  GtkWidget* subtree_button;
102 103 104
} sTreeButtons;
/* end of tree section */

105
static GtkWidget *
106 107 108 109 110
build_option_menu (gchar           *items[],
		   gint             num_items,
		   gint             history,
		   void           (*func)(GtkWidget *widget, gpointer data),
		   gpointer         data)
111 112 113 114
{
  GtkWidget *omenu;
  GtkWidget *menu;
  GtkWidget *menu_item;
115
  GSList *group;
116 117 118
  gint i;

  omenu = gtk_option_menu_new ();
Manish Singh's avatar
Manish Singh committed
119 120
  g_signal_connect (omenu, "changed",
		    G_CALLBACK (func), data);
121 122
      
  menu = gtk_menu_new ();
123
  group = NULL;
124 125 126
  
  for (i = 0; i < num_items; i++)
    {
127
      menu_item = gtk_radio_menu_item_new_with_label (group, items[i]);
Manish Singh's avatar
Manish Singh committed
128
      group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
129
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
130 131
      if (i == history)
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
132 133 134 135 136 137 138 139 140
      gtk_widget_show (menu_item);
    }

  gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
  gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), history);
  
  return omenu;
}

141
static void
142 143
destroy_tooltips (GtkWidget *widget, GtkWindow **window)
{
Manish Singh's avatar
Manish Singh committed
144 145
  GtkTooltips *tt = g_object_get_data (G_OBJECT (*window), "tooltips");
  g_object_unref (tt);
146 147 148
  *window = NULL;
}

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

/*
 * Big windows and guffaw scrolling
 */

static gboolean
pattern_expose (GtkWidget      *widget,
		GdkEventExpose *event,
		gpointer        data)
{
  GdkColor *color;
  GdkWindow *window = event->window;

  color = g_object_get_data (G_OBJECT (window), "pattern-color");
  if (color)
    {
      GdkGC *tmp_gc = gdk_gc_new (window);
      gdk_gc_set_rgb_fg_color (tmp_gc, color);

      gdk_draw_rectangle (window, tmp_gc, TRUE,
			  event->area.x, event->area.y,
			  event->area.width, event->area.height);

Manish Singh's avatar
Manish Singh committed
172
      g_object_unref (tmp_gc);
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
    }

  return FALSE;
}

static void
pattern_set_bg (GtkWidget   *widget,
		GdkWindow   *child,
		gint         level)
{
  static const GdkColor colors[] = {
    { 0, 0x4444, 0x4444, 0xffff },
    { 0, 0x8888, 0x8888, 0xffff },
    { 0, 0xaaaa, 0xaaaa, 0xffff }
  };
    
Manish Singh's avatar
Manish Singh committed
189
  g_object_set_data (G_OBJECT (child), "pattern-color", (gpointer) &colors[level]);
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
  gdk_window_set_user_data (child, widget);
}

static void
create_pattern (GtkWidget   *widget,
		GdkWindow   *parent,
		gint         level,
		gint         width,
		gint         height)
{
  gint h = 1;
  gint i = 0;
    
  GdkWindow *child;

  while (2 * h <= height)
    {
      gint w = 1;
      gint j = 0;
      
      while (2 * w <= width)
	{
	  if ((i + j) % 2 == 0)
	    {
	      gint x = w  - 1;
	      gint y = h - 1;
	      
	      GdkWindowAttr attributes;

	      attributes.window_type = GDK_WINDOW_CHILD;
	      attributes.x = x;
	      attributes.y = y;
	      attributes.width = w;
	      attributes.height = h;
	      attributes.wclass = GDK_INPUT_OUTPUT;
	      attributes.event_mask = GDK_EXPOSURE_MASK;
	      attributes.visual = gtk_widget_get_visual (widget);
	      attributes.colormap = gtk_widget_get_colormap (widget);
	      
	      child = gdk_window_new (parent, &attributes,
				      GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP);

	      pattern_set_bg (widget, child, level);

	      if (level < 2)
		create_pattern (widget, child, level + 1, w, h);

	      gdk_window_show (child);
	    }
	  j++;
	  w *= 2;
	}
      i++;
      h *= 2;
    }
}

#define PATTERN_SIZE (1 << 18)

static void
pattern_hadj_changed (GtkAdjustment *adj,
		      GtkWidget     *darea)
{
  gint *old_value = g_object_get_data (G_OBJECT (adj), "old-value");
  gint new_value = adj->value;

  if (GTK_WIDGET_REALIZED (darea))
    {
      gdk_window_scroll (darea->window, *old_value - new_value, 0);
      *old_value = new_value;
    }
}

static void
pattern_vadj_changed (GtkAdjustment *adj,
		      GtkWidget *darea)
{
  gint *old_value = g_object_get_data (G_OBJECT (adj), "old-value");
  gint new_value = adj->value;

  if (GTK_WIDGET_REALIZED (darea))
    {
      gdk_window_scroll (darea->window, 0, *old_value - new_value);
      *old_value = new_value;
    }
}

static void
pattern_realize (GtkWidget *widget,
		 gpointer   data)
{
  pattern_set_bg (widget, widget->window, 0);
  create_pattern (widget, widget->window, 1, PATTERN_SIZE, PATTERN_SIZE);
}

static void 
286
create_big_windows (GtkWidget *widget)
287 288 289 290 291 292 293 294
{
  static GtkWidget *window = NULL;
  GtkWidget *darea, *table, *scrollbar;
  GtkWidget *eventbox;
  GtkAdjustment *hadj;
  GtkAdjustment *vadj;
  static gint current_x;
  static gint current_y;
295
 
296 297 298 299 300 301 302 303 304 305
  if (!window)
    {
      current_x = 0;
      current_y = 0;
      
      window = gtk_dialog_new_with_buttons ("Big Windows",
                                            NULL, 0,
                                            GTK_STOCK_CLOSE,
                                            GTK_RESPONSE_NONE,
                                            NULL);
306 307 308
 
      gtk_window_set_screen (GTK_WINDOW (window),
			     gtk_widget_get_screen (widget));
309 310 311

      gtk_window_set_default_size (GTK_WINDOW (window), 200, 300);

Manish Singh's avatar
Manish Singh committed
312 313 314
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed),
			&window);
315

Manish Singh's avatar
Manish Singh committed
316 317 318
      g_signal_connect (window, "response",
                        G_CALLBACK (gtk_widget_destroy),
                        NULL);
319 320 321 322 323 324 325 326

      table = gtk_table_new (2, 2, FALSE);
      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox),
			  table, TRUE, TRUE, 0);

      darea = gtk_drawing_area_new ();

      hadj = (GtkAdjustment *)gtk_adjustment_new (0, 0, PATTERN_SIZE, 10, 100, 100);
Manish Singh's avatar
Manish Singh committed
327 328
      g_signal_connect (hadj, "value_changed",
			G_CALLBACK (pattern_hadj_changed), darea);
329 330 331
      g_object_set_data (G_OBJECT (hadj), "old-value", &current_x);
      
      vadj = (GtkAdjustment *)gtk_adjustment_new (0, 0, PATTERN_SIZE, 10, 100, 100);
Manish Singh's avatar
Manish Singh committed
332 333
      g_signal_connect (vadj, "value_changed",
			G_CALLBACK (pattern_vadj_changed), darea);
334 335
      g_object_set_data (G_OBJECT (vadj), "old-value", &current_y);
      
Manish Singh's avatar
Manish Singh committed
336 337 338 339 340 341
      g_signal_connect (darea, "realize",
                        G_CALLBACK (pattern_realize),
                        NULL);
      g_signal_connect (darea, "expose_event",
                        G_CALLBACK (pattern_expose),
                        NULL);
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370

      eventbox = gtk_event_box_new ();
      gtk_table_attach (GTK_TABLE (table), eventbox,
			0, 1,                  0, 1,
			GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
			0,                     0);

      gtk_container_add (GTK_CONTAINER (eventbox), darea);

      scrollbar = gtk_hscrollbar_new (hadj);
      gtk_table_attach (GTK_TABLE (table), scrollbar,
			0, 1,                  1, 2,
			GTK_FILL | GTK_EXPAND, GTK_FILL,
			0,                     0);

      scrollbar = gtk_vscrollbar_new (vadj);
      gtk_table_attach (GTK_TABLE (table), scrollbar,
			1, 2,                  0, 1,
			GTK_FILL,              GTK_EXPAND | GTK_FILL,
			0,                     0);

    }

  if (!GTK_WIDGET_VISIBLE (window))
    gtk_widget_show_all (window);
  else
    gtk_widget_hide (window);
}

371 372 373 374
/*
 * GtkButton
 */

375
static void
Elliot Lee's avatar
Elliot Lee committed
376 377 378 379 380 381 382 383 384
button_window (GtkWidget *widget,
	       GtkWidget *button)
{
  if (!GTK_WIDGET_VISIBLE (button))
    gtk_widget_show (button);
  else
    gtk_widget_hide (button);
}

385
static void
386
create_buttons (GtkWidget *widget)
Elliot Lee's avatar
Elliot Lee committed
387 388 389 390 391 392 393 394 395 396 397
{
  static GtkWidget *window = NULL;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *table;
  GtkWidget *button[10];
  GtkWidget *separator;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
398 399
      gtk_window_set_screen (GTK_WINDOW (window),
			     gtk_widget_get_screen (widget));
Elliot Lee's avatar
Elliot Lee committed
400

Manish Singh's avatar
Manish Singh committed
401 402 403
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed),
			&window);
Elliot Lee's avatar
Elliot Lee committed
404

405
      gtk_window_set_title (GTK_WINDOW (window), "GtkButton");
406
      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
Elliot Lee's avatar
Elliot Lee committed
407 408 409 410 411 412 413

      box1 = gtk_vbox_new (FALSE, 0);
      gtk_container_add (GTK_CONTAINER (window), box1);

      table = gtk_table_new (3, 3, FALSE);
      gtk_table_set_row_spacings (GTK_TABLE (table), 5);
      gtk_table_set_col_spacings (GTK_TABLE (table), 5);
414
      gtk_container_set_border_width (GTK_CONTAINER (table), 10);
Elliot Lee's avatar
Elliot Lee committed
415 416 417
      gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);

      button[0] = gtk_button_new_with_label ("button1");
418
      button[1] = gtk_button_new_with_mnemonic ("_button2");
419
      button[2] = gtk_button_new_with_mnemonic ("_button3");
420
      button[3] = gtk_button_new_from_stock (GTK_STOCK_OK);
Elliot Lee's avatar
Elliot Lee committed
421 422 423
      button[4] = gtk_button_new_with_label ("button5");
      button[5] = gtk_button_new_with_label ("button6");
      button[6] = gtk_button_new_with_label ("button7");
424
      button[7] = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
Elliot Lee's avatar
Elliot Lee committed
425
      button[8] = gtk_button_new_with_label ("button9");
426
      
Manish Singh's avatar
Manish Singh committed
427 428 429
      g_signal_connect (button[0], "clicked",
			G_CALLBACK (button_window),
			button[1]);
Elliot Lee's avatar
Elliot Lee committed
430 431 432 433

      gtk_table_attach (GTK_TABLE (table), button[0], 0, 1, 0, 1,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
434 435 436
      g_signal_connect (button[1], "clicked",
			G_CALLBACK (button_window),
			button[2]);
Elliot Lee's avatar
Elliot Lee committed
437 438 439 440

      gtk_table_attach (GTK_TABLE (table), button[1], 1, 2, 1, 2,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
441 442 443
      g_signal_connect (button[2], "clicked",
			G_CALLBACK (button_window),
			button[3]);
Elliot Lee's avatar
Elliot Lee committed
444 445 446
      gtk_table_attach (GTK_TABLE (table), button[2], 2, 3, 2, 3,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
447 448 449
      g_signal_connect (button[3], "clicked",
			G_CALLBACK (button_window),
			button[4]);
Elliot Lee's avatar
Elliot Lee committed
450 451 452
      gtk_table_attach (GTK_TABLE (table), button[3], 0, 1, 2, 3,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
453 454 455
      g_signal_connect (button[4], "clicked",
			G_CALLBACK (button_window),
			button[5]);
Elliot Lee's avatar
Elliot Lee committed
456 457 458
      gtk_table_attach (GTK_TABLE (table), button[4], 2, 3, 0, 1,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
459 460 461
      g_signal_connect (button[5], "clicked",
			G_CALLBACK (button_window),
			button[6]);
Elliot Lee's avatar
Elliot Lee committed
462 463 464
      gtk_table_attach (GTK_TABLE (table), button[5], 1, 2, 2, 3,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
465 466 467
      g_signal_connect (button[6], "clicked",
			G_CALLBACK (button_window),
			button[7]);
Elliot Lee's avatar
Elliot Lee committed
468 469 470
      gtk_table_attach (GTK_TABLE (table), button[6], 1, 2, 0, 1,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
471 472 473
      g_signal_connect (button[7], "clicked",
			G_CALLBACK (button_window),
			button[8]);
Elliot Lee's avatar
Elliot Lee committed
474 475 476
      gtk_table_attach (GTK_TABLE (table), button[7], 2, 3, 1, 2,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

Manish Singh's avatar
Manish Singh committed
477 478 479
      g_signal_connect (button[8], "clicked",
			G_CALLBACK (button_window),
			button[0]);
Elliot Lee's avatar
Elliot Lee committed
480 481 482 483 484 485 486
      gtk_table_attach (GTK_TABLE (table), button[8], 0, 1, 1, 2,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

      separator = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

      box2 = gtk_vbox_new (FALSE, 10);
487
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
Elliot Lee's avatar
Elliot Lee committed
488 489 490
      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);

      button[9] = gtk_button_new_with_label ("close");
Manish Singh's avatar
Manish Singh committed
491 492 493
      g_signal_connect_swapped (button[9], "clicked",
				G_CALLBACK (gtk_widget_destroy),
				window);
Elliot Lee's avatar
Elliot Lee committed
494 495 496 497 498 499
      gtk_box_pack_start (GTK_BOX (box2), button[9], TRUE, TRUE, 0);
      GTK_WIDGET_SET_FLAGS (button[9], GTK_CAN_DEFAULT);
      gtk_widget_grab_default (button[9]);
    }

  if (!GTK_WIDGET_VISIBLE (window))
500
    gtk_widget_show_all (window);
Elliot Lee's avatar
Elliot Lee committed
501
  else
502
    gtk_widget_destroy (window);
Elliot Lee's avatar
Elliot Lee committed
503 504
}

505 506 507 508
/*
 * GtkToggleButton
 */

509
static void
510
create_toggle_buttons (GtkWidget *widget)
Elliot Lee's avatar
Elliot Lee committed
511 512 513 514 515 516 517 518 519 520
{
  static GtkWidget *window = NULL;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *button;
  GtkWidget *separator;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
521 522
      gtk_window_set_screen (GTK_WINDOW (window),
			     gtk_widget_get_screen (widget));
Elliot Lee's avatar
Elliot Lee committed
523

Manish Singh's avatar
Manish Singh committed
524 525 526
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed),
			&window);
Elliot Lee's avatar
Elliot Lee committed
527

528
      gtk_window_set_title (GTK_WINDOW (window), "GtkToggleButton");
529
      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
Elliot Lee's avatar
Elliot Lee committed
530 531 532 533 534

      box1 = gtk_vbox_new (FALSE, 0);
      gtk_container_add (GTK_CONTAINER (window), box1);

      box2 = gtk_vbox_new (FALSE, 10);
535
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
Elliot Lee's avatar
Elliot Lee committed
536 537 538 539 540 541 542 543 544 545 546
      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);

      button = gtk_toggle_button_new_with_label ("button1");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_toggle_button_new_with_label ("button2");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_toggle_button_new_with_label ("button3");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

547 548 549 550
      button = gtk_toggle_button_new_with_label ("inconsistent");
      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
      
Elliot Lee's avatar
Elliot Lee committed
551 552 553 554
      separator = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

      box2 = gtk_vbox_new (FALSE, 10);
555
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
Elliot Lee's avatar
Elliot Lee committed
556 557 558
      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);

      button = gtk_button_new_with_label ("close");
Manish Singh's avatar
Manish Singh committed
559 560 561
      g_signal_connect_swapped (button, "clicked",
			        G_CALLBACK (gtk_widget_destroy),
				window);
Elliot Lee's avatar
Elliot Lee committed
562 563 564 565 566 567
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
      gtk_widget_grab_default (button);
    }

  if (!GTK_WIDGET_VISIBLE (window))
568
    gtk_widget_show_all (window);
Elliot Lee's avatar
Elliot Lee committed
569 570 571 572
  else
    gtk_widget_destroy (window);
}

573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
static GtkWidget *
create_widget_grid (GType widget_type)
{
  GtkWidget *table;
  GtkWidget *group_widget = NULL;
  gint i, j;
  
  table = gtk_table_new (FALSE, 3, 3);
  
  for (i = 0; i < 5; i++)
    {
      for (j = 0; j < 5; j++)
	{
	  GtkWidget *widget;
	  char *tmp;
	  
	  if (i == 0 && j == 0)
	    {
	      widget = NULL;
	    }
	  else if (i == 0)
	    {
	      tmp = g_strdup_printf ("%d", j);
	      widget = gtk_label_new (tmp);
	      g_free (tmp);
	    }
	  else if (j == 0)
	    {
	      tmp = g_strdup_printf ("%c", 'A' + i - 1);
	      widget = gtk_label_new (tmp);
	      g_free (tmp);
	    }
	  else
	    {
	      widget = g_object_new (widget_type, NULL);
	      
	      if (g_type_is_a (widget_type, GTK_TYPE_RADIO_BUTTON))
		{
		  if (!group_widget)
		    group_widget = widget;
		  else
		    g_object_set (widget, "group", group_widget, NULL);
		}
	    }
	  
	  if (widget)
	    gtk_table_attach (GTK_TABLE (table), widget,
			      i, i + 1, j, j + 1,
			      0,        0,
			      0,        0);
	}
    }

  return table;
}

629 630 631 632
/*
 * GtkCheckButton
 */

633
static void
634
create_check_buttons (GtkWidget *widget)
Elliot Lee's avatar
Elliot Lee committed
635 636 637 638 639 640
{
  static GtkWidget *window = NULL;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *button;
  GtkWidget *separator;
641
  GtkWidget *table;
642
  
Elliot Lee's avatar
Elliot Lee committed
643 644
  if (!window)
    {
645 646 647 648 649 650
      window = gtk_dialog_new_with_buttons ("Check Buttons",
                                            NULL, 0,
                                            GTK_STOCK_CLOSE,
                                            GTK_RESPONSE_NONE,
                                            NULL);

651 652
      gtk_window_set_screen (GTK_WINDOW (window), 
			     gtk_widget_get_screen (widget));
Elliot Lee's avatar
Elliot Lee committed
653

Manish Singh's avatar
Manish Singh committed
654 655 656
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed),
			&window);
657 658 659
      g_signal_connect (window, "response",
                        G_CALLBACK (gtk_widget_destroy),
                        NULL);
Elliot Lee's avatar
Elliot Lee committed
660

661 662
      box1 = GTK_DIALOG (window)->vbox;
      
Elliot Lee's avatar
Elliot Lee committed
663
      box2 = gtk_vbox_new (FALSE, 10);
664
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
Elliot Lee's avatar
Elliot Lee committed
665 666
      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);

667
      button = gtk_check_button_new_with_mnemonic ("_button1");
Elliot Lee's avatar
Elliot Lee committed
668 669 670 671 672 673 674 675
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_check_button_new_with_label ("button2");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_check_button_new_with_label ("button3");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

676 677 678
      button = gtk_check_button_new_with_label ("inconsistent");
      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
679

Elliot Lee's avatar
Elliot Lee committed
680 681 682
      separator = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

683 684 685
      table = create_widget_grid (GTK_TYPE_CHECK_BUTTON);
      gtk_container_set_border_width (GTK_CONTAINER (table), 10);
      gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);
Elliot Lee's avatar
Elliot Lee committed
686 687 688
    }

  if (!GTK_WIDGET_VISIBLE (window))
689
    gtk_widget_show_all (window);
Elliot Lee's avatar
Elliot Lee committed
690 691 692 693
  else
    gtk_widget_destroy (window);
}

694 695 696 697
/*
 * GtkRadioButton
 */

698
static void
699
create_radio_buttons (GtkWidget *widget)
Elliot Lee's avatar
Elliot Lee committed
700 701 702 703 704 705
{
  static GtkWidget *window = NULL;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *button;
  GtkWidget *separator;
706
  GtkWidget *table;
Elliot Lee's avatar
Elliot Lee committed
707 708 709

  if (!window)
    {
710 711 712 713 714
      window = gtk_dialog_new_with_buttons ("Radio Buttons",
                                            NULL, 0,
                                            GTK_STOCK_CLOSE,
                                            GTK_RESPONSE_NONE,
                                            NULL);
Elliot Lee's avatar
Elliot Lee committed
715

716 717 718
      gtk_window_set_screen (GTK_WINDOW (window),
			     gtk_widget_get_screen (widget));

Manish Singh's avatar
Manish Singh committed
719 720 721
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed),
			&window);
722 723 724
      g_signal_connect (window, "response",
                        G_CALLBACK (gtk_widget_destroy),
                        NULL);
Elliot Lee's avatar
Elliot Lee committed
725

726
      box1 = GTK_DIALOG (window)->vbox;
Elliot Lee's avatar
Elliot Lee committed
727 728

      box2 = gtk_vbox_new (FALSE, 10);
729
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
Elliot Lee's avatar
Elliot Lee committed
730 731 732 733 734 735
      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);

      button = gtk_radio_button_new_with_label (NULL, "button1");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_radio_button_new_with_label (
736
	         gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
Elliot Lee's avatar
Elliot Lee committed
737
		 "button2");
738
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
Elliot Lee's avatar
Elliot Lee committed
739 740 741
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_radio_button_new_with_label (
742
                 gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
Elliot Lee's avatar
Elliot Lee committed
743 744 745
		 "button3");
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

746
      button = gtk_radio_button_new_with_label (
747
                 gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
748 749 750 751
		 "inconsistent");
      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
      
Elliot Lee's avatar
Elliot Lee committed
752 753 754
      separator = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

755 756 757 758
      box2 = gtk_vbox_new (FALSE, 10);
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);

759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
      button = gtk_radio_button_new_with_label (NULL, "button4");
      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_radio_button_new_with_label (
	         gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
		 "button5");
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      button = gtk_radio_button_new_with_label (
                 gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
		 "button6");
      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);

      separator = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

779 780 781
      table = create_widget_grid (GTK_TYPE_RADIO_BUTTON);
      gtk_container_set_border_width (GTK_CONTAINER (table), 10);
      gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);
Elliot Lee's avatar
Elliot Lee committed
782 783 784
    }

  if (!GTK_WIDGET_VISIBLE (window))
785
    gtk_widget_show_all (window);
Elliot Lee's avatar
Elliot Lee committed
786 787 788 789
  else
    gtk_widget_destroy (window);
}

790 791 792
/*
 * GtkButtonBox
 */
Elliot Lee's avatar
Elliot Lee committed
793

794 795 796 797
static GtkWidget *
create_bbox (gint  horizontal,
	     char* title, 
	     gint  spacing,
Manish Singh's avatar
Manish Singh committed
798 799
	     gint  child_w,
	     gint  child_h,
800
	     gint  layout)
Elliot Lee's avatar
Elliot Lee committed
801
{
802 803 804
  GtkWidget *frame;
  GtkWidget *bbox;
  GtkWidget *button;
Elliot Lee's avatar
Elliot Lee committed
805
	
806
  frame = gtk_frame_new (title);
Elliot Lee's avatar
Elliot Lee committed
807 808

  if (horizontal)
809
    bbox = gtk_hbutton_box_new ();
Elliot Lee's avatar
Elliot Lee committed
810
  else
811 812
    bbox = gtk_vbutton_box_new ();

813
  gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
814 815
  gtk_container_add (GTK_CONTAINER (frame), bbox);

Elliot Lee's avatar
Elliot Lee committed
816
  gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
817
  gtk_box_set_spacing (GTK_BOX (bbox), spacing);
Elliot Lee's avatar
Elliot Lee committed
818 819 820
  gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), child_w, child_h);
  
  button = gtk_button_new_with_label ("OK");
821
  gtk_container_add (GTK_CONTAINER (bbox), button);
Elliot Lee's avatar
Elliot Lee committed
822 823
  
  button = gtk_button_new_with_label ("Cancel");
824
  gtk_container_add (GTK_CONTAINER (bbox), button);
Elliot Lee's avatar
Elliot Lee committed
825 826
  
  button = gtk_button_new_with_label ("Help");
827
  gtk_container_add (GTK_CONTAINER (bbox), button);
Elliot Lee's avatar
Elliot Lee committed
828

829
  return frame;
Elliot Lee's avatar
Elliot Lee committed
830 831
}

832
static void
833
create_button_box (GtkWidget *widget)
Elliot Lee's avatar
Elliot Lee committed
834 835
{
  static GtkWidget* window = NULL;
836 837 838 839 840
  GtkWidget *main_vbox;
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *frame_horz;
  GtkWidget *frame_vert;
841

Elliot Lee's avatar
Elliot Lee committed
842 843 844
  if (!window)
  {
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
845
    gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (widget));
846
    gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
Elliot Lee's avatar
Elliot Lee committed
847
    
Manish Singh's avatar
Manish Singh committed
848 849 850
    g_signal_connect (window, "destroy",
		      G_CALLBACK (gtk_widget_destroyed),
		      &window);
Elliot Lee's avatar
Elliot Lee committed
851
    
852
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
853 854 855

    main_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), main_vbox);
Elliot Lee's avatar
Elliot Lee committed
856
    
857 858
    frame_horz = gtk_frame_new ("Horizontal Button Boxes");
    gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);
Elliot Lee's avatar
Elliot Lee committed
859
    
860
    vbox = gtk_vbox_new (FALSE, 0);
861
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881
    gtk_container_add (GTK_CONTAINER (frame_horz), vbox);

    gtk_box_pack_start (GTK_BOX (vbox), 
	   create_bbox (TRUE, "Spread", 40, 85, 20, GTK_BUTTONBOX_SPREAD),
			TRUE, TRUE, 0);

    gtk_box_pack_start (GTK_BOX (vbox), 
	   create_bbox (TRUE, "Edge", 40, 85, 20, GTK_BUTTONBOX_EDGE),
			TRUE, TRUE, 5);

    gtk_box_pack_start (GTK_BOX (vbox), 
	   create_bbox (TRUE, "Start", 40, 85, 20, GTK_BUTTONBOX_START),
			TRUE, TRUE, 5);

    gtk_box_pack_start (GTK_BOX (vbox), 
	   create_bbox (TRUE, "End", 40, 85, 20, GTK_BUTTONBOX_END),
			TRUE, TRUE, 5);

    frame_vert = gtk_frame_new ("Vertical Button Boxes");
    gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10);
Elliot Lee's avatar
Elliot Lee committed
882
    
883
    hbox = gtk_hbox_new (FALSE, 0);
884
    gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
    gtk_container_add (GTK_CONTAINER (frame_vert), hbox);

    gtk_box_pack_start (GTK_BOX (hbox), 
	   create_bbox (FALSE, "Spread", 30, 85, 20, GTK_BUTTONBOX_SPREAD),
			TRUE, TRUE, 0);

    gtk_box_pack_start (GTK_BOX (hbox), 
	   create_bbox (FALSE, "Edge", 30, 85, 20, GTK_BUTTONBOX_EDGE),
			TRUE, TRUE, 5);

    gtk_box_pack_start (GTK_BOX (hbox), 
	   create_bbox (FALSE, "Start", 30, 85, 20, GTK_BUTTONBOX_START),
			TRUE, TRUE, 5);

    gtk_box_pack_start (GTK_BOX (hbox), 
	   create_bbox (FALSE, "End", 30, 85, 20, GTK_BUTTONBOX_END),
			TRUE, TRUE, 5);
Elliot Lee's avatar
Elliot Lee committed
902 903 904
  }

  if (!GTK_WIDGET_VISIBLE (window))
905
    gtk_widget_show_all (window);
Elliot Lee's avatar
Elliot Lee committed
906 907 908 909
  else
    gtk_widget_destroy (window);
}

910 911 912 913
/*
 * GtkToolBar
 */

914
static GtkWidget*
915 916 917
new_pixmap (char      *filename,
	    GdkWindow *window,
	    GdkColor  *background)
918 919 920 921 922
{
  GtkWidget *wpixmap;
  GdkPixmap *pixmap;
  GdkBitmap *mask;

923 924 925 926 927 928 929 930 931 932 933 934
  if (strcmp (filename, "test.xpm") == 0 ||
      !file_exists (filename))
    {
      pixmap = gdk_pixmap_create_from_xpm_d (window, &mask,
					     background,
					     openfile);
    }
  else
    pixmap = gdk_pixmap_create_from_xpm (window, &mask,
					 background,
					 filename);
  
Manish Singh's avatar
Manish Singh committed
935
  wpixmap = gtk_image_new_from_pixmap (pixmap, mask);
936 937 938 939

  return wpixmap;
}

940 941 942 943 944 945 946 947 948 949 950 951 952 953 954

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);
}

955
static void
956 957 958 959 960 961
set_toolbar_horizontal (GtkWidget *widget,
			gpointer   data)
{
  gtk_toolbar_set_orientation (GTK_TOOLBAR (data), GTK_ORIENTATION_HORIZONTAL);
}

962
static void
963 964 965 966 967 968
set_toolbar_vertical (GtkWidget *widget,
		      gpointer   data)
{
  gtk_toolbar_set_orientation (GTK_TOOLBAR (data), GTK_ORIENTATION_VERTICAL);
}

969
static void
970 971 972 973 974 975
set_toolbar_icons (GtkWidget *widget,
		   gpointer   data)
{
  gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_ICONS);
}

976
static void
977 978 979 980 981 982
set_toolbar_text (GtkWidget *widget,
	          gpointer   data)
{
  gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_TEXT);
}

983
static void
984 985 986 987 988 989
set_toolbar_both (GtkWidget *widget,
		  gpointer   data)
{
  gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH);
}

990 991 992 993 994 995 996
static void
set_toolbar_both_horiz (GtkWidget *widget,
			gpointer   data)
{
  gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH_HORIZ);
}

997
static void
998 999 1000 1001 1002 1003
set_toolbar_enable (GtkWidget *widget,
		    gpointer   data)
{
  gtk_toolbar_set_tooltips (GTK_TOOLBAR (data), TRUE);
}

1004
static void
1005 1006 1007 1008 1009 1010
set_toolbar_disable (GtkWidget *widget,
		     gpointer   data)
{
  gtk_toolbar_set_tooltips (GTK_TOOLBAR (data), FALSE);
}

1011
static void
1012
create_toolbar (GtkWidget *widget)
1013 1014 1015
{
  static GtkWidget *window = NULL;
  GtkWidget *toolbar;
1016
  GtkWidget *entry;
1017 1018 1019 1020

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1021 1022 1023
      gtk_window_set_screen (GTK_WINDOW (window),
			     gtk_widget_get_screen (widget));
      
1024
      gtk_window_set_title (GTK_WINDOW (window), "Toolbar test");
1025
      gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
1026

Manish Singh's avatar
Manish Singh committed
1027 1028 1029
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed),
			&window);
1030

1031
      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
1032 1033
      gtk_widget_realize (window);

1034
      toolbar = gtk_toolbar_new ();
1035

1036 1037 1038
      gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
				GTK_STOCK_NEW,
				"Stock icon: New", "Toolbar/New",
Manish Singh's avatar
Manish Singh committed
1039
				G_CALLBACK (set_toolbar_small_stock), toolbar, -1);
1040 1041 1042 1043
      
      gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
				GTK_STOCK_OPEN,
				"Stock icon: Open", "Toolbar/Open",
Manish Singh's avatar
Manish Singh committed
1044
				G_CALLBACK (set_toolbar_large_stock), toolbar, -1);
1045
      
1046
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1047
			       "Horizontal", "Horizontal toolbar layout", "Toolbar/Horizontal",
1048
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1049
			       G_CALLBACK (set_toolbar_horizontal), toolbar);
1050
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1051
			       "Vertical", "Vertical toolbar layout", "Toolbar/Vertical",
1052
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1053
			       G_CALLBACK (set_toolbar_vertical), toolbar);
1054 1055 1056 1057

      gtk_toolbar_append_space (GTK_TOOLBAR(toolbar));

      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1058
			       "Icons", "Only show toolbar icons", "Toolbar/IconsOnly",
1059
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1060
			       G_CALLBACK (set_toolbar_icons), toolbar);
1061
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1062
			       "Text", "Only show toolbar text", "Toolbar/TextOnly",
1063
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1064
			       G_CALLBACK (set_toolbar_text), toolbar);
1065
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1066
			       "Both", "Show toolbar icons and text", "Toolbar/Both",
1067
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1068
			       G_CALLBACK (set_toolbar_both), toolbar);
1069 1070 1071 1072 1073
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
			       "Both (horizontal)",
			       "Show toolbar icons and text in a horizontal fashion",
			       "Toolbar/BothHoriz",
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1074
			       G_CALLBACK (set_toolbar_both_horiz), toolbar);
1075
			       
1076 1077
      gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

1078
      entry = gtk_entry_new ();
1079

1080
      gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar), entry, "This is an unusable GtkEntry ;)", "Hey don't click me!!!");
1081 1082 1083

      gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

1084

1085 1086
      gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

1087
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1088
			       "Enable", "Enable tooltips", NULL,
1089
			       new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
Manish Singh's avatar
Manish Singh committed
1090
			       G_CALLBACK (set_toolbar_enable), toolbar);
1091
      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
1092
			       "Disable", "Disable tooltips", NULL,