[Nautilus-list] The Bonobo::Zoomable patch
- From: Martin Baulig <martin home-of-linux org>
- To: nautilus-list lists eazel com
- Subject: [Nautilus-list] The Bonobo::Zoomable patch
- Date: 12 Oct 2000 02:38:32 +0200
Hi guys,
here is the Nautilus::Zoomable -> Bonobo::Zoomable patch
which I promised you:
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.2312
diff -u -u -p -r1.2312 ChangeLog
--- ChangeLog 2000/10/11 20:19:53 1.2312
+++ ChangeLog 2000/10/12 00:36:02
@@ -1,3 +1,76 @@
+2000-10-12 Martin Baulig <baulig suse de>
+
+ Use the new Bonobo::Zoomable interface instead of Nautilus::Zoomable.
+
+ * libnautilus/nautilus-zoomable.[ch]: Removed.
+ * src/nautilus-zoomable-frame-corba.c: Removed.
+
+ * libnautilus/nautilus-view-component.idl
+ (ZoomLevels, ZoomLevelList, Zoomable, ZoomableFrame): Removed.
+
+ * src/nautilus-view-frame-private.h
+ (impl_Nautilus_ZoomableFrame_vepv, impl_Nautilus_ZoomableFrame__create):
+ Removed external declarations.
+
+ * src/nautilus-view-frame.h: include <bonobo/bonobo-zoomable-frame.h>.
+ (NautilusViewFrame): Removed the `zoomable' field and changed the
+ type of the `zoomable_frame' field from BonoboObject into
+ BonoboZoomableFrame.
+
+ * src/nautilus-view-frame.c (nautilus_view_frame_destroy_client):
+ Don't release `view->zoomable' and set `view->history_frame' and
+ `view->zoomable_frame' to NULL, not to CORBA_OBJECT_NIL.
+ (zoom_level_changed_cb): New static callback function; this calls
+ nautilus_view_frame_zoom_level_changed().
+ (zoom_parameters_changed_cb): New static callback function; this
+ asks the Zoomable the new new zoom level and then passes it to
+ nautilus_view_frame_zoom_level_changed().
+ (nautilus_view_frame_load_client): Create the client_widget first,
+ then query_interface the client_object for "IDL:Bonobo/Zoomable:1.0";
+ if found, create a BonoboZoomableFrame, bind it to the zoomable and
+ connect the zoom_level_changed_cb() to the "zoom_level_changed" signal
+ on the BonoboZoomableFrame and the zoom_parameters_changed_cb() to the
+ "zoom_parameters_changed" signal.
+ (nautilus_view_frame_is_zoomable): Return `view->zoomable_frame != NULL'.
+ (nautilus_view_frame_get_zoom_level): Check whether view->zoomable_frame
+ is not NULL and call bonobo_zoomable_frame_get_zoom_level().
+ (nautilus_view_frame_set_zoom_level): Check whether view->zoomable_frame
+ is not NULL and call bonobo_zoomable_frame_set_zoom_level().
+ (nautilus_view_frame_get_min_zoom_level): Check whether view->zoomable_frame
+ is not NULL and call bonobo_zoomable_frame_get_min_zoom_level().
+ (nautilus_view_frame_get_max_zoom_level): Check whether view->zoomable_frame
+ is not NULL and call bonobo_zoomable_frame_get_max_zoom_level().
+ (nautilus_view_frame_get_preferred_zoom_levels): If view->zoomable_frame is
+ NULL, return NULL. Otherwise bonobo_zoomable_frame_get_preferred_zoom_levels()
+ returns a 0.0 terminated float array, so create a GList with its contents.
+ (nautilus_view_frame_zoom_in): If view->zoomable_frame is not NULL, call
+ bonobo_zoomable_frame_zoom_in().
+ (nautilus_view_frame_zoom_out): If view->zoomable_frame is not NULL, call
+ bonobo_zoomable_frame_zoom_out().
+ (nautilus_view_frame_zoom_to_fit): If view->zoomable_frame is not NULL, call
+ bonobo_zoomable_frame_zoom_out().
+
+ * src/file-manager/fm-directory-view.c: include <bonobo/bonobo-zoomable.h> instead
+ of <libnautilus/libnautilus-zoomable.h>.
+ (fm_directory_view_preferred_zoom_levels): Made this an array of float, not double.
+ (fm_directory_view_initialize): Create a new BonoboZoomable object here.
+ (zoomable_zoom_in_callback): The first argument is now a BonoboZoomable.
+ (zoomable_zoom_out_callback): The first argument is now a BonoboZoomable.
+ (nautilus_zoom_level_from_double): Renamed into nautilus_zoom_level_from_float().
+ (zoomable_set_zoom_level_callback): The first argument is now a BonoboZoomable and
+ the second one a float.
+ (zoomable_zoom_to_fit_callback): The first argument is now a BonoboZoomable.
+ (fm_directory_view_set_zoom_level): Call the `set_zoom_level' method on the
+ Bonobo::Zoomable CORBA object (instead of using nautilus_zoomable_set_zoom_level).
+
+ * components/image-viewer/image-viewer-control.c: Zooming support is not yet
+ implemented and was already #ifdef'ed out with the old NautilusZoomable so don't
+ even create a BonoboZoomable object to avoid that people wonder why there is a
+ zoom control, but zooming doesn't work. [NOTE: I'm currently working on a new
+ EOG image viewer component which will support zooming.]
+ (view_data_t): Changed type of the `zoomable' field into `BonoboZoomable'.
+ (view_factory_common): Use BonoboZoomable instead of NautilusZoomable.
+
2000-10-11 John Sullivan <sullivan eazel com>
Fixed bug 3603 ("Select All Files" initially insensitive)
Index: components/image-viewer/nautilus-image-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/image-viewer/nautilus-image-view.c,v
retrieving revision 1.4
diff -u -u -p -r1.4 nautilus-image-view.c
--- components/image-viewer/nautilus-image-view.c 2000/09/28 17:17:59 1.4
+++ components/image-viewer/nautilus-image-view.c 2000/10/12 00:36:03
@@ -34,7 +34,9 @@
#include <libart_lgpl/art_pixbuf.h>
#include <libart_lgpl/art_rgb_pixbuf_affine.h>
#include <libart_lgpl/art_alphagamma.h>
-#include <libnautilus/nautilus-zoomable.h>
+#if 0
+#include <bonobo/bonobo-zoomable.h>
+#endif
#include "io-png.h"
@@ -62,7 +64,9 @@ typedef struct {
GtkWidget *drawing_area;
GtkWidget *scrolled_window;
GdkPixbuf *scaled;
- NautilusZoomable *zoomable;
+#if 0
+ BonoboZoomable *zoomable;
+#endif
gboolean size_allocated;
} view_data_t;
@@ -498,8 +502,8 @@ scrolled_view_size_allocate_cb (GtkWidge
}
-static double zoom_levels[] = {
- (double) 100.0
+static float zoom_levels[] = {
+ (float) 1.0
};
static BonoboView *
@@ -534,9 +538,6 @@ view_factory_common (BonoboEmbeddable *b
gtk_widget_show_all (root);
view = bonobo_view_new (root);
- view_data->zoomable = nautilus_zoomable_new_from_bonobo_control (BONOBO_CONTROL (view),
- .25, 4.0, FALSE, zoom_levels, 1);
-
gtk_object_set_data (GTK_OBJECT (view), "view_data",
view_data);
@@ -544,19 +545,25 @@ view_factory_common (BonoboEmbeddable *b
GTK_SIGNAL_FUNC (destroy_view), view_data);
#if 0
- gtk_signal_connect (GTK_OBJECT (view),
+ view_data->zoomable = bonobo_zoomable_new ();
+ bonobo_zoomable_set_parameters (view_data->zoomable, .25, 4.0, TRUE, TRUE,
+ FALSE, zoom_levels, 1);
+ bonobo_object_add_interface (BONOBO_OBJECT (view),
+ BONOBO_OBJECT (view_data->zoomable));
+
+ gtk_signal_connect (GTK_OBJECT (view_data->zoomable),
"zoom_in",
zoomable_zoom_in_callback,
view_data);
- gtk_signal_connect (GTK_OBJECT (view),
+ gtk_signal_connect (GTK_OBJECT (view_data->zoomable),
"zoom_out",
zoomable_zoom_out_callback,
view_data);
- gtk_signal_connect (GTK_OBJECT (view),
+ gtk_signal_connect (GTK_OBJECT (view_data->zoomable),
"set_zoom_level",
zoomable_set_zoom_level_callback,
view_data);
- gtk_signal_connect (GTK_OBJECT (view),
+ gtk_signal_connect (GTK_OBJECT (view_data->zoomabel),
"zoom_to_fit",
zoomable_zoom_to_fit_callback,
view_data);
Index: libnautilus/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus/Makefile.am,v
retrieving revision 1.77
diff -u -u -p -r1.77 Makefile.am
--- libnautilus/Makefile.am 2000/09/27 00:07:31 1.77
+++ libnautilus/Makefile.am 2000/10/12 00:36:04
@@ -48,7 +48,6 @@ libnautilusinclude_HEADERS= \
nautilus-view.h \
nautilus-undo.h \
nautilus-undo-private.h \
- nautilus-zoomable.h \
$(NULL)
@@ -61,7 +60,6 @@ libnautilus_la_SOURCES= \
nautilus-undo-transaction.h \
nautilus-undo.c \
nautilus-view.c \
- nautilus-zoomable.c \
$(NULL)
$(nautilus_view_component_idl_sources): nautilus_view_component_idl_stamp
Index: libnautilus/nautilus-view-component.idl
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus/nautilus-view-component.idl,v
retrieving revision 1.30
diff -u -u -p -r1.30 nautilus-view-component.idl
--- libnautilus/nautilus-view-component.idl 2000/10/03 02:02:05 1.30
+++ libnautilus/nautilus-view-component.idl 2000/10/12 00:36:05
@@ -93,44 +93,6 @@ module Nautilus {
oneway void set_title (in string new_title);
};
- typedef float ZoomLevel;
- typedef sequence<ZoomLevel> ZoomLevelList;
-
- /* The interface for something zoomable. Nautilus looks for
- * this interface on Bonobo controls that it uses as views. If
- * the interface is present, it shows a widget in the toolbar
- * for zooming. It's still the component's job to save the
- * zoom level.
- */
- interface Zoomable : ::Bonobo::Unknown {
- /* Set this attribute to make the thing zoom. */
- attribute float zoom_level;
-
- /* Information about the type of zooming that's supported. */
- readonly attribute float min_zoom_level;
- readonly attribute float max_zoom_level;
- readonly attribute boolean is_continuous;
- readonly attribute ZoomLevelList preferred_zoom_levels;
-
- /* High level operations.
- * These can cause a change in the zoom level.
- * The zoomable itself must decide what the concepts
- * "one level in", "one level out", and "to fit" mean.
- */
- oneway void zoom_in ();
- oneway void zoom_out ();
- oneway void zoom_to_fit ();
- };
-
- /* A zoomable has the responsibility to look for this
- * interface on its Bonobo control frame and call
- * zoom_level_changed whenever it changes the zoom level (on
- * its own or due to calls from the zoomable interface).
- */
- interface ZoomableFrame : ::Bonobo::Unknown {
- oneway void report_zoom_level_changed (in float zoom_level);
- };
-
/* The specifications for a history list item. The structure
* contains the title of the item, and the location it's for.
*/
Index: po/Makefile.in.in
===================================================================
RCS file: /cvs/gnome/nautilus/po/Makefile.in.in,v
retrieving revision 1.2
diff -u -u -p -r1.2 Makefile.in.in
--- po/Makefile.in.in 2000/10/10 16:32:46 1.2
+++ po/Makefile.in.in 2000/10/12 00:36:05
@@ -62,7 +62,7 @@ INSTOBJEXT = @INSTOBJEXT@
$(COMPILE) $<
.po.pox:
- $(MAKE) $(PACKAGE).pot
+ $(MAKE) $(srcdir)/$(PACKAGE).pot
$(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
.po.mo:
@@ -79,7 +79,7 @@ INSTOBJEXT = @INSTOBJEXT@
all: all- USE_NLS@
-all-yes: cat-id-tbl.c $(CATALOGS)
+all-yes: $(srcdir)/cat-id-tbl.c $(CATALOGS)
all-no:
$(srcdir)/$(PACKAGE).pot: $(POTFILES)
@@ -90,8 +90,8 @@ $(srcdir)/$(PACKAGE).pot: $(POTFILES)
|| ( rm -f $(srcdir)/$(PACKAGE).pot \
&& mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot )
-$(srcdir)/cat-id-tbl.c: stamp-cat-id; @:
-$(srcdir)/stamp-cat-id: $(PACKAGE).pot
+$(srcdir)/cat-id-tbl.c: $(srcdir)/stamp-cat-id; @:
+$(srcdir)/stamp-cat-id: $(srcdir)/$(PACKAGE).pot
rm -f cat-id-tbl.tmp
sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
| sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
@@ -180,7 +180,8 @@ uninstall:
check: all
-cat-id-tbl.o: ../intl/libgettext.h
+cat-id-tbl.o: $(srcdir)/cat-id-tbl.c $(top_srcdir)/intl/libgettext.h
+ $(COMPILE) $(srcdir)/cat-id-tbl.c
dvi info tags TAGS ID:
@@ -196,7 +197,7 @@ distclean: clean
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
- rm -f $(GMOFILES)
+ rm -f $(GMOFILES) cat-id-tbl.c stamp-cat-id
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
dist distdir: update-po $(DISTFILES)
@@ -207,7 +208,7 @@ dist distdir: update-po $(DISTFILES)
done
update-po: Makefile
- $(MAKE) $(PACKAGE).pot
+ $(MAKE) $(srcdir)/$(PACKAGE).pot
PATH=`pwd`/../src:$$PATH; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/src/Makefile.am,v
retrieving revision 1.87
diff -u -u -p -r1.87 Makefile.am
--- src/Makefile.am 2000/10/09 22:06:12 1.87
+++ src/Makefile.am 2000/10/12 00:36:06
@@ -130,7 +130,6 @@ nautilus_SOURCES = \
nautilus-window-toolbars.c \
nautilus-window.c \
nautilus-zoom-control.c \
- nautilus-zoomable-frame-corba.c \
$(profiler_sources) \
$(NULL)
Index: src/nautilus-view-frame-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame-private.h,v
retrieving revision 1.25
diff -u -u -p -r1.25 nautilus-view-frame-private.h
--- src/nautilus-view-frame-private.h 2000/09/29 21:34:04 1.25
+++ src/nautilus-view-frame-private.h 2000/10/12 00:36:06
@@ -39,11 +39,8 @@ typedef struct {
} impl_POA_Nautilus_ViewFrame;
extern POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv;
-extern POA_Nautilus_ZoomableFrame__vepv impl_Nautilus_ZoomableFrame_vepv;
BonoboObject *impl_Nautilus_ViewFrame__create (NautilusViewFrame *view,
- CORBA_Environment *ev);
-BonoboObject *impl_Nautilus_ZoomableFrame__create (NautilusViewFrame *view,
CORBA_Environment *ev);
/* ViewFrame */
Index: src/nautilus-view-frame.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame.c,v
retrieving revision 1.99
diff -u -u -p -r1.99 nautilus-view-frame.c
--- src/nautilus-view-frame.c 2000/10/05 23:47:50 1.99
+++ src/nautilus-view-frame.c 2000/10/12 00:36:06
@@ -41,7 +41,8 @@
#include <gtk/gtk.h>
#include <libnautilus-extensions/nautilus-undo-manager.h>
#include <libnautilus/nautilus-view.h>
-#include <libnautilus/nautilus-zoomable.h>
+#include <bonobo/bonobo-zoomable-frame.h>
+#include <bonobo/bonobo-zoomable.h>
@@ -228,17 +229,12 @@ nautilus_view_frame_destroy_client (Naut
gtk_container_remove (GTK_CONTAINER (view), view->client_widget);
view->client_widget = NULL;
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- bonobo_object_release_unref (view->zoomable, &ev);
- }
- view->zoomable = CORBA_OBJECT_NIL;
-
bonobo_object_unref (view->view_frame);
view->view_frame = NULL;
/* we can NULL those since we just unref'ed them
with the aggregate view frame. */
- view->history_frame = CORBA_OBJECT_NIL;
- view->zoomable_frame = CORBA_OBJECT_NIL;
+ view->history_frame = NULL;
+ view->zoomable_frame = NULL;
CORBA_exception_free (&ev);
@@ -451,6 +447,31 @@ check_if_view_is_gone (gpointer data)
return ok;
}
+static void
+zoom_level_changed_cb (BonoboZoomableFrame *zframe, float zoom_level, NautilusViewFrame *view)
+{
+ g_return_if_fail (zframe != NULL);
+ g_return_if_fail (BONOBO_IS_ZOOMABLE_FRAME (zframe));
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
+
+ nautilus_view_frame_zoom_level_changed (view, (float) zoom_level);
+}
+
+static void
+zoom_parameters_changed_cb (BonoboZoomableFrame *zframe, NautilusViewFrame *view)
+{
+ float zoom_level;
+
+ g_return_if_fail (zframe != NULL);
+ g_return_if_fail (BONOBO_IS_ZOOMABLE_FRAME (zframe));
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
+
+ zoom_level = bonobo_zoomable_frame_get_zoom_level (zframe);
+ nautilus_view_frame_zoom_level_changed (view, (float) zoom_level);
+}
+
gboolean /* returns TRUE if successful */
nautilus_view_frame_load_client (NautilusViewFrame *view, const char *iid)
{
@@ -459,6 +480,7 @@ nautilus_view_frame_load_client (Nautilu
BonoboObjectClient *component;
Bonobo_Control control;
BonoboControlFrame *control_frame;
+ Bonobo_Zoomable zoomable;
g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE);
g_return_val_if_fail (view->details->state == VIEW_FRAME_EMPTY, FALSE);
@@ -500,9 +522,6 @@ nautilus_view_frame_load_client (Nautilu
(BONOBO_OBJECT (view->client_object),
"IDL:Bonobo/Control:1.0");
g_assert (control != CORBA_OBJECT_NIL);
- view->zoomable = bonobo_object_query_interface
- (BONOBO_OBJECT (view->client_object),
- "IDL:Nautilus/Zoomable:1.0");
/* Start with a view frame interface. */
view->view_frame = impl_Nautilus_ViewFrame__create (view, &ev);
@@ -515,9 +534,20 @@ nautilus_view_frame_load_client (Nautilu
view->client_widget = bonobo_control_frame_get_widget (control_frame);
/* Add a zoomable frame interface. */
- view->zoomable_frame = impl_Nautilus_ZoomableFrame__create (view, &ev);
- bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame),
- BONOBO_OBJECT (view->zoomable_frame));
+ zoomable = bonobo_object_query_interface
+ (BONOBO_OBJECT (view->client_object),
+ "IDL:Bonobo/Zoomable:1.0");
+ if (zoomable != CORBA_OBJECT_NIL) {
+ view->zoomable_frame = bonobo_zoomable_frame_new ();
+ bonobo_zoomable_frame_bind_to_zoomable (view->zoomable_frame, zoomable);
+ bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame),
+ BONOBO_OBJECT (view->zoomable_frame));
+
+ gtk_signal_connect (GTK_OBJECT (view->zoomable_frame), "zoom_level_changed",
+ GTK_SIGNAL_FUNC (zoom_level_changed_cb), view);
+ gtk_signal_connect (GTK_OBJECT (view->zoomable_frame), "zoom_parameters_changed",
+ GTK_SIGNAL_FUNC (zoom_parameters_changed_cb), view);
+ }
/* Add a history frame interface. */
view->history_frame = impl_Nautilus_HistoryFrame__create (view, &ev);
@@ -652,177 +682,118 @@ nautilus_view_frame_title_changed (Nauti
gboolean
nautilus_view_frame_is_zoomable (NautilusViewFrame *view)
{
- CORBA_Environment ev;
gboolean is_zoomable;
- g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE);
+ is_zoomable = view->zoomable_frame != NULL;
- CORBA_exception_init (&ev);
- is_zoomable = !CORBA_Object_is_nil (view->zoomable, &ev);
- CORBA_exception_free (&ev);
-
return is_zoomable;
}
gdouble
nautilus_view_frame_get_zoom_level (NautilusViewFrame *view)
{
- CORBA_Environment ev;
- double level;
-
- g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0);
-
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- level = Nautilus_Zoomable__get_zoom_level (view->zoomable, &ev);
- } else {
- level = 1.0;
- }
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0);
- CORBA_exception_free (&ev);
-
- return level;
+ if (view->zoomable_frame == NULL)
+ return 0.0;
+
+ return (gdouble) bonobo_zoomable_frame_get_zoom_level (view->zoomable_frame);
}
void
nautilus_view_frame_set_zoom_level (NautilusViewFrame *view,
double zoom_level)
{
- CORBA_Environment ev;
-
g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
-
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- Nautilus_Zoomable__set_zoom_level (view->zoomable, zoom_level, &ev);
- } else {
- /* do nothing */
- }
-
- CORBA_exception_free (&ev);
+
+ if (view->zoomable_frame == NULL)
+ return;
+
+ bonobo_zoomable_frame_set_zoom_level (view->zoomable_frame, (float) zoom_level);
}
gdouble
nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view)
{
- CORBA_Environment ev;
- double level;
-
- g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0);
-
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- level = Nautilus_Zoomable__get_min_zoom_level (view->zoomable, &ev);
- } else {
- level = 1.0;
- }
-
- CORBA_exception_free (&ev);
-
- return level;
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0);
+
+ if (view->zoomable_frame == NULL)
+ return 0.0;
+
+ return (gdouble) bonobo_zoomable_frame_get_min_zoom_level (view->zoomable_frame);
}
double
nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view)
{
- CORBA_Environment ev;
- double level;
-
- g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0);
-
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- level = Nautilus_Zoomable__get_max_zoom_level (view->zoomable, &ev);
- } else {
- level = 1.0;
- }
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0);
- CORBA_exception_free (&ev);
-
- return level;
+ if (view->zoomable_frame == NULL)
+ return;
+
+ return (gdouble) bonobo_zoomable_frame_get_max_zoom_level (view->zoomable_frame);
}
GList *
nautilus_view_frame_get_preferred_zoom_levels (NautilusViewFrame *view)
{
- CORBA_Environment ev;
- GList *levels;
- Nautilus_ZoomLevelList *zoom_levels;
-
- g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0);
+ GList *list = NULL;
+ float *levels;
+ int i, num = 0;
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- zoom_levels = Nautilus_Zoomable__get_preferred_zoom_levels (view->zoomable, &ev);
- levels = nautilus_g_list_from_ZoomLevelList (zoom_levels);
- CORBA_free (zoom_levels);
-
- } else {
- levels = NULL;
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL);
+
+ if (view->zoomable_frame == NULL)
+ return NULL;
+
+ levels = bonobo_zoomable_frame_get_preferred_zoom_levels (view->zoomable_frame, &num);
+
+ if (!levels)
+ return NULL;
+
+ for (i = 0; i < num; ++i) {
+ double *zoom_level_ptr = g_new (double, 1);
+
+ *zoom_level_ptr = (double) levels[i];
+ list = g_list_prepend (list, zoom_level_ptr);
}
-
- CORBA_exception_free (&ev);
-
- return levels;
+
+ g_free (levels);
+
+ return g_list_reverse (list);
}
void
nautilus_view_frame_zoom_in (NautilusViewFrame *view)
{
- CORBA_Environment ev;
-
g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
-
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- Nautilus_Zoomable_zoom_in (view->zoomable, &ev);
- } else {
- /* do nothing */
- }
-
- CORBA_exception_free (&ev);
+
+ if (view->zoomable_frame == NULL)
+ return;
+
+ bonobo_zoomable_frame_zoom_in (view->zoomable_frame);
}
void
nautilus_view_frame_zoom_out (NautilusViewFrame *view)
{
- CORBA_Environment ev;
-
g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- Nautilus_Zoomable_zoom_out (view->zoomable, &ev);
- } else {
- /* do nothing */
- }
-
- CORBA_exception_free (&ev);
+ if (view->zoomable_frame == NULL)
+ return;
+
+ bonobo_zoomable_frame_zoom_out (view->zoomable_frame);
}
void
nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view)
{
- CORBA_Environment ev;
-
g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
- CORBA_exception_init (&ev);
-
- if (!CORBA_Object_is_nil (view->zoomable, &ev)) {
- Nautilus_Zoomable_zoom_to_fit (view->zoomable, &ev);
- } else {
- /* do nothing */
- }
-
- CORBA_exception_free (&ev);
+ if (view->zoomable_frame == NULL)
+ return;
+
+ bonobo_zoomable_frame_zoom_to_fit (view->zoomable_frame);
}
const char *
Index: src/nautilus-view-frame.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame.h,v
retrieving revision 1.52
diff -u -u -p -r1.52 nautilus-view-frame.h
--- src/nautilus-view-frame.h 2000/10/05 23:47:50 1.52
+++ src/nautilus-view-frame.h 2000/10/12 00:36:07
@@ -34,6 +34,7 @@
#include <bonobo/bonobo-object-client.h>
#include <bonobo/bonobo-ui-container.h>
+#include <bonobo/bonobo-zoomable-frame.h>
#include <libnautilus-extensions/nautilus-generous-bin.h>
#include <libnautilus-extensions/nautilus-undo-manager.h>
#include <libnautilus/nautilus-view-component.h>
@@ -56,12 +57,11 @@ typedef struct {
/* The frame itself (from various interface points of view). */
BonoboObject *view_frame;
- BonoboObject *zoomable_frame;
+ BonoboZoomableFrame *zoomable_frame;
BonoboObject *history_frame;
/* The view inside the (various interfaces). */
BonoboObjectClient *client_object;
- Nautilus_Zoomable zoomable;
GtkWidget *client_widget;
} NautilusViewFrame;
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.296
diff -u -u -p -r1.296 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 2000/10/11 20:19:54 1.296
+++ src/file-manager/fm-directory-view.c 2000/10/12 00:36:10
@@ -32,6 +32,7 @@
#include "fm-properties-window.h"
#include "nautilus-trash-monitor.h"
#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-zoomable.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
@@ -67,7 +68,6 @@
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-view-identifier.h>
#include <libnautilus/nautilus-bonobo-ui.h>
-#include <libnautilus/nautilus-zoomable.h>
#include <math.h>
#include <src/nautilus-application.h>
@@ -110,7 +110,7 @@ static guint signals[LAST_SIGNAL];
struct FMDirectoryViewDetails
{
NautilusView *nautilus_view;
- NautilusZoomable *zoomable;
+ BonoboZoomable *zoomable;
NautilusDirectory *model;
BonoboUIComponent *ui;
@@ -187,14 +187,14 @@ static void open_one_in_new_wi
gpointer callback_data);
static void open_one_properties_window (gpointer data,
gpointer callback_data);
-static void zoomable_set_zoom_level_callback (NautilusZoomable *zoomable,
- double level,
+static void zoomable_set_zoom_level_callback (BonoboZoomable *zoomable,
+ float level,
FMDirectoryView *view);
-static void zoomable_zoom_in_callback (NautilusZoomable *zoomable,
+static void zoomable_zoom_in_callback (BonoboZoomable *zoomable,
FMDirectoryView *directory_view);
-static void zoomable_zoom_out_callback (NautilusZoomable *zoomable,
+static void zoomable_zoom_out_callback (BonoboZoomable *zoomable,
FMDirectoryView *directory_view);
-static void zoomable_zoom_to_fit_callback (NautilusZoomable *zoomable,
+static void zoomable_zoom_to_fit_callback (BonoboZoomable *zoomable,
FMDirectoryView *directory_view);
static void schedule_update_menus (FMDirectoryView *view);
static void schedule_update_menus_callback (gpointer callback_data);
@@ -930,14 +930,14 @@ smooth_graphics_mode_changed_callback (g
smooth_graphics_mode_changed, (view));
}
-static double fm_directory_view_preferred_zoom_levels[] = {
- (double) NAUTILUS_ICON_SIZE_SMALLEST / NAUTILUS_ICON_SIZE_STANDARD,
- (double) NAUTILUS_ICON_SIZE_SMALLER / NAUTILUS_ICON_SIZE_STANDARD,
- (double) NAUTILUS_ICON_SIZE_SMALL / NAUTILUS_ICON_SIZE_STANDARD,
- (double) NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_STANDARD,
- (double) NAUTILUS_ICON_SIZE_LARGE / NAUTILUS_ICON_SIZE_STANDARD,
- (double) NAUTILUS_ICON_SIZE_LARGER / NAUTILUS_ICON_SIZE_STANDARD,
- (double) NAUTILUS_ICON_SIZE_LARGEST / NAUTILUS_ICON_SIZE_STANDARD,
+static float fm_directory_view_preferred_zoom_levels[] = {
+ (float) NAUTILUS_ICON_SIZE_SMALLEST / NAUTILUS_ICON_SIZE_STANDARD,
+ (float) NAUTILUS_ICON_SIZE_SMALLER / NAUTILUS_ICON_SIZE_STANDARD,
+ (float) NAUTILUS_ICON_SIZE_SMALL / NAUTILUS_ICON_SIZE_STANDARD,
+ (float) NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_STANDARD,
+ (float) NAUTILUS_ICON_SIZE_LARGE / NAUTILUS_ICON_SIZE_STANDARD,
+ (float) NAUTILUS_ICON_SIZE_LARGER / NAUTILUS_ICON_SIZE_STANDARD,
+ (float) NAUTILUS_ICON_SIZE_LARGEST / NAUTILUS_ICON_SIZE_STANDARD,
};
static void
@@ -953,11 +953,9 @@ fm_directory_view_initialize (FMDirector
directory_view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (directory_view));
- directory_view->details->zoomable = nautilus_zoomable_new_from_bonobo_control
- (get_bonobo_control (directory_view),
- .25,
- 4.0,
- FALSE,
+ directory_view->details->zoomable = bonobo_zoomable_new ();
+ bonobo_zoomable_set_parameters (directory_view->details->zoomable,
+ .25, 4.0, TRUE, TRUE, FALSE,
fm_directory_view_preferred_zoom_levels,
NAUTILUS_N_ELEMENTS (fm_directory_view_preferred_zoom_levels));
@@ -981,19 +979,19 @@ fm_directory_view_initialize (FMDirector
gtk_signal_connect (GTK_OBJECT (directory_view->details->zoomable),
"zoom_in",
- zoomable_zoom_in_callback,
+ GTK_SIGNAL_FUNC (zoomable_zoom_in_callback),
directory_view);
gtk_signal_connect (GTK_OBJECT (directory_view->details->zoomable),
"zoom_out",
- zoomable_zoom_out_callback,
+ GTK_SIGNAL_FUNC (zoomable_zoom_out_callback),
directory_view);
gtk_signal_connect (GTK_OBJECT (directory_view->details->zoomable),
"set_zoom_level",
- zoomable_set_zoom_level_callback,
+ GTK_SIGNAL_FUNC (zoomable_set_zoom_level_callback),
directory_view);
gtk_signal_connect (GTK_OBJECT (directory_view->details->zoomable),
"zoom_to_fit",
- zoomable_zoom_to_fit_callback,
+ GTK_SIGNAL_FUNC (zoomable_zoom_to_fit_callback),
directory_view);
gtk_signal_connect_while_alive (GTK_OBJECT (nautilus_trash_monitor_get ()),
"trash_state_changed",
@@ -1405,19 +1403,19 @@ zoom_default_callback (GtkMenuItem *item
static void
-zoomable_zoom_in_callback (NautilusZoomable *zoomable, FMDirectoryView *directory_view)
+zoomable_zoom_in_callback (BonoboZoomable *zoomable, FMDirectoryView *directory_view)
{
fm_directory_view_bump_zoom_level (directory_view, 1);
}
static void
-zoomable_zoom_out_callback (NautilusZoomable *zoomable, FMDirectoryView *directory_view)
+zoomable_zoom_out_callback (BonoboZoomable *zoomable, FMDirectoryView *directory_view)
{
fm_directory_view_bump_zoom_level (directory_view, -1);
}
static NautilusZoomLevel
-nautilus_zoom_level_from_double(double zoom_level)
+nautilus_zoom_level_from_float(float zoom_level)
{
int icon_size = floor(zoom_level * NAUTILUS_ICON_SIZE_STANDARD + 0.5);
@@ -1439,13 +1437,13 @@ nautilus_zoom_level_from_double(double z
}
static void
-zoomable_set_zoom_level_callback (NautilusZoomable *zoomable, double level, FMDirectoryView *view)
+zoomable_set_zoom_level_callback (BonoboZoomable *zoomable, float level, FMDirectoryView *view)
{
- fm_directory_view_zoom_to_level (view, nautilus_zoom_level_from_double(level));
+ fm_directory_view_zoom_to_level (view, nautilus_zoom_level_from_float(level));
}
static void
-zoomable_zoom_to_fit_callback (NautilusZoomable *zoomable, FMDirectoryView *view)
+zoomable_zoom_to_fit_callback (BonoboZoomable *zoomable, FMDirectoryView *view)
{
/* FIXME bugzilla.eazel.com 2388:
* Need to really implement "zoom to fit"
@@ -1846,16 +1844,24 @@ fm_directory_view_zoom_to_level (FMDirec
void
fm_directory_view_set_zoom_level (FMDirectoryView *view, int zoom_level)
{
+ CORBA_Environment ev;
+ Bonobo_Zoomable zoomable;
+ float new_zoom_level;
+
g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
if (!fm_directory_view_supports_zooming (view)) {
return;
}
+
+ new_zoom_level = (float) nautilus_get_icon_size_for_zoom_level (zoom_level)
+ / NAUTILUS_ICON_SIZE_STANDARD;
- nautilus_zoomable_set_zoom_level
- (view->details->zoomable,
- (double) nautilus_get_icon_size_for_zoom_level (zoom_level)
- / NAUTILUS_ICON_SIZE_STANDARD);
+ CORBA_exception_init (&ev);
+ zoomable = bonobo_object_corba_objref (BONOBO_OBJECT (view->details->zoomable));
+ Bonobo_Zoomable_set_zoom_level (zoomable, new_zoom_level, &ev);
+ bonobo_object_check_env (BONOBO_OBJECT (view->details->zoomable), zoomable, &ev);
+ CORBA_exception_free (&ev);
}
/**
I hope I have done everything correct and it all conforms with
the Nautilus coding style; if not, just let me know and I'll reformat it.
--
Martin Baulig
martin gnome org (private)
baulig suse de (work)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]