Patch to add gtk_container_get_focus_child



Here is a patch (I will also open a bug), to add a function
gtk_container_get_focus_child to gtkcontainer.c

All it does is return the focus_child variable from the container
object.

The reason this is important is (for example) when the Edit menu is
dropped down and copy is selected, it is easy to find out which widget
should be sent the "copy_clipboard" signal.

Let me know what you think.

I also have another function "lookup_focus_widget", which if given one
widget (e.g. the menu entry) it will go up the tree until it finds the
top container, then back down again until the focused widget is found. I
think it would be useful to have as a utility function, however I am not
sure where it would be sensible for it go. Do you want the function and
if so which source file would make sense?

Damian


-- 
Damian Ivereigh
CEPS Team Lead
http://wwwin-print.cisco.com
Desk: +61 2 8446 6344
Mob: +61 418 217 582
--- gtk/gtkcontainer.c.old	Sun Oct 28 00:25:16 2001
+++ gtk/gtkcontainer.c	Sun Oct 28 01:00:15 2001
@@ -1393,6 +1393,25 @@
   gtk_signal_emit (GTK_OBJECT (container), container_signals[SET_FOCUS_CHILD], widget);
 }
 
+/**
+ * gtk_container_get_focus_child:
+ * @container: a #GtkContainer
+ * 
+ * Retrieves the currently focused child of the container. See
+ * gtk_container_set_focus_child().
+ *
+ * Return value: pointer to the widget of the focused child (NULL
+ * if none is set
+ **/
+GtkWidget *
+gtk_container_get_focus_child (GtkContainer *container)
+{
+  g_return_val_if_fail (container != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
+
+  return container->focus_child;
+}
+
 GList*
 gtk_container_get_children (GtkContainer *container)
 {
--- gtk/gtkcontainer.h.old	Sun Oct 28 00:25:32 2001
+++ gtk/gtkcontainer.h	Sun Oct 28 00:32:37 2001
@@ -149,6 +149,7 @@
 					     gboolean         needs_redraws);
 void   gtk_container_set_focus_child	   (GtkContainer     *container,
 					    GtkWidget	     *child);
+GtkWidget *gtk_container_get_focus_child   (GtkContainer     *container);
 void   gtk_container_set_focus_vadjustment (GtkContainer     *container,
 					    GtkAdjustment    *adjustment);
 GtkAdjustment *gtk_container_get_focus_vadjustment (GtkContainer *container);

Attachment: pgpBxjCcPVIHZ.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]