[gtk+/refactor: 77/106] Use accessor functions to access GtkPaned
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 77/106] Use accessor functions to access GtkPaned
- Date: Tue, 13 Jul 2010 17:36:28 +0000 (UTC)
commit 964f7680c309970a610968e18347b7bb82fc9a70
Author: Javier Jardón <jjardon gnome org>
Date: Tue Jul 6 06:32:48 2010 +0200
Use accessor functions to access GtkPaned
demos/gtk-demo/panes.c | 36 ++++++++++++++++++++++--------------
modules/other/gail/gailpaned.c | 8 ++++++--
tests/testgtk.c | 20 ++++++++++++--------
3 files changed, 40 insertions(+), 24 deletions(-)
---
diff --git a/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c
index 93f1aa1..60ee2dd 100644
--- a/demos/gtk-demo/panes.c
+++ b/demos/gtk-demo/panes.c
@@ -18,11 +18,13 @@ toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
GtkPaned *paned = GTK_PANED (child->parent);
- gboolean is_child1 = (child == paned->child1);
+ gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
gboolean resize, shrink;
- resize = is_child1 ? paned->child1_resize : paned->child2_resize;
- shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
+ gtk_container_child_get (GTK_CONTAINER (paned), child,
+ "resize", &resize,
+ "shrink", &shrink,
+ NULL);
g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (child->parent), child);
@@ -38,11 +40,13 @@ toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
GtkPaned *paned = GTK_PANED (child->parent);
- gboolean is_child1 = (child == paned->child1);
+ gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
gboolean resize, shrink;
- resize = is_child1 ? paned->child1_resize : paned->child2_resize;
- shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
+ gtk_container_child_get (GTK_CONTAINER (paned), child,
+ "resize", &resize,
+ "shrink", &shrink,
+ NULL);
g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (child->parent), child);
@@ -59,11 +63,15 @@ create_pane_options (GtkPaned *paned,
const gchar *label1,
const gchar *label2)
{
+ GtkWidget *child1, *child2;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *check_button;
-
+
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+
frame = gtk_frame_new (frame_label);
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,
0, 1, 1, 2);
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");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 2, 3);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE);
g_signal_connect (check_button, "toggled",
- G_CALLBACK (toggle_shrink), paned->child1);
-
+ G_CALLBACK (toggle_shrink), child1);
+
label = gtk_label_new (label2);
gtk_table_attach_defaults (GTK_TABLE (table), label,
1, 2, 0, 1);
@@ -98,15 +106,15 @@ create_pane_options (GtkPaned *paned,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE);
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");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 2, 3);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE);
g_signal_connect (check_button, "toggled",
- G_CALLBACK (toggle_shrink), paned->child2);
+ G_CALLBACK (toggle_shrink), child2);
return frame;
}
diff --git a/modules/other/gail/gailpaned.c b/modules/other/gail/gailpaned.c
index 5ac7cf3..1e1404b 100644
--- a/modules/other/gail/gailpaned.c
+++ b/modules/other/gail/gailpaned.c
@@ -144,7 +144,9 @@ gail_paned_get_maximum_value (AtkValue *obj,
/* State is defunct */
return;
- maximum_value = GTK_PANED (widget)->max_position;
+ g_object_get (GTK_PANED (widget),
+ "max-position", &maximum_value,
+ NULL);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, maximum_value);
@@ -162,7 +164,9 @@ gail_paned_get_minimum_value (AtkValue *obj,
/* State is defunct */
return;
- minimum_value = GTK_PANED (widget)->min_position;
+ g_object_get (GTK_PANED (widget),
+ "min-position", &minimum_value,
+ NULL);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, minimum_value);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index f0fcb90..d196276 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -7070,12 +7070,16 @@ create_pane_options (GtkPaned *paned,
const gchar *label1,
const gchar *label2)
{
+ GtkWidget *child1, *child2;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *button;
GtkWidget *check_button;
-
+
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+
frame = gtk_frame_new (frame_label);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
@@ -7091,8 +7095,8 @@ create_pane_options (GtkPaned *paned,
0, 1, 1, 2);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize),
- paned->child1);
-
+ child1);
+
check_button = gtk_check_button_new_with_label ("Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 2, 3);
@@ -7100,8 +7104,8 @@ create_pane_options (GtkPaned *paned,
TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink),
- paned->child1);
-
+ child1);
+
label = gtk_label_new (label2);
gtk_table_attach_defaults (GTK_TABLE (table), label,
1, 2, 0, 1);
@@ -7113,8 +7117,8 @@ create_pane_options (GtkPaned *paned,
TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize),
- paned->child2);
-
+ child2);
+
check_button = gtk_check_button_new_with_label ("Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 2, 3);
@@ -7122,7 +7126,7 @@ create_pane_options (GtkPaned *paned,
TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink),
- paned->child2);
+ child2);
button = gtk_button_new_with_mnemonic ("_Properties");
gtk_table_attach_defaults (GTK_TABLE (table), button,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]