cvs server: Diffing .
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/libpanel-applet/ChangeLog,v
retrieving revision 1.74
diff -u -p -r1.74 ChangeLog
--- ChangeLog	16 Jul 2002 08:07:40 -0000	1.74
+++ ChangeLog	17 Jul 2002 12:26:14 -0000
@@ -1,3 +1,19 @@
+2002-07-17  Padraig O'Briain <padraig.obriain@sun.com>
+
+	* panel-applet.c: This is an attempt to provide focus indication
+	as unobtrusively as possible for applets which currrently do not 
+	have focus indication, e.g. cdplayer and workspace switcher.
+	(panel_widget_size_request): Allow for focus indication around
+	applets which can receive focus; reduce focus_pad by 1 so that in
+	default case only 1 pixel is required on each side of the applet.
+	Constrain size request to be no greater than panel size.
+	(panel_applet_size_allocate): If applet can receive focus, position
+	child so that focus indicator can be drawn around it; reduce 
+	focus_pad by 1 so that in default case only 1 pixel is required on 
+	each side of the applet.
+	(panel_applet_expose): Reduce focus_pad by 1 so that in default
+	case only 1 pixel is required on each side of the applet.
+
 2002-07-16  Padraig O'Briain <padraig.obriain@sun.com>
 
 	* panel-applet.c: 
Index: panel-applet.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-applet.c,v
retrieving revision 1.65
diff -u -p -r1.65 panel-applet.c
--- panel-applet.c	16 Jul 2002 08:07:40 -0000	1.65
+++ panel-applet.c	17 Jul 2002 12:26:14 -0000
@@ -501,6 +501,22 @@ panel_applet_has_focusable_child (PanelA
 }
 
 static gboolean
+panel_applet_can_focus (GtkWidget *widget)
+{
+	/*
+	 * A PanelApplet widget can focus if it has a tooltip or it does 
+	 * not have any focusable children.
+	 */
+	if (gtk_tooltips_data_get (widget))
+		return TRUE;
+
+	if (!PANEL_IS_APPLET (widget))
+		return FALSE;
+
+	return (panel_applet_has_focusable_child (PANEL_APPLET (widget)) != TRUE);
+}
+
+static gboolean
 panel_applet_button_press (GtkWidget      *widget,
 			   GdkEventButton *event)
 {
@@ -543,32 +559,38 @@ panel_applet_popup_menu (PanelApplet *ap
 	return _panel_applet_popup_menu (applet, 3, GDK_CURRENT_TIME);
 }
 
-#ifdef FIXME
 static void
 panel_applet_size_request (GtkWidget *widget, GtkRequisition *requisition)
 {
-	PanelApplet *applet = PANEL_APPLET (widget);
-	GtkBin *bin = GTK_BIN (widget);
-	gint focus_width, focus_pad;
-
-	requisition->width = GTK_CONTAINER (widget)->border_width * 2;
-	requisition->height = GTK_CONTAINER (widget)->border_width * 2;
-
-	gtk_widget_style_get (widget,
-			      "focus-line-width", &focus_width,
-			      "focus-padding", &focus_pad,
-			      NULL);
-
-	if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) {
-		GtkRequisition child_requisition;
+	PanelApplet *applet;
+	GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
 
-		gtk_widget_size_request (bin->child, &child_requisition);
+	if (panel_applet_can_focus (widget)) {
+		gint focus_width, focus_pad;
 
-		requisition->width += child_requisition.width;
-		requisition->height += child_requisition.height;
+		gtk_widget_style_get (widget,
+				      "focus-line-width", &focus_width,
+				      "focus-padding", &focus_pad,
+				      NULL);
+		if (focus_pad > 0)
+			focus_pad--;
+		requisition->width += 2 * (2 * focus_pad + focus_width);
+		requisition->height += 2 * (2 * focus_pad + focus_width);
+	}
+	applet = PANEL_APPLET (widget);
+	switch (applet->priv->orient) {
+	case PANEL_APPLET_ORIENT_LEFT:
+	case PANEL_APPLET_ORIENT_RIGHT:
+		if (requisition->width > applet->priv->size)
+			requisition->width = applet->priv->size;
+		break;
+	case PANEL_APPLET_ORIENT_UP:
+	case PANEL_APPLET_ORIENT_DOWN:
+	default:
+		if (requisition->height > applet->priv->size)
+			requisition->height = applet->priv->size;
+		break;
 	}
-	requisition->width += 2 * (2 * focus_pad + focus_width);
-	requisition->height += 2 * (2 * focus_pad + focus_width);
 }
 
 static void
@@ -581,10 +603,17 @@ panel_applet_size_allocate (GtkWidget *w
 	GtkBin *bin;
 	GtkAllocation child_allocation;
 
+	if (!panel_applet_can_focus (widget)) {
+		GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+		return;
+	}
+
 	gtk_widget_style_get (widget,
 			      "focus-line-width", &focus_width,
 			      "focus-padding", &focus_pad,
 			      NULL);
+	if (focus_pad > 0)
+		focus_pad--;
 	border_width = GTK_CONTAINER (widget)->border_width;
 
 	widget->allocation = *allocation;
@@ -607,7 +636,6 @@ panel_applet_size_allocate (GtkWidget *w
 	if (bin->child)
 		gtk_widget_size_allocate (bin->child, &child_allocation);
 }
-#endif /* FIXME */
 
 static gboolean
 panel_applet_expose (GtkWidget      *widget,
@@ -627,12 +655,14 @@ panel_applet_expose (GtkWidget      *wid
 				      "focus-line-width", &focus_width,
 				      "focus-padding", &focus_pad,
 				      NULL);
+		if (focus_pad > 0)
+			focus_pad--;
 		border_width = GTK_CONTAINER (widget)->border_width;
 
 		x = widget->allocation.x + focus_pad;
 		y = widget->allocation.y + focus_pad;
-		width = widget->allocation.width - 2 * border_width - 0.5 * focus_pad;
-		height = widget->allocation.height - 2 * border_width - 0.5 * focus_pad;
+		width = widget->allocation.width - 2 * border_width;
+		height = widget->allocation.height - 2 * border_width;
 		gtk_paint_focus (widget->style, widget->window,
                                  GTK_WIDGET_STATE (widget),
                                  &event->area, widget, "panel_applet",
@@ -1215,10 +1245,8 @@ panel_applet_class_init (PanelAppletClas
 	klass->move_focus_out_of_applet = panel_applet_move_focus_out_of_applet;
 
 	widget_class->button_press_event = panel_applet_button_press;
-#ifdef FIXME
 	widget_class->size_request = panel_applet_size_request;
 	widget_class->size_allocate = panel_applet_size_allocate;
-#endif /* FIXME */
 	widget_class->expose_event = panel_applet_expose;
 	widget_class->focus = panel_applet_focus;
 
