2005-02-25 [paul] 1.0.1cvs15.12
[claws.git] / src / gtk / gtkutils.c
index 6f04f9a47d4b0a5218c587cb75693acd99f3792d..b23177ca4f1f9dee7b0822fc30f72691eb01cd40 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 #endif
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 #include <gdk/gdk.h>
 #include <gtk/gtkwidget.h>
@@ -29,8 +30,8 @@
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkctree.h>
 #include <gtk/gtkcombo.h>
-#include <gtk/gtkthemes.h>
 #include <gtk/gtkbindings.h>
+#include <gtk/gtkitemfactory.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <sys/stat.h>
@@ -40,7 +41,7 @@
 #  include <wctype.h>
 #endif
 
-#include "intl.h"
+#include "defs.h"
 #include "gtkutils.h"
 #include "utils.h"
 #include "gtksctree.h"
 #include "stock_pixmap.h"
 #include "menu.h"
 #include "prefs_account.h"
+#include "prefs_common.h"
 
-gint gtkut_get_font_width(GdkFont *font)
+#warning FIXME_GTK2
+gboolean gtkut_get_font_size(GtkWidget *widget,
+                            gint *width, gint *height)
 {
-       gchar *str;
-       gint width;
+       PangoLayout *layout;
+       const gchar *str = "Abcdef";
 
-       if (conv_get_current_charset() == C_UTF_8)
-               str = "Abcdef";
-       else
-               str = _("Abcdef");
-
-       width = gdk_string_width(font, str);
-       width /= strlen(str);
-
-       return width;
-}
-
-gint gtkut_get_font_height(GdkFont *font)
-{
-       gchar *str;
-       gint height;
-
-       if (conv_get_current_charset() == C_UTF_8)
-               str = "Abcdef";
-       else
-               str = _("Abcdef");
+       g_return_val_if_fail(GTK_IS_WIDGET(widget), FALSE);
 
-       height = gdk_string_height(font, str);
+       layout = gtk_widget_create_pango_layout(widget, str);
+       g_return_val_if_fail(layout, FALSE);
+       pango_layout_get_pixel_size(layout, width, height);
+       if (width)
+               *width = *width / g_utf8_strlen(str, -1);
+       g_object_unref(layout);
 
-       return height;
+       return TRUE;
 }
 
-GdkFont *gtkut_font_load(const gchar *fontset_name)
+void gtkut_widget_set_small_font_size(GtkWidget *widget)
 {
-       GdkFont *font;
+       PangoFontDescription *font_desc;
+       gint size;
 
-       g_return_val_if_fail(fontset_name != NULL, NULL);
-
-       if (conv_get_current_charset() == C_US_ASCII)
-               font = gtkut_font_load_from_fontset(fontset_name);
-       else
-               font = gdk_fontset_load(fontset_name);
-
-       return font;
-}
-
-GdkFont *gtkut_font_load_from_fontset(const gchar *fontset_name)
-{
-       GdkFont *font = NULL;
-
-       if (strchr(fontset_name, ',') == NULL) {
-               font = gdk_font_load(fontset_name);
-       } else {
-               gchar **fonts;
-               gint i;
-
-               fonts = g_strsplit(fontset_name, ",", -1);
-               for (i = 0; fonts[i] != NULL && fonts[i][0] != '\0';
-                    i++) {
-                       font = gdk_font_load(fonts[i]);
-                       if (font) break;
-               }
-               g_strfreev(fonts);
-       }
+       g_return_if_fail(widget != NULL);
+       g_return_if_fail(widget->style != NULL);
 
-       return font;
+       font_desc = pango_font_description_from_string(NORMAL_FONT);
+       size = pango_font_description_get_size(font_desc);
+       pango_font_description_set_size(font_desc, size * PANGO_SCALE_SMALL);
+       gtk_widget_modify_font(widget, font_desc);
+       pango_font_description_free(font_desc);
 }
 
 void gtkut_convert_int_to_gdk_color(gint rgbvalue, GdkColor *color)
