[Nautilus-list] keynav patch
- From: Dave Camp <dave ximian com>
- To: nautilus-list eazel com
- Subject: [Nautilus-list] keynav patch
- Date: 15 Mar 2002 22:36:12 -0500
Here are fixes to some keynav problems.
The first is an eel patch with two parts: The first part adds some
functions to eel-gtk-extensions for dealing with viewports. The second
adds an eel_scrolled_wrap_box_new (similar in spirit to
eel_scrolled_image_chooser_new) to eel-wrap-box.c. A scrolled wrap box
will make sure the focused child is scrolled into view. (To see what
I'm talking about, open a file properties dialog, change to the emblems
page, focus a checkbox, and then use the keyboard to navigate to an
emblem below the edge of the scrolled window).
The second patch changes the emblems viewer in
src/file-manager/fm-properties-window.c to use
eel_scrolled_wrap_box_new().
The third patch is for the news sidebar, and uses the same viewport
functions to fix the same problem with the list of checkboxes.
-dave
? eel-wrap-box-keynav.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/eel/ChangeLog,v
retrieving revision 1.326
diff -u -r1.326 ChangeLog
--- ChangeLog 14 Mar 2002 00:41:37 -0000 1.326
+++ ChangeLog 16 Mar 2002 03:26:49 -0000
@@ -1,3 +1,18 @@
+2002-03-15 Dave Camp <dave ximian com>
+
+ * eel/eel-gtk-extensions.c: (eel_gtk_viewport_get_visible_rect),
+ (eel_gtk_viewport_scroll_to_rect): New functions.
+ * eel/eel-gtk-extensions.h: Prototypes for the eel_gtk_viewport
+ functions.
+ * eel/eel-wrap-table.c: (eel_scrolled_wrap_table_new): New
+ function to create a wrap table inside of a scrolled window.
+ (eel_wrap_table_add),
+ (eel_wrap_table_remove): If the wrap table is scrolled, connect
+ to focus_in_event.
+ (wrap_table_child_focus_in): New function, scrolls to the focused
+ item in the viewport.
+ * eel/eel-wrap-table.h:
+
2002-03-13 Gregory Leblanc <gleblanc linuxweasel com>
* eel.spec.in: New one, from Chris Chabot
Index: eel/eel-gtk-extensions.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-gtk-extensions.c,v
retrieving revision 1.41
diff -u -r1.41 eel-gtk-extensions.c
--- eel/eel-gtk-extensions.c 1 Mar 2002 22:13:02 -0000 1.41
+++ eel/eel-gtk-extensions.c 16 Mar 2002 03:26:49 -0000
@@ -1079,3 +1079,86 @@
gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
return eel_gdk_rectangle_contains_rectangle (visible_rect, cell_rect);
}
+
+gboolean
+eel_gtk_viewport_get_visible_rect (GtkViewport *viewport,
+ GdkRectangle *rect)
+{
+ GdkRectangle viewport_rect;
+ GdkRectangle child_rect;
+ gboolean return_val;
+
+ g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), FALSE);
+ g_return_val_if_fail (rect != NULL, FALSE);
+
+ if (GTK_WIDGET_REALIZED (viewport)) {
+ viewport_rect.x = 0;
+ viewport_rect.y = 0;
+ gdk_drawable_get_size (viewport->view_window,
+ &viewport_rect.width,
+ &viewport_rect.height);
+
+ gdk_window_get_position (viewport->bin_window,
+ &child_rect.x,
+ &child_rect.y);
+ gdk_drawable_get_size (viewport->bin_window,
+ &child_rect.width,
+ &child_rect.height);
+
+ return_val = gdk_rectangle_intersect (&viewport_rect,
+ &child_rect,
+ rect);
+ rect->x -= child_rect.x;
+ rect->y -= child_rect.y;
+
+ return return_val;
+ }
+
+ rect->x = rect->y = rect->width = rect->height = 0;
+ return FALSE;
+}
+
+void
+eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport,
+ GdkRectangle *rect)
+{
+ GdkRectangle visible_rect;
+ int scroll_x;
+ int scroll_y;
+ GtkAdjustment *adjustment;
+
+ g_return_if_fail (GTK_IS_VIEWPORT (viewport));
+ g_return_if_fail (rect != NULL);
+
+ if (eel_gtk_viewport_get_visible_rect (viewport, &visible_rect)) {
+ scroll_x = -1;
+ scroll_y = -1;
+
+ if (rect->x + rect->width > visible_rect.x + visible_rect.width) {
+ scroll_x = rect->x - (visible_rect.width - rect->width);
+ }
+ if (rect->y + rect->height > visible_rect.y + visible_rect.height) {
+ scroll_y = rect->y - (visible_rect.height - rect->height);
+ }
+
+ if (rect->x < visible_rect.x) {
+ scroll_x = rect->x;
+ }
+
+ if (rect->y < visible_rect.y) {
+ scroll_y = rect->y;
+ }
+
+ adjustment = gtk_viewport_get_hadjustment (viewport);
+ if (adjustment && scroll_x != -1) {
+ eel_gtk_adjustment_set_value (adjustment,
+ (double)scroll_x);
+ }
+
+ adjustment = gtk_viewport_get_vadjustment (viewport);
+ if (adjustment && scroll_y != -1) {
+ eel_gtk_adjustment_set_value (adjustment,
+ (double)scroll_y);
+ }
+ }
+}
Index: eel/eel-gtk-extensions.h
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-gtk-extensions.h,v
retrieving revision 1.23
diff -u -r1.23 eel-gtk-extensions.h
--- eel/eel-gtk-extensions.h 1 Mar 2002 22:13:02 -0000 1.23
+++ eel/eel-gtk-extensions.h 16 Mar 2002 03:26:49 -0000
@@ -35,6 +35,7 @@
#include <gtk/gtkmenuitem.h>
#include <gtk/gtktreeview.h>
#include <gtk/gtkwindow.h>
+#include <gtk/gtkviewport.h>
#include <eel/eel-gdk-extensions.h>
#define EEL_DEFAULT_POPUP_MENU_DISPLACEMENT 2
@@ -148,5 +149,12 @@
gboolean eel_gtk_tree_view_cell_is_completely_visible (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column);
+
+/* GtkViewport */
+gboolean eel_gtk_viewport_get_visible_rect (GtkViewport *viewport,
+ GdkRectangle *rect);
+
+void eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport,
+ GdkRectangle *rect);
#endif /* EEL_GTK_EXTENSIONS_H */
Index: eel/eel-wrap-table.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-wrap-table.c,v
retrieving revision 1.17
diff -u -r1.17 eel-wrap-table.c
--- eel/eel-wrap-table.c 6 Mar 2002 19:34:14 -0000 1.17
+++ eel/eel-wrap-table.c 16 Mar 2002 03:26:50 -0000
@@ -32,6 +32,7 @@
#include "eel-types.h"
#include <gtk/gtkmain.h>
#include <gtk/gtkviewport.h>
+#include <gtk/gtkscrolledwindow.h>
/* Arguments */
enum
@@ -53,6 +54,8 @@
EelJustification y_justification;
gboolean homogeneous;
GList *children;
+
+ gboolean is_scrolled : 1;
};
static void eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class);
@@ -99,8 +102,12 @@
static GtkWidget * wrap_table_find_child_at_point (const EelWrapTable *wrap_table,
int x,
int y);
+static gboolean wrap_table_child_focus_in (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer data);
static void wrap_table_layout (EelWrapTable *wrap_table);
+
EEL_CLASS_BOILERPLATE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER)
/* Class init methods */
@@ -404,6 +411,12 @@
gtk_widget_queue_resize (child);
}
+
+ if (wrap_table->details->is_scrolled) {
+ g_signal_connect (child, "focus_in_event",
+ G_CALLBACK (wrap_table_child_focus_in),
+ wrap_table);
+ }
}
static void
@@ -425,6 +438,13 @@
if (child_was_visible) {
gtk_widget_queue_resize (GTK_WIDGET (container));
}
+
+ if (wrap_table->details->is_scrolled) {
+ g_signal_handlers_disconnect_by_func (
+ child,
+ G_CALLBACK (wrap_table_child_focus_in),
+ wrap_table);
+ }
}
static void
@@ -691,6 +711,20 @@
return scroll_offset;
}
+static gboolean
+wrap_table_child_focus_in (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer data)
+{
+ g_return_val_if_fail (widget->parent && widget->parent->parent, FALSE);
+ g_return_val_if_fail (GTK_IS_VIEWPORT (widget->parent->parent), FALSE);
+
+ eel_gtk_viewport_scroll_to_rect (GTK_VIEWPORT (widget->parent->parent),
+ &widget->allocation);
+
+ return FALSE;
+}
+
static GtkWidget *
wrap_table_find_child_at_point (const EelWrapTable *wrap_table,
int x,
@@ -1000,3 +1034,38 @@
return g_list_length (wrap_table->details->children);
}
+GtkWidget *
+eel_scrolled_wrap_table_new (gboolean homogenous,
+ GtkWidget **wrap_table_out)
+{
+ GtkWidget *scrolled_window;
+ GtkWidget *wrap_table;
+ GtkWidget *viewport;
+
+ g_return_val_if_fail (wrap_table_out != NULL, NULL);
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+
+ viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scrolled_window)),
+ gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window)));
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport),
+ GTK_SHADOW_NONE);
+
+ gtk_container_add (GTK_CONTAINER (scrolled_window),
+ viewport);
+
+ wrap_table = eel_wrap_table_new (homogenous);
+ gtk_container_add (GTK_CONTAINER (viewport),
+ wrap_table);
+
+ gtk_widget_show (wrap_table);
+ gtk_widget_show (viewport);
+
+ EEL_WRAP_TABLE (wrap_table)->details->is_scrolled = 1;
+
+ *wrap_table_out = wrap_table;
+ return scrolled_window;
+}
Index: eel/eel-wrap-table.h
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-wrap-table.h,v
retrieving revision 1.5
diff -u -r1.5 eel-wrap-table.h
--- eel/eel-wrap-table.h 9 Jul 2001 19:51:16 -0000 1.5
+++ eel/eel-wrap-table.h 16 Mar 2002 03:26:50 -0000
@@ -87,6 +87,9 @@
int position);
guint eel_wrap_table_get_num_children (const EelWrapTable *wrap_table);
+GtkWidget * eel_scrolled_wrap_table_new (gboolean homogenous,
+ GtkWidget **wrap_table_out);
+
G_END_DECLS
#endif /* EEL_WRAP_TABLE_H */
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5140
diff -u -r1.5140 ChangeLog
--- ChangeLog 15 Mar 2002 04:47:22 -0000 1.5140
+++ ChangeLog 16 Mar 2002 03:30:16 -0000
@@ -1,3 +1,8 @@
+2002-03-15 Dave Camp <dave ximian com>
+
+ * src/file-manager/fm-properties-window.c: (create_emblems_page):
+ use eel_scrolled_wrap_box_new().
+
2002-03-15 Hasbullah Bin Pit <sebol ikhlas com>
* configure.in: Added Malay (ms)to ALL_LINGUAS.
Index: src/file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.148
diff -u -r1.148 fm-properties-window.c
--- src/file-manager/fm-properties-window.c 7 Mar 2002 19:36:16 -0000 1.148
+++ src/file-manager/fm-properties-window.c 16 Mar 2002 03:30:16 -0000
@@ -1631,14 +1631,6 @@
}
static void
-remove_default_viewport_shadow (GtkViewport *viewport)
-{
- g_return_if_fail (GTK_IS_VIEWPORT (viewport));
-
- gtk_viewport_set_shadow_type (viewport, GTK_SHADOW_NONE);
-}
-
-static void
create_emblems_page (FMPropertiesWindow *window)
{
NautilusCustomizationData *customization_data;
@@ -1651,27 +1643,11 @@
file = window->details->target_file;
/* The emblems wrapped table */
- emblems_table = eel_wrap_table_new (TRUE);
+ scroller = eel_scrolled_wrap_table_new (TRUE, &emblems_table);
- gtk_widget_show (emblems_table);
gtk_container_set_border_width (GTK_CONTAINER (emblems_table), GNOME_PAD);
- scroller = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
-
- /* Viewport */
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller),
- emblems_table);
gtk_widget_show (scroller);
-
- /* Get rid of default lowered shadow appearance.
- * This must be done after the widget is realized, due to
- * an apparent bug in gtk_viewport_set_shadow_type.
- */
- g_signal_connect (GTK_BIN (scroller)->child, "realize",
- G_CALLBACK (remove_default_viewport_shadow), NULL);
gtk_notebook_append_page (window->details->notebook,
scroller, gtk_label_new (_("Emblems")));
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5140
diff -u -r1.5140 ChangeLog
--- ChangeLog 15 Mar 2002 04:47:22 -0000 1.5140
+++ ChangeLog 16 Mar 2002 03:27:39 -0000
@@ -1,3 +1,10 @@
+2002-03-15 Dave Camp <dave ximian com>
+
+ * components/news/nautilus-news.c:
+ (check_button_focus_in_callback), (add_channel_entry): Use the
+ new eel_gtk_viewport functions to move the focused checkbox into
+ view on focus changes.
+
2002-03-15 Hasbullah Bin Pit <sebol ikhlas com>
* configure.in: Added Malay (ms)to ALL_LINGUAS.
Index: components/news/nautilus-news.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/news/nautilus-news.c,v
retrieving revision 1.61
diff -u -r1.61 nautilus-news.c
--- components/news/nautilus-news.c 15 Mar 2002 02:42:02 -0000 1.61
+++ components/news/nautilus-news.c 16 Mar 2002 03:27:39 -0000
@@ -1923,6 +1923,21 @@
}
}
+static gboolean
+check_button_focus_in_callback (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer data)
+{
+ g_return_val_if_fail (widget->parent && widget->parent->parent, FALSE);
+ g_return_val_if_fail (GTK_IS_VIEWPORT (widget->parent->parent), FALSE);
+
+ eel_gtk_viewport_scroll_to_rect (GTK_VIEWPORT (widget->parent->parent),
+ &widget->allocation);
+
+ return FALSE;
+}
+
+
/* callback to maintain the current location */
static void
nautilus_news_load_location (NautilusView *view, const char *location, News *news)
@@ -2005,6 +2020,9 @@
g_signal_connect (check_button, "toggled",
G_CALLBACK (check_button_toggled_callback),
+ news_data);
+ g_signal_connect (check_button, "focus_in_event",
+ G_CALLBACK (check_button_focus_in_callback),
news_data);
/* reorder newly added button so it's sorted by it's name */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]