Make 50% the default list view zoom.

2003-03-10  Alexander Larsson  <alexl@redhat.com>

	* libnautilus-private/nautilus-global-preferences.c:
	* libnautilus-private/apps_nautilus_preferences.schemas:
	Make 50% the default list view zoom.

	* libnautilus-private/nautilus-bookmark.h:
	* libnautilus-private/nautilus-bookmark.c:
	(nautilus_bookmark_finalize),
	(nautilus_bookmark_uri_known_not_to_exist),
	(nautilus_bookmark_set_scroll_pos),
	(nautilus_bookmark_get_scroll_pos):
	Add scroll positions to bookmarks. Used for the window
	back/forward history.

	* libnautilus-private/nautilus-icon-container.h:
	* libnautilus-private/nautilus-icon-container.c:
	(nautilus_icon_container_get_first_visible_icon),
	(nautilus_icon_container_scroll_to_icon):
	Add new functions.

	* libnautilus/nautilus-view-component.idl:
	Add Nautilus::ScollPositionable interface.

	* libnautilus/Makefile.am:
	* libnautilus/nautilus-scroll-positionable.h:
	* libnautilus/nautilus-scroll-positionable.c:
	Standard implementation of Nautilus::ScollPositionable.

	* src/file-manager/fm-icon-view.c:
	(icon_view_get_first_visible_file_callback),
	(icon_view_scroll_to_file_callback), (fm_icon_view_instance_init):
	Implement Nautilus::ScollPositionable for icon view.

	* src/file-manager/fm-list-view.c:
	(list_view_get_first_visible_file_callback),
	(list_view_scroll_to_file_callback), (fm_list_view_instance_init):
	Implement Nautilus::ScollPositionable for list view.

	* src/nautilus-view-frame.h:
	* src/nautilus-view-frame.c: (destroy_view),
	(create_corba_objects),
	(nautilus_view_frame_get_first_visible_file),
	(nautilus_view_frame_scroll_to_file):
	Add support for Nautilus::ScollPositionable.

	* src/nautilus-window-private.h:
	* src/nautilus-window-manage-views.c: (open_location),
	(free_location_change), (end_location_change),
	(begin_location_change), (nautilus_window_set_content_view),
	(load_complete_callback), (nautilus_window_back_or_forward),
	(nautilus_window_reload):
	Save scroll position when changing location and switching
	components. Scroll to the right place on back/forward.
This commit is contained in:
Alexander Larsson 2003-03-10 16:46:07 +00:00 committed by Alexander Larsson
parent 1809091597
commit f4723e980c
17 changed files with 602 additions and 13 deletions

View file

@ -1,3 +1,58 @@
2003-03-10 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-global-preferences.c:
* libnautilus-private/apps_nautilus_preferences.schemas:
Make 50% the default list view zoom.
* libnautilus-private/nautilus-bookmark.h:
* libnautilus-private/nautilus-bookmark.c:
(nautilus_bookmark_finalize),
(nautilus_bookmark_uri_known_not_to_exist),
(nautilus_bookmark_set_scroll_pos),
(nautilus_bookmark_get_scroll_pos):
Add scroll positions to bookmarks. Used for the window
back/forward history.
* libnautilus-private/nautilus-icon-container.h:
* libnautilus-private/nautilus-icon-container.c:
(nautilus_icon_container_get_first_visible_icon),
(nautilus_icon_container_scroll_to_icon):
Add new functions.
* libnautilus/nautilus-view-component.idl:
Add Nautilus::ScollPositionable interface.
* libnautilus/Makefile.am:
* libnautilus/nautilus-scroll-positionable.h:
* libnautilus/nautilus-scroll-positionable.c:
Standard implementation of Nautilus::ScollPositionable.
* src/file-manager/fm-icon-view.c:
(icon_view_get_first_visible_file_callback),
(icon_view_scroll_to_file_callback), (fm_icon_view_instance_init):
Implement Nautilus::ScollPositionable for icon view.
* src/file-manager/fm-list-view.c:
(list_view_get_first_visible_file_callback),
(list_view_scroll_to_file_callback), (fm_list_view_instance_init):
Implement Nautilus::ScollPositionable for list view.
* src/nautilus-view-frame.h:
* src/nautilus-view-frame.c: (destroy_view),
(create_corba_objects),
(nautilus_view_frame_get_first_visible_file),
(nautilus_view_frame_scroll_to_file):
Add support for Nautilus::ScollPositionable.
* src/nautilus-window-private.h:
* src/nautilus-window-manage-views.c: (open_location),
(free_location_change), (end_location_change),
(begin_location_change), (nautilus_window_set_content_view),
(load_complete_callback), (nautilus_window_back_or_forward),
(nautilus_window_reload):
Save scroll position when changing location and switching
components. Scroll to the right place on back/forward.
2003-03-08 Dave Camp <dave@ximian.com>
* components/text/nautilus-text-view-ui.xml: Fixed the strings