@@ -136,7 +105,7 @@ void gtkut_button_set_create(GtkWidget **bbox,
 
        *bbox = gtk_hbutton_box_new();
        gtk_button_box_set_layout(GTK_BUTTON_BOX(*bbox), GTK_BUTTONBOX_END);
-       gtk_button_box_set_spacing(GTK_BUTTON_BOX(*bbox), 5);
+       gtk_box_set_spacing(GTK_BOX(*bbox), 5);
 
        *button1 = gtk_button_new_with_label(label1);
        GTK_WIDGET_SET_FLAGS(*button1, GTK_CAN_DEFAULT);
@@ -158,6 +127,139 @@ void gtkut_button_set_create(GtkWidget **bbox,
        }
 }
 
+void gtkut_stock_button_set_create(GtkWidget **bbox,
+                                  GtkWidget **button1, const gchar *label1,
+                                  GtkWidget **button2, const gchar *label2,
+                                  GtkWidget **button3, const gchar *label3)
+{
+       g_return_if_fail(bbox != NULL);
+       g_return_if_fail(button1 != NULL);
+
+       *bbox = gtk_hbutton_box_new();
+       gtk_button_box_set_layout(GTK_BUTTON_BOX(*bbox), GTK_BUTTONBOX_END);
+       gtk_box_set_spacing(GTK_BOX(*bbox), 5);
+
+       *button1 = gtk_button_new_from_stock(label1);
+       GTK_WIDGET_SET_FLAGS(*button1, GTK_CAN_DEFAULT);
+       gtk_box_pack_start(GTK_BOX(*bbox), *button1, TRUE, TRUE, 0);
+       gtk_widget_show(*button1);
+
+       if (button2) {
+               *button2 = gtk_button_new_from_stock(label2);
+               GTK_WIDGET_SET_FLAGS(*button2, GTK_CAN_DEFAULT);
+               gtk_box_pack_start(GTK_BOX(*bbox), *button2, TRUE, TRUE, 0);
+               gtk_widget_show(*button2);
+       }
+
+       if (button3) {
+               *button3 = gtk_button_new_from_stock(label3);
+               GTK_WIDGET_SET_FLAGS(*button3, GTK_CAN_DEFAULT);
+               gtk_box_pack_start(GTK_BOX(*bbox), *button3, TRUE, TRUE, 0);
+               gtk_widget_show(*button3);
+       }
+}
+
+static void combo_button_size_request(GtkWidget *widget,
+                                     GtkRequisition *requisition,
+                                     gpointer data)
+{
+       ComboButton *combo = (ComboButton *)data;
+
+       if (combo->arrow->allocation.height != requisition->height)
+               gtk_widget_set_size_request(combo->arrow,
+                                           -1, requisition->height);
+}
+
+static void combo_button_enter(GtkWidget *widget, gpointer data)
+{
+       ComboButton *combo = (ComboButton *)data;
+
+       if (GTK_WIDGET_STATE(combo->arrow) != GTK_STATE_PRELIGHT) {
+               gtk_widget_set_state(combo->arrow, GTK_STATE_PRELIGHT);
+               gtk_widget_queue_draw(combo->arrow);
+       }
+       if (GTK_WIDGET_STATE(combo->button) != GTK_STATE_PRELIGHT) {
+               gtk_widget_set_state(combo->button, GTK_STATE_PRELIGHT);
+               gtk_widget_queue_draw(combo->button);
+       }
+}
+
+static void combo_button_leave(GtkWidget *widget, gpointer data)
+{
+       ComboButton *combo = (ComboButton *)data;
+
+       if (GTK_WIDGET_STATE(combo->arrow) != GTK_STATE_NORMAL) {
+               gtk_widget_set_state(combo->arrow, GTK_STATE_NORMAL);
+               gtk_widget_queue_draw(combo->arrow);
+       }
+       if (GTK_WIDGET_STATE(combo->button) != GTK_STATE_NORMAL) {
+               gtk_widget_set_state(combo->button, GTK_STATE_NORMAL);
+               gtk_widget_queue_draw(combo->button);
+       }
+}
+
+static gint combo_button_arrow_pressed(GtkWidget *widget, GdkEventButton *event,
+                                      gpointer data)
+{
+       ComboButton *combo = (ComboButton *)data;
+
+       if (!event) return FALSE;
+
+       gtk_menu_popup(GTK_MENU(combo->menu), NULL, NULL,
+                      menu_button_position, combo->button,
+                      event->button, event->time);
+
+       return FALSE;
+}
+
+static void combo_button_destroy(GtkWidget *widget, gpointer data)
+{
+       ComboButton *combo = (ComboButton *)data;
+
+       gtk_object_destroy(GTK_OBJECT(combo->factory));
+       g_free(combo);
+}
+
+ComboButton *gtkut_combo_button_create(GtkWidget *button,
+                                      GtkItemFactoryEntry *entries,
+                                      gint n_entries, const gchar *path,
+                                      gpointer data)
+{
+       ComboButton *combo;
+       GtkWidget *arrow;
+
+       combo = g_new0(ComboButton, 1);
+
+       combo->arrow = gtk_button_new();
+       arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+       gtk_widget_set_size_request(arrow, 7, -1);
+       gtk_container_add(GTK_CONTAINER(combo->arrow), arrow);
+       GTK_WIDGET_UNSET_FLAGS(combo->arrow, GTK_CAN_FOCUS);
+       gtk_widget_show_all(combo->arrow);
+
+       combo->button = button;
+       combo->menu = menu_create_items(entries, n_entries, path,
+                                       &combo->factory, data);
+       combo->data = data;
+
+       g_signal_connect(G_OBJECT(combo->button), "size_request",
+                        G_CALLBACK(combo_button_size_request), combo);
+       g_signal_connect(G_OBJECT(combo->button), "enter",
+                        G_CALLBACK(combo_button_enter), combo);
+       g_signal_connect(G_OBJECT(combo->button), "leave",
+                        G_CALLBACK(combo_button_leave), combo);
+       g_signal_connect(G_OBJECT(combo->arrow), "enter",
+                        G_CALLBACK(combo_button_enter), combo);
+       g_signal_connect(G_OBJECT(combo->arrow), "leave",
+                        G_CALLBACK(combo_button_leave), combo);
+       g_signal_connect(G_OBJECT(combo->arrow), "button_press_event",
+                        G_CALLBACK(combo_button_arrow_pressed), combo);
+       g_signal_connect(G_OBJECT(combo->arrow), "destroy",
+                        G_CALLBACK(combo_button_destroy), combo);
+
+       return combo;
+}
+
 #define CELL_SPACING 1
 #define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
                                    (((row) + 1) * CELL_SPACING) + \
