diff options
author | Elliot Lee <sopwith@src.gnome.org> | 1999-12-06 23:23:41 +0000 |
---|---|---|
committer | Elliot Lee <sopwith@src.gnome.org> | 1999-12-06 23:23:41 +0000 |
commit | 1d23907d45a168e45dc65b89b36f30bb094c37ff (patch) | |
tree | 7effb91babbc4edb5c0bc244ce63738a13709131 | |
parent | 44302b3c22f7b27bce0d7d9ca1c8189f14526195 (diff) | |
download | nautilus-1d23907d45a168e45dc65b89b36f30bb094c37ff.tar.gz |
Implement libnautilus.
Implement libnautilus.
Normalize the way requests and notifications are passed around.
43 files changed, 3565 insertions, 190 deletions
diff --git a/Makefile.am b/Makefile.am index 1bfdcf486..453603913 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1 @@ -SUBDIRS=src +SUBDIRS=libnautilus src diff --git a/configure.in b/configure.in index e87209e27..722e3c154 100644 --- a/configure.in +++ b/configure.in @@ -40,5 +40,6 @@ AC_C_CONST AC_OUTPUT([ Makefile +libnautilus/Makefile src/Makefile ]) diff --git a/docs/design.txt b/docs/design.txt new file mode 100644 index 000000000..8236d0618 --- /dev/null +++ b/docs/design.txt @@ -0,0 +1,2 @@ +Factors that influence how a URL will be displayed: + In a new window or not
\ No newline at end of file diff --git a/idl/nautilus.idl b/idl/nautilus.idl new file mode 100644 index 000000000..5e4093081 --- /dev/null +++ b/idl/nautilus.idl @@ -0,0 +1,37 @@ +#include <gnome-unknown.idl> + +module Nautilus { + enum TruthValue { V_UNKNOWN, V_FALSE, V_TRUE }; + struct NavigationRequestInfo { + string requested_uri; + TruthValue new_window_default, new_window_suggested, new_window_enforced; + }; + + struct NavigationInfo { + string requested_uri, actual_uri, content_type; + string referring_uri, actual_referring_uri, referring_content_type; + }; + + struct SelectionInfo { + string selected_uri; + }; + + struct SelectionRequestInfo { + string selected_uri; + }; + + interface View : ::GNOME::Unknown { + void save_state(in string config_path); + void load_state(in string config_path); + oneway void notify_location_change(in NavigationInfo navinfo); + + oneway void show_properties(); // Requests that the client show its properties + + oneway void notify_selection_change(in SelectionInfo selinfo); + }; + + interface ViewFrame : ::GNOME::Unknown { + oneway void request_location_change(in NavigationRequestInfo navinfo); + oneway void request_selection_change(in SelectionRequestInfo selinfo); + }; +}; diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am new file mode 100644 index 000000000..d4982486d --- /dev/null +++ b/libnautilus-extensions/Makefile.am @@ -0,0 +1,22 @@ +lib_LTLIBRARIES=libnautilus.la + +INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOME_CFLAGS) $(GNORBA_CFLAGS) + +nautilus_idl_sources=nautilus-stubs.c nautilus-skels.c nautilus.h nautilus-common.c +BUILT_SOURCES=$(nautilus_idl_sources) + +libnautilusincludedir=$(includedir)/libnautilus +libnautilusinclude_HEADERS= \ + ntl-view-client.h \ + nautilus.h + +libnautilus_la_SOURCES=$(nautilus_idl_sources) \ + ntl-view-client.c + +$(nautilus_idl_sources): nautilus_idl_stamp + +nautilus_idl_stamp: $(top_srcdir)/idl/nautilus.idl + orbit-idl `gnome-config --cflags idl` $(top_srcdir)/idl/nautilus.idl + touch nautilus_idl_stamp + +CLEANFILES=nautilus_idl_stamp diff --git a/libnautilus-extensions/libnautilus.h b/libnautilus-extensions/libnautilus.h new file mode 100644 index 000000000..7ba1078ca --- /dev/null +++ b/libnautilus-extensions/libnautilus.h @@ -0,0 +1,8 @@ +#ifndef LIBNAUTILUS_H +#define LIBNAUTILUS_H 1 + +#include <bonobo/gnome-bonobo.h> +#include <libnautilus/nautilus.h> +#include <libnautilus/ntl-view-client.h> + +#endif diff --git a/libnautilus-extensions/ntl-view-client.c b/libnautilus-extensions/ntl-view-client.c new file mode 100644 index 000000000..f6397ef53 --- /dev/null +++ b/libnautilus-extensions/ntl-view-client.c @@ -0,0 +1,383 @@ +/* ntl-view-client.c + * Copyright (C) 1999 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. + */ + +#include <gtk/gtk.h> +#include "libnautilus.h" + +typedef struct { + POA_Nautilus_View servant; + gpointer gnome_object; + + NautilusViewClient *view; +} impl_POA_Nautilus_View; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_View__epv impl_Nautilus_View_epv = +{ + NULL, /* _private */ + (gpointer) & impl_Nautilus_View_save_state, + (gpointer) & impl_Nautilus_View_load_state, + (gpointer) & impl_Nautilus_View_notify_location_change, + (gpointer) & impl_Nautilus_View_show_properties, + (gpointer) & impl_Nautilus_View_notify_selection_change +}; + +static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_View_epv +}; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path); +} + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path); +} + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo); +} + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties"); +} + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo); +} + + +static void +impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_View__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_View *newservant; + + newservant = g_new0(impl_POA_Nautilus_View, 1); + newservant->servant.vepv = &impl_Nautilus_View_vepv; + newservant->view = view; + POA_Nautilus_View__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant); + + return retval; +} + +static void nautilus_view_client_init (NautilusViewClient *view); +static void nautilus_view_client_destroy (NautilusViewClient *view); +static void nautilus_view_client_class_init (NautilusViewClientClass *klass); +static void nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +GtkType +nautilus_view_client_get_type (void) +{ + static GtkType view_client_type = 0; + + if (!view_client_type) { + const GtkTypeInfo view_client_info = { + "NautilusViewClient", + sizeof (NautilusViewClient), + sizeof (NautilusViewClientClass), + (GtkClassInitFunc) nautilus_view_client_class_init, + (GtkObjectInitFunc) nautilus_view_client_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info); + } + + return view_client_type; +} + +#if 0 +typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, + gpointer arg1, + GtkObject *arg2, + gpointer arg3, + gpointer user_data); +static void +gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, + GtkArg * args) +{ + GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func; + (*rfunc) (object, + GTK_VALUE_BOXED (args[0]), + GTK_VALUE_OBJECT (args[1]), + GTK_VALUE_BOXED (args[2]), + func_data); +} +#endif + +static void +nautilus_view_client_class_init (NautilusViewClientClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + int i; + + object_class = (GtkObjectClass*) klass; + object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy; + object_class->set_arg = nautilus_view_client_set_arg; + object_class->get_arg = nautilus_view_client_get_arg; + + widget_class = (GtkWidgetClass*) klass; + widget_class->size_request = nautilus_view_client_size_request; + widget_class->size_allocate = nautilus_view_client_size_allocate; + + klass->notify_location_change = NULL; + + klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); + + i = 0; + klass->view_client_signals[i++] = gtk_signal_new("notify_location_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + klass->view_client_signals[i++] = gtk_signal_new("load_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("save_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("show_properties", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + gtk_object_class_add_signals (object_class, klass->view_client_signals, i); +} + +static void +nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_init (NautilusViewClient *view) +{ + CORBA_Environment ev; + GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view))); + + CORBA_exception_init(&ev); + view->view_client = impl_Nautilus_View__create(view, &ev); + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_destroy (NautilusViewClient *view) +{ + gtk_object_destroy(GTK_OBJECT(view->view_client)); +} + +void +nautilus_view_client_request_location_change(NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +void +nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin; + + bin = GTK_BIN (widget); + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; + } +} + +static void +nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkBin *bin; + GtkAllocation child_allocation; + + widget->allocation = child_allocation = *allocation; + bin = GTK_BIN (widget); + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &child_allocation); +} diff --git a/libnautilus-extensions/ntl-view-client.h b/libnautilus-extensions/ntl-view-client.h new file mode 100644 index 000000000..47928df34 --- /dev/null +++ b/libnautilus-extensions/ntl-view-client.h @@ -0,0 +1,55 @@ +#ifndef NTL_VIEW_CLIENT_H +#define NTL_VIEW_CLIENT_H + +#include <gtk/gtkobject.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define NAUTILUS_TYPE_VIEW_CLIENT (nautilus_view_client_get_type ()) +#define NAUTILUS_VIEW_CLIENT(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClient)) +#define NAUTILUS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClientClass)) +#define NAUTILUS_IS_VIEW_CLIENT(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) +#define NAUTILUS_IS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) + +typedef struct _NautilusViewClient NautilusViewClient; +typedef struct _NautilusViewClientClass NautilusViewClientClass; + +struct _NautilusViewClientClass +{ + GtkBinClass parent_spot; + + void (*notify_location_change) (NautilusViewClient *view, + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusViewClient *view, + Nautilus_SelectionInfo *nav_context); + void (*load_state) (NautilusViewClient *view, const char *config_path); + void (*save_state) (NautilusViewClient *view, const char *config_path); + void (*show_properties) (NautilusViewClient *view); + + GtkBinClass *parent_class; + guint view_client_signals[5]; +}; + +struct _NautilusViewClient +{ + GtkBin parent; + + GtkWidget *main_window; + + GnomeObject *control, *view_client; + Nautilus_ViewFrame view_frame; +}; + +GtkType nautilus_view_client_get_type (void); +void nautilus_view_client_request_location_change (NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am new file mode 100644 index 000000000..d4982486d --- /dev/null +++ b/libnautilus-private/Makefile.am @@ -0,0 +1,22 @@ +lib_LTLIBRARIES=libnautilus.la + +INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOME_CFLAGS) $(GNORBA_CFLAGS) + +nautilus_idl_sources=nautilus-stubs.c nautilus-skels.c nautilus.h nautilus-common.c +BUILT_SOURCES=$(nautilus_idl_sources) + +libnautilusincludedir=$(includedir)/libnautilus +libnautilusinclude_HEADERS= \ + ntl-view-client.h \ + nautilus.h + +libnautilus_la_SOURCES=$(nautilus_idl_sources) \ + ntl-view-client.c + +$(nautilus_idl_sources): nautilus_idl_stamp + +nautilus_idl_stamp: $(top_srcdir)/idl/nautilus.idl + orbit-idl `gnome-config --cflags idl` $(top_srcdir)/idl/nautilus.idl + touch nautilus_idl_stamp + +CLEANFILES=nautilus_idl_stamp diff --git a/libnautilus-private/libnautilus.h b/libnautilus-private/libnautilus.h new file mode 100644 index 000000000..7ba1078ca --- /dev/null +++ b/libnautilus-private/libnautilus.h @@ -0,0 +1,8 @@ +#ifndef LIBNAUTILUS_H +#define LIBNAUTILUS_H 1 + +#include <bonobo/gnome-bonobo.h> +#include <libnautilus/nautilus.h> +#include <libnautilus/ntl-view-client.h> + +#endif diff --git a/libnautilus-private/ntl-view-client.c b/libnautilus-private/ntl-view-client.c new file mode 100644 index 000000000..f6397ef53 --- /dev/null +++ b/libnautilus-private/ntl-view-client.c @@ -0,0 +1,383 @@ +/* ntl-view-client.c + * Copyright (C) 1999 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. + */ + +#include <gtk/gtk.h> +#include "libnautilus.h" + +typedef struct { + POA_Nautilus_View servant; + gpointer gnome_object; + + NautilusViewClient *view; +} impl_POA_Nautilus_View; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_View__epv impl_Nautilus_View_epv = +{ + NULL, /* _private */ + (gpointer) & impl_Nautilus_View_save_state, + (gpointer) & impl_Nautilus_View_load_state, + (gpointer) & impl_Nautilus_View_notify_location_change, + (gpointer) & impl_Nautilus_View_show_properties, + (gpointer) & impl_Nautilus_View_notify_selection_change +}; + +static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_View_epv +}; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path); +} + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path); +} + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo); +} + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties"); +} + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo); +} + + +static void +impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_View__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_View *newservant; + + newservant = g_new0(impl_POA_Nautilus_View, 1); + newservant->servant.vepv = &impl_Nautilus_View_vepv; + newservant->view = view; + POA_Nautilus_View__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant); + + return retval; +} + +static void nautilus_view_client_init (NautilusViewClient *view); +static void nautilus_view_client_destroy (NautilusViewClient *view); +static void nautilus_view_client_class_init (NautilusViewClientClass *klass); +static void nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +GtkType +nautilus_view_client_get_type (void) +{ + static GtkType view_client_type = 0; + + if (!view_client_type) { + const GtkTypeInfo view_client_info = { + "NautilusViewClient", + sizeof (NautilusViewClient), + sizeof (NautilusViewClientClass), + (GtkClassInitFunc) nautilus_view_client_class_init, + (GtkObjectInitFunc) nautilus_view_client_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info); + } + + return view_client_type; +} + +#if 0 +typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, + gpointer arg1, + GtkObject *arg2, + gpointer arg3, + gpointer user_data); +static void +gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, + GtkArg * args) +{ + GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func; + (*rfunc) (object, + GTK_VALUE_BOXED (args[0]), + GTK_VALUE_OBJECT (args[1]), + GTK_VALUE_BOXED (args[2]), + func_data); +} +#endif + +static void +nautilus_view_client_class_init (NautilusViewClientClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + int i; + + object_class = (GtkObjectClass*) klass; + object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy; + object_class->set_arg = nautilus_view_client_set_arg; + object_class->get_arg = nautilus_view_client_get_arg; + + widget_class = (GtkWidgetClass*) klass; + widget_class->size_request = nautilus_view_client_size_request; + widget_class->size_allocate = nautilus_view_client_size_allocate; + + klass->notify_location_change = NULL; + + klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); + + i = 0; + klass->view_client_signals[i++] = gtk_signal_new("notify_location_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + klass->view_client_signals[i++] = gtk_signal_new("load_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("save_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("show_properties", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + gtk_object_class_add_signals (object_class, klass->view_client_signals, i); +} + +static void +nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_init (NautilusViewClient *view) +{ + CORBA_Environment ev; + GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view))); + + CORBA_exception_init(&ev); + view->view_client = impl_Nautilus_View__create(view, &ev); + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_destroy (NautilusViewClient *view) +{ + gtk_object_destroy(GTK_OBJECT(view->view_client)); +} + +void +nautilus_view_client_request_location_change(NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +void +nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin; + + bin = GTK_BIN (widget); + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; + } +} + +static void +nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkBin *bin; + GtkAllocation child_allocation; + + widget->allocation = child_allocation = *allocation; + bin = GTK_BIN (widget); + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &child_allocation); +} diff --git a/libnautilus-private/ntl-view-client.h b/libnautilus-private/ntl-view-client.h new file mode 100644 index 000000000..47928df34 --- /dev/null +++ b/libnautilus-private/ntl-view-client.h @@ -0,0 +1,55 @@ +#ifndef NTL_VIEW_CLIENT_H +#define NTL_VIEW_CLIENT_H + +#include <gtk/gtkobject.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define NAUTILUS_TYPE_VIEW_CLIENT (nautilus_view_client_get_type ()) +#define NAUTILUS_VIEW_CLIENT(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClient)) +#define NAUTILUS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClientClass)) +#define NAUTILUS_IS_VIEW_CLIENT(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) +#define NAUTILUS_IS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) + +typedef struct _NautilusViewClient NautilusViewClient; +typedef struct _NautilusViewClientClass NautilusViewClientClass; + +struct _NautilusViewClientClass +{ + GtkBinClass parent_spot; + + void (*notify_location_change) (NautilusViewClient *view, + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusViewClient *view, + Nautilus_SelectionInfo *nav_context); + void (*load_state) (NautilusViewClient *view, const char *config_path); + void (*save_state) (NautilusViewClient *view, const char *config_path); + void (*show_properties) (NautilusViewClient *view); + + GtkBinClass *parent_class; + guint view_client_signals[5]; +}; + +struct _NautilusViewClient +{ + GtkBin parent; + + GtkWidget *main_window; + + GnomeObject *control, *view_client; + Nautilus_ViewFrame view_frame; +}; + +GtkType nautilus_view_client_get_type (void); +void nautilus_view_client_request_location_change (NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/libnautilus/Makefile.am b/libnautilus/Makefile.am new file mode 100644 index 000000000..d4982486d --- /dev/null +++ b/libnautilus/Makefile.am @@ -0,0 +1,22 @@ +lib_LTLIBRARIES=libnautilus.la + +INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOME_CFLAGS) $(GNORBA_CFLAGS) + +nautilus_idl_sources=nautilus-stubs.c nautilus-skels.c nautilus.h nautilus-common.c +BUILT_SOURCES=$(nautilus_idl_sources) + +libnautilusincludedir=$(includedir)/libnautilus +libnautilusinclude_HEADERS= \ + ntl-view-client.h \ + nautilus.h + +libnautilus_la_SOURCES=$(nautilus_idl_sources) \ + ntl-view-client.c + +$(nautilus_idl_sources): nautilus_idl_stamp + +nautilus_idl_stamp: $(top_srcdir)/idl/nautilus.idl + orbit-idl `gnome-config --cflags idl` $(top_srcdir)/idl/nautilus.idl + touch nautilus_idl_stamp + +CLEANFILES=nautilus_idl_stamp diff --git a/libnautilus/libnautilus.h b/libnautilus/libnautilus.h new file mode 100644 index 000000000..7ba1078ca --- /dev/null +++ b/libnautilus/libnautilus.h @@ -0,0 +1,8 @@ +#ifndef LIBNAUTILUS_H +#define LIBNAUTILUS_H 1 + +#include <bonobo/gnome-bonobo.h> +#include <libnautilus/nautilus.h> +#include <libnautilus/ntl-view-client.h> + +#endif diff --git a/libnautilus/nautilus-view-frame.c b/libnautilus/nautilus-view-frame.c new file mode 100644 index 000000000..f6397ef53 --- /dev/null +++ b/libnautilus/nautilus-view-frame.c @@ -0,0 +1,383 @@ +/* ntl-view-client.c + * Copyright (C) 1999 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. + */ + +#include <gtk/gtk.h> +#include "libnautilus.h" + +typedef struct { + POA_Nautilus_View servant; + gpointer gnome_object; + + NautilusViewClient *view; +} impl_POA_Nautilus_View; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_View__epv impl_Nautilus_View_epv = +{ + NULL, /* _private */ + (gpointer) & impl_Nautilus_View_save_state, + (gpointer) & impl_Nautilus_View_load_state, + (gpointer) & impl_Nautilus_View_notify_location_change, + (gpointer) & impl_Nautilus_View_show_properties, + (gpointer) & impl_Nautilus_View_notify_selection_change +}; + +static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_View_epv +}; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path); +} + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path); +} + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo); +} + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties"); +} + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo); +} + + +static void +impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_View__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_View *newservant; + + newservant = g_new0(impl_POA_Nautilus_View, 1); + newservant->servant.vepv = &impl_Nautilus_View_vepv; + newservant->view = view; + POA_Nautilus_View__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant); + + return retval; +} + +static void nautilus_view_client_init (NautilusViewClient *view); +static void nautilus_view_client_destroy (NautilusViewClient *view); +static void nautilus_view_client_class_init (NautilusViewClientClass *klass); +static void nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +GtkType +nautilus_view_client_get_type (void) +{ + static GtkType view_client_type = 0; + + if (!view_client_type) { + const GtkTypeInfo view_client_info = { + "NautilusViewClient", + sizeof (NautilusViewClient), + sizeof (NautilusViewClientClass), + (GtkClassInitFunc) nautilus_view_client_class_init, + (GtkObjectInitFunc) nautilus_view_client_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info); + } + + return view_client_type; +} + +#if 0 +typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, + gpointer arg1, + GtkObject *arg2, + gpointer arg3, + gpointer user_data); +static void +gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, + GtkArg * args) +{ + GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func; + (*rfunc) (object, + GTK_VALUE_BOXED (args[0]), + GTK_VALUE_OBJECT (args[1]), + GTK_VALUE_BOXED (args[2]), + func_data); +} +#endif + +static void +nautilus_view_client_class_init (NautilusViewClientClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + int i; + + object_class = (GtkObjectClass*) klass; + object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy; + object_class->set_arg = nautilus_view_client_set_arg; + object_class->get_arg = nautilus_view_client_get_arg; + + widget_class = (GtkWidgetClass*) klass; + widget_class->size_request = nautilus_view_client_size_request; + widget_class->size_allocate = nautilus_view_client_size_allocate; + + klass->notify_location_change = NULL; + + klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); + + i = 0; + klass->view_client_signals[i++] = gtk_signal_new("notify_location_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + klass->view_client_signals[i++] = gtk_signal_new("load_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("save_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("show_properties", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + gtk_object_class_add_signals (object_class, klass->view_client_signals, i); +} + +static void +nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_init (NautilusViewClient *view) +{ + CORBA_Environment ev; + GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view))); + + CORBA_exception_init(&ev); + view->view_client = impl_Nautilus_View__create(view, &ev); + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_destroy (NautilusViewClient *view) +{ + gtk_object_destroy(GTK_OBJECT(view->view_client)); +} + +void +nautilus_view_client_request_location_change(NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +void +nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin; + + bin = GTK_BIN (widget); + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; + } +} + +static void +nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkBin *bin; + GtkAllocation child_allocation; + + widget->allocation = child_allocation = *allocation; + bin = GTK_BIN (widget); + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &child_allocation); +} diff --git a/libnautilus/nautilus-view-frame.h b/libnautilus/nautilus-view-frame.h new file mode 100644 index 000000000..47928df34 --- /dev/null +++ b/libnautilus/nautilus-view-frame.h @@ -0,0 +1,55 @@ +#ifndef NTL_VIEW_CLIENT_H +#define NTL_VIEW_CLIENT_H + +#include <gtk/gtkobject.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define NAUTILUS_TYPE_VIEW_CLIENT (nautilus_view_client_get_type ()) +#define NAUTILUS_VIEW_CLIENT(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClient)) +#define NAUTILUS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClientClass)) +#define NAUTILUS_IS_VIEW_CLIENT(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) +#define NAUTILUS_IS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) + +typedef struct _NautilusViewClient NautilusViewClient; +typedef struct _NautilusViewClientClass NautilusViewClientClass; + +struct _NautilusViewClientClass +{ + GtkBinClass parent_spot; + + void (*notify_location_change) (NautilusViewClient *view, + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusViewClient *view, + Nautilus_SelectionInfo *nav_context); + void (*load_state) (NautilusViewClient *view, const char *config_path); + void (*save_state) (NautilusViewClient *view, const char *config_path); + void (*show_properties) (NautilusViewClient *view); + + GtkBinClass *parent_class; + guint view_client_signals[5]; +}; + +struct _NautilusViewClient +{ + GtkBin parent; + + GtkWidget *main_window; + + GnomeObject *control, *view_client; + Nautilus_ViewFrame view_frame; +}; + +GtkType nautilus_view_client_get_type (void); +void nautilus_view_client_request_location_change (NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/libnautilus/nautilus-view.c b/libnautilus/nautilus-view.c new file mode 100644 index 000000000..f6397ef53 --- /dev/null +++ b/libnautilus/nautilus-view.c @@ -0,0 +1,383 @@ +/* ntl-view-client.c + * Copyright (C) 1999 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. + */ + +#include <gtk/gtk.h> +#include "libnautilus.h" + +typedef struct { + POA_Nautilus_View servant; + gpointer gnome_object; + + NautilusViewClient *view; +} impl_POA_Nautilus_View; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_View__epv impl_Nautilus_View_epv = +{ + NULL, /* _private */ + (gpointer) & impl_Nautilus_View_save_state, + (gpointer) & impl_Nautilus_View_load_state, + (gpointer) & impl_Nautilus_View_notify_location_change, + (gpointer) & impl_Nautilus_View_show_properties, + (gpointer) & impl_Nautilus_View_notify_selection_change +}; + +static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_View_epv +}; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path); +} + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path); +} + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo); +} + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties"); +} + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo); +} + + +static void +impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_View__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_View *newservant; + + newservant = g_new0(impl_POA_Nautilus_View, 1); + newservant->servant.vepv = &impl_Nautilus_View_vepv; + newservant->view = view; + POA_Nautilus_View__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant); + + return retval; +} + +static void nautilus_view_client_init (NautilusViewClient *view); +static void nautilus_view_client_destroy (NautilusViewClient *view); +static void nautilus_view_client_class_init (NautilusViewClientClass *klass); +static void nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +GtkType +nautilus_view_client_get_type (void) +{ + static GtkType view_client_type = 0; + + if (!view_client_type) { + const GtkTypeInfo view_client_info = { + "NautilusViewClient", + sizeof (NautilusViewClient), + sizeof (NautilusViewClientClass), + (GtkClassInitFunc) nautilus_view_client_class_init, + (GtkObjectInitFunc) nautilus_view_client_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info); + } + + return view_client_type; +} + +#if 0 +typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, + gpointer arg1, + GtkObject *arg2, + gpointer arg3, + gpointer user_data); +static void +gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, + GtkArg * args) +{ + GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func; + (*rfunc) (object, + GTK_VALUE_BOXED (args[0]), + GTK_VALUE_OBJECT (args[1]), + GTK_VALUE_BOXED (args[2]), + func_data); +} +#endif + +static void +nautilus_view_client_class_init (NautilusViewClientClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + int i; + + object_class = (GtkObjectClass*) klass; + object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy; + object_class->set_arg = nautilus_view_client_set_arg; + object_class->get_arg = nautilus_view_client_get_arg; + + widget_class = (GtkWidgetClass*) klass; + widget_class->size_request = nautilus_view_client_size_request; + widget_class->size_allocate = nautilus_view_client_size_allocate; + + klass->notify_location_change = NULL; + + klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); + + i = 0; + klass->view_client_signals[i++] = gtk_signal_new("notify_location_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + klass->view_client_signals[i++] = gtk_signal_new("load_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("save_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("show_properties", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + gtk_object_class_add_signals (object_class, klass->view_client_signals, i); +} + +static void +nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_init (NautilusViewClient *view) +{ + CORBA_Environment ev; + GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view))); + + CORBA_exception_init(&ev); + view->view_client = impl_Nautilus_View__create(view, &ev); + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_destroy (NautilusViewClient *view) +{ + gtk_object_destroy(GTK_OBJECT(view->view_client)); +} + +void +nautilus_view_client_request_location_change(NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +void +nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin; + + bin = GTK_BIN (widget); + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; + } +} + +static void +nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkBin *bin; + GtkAllocation child_allocation; + + widget->allocation = child_allocation = *allocation; + bin = GTK_BIN (widget); + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &child_allocation); +} diff --git a/libnautilus/nautilus-view.h b/libnautilus/nautilus-view.h new file mode 100644 index 000000000..47928df34 --- /dev/null +++ b/libnautilus/nautilus-view.h @@ -0,0 +1,55 @@ +#ifndef NTL_VIEW_CLIENT_H +#define NTL_VIEW_CLIENT_H + +#include <gtk/gtkobject.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define NAUTILUS_TYPE_VIEW_CLIENT (nautilus_view_client_get_type ()) +#define NAUTILUS_VIEW_CLIENT(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClient)) +#define NAUTILUS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClientClass)) +#define NAUTILUS_IS_VIEW_CLIENT(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) +#define NAUTILUS_IS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) + +typedef struct _NautilusViewClient NautilusViewClient; +typedef struct _NautilusViewClientClass NautilusViewClientClass; + +struct _NautilusViewClientClass +{ + GtkBinClass parent_spot; + + void (*notify_location_change) (NautilusViewClient *view, + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusViewClient *view, + Nautilus_SelectionInfo *nav_context); + void (*load_state) (NautilusViewClient *view, const char *config_path); + void (*save_state) (NautilusViewClient *view, const char *config_path); + void (*show_properties) (NautilusViewClient *view); + + GtkBinClass *parent_class; + guint view_client_signals[5]; +}; + +struct _NautilusViewClient +{ + GtkBin parent; + + GtkWidget *main_window; + + GnomeObject *control, *view_client; + Nautilus_ViewFrame view_frame; +}; + +GtkType nautilus_view_client_get_type (void); +void nautilus_view_client_request_location_change (NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/libnautilus/ntl-view-client.c b/libnautilus/ntl-view-client.c new file mode 100644 index 000000000..f6397ef53 --- /dev/null +++ b/libnautilus/ntl-view-client.c @@ -0,0 +1,383 @@ +/* ntl-view-client.c + * Copyright (C) 1999 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. + */ + +#include <gtk/gtk.h> +#include "libnautilus.h" + +typedef struct { + POA_Nautilus_View servant; + gpointer gnome_object; + + NautilusViewClient *view; +} impl_POA_Nautilus_View; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_View__epv impl_Nautilus_View_epv = +{ + NULL, /* _private */ + (gpointer) & impl_Nautilus_View_save_state, + (gpointer) & impl_Nautilus_View_load_state, + (gpointer) & impl_Nautilus_View_notify_location_change, + (gpointer) & impl_Nautilus_View_show_properties, + (gpointer) & impl_Nautilus_View_notify_selection_change +}; + +static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_View_epv +}; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path); +} + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path); +} + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo); +} + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties"); +} + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo); +} + + +static void +impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_View__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_View *newservant; + + newservant = g_new0(impl_POA_Nautilus_View, 1); + newservant->servant.vepv = &impl_Nautilus_View_vepv; + newservant->view = view; + POA_Nautilus_View__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant); + + return retval; +} + +static void nautilus_view_client_init (NautilusViewClient *view); +static void nautilus_view_client_destroy (NautilusViewClient *view); +static void nautilus_view_client_class_init (NautilusViewClientClass *klass); +static void nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +GtkType +nautilus_view_client_get_type (void) +{ + static GtkType view_client_type = 0; + + if (!view_client_type) { + const GtkTypeInfo view_client_info = { + "NautilusViewClient", + sizeof (NautilusViewClient), + sizeof (NautilusViewClientClass), + (GtkClassInitFunc) nautilus_view_client_class_init, + (GtkObjectInitFunc) nautilus_view_client_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info); + } + + return view_client_type; +} + +#if 0 +typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, + gpointer arg1, + GtkObject *arg2, + gpointer arg3, + gpointer user_data); +static void +gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, + GtkArg * args) +{ + GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func; + (*rfunc) (object, + GTK_VALUE_BOXED (args[0]), + GTK_VALUE_OBJECT (args[1]), + GTK_VALUE_BOXED (args[2]), + func_data); +} +#endif + +static void +nautilus_view_client_class_init (NautilusViewClientClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + int i; + + object_class = (GtkObjectClass*) klass; + object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy; + object_class->set_arg = nautilus_view_client_set_arg; + object_class->get_arg = nautilus_view_client_get_arg; + + widget_class = (GtkWidgetClass*) klass; + widget_class->size_request = nautilus_view_client_size_request; + widget_class->size_allocate = nautilus_view_client_size_allocate; + + klass->notify_location_change = NULL; + + klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); + + i = 0; + klass->view_client_signals[i++] = gtk_signal_new("notify_location_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + klass->view_client_signals[i++] = gtk_signal_new("load_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("save_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("show_properties", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + gtk_object_class_add_signals (object_class, klass->view_client_signals, i); +} + +static void +nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_init (NautilusViewClient *view) +{ + CORBA_Environment ev; + GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view))); + + CORBA_exception_init(&ev); + view->view_client = impl_Nautilus_View__create(view, &ev); + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_destroy (NautilusViewClient *view) +{ + gtk_object_destroy(GTK_OBJECT(view->view_client)); +} + +void +nautilus_view_client_request_location_change(NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +void +nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin; + + bin = GTK_BIN (widget); + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; + } +} + +static void +nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkBin *bin; + GtkAllocation child_allocation; + + widget->allocation = child_allocation = *allocation; + bin = GTK_BIN (widget); + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &child_allocation); +} diff --git a/libnautilus/ntl-view-client.h b/libnautilus/ntl-view-client.h new file mode 100644 index 000000000..47928df34 --- /dev/null +++ b/libnautilus/ntl-view-client.h @@ -0,0 +1,55 @@ +#ifndef NTL_VIEW_CLIENT_H +#define NTL_VIEW_CLIENT_H + +#include <gtk/gtkobject.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define NAUTILUS_TYPE_VIEW_CLIENT (nautilus_view_client_get_type ()) +#define NAUTILUS_VIEW_CLIENT(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClient)) +#define NAUTILUS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClientClass)) +#define NAUTILUS_IS_VIEW_CLIENT(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) +#define NAUTILUS_IS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) + +typedef struct _NautilusViewClient NautilusViewClient; +typedef struct _NautilusViewClientClass NautilusViewClientClass; + +struct _NautilusViewClientClass +{ + GtkBinClass parent_spot; + + void (*notify_location_change) (NautilusViewClient *view, + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusViewClient *view, + Nautilus_SelectionInfo *nav_context); + void (*load_state) (NautilusViewClient *view, const char *config_path); + void (*save_state) (NautilusViewClient *view, const char *config_path); + void (*show_properties) (NautilusViewClient *view); + + GtkBinClass *parent_class; + guint view_client_signals[5]; +}; + +struct _NautilusViewClient +{ + GtkBin parent; + + GtkWidget *main_window; + + GnomeObject *control, *view_client; + Nautilus_ViewFrame view_frame; +}; + +GtkType nautilus_view_client_get_type (void); +void nautilus_view_client_request_location_change (NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/libnautilus/ntl-view-frame.c b/libnautilus/ntl-view-frame.c new file mode 100644 index 000000000..f6397ef53 --- /dev/null +++ b/libnautilus/ntl-view-frame.c @@ -0,0 +1,383 @@ +/* ntl-view-client.c + * Copyright (C) 1999 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. + */ + +#include <gtk/gtk.h> +#include "libnautilus.h" + +typedef struct { + POA_Nautilus_View servant; + gpointer gnome_object; + + NautilusViewClient *view; +} impl_POA_Nautilus_View; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev); + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_View__epv impl_Nautilus_View_epv = +{ + NULL, /* _private */ + (gpointer) & impl_Nautilus_View_save_state, + (gpointer) & impl_Nautilus_View_load_state, + (gpointer) & impl_Nautilus_View_notify_location_change, + (gpointer) & impl_Nautilus_View_show_properties, + (gpointer) & impl_Nautilus_View_notify_selection_change +}; + +static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_View_epv +}; + +static void +impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path); +} + +static void +impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant, + CORBA_char * config_path, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path); +} + +static void +impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant, + Nautilus_NavigationInfo * navinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo); +} + +static void +impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties"); +} + +static void +impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant, + Nautilus_SelectionInfo * selinfo, + CORBA_Environment * ev) +{ + gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo); +} + + +static void +impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_View__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_View *newservant; + + newservant = g_new0(impl_POA_Nautilus_View, 1); + newservant->servant.vepv = &impl_Nautilus_View_vepv; + newservant->view = view; + POA_Nautilus_View__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant); + + return retval; +} + +static void nautilus_view_client_init (NautilusViewClient *view); +static void nautilus_view_client_destroy (NautilusViewClient *view); +static void nautilus_view_client_class_init (NautilusViewClientClass *klass); +static void nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +GtkType +nautilus_view_client_get_type (void) +{ + static GtkType view_client_type = 0; + + if (!view_client_type) { + const GtkTypeInfo view_client_info = { + "NautilusViewClient", + sizeof (NautilusViewClient), + sizeof (NautilusViewClientClass), + (GtkClassInitFunc) nautilus_view_client_class_init, + (GtkObjectInitFunc) nautilus_view_client_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info); + } + + return view_client_type; +} + +#if 0 +typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, + gpointer arg1, + GtkObject *arg2, + gpointer arg3, + gpointer user_data); +static void +gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, + GtkArg * args) +{ + GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func; + (*rfunc) (object, + GTK_VALUE_BOXED (args[0]), + GTK_VALUE_OBJECT (args[1]), + GTK_VALUE_BOXED (args[2]), + func_data); +} +#endif + +static void +nautilus_view_client_class_init (NautilusViewClientClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + int i; + + object_class = (GtkObjectClass*) klass; + object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy; + object_class->set_arg = nautilus_view_client_set_arg; + object_class->get_arg = nautilus_view_client_get_arg; + + widget_class = (GtkWidgetClass*) klass; + widget_class->size_request = nautilus_view_client_size_request; + widget_class->size_allocate = nautilus_view_client_size_allocate; + + klass->notify_location_change = NULL; + + klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); + + i = 0; + klass->view_client_signals[i++] = gtk_signal_new("notify_location_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + klass->view_client_signals[i++] = gtk_signal_new("load_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("save_state", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + klass->view_client_signals[i++] = gtk_signal_new("show_properties", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); + gtk_object_class_add_signals (object_class, klass->view_client_signals, i); +} + +static void +nautilus_view_client_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ +} + +static void +nautilus_view_client_init (NautilusViewClient *view) +{ + CORBA_Environment ev; + GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view))); + + CORBA_exception_init(&ev); + view->view_client = impl_Nautilus_View__create(view, &ev); + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_destroy (NautilusViewClient *view) +{ + gtk_object_destroy(GTK_OBJECT(view->view_client)); +} + +void +nautilus_view_client_request_location_change(NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +void +nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc) +{ + CORBA_Environment ev; + + g_return_if_fail (view != NULL); + g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view)); + + CORBA_exception_init(&ev); + if(CORBA_Object_is_nil(view->view_frame, &ev)) + view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)), + "IDL:Nautilus/ViewFrame:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_frame = CORBA_OBJECT_NIL; + if(CORBA_Object_is_nil(view->view_frame, &ev)) + return; + + Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + { + CORBA_Object_release(view->view_frame, &ev); + view->view_frame = CORBA_OBJECT_NIL; + } + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_client_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin; + + bin = GTK_BIN (widget); + + requisition->width = 0; + requisition->height = 0; + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; + } +} + +static void +nautilus_view_client_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkBin *bin; + GtkAllocation child_allocation; + + widget->allocation = child_allocation = *allocation; + bin = GTK_BIN (widget); + + if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + gtk_widget_size_allocate (bin->child, &child_allocation); +} diff --git a/libnautilus/ntl-view-frame.h b/libnautilus/ntl-view-frame.h new file mode 100644 index 000000000..47928df34 --- /dev/null +++ b/libnautilus/ntl-view-frame.h @@ -0,0 +1,55 @@ +#ifndef NTL_VIEW_CLIENT_H +#define NTL_VIEW_CLIENT_H + +#include <gtk/gtkobject.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define NAUTILUS_TYPE_VIEW_CLIENT (nautilus_view_client_get_type ()) +#define NAUTILUS_VIEW_CLIENT(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClient)) +#define NAUTILUS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_CLIENT, NautilusViewClientClass)) +#define NAUTILUS_IS_VIEW_CLIENT(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) +#define NAUTILUS_IS_VIEW_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_CLIENT)) + +typedef struct _NautilusViewClient NautilusViewClient; +typedef struct _NautilusViewClientClass NautilusViewClientClass; + +struct _NautilusViewClientClass +{ + GtkBinClass parent_spot; + + void (*notify_location_change) (NautilusViewClient *view, + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusViewClient *view, + Nautilus_SelectionInfo *nav_context); + void (*load_state) (NautilusViewClient *view, const char *config_path); + void (*save_state) (NautilusViewClient *view, const char *config_path); + void (*show_properties) (NautilusViewClient *view); + + GtkBinClass *parent_class; + guint view_client_signals[5]; +}; + +struct _NautilusViewClient +{ + GtkBin parent; + + GtkWidget *main_window; + + GnomeObject *control, *view_client; + Nautilus_ViewFrame view_frame; +}; + +GtkType nautilus_view_client_get_type (void); +void nautilus_view_client_request_location_change (NautilusViewClient *view, + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_client_request_selection_change (NautilusViewClient *view, + Nautilus_SelectionRequestInfo *loc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index de99afb80..521ae102a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ bin_PROGRAMS=nautilus -INCLUDES=$(GNORBA_CFLAGS) $(GNOMEUI_CFLAGS) -DVERSION="\"$(VERSION)\"" -LDADD=$(GNORBA_LIBS) $(GNOMEUI_LIBS) $(BONOBO_LIBS) +INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(BONOBO_CFLAGS) $(GNORBA_CFLAGS) $(GNOMEUI_CFLAGS) -DVERSION="\"$(VERSION)\"" +LDADD=../libnautilus/libnautilus.la $(BONOBO_LIBS) $(GNORBA_LIBS) $(GNOMEUI_LIBS) $(BONOBO_LIBS) nautilus_SOURCES= \ ntl-content-view.h \ diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c index b2c4a94ba..b65fd8049 100644 --- a/src/nautilus-applicable-views.c +++ b/src/nautilus-applicable-views.c @@ -2,15 +2,21 @@ #include <libgnorba/gnorba.h> NautilusNavigationInfo * -nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri, +nautilus_navinfo_new(NautilusNavigationInfo *navinfo, + Nautilus_NavigationRequestInfo *nri, NautilusLocationReference referring_uri, NautilusLocationReference actual_referring_uri, - const char *referring_content_type) + const char *referring_content_type, + GtkWidget *requesting_view) { - navinfo->requested_uri = uri; - navinfo->referring_uri = referring_uri; - navinfo->actual_referring_uri = actual_referring_uri; - navinfo->referring_content_type = (char *)referring_content_type; + memset(navinfo, 0, sizeof(*navinfo)); + + navinfo->navinfo.requested_uri = nri->requested_uri; + navinfo->navinfo.referring_uri = referring_uri; + navinfo->navinfo.actual_referring_uri = actual_referring_uri; + navinfo->navinfo.referring_content_type = (char *)referring_content_type; + + navinfo->requesting_view = requesting_view; /* XXX turn the provided information into some activateable IID's */ diff --git a/src/nautilus-applicable-views.h b/src/nautilus-applicable-views.h index d01e0c617..8c1b9b377 100644 --- a/src/nautilus-applicable-views.h +++ b/src/nautilus-applicable-views.h @@ -3,10 +3,12 @@ #include "ntl-types.h" -NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri, +NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo, + Nautilus_NavigationRequestInfo *nri, NautilusLocationReference referring_uri, NautilusLocationReference actual_referring_uri, - const char *referring_content_type); + const char *referring_content_type, + GtkWidget *requesting_view); void nautilus_navinfo_free(NautilusNavigationInfo *navinfo); #endif diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 62e824628..ab0e4a1a8 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -16,7 +16,7 @@ static void nautilus_window_get_arg (GtkObject *object, static void nautilus_window_close (GtkWidget *widget, GtkWidget *window); static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); #define CONTENTS_AS_HBOX @@ -44,20 +44,20 @@ nautilus_window_get_type(void) return window_type; } -typedef void (*GtkSignal_NONE__STRING_OBJECT) (GtkObject * object, - const char *arg1, +typedef void (*GtkSignal_NONE__BOXED_OBJECT) (GtkObject * object, + gpointer arg1, GtkObject *arg2, gpointer user_data); static void -gtk_marshal_NONE__STRING_OBJECT (GtkObject * object, +gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args) { - GtkSignal_NONE__STRING_OBJECT rfunc; - rfunc = (GtkSignal_NONE__STRING_OBJECT) func; + GtkSignal_NONE__BOXED_OBJECT rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT) func; (*rfunc) (object, - GTK_VALUE_STRING (args[0]), + GTK_VALUE_BOXED (args[0]), GTK_VALUE_OBJECT (args[1]), func_data); } @@ -90,8 +90,14 @@ nautilus_window_class_init (NautilusWindowClass *klass) GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusWindowClass, request_location_change), - gtk_marshal_NONE__STRING_OBJECT, - GTK_TYPE_NONE, 2, GTK_TYPE_STRING, GTK_TYPE_OBJECT); + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); + klass->window_signals[i++] = gtk_signal_new("request_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusWindowClass, request_selection_change), + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); gtk_object_class_add_signals (object_class, klass->window_signals, i); gtk_object_add_arg_type ("NautilusWindow::app_id", @@ -415,8 +421,22 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view } void +nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view) +{ + NautilusWindowClass *klass; + GtkObject *obj; + + obj = GTK_OBJECT(window); + + klass = NAUTILUS_WINDOW_CLASS(obj->klass); + gtk_signal_emit(obj, klass->window_signals[1], loc, requesting_view); +} + +void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { NautilusWindowClass *klass; @@ -430,7 +450,7 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view, gboolean is_back) { @@ -440,12 +460,13 @@ nautilus_window_change_location(NautilusWindow *window, NautilusNavigationInfo loci_spot, *loci; - loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type); + loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type, + requesting_view); if(!loci) { char cbuf[1024]; - g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc); + g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc->requested_uri); nautilus_window_set_status(window, cbuf); return; } @@ -459,14 +480,14 @@ nautilus_window_change_location(NautilusWindow *window, else { char *append_val; - if(window->uris_next && !strcmp(loc, window->uris_next->data)) + if(window->uris_next && !strcmp(loc->requested_uri, window->uris_next->data)) { append_val = window->uris_next->data; window->uris_next = g_slist_remove(window->uris_next, window->uris_next->data); } else { - append_val = g_strdup(loc); + append_val = g_strdup(loc->requested_uri); g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); g_slist_free(window->uris_next); window->uris_next = NULL; } @@ -514,18 +535,18 @@ nautilus_window_change_location(NautilusWindow *window, g_slist_free(discard_views); g_free(window->current_content_type); - window->current_content_type = g_strdup(loci->content_type); + window->current_content_type = g_strdup(loci->navinfo.content_type); g_free(window->current_uri); - window->current_uri = g_strdup(loci->requested_uri); + window->current_uri = g_strdup(loci->navinfo.requested_uri); g_free(window->actual_current_uri); - window->actual_current_uri = g_strdup(loci->actual_uri); + window->actual_current_uri = g_strdup(loci->navinfo.actual_uri); nautilus_navinfo_free(loci); } static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { nautilus_window_change_location(window, loc, requesting_view, FALSE); @@ -683,23 +704,26 @@ nautilus_window_load_state(NautilusWindow *window, const char *config_path) static void nautilus_window_back (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_prev); - uri = window->uris_prev->data; + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_prev->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, uri, NULL, TRUE); + nautilus_window_change_location(window, &nri, NULL, TRUE); } static void nautilus_window_fwd (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_next); - uri = window->uris_next->data; - - nautilus_window_change_location(window, uri, NULL, FALSE); + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_next->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; + nautilus_window_change_location(window, &nri, NULL, FALSE); } diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index d69ecabfe..7f637097a 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -19,9 +19,12 @@ typedef struct { GnomeAppClass *parent_class; void (* request_location_change)(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); - guint window_signals[1]; + void (* request_selection_change)(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); + guint window_signals[2]; } NautilusWindowClass; struct _NautilusWindow { @@ -42,8 +45,11 @@ struct _NautilusWindow { GtkType nautilus_window_get_type(void); GtkWidget *nautilus_window_new(const char *app_id); void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); +void nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); void nautilus_window_set_initial_state(NautilusWindow *window); diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 62e824628..ab0e4a1a8 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -16,7 +16,7 @@ static void nautilus_window_get_arg (GtkObject *object, static void nautilus_window_close (GtkWidget *widget, GtkWidget *window); static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); #define CONTENTS_AS_HBOX @@ -44,20 +44,20 @@ nautilus_window_get_type(void) return window_type; } -typedef void (*GtkSignal_NONE__STRING_OBJECT) (GtkObject * object, - const char *arg1, +typedef void (*GtkSignal_NONE__BOXED_OBJECT) (GtkObject * object, + gpointer arg1, GtkObject *arg2, gpointer user_data); static void -gtk_marshal_NONE__STRING_OBJECT (GtkObject * object, +gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args) { - GtkSignal_NONE__STRING_OBJECT rfunc; - rfunc = (GtkSignal_NONE__STRING_OBJECT) func; + GtkSignal_NONE__BOXED_OBJECT rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT) func; (*rfunc) (object, - GTK_VALUE_STRING (args[0]), + GTK_VALUE_BOXED (args[0]), GTK_VALUE_OBJECT (args[1]), func_data); } @@ -90,8 +90,14 @@ nautilus_window_class_init (NautilusWindowClass *klass) GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusWindowClass, request_location_change), - gtk_marshal_NONE__STRING_OBJECT, - GTK_TYPE_NONE, 2, GTK_TYPE_STRING, GTK_TYPE_OBJECT); + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); + klass->window_signals[i++] = gtk_signal_new("request_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusWindowClass, request_selection_change), + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); gtk_object_class_add_signals (object_class, klass->window_signals, i); gtk_object_add_arg_type ("NautilusWindow::app_id", @@ -415,8 +421,22 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view } void +nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view) +{ + NautilusWindowClass *klass; + GtkObject *obj; + + obj = GTK_OBJECT(window); + + klass = NAUTILUS_WINDOW_CLASS(obj->klass); + gtk_signal_emit(obj, klass->window_signals[1], loc, requesting_view); +} + +void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { NautilusWindowClass *klass; @@ -430,7 +450,7 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view, gboolean is_back) { @@ -440,12 +460,13 @@ nautilus_window_change_location(NautilusWindow *window, NautilusNavigationInfo loci_spot, *loci; - loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type); + loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type, + requesting_view); if(!loci) { char cbuf[1024]; - g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc); + g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc->requested_uri); nautilus_window_set_status(window, cbuf); return; } @@ -459,14 +480,14 @@ nautilus_window_change_location(NautilusWindow *window, else { char *append_val; - if(window->uris_next && !strcmp(loc, window->uris_next->data)) + if(window->uris_next && !strcmp(loc->requested_uri, window->uris_next->data)) { append_val = window->uris_next->data; window->uris_next = g_slist_remove(window->uris_next, window->uris_next->data); } else { - append_val = g_strdup(loc); + append_val = g_strdup(loc->requested_uri); g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); g_slist_free(window->uris_next); window->uris_next = NULL; } @@ -514,18 +535,18 @@ nautilus_window_change_location(NautilusWindow *window, g_slist_free(discard_views); g_free(window->current_content_type); - window->current_content_type = g_strdup(loci->content_type); + window->current_content_type = g_strdup(loci->navinfo.content_type); g_free(window->current_uri); - window->current_uri = g_strdup(loci->requested_uri); + window->current_uri = g_strdup(loci->navinfo.requested_uri); g_free(window->actual_current_uri); - window->actual_current_uri = g_strdup(loci->actual_uri); + window->actual_current_uri = g_strdup(loci->navinfo.actual_uri); nautilus_navinfo_free(loci); } static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { nautilus_window_change_location(window, loc, requesting_view, FALSE); @@ -683,23 +704,26 @@ nautilus_window_load_state(NautilusWindow *window, const char *config_path) static void nautilus_window_back (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_prev); - uri = window->uris_prev->data; + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_prev->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, uri, NULL, TRUE); + nautilus_window_change_location(window, &nri, NULL, TRUE); } static void nautilus_window_fwd (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_next); - uri = window->uris_next->data; - - nautilus_window_change_location(window, uri, NULL, FALSE); + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_next->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; + nautilus_window_change_location(window, &nri, NULL, FALSE); } diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h index d69ecabfe..7f637097a 100644 --- a/src/nautilus-object-window.h +++ b/src/nautilus-object-window.h @@ -19,9 +19,12 @@ typedef struct { GnomeAppClass *parent_class; void (* request_location_change)(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); - guint window_signals[1]; + void (* request_selection_change)(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); + guint window_signals[2]; } NautilusWindowClass; struct _NautilusWindow { @@ -42,8 +45,11 @@ struct _NautilusWindow { GtkType nautilus_window_get_type(void); GtkWidget *nautilus_window_new(const char *app_id); void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); +void nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); void nautilus_window_set_initial_state(NautilusWindow *window); diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 62e824628..ab0e4a1a8 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -16,7 +16,7 @@ static void nautilus_window_get_arg (GtkObject *object, static void nautilus_window_close (GtkWidget *widget, GtkWidget *window); static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); #define CONTENTS_AS_HBOX @@ -44,20 +44,20 @@ nautilus_window_get_type(void) return window_type; } -typedef void (*GtkSignal_NONE__STRING_OBJECT) (GtkObject * object, - const char *arg1, +typedef void (*GtkSignal_NONE__BOXED_OBJECT) (GtkObject * object, + gpointer arg1, GtkObject *arg2, gpointer user_data); static void -gtk_marshal_NONE__STRING_OBJECT (GtkObject * object, +gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args) { - GtkSignal_NONE__STRING_OBJECT rfunc; - rfunc = (GtkSignal_NONE__STRING_OBJECT) func; + GtkSignal_NONE__BOXED_OBJECT rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT) func; (*rfunc) (object, - GTK_VALUE_STRING (args[0]), + GTK_VALUE_BOXED (args[0]), GTK_VALUE_OBJECT (args[1]), func_data); } @@ -90,8 +90,14 @@ nautilus_window_class_init (NautilusWindowClass *klass) GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusWindowClass, request_location_change), - gtk_marshal_NONE__STRING_OBJECT, - GTK_TYPE_NONE, 2, GTK_TYPE_STRING, GTK_TYPE_OBJECT); + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); + klass->window_signals[i++] = gtk_signal_new("request_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusWindowClass, request_selection_change), + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); gtk_object_class_add_signals (object_class, klass->window_signals, i); gtk_object_add_arg_type ("NautilusWindow::app_id", @@ -415,8 +421,22 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view } void +nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view) +{ + NautilusWindowClass *klass; + GtkObject *obj; + + obj = GTK_OBJECT(window); + + klass = NAUTILUS_WINDOW_CLASS(obj->klass); + gtk_signal_emit(obj, klass->window_signals[1], loc, requesting_view); +} + +void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { NautilusWindowClass *klass; @@ -430,7 +450,7 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view, gboolean is_back) { @@ -440,12 +460,13 @@ nautilus_window_change_location(NautilusWindow *window, NautilusNavigationInfo loci_spot, *loci; - loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type); + loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type, + requesting_view); if(!loci) { char cbuf[1024]; - g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc); + g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc->requested_uri); nautilus_window_set_status(window, cbuf); return; } @@ -459,14 +480,14 @@ nautilus_window_change_location(NautilusWindow *window, else { char *append_val; - if(window->uris_next && !strcmp(loc, window->uris_next->data)) + if(window->uris_next && !strcmp(loc->requested_uri, window->uris_next->data)) { append_val = window->uris_next->data; window->uris_next = g_slist_remove(window->uris_next, window->uris_next->data); } else { - append_val = g_strdup(loc); + append_val = g_strdup(loc->requested_uri); g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); g_slist_free(window->uris_next); window->uris_next = NULL; } @@ -514,18 +535,18 @@ nautilus_window_change_location(NautilusWindow *window, g_slist_free(discard_views); g_free(window->current_content_type); - window->current_content_type = g_strdup(loci->content_type); + window->current_content_type = g_strdup(loci->navinfo.content_type); g_free(window->current_uri); - window->current_uri = g_strdup(loci->requested_uri); + window->current_uri = g_strdup(loci->navinfo.requested_uri); g_free(window->actual_current_uri); - window->actual_current_uri = g_strdup(loci->actual_uri); + window->actual_current_uri = g_strdup(loci->navinfo.actual_uri); nautilus_navinfo_free(loci); } static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { nautilus_window_change_location(window, loc, requesting_view, FALSE); @@ -683,23 +704,26 @@ nautilus_window_load_state(NautilusWindow *window, const char *config_path) static void nautilus_window_back (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_prev); - uri = window->uris_prev->data; + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_prev->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, uri, NULL, TRUE); + nautilus_window_change_location(window, &nri, NULL, TRUE); } static void nautilus_window_fwd (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_next); - uri = window->uris_next->data; - - nautilus_window_change_location(window, uri, NULL, FALSE); + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_next->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; + nautilus_window_change_location(window, &nri, NULL, FALSE); } diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h index d69ecabfe..7f637097a 100644 --- a/src/nautilus-spatial-window.h +++ b/src/nautilus-spatial-window.h @@ -19,9 +19,12 @@ typedef struct { GnomeAppClass *parent_class; void (* request_location_change)(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); - guint window_signals[1]; + void (* request_selection_change)(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); + guint window_signals[2]; } NautilusWindowClass; struct _NautilusWindow { @@ -42,8 +45,11 @@ struct _NautilusWindow { GtkType nautilus_window_get_type(void); GtkWidget *nautilus_window_new(const char *app_id); void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); +void nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); void nautilus_window_set_initial_state(NautilusWindow *window); diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c index aa180e5a4..117f94e58 100644 --- a/src/nautilus-view-frame.c +++ b/src/nautilus-view-frame.c @@ -23,15 +23,98 @@ #include "ntl-window.h" enum { - NOTIFY_LOCATION_CHANGE, - LAST_SIGNAL + NOTIFY_LOCATION_CHANGE, + LAST_SIGNAL }; enum { - ARG_0, - ARG_MAIN_WINDOW + ARG_0, + ARG_MAIN_WINDOW }; +typedef struct { + POA_Nautilus_ViewFrame servant; + gpointer gnome_object; + + NautilusView *view; +} impl_POA_Nautilus_ViewFrame; + +static void +impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_NavigationRequestInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_SelectionRequestInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_ViewFrame__epv impl_Nautilus_ViewFrame_epv = +{ + NULL, /* _private */ + (void(*))&impl_Nautilus_ViewFrame_request_location_change, + (void(*))&impl_Nautilus_ViewFrame_request_selection_change +}; + +static POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_ViewFrame_epv +}; + +static void +impl_Nautilus_ViewFrame__destroy(GnomeObject *obj, impl_POA_Nautilus_ViewFrame *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_ViewFrame__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_ViewFrame__create(NautilusView *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_ViewFrame *newservant; + + newservant = g_new0(impl_POA_Nautilus_ViewFrame, 1); + newservant->servant.vepv = &impl_Nautilus_ViewFrame_vepv; + newservant->view = view; + POA_Nautilus_ViewFrame__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_ViewFrame__destroy), newservant); + + return retval; +} + +static void +impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_NavigationRequestInfo * navinfo, + CORBA_Environment * ev) +{ + nautilus_view_request_location_change(servant->view, navinfo); +} + +static void +impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_SelectionRequestInfo * selinfo, + CORBA_Environment * ev) +{ + nautilus_view_request_selection_change(servant->view, selinfo); +} + static void nautilus_view_init (NautilusView *view); static void nautilus_view_constructed(NautilusView *view); static void nautilus_view_class_init (NautilusViewClass *klass); @@ -45,7 +128,13 @@ static void nautilus_view_size_request (GtkWidget *widget, GtkRequisition *requisition); static void nautilus_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation); - +static void nautilus_view_notify_location_change(NautilusView *view, + Nautilus_NavigationInfo *nav_context); +static void nautilus_view_notify_selection_change(NautilusView *view, + Nautilus_SelectionInfo *nav_context); +static void nautilus_view_load_state(NautilusView *view, const char *config_path); +static void nautilus_view_save_state(NautilusView *view, const char *config_path); +static void nautilus_view_show_properties(NautilusView *view); GtkType nautilus_view_get_type (void) @@ -70,6 +159,7 @@ nautilus_view_get_type (void) return view_type; } +#if 0 typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, gpointer arg1, GtkObject *arg2, @@ -89,6 +179,7 @@ gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, GTK_VALUE_BOXED (args[2]), func_data); } +#endif static void nautilus_view_class_init (NautilusViewClass *klass) @@ -109,14 +200,19 @@ nautilus_view_class_init (NautilusViewClass *klass) klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); klass->view_constructed = nautilus_view_constructed; + klass->notify_location_change = nautilus_view_notify_location_change; + klass->notify_selection_change = nautilus_view_notify_selection_change; + klass->load_state = nautilus_view_load_state; + klass->save_state = nautilus_view_save_state; + klass->show_properties = nautilus_view_show_properties; i = 0; klass->view_signals[i++] = gtk_signal_new("notify_location_change", GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusViewClass, notify_location_change), - gtk_marshal_NONE__BOXED_OBJECT_BOXED, - GTK_TYPE_NONE, 3, GTK_TYPE_BOXED, GTK_TYPE_OBJECT, GTK_TYPE_BOXED); + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); klass->view_signals[i++] = gtk_signal_new("load_state", GTK_RUN_LAST, object_class->type, @@ -135,6 +231,12 @@ nautilus_view_class_init (NautilusViewClass *klass) GTK_SIGNAL_OFFSET (NautilusViewClass, show_properties), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + klass->view_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); gtk_object_class_add_signals (object_class, klass->view_signals, i); gtk_object_add_arg_type ("NautilusView::main_window", @@ -175,7 +277,12 @@ nautilus_view_get_arg (GtkObject *object, static void nautilus_view_init (NautilusView *view) { + CORBA_Environment ev; GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + CORBA_exception_init(&ev); + view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); + CORBA_exception_free(&ev); } static void @@ -202,7 +309,7 @@ nautilus_view_construct_arg_set(NautilusView *view) void nautilus_view_request_location_change(NautilusView *view, - NautilusLocationReference loc) + Nautilus_NavigationRequestInfo *loc) { g_return_if_fail (view != NULL); g_return_if_fail (NAUTILUS_IS_VIEW (view)); @@ -211,6 +318,13 @@ nautilus_view_request_location_change(NautilusView *view, nautilus_window_request_location_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view)); } +void +nautilus_view_request_selection_change (NautilusView *view, + Nautilus_SelectionRequestInfo *loc) +{ + nautilus_window_request_selection_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view)); +} + static void nautilus_view_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -247,10 +361,24 @@ nautilus_view_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (bin->child, &child_allocation); } +static void +nautilus_view_activate_uri(GnomeControlFrame *frame, const char *uri, gboolean relative, NautilusView *view) +{ + Nautilus_NavigationRequestInfo nri; + g_assert(!relative); + + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = (char *)uri; + nautilus_view_request_location_change(view, &nri); +} + void nautilus_view_load_client(NautilusView *view, const char * iid) { + GnomeControlFrame *frame; + CORBA_Environment ev; + if(view->client) { g_free(view->iid); view->iid = NULL; @@ -259,7 +387,82 @@ nautilus_view_load_client(NautilusView *view, view->client = gnome_bonobo_widget_new_control((char *)iid); g_return_if_fail(view->client); + CORBA_exception_init(&ev); + CORBA_Object_release(view->view_client, &ev); + frame = gnome_bonobo_widget_get_control_frame(GNOME_BONOBO_WIDGET(view->client)); + gnome_object_add_interface(GNOME_OBJECT(frame), view->view_frame); + view->view_client = GNOME_Unknown_query_interface(gnome_control_frame_get_control(GNOME_CONTROL_FRAME(frame)), + "IDL:Nautilus/View:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_client = CORBA_OBJECT_NIL; view->iid = g_strdup(iid); + + gtk_signal_connect(GTK_OBJECT(frame), "activate_uri", GTK_SIGNAL_FUNC(nautilus_view_activate_uri), view); gtk_widget_show(view->client); gtk_container_add(GTK_CONTAINER(view), view->client); + CORBA_exception_free(&ev); } + +static void +nautilus_view_notify_location_change(NautilusView *view, + Nautilus_NavigationInfo *nav_context) +{ + CORBA_Environment ev; + + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_notify_location_change(view->view_client, nav_context, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_notify_selection_change(NautilusView *view, + Nautilus_SelectionInfo *nav_context) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_notify_selection_change(view->view_client, nav_context, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_load_state(NautilusView *view, const char *config_path) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_load_state(view->view_client, (char *)config_path, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_save_state(NautilusView *view, const char *config_path) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_save_state(view->view_client, (char *)config_path, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_show_properties(NautilusView *view) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_show_properties(view->view_client, &ev); + + CORBA_exception_free(&ev); +} + diff --git a/src/nautilus-view-frame.h b/src/nautilus-view-frame.h index 3581b6cf3..87050b5a0 100644 --- a/src/nautilus-view-frame.h +++ b/src/nautilus-view-frame.h @@ -42,7 +42,9 @@ struct _NautilusViewClass GtkBinClass parent_spot; void (*notify_location_change) (NautilusView *view, - NautilusNavigationInfo *nav_context); + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusView *view, + Nautilus_SelectionInfo *nav_context); void (*load_state) (NautilusView *view, const char *config_path); void (*save_state) (NautilusView *view, const char *config_path); void (*show_properties) (NautilusView *view); @@ -50,7 +52,7 @@ struct _NautilusViewClass void (*view_constructed) (NautilusView *view); /* Not a signal. Work-around for Gtk+'s lack of a 'constructed' operation */ GtkBinClass *parent_class; - guint view_signals[3]; + guint view_signals[6]; guint num_construct_args; }; @@ -62,13 +64,18 @@ struct _NautilusView char *iid; GtkWidget *client; + CORBA_Object view_client; + + GnomeObject *view_frame; guint construct_arg_count; }; GtkType nautilus_view_get_type (void); void nautilus_view_request_location_change (NautilusView *view, - NautilusLocationReference loc); + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_request_selection_change (NautilusView *view, + Nautilus_SelectionRequestInfo *loc); void nautilus_view_load_client (NautilusView *view, const char * iid); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 62e824628..ab0e4a1a8 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -16,7 +16,7 @@ static void nautilus_window_get_arg (GtkObject *object, static void nautilus_window_close (GtkWidget *widget, GtkWidget *window); static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); #define CONTENTS_AS_HBOX @@ -44,20 +44,20 @@ nautilus_window_get_type(void) return window_type; } -typedef void (*GtkSignal_NONE__STRING_OBJECT) (GtkObject * object, - const char *arg1, +typedef void (*GtkSignal_NONE__BOXED_OBJECT) (GtkObject * object, + gpointer arg1, GtkObject *arg2, gpointer user_data); static void -gtk_marshal_NONE__STRING_OBJECT (GtkObject * object, +gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args) { - GtkSignal_NONE__STRING_OBJECT rfunc; - rfunc = (GtkSignal_NONE__STRING_OBJECT) func; + GtkSignal_NONE__BOXED_OBJECT rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT) func; (*rfunc) (object, - GTK_VALUE_STRING (args[0]), + GTK_VALUE_BOXED (args[0]), GTK_VALUE_OBJECT (args[1]), func_data); } @@ -90,8 +90,14 @@ nautilus_window_class_init (NautilusWindowClass *klass) GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusWindowClass, request_location_change), - gtk_marshal_NONE__STRING_OBJECT, - GTK_TYPE_NONE, 2, GTK_TYPE_STRING, GTK_TYPE_OBJECT); + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); + klass->window_signals[i++] = gtk_signal_new("request_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusWindowClass, request_selection_change), + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); gtk_object_class_add_signals (object_class, klass->window_signals, i); gtk_object_add_arg_type ("NautilusWindow::app_id", @@ -415,8 +421,22 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view } void +nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view) +{ + NautilusWindowClass *klass; + GtkObject *obj; + + obj = GTK_OBJECT(window); + + klass = NAUTILUS_WINDOW_CLASS(obj->klass); + gtk_signal_emit(obj, klass->window_signals[1], loc, requesting_view); +} + +void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { NautilusWindowClass *klass; @@ -430,7 +450,7 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view, gboolean is_back) { @@ -440,12 +460,13 @@ nautilus_window_change_location(NautilusWindow *window, NautilusNavigationInfo loci_spot, *loci; - loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type); + loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type, + requesting_view); if(!loci) { char cbuf[1024]; - g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc); + g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc->requested_uri); nautilus_window_set_status(window, cbuf); return; } @@ -459,14 +480,14 @@ nautilus_window_change_location(NautilusWindow *window, else { char *append_val; - if(window->uris_next && !strcmp(loc, window->uris_next->data)) + if(window->uris_next && !strcmp(loc->requested_uri, window->uris_next->data)) { append_val = window->uris_next->data; window->uris_next = g_slist_remove(window->uris_next, window->uris_next->data); } else { - append_val = g_strdup(loc); + append_val = g_strdup(loc->requested_uri); g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); g_slist_free(window->uris_next); window->uris_next = NULL; } @@ -514,18 +535,18 @@ nautilus_window_change_location(NautilusWindow *window, g_slist_free(discard_views); g_free(window->current_content_type); - window->current_content_type = g_strdup(loci->content_type); + window->current_content_type = g_strdup(loci->navinfo.content_type); g_free(window->current_uri); - window->current_uri = g_strdup(loci->requested_uri); + window->current_uri = g_strdup(loci->navinfo.requested_uri); g_free(window->actual_current_uri); - window->actual_current_uri = g_strdup(loci->actual_uri); + window->actual_current_uri = g_strdup(loci->navinfo.actual_uri); nautilus_navinfo_free(loci); } static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { nautilus_window_change_location(window, loc, requesting_view, FALSE); @@ -683,23 +704,26 @@ nautilus_window_load_state(NautilusWindow *window, const char *config_path) static void nautilus_window_back (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_prev); - uri = window->uris_prev->data; + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_prev->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, uri, NULL, TRUE); + nautilus_window_change_location(window, &nri, NULL, TRUE); } static void nautilus_window_fwd (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_next); - uri = window->uris_next->data; - - nautilus_window_change_location(window, uri, NULL, FALSE); + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_next->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; + nautilus_window_change_location(window, &nri, NULL, FALSE); } diff --git a/src/nautilus-window.h b/src/nautilus-window.h index d69ecabfe..7f637097a 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -19,9 +19,12 @@ typedef struct { GnomeAppClass *parent_class; void (* request_location_change)(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); - guint window_signals[1]; + void (* request_selection_change)(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); + guint window_signals[2]; } NautilusWindowClass; struct _NautilusWindow { @@ -42,8 +45,11 @@ struct _NautilusWindow { GtkType nautilus_window_get_type(void); GtkWidget *nautilus_window_new(const char *app_id); void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); +void nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); void nautilus_window_set_initial_state(NautilusWindow *window); diff --git a/src/ntl-meta-view.c b/src/ntl-meta-view.c index 3676f21e4..cd4d6ac63 100644 --- a/src/ntl-meta-view.c +++ b/src/ntl-meta-view.c @@ -50,5 +50,36 @@ nautilus_meta_view_new(void) const char * nautilus_meta_view_get_description(NautilusMetaView *nview) { - return NULL; + NautilusView *view = NAUTILUS_VIEW(nview); + GnomePropertyBagClient *bc; + GNOME_Property prop; + CORBA_Environment ev; + char *retval = NULL; + CORBA_any *anyval; + + g_return_val_if_fail(view->client, NULL); + + bc = gnome_control_frame_get_control_property_bag(gnome_bonobo_widget_get_control_frame(GNOME_BONOBO_WIDGET(view->client))); + g_return_val_if_fail(bc, NULL); + + prop = gnome_property_bag_client_get_property(bc, "description"); + CORBA_exception_init(&ev); + + if(CORBA_Object_is_nil(prop, &ev)) + goto out; + + anyval = GNOME_Property_get_value(prop, &ev); + if(ev._major != CORBA_NO_EXCEPTION) + goto out; + + if(!CORBA_TypeCode_equal(anyval->_type, TC_string, &ev)) + goto out; + + retval = g_strdup(*(CORBA_char **)anyval->_value); + + CORBA_free(anyval); + + out: + CORBA_exception_free(&ev); + return retval; } diff --git a/src/ntl-types.h b/src/ntl-types.h index f712448d9..5ee6ec984 100644 --- a/src/ntl-types.h +++ b/src/ntl-types.h @@ -2,13 +2,13 @@ #define NTL_TYPES_H 1 #include <gtk/gtk.h> +#include <libnautilus/libnautilus.h> typedef char *NautilusLocationReference; typedef struct { - NautilusLocationReference requested_uri, actual_uri; - NautilusLocationReference referring_uri, actual_referring_uri; - char *content_type, *referring_content_type; + Nautilus_NavigationInfo navinfo; + GtkWidget *requesting_view; char *content_iid; diff --git a/src/ntl-uri-map.c b/src/ntl-uri-map.c index b2c4a94ba..b65fd8049 100644 --- a/src/ntl-uri-map.c +++ b/src/ntl-uri-map.c @@ -2,15 +2,21 @@ #include <libgnorba/gnorba.h> NautilusNavigationInfo * -nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri, +nautilus_navinfo_new(NautilusNavigationInfo *navinfo, + Nautilus_NavigationRequestInfo *nri, NautilusLocationReference referring_uri, NautilusLocationReference actual_referring_uri, - const char *referring_content_type) + const char *referring_content_type, + GtkWidget *requesting_view) { - navinfo->requested_uri = uri; - navinfo->referring_uri = referring_uri; - navinfo->actual_referring_uri = actual_referring_uri; - navinfo->referring_content_type = (char *)referring_content_type; + memset(navinfo, 0, sizeof(*navinfo)); + + navinfo->navinfo.requested_uri = nri->requested_uri; + navinfo->navinfo.referring_uri = referring_uri; + navinfo->navinfo.actual_referring_uri = actual_referring_uri; + navinfo->navinfo.referring_content_type = (char *)referring_content_type; + + navinfo->requesting_view = requesting_view; /* XXX turn the provided information into some activateable IID's */ diff --git a/src/ntl-uri-map.h b/src/ntl-uri-map.h index d01e0c617..8c1b9b377 100644 --- a/src/ntl-uri-map.h +++ b/src/ntl-uri-map.h @@ -3,10 +3,12 @@ #include "ntl-types.h" -NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri, +NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo, + Nautilus_NavigationRequestInfo *nri, NautilusLocationReference referring_uri, NautilusLocationReference actual_referring_uri, - const char *referring_content_type); + const char *referring_content_type, + GtkWidget *requesting_view); void nautilus_navinfo_free(NautilusNavigationInfo *navinfo); #endif diff --git a/src/ntl-view.c b/src/ntl-view.c index aa180e5a4..117f94e58 100644 --- a/src/ntl-view.c +++ b/src/ntl-view.c @@ -23,15 +23,98 @@ #include "ntl-window.h" enum { - NOTIFY_LOCATION_CHANGE, - LAST_SIGNAL + NOTIFY_LOCATION_CHANGE, + LAST_SIGNAL }; enum { - ARG_0, - ARG_MAIN_WINDOW + ARG_0, + ARG_MAIN_WINDOW }; +typedef struct { + POA_Nautilus_ViewFrame servant; + gpointer gnome_object; + + NautilusView *view; +} impl_POA_Nautilus_ViewFrame; + +static void +impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_NavigationRequestInfo * navinfo, + CORBA_Environment * ev); + +static void +impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_SelectionRequestInfo * selinfo, + CORBA_Environment * ev); + +static POA_Nautilus_ViewFrame__epv impl_Nautilus_ViewFrame_epv = +{ + NULL, /* _private */ + (void(*))&impl_Nautilus_ViewFrame_request_location_change, + (void(*))&impl_Nautilus_ViewFrame_request_selection_change +}; + +static POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv = +{ + &gnome_object_base_epv, + &gnome_object_epv, + &impl_Nautilus_ViewFrame_epv +}; + +static void +impl_Nautilus_ViewFrame__destroy(GnomeObject *obj, impl_POA_Nautilus_ViewFrame *servant) +{ + PortableServer_ObjectId *objid; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); + PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); + CORBA_free(objid); + obj->servant = NULL; + + POA_Nautilus_ViewFrame__fini((PortableServer_Servant) servant, &ev); + g_free(servant); + CORBA_exception_free(&ev); +} + +static GnomeObject * +impl_Nautilus_ViewFrame__create(NautilusView *view, CORBA_Environment * ev) +{ + GnomeObject *retval; + impl_POA_Nautilus_ViewFrame *newservant; + + newservant = g_new0(impl_POA_Nautilus_ViewFrame, 1); + newservant->servant.vepv = &impl_Nautilus_ViewFrame_vepv; + newservant->view = view; + POA_Nautilus_ViewFrame__init((PortableServer_Servant) newservant, ev); + + retval = gnome_object_new_from_servant(newservant); + + gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_ViewFrame__destroy), newservant); + + return retval; +} + +static void +impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_NavigationRequestInfo * navinfo, + CORBA_Environment * ev) +{ + nautilus_view_request_location_change(servant->view, navinfo); +} + +static void +impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant, + Nautilus_SelectionRequestInfo * selinfo, + CORBA_Environment * ev) +{ + nautilus_view_request_selection_change(servant->view, selinfo); +} + static void nautilus_view_init (NautilusView *view); static void nautilus_view_constructed(NautilusView *view); static void nautilus_view_class_init (NautilusViewClass *klass); @@ -45,7 +128,13 @@ static void nautilus_view_size_request (GtkWidget *widget, GtkRequisition *requisition); static void nautilus_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation); - +static void nautilus_view_notify_location_change(NautilusView *view, + Nautilus_NavigationInfo *nav_context); +static void nautilus_view_notify_selection_change(NautilusView *view, + Nautilus_SelectionInfo *nav_context); +static void nautilus_view_load_state(NautilusView *view, const char *config_path); +static void nautilus_view_save_state(NautilusView *view, const char *config_path); +static void nautilus_view_show_properties(NautilusView *view); GtkType nautilus_view_get_type (void) @@ -70,6 +159,7 @@ nautilus_view_get_type (void) return view_type; } +#if 0 typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object, gpointer arg1, GtkObject *arg2, @@ -89,6 +179,7 @@ gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object, GTK_VALUE_BOXED (args[2]), func_data); } +#endif static void nautilus_view_class_init (NautilusViewClass *klass) @@ -109,14 +200,19 @@ nautilus_view_class_init (NautilusViewClass *klass) klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); klass->view_constructed = nautilus_view_constructed; + klass->notify_location_change = nautilus_view_notify_location_change; + klass->notify_selection_change = nautilus_view_notify_selection_change; + klass->load_state = nautilus_view_load_state; + klass->save_state = nautilus_view_save_state; + klass->show_properties = nautilus_view_show_properties; i = 0; klass->view_signals[i++] = gtk_signal_new("notify_location_change", GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusViewClass, notify_location_change), - gtk_marshal_NONE__BOXED_OBJECT_BOXED, - GTK_TYPE_NONE, 3, GTK_TYPE_BOXED, GTK_TYPE_OBJECT, GTK_TYPE_BOXED); + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); klass->view_signals[i++] = gtk_signal_new("load_state", GTK_RUN_LAST, object_class->type, @@ -135,6 +231,12 @@ nautilus_view_class_init (NautilusViewClass *klass) GTK_SIGNAL_OFFSET (NautilusViewClass, show_properties), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + klass->view_signals[i++] = gtk_signal_new("notify_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusViewClass, notify_selection_change), + gtk_marshal_NONE__BOXED, + GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); gtk_object_class_add_signals (object_class, klass->view_signals, i); gtk_object_add_arg_type ("NautilusView::main_window", @@ -175,7 +277,12 @@ nautilus_view_get_arg (GtkObject *object, static void nautilus_view_init (NautilusView *view) { + CORBA_Environment ev; GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); + + CORBA_exception_init(&ev); + view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); + CORBA_exception_free(&ev); } static void @@ -202,7 +309,7 @@ nautilus_view_construct_arg_set(NautilusView *view) void nautilus_view_request_location_change(NautilusView *view, - NautilusLocationReference loc) + Nautilus_NavigationRequestInfo *loc) { g_return_if_fail (view != NULL); g_return_if_fail (NAUTILUS_IS_VIEW (view)); @@ -211,6 +318,13 @@ nautilus_view_request_location_change(NautilusView *view, nautilus_window_request_location_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view)); } +void +nautilus_view_request_selection_change (NautilusView *view, + Nautilus_SelectionRequestInfo *loc) +{ + nautilus_window_request_selection_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view)); +} + static void nautilus_view_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -247,10 +361,24 @@ nautilus_view_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (bin->child, &child_allocation); } +static void +nautilus_view_activate_uri(GnomeControlFrame *frame, const char *uri, gboolean relative, NautilusView *view) +{ + Nautilus_NavigationRequestInfo nri; + g_assert(!relative); + + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = (char *)uri; + nautilus_view_request_location_change(view, &nri); +} + void nautilus_view_load_client(NautilusView *view, const char * iid) { + GnomeControlFrame *frame; + CORBA_Environment ev; + if(view->client) { g_free(view->iid); view->iid = NULL; @@ -259,7 +387,82 @@ nautilus_view_load_client(NautilusView *view, view->client = gnome_bonobo_widget_new_control((char *)iid); g_return_if_fail(view->client); + CORBA_exception_init(&ev); + CORBA_Object_release(view->view_client, &ev); + frame = gnome_bonobo_widget_get_control_frame(GNOME_BONOBO_WIDGET(view->client)); + gnome_object_add_interface(GNOME_OBJECT(frame), view->view_frame); + view->view_client = GNOME_Unknown_query_interface(gnome_control_frame_get_control(GNOME_CONTROL_FRAME(frame)), + "IDL:Nautilus/View:1.0", &ev); + if(ev._major != CORBA_NO_EXCEPTION) + view->view_client = CORBA_OBJECT_NIL; view->iid = g_strdup(iid); + + gtk_signal_connect(GTK_OBJECT(frame), "activate_uri", GTK_SIGNAL_FUNC(nautilus_view_activate_uri), view); gtk_widget_show(view->client); gtk_container_add(GTK_CONTAINER(view), view->client); + CORBA_exception_free(&ev); } + +static void +nautilus_view_notify_location_change(NautilusView *view, + Nautilus_NavigationInfo *nav_context) +{ + CORBA_Environment ev; + + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_notify_location_change(view->view_client, nav_context, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_notify_selection_change(NautilusView *view, + Nautilus_SelectionInfo *nav_context) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_notify_selection_change(view->view_client, nav_context, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_load_state(NautilusView *view, const char *config_path) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_load_state(view->view_client, (char *)config_path, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_save_state(NautilusView *view, const char *config_path) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_save_state(view->view_client, (char *)config_path, &ev); + + CORBA_exception_free(&ev); +} + +static void +nautilus_view_show_properties(NautilusView *view) +{ + CORBA_Environment ev; + CORBA_exception_init(&ev); + g_return_if_fail(!CORBA_Object_is_nil(view->view_client, &ev)); + + Nautilus_View_show_properties(view->view_client, &ev); + + CORBA_exception_free(&ev); +} + diff --git a/src/ntl-view.h b/src/ntl-view.h index 3581b6cf3..87050b5a0 100644 --- a/src/ntl-view.h +++ b/src/ntl-view.h @@ -42,7 +42,9 @@ struct _NautilusViewClass GtkBinClass parent_spot; void (*notify_location_change) (NautilusView *view, - NautilusNavigationInfo *nav_context); + Nautilus_NavigationInfo *nav_context); + void (*notify_selection_change) (NautilusView *view, + Nautilus_SelectionInfo *nav_context); void (*load_state) (NautilusView *view, const char *config_path); void (*save_state) (NautilusView *view, const char *config_path); void (*show_properties) (NautilusView *view); @@ -50,7 +52,7 @@ struct _NautilusViewClass void (*view_constructed) (NautilusView *view); /* Not a signal. Work-around for Gtk+'s lack of a 'constructed' operation */ GtkBinClass *parent_class; - guint view_signals[3]; + guint view_signals[6]; guint num_construct_args; }; @@ -62,13 +64,18 @@ struct _NautilusView char *iid; GtkWidget *client; + CORBA_Object view_client; + + GnomeObject *view_frame; guint construct_arg_count; }; GtkType nautilus_view_get_type (void); void nautilus_view_request_location_change (NautilusView *view, - NautilusLocationReference loc); + Nautilus_NavigationRequestInfo *loc); +void nautilus_view_request_selection_change (NautilusView *view, + Nautilus_SelectionRequestInfo *loc); void nautilus_view_load_client (NautilusView *view, const char * iid); diff --git a/src/ntl-window.c b/src/ntl-window.c index 62e824628..ab0e4a1a8 100644 --- a/src/ntl-window.c +++ b/src/ntl-window.c @@ -16,7 +16,7 @@ static void nautilus_window_get_arg (GtkObject *object, static void nautilus_window_close (GtkWidget *widget, GtkWidget *window); static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); #define CONTENTS_AS_HBOX @@ -44,20 +44,20 @@ nautilus_window_get_type(void) return window_type; } -typedef void (*GtkSignal_NONE__STRING_OBJECT) (GtkObject * object, - const char *arg1, +typedef void (*GtkSignal_NONE__BOXED_OBJECT) (GtkObject * object, + gpointer arg1, GtkObject *arg2, gpointer user_data); static void -gtk_marshal_NONE__STRING_OBJECT (GtkObject * object, +gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object, GtkSignalFunc func, gpointer func_data, GtkArg * args) { - GtkSignal_NONE__STRING_OBJECT rfunc; - rfunc = (GtkSignal_NONE__STRING_OBJECT) func; + GtkSignal_NONE__BOXED_OBJECT rfunc; + rfunc = (GtkSignal_NONE__BOXED_OBJECT) func; (*rfunc) (object, - GTK_VALUE_STRING (args[0]), + GTK_VALUE_BOXED (args[0]), GTK_VALUE_OBJECT (args[1]), func_data); } @@ -90,8 +90,14 @@ nautilus_window_class_init (NautilusWindowClass *klass) GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusWindowClass, request_location_change), - gtk_marshal_NONE__STRING_OBJECT, - GTK_TYPE_NONE, 2, GTK_TYPE_STRING, GTK_TYPE_OBJECT); + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); + klass->window_signals[i++] = gtk_signal_new("request_selection_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusWindowClass, request_selection_change), + gtk_marshal_NONE__BOXED_OBJECT, + GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_OBJECT); gtk_object_class_add_signals (object_class, klass->window_signals, i); gtk_object_add_arg_type ("NautilusWindow::app_id", @@ -415,8 +421,22 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view } void +nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view) +{ + NautilusWindowClass *klass; + GtkObject *obj; + + obj = GTK_OBJECT(window); + + klass = NAUTILUS_WINDOW_CLASS(obj->klass); + gtk_signal_emit(obj, klass->window_signals[1], loc, requesting_view); +} + +void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { NautilusWindowClass *klass; @@ -430,7 +450,7 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view, gboolean is_back) { @@ -440,12 +460,13 @@ nautilus_window_change_location(NautilusWindow *window, NautilusNavigationInfo loci_spot, *loci; - loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type); + loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type, + requesting_view); if(!loci) { char cbuf[1024]; - g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc); + g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc->requested_uri); nautilus_window_set_status(window, cbuf); return; } @@ -459,14 +480,14 @@ nautilus_window_change_location(NautilusWindow *window, else { char *append_val; - if(window->uris_next && !strcmp(loc, window->uris_next->data)) + if(window->uris_next && !strcmp(loc->requested_uri, window->uris_next->data)) { append_val = window->uris_next->data; window->uris_next = g_slist_remove(window->uris_next, window->uris_next->data); } else { - append_val = g_strdup(loc); + append_val = g_strdup(loc->requested_uri); g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); g_slist_free(window->uris_next); window->uris_next = NULL; } @@ -514,18 +535,18 @@ nautilus_window_change_location(NautilusWindow *window, g_slist_free(discard_views); g_free(window->current_content_type); - window->current_content_type = g_strdup(loci->content_type); + window->current_content_type = g_strdup(loci->navinfo.content_type); g_free(window->current_uri); - window->current_uri = g_strdup(loci->requested_uri); + window->current_uri = g_strdup(loci->navinfo.requested_uri); g_free(window->actual_current_uri); - window->actual_current_uri = g_strdup(loci->actual_uri); + window->actual_current_uri = g_strdup(loci->navinfo.actual_uri); nautilus_navinfo_free(loci); } static void nautilus_window_real_request_location_change (NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view) { nautilus_window_change_location(window, loc, requesting_view, FALSE); @@ -683,23 +704,26 @@ nautilus_window_load_state(NautilusWindow *window, const char *config_path) static void nautilus_window_back (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_prev); - uri = window->uris_prev->data; + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_prev->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, uri, NULL, TRUE); + nautilus_window_change_location(window, &nri, NULL, TRUE); } static void nautilus_window_fwd (NautilusWindow *window) { - char *uri; + Nautilus_NavigationRequestInfo nri; g_assert(window->uris_next); - uri = window->uris_next->data; - - nautilus_window_change_location(window, uri, NULL, FALSE); + memset(&nri, 0, sizeof(nri)); + nri.requested_uri = window->uris_next->data; + nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; + nautilus_window_change_location(window, &nri, NULL, FALSE); } diff --git a/src/ntl-window.h b/src/ntl-window.h index d69ecabfe..7f637097a 100644 --- a/src/ntl-window.h +++ b/src/ntl-window.h @@ -19,9 +19,12 @@ typedef struct { GnomeAppClass *parent_class; void (* request_location_change)(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); - guint window_signals[1]; + void (* request_selection_change)(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); + guint window_signals[2]; } NautilusWindowClass; struct _NautilusWindow { @@ -42,8 +45,11 @@ struct _NautilusWindow { GtkType nautilus_window_get_type(void); GtkWidget *nautilus_window_new(const char *app_id); void nautilus_window_request_location_change(NautilusWindow *window, - NautilusLocationReference loc, + Nautilus_NavigationRequestInfo *loc, GtkWidget *requesting_view); +void nautilus_window_request_selection_change(NautilusWindow *window, + Nautilus_SelectionRequestInfo *loc, + GtkWidget *requesting_view); void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); void nautilus_window_set_initial_state(NautilusWindow *window); |