2004-12-14 [colin] 0.9.13cvs17
authorColin Leroy <colin@colino.net>
Tue, 14 Dec 2004 14:39:50 +0000 (14:39 +0000)
committerColin Leroy <colin@colino.net>
Tue, 14 Dec 2004 14:39:50 +0000 (14:39 +0000)
        * src/gtk/gtkutils.c
        * src/gtk/gtkutils.h
        * src/gtk/prefswindow.c
                Catch Enter in prefswindow while in text
                widget. Patch by Alfons.

ChangeLog.claws
PATCHSETS
configure.ac
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/gtk/prefswindow.c

index 982ec1f..5670679 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-14 [colin]     0.9.13cvs17
+
+       * src/gtk/gtkutils.c
+       * src/gtk/gtkutils.h
+       * src/gtk/prefswindow.c
+               Catch Enter in prefswindow while in text
+               widget. Patch by Alfons.
+
 2004-12-14 [paul]      0.9.13cvs16
 
        * ChangeLog
index a158dea..18abd06 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.17 -r 1.18 src/gtk/prefswindow.c; cvs diff -u -r 1.9 -r 1.10 src/gtk/pluginwindow.c; ) > 0.9.13cvs14.patchset
 ( cvs diff -u -r 1.8 -r 1.9 src/plugins/spamassassin/libspamc.c; ) > 0.9.13cvs15.patchset
 ( cvs diff -u -r 1.449 -r 1.450 ChangeLog; cvs diff -u -r 1.444 -r 1.445 ChangeLog.jp; cvs diff -u -r 1.18 -r 1.19 src/action.c; cvs diff -u -r 1.463 -r 1.464 src/compose.c; cvs diff -u -r 1.60 -r 1.61 src/common/utils.c; ) > 0.9.13cvs16.patchset
+( cvs diff -u -r 1.7 -r 1.8 src/gtk/gtkutils.c; cvs diff -u -r 1.6 -r 1.7 src/gtk/gtkutils.h; cvs diff -u -r 1.18 -r 1.19 src/gtk/prefswindow.c; ) > 0.9.13cvs17.patchset
index eb7d980..3bcbb1d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=16
+EXTRA_VERSION=17
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 95813f9..ca6cedf 100644 (file)
@@ -704,3 +704,52 @@ void gtkut_set_widget_bgcolor_rgb(GtkWidget *widget, guint rgbvalue)
        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_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;
+}
index 4ba4e37..75cfb91 100644 (file)
@@ -165,4 +165,5 @@ GtkWidget *gtkut_account_menu_new   (GList                  *ac_list,
 
 void gtkut_set_widget_bgcolor_rgb      (GtkWidget      *widget,
                                         guint           rgbvalue);
+GtkWidget *gtkut_get_focused_child     (GtkContainer   *parent);
 #endif /* __GTKUTILS_H__ */
index a512d24..b6630f4 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <string.h>
 #include <gtk/gtk.h>
+#include <gtk/gtktext.h>
 #include <gdk/gdkkeysyms.h>
 
 #include "intl.h"
@@ -208,6 +209,8 @@ gint compare_func(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 static gboolean prefswindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                    gpointer data)
 {
+       GtkWidget *focused_child;
+       
        if (event) {
                switch (event->keyval) {
                        case GDK_Escape :
@@ -215,7 +218,13 @@ static gboolean prefswindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                break;
                        case GDK_Return : 
                        case GDK_KP_Enter :
-                               ok_button_released(NULL, data);
+                               focused_child = gtkut_get_focused_child
+                                       (GTK_CONTAINER(data->notebook));
+                               /* Press ok, if the focused child is not a text view
+                                * and text (anything that accepts return) (can pass
+                                * NULL to any of the GTK_xxx() casts) */
+                               if (!GTK_IS_TEXT(focused_child))
+                                       ok_button_released(NULL, data);
                                break;
                        default:
                                break;