After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 669116 - GtkNotebook's child-notify::position not always emitted as expected
GtkNotebook's child-notify::position not always emitted as expected
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.3.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-01-31 15:10 UTC by Claudio Saavedra
Modified: 2012-02-16 10:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (1.33 KB, text/plain)
2012-01-31 15:10 UTC, Claudio Saavedra
  Details
GtkNotebook: emit child-notify::position a few more times (1.41 KB, patch)
2012-02-07 16:06 UTC, Claudio Saavedra
reviewed Details | Review
GtkNotebook: emit child-notify::position a few more times (1.42 KB, patch)
2012-02-10 09:38 UTC, Claudio Saavedra
committed Details | Review
GtkNotebook: emit child-notify::position on page add/removal (2.09 KB, patch)
2012-02-10 14:49 UTC, Claudio Saavedra
committed Details | Review
GtkNotebook: emit child-notify::position on drag 'n drop reorder (1.60 KB, patch)
2012-02-14 15:27 UTC, Claudio Saavedra
committed Details | Review
GtkNotebook: fix one child-notify emission (1019 bytes, patch)
2012-02-16 10:29 UTC, Claudio Saavedra
committed Details | Review
GtkNotebook: and another fix (961 bytes, patch)
2012-02-16 10:33 UTC, Claudio Saavedra
committed Details | Review

Description Claudio Saavedra 2012-01-31 15:10:13 UTC
Created attachment 206523 [details]
test case

Unless I'm missing the obvious, I'd say that "child-notify" is not working at all.
Comment 1 Matthias Clasen 2012-02-05 23:38:06 UTC
Wrong conclusion. If you connect to child-notify on the other button, you will see it getting emitted. Its just that gtknotebook is not very good about emitting child-notify on other children that are affected by reordering.
Comment 2 Claudio Saavedra 2012-02-06 09:21:34 UTC
Just spent some minutes with this, and yes, I obviously connected the signal handler to the wrong button. However, child-notify in GtkNotebook is not very useful to keep track of the position of the notebook children soundly, apparently it's not even emitted when manually reordering the tabs.
Comment 3 Claudio Saavedra 2012-02-07 16:06:14 UTC
Created attachment 206995 [details] [review]
GtkNotebook: emit child-notify::position a few more times

When moving a page around, all children changing their position
need to be notified.

There are still other places where proper notification is missing
(drag 'n drop, etc.)
Comment 4 Matthias Clasen 2012-02-10 01:51:05 UTC
Review of attachment 206995 [details] [review]:

::: gtk/gtknotebook.c
@@ +8020,3 @@
+  list = g_list_nth (priv->children, MIN (old_pos, position));
+  for (i = ABS (old_pos - position) + 1; i > 0; i--, list = list->next)
+    gtk_widget_child_notify (((GtkNotebookPage *) list->data)->child, "position");

I think I would find this easier to follow as a straight loop over the children, like

for (list = priv->children, i = 0; list; list = list->next, i++)
  {
     if (MIN (old_pos, position) <= i && i <= MAX (old_pos, position))
       gtk_widget_child_notify (...)
  }
Comment 5 Claudio Saavedra 2012-02-10 09:38:18 UTC
Created attachment 207237 [details] [review]
GtkNotebook: emit child-notify::position a few more times

When moving a page around, all children changing their position
need to be notified.

There are still other places where proper notification is missing
(drag 'n drop, etc.)
Comment 6 Matthias Clasen 2012-02-10 12:52:58 UTC
Review of attachment 207237 [details] [review]:

Thanks, looks good
Comment 7 Claudio Saavedra 2012-02-10 14:42:29 UTC
Comment on attachment 207237 [details] [review]
GtkNotebook: emit child-notify::position a few more times

Attachment 207237 [details] pushed as e2339f5 - GtkNotebook: emit child-notify::position a few more times
Comment 8 Claudio Saavedra 2012-02-10 14:49:08 UTC
Created attachment 207258 [details] [review]
GtkNotebook: emit child-notify::position on page add/removal

For each page added/removed, notify all the other children changing
position.
Comment 9 Claudio Saavedra 2012-02-14 15:27:32 UTC
Created attachment 207528 [details] [review]
GtkNotebook: emit child-notify::position on drag 'n drop reorder
Comment 10 Claudio Saavedra 2012-02-14 15:29:58 UTC
I think that should do it to close this bug, unless I'm missing other entry points to reordering..
Comment 11 Matthias Clasen 2012-02-14 17:36:58 UTC
Review of attachment 207258 [details] [review]:

Looks right
Comment 12 Matthias Clasen 2012-02-14 17:37:57 UTC
Review of attachment 207528 [details] [review]:

Looks right, too
Comment 13 Claudio Saavedra 2012-02-14 23:06:35 UTC
Thank you, Matthias. Pushing and closing the bug.

Attachment 207258 [details] pushed as cb775a6 - GtkNotebook: emit child-notify::position on page add/removal
Attachment 207528 [details] pushed as 347328a - GtkNotebook: emit child-notify::position on drag 'n drop reorder
Comment 14 Claudio Saavedra 2012-02-16 10:20:45 UTC
Review of attachment 207237 [details] [review]:

::: gtk/gtknotebook.c
@@ +8018,3 @@
   gtk_notebook_child_reordered (notebook, page);
+
+  for (list = priv->children, i = 0; list; list = list->next)

I forgot to increase the counter here, my bad. I'm fixing this in master.
Comment 15 Claudio Saavedra 2012-02-16 10:28:47 UTC
The following fix has been pushed:
ccf7867 GtkNotebook: fix one child-notify emission
Comment 16 Claudio Saavedra 2012-02-16 10:29:01 UTC
Created attachment 207741 [details] [review]
GtkNotebook: fix one child-notify emission

Forgot to increase the counter in the for loop, doing it now.
Comment 17 Claudio Saavedra 2012-02-16 10:33:27 UTC
The following fix has been pushed:
cfe65a0 GtkNotebook: and another fix
Comment 18 Claudio Saavedra 2012-02-16 10:33:31 UTC
Created attachment 207742 [details] [review]
GtkNotebook: and another fix