@@ -343,23 +445,32 @@ void gtkut_combo_set_items(GtkCombo *combo, const gchar *str1, ...)
 gchar *gtkut_editable_get_selection(GtkEditable *editable)
 {
        guint start_pos, end_pos;
+       gboolean found;
 
-       g_return_val_if_fail(editable != NULL, NULL);
+       g_return_val_if_fail(GTK_IS_EDITABLE(editable), NULL);
 
-       if (!editable->has_selection) return NULL;
-
-       if (editable->selection_start_pos == editable->selection_end_pos)
+       found = gtk_editable_get_selection_bounds(editable,
+                                                 &start_pos, &end_pos);
+       if (found)
+               return gtk_editable_get_chars(editable, start_pos, end_pos);
+       else
                return NULL;
+}
 
-       if (editable->selection_start_pos < editable->selection_end_pos) {
-               start_pos = editable->selection_start_pos;
-               end_pos = editable->selection_end_pos;
-       } else {
-               start_pos = editable->selection_end_pos;
-               end_pos = editable->selection_start_pos;
-       }
+void gtkut_editable_disable_im(GtkEditable *editable)
+{
+       g_return_if_fail(editable != NULL);
 
-       return gtk_editable_get_chars(editable, start_pos, end_pos);
+#if USE_XIM
+       if (editable->ic) {
+               gdk_ic_destroy(editable->ic);
+               editable->ic = NULL;
+       }
+       if (editable->ic_attr) {
+               gdk_ic_attr_destroy(editable->ic_attr);
+               editable->ic_attr = NULL;
+       }
+#endif
 }
 
 /*
@@ -375,9 +486,12 @@ static void gtkut_check_before_remove(GtkWidget *widget, gpointer unused)
        if (GTK_IS_CONTAINER(widget))
                gtk_container_forall(GTK_CONTAINER(widget),
                                     gtkut_check_before_remove, NULL);
+#warning FIXME_GTK2
+#if 0
        if (GTK_IS_EDITABLE(widget))
                gtk_editable_claim_selection(GTK_EDITABLE(widget),
                                             FALSE, GDK_CURRENT_TIME);
+#endif
 }
 
 /*
@@ -402,6 +516,141 @@ void gtkut_container_remove(GtkContainer *container, GtkWidget *widget)
        gtk_container_remove(container, widget);
 }
 
+gboolean gtkut_text_buffer_match_string(GtkTextBuffer *textbuf,
+                                       const GtkTextIter *iter,
+                                       gunichar *wcs, gint len,
+                                       gboolean case_sens)
+{
+       GtkTextIter start_iter, end_iter;
+       gchar *utf8str, *p;
+       gint match_count;
+
+       start_iter = end_iter = *iter;
+       gtk_text_iter_forward_chars(&end_iter, len);
+
+       utf8str = gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter,
+                                          FALSE);
+       if (!utf8str) return FALSE;
+
+       if ((gint)g_utf8_strlen(utf8str, -1) != len) {
+               g_free(utf8str);
+               return FALSE;
+       }
+
+       for (p = utf8str, match_count = 0;
+            *p != '\0' && match_count < len;
+            p = g_utf8_next_char(p), match_count++) {
+               gunichar wc;
+
+               wc = g_utf8_get_char(p);
+
+               if (case_sens) {
+                       if (wc != wcs[match_count])
+                               break;
+               } else {
+                       if (g_unichar_tolower(wc) !=
+                           g_unichar_tolower(wcs[match_count]))
+                               break;
+               }
+       }
+
+       g_free(utf8str);
+
+       if (match_count == len)
+               return TRUE;
+       else
+               return FALSE;
+}
+
+gboolean gtkut_text_buffer_find(GtkTextBuffer *buffer, const GtkTextIter *iter,
+                               const gchar *str, gboolean case_sens,
+                               GtkTextIter *match_pos)
+{
+       gunichar *wcs;
+       gint len;
+       glong items_read = 0, items_written = 0;
+       GError *error = NULL;
+       GtkTextIter iter_;
+       gboolean found = FALSE;
+
+       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
+       if (error != NULL) {
+               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n",
+                         error->message);
+               g_error_free(error);
+       }
+       if (!wcs || items_written <= 0) return FALSE;
+       len = (gint)items_written;
+
+       iter_ = *iter;
+       do {
+               found = gtkut_text_buffer_match_string
+                       (buffer, &iter_, wcs, len, case_sens);
+               if (found) {
+                       *match_pos = iter_;
+                       break;
+               }
+       } while (gtk_text_iter_forward_char(&iter_));
+
+       g_free(wcs);
+
+       return found;
+}
+
+gboolean gtkut_text_buffer_find_backward(GtkTextBuffer *buffer,
+                                        const GtkTextIter *iter,
+                                        const gchar *str, gboolean case_sens,
+                                        GtkTextIter *match_pos)
+{
+       gunichar *wcs;
+       gint len;
+       glong items_read = 0, items_written = 0;
+       GError *error = NULL;
+       GtkTextIter iter_;
+       gboolean found = FALSE;
+
+       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
+       if (error != NULL) {
+               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n", error->message);
+               g_error_free(error);
+       }
+       if (!wcs || items_written <= 0) return FALSE;
+       len = (gint)items_written;
+
+       iter_ = *iter;
+       while (gtk_text_iter_backward_char(&iter_)) {
+               found = gtkut_text_buffer_match_string
+                       (buffer, &iter_, wcs, len, case_sens);
+               if (found) {
+                       *match_pos = iter_;
+                       break;
+               }
+       }
+
+       g_free(wcs);
+
+       return found;
+}
+
+gchar *gtkut_text_view_get_selection(GtkTextView *textview)
+{
+       GtkTextBuffer *buffer;
+       GtkTextIter start_iter, end_iter;
+       gboolean found;
+
+       g_return_val_if_fail(GTK_IS_TEXT_VIEW(textview), NULL);
+
+       buffer = gtk_text_view_get_buffer(textview);
+       found = gtk_text_buffer_get_selection_bounds(buffer,
+                                                    &start_iter,
+                                                    &end_iter);
+       if (found)
+               return gtk_text_buffer_get_text(buffer, &start_iter, &end_iter,
+                                               FALSE);
+       else
+               return NULL;
+}
+
 void gtkut_window_popup(GtkWidget *window)
 {
        gint x, y, sx, sy, new_x, new_y;
@@ -418,8 +667,7 @@ void gtkut_window_popup(GtkWidget *window)
        if (new_x != x || new_y != y)
                gdk_window_move(window->window, new_x, new_y);
 
-       gdk_window_raise(window->window);
-       gdk_window_show(window->window);
+       gtk_window_present(GTK_WINDOW(window));
 }
 
 void gtkut_widget_get_uposition(GtkWidget *widget, gint *px, gint *py)
@@ -442,39 +690,11 @@ void gtkut_widget_get_uposition(GtkWidget *widget, gint *px, gint *py)
        *py = y;
 }
 
-void gtkut_widget_disable_theme_engine(GtkWidget *widget)
-{
-       GtkStyle *style, *new_style;
-
-       style = gtk_widget_get_style(widget);
-
-       if (style->engine) {
-               GtkThemeEngine *engine;
-
-               engine = style->engine;
-               style->engine = NULL;
-               new_style = gtk_style_copy(style);
-               style->engine = engine;
-               gtk_widget_set_style(widget, new_style);
-       }
-}
-
-static void gtkut_widget_draw_cb(GtkWidget *widget, GdkRectangle *area,
-                                gboolean *flag)
-{
-       *flag = TRUE;
-       gtk_signal_disconnect_by_data(GTK_OBJECT(widget), flag);
-}
-
 void gtkut_widget_wait_for_draw(GtkWidget *widget)
 {
-       gboolean flag = FALSE;
-
-       if (!GTK_WIDGET_VISIBLE(widget) || !GTK_WIDGET_MAPPED(widget)) return;
+       if (!GTK_WIDGET_DRAWABLE(widget)) return;
 
-       gtk_signal_connect(GTK_OBJECT(widget), "draw",
-                          GTK_SIGNAL_FUNC(gtkut_widget_draw_cb), &flag);
-       while (!flag)
+       while (gtk_events_pending())
                gtk_main_iteration();
 }
 
@@ -483,16 +703,16 @@ static void gtkut_clist_bindings_add(GtkWidget *clist)
        GtkBindingSet *binding_set;
 
        binding_set = gtk_binding_set_by_class
-               (GTK_CLIST_CLASS(GTK_OBJECT(clist)->klass));
+               (GTK_CLIST_GET_CLASS(clist));
 
        gtk_binding_entry_add_signal(binding_set, GDK_n, GDK_CONTROL_MASK,
                                     "scroll_vertical", 2,
-                                    GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD,
-                                    GTK_TYPE_FLOAT, 0.0);
+                                    G_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD,
+                                    G_TYPE_FLOAT, 0.0);
        gtk_binding_entry_add_signal(binding_set, GDK_p, GDK_CONTROL_MASK,
                                     "scroll_vertical", 2,
-                                    GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD,
-                                    GTK_TYPE_FLOAT, 0.0);
+                                    G_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD,
+                                    G_TYPE_FLOAT, 0.0);
 }
 
 void gtkut_widget_init(void)
@@ -500,16 +720,22 @@ void gtkut_widget_init(void)
        GtkWidget *clist;
 
        clist = gtk_clist_new(1);
+       g_object_ref(G_OBJECT(clist));
+       gtk_object_sink(GTK_OBJECT(clist));
        gtkut_clist_bindings_add(clist);
-       gtk_widget_unref(clist);
+       g_object_unref(G_OBJECT(clist));
 
        clist = gtk_ctree_new(1, 0);
+       g_object_ref(G_OBJECT(clist));
+       gtk_object_sink(GTK_OBJECT(clist));
        gtkut_clist_bindings_add(clist);
-       gtk_widget_unref(clist);
+       g_object_unref(G_OBJECT(clist));
 
        clist = gtk_sctree_new_with_titles(1, 0, NULL);
+       g_object_ref(G_OBJECT(clist));
+       gtk_object_sink(GTK_OBJECT(clist));
        gtkut_clist_bindings_add(clist);
-       gtk_widget_unref(clist);
+       g_object_unref(G_OBJECT(clist));
 }
 
 void gtkut_widget_set_app_icon(GtkWidget *widget)
@@ -540,7 +766,7 @@ void gtkut_widget_set_composer_icon(GtkWidget *widget)
 }
 
 GtkWidget *gtkut_account_menu_new(GList                        *ac_list,
-                                 GtkSignalFunc          callback,
+                                 GCallback              callback,
                                  gpointer               data)
 {
        GList *cur_ac;
@@ -568,9 +794,72 @@ GtkWidget *gtkut_account_menu_new(GList                    *ac_list,
                MENUITEM_ADD(menu, menuitem, name, account->account_id);
                g_free(name);
                if (callback != NULL)
-                       gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
-                                          callback,
-                                          data);
+                       g_signal_connect(G_OBJECT(menuitem), "activate",
+                                        callback, data);
        }
        return menu;
 }
+
+void gtkut_set_widget_bgcolor_rgb(GtkWidget *widget, guint rgbvalue)
+{
+       GtkStyle *newstyle;
+       GdkColor gdk_color;
+
+       gtkut_convert_int_to_gdk_color(rgbvalue, &gdk_color);
+       newstyle = gtk_style_copy(gtk_widget_get_default_style());
+       newstyle->bg[GTK_STATE_NORMAL]   = gdk_color;
+       newstyle->bg[GTK_STATE_PRELIGHT] = gdk_color;
+       newstyle->bg[GTK_STATE_ACTIVE]   = gdk_color;
+       gtk_widget_set_style(widget, newstyle);
+}
+  
+/*!
+ *\brief       Tries to find a focused child using a lame strategy
+ */
+GtkWidget *gtkut_get_focused_child(GtkContainer *parent)
+{
+       GtkWidget *result = NULL;
+       GList *child_list = NULL;
+       GList *c;
+
+       g_return_val_if_fail(parent, NULL);
+
+       /* Get children list and see which has the focus. */
+       child_list = gtk_container_get_children(parent);
+       if (!child_list)
+               return NULL;
+
+       for (c = child_list; c != NULL; c = g_list_next(c)) {
+               if (c->data && GTK_IS_WIDGET(c->data)) {
+                       if (GTK_WIDGET_HAS_FOCUS(GTK_WIDGET(c->data))) {
+                               result = GTK_WIDGET(c->data);
+                               break;
+                       }
+               }
+       }
+       
+       /* See if the returned widget is a container itself; if it is,
+        * see if one of its children is focused. If the focused 
+        * container has no focused child, it is itself a focusable 
+        * child, and has focus. */
+       if (result && GTK_IS_CONTAINER(result)) {
+               GtkWidget *tmp =  gtkut_get_focused_child(GTK_CONTAINER(result)); 
+               
+               if (tmp) 
+                       result = tmp;
+       } else {
+               /* Try the same for each container in the chain */
+               for (c = child_list; c != NULL && !result; c = g_list_next(c)) {
+                       if (c->data && GTK_IS_WIDGET(c->data) 
+                       &&  GTK_IS_CONTAINER(c->data)) {
+                               result = gtkut_get_focused_child
+                                       (GTK_CONTAINER(c->data));
+                       }
+               }
+       
+       }
+       
+       g_list_free(child_list);
+               
+       return result;
+}