/src/wrappers/gtk/examples/gtk-demo/button_box.e

http://github.com/tybor/Liberty · Specman e · 154 lines · 21 code · 35 blank · 98 comment · 2 complexity · c1bc5673fb38e2b8e6fd87e5b1e70641 MD5 · raw file

  1. indexing
  2. description: "."
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class BUTTON_BOX
  19. creation make
  20. feature
  21. -- /* Button Boxes
  22. -- *
  23. -- * The Button Box widgets are used to arrange buttons with padding.
  24. -- */
  25. -- #include <gtk/gtk.h>
  26. -- static GtkWidget *
  27. -- create_bbox (gint horizontal,
  28. -- char *title,
  29. -- gint spacing,
  30. -- gint layout)
  31. -- {
  32. -- GtkWidget *frame;
  33. -- GtkWidget *bbox;
  34. -- GtkWidget *button;
  35. -- frame = gtk_frame_new (title);
  36. -- if (horizontal)
  37. -- bbox = gtk_hbutton_box_new ();
  38. -- else
  39. -- bbox = gtk_vbutton_box_new ();
  40. -- gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
  41. -- gtk_container_add (GTK_CONTAINER (frame), bbox);
  42. -- gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
  43. -- gtk_box_set_spacing (GTK_BOX (bbox), spacing);
  44. -- button = gtk_button_new_from_stock (GTK_STOCK_OK);
  45. -- gtk_container_add (GTK_CONTAINER (bbox), button);
  46. -- button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  47. -- gtk_container_add (GTK_CONTAINER (bbox), button);
  48. -- button = gtk_button_new_from_stock (GTK_STOCK_HELP);
  49. -- gtk_container_add (GTK_CONTAINER (bbox), button);
  50. -- return frame;
  51. -- }
  52. -- GtkWidget *
  53. -- do_button_box (GtkWidget *do_widget)
  54. -- {
  55. -- static GtkWidget *window = NULL;
  56. -- GtkWidget *main_vbox;
  57. -- GtkWidget *vbox;
  58. -- GtkWidget *hbox;
  59. -- GtkWidget *frame_horz;
  60. -- GtkWidget *frame_vert;
  61. -- if (!window)
  62. -- {
  63. -- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  64. -- gtk_window_set_screen (GTK_WINDOW (window),
  65. -- gtk_widget_get_screen (do_widget));
  66. -- gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
  67. -- g_signal_connect (window, "destroy",
  68. -- G_CALLBACK (gtk_widget_destroyed),
  69. -- &window);
  70. -- gtk_container_set_border_width (GTK_CONTAINER (window), 10);
  71. -- main_vbox = gtk_vbox_new (FALSE, 0);
  72. -- gtk_container_add (GTK_CONTAINER (window), main_vbox);
  73. -- frame_horz = gtk_frame_new ("Horizontal Button Boxes");
  74. -- gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);
  75. -- vbox = gtk_vbox_new (FALSE, 0);
  76. -- gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
  77. -- gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
  78. -- gtk_box_pack_start (GTK_BOX (vbox),
  79. -- create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
  80. -- TRUE, TRUE, 0);
  81. -- gtk_box_pack_start (GTK_BOX (vbox),
  82. -- create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
  83. -- TRUE, TRUE, 5);
  84. -- gtk_box_pack_start (GTK_BOX (vbox),
  85. -- create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
  86. -- TRUE, TRUE, 5);
  87. -- gtk_box_pack_start (GTK_BOX (vbox),
  88. -- create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
  89. -- TRUE, TRUE, 5);
  90. -- frame_vert = gtk_frame_new ("Vertical Button Boxes");
  91. -- gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10);
  92. -- hbox = gtk_hbox_new (FALSE, 0);
  93. -- gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
  94. -- gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
  95. -- gtk_box_pack_start (GTK_BOX (hbox),
  96. -- create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
  97. -- TRUE, TRUE, 0);
  98. -- gtk_box_pack_start (GTK_BOX (hbox),
  99. -- create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
  100. -- TRUE, TRUE, 5);
  101. -- gtk_box_pack_start (GTK_BOX (hbox),
  102. -- create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
  103. -- TRUE, TRUE, 5);
  104. -- gtk_box_pack_start (GTK_BOX (hbox),
  105. -- create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
  106. -- TRUE, TRUE, 5);
  107. -- }
  108. -- if (!GTK_WIDGET_VISIBLE (window))
  109. -- {
  110. -- gtk_widget_show_all (window);
  111. -- }
  112. -- else
  113. -- {
  114. -- gtk_widget_destroy (window);
  115. -- window = NULL;
  116. -- }
  117. -- return window;
  118. -- }
  119. end