| 61 GtkExpanderStyle expander_style; |
61 GtkExpanderStyle expander_style; |
| 62 guint animation_timeout; |
62 guint animation_timeout; |
| 63 |
63 |
| 64 guint expanded : 1; |
64 guint expanded : 1; |
| 65 guint use_underline : 1; |
65 guint use_underline : 1; |
| 66 guint use_markup : 1; |
66 guint use_markup : 1; |
| 67 guint button_down : 1; |
67 guint button_down : 1; |
| 68 guint prelight : 1; |
68 guint prelight : 1; |
| 69 }; |
69 }; |
| 70 |
70 |
| 71 static void gtk_expander_class_init (GtkExpanderClass *klass); |
71 static void gtk_expander_class_init (GtkExpanderClass *klass); |
| 142 NULL, /* class_data */ |
142 NULL, /* class_data */ |
| 143 sizeof (GtkExpander), |
143 sizeof (GtkExpander), |
| 144 0, /* n_preallocs */ |
144 0, /* n_preallocs */ |
| 145 (GInstanceInitFunc) gtk_expander_init, |
145 (GInstanceInitFunc) gtk_expander_init, |
| 146 }; |
146 }; |
| 147 |
147 |
| 148 expander_type = g_type_register_static (GTK_TYPE_BIN, |
148 expander_type = g_type_register_static (GTK_TYPE_BIN, |
| 149 "GtkExpander", |
149 "GtkExpander", |
| 150 &expander_info, 0); |
150 &expander_info, 0); |
| 151 } |
151 } |
| 152 |
152 |
| 153 return expander_type; |
153 return expander_type; |
| 154 } |
154 } |
| 155 |
155 |
| 156 static void |
156 static void |
| 157 gtk_expander_class_init (GtkExpanderClass *klass) |
157 gtk_expander_class_init (GtkExpanderClass *klass) |
| 380 |
380 |
| 381 static void |
381 static void |
| 382 gtk_expander_destroy (GtkObject *object) |
382 gtk_expander_destroy (GtkObject *object) |
| 383 { |
383 { |
| 384 GtkExpanderPrivate *priv = GTK_EXPANDER (object)->priv; |
384 GtkExpanderPrivate *priv = GTK_EXPANDER (object)->priv; |
| 385 |
385 |
| 386 if (priv->animation_timeout) |
386 if (priv->animation_timeout) |
| 387 { |
387 { |
| 388 g_source_remove (priv->animation_timeout); |
388 g_source_remove (priv->animation_timeout); |
| 389 priv->animation_timeout = 0; |
389 priv->animation_timeout = 0; |
| 390 } |
390 } |
| 405 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); |
405 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); |
| 406 |
406 |
| 407 border_width = GTK_CONTAINER (widget)->border_width; |
407 border_width = GTK_CONTAINER (widget)->border_width; |
| 408 |
408 |
| 409 get_expander_bounds (GTK_EXPANDER (widget), &expander_rect); |
409 get_expander_bounds (GTK_EXPANDER (widget), &expander_rect); |
| 410 |
410 |
| 411 attributes.window_type = GDK_WINDOW_CHILD; |
411 attributes.window_type = GDK_WINDOW_CHILD; |
| 412 attributes.x = widget->allocation.x + border_width; |
412 attributes.x = widget->allocation.x + border_width; |
| 413 attributes.y = expander_rect.y; |
413 attributes.y = expander_rect.y; |
| 414 attributes.width = MAX (widget->allocation.width - 2 * border_width, 1); |
414 attributes.width = MAX (widget->allocation.width - 2 * border_width, 1); |
| 415 attributes.height = expander_rect.width; |
415 attributes.height = expander_rect.width; |
| 829 "expander-size", &expander_size, |
829 "expander-size", &expander_size, |
| 830 "expander-spacing", &expander_spacing, |
830 "expander-spacing", &expander_spacing, |
| 831 NULL); |
831 NULL); |
| 832 |
832 |
| 833 ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; |
833 ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; |
| 834 |
834 |
| 835 x = widget->allocation.x + border_width; |
835 x = widget->allocation.x + border_width; |
| 836 y = widget->allocation.y + border_width; |
836 y = widget->allocation.y + border_width; |
| 837 |
837 |
| 838 if (ltr && interior_focus) |
838 if (ltr && interior_focus) |
| 839 x += expander_spacing * 2 + expander_size; |
839 x += expander_spacing * 2 + expander_size; |
| 851 if (!interior_focus) |
851 if (!interior_focus) |
| 852 { |
852 { |
| 853 width += expander_size + 2 * expander_spacing; |
853 width += expander_size + 2 * expander_spacing; |
| 854 height = MAX (height, expander_size + 2 * expander_spacing); |
854 height = MAX (height, expander_size + 2 * expander_spacing); |
| 855 } |
855 } |
| 856 |
856 |
| 857 width += 2 * focus_pad + 2 * focus_width; |
857 width += 2 * focus_pad + 2 * focus_width; |
| 858 height += 2 * focus_pad + 2 * focus_width; |
858 height += 2 * focus_pad + 2 * focus_width; |
| 859 |
859 |
| 860 gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), |
860 gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), |
| 861 area, widget, "expander", |
861 area, widget, "expander", |
| 1113 static gboolean |
1113 static gboolean |
| 1114 gtk_expander_focus (GtkWidget *widget, |
1114 gtk_expander_focus (GtkWidget *widget, |
| 1115 GtkDirectionType direction) |
1115 GtkDirectionType direction) |
| 1116 { |
1116 { |
| 1117 GtkExpander *expander = GTK_EXPANDER (widget); |
1117 GtkExpander *expander = GTK_EXPANDER (widget); |
| 1118 |
1118 |
| 1119 if (!focus_current_site (expander, direction)) |
1119 if (!focus_current_site (expander, direction)) |
| 1120 { |
1120 { |
| 1121 GtkWidget *old_focus_child; |
1121 GtkWidget *old_focus_child; |
| 1122 gboolean widget_is_focus; |
1122 gboolean widget_is_focus; |
| 1123 FocusSite site = FOCUS_NONE; |
1123 FocusSite site = FOCUS_NONE; |
| 1124 |
1124 |
| 1125 widget_is_focus = gtk_widget_is_focus (widget); |
1125 widget_is_focus = gtk_widget_is_focus (widget); |
| 1126 old_focus_child = GTK_CONTAINER (widget)->focus_child; |
1126 old_focus_child = GTK_CONTAINER (widget)->focus_child; |
| 1127 |
1127 |
| 1128 if (old_focus_child && old_focus_child == expander->priv->label_widget) |
1128 if (old_focus_child && old_focus_child == expander->priv->label_widget) |
| 1129 site = FOCUS_LABEL; |
1129 site = FOCUS_LABEL; |
| 1130 else if (old_focus_child) |
1130 else if (old_focus_child) |
| 1131 site = FOCUS_CHILD; |
1131 site = FOCUS_CHILD; |
| 1132 else if (widget_is_focus) |
1132 else if (widget_is_focus) |
| 1207 |
1207 |
| 1208 /** |
1208 /** |
| 1209 * gtk_expander_new_with_mnemonic: |
1209 * gtk_expander_new_with_mnemonic: |
| 1210 * @label: the text of the label with an underscore in front of the |
1210 * @label: the text of the label with an underscore in front of the |
| 1211 * mnemonic character |
1211 * mnemonic character |
| 1212 * |
1212 * |
| 1213 * Creates a new expander using @label as the text of the label. |
1213 * Creates a new expander using @label as the text of the label. |
| 1214 * If characters in @label are preceded by an underscore, they are underlined. |
1214 * If characters in @label are preceded by an underscore, they are underlined. |
| 1215 * If you need a literal underscore character in a label, use '__' (two |
1215 * If you need a literal underscore character in a label, use '__' (two |
| 1216 * underscores). The first underlined character represents a keyboard |
1216 * underscores). The first underlined character represents a keyboard |
| 1217 * accelerator called a mnemonic. |
1217 * accelerator called a mnemonic. |
| 1218 * Pressing Alt and that key activates the button. |
1218 * Pressing Alt and that key activates the button. |
| 1219 * |
1219 * |
| 1220 * Return value: a new #GtkExpander widget. |
1220 * Return value: a new #GtkExpander widget. |
| 1221 * |
1221 * |
| 1222 * Since: 2.4 |
1222 * Since: 2.4 |
| 1223 **/ |
1223 **/ |
| 1224 GtkWidget * |
1224 GtkWidget * |
| 1326 |
1326 |
| 1327 if (GTK_WIDGET_REALIZED (expander)) |
1327 if (GTK_WIDGET_REALIZED (expander)) |
| 1328 { |
1328 { |
| 1329 gtk_expander_start_animation (expander); |
1329 gtk_expander_start_animation (expander); |
| 1330 } |
1330 } |
| 1331 else |
1331 else |
| 1332 { |
1332 { |
| 1333 priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED : |
1333 priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED : |
| 1334 GTK_EXPANDER_COLLAPSED; |
1334 GTK_EXPANDER_COLLAPSED; |
| 1335 |
1335 |
| 1336 if (GTK_BIN (expander)->child) |
1336 if (GTK_BIN (expander)->child) |