Commit 4f7ae827 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

libnautilus-extensions/nautilus-list.c Fix 296 - properly set the default

2000-05-08  Pavel Cisler  <pavel@eazel.com>

	* libnautilus-extensions/nautilus-list.c
	* libnautilus-extensions/nautilus-icon-container.c
	(realize), (unrealize), (nautilus_list_realize),
	(nautilus_list_unrealize),
	(nautilus_icon_container_initialize_class),
	(nautilus_list_initialize_class),
	(nautilus_list_realize),
	(nautilus_list_unrealize):
	Fix 296 - properly set the default focus to the icon and
	list views so that keyboard navigation works right away.
	Properly defocus the icon and list view when switching
	between the two views.

	* libnautilus-extensions/nautilus-icon-container.c:
	(keyboard_arrow_key), (keyboard_right), (keyboard_left),
	(keyboard_down), (keyboard_up):
	Properly handle the first keyboard arrow press when we have no selection
	yet. To do this pass in a new empty_start predicate.

	* libnautilus-extensions/nautilus-icon-container.c
	* libnautilus-extensions/nautilus-list.c
	(nautilus_list_initialize),
	(select_row_from_mouse),
	(nautilus_list_keyboard_navigation_key_press),
	(nautilus_list_key_press):
	Properly handle the first keyboard arrow press when we have no selection
	yet (this will only start working when 454 gets fixed).
	Make it so that the keyboard focus gets collapsed with the selection
	when selecting an item with a mouse.
