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

http://github.com/tybor/Liberty · Specman e · 222 lines · 21 code · 41 blank · 160 comment · 2 complexity · 134bbaeda7ea61cca1abea524a3b571d 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 PANES
  19. creation make
  20. feature
  21. -- /* Paned Widgets
  22. -- *
  23. -- * The GtkHPaned and GtkVPaned Widgets divide their content
  24. -- * area into two panes with a divider in between that the
  25. -- * user can adjust. A separate child is placed into each
  26. -- * pane.
  27. -- *
  28. -- * There are a number of options that can be set for each pane.
  29. -- * This test contains both a horizontal (HPaned) and a vertical
  30. -- * (VPaned) widget, and allows you to adjust the options for
  31. -- * each side of each widget.
  32. -- */
  33. -- #include <gtk/gtk.h>
  34. -- void
  35. -- toggle_resize (GtkWidget *widget,
  36. -- GtkWidget *child)
  37. -- {
  38. -- GtkPaned *paned = GTK_PANED (child->parent);
  39. -- gboolean is_child1 = (child == paned->child1);
  40. -- gboolean resize, shrink;
  41. -- resize = is_child1 ? paned->child1_resize : paned->child2_resize;
  42. -- shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
  43. -- gtk_widget_ref (child);
  44. -- gtk_container_remove (GTK_CONTAINER (child->parent), child);
  45. -- if (is_child1)
  46. -- gtk_paned_pack1 (paned, child, !resize, shrink);
  47. -- else
  48. -- gtk_paned_pack2 (paned, child, !resize, shrink);
  49. -- gtk_widget_unref (child);
  50. -- }
  51. -- void
  52. -- toggle_shrink (GtkWidget *widget,
  53. -- GtkWidget *child)
  54. -- {
  55. -- GtkPaned *paned = GTK_PANED (child->parent);
  56. -- gboolean is_child1 = (child == paned->child1);
  57. -- gboolean resize, shrink;
  58. -- resize = is_child1 ? paned->child1_resize : paned->child2_resize;
  59. -- shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
  60. -- gtk_widget_ref (child);
  61. -- gtk_container_remove (GTK_CONTAINER (child->parent), child);
  62. -- if (is_child1)
  63. -- gtk_paned_pack1 (paned, child, resize, !shrink);
  64. -- else
  65. -- gtk_paned_pack2 (paned, child, resize, !shrink);
  66. -- gtk_widget_unref (child);
  67. -- }
  68. -- GtkWidget *
  69. -- create_pane_options (GtkPaned *paned,
  70. -- const gchar *frame_label,
  71. -- const gchar *label1,
  72. -- const gchar *label2)
  73. -- {
  74. -- GtkWidget *frame;
  75. -- GtkWidget *table;
  76. -- GtkWidget *label;
  77. -- GtkWidget *check_button;
  78. -- frame = gtk_frame_new (frame_label);
  79. -- gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
  80. -- table = gtk_table_new (3, 2, TRUE);
  81. -- gtk_container_add (GTK_CONTAINER (frame), table);
  82. -- label = gtk_label_new (label1);
  83. -- gtk_table_attach_defaults (GTK_TABLE (table), label,
  84. -- 0, 1, 0, 1);
  85. -- check_button = gtk_check_button_new_with_mnemonic ("_Resize");
  86. -- gtk_table_attach_defaults (GTK_TABLE (table), check_button,
  87. -- 0, 1, 1, 2);
  88. -- g_signal_connect (check_button, "toggled",
  89. -- G_CALLBACK (toggle_resize), paned->child1);
  90. -- check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
  91. -- gtk_table_attach_defaults (GTK_TABLE (table), check_button,
  92. -- 0, 1, 2, 3);
  93. -- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
  94. -- TRUE);
  95. -- g_signal_connect (check_button, "toggled",
  96. -- G_CALLBACK (toggle_shrink), paned->child1);
  97. -- label = gtk_label_new (label2);
  98. -- gtk_table_attach_defaults (GTK_TABLE (table), label,
  99. -- 1, 2, 0, 1);
  100. -- check_button = gtk_check_button_new_with_mnemonic ("_Resize");
  101. -- gtk_table_attach_defaults (GTK_TABLE (table), check_button,
  102. -- 1, 2, 1, 2);
  103. -- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
  104. -- TRUE);
  105. -- g_signal_connect (check_button, "toggled",
  106. -- G_CALLBACK (toggle_resize), paned->child2);
  107. -- check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
  108. -- gtk_table_attach_defaults (GTK_TABLE (table), check_button,
  109. -- 1, 2, 2, 3);
  110. -- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
  111. -- TRUE);
  112. -- g_signal_connect (check_button, "toggled",
  113. -- G_CALLBACK (toggle_shrink), paned->child2);
  114. -- return frame;
  115. -- }
  116. -- GtkWidget *
  117. -- do_panes (GtkWidget *do_widget)
  118. -- {
  119. -- static GtkWidget *window = NULL;
  120. -- GtkWidget *frame;
  121. -- GtkWidget *hpaned;
  122. -- GtkWidget *vpaned;
  123. -- GtkWidget *button;
  124. -- GtkWidget *vbox;
  125. -- if (!window)
  126. -- {
  127. -- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  128. -- gtk_window_set_screen (GTK_WINDOW (window),
  129. -- gtk_widget_get_screen (do_widget));
  130. -- g_signal_connect (window, "destroy",
  131. -- G_CALLBACK (gtk_widget_destroyed), &window);
  132. -- gtk_window_set_title (GTK_WINDOW (window), "Panes");
  133. -- gtk_container_set_border_width (GTK_CONTAINER (window), 0);
  134. -- vbox = gtk_vbox_new (FALSE, 0);
  135. -- gtk_container_add (GTK_CONTAINER (window), vbox);
  136. -- vpaned = gtk_vpaned_new ();
  137. -- gtk_box_pack_start (GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);
  138. -- gtk_container_set_border_width (GTK_CONTAINER(vpaned), 5);
  139. -- hpaned = gtk_hpaned_new ();
  140. -- gtk_paned_add1 (GTK_PANED (vpaned), hpaned);
  141. -- frame = gtk_frame_new (NULL);
  142. -- gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
  143. -- gtk_widget_set_size_request (frame, 60, 60);
  144. -- gtk_paned_add1 (GTK_PANED (hpaned), frame);
  145. -- button = gtk_button_new_with_mnemonic ("_Hi there");
  146. -- gtk_container_add (GTK_CONTAINER(frame), button);
  147. -- frame = gtk_frame_new (NULL);
  148. -- gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
  149. -- gtk_widget_set_size_request (frame, 80, 60);
  150. -- gtk_paned_add2 (GTK_PANED (hpaned), frame);
  151. -- frame = gtk_frame_new (NULL);
  152. -- gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
  153. -- gtk_widget_set_size_request (frame, 60, 80);
  154. -- gtk_paned_add2 (GTK_PANED (vpaned), frame);
  155. -- /* Now create toggle buttons to control sizing */
  156. -- gtk_box_pack_start (GTK_BOX (vbox),
  157. -- create_pane_options (GTK_PANED (hpaned),
  158. -- "Horizontal",
  159. -- "Left",
  160. -- "Right"),
  161. -- FALSE, FALSE, 0);
  162. -- gtk_box_pack_start (GTK_BOX (vbox),
  163. -- create_pane_options (GTK_PANED (vpaned),
  164. -- "Vertical",
  165. -- "Top",
  166. -- "Bottom"),
  167. -- FALSE, FALSE, 0);
  168. -- gtk_widget_show_all (vbox);
  169. -- }
  170. -- if (!GTK_WIDGET_VISIBLE (window))
  171. -- {
  172. -- gtk_widget_show (window);
  173. -- }
  174. -- else
  175. -- {
  176. -- gtk_widget_destroy (window);
  177. -- window = NULL;
  178. -- }
  179. -- return window;
  180. -- }
  181. end