View file

@ -569,7 +569,7 @@
<applyto>/apps/nautilus/list_view/default_zoom_level</applyto>
<owner>nautilus</owner>
<type>string</type>
<default>small</default>
<default>smaller</default>
<locale name="C">
<short>Default zoom level used by the list view</short>
<long>

View file

@ -58,6 +58,8 @@ struct NautilusBookmarkDetails
char *uri;
char *icon;
NautilusFile *file;
char *scroll_file;
};
static void nautilus_bookmark_connect_file (NautilusBookmark *file);
@ -82,6 +84,7 @@ nautilus_bookmark_finalize (GObject *object)
g_free (bookmark->details->name);
g_free (bookmark->details->uri);
g_free (bookmark->details->icon);
g_free (bookmark->details->scroll_file);
g_free (bookmark->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -544,3 +547,17 @@ nautilus_bookmark_uri_known_not_to_exist (NautilusBookmark *bookmark)
return !exists;
}
void
nautilus_bookmark_set_scroll_pos (NautilusBookmark *bookmark,
const char *uri)
{
g_free (bookmark->details->scroll_file);
bookmark->details->scroll_file = g_strdup (uri);
}
char *
nautilus_bookmark_get_scroll_pos (NautilusBookmark *bookmark)
{
return g_strdup (bookmark->details->scroll_file);
}

View file

@ -84,6 +84,11 @@ int nautilus_bookmark_compare_with (gconstpointer
int nautilus_bookmark_compare_uris (gconstpointer a,
gconstpointer b);
void nautilus_bookmark_set_scroll_pos (NautilusBookmark *bookmark,
const char *uri);
char * nautilus_bookmark_get_scroll_pos (NautilusBookmark *bookmark);
/* Helper functions for displaying bookmarks */
GdkPixbuf * nautilus_bookmark_get_pixbuf (NautilusBookmark *bookmark,
guint icon_size,

View file

@ -486,7 +486,7 @@ static const PreferenceDefault preference_defaults[] = {
},
{ NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
PREFERENCE_STRING,
"small",
"smaller",
NULL, NULL,
"default_zoom_level"
},

View file

@ -3823,6 +3823,76 @@ nautilus_icon_container_is_empty (NautilusIconContainer *container)
return container->details->icons == NULL;
}
NautilusIconData *
nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container)
{
GList *l;
NautilusIcon *icon;
GtkAdjustment *vadj;
double x, y;
double x1, y1, x2, y2;
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
eel_canvas_c2w (EEL_CANVAS (container),
0, vadj->value,
&x, &y);
l = container->details->icons;
while (l != NULL) {
icon = l->data;
if (icon_is_positioned (icon)) {
eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (icon->item),
&x1, &y1, &x2, &y2);
if (y2 > y) {
return icon->data;
}
}
l = l->next;
}
return NULL;
}
void
nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container,
NautilusIconData *data)
{
GList *l;
NautilusIcon *icon;
GtkAdjustment *vadj;
int x, y;
double x1, y1, x2, y2;
EelCanvasItem *item;
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
l = container->details->icons;
while (l != NULL) {
icon = l->data;
if (icon->data == data &&
icon_is_positioned (icon)) {
item = EEL_CANVAS_ITEM (icon->item);
eel_canvas_item_get_bounds (item,
&x1, &y1, &x2, &y2);
eel_canvas_item_i2w (item->parent,
&x1,
&y1);
eel_canvas_w2c (item->canvas,
x1, y1,
&x, &y);
y = MAX (0, y);
eel_gtk_adjustment_set_value (vadj, y);
}
l = l->next;
}
}
/* Call a function for all the icons. */
typedef struct {
NautilusIconCallback callback;

View file

@ -191,6 +191,9 @@ void nautilus_icon_container_request_update_all (Nautilu
void nautilus_icon_container_reveal (NautilusIconContainer *container,
NautilusIconData *data);
gboolean nautilus_icon_container_is_empty (NautilusIconContainer *container);
NautilusIconData *nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container);
void nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container,
NautilusIconData *data);
/* control the layout */
gboolean nautilus_icon_container_is_auto_layout (NautilusIconContainer *container);

View file

@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \
nautilus-clipboard.h \
nautilus-distributed-undo.h \
nautilus-idle-queue.h \
nautilus-scroll-positionable.h \
nautilus-view-component.h \
nautilus-view.h \
nautilus-view-standard-main.h \
@ -46,6 +47,7 @@ libnautilus_la_SOURCES= \
$(nautilus_distributed_undo_idl_sources) \
nautilus-clipboard.c \
nautilus-idle-queue.c \
nautilus-scroll-positionable.c \
nautilus-undo-transaction.c \
nautilus-undo-transaction.h \
nautilus-undo.c \

View file

@ -0,0 +1,155 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-scroll-positionable.c - public interface for objects that implement
* scroll positioning
*
* Copyright (C) 2003 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#include "nautilus-scroll-positionable.h"
#include <config.h>
#include <string.h>
#include <bonobo/bonobo-i18n.h>
#include <bonobo/bonobo-exception.h>
#include <eel/eel-marshal.h>
enum {
GET_FIRST_VISIBLE_FILE,
SCROLL_TO_FILE,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL];
BONOBO_CLASS_BOILERPLATE_FULL (NautilusScrollPositionable, nautilus_scroll_positionable, Nautilus_ScrollPositionable,
BonoboObject, BONOBO_OBJECT_TYPE)
static Nautilus_URI
impl_Nautilus_Scroll_Positionable_get_first_visible_file (PortableServer_Servant servant,
CORBA_Environment *ev)
{
NautilusScrollPositionable *positionable;
char *uri;
char *ret;
positionable = NAUTILUS_SCROLL_POSITIONABLE (bonobo_object_from_servant (servant));
uri = NULL;
g_signal_emit (G_OBJECT (positionable), signals [GET_FIRST_VISIBLE_FILE],
0, &uri);
if (uri) {
ret = CORBA_string_dup (uri);
g_free (uri);
} else {
ret = CORBA_string_dup ("");
}
return ret;
}
static void
impl_Nautilus_Scroll_Positionable_scroll_to_file (PortableServer_Servant servant,
const CORBA_char *uri,
CORBA_Environment *ev)
{
NautilusScrollPositionable *positionable;
positionable = NAUTILUS_SCROLL_POSITIONABLE (bonobo_object_from_servant (servant));
g_signal_emit (G_OBJECT (positionable),
signals [SCROLL_TO_FILE], 0,
uri);
}
static char *
nautilus_scroll_positionable_get_first_visible_file (NautilusScrollPositionable *positionable)
{
return NULL;
}
static void
nautilus_scroll_positionable_instance_init (NautilusScrollPositionable *positionable)
{
}
static void
nautilus_scroll_positionable_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
single_string_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
const GValue *handler_return,
gpointer dummy)
{
gboolean continue_emission;
const gchar *str;
str = g_value_get_string (handler_return);
g_value_set_string (return_accu, str);
continue_emission = str == NULL;
return continue_emission;
}
static void
nautilus_scroll_positionable_class_init (NautilusScrollPositionableClass *klass)
{
POA_Nautilus_ScrollPositionable__epv *epv = &klass->epv;
GObjectClass *object_class;
object_class = (GObjectClass *) klass;
klass->get_first_visible_file = nautilus_scroll_positionable_get_first_visible_file;
object_class->finalize = nautilus_scroll_positionable_finalize;
signals [GET_FIRST_VISIBLE_FILE] =
g_signal_new ("get_first_visible_file",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusScrollPositionableClass, get_first_visible_file),
single_string_accumulator, NULL,
eel_marshal_STRING__VOID,
G_TYPE_STRING, 0);
signals [SCROLL_TO_FILE] =
g_signal_new ("scroll_to_file",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusScrollPositionableClass, scroll_to_file),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
epv->scroll_to_file = impl_Nautilus_Scroll_Positionable_scroll_to_file;
epv->get_first_visible_file = impl_Nautilus_Scroll_Positionable_get_first_visible_file;
}
NautilusScrollPositionable *
nautilus_scroll_positionable_new (void)
{
return g_object_new (nautilus_scroll_positionable_get_type (), NULL);
}

View file

@ -0,0 +1,62 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-scroll-positionable.h - public interface for objects that implement
* scroll positioning
*
* Copyright (C) 2003 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#ifndef NAUTILUS_SCROLL_POSITIONABLE_H
#define NAUTILUS_SCROLL_POSITIONABLE_H
#include <libnautilus/nautilus-view-component.h>
#include <bonobo/bonobo-object.h>
G_BEGIN_DECLS
#define NAUTILUS_TYPE_SCROLL_POSITIONABLE (nautilus_scroll_positionable_get_type ())
#define NAUTILUS_SCROLL_POSITIONABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_SCROLL_POSITIONABLE, NautilusScrollPositionable))
#define NAUTILUS_SCROLL_POSITIONABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_SCROLL_POSITIONABLE, NautilusScrollPositionableClass))
#define BONOBO_IS_POSITIONABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_SCROLL_POSITIONABLE))
#define BONOBO_IS_POSITIONABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_SCROLL_POSITIONABLE))
#define NAUTILUS_SCROLL_POSITIONABLE_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_SCROLL_POSITIONABLE, NautilusScrollPositionableClass))
typedef struct _NautilusScrollPositionablePrivate NautilusScrollPositionablePrivate;
typedef struct {
BonoboObject object;
} NautilusScrollPositionable;
typedef struct {
BonoboObjectClass parent;
POA_Nautilus_ScrollPositionable__epv epv;
char * (*get_first_visible_file) (NautilusScrollPositionable *positionable);
void (*scroll_to_file) (NautilusScrollPositionable *positionable,
const char *uri);
gpointer dummy[4];
} NautilusScrollPositionableClass;
GType nautilus_scroll_positionable_get_type (void) G_GNUC_CONST;
NautilusScrollPositionable *nautilus_scroll_positionable_new (void);
#endif /* NAUTILUS_SCROLL_POSITIONABLE_H */

View file

