Use accessor functions to access GtkPaned

This commit is contained in:
Javier Jardón 2010-07-06 06:32:48 +02:00
parent 28cf61a2ca
commit 92a1382bd6
3 changed files with 40 additions and 24 deletions

View File

@ -18,11 +18,13 @@ toggle_resize (GtkWidget *widget,
GtkWidget *child) GtkWidget *child)
{ {
GtkPaned *paned = GTK_PANED (child->parent); GtkPaned *paned = GTK_PANED (child->parent);
gboolean is_child1 = (child == paned->child1); gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
gboolean resize, shrink; gboolean resize, shrink;
resize = is_child1 ? paned->child1_resize : paned->child2_resize; gtk_container_child_get (GTK_CONTAINER (paned), child,
shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink; "resize", &resize,
"shrink", &shrink,
NULL);
g_object_ref (child); g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (child->parent), child); gtk_container_remove (GTK_CONTAINER (child->parent), child);
@ -38,11 +40,13 @@ toggle_shrink (GtkWidget *widget,
GtkWidget *child) GtkWidget *child)
{ {
GtkPaned *paned = GTK_PANED (child->parent); GtkPaned *paned = GTK_PANED (child->parent);
gboolean is_child1 = (child == paned->child1); gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
gboolean resize, shrink; gboolean resize, shrink;
resize = is_child1 ? paned->child1_resize : paned->child2_resize; gtk_container_child_get (GTK_CONTAINER (paned), child,
shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink; "resize", &resize,
"shrink", &shrink,
NULL);
g_object_ref (child); g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (child->parent), child); gtk_container_remove (GTK_CONTAINER (child->parent), child);
@ -59,11 +63,15 @@ create_pane_options (GtkPaned *paned,
const gchar *label1, const gchar *label1,
const gchar *label2) const gchar *label2)
{ {
GtkWidget *child1, *child2;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *table; GtkWidget *table;
GtkWidget *label; GtkWidget *label;
GtkWidget *check_button; GtkWidget *check_button;
child1 = gtk_paned_get_child1 (paned);
child2 = gtk_paned_get_child2 (paned);
frame = gtk_frame_new (frame_label); frame = gtk_frame_new (frame_label);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4); gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
@ -78,16 +86,16 @@ create_pane_options (GtkPaned *paned,
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 1, 2); 0, 1, 1, 2);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), paned->child1); G_CALLBACK (toggle_resize), child1);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink"); check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 2, 3); 0, 1, 2, 3);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE); TRUE);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), paned->child1); G_CALLBACK (toggle_shrink), child1);
label = gtk_label_new (label2); label = gtk_label_new (label2);
gtk_table_attach_defaults (GTK_TABLE (table), label, gtk_table_attach_defaults (GTK_TABLE (table), label,
1, 2, 0, 1); 1, 2, 0, 1);
@ -98,15 +106,15 @@ create_pane_options (GtkPaned *paned,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE); TRUE);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), paned->child2); G_CALLBACK (toggle_resize), child2);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink"); check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 2, 3); 1, 2, 2, 3);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE); TRUE);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), paned->child2); G_CALLBACK (toggle_shrink), child2);
return frame; return frame;
} }

View File

@ -144,7 +144,9 @@ gail_paned_get_maximum_value (AtkValue *obj,
/* State is defunct */ /* State is defunct */
return; return;
maximum_value = GTK_PANED (widget)->max_position; g_object_get (GTK_PANED (widget),
"max-position", &maximum_value,
NULL);
memset (value, 0, sizeof (GValue)); memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT); g_value_init (value, G_TYPE_INT);
g_value_set_int (value, maximum_value); g_value_set_int (value, maximum_value);
@ -162,7 +164,9 @@ gail_paned_get_minimum_value (AtkValue *obj,
/* State is defunct */ /* State is defunct */
return; return;
minimum_value = GTK_PANED (widget)->min_position; g_object_get (GTK_PANED (widget),
"min-position", &minimum_value,
NULL);
memset (value, 0, sizeof (GValue)); memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT); g_value_init (value, G_TYPE_INT);
g_value_set_int (value, minimum_value); g_value_set_int (value, minimum_value);

View File

@ -7070,12 +7070,16 @@ create_pane_options (GtkPaned *paned,
const gchar *label1, const gchar *label1,
const gchar *label2) const gchar *label2)
{ {
GtkWidget *child1, *child2;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *table; GtkWidget *table;
GtkWidget *label; GtkWidget *label;
GtkWidget *button; GtkWidget *button;
GtkWidget *check_button; GtkWidget *check_button;
child1 = gtk_paned_get_child1 (paned);
child2 = gtk_paned_get_child2 (paned);
frame = gtk_frame_new (frame_label); frame = gtk_frame_new (frame_label);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4); gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
@ -7091,8 +7095,8 @@ create_pane_options (GtkPaned *paned,
0, 1, 1, 2); 0, 1, 1, 2);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), G_CALLBACK (toggle_resize),
paned->child1); child1);
check_button = gtk_check_button_new_with_label ("Shrink"); check_button = gtk_check_button_new_with_label ("Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 2, 3); 0, 1, 2, 3);
@ -7100,8 +7104,8 @@ create_pane_options (GtkPaned *paned,
TRUE); TRUE);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), G_CALLBACK (toggle_shrink),
paned->child1); child1);
label = gtk_label_new (label2); label = gtk_label_new (label2);
gtk_table_attach_defaults (GTK_TABLE (table), label, gtk_table_attach_defaults (GTK_TABLE (table), label,
1, 2, 0, 1); 1, 2, 0, 1);
@ -7113,8 +7117,8 @@ create_pane_options (GtkPaned *paned,
TRUE); TRUE);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), G_CALLBACK (toggle_resize),
paned->child2); child2);
check_button = gtk_check_button_new_with_label ("Shrink"); check_button = gtk_check_button_new_with_label ("Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 2, 3); 1, 2, 2, 3);
@ -7122,7 +7126,7 @@ create_pane_options (GtkPaned *paned,
TRUE); TRUE);
g_signal_connect (check_button, "toggled", g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), G_CALLBACK (toggle_shrink),
paned->child2); child2);
button = gtk_button_new_with_mnemonic ("_Properties"); button = gtk_button_new_with_mnemonic ("_Properties");
gtk_table_attach_defaults (GTK_TABLE (table), button, gtk_table_attach_defaults (GTK_TABLE (table), button,