Commit 1d23907d authored by Elliot Lee's avatar Elliot Lee

Implement libnautilus.



Implement libnautilus.

Normalize the way requests and notifications are passed around.
parent 44302b3c
SUBDIRS=src
SUBDIRS=libnautilus src
......@@ -40,5 +40,6 @@ AC_C_CONST
AC_OUTPUT([
Makefile
libnautilus/Makefile
src/Makefile
])
Factors that influence how a URL will be displayed:
In a new window or not
\ No newline at end of file
#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);
};
};
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
#ifndef LIBNAUTILUS_H
#define LIBNAUTILUS_H 1
#include <bonobo/gnome-bonobo.h>
#include <libnautilus/nautilus.h>
#include <libnautilus/ntl-view-client.h>
#endif
/* 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);
}
#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
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
#ifndef LIBNAUTILUS_H
#define LIBNAUTILUS_H 1
#include <bonobo/gnome-bonobo.h>
#include <libnautilus/nautilus.h>
#include <libnautilus/ntl-view-client.h>
#endif
/* 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,