parent 8ad77275
2000-05-08 Pavel Cisler <pavel@eazel.com>
* libnautilus-extensions/nautilus-list.c
* libnautilus-extensions/nautilus-icon-container.c
(realize), (unrealize), (nautilus_list_realize),
(nautilus_list_unrealize),
(nautilus_icon_container_initialize_class),
(nautilus_list_initialize_class),
(nautilus_list_realize),
(nautilus_list_unrealize):
Fix 296 - properly set the default focus to the icon and
list views so that keyboard navigation works right away.
Properly defocus the icon and list view when switching
between the two views.
* libnautilus-extensions/nautilus-icon-container.c:
(keyboard_arrow_key), (keyboard_right), (keyboard_left),
(keyboard_down), (keyboard_up):
Properly handle the first keyboard arrow press when we have no selection
yet. To do this pass in a new empty_start predicate.
* libnautilus-extensions/nautilus-icon-container.c
* libnautilus-extensions/nautilus-list.c
(nautilus_list_initialize),
(select_row_from_mouse),
(nautilus_list_keyboard_navigation_key_press),
(nautilus_list_key_press):
Properly handle the first keyboard arrow press when we have no selection
yet (this will only start working when 454 gets fixed).
Make it so that the keyboard focus gets collapsed with the selection
when selecting an item with a mouse.
2000-05-08 Darin Adler <darin@eazel.com>
* check-FIXME.pl:
......@@ -126,7 +158,7 @@
* nautilus-clean.sh: Added pdf component to list. Added -x option
to also kill oafd and gconfd.
2000-05-08 Pavel <pavel@eazel.com>
2000-05-08 Pavel Cisler <pavel@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c:
* libnautilus-extensions/nautilus-icon-private.h:
......
......@@ -1272,6 +1272,7 @@ keyboard_arrow_key (NautilusIconContainer *container,
GdkEventKey *event,
Axis axis,
IsBetterIconFunction better_start,
IsBetterIconFunction empty_start,
IsBetterIconFunction better_destination)
{
NautilusIcon *icon;
......@@ -1300,7 +1301,7 @@ keyboard_arrow_key (NautilusIconContainer *container,
container->details->arrow_key_axis = AXIS_NONE;
icon = find_best_icon (container,
NULL,
better_start,
empty_start,
NULL);
} else {
record_arrow_key_start (container, icon, axis);
......@@ -1324,6 +1325,7 @@ keyboard_right (NautilusIconContainer *container,
event,
AXIS_HORIZONTAL,
rightmost_in_bottom_row,
leftmost_in_top_row,
same_row_right_side_leftmost);
}
......@@ -1338,6 +1340,7 @@ keyboard_left (NautilusIconContainer *container,
event,
AXIS_HORIZONTAL,
leftmost_in_top_row,
rightmost_in_bottom_row,
same_row_left_side_rightmost);
}
......@@ -1352,6 +1355,7 @@ keyboard_down (NautilusIconContainer *container,
event,
AXIS_VERTICAL,
rightmost_in_bottom_row,
leftmost_in_top_row,
same_column_below_highest);
}
......@@ -1366,6 +1370,7 @@ keyboard_up (NautilusIconContainer *container,
event,
AXIS_VERTICAL,
leftmost_in_top_row,
rightmost_in_bottom_row,
same_column_above_lowest);
}
......@@ -1619,6 +1624,7 @@ static void
realize (GtkWidget *widget)
{
GtkStyle *style;
GtkWindow *window;
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, realize, (widget));
......@@ -1628,6 +1634,22 @@ realize (GtkWidget *widget)
gdk_window_set_background (GTK_LAYOUT (widget)->bin_window,
& widget->style->bg [GTK_STATE_NORMAL]);
/* make us the focused widget */
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, widget);
}
static void
unrealize (GtkWidget *widget)
{
GtkWindow *window;
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, NULL);
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, unrealize, (widget));
}
static gboolean
......@@ -2251,6 +2273,7 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
widget_class->size_request = size_request;
widget_class->size_allocate = size_allocate;
widget_class->realize = realize;
widget_class->unrealize = unrealize;
widget_class->button_press_event = button_press_event;
widget_class->button_release_event = button_release_event;
widget_class->motion_notify_event = motion_notify_event;
......
......@@ -216,6 +216,7 @@ static void draw_row (GtkCList *l
gint row,
GtkCListRow *clist_row);
static void nautilus_list_realize (GtkWidget *widget);
static void nautilus_list_unrealize (GtkWidget *widget);
static void nautilus_list_set_cell_contents (GtkCList *clist,
GtkCListRow *clist_row,
gint column,
......@@ -362,6 +363,7 @@ nautilus_list_initialize_class (NautilusListClass *klass)
widget_class->draw_focus = nautilus_list_draw_focus;
widget_class->key_press_event = nautilus_list_key_press;
widget_class->realize = nautilus_list_realize;
widget_class->unrealize = nautilus_list_unrealize;
widget_class->size_request = nautilus_list_size_request;
object_class->destroy = nautilus_list_destroy;
......@@ -405,6 +407,7 @@ nautilus_list_initialize (NautilusList *list)
nautilus_preferences_add_enum_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list);
}
static void
......@@ -503,6 +506,8 @@ select_row_from_mouse (NautilusList *list, int row, guint state)
range = (state & GDK_SHIFT_MASK) != 0;
additive = (state & GDK_CONTROL_MASK) != 0;
nautilus_list_clear_keyboard_focus (list);
if (!additive) {
selection_changed |= select_row_unselect_others (list, -1);
}
......@@ -942,7 +947,7 @@ nautilus_list_keyboard_navigation_key_press (NautilusList *list, GdkEventKey *ev
* If there's a selection, use the selected row farthest toward the end.
*/
if (GTK_CLIST (list)->focus_row >= 0) {
if (clist->focus_row >= 0) {
start_row = clist->focus_row;
} else {
start_row = (scroll_type == GTK_SCROLL_STEP_FORWARD || scroll_type == GTK_SCROLL_PAGE_FORWARD ?
......@@ -954,9 +959,8 @@ nautilus_list_keyboard_navigation_key_press (NautilusList *list, GdkEventKey *ev
* If there is a row to start with, select the next row in the arrow direction.
*/
if (start_row < 0) {
destination_row = (scroll_type == GTK_SCROLL_STEP_FORWARD || scroll_type == GTK_SCROLL_PAGE_FORWARD ?
clist->rows - 1 :
0);
destination_row = (scroll_type == GTK_SCROLL_STEP_FORWARD || scroll_type == GTK_SCROLL_PAGE_FORWARD
? 0 : clist->rows - 1);
} else if (scroll_type == GTK_SCROLL_STEP_FORWARD) {
destination_row = MIN (clist->rows - 1, start_row + 1);
} else if (scroll_type == GTK_SCROLL_STEP_BACKWARD) {
......@@ -1088,11 +1092,7 @@ nautilus_list_key_press (GtkWidget *widget,
nautilus_list_activate_selected_items (list);
break;
default:
if (NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, key_press_event, (widget, event))) {
return TRUE;
} else {
return FALSE;
}
return NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, key_press_event, (widget, event));
}
return TRUE;
......@@ -1103,6 +1103,7 @@ nautilus_list_realize (GtkWidget *widget)
{
NautilusList *list;
GtkCList *clist;
GtkWindow *window;
g_return_if_fail (NAUTILUS_IS_LIST (widget));
......@@ -1118,10 +1119,26 @@ nautilus_list_realize (GtkWidget *widget)
}
gtk_widget_set_parent (list->details->title, GTK_WIDGET (clist));
gtk_widget_show (list->details->title);
/* make us the focused widget */
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, widget);
GTK_CLIST_SET_FLAG (clist, CLIST_SHOW_TITLES);
}
static void
nautilus_list_unrealize (GtkWidget *widget)
{
GtkWindow *window;
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, NULL);
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, unrealize, (widget));
}
/* this is here just temporarily */
static gint
list_requisition_width (GtkCList *clist)
......
......@@ -1272,6 +1272,7 @@ keyboard_arrow_key (NautilusIconContainer *container,
GdkEventKey *event,
Axis axis,
IsBetterIconFunction better_start,
IsBetterIconFunction empty_start,
IsBetterIconFunction better_destination)
{
NautilusIcon *icon;
......@@ -1300,7 +1301,7 @@ keyboard_arrow_key (NautilusIconContainer *container,
container->details->arrow_key_axis = AXIS_NONE;
icon = find_best_icon (container,
NULL,
better_start,
empty_start,
NULL);
} else {
record_arrow_key_start (container, icon, axis);
......@@ -1324,6 +1325,7 @@ keyboard_right (NautilusIconContainer *container,
event,
AXIS_HORIZONTAL,
rightmost_in_bottom_row,
leftmost_in_top_row,
same_row_right_side_leftmost);
}
......@@ -1338,6 +1340,7 @@ keyboard_left (NautilusIconContainer *container,
event,
AXIS_HORIZONTAL,
leftmost_in_top_row,
rightmost_in_bottom_row,
same_row_left_side_rightmost);
}
......@@ -1352,6 +1355,7 @@ keyboard_down (NautilusIconContainer *container,
event,
AXIS_VERTICAL,
rightmost_in_bottom_row,
leftmost_in_top_row,
same_column_below_highest);
}
......@@ -1366,6 +1370,7 @@ keyboard_up (NautilusIconContainer *container,
event,
AXIS_VERTICAL,
leftmost_in_top_row,
rightmost_in_bottom_row,
same_column_above_lowest);
}
......@@ -1619,6 +1624,7 @@ static void
realize (GtkWidget *widget)
{
GtkStyle *style;
GtkWindow *window;
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, realize, (widget));
......@@ -1628,6 +1634,22 @@ realize (GtkWidget *widget)
gdk_window_set_background (GTK_LAYOUT (widget)->bin_window,
& widget->style->bg [GTK_STATE_NORMAL]);
/* make us the focused widget */
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, widget);
}
static void
unrealize (GtkWidget *widget)
{
GtkWindow *window;
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, NULL);
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, unrealize, (widget));
}
static gboolean
......@@ -2251,6 +2273,7 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
widget_class->size_request = size_request;
widget_class->size_allocate = size_allocate;
widget_class->realize = realize;
widget_class->unrealize = unrealize;
widget_class->button_press_event = button_press_event;
widget_class->button_release_event = button_release_event;
widget_class->motion_notify_event = motion_notify_event;
......
......@@ -216,6 +216,7 @@ static void draw_row (GtkCList *l
gint row,
GtkCListRow *clist_row);
static void nautilus_list_realize (GtkWidget *widget);
static void nautilus_list_unrealize (GtkWidget *widget);
static void nautilus_list_set_cell_contents (GtkCList *clist,
GtkCListRow *clist_row,
gint column,
......@@ -362,6 +363,7 @@ nautilus_list_initialize_class (NautilusListClass *klass)
widget_class->draw_focus = nautilus_list_draw_focus;
widget_class->key_press_event = nautilus_list_key_press;
widget_class->realize = nautilus_list_realize;
widget_class->unrealize = nautilus_list_unrealize;
widget_class->size_request = nautilus_list_size_request;
object_class->destroy = nautilus_list_destroy;
......@@ -405,6 +407,7 @@ nautilus_list_initialize (NautilusList *list)
nautilus_preferences_add_enum_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list);
}
static void
......@@ -503,6 +506,8 @@ select_row_from_mouse (NautilusList *list, int row, guint state)
range = (state & GDK_SHIFT_MASK) != 0;
additive = (state & GDK_CONTROL_MASK) != 0;
nautilus_list_clear_keyboard_focus (list);
if (!additive) {
selection_changed |= select_row_unselect_others (list, -1);
}
......@@ -942,7 +947,7 @@ nautilus_list_keyboard_navigation_key_press (NautilusList *list, GdkEventKey *ev
* If there's a selection, use the selected row farthest toward the end.
*/
if (GTK_CLIST (list)->focus_row >= 0) {
if (clist->focus_row >= 0) {
start_row = clist->focus_row;
} else {
start_row = (scroll_type == GTK_SCROLL_STEP_FORWARD || scroll_type == GTK_SCROLL_PAGE_FORWARD ?
......@@ -954,9 +959,8 @@ nautilus_list_keyboard_navigation_key_press (NautilusList *list, GdkEventKey *ev
* If there is a row to start with, select the next row in the arrow direction.
*/
if (start_row < 0) {
destination_row = (scroll_type == GTK_SCROLL_STEP_FORWARD || scroll_type == GTK_SCROLL_PAGE_FORWARD ?
clist->rows - 1 :
0);
destination_row = (scroll_type == GTK_SCROLL_STEP_FORWARD || scroll_type == GTK_SCROLL_PAGE_FORWARD
? 0 : clist->rows - 1);
} else if (scroll_type == GTK_SCROLL_STEP_FORWARD) {
destination_row = MIN (clist->rows - 1, start_row + 1);
} else if (scroll_type == GTK_SCROLL_STEP_BACKWARD) {
......@@ -1088,11 +1092,7 @@ nautilus_list_key_press (GtkWidget *widget,
nautilus_list_activate_selected_items (list);
break;
default:
if (NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, key_press_event, (widget, event))) {
return TRUE;
} else {
return FALSE;
}
return NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, key_press_event, (widget, event));
}
return TRUE;
......@@ -1103,6 +1103,7 @@ nautilus_list_realize (GtkWidget *widget)
{
NautilusList *list;
GtkCList *clist;
GtkWindow *window;
g_return_if_fail (NAUTILUS_IS_LIST (widget));
......@@ -1118,10 +1119,26 @@ nautilus_list_realize (GtkWidget *widget)
}
gtk_widget_set_parent (list->details->title, GTK_WIDGET (clist));
gtk_widget_show (list->details->title);
/* make us the focused widget */
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, widget);
GTK_CLIST_SET_FLAG (clist, CLIST_SHOW_TITLES);
}
static void
nautilus_list_unrealize (GtkWidget *widget)
{
GtkWindow *window;
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, NULL);
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, unrealize, (widget));
}
/* this is here just temporarily */
static gint
list_requisition_width (GtkCList *clist)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment