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

gEDA-dev: Patches attached to fix new_page on spacebar bug(#1552778)



Either of these patches fixes the bug logged in sourceforge today.

The toolbar widgets were becoming focused, and getting "activated" when
the user pressed "Spacebar".

Two approaches to fix this:

1. cvs_geda.new_page_bug.patch

(I think this is the better approach and patch)

Set the drawing area which gschem draws in to be focusable, then grab
the focus on it. Attach key-press events to the drawing-area, rather
than the main window.

Results:

Key-bindings work by default, toolbar isn't keyboard accessible until
"TAB" key is pressed to change focus. At this point, the toobar has
keyboard focus, and the individual elements can be selected by the
keyboard.

Due to moving the key-press events to the drawing-area, the left-right
keys used to move between toobar items don't pan the schematic whilst
using the keyboard to focus toolbar items as it did before.

Possible disadvatage:

Users can de-focus the drawing area with the "TAB" key, and this
de-activates their keybindings until they "TAB" back to it.


2. cvs_geda.new_page_bug.alt.patch

(More messy patch by the nature of the fix)

remove the CAN_FOCUS flag from each toolbar button as we add it. By
leaving no toobar-buttons focusable, key presses such as "SPACEBAR" no
longer activate any of the buttons.


I hope that one of these patches can be applied before the release. I
prefer the first (cvs_geda.new_page_bug.patch), as it is a more
generally applicable solution to the problem of other controls being
focused whilst keybindings are active.

Regards

Peter Clifton

? src/gschem.log
Index: src/x_window.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_window.c,v
retrieving revision 1.37
diff -U3 -p -r1.37 x_window.c
--- src/x_window.c	4 Sep 2006 16:51:57 -0000	1.37
+++ src/x_window.c	5 Sep 2006 17:50:45 -0000
@@ -335,6 +335,8 @@ void x_window_create_drawing(GtkWidget *
 
   gtk_box_pack_start (GTK_BOX (drawbox), w_current->drawing_area,
                       TRUE, TRUE, 0);
+  GTK_WIDGET_SET_FLAGS (w_current->drawing_area, GTK_CAN_FOCUS );
+  gtk_widget_grab_focus (w_current->drawing_area);
   gtk_widget_show (w_current->drawing_area);
 
 }
@@ -357,10 +359,10 @@ void x_window_setup_draw_events(TOPLEVEL
     { "button_release_event", G_CALLBACK(x_event_button_released) },
     { "motion_notify_event",  G_CALLBACK(x_event_motion)          },
     { "configure_event",      G_CALLBACK(x_event_configure)       },
+    { "key_press_event",      G_CALLBACK(x_event_key_press)       },
     { NULL,                   NULL                                } };
   struct event_reg_t main_window_events[] = {
     { "enter_notify_event",   G_CALLBACK(x_event_enter)           },
-    { "key_press_event",      G_CALLBACK(x_event_key_press)       },
     { "scroll_event",         G_CALLBACK(x_event_scroll)          },
     { NULL,                   NULL                                } };
   struct event_reg_t *tmp;
Index: x_window.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_window.c,v
retrieving revision 1.37
diff -U3 -p -r1.37 x_window.c
--- x_window.c	4 Sep 2006 16:51:57 -0000	1.37
+++ x_window.c	5 Sep 2006 18:04:18 -0000
@@ -445,6 +445,7 @@ void x_window_create_main(TOPLEVEL *w_cu
   GtkWidget *bottom_box=NULL;
   GtkWidget *toolbar=NULL;
   GtkWidget *handlebox=NULL;
+  GtkWidget *toolbutton=NULL;
 
   /* used to signify that the window isn't mapped yet */
   w_current->window = NULL; 
@@ -517,51 +518,57 @@ void x_window_create_main(TOPLEVEL *w_cu
       gtk_box_pack_start(GTK_BOX(main_box), toolbar, FALSE, FALSE, 0);
     }
 
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
-                             _("New"), 
-                             _("New file"), 
-                             "toolbar/new", 
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+                             _("New"),
+                             _("New file"),
+                             "toolbar/new",
                              x_window_stock_pixmap("new", w_current),
-                             (GtkSignalFunc) i_callback_toolbar_file_new, 
+                             (GtkSignalFunc) i_callback_toolbar_file_new,
                              w_current);
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
                              _("Open"), 
                              _("Open file..."), 
                              "toolbar/open",
                              x_window_stock_pixmap("open", w_current),
                              (GtkSignalFunc) i_callback_toolbar_file_open, 
                              w_current);
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
                              _("Save"), 
                              _("Save file"), 
                              "toolbar/save", 
                              x_window_stock_pixmap("save", w_current),
                              (GtkSignalFunc) i_callback_toolbar_file_save, 
                              w_current);
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
     gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); 
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
                              _("Undo"), 
                              _("Undo last operation"), 
                              "toolbar/undo", 
                              x_window_stock_pixmap("undo", w_current),
                              (GtkSignalFunc) i_callback_toolbar_edit_undo, 
                              w_current);
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
                              _("Redo"), 
                              _("Redo last undo"), 
                              "toolbar/redo", 
                              x_window_stock_pixmap("redo", w_current),
                              (GtkSignalFunc) i_callback_toolbar_edit_redo, 
                              w_current);
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
     gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); 
     /* not part of any radio button group */
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
                              _("Component"), 
                              _("Add component...\nSelect library and component from list, move the mouse into main window, click to place\nRight mouse button to cancel"), 
                              "toolbar/component", 
                              x_window_stock_pixmap("comp", w_current),
                              (GtkSignalFunc) i_callback_toolbar_add_component, 
                              w_current);
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
     w_current->toolbar_net = 
       gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
                                  GTK_TOOLBAR_CHILD_RADIOBUTTON,
@@ -572,6 +579,7 @@ void x_window_create_main(TOPLEVEL *w_cu
                                  x_window_stock_pixmap("net", w_current),
                                  (GtkSignalFunc) i_callback_toolbar_add_net,
                                  w_current);
+    GTK_WIDGET_UNSET_FLAGS ( w_current->toolbar_net, GTK_CAN_FOCUS );
     w_current->toolbar_bus = 
       gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
                                  GTK_TOOLBAR_CHILD_RADIOBUTTON,
@@ -582,14 +590,16 @@ void x_window_create_main(TOPLEVEL *w_cu
                                  x_window_stock_pixmap("bus", w_current),
                                  (GtkSignalFunc) i_callback_toolbar_add_bus,
                                  w_current);
+    GTK_WIDGET_UNSET_FLAGS ( w_current->toolbar_bus, GTK_CAN_FOCUS );
     /* not part of any radio button group */
-    gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
+    toolbutton = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), 
                              _("Text"), 
                              _("Add Text..."), 
                              "toolbar/text", 
                              x_window_stock_pixmap("text", w_current),
                              (GtkSignalFunc) i_callback_toolbar_add_text, 
                              w_current);
+    GTK_WIDGET_UNSET_FLAGS ( toolbutton, GTK_CAN_FOCUS );
     gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); 
     w_current->toolbar_select = 
       gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
@@ -601,6 +611,7 @@ void x_window_create_main(TOPLEVEL *w_cu
                                  x_window_stock_pixmap("select", w_current),
                                  (GtkSignalFunc) i_callback_toolbar_edit_select, 
                                  w_current);
+    GTK_WIDGET_UNSET_FLAGS ( w_current->toolbar_select, GTK_CAN_FOCUS );
 
 
     gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); 


_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev