[evolution-patches] [Patch]: Bug #46356, Can't change the color of the text with keyboard



Hi all,
The attachment is a patch which tries to fix bug #46356. This bug can be
reproduced by the following steps:
  1. Start evolution. 
  2. Click New Mail Message.
  3. Input text, highlight the text.
  4. Press Alt+m, then press t to open Text Properties dialog.
  5. Press Tab key to put focus on the Color item.
  6. Press Up, space, enter key to open the color picker.
Actual Results:
  The color picker can't be opened.
Expected Results:
  There should one way to open the color picker to change the color.

I've tested the patch both on the 1_4_5 branch and the HEAD, please help review.

Changes:
 * /cvs/gnome/gal/gal/widgets/gal-combo-box.c
  fixed the bug that neither the arrow button nor the display widget 
  can be focused with keyboard navigation.

 * /cvs/gnome/gal/gal/widgets/color-palette.c
  fixed the bug which caused the color-button can't display focus area
  when focused. Tuned the color item so that is displays in the center
  of canvas.

 * /cvs/gnome/gal/gal/widgets/widget-color-combo.c
  fixed the bug which caused the preview-button can't display focus area
  when focused. 


TODO:
 * Both the color button and icon button will erase the focus area when 
   they're clicked or key-pressed.
 
 * The color_combo_xxx and gal_combo_xxx functions are provided both by gal 
   and gtkhtml, but libgal-2.2.so is loaded first(IMHO, maybe not), so maybe 
   such functions should be removed from gal and the above changes should be 
   merged into gtkhtml. 


Best regards.
-- 
Eric Zhao <eric zhao sun com>
Index: gal-combo-box.c
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/gal-combo-box.c,v
retrieving revision 1.1
diff -u -r1.1 gal-combo-box.c
--- gal-combo-box.c	17 Nov 2003 21:05:15 -0000	1.1
+++ gal-combo-box.c	12 Feb 2004 08:39:40 -0000
@@ -330,6 +330,7 @@
 			  GDK_BUTTON_RELEASE_MASK |
 			  GDK_POINTER_MOTION_MASK,
 			  NULL, NULL, GDK_CURRENT_TIME);
+	gdk_keyboard_grab (combo_box->priv->toplevel->window, TRUE, GDK_CURRENT_TIME);
 }
 
 static int
@@ -401,7 +402,7 @@
 	 */
 	combo_box->priv->arrow_button = gtk_toggle_button_new ();
 	gtk_button_set_relief (GTK_BUTTON (combo_box->priv->arrow_button), GTK_RELIEF_NONE);
-	GTK_WIDGET_UNSET_FLAGS (combo_box->priv->arrow_button, GTK_CAN_FOCUS);
+	/*GTK_WIDGET_UNSET_FLAGS (combo_box->priv->arrow_button, GTK_CAN_FOCUS); */
 
 	arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
 	gtk_container_add (GTK_CONTAINER (combo_box->priv->arrow_button), arrow);
Index: color-palette.c
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/color-palette.c,v
retrieving revision 1.21
diff -u -r1.21 color-palette.c
--- color-palette.c	16 Nov 2002 23:42:17 -0000	1.21
+++ color-palette.c	12 Feb 2004 09:03:19 -0000
@@ -281,6 +281,35 @@
 }
 
 /*
+ * Repaint the canvas to erase the focus area when the button 
+ * lost focus.
+ */
+static gboolean
+on_color_palette_button_focus_out (GtkWidget	*button,
+				GdkEventFocus	*event,
+				GtkWidget	*canvas)
+{
+	gtk_widget_queue_draw (canvas);
+	return FALSE;
+}
+
+/*
+ * Paint the focus area on the top canvas when the button is focused.
+ */
+static gboolean
+on_color_palette_button_focus_in (GtkWidget	*button,
+				GdkEventFocus	*event,
+				GtkWidget	*canvas)
+{
+	gtk_paint_focus (canvas->style, ((GtkLayout *)canvas)->bin_window, 
+			GTK_WIDGET_STATE (canvas),
+			NULL, canvas, "button",
+			0, 0, canvas->allocation.width, 
+			canvas->allocation.height);
+	return FALSE;
+}
+
+/*
  * Create the individual color buttons
  *
  * Utility function
@@ -305,10 +334,10 @@
 	item  = gnome_canvas_item_new (GNOME_CANVAS_GROUP (gnome_canvas_root
 							   (GNOME_CANVAS (canvas))),
 				       gnome_canvas_rect_get_type (),
-				       "x1", 0.0,
-				       "y1", 0.0,
-				       "x2", (double) COLOR_PREVIEW_WIDTH,
-				       "y2", (double) COLOR_PREVIEW_HEIGHT,
+				       "x1", 2.0,
+				       "y1", 2.0,
+				       "x2", 2.0+(double) COLOR_PREVIEW_WIDTH,
+				       "y2", 2.0+(double) COLOR_PREVIEW_HEIGHT,
 				       "fill_color", color_name->color,
 				       NULL);
 
@@ -320,6 +349,12 @@
 
 	g_signal_connect (button, "clicked",
 			  G_CALLBACK (color_clicked), P);
+	g_signal_connect (button, "focus_in_event",
+			  G_CALLBACK (on_color_palette_button_focus_in), 
+			  canvas);
+	g_signal_connect (button, "focus_out_event",
+			  G_CALLBACK (on_color_palette_button_focus_out), 
+			  canvas);
 	gtk_object_set_user_data (GTK_OBJECT (button),
 				  GINT_TO_POINTER (data));
 	return item;
Index: widget-color-combo.c
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/widget-color-combo.c,v
retrieving revision 1.46
diff -u -r1.46 widget-color-combo.c
--- widget-color-combo.c	17 Nov 2003 21:05:15 -0000	1.46
+++ widget-color-combo.c	12 Feb 2004 09:11:28 -0000
@@ -123,6 +123,40 @@
 		gdk_color_free (color);
 }
 
+/*
+ * Repaint the canvas to erase the focus area when the button 
+ * lost focus.
+ */
+static gboolean
+on_preview_button_focus_out (GtkWidget *button, GdkEventFocus *event,
+		GtkWidget *canvas)
+{
+	gtk_widget_queue_draw (canvas);
+	return FALSE;
+}
+
+/*
+ * Paint the focus area on the top canvas when the button is focused.
+ */
+static gboolean
+on_preview_button_focus_in (GtkWidget *button, GdkEventFocus *event,
+		GtkWidget *canvas)
+{
+	gint focus_width, focus_pad, focus_tune;
+	gtk_widget_style_get (GTK_WIDGET (canvas),
+				"focus-line-width", &focus_width,
+				"focus-padding", &focus_pad,
+				NULL);
+	focus_tune = focus_width + focus_pad;
+	gtk_paint_focus (canvas->style, ((GtkLayout *)canvas)->bin_window,
+		GTK_WIDGET_STATE (canvas),
+		NULL, canvas, "preview-button",
+		focus_tune, focus_tune, 
+		canvas->allocation.width - 2*focus_tune, 
+		canvas->allocation.height - 2*focus_tune);
+	return FALSE;
+}
+
 static void
 cb_cust_color_clicked (GtkWidget *widget, ColorCombo *cc)
 {
@@ -225,6 +259,10 @@
 	gtk_widget_set_usize (GTK_WIDGET (cc->preview_canvas), 24, 22);
 	g_signal_connect (cc->preview_button, "clicked",
 			  G_CALLBACK (preview_clicked), cc);
+	g_signal_connect (cc->preview_button, "focus_in_event",
+			  G_CALLBACK (on_preview_button_focus_in), cc->preview_canvas);
+	g_signal_connect (cc->preview_button, "focus_out_event",
+			  G_CALLBACK (on_preview_button_focus_out), cc->preview_canvas);
 
 	color_table_setup (cc, no_color_label, color_group);
 


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