PageRenderTime 15ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1indexing
  2	description: "."
  3	copyright: "[
  4					Copyright (C) 2006 Paolo Redaelli, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20			]"
 21
 22class PANES
 23
 24creation make
 25
 26feature 
 27-- /* Paned Widgets
 28--  *
 29--  * The GtkHPaned and GtkVPaned Widgets divide their content
 30--  * area into two panes with a divider in between that the
 31--  * user can adjust. A separate child is placed into each
 32--  * pane.
 33--  *
 34--  * There are a number of options that can be set for each pane.
 35--  * This test contains both a horizontal (HPaned) and a vertical
 36--  * (VPaned) widget, and allows you to adjust the options for
 37--  * each side of each widget.
 38--  */
 39
 40-- #include <gtk/gtk.h>
 41
 42-- void
 43-- toggle_resize (GtkWidget *widget,
 44-- 	       GtkWidget *child)
 45-- {
 46--   GtkPaned *paned = GTK_PANED (child->parent);
 47--   gboolean is_child1 = (child == paned->child1);
 48--   gboolean resize, shrink;
 49
 50--   resize = is_child1 ? paned->child1_resize : paned->child2_resize;
 51--   shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
 52
 53--   gtk_widget_ref (child);
 54--   gtk_container_remove (GTK_CONTAINER (child->parent), child);
 55--   if (is_child1)
 56--     gtk_paned_pack1 (paned, child, !resize, shrink);
 57--   else
 58--     gtk_paned_pack2 (paned, child, !resize, shrink);
 59--   gtk_widget_unref (child);
 60-- }
 61
 62-- void
 63-- toggle_shrink (GtkWidget *widget,
 64-- 	       GtkWidget *child)
 65-- {
 66--   GtkPaned *paned = GTK_PANED (child->parent);
 67--   gboolean is_child1 = (child == paned->child1);
 68--   gboolean resize, shrink;
 69
 70--   resize = is_child1 ? paned->child1_resize : paned->child2_resize;
 71--   shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
 72
 73--   gtk_widget_ref (child);
 74--   gtk_container_remove (GTK_CONTAINER (child->parent), child);
 75--   if (is_child1)
 76--     gtk_paned_pack1 (paned, child, resize, !shrink);
 77--   else
 78--     gtk_paned_pack2 (paned, child, resize, !shrink);
 79--   gtk_widget_unref (child);
 80-- }
 81
 82-- GtkWidget *
 83-- create_pane_options (GtkPaned	 *paned,
 84-- 		     const gchar *frame_label,
 85-- 		     const gchar *label1,
 86-- 		     const gchar *label2)
 87-- {
 88--   GtkWidget *frame;
 89--   GtkWidget *table;
 90--   GtkWidget *label;
 91--   GtkWidget *check_button;
 92  
 93--   frame = gtk_frame_new (frame_label);
 94--   gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
 95  
 96--   table = gtk_table_new (3, 2, TRUE);
 97--   gtk_container_add (GTK_CONTAINER (frame), table);
 98  
 99--   label = gtk_label_new (label1);
100--   gtk_table_attach_defaults (GTK_TABLE (table), label,
101-- 			     0, 1, 0, 1);
102  
103--   check_button = gtk_check_button_new_with_mnemonic ("_Resize");
104--   gtk_table_attach_defaults (GTK_TABLE (table), check_button,
105-- 			     0, 1, 1, 2);
106--   g_signal_connect (check_button, "toggled",
107-- 		    G_CALLBACK (toggle_resize), paned->child1);
108  
109--   check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
110--   gtk_table_attach_defaults (GTK_TABLE (table), check_button,
111-- 			     0, 1, 2, 3);
112--   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
113-- 			       TRUE);
114--   g_signal_connect (check_button, "toggled",
115-- 		    G_CALLBACK (toggle_shrink), paned->child1);
116  
117--   label = gtk_label_new (label2);
118--   gtk_table_attach_defaults (GTK_TABLE (table), label,
119-- 			     1, 2, 0, 1);
120  
121--   check_button = gtk_check_button_new_with_mnemonic ("_Resize");
122--   gtk_table_attach_defaults (GTK_TABLE (table), check_button,
123-- 			     1, 2, 1, 2);
124--   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
125-- 			       TRUE);
126--   g_signal_connect (check_button, "toggled",
127-- 		    G_CALLBACK (toggle_resize), paned->child2);
128  
129--   check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
130--   gtk_table_attach_defaults (GTK_TABLE (table), check_button,
131-- 			     1, 2, 2, 3);
132--   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
133-- 			       TRUE);
134--   g_signal_connect (check_button, "toggled",
135-- 		    G_CALLBACK (toggle_shrink), paned->child2);
136
137--   return frame;
138-- }
139
140-- GtkWidget *
141-- do_panes (GtkWidget *do_widget)
142-- {
143--   static GtkWidget *window = NULL;
144--   GtkWidget *frame;
145--   GtkWidget *hpaned;
146--   GtkWidget *vpaned;
147--   GtkWidget *button;
148--   GtkWidget *vbox;
149
150--   if (!window)
151--     {
152--       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
153--       gtk_window_set_screen (GTK_WINDOW (window),
154-- 			     gtk_widget_get_screen (do_widget));
155
156--       g_signal_connect (window, "destroy",
157-- 			G_CALLBACK (gtk_widget_destroyed), &window);
158
159--       gtk_window_set_title (GTK_WINDOW (window), "Panes");
160--       gtk_container_set_border_width (GTK_CONTAINER (window), 0);
161
162--       vbox = gtk_vbox_new (FALSE, 0);
163--       gtk_container_add (GTK_CONTAINER (window), vbox);
164		
165--       vpaned = gtk_vpaned_new ();
166--       gtk_box_pack_start (GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);
167--       gtk_container_set_border_width (GTK_CONTAINER(vpaned), 5);
168
169--       hpaned = gtk_hpaned_new ();
170--       gtk_paned_add1 (GTK_PANED (vpaned), hpaned);
171
172--       frame = gtk_frame_new (NULL);
173--       gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
174--       gtk_widget_set_size_request (frame, 60, 60);
175--       gtk_paned_add1 (GTK_PANED (hpaned), frame);
176		
177--       button = gtk_button_new_with_mnemonic ("_Hi there");
178--       gtk_container_add (GTK_CONTAINER(frame), button);
179
180--       frame = gtk_frame_new (NULL);
181--       gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
182--       gtk_widget_set_size_request (frame, 80, 60);
183--       gtk_paned_add2 (GTK_PANED (hpaned), frame);
184
185--       frame = gtk_frame_new (NULL);
186--       gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
187--       gtk_widget_set_size_request (frame, 60, 80);
188--       gtk_paned_add2 (GTK_PANED (vpaned), frame);
189
190--       /* Now create toggle buttons to control sizing */
191
192--       gtk_box_pack_start (GTK_BOX (vbox),
193-- 			  create_pane_options (GTK_PANED (hpaned),
194-- 					       "Horizontal",
195-- 					       "Left",
196-- 					       "Right"),
197-- 			  FALSE, FALSE, 0);
198
199--       gtk_box_pack_start (GTK_BOX (vbox),
200-- 			  create_pane_options (GTK_PANED (vpaned),
201-- 					       "Vertical",
202-- 					       "Top",
203-- 					       "Bottom"),
204-- 			  FALSE, FALSE, 0);
205
206--       gtk_widget_show_all (vbox);
207--     }
208
209--   if (!GTK_WIDGET_VISIBLE (window))
210--     {
211--       gtk_widget_show (window);
212--     }
213--   else
214--     {
215--       gtk_widget_destroy (window);
216--       window = NULL;
217--     }
218
219--   return window;
220-- }
221end
222