@ -66,6 +66,16 @@ module Nautilus {
oneway void load_location (in URI location);
oneway void stop_loading ();
};
/* An interface that allows the shell to query the current
* scrolled position of views, and later return to that
* position. Typically used when going back/forward.
*/
interface ScrollPositionable : ::Bonobo::Unknown {
URI get_first_visible_file ();
void scroll_to_file (in URI position);
};
/* The ViewFrame interface is used by the view to communicate
* with the Nautilus shell. It's implemented as an interface

View file

@ -69,6 +69,7 @@
#include <libnautilus-private/nautilus-sound.h>
#include <libnautilus/nautilus-bonobo-ui.h>
#include <libnautilus/nautilus-clipboard.h>
#include <libnautilus/nautilus-scroll-positionable.h>
#include <locale.h>
#include <signal.h>
#include <stdio.h>
@ -128,6 +129,8 @@ struct FMIconViewDetails
const SortCriterion *sort;
gboolean sort_reversed;
NautilusScrollPositionable *positionable;
BonoboUIComponent *ui;
NautilusAudioPlayerData *audio_player_data;
@ -2436,6 +2439,38 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur
}
static char *
icon_view_get_first_visible_file_callback (NautilusScrollPositionable *positionable,
FMIconView *icon_view)
{
NautilusFile *file;
file = NAUTILUS_FILE (nautilus_icon_container_get_first_visible_icon (get_icon_container (icon_view)));
if (file) {
return nautilus_file_get_uri (file);
}
return NULL;
}
static void
icon_view_scroll_to_file_callback (NautilusScrollPositionable *positionable,
const char *uri,
FMIconView *icon_view)
{
NautilusFile *file;
if (uri != NULL) {
file = nautilus_file_get (uri);
if (file != NULL) {
nautilus_icon_container_scroll_to_icon (get_icon_container (icon_view),
NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
nautilus_file_unref (file);
}
}
}
static void
fm_icon_view_class_init (FMIconViewClass *klass)
{
@ -2492,6 +2527,7 @@ static void
fm_icon_view_instance_init (FMIconView *icon_view)
{
static gboolean setup_sound_preview = FALSE;
NautilusView *nautilus_view;
g_return_if_fail (GTK_BIN (icon_view)->child == NULL);
@ -2501,6 +2537,11 @@ fm_icon_view_instance_init (FMIconView *icon_view)
create_icon_container (icon_view);
icon_view->details->positionable = nautilus_scroll_positionable_new ();
nautilus_view = fm_directory_view_get_nautilus_view (FM_DIRECTORY_VIEW (icon_view));
bonobo_object_add_interface (BONOBO_OBJECT (nautilus_view),
BONOBO_OBJECT (icon_view->details->positionable));
if (!setup_sound_preview) {
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_PREVIEW_SOUND,
&preview_sound_auto_value);
@ -2530,5 +2571,8 @@ fm_icon_view_instance_init (FMIconView *icon_view)
g_signal_connect_object (get_icon_container (icon_view), "handle_uri_list",
G_CALLBACK (icon_view_handle_uri_list), icon_view, 0);
g_signal_connect_object (icon_view->details->positionable, "get_first_visible_file",
G_CALLBACK (icon_view_get_first_visible_file_callback), icon_view, 0);
g_signal_connect_object (icon_view->details->positionable, "scroll_to_file",
G_CALLBACK (icon_view_scroll_to_file_callback), icon_view, 0);
}

View file

@ -48,6 +48,7 @@
#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-tree-view-drag-dest.h>
#include <libnautilus/nautilus-scroll-positionable.h>
struct FMListViewDetails {
GtkTreeView *tree_view;
@ -63,6 +64,8 @@ struct FMListViewDetails {
NautilusZoomLevel zoom_level;
NautilusScrollPositionable *positionable;
NautilusTreeViewDragDest *drag_dest;
};
@ -950,6 +953,63 @@ fm_list_view_emblems_changed (FMDirectoryView *directory_view)
#endif
}
static char *
list_view_get_first_visible_file_callback (NautilusScrollPositionable *positionable,
FMListView *list_view)
{
NautilusFile *file;
GtkTreePath *path;
GtkTreeIter iter;
if (gtk_tree_view_get_path_at_pos (list_view->details->tree_view,
0, 0,
&path, NULL, NULL, NULL)) {
gtk_tree_model_get_iter (GTK_TREE_MODEL (list_view->details->model),
&iter, path);
gtk_tree_path_free (path);
gtk_tree_model_get (GTK_TREE_MODEL (list_view->details->model),
&iter,
FM_LIST_MODEL_FILE_COLUMN, &file,
-1);
if (file) {
return nautilus_file_get_uri (file);
}
}
return NULL;
}
static void
list_view_scroll_to_file_callback (NautilusScrollPositionable *positionable,
const char *uri,
FMListView *list_view)
{
NautilusFile *file;
GtkTreePath *path;
GtkTreeIter iter;
if (uri != NULL) {
file = nautilus_file_get (uri);
if (!fm_list_model_get_tree_iter_from_file (list_view->details->model, file, &iter)) {
nautilus_file_unref (file);
return;
}
path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_view->details->model), &iter);
gtk_tree_view_scroll_to_cell (list_view->details->tree_view,
path, NULL,
TRUE, 0.0, 0.0);
gtk_tree_path_free (path);
nautilus_file_unref (file);
}
}
static void
fm_list_view_class_init (FMListViewClass *class)
{
@ -993,10 +1053,18 @@ fm_list_view_class_init (FMListViewClass *class)
static void
fm_list_view_instance_init (FMListView *list_view)
{
NautilusView *nautilus_view;
list_view->details = g_new0 (FMListViewDetails, 1);
create_and_set_up_tree_view (list_view);
list_view->details->positionable = nautilus_scroll_positionable_new ();
nautilus_view = fm_directory_view_get_nautilus_view (FM_DIRECTORY_VIEW (list_view));
bonobo_object_add_interface (BONOBO_OBJECT (nautilus_view),
BONOBO_OBJECT (list_view->details->positionable));
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list_view, G_OBJECT (list_view));
@ -1019,4 +1087,8 @@ fm_list_view_instance_init (FMListView *list_view)
"icons_changed",
G_CALLBACK (icons_changed_callback),
list_view, 0);
g_signal_connect_object (list_view->details->positionable, "get_first_visible_file",
G_CALLBACK (list_view_get_first_visible_file_callback), list_view, 0);
g_signal_connect_object (list_view->details->positionable, "scroll_to_file",
G_CALLBACK (list_view_scroll_to_file_callback), list_view, 0);
}

View file

@ -95,10 +95,13 @@ struct NautilusViewFrameDetails {
BonoboEventSource *event_source;
BonoboControlFrame *control_frame;
BonoboZoomableFrame *zoomable_frame;
/* The view CORBA object. */
Nautilus_View view;
/* The positionable CORBA object. */
Nautilus_ScrollPositionable positionable;
/* A container to connect our clients to. */
BonoboUIContainer *ui_container;
NautilusUndoManager *undo_manager;
@ -182,6 +185,11 @@ destroy_view (NautilusViewFrame *view)
g_free (view->details->view_iid);
view->details->view_iid = NULL;
if (view->details->positionable != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (view->details->positionable, NULL);
view->details->positionable = CORBA_OBJECT_NIL;
}
CORBA_Object_release (view->details->view, NULL);
view->details->view = CORBA_OBJECT_NIL;
@ -578,6 +586,7 @@ create_corba_objects (NautilusViewFrame *view)
CORBA_Environment ev;
Bonobo_Control control;
Bonobo_Zoomable zoomable;
Nautilus_ScrollPositionable positionable;
BonoboPropertyBag *bag;
CORBA_exception_init (&ev);
@ -615,6 +624,18 @@ create_corba_objects (NautilusViewFrame *view)
CORBA_exception_free (&ev);
CORBA_exception_init (&ev);
positionable = Bonobo_Unknown_queryInterface
(view->details->view, "IDL:Nautilus/ScrollPositionable:1.0", &ev);
if (!BONOBO_EX (&ev)
&& !CORBA_Object_is_nil (positionable, &ev)
&& !BONOBO_EX (&ev)) {
view->details->positionable = positionable;
}
CORBA_exception_free (&ev);
/* Aggregate all the interfaces into one object. */
bonobo_object_add_interface (BONOBO_OBJECT (view->details->view_frame),
BONOBO_OBJECT (view->details->control_frame));
@ -1054,6 +1075,33 @@ nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view)
bonobo_zoomable_frame_zoom_to_fit (view->details->zoomable_frame);
}
char *
nautilus_view_frame_get_first_visible_file (NautilusViewFrame *view)
{
Nautilus_URI uri;
char *ret;
ret = NULL;
if (view->details->positionable) {
uri = Nautilus_ScrollPositionable_get_first_visible_file (view->details->positionable, NULL);
ret = g_strdup (uri);
CORBA_free (uri);
}
return ret;
}
void
nautilus_view_frame_scroll_to_file (NautilusViewFrame *view,
const char *uri)
{
if (view->details->positionable) {
Nautilus_ScrollPositionable_scroll_to_file (view->details->positionable,
uri,
NULL);
}
}
const char *
nautilus_view_frame_get_view_iid (NautilusViewFrame *view)
{

View file

@ -128,6 +128,11 @@ void nautilus_view_frame_zoom_in (NautilusViewFr
void nautilus_view_frame_zoom_out (NautilusViewFrame *view);
void nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view);
/* calls to Nautilus::ScrollPositionable */
char * nautilus_view_frame_get_first_visible_file (NautilusViewFrame *view);
void nautilus_view_frame_scroll_to_file (NautilusViewFrame *view,
const char *uri);
/* Other. */
gboolean nautilus_view_frame_get_is_view_loaded (NautilusViewFrame *view);
const char * nautilus_view_frame_get_view_iid (NautilusViewFrame *view);

View file

@ -108,7 +108,8 @@ static void disconnect_view (NautilusWindow *window,
static void begin_location_change (NautilusWindow *window,
const char *location,
NautilusLocationChangeType type,
guint distance);
guint distance,
const char *scroll_pos);
static void free_location_change (NautilusWindow *window);
static void end_location_change (NautilusWindow *window);
static void cancel_location_change (NautilusWindow *window);
@ -753,7 +754,7 @@ open_location (NautilusWindow *window,
"This can cause subtle evils like #48423", location);
begin_location_change (target_window, location,
NAUTILUS_LOCATION_CHANGE_STANDARD, 0);
NAUTILUS_LOCATION_CHANGE_STANDARD, 0, NULL);
}
void
@ -1115,6 +1116,10 @@ free_location_change (NautilusWindow *window)
g_free (window->details->pending_location);
window->details->pending_location = NULL;
/* Don't free pending_scroll_to, since thats needed until
* the load_complete callback.
*/
if (window->details->determine_view_handle != NULL) {
nautilus_determine_initial_view_cancel (window->details->determine_view_handle);
window->details->determine_view_handle = NULL;
@ -1134,6 +1139,13 @@ static void
end_location_change (NautilusWindow *window)
{
nautilus_window_allow_stop (window, FALSE);
/* Now we can free pending_scroll_to, since the load_complete
* callback already has been emitted.
*/
g_free (window->details->pending_scroll_to);
window->details->pending_scroll_to = NULL;
free_location_change (window);
}
@ -1464,16 +1476,19 @@ determined_initial_view_callback (NautilusDetermineViewHandle *handle,
* @type: Which type of location change is this? Standard, back, forward, or reload?
* @distance: If type is back or forward, the index into the back or forward chain. If
* type is standard or reload, this is ignored, and must be 0.
* @scroll_pos: The file to scroll to when the location is loaded.
*/
static void
begin_location_change (NautilusWindow *window,
const char *location,
NautilusLocationChangeType type,
guint distance)
guint distance,
const char *scroll_pos)
{
NautilusDirectory *directory;
NautilusFile *file;
gboolean force_reload;
char *current_pos;
g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (location != NULL);
@ -1490,7 +1505,9 @@ begin_location_change (NautilusWindow *window,
window->details->pending_location = g_strdup (location);
window->details->location_change_type = type;
window->details->location_change_distance = distance;
window->details->pending_scroll_to = g_strdup (scroll_pos);
directory = nautilus_directory_get (location);
/* The code to force a reload is here because if we do it
@ -1513,6 +1530,13 @@ begin_location_change (NautilusWindow *window,
}
nautilus_directory_unref (directory);
/* Set current_bookmark scroll pos */
if (window->current_location_bookmark != NULL) {
current_pos = nautilus_view_frame_get_first_visible_file (window->content_view);
nautilus_bookmark_set_scroll_pos (window->current_location_bookmark, current_pos);
g_free (current_pos);
}
window->details->determine_view_handle = nautilus_determine_initial_view
(location, determined_initial_view_callback, window);
@ -1564,18 +1588,24 @@ nautilus_window_set_content_view (NautilusWindow *window,
g_return_if_fail (window->details->location != NULL);
g_return_if_fail (id != NULL);
end_location_change (window);
if (nautilus_window_content_view_matches_iid (window, id->iid)) {
return;
}
end_location_change (window);
file = nautilus_file_get (window->details->location);
nautilus_mime_set_default_component_for_file
(file, id->iid);
nautilus_file_unref (file);
nautilus_window_allow_stop (window, TRUE);
if (window->details->selection == NULL) {
/* If there is no selection, queue a scroll to the same icon that
* is currently visible */
window->details->pending_scroll_to = nautilus_view_frame_get_first_visible_file (window->content_view);
}
load_content_view (window, id);
}
@ -1873,6 +1903,10 @@ load_complete_callback (NautilusViewFrame *view,
*/
if (view == window->content_view) {
if (window->details->pending_scroll_to != NULL) {
nautilus_view_frame_scroll_to_file (window->content_view,
window->details->pending_scroll_to);
}
end_location_change (window);
}
}
@ -2196,7 +2230,9 @@ nautilus_window_back_or_forward (NautilusWindow *window, gboolean back, guint di
{
GList *list;
char *uri;
char *scroll_pos;
guint len;
NautilusBookmark *bookmark;
list = back ? window->back_list : window->forward_list;
@ -2211,14 +2247,18 @@ nautilus_window_back_or_forward (NautilusWindow *window, gboolean back, guint di
if (distance >= len)
distance = len - 1;
uri = nautilus_bookmark_get_uri (g_list_nth_data (list, distance));
bookmark = g_list_nth_data (list, distance);
uri = nautilus_bookmark_get_uri (bookmark);
scroll_pos = nautilus_bookmark_get_scroll_pos (bookmark);
begin_location_change
(window,
uri,
back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD,
distance);
distance,
scroll_pos);
g_free (uri);
g_free (scroll_pos);
}
/* reload the contents of the window */
@ -2235,6 +2275,6 @@ nautilus_window_reload (NautilusWindow *window)
location = g_strdup (window->details->location);
begin_location_change
(window, location,
NAUTILUS_LOCATION_CHANGE_RELOAD, 0);
NAUTILUS_LOCATION_CHANGE_RELOAD, 0, NULL);
g_free (location);
}

View file

@ -76,6 +76,7 @@ struct NautilusWindowDetails
NautilusLocationChangeType location_change_type;
guint location_change_distance;
char *pending_location;
char *pending_scroll_to;
GList *pending_selection;
NautilusDetermineViewHandle *determine_view_handle;