gnuymeric bonobo component
- From: Mathieu Lacage <mathieu eazel com>
- To: gnumeric-list gnome org
- Subject: gnuymeric bonobo component
- Date: 08 Nov 2000 19:23:17 -0800
hi all,
With jody's magic help, I succeeded at getting a
gnumeric component working:
http://le-hacker.org/shots/nautilus-gnumeric.png
If you want, you can play with the folowing patch.
The current component will not do much: it just displays...
you cannot edit anything, and it does not merge toolbars/menus....
It is also a gross hack. I feel ashamed.
Mathieu
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gnumeric/Makefile.am,v
retrieving revision 1.51
diff -u -r1.51 Makefile.am
--- Makefile.am 2000/10/16 02:56:45 1.51
+++ Makefile.am 2000/11/08 22:58:16
@@ -43,7 +43,7 @@
Applications_DATA = gnumeric.desktop
Mimedir = $(datadir)/mime-info
-Mime_DATA = gnumeric.keys gnumeric.mime
+Mime_DATA = gnumeric.keys gnumeric.mime gnumeric-vfs.keys
gnewdir = $(datadir)/mc/templates
gnew_DATA = gnumeric.desktop
Index: gnumeric.oafinfo
===================================================================
RCS file: /cvs/gnome/gnumeric/gnumeric.oafinfo,v
retrieving revision 1.6
diff -u -r1.6 gnumeric.oafinfo
--- gnumeric.oafinfo 2000/10/04 16:41:56 1.6
+++ gnumeric.oafinfo 2000/11/08 22:58:16
@@ -25,28 +25,37 @@
value="Workbook component"/>
</oaf_server>
- <oaf_server iid="OAFIID:GNOME:Gnumeric:GridFactory:1.0:a1c2ad1c-33bd-4c42-b5d1-9a454f862873"
+ <oaf_server iid="OAFIID:gnumeric-component-factory:2000-11-07"
type="exe"
- location="gnumeric-bonobo">
+ location="gnumeric-component">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/GenericFactory:1.0"/>
</oaf_attribute>
<oaf_attribute name="description" type="string"
- value="Embeddable Grid Component Factory"/>
+ value="Gnumeric Component Factory"/>
</oaf_server>
- <oaf_server iid="OAFIID:GNOME:Gnumeric:Grid:1.0:872b76ec-a9c7-4848-aa9e-c0c60b27d446"
+ <oaf_server iid="OAFIID:gnumeric-component:2000-11-07"
type="factory"
- location="OAFIID:GNOME:Gnumeric:GridFactory:1.0:a1c2ad1c-33bd-4c42-b5d1-9a454f862873">
+ location="OAFIID:gnumeric-component-factory:2000-11-07">
<oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Gnumeric/Grid"/>
- <item value="IDL:Bonobo/Embeddable:1.0"/>
+ <item value="IDL:Bonobo/Control:1.0"/>
+ <item value="IDL:Bonobo/PersistStream:1.0"/>
+ <item value="IDL:Bonobo/Persist:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
+ <oaf_attribute name="bonobo:supported_mime_types" type="stringv">
+ <item value="application/x-gnumeric"/>
+ </oaf_attribute>
+
+
+ <oaf_attribute name="nautilus:view_as_name" type="string" value="Spreadsheet"/>
+
<oaf_attribute name="description" type="string"
- value="Embeddable Grid Component"/>
+ value="Gnumeric Component"/>
</oaf_server>
</oaf_info>
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnumeric/src/Makefile.am,v
retrieving revision 1.212
diff -u -r1.212 Makefile.am
--- src/Makefile.am 2000/10/31 16:17:30 1.212
+++ src/Makefile.am 2000/11/08 22:58:16
@@ -15,10 +15,10 @@
SUBDIRS = dialogs functions widgets
if BONOBO
-bin_PROGRAMS = gnumeric-bonobo
+bin_PROGRAMS = gnumeric-component
CLEANFILES += gnumeric
else
-bin_PROGRAMS = gnumeric
+bin_PROGRAMS = gnumeric gnumeric-bonobo
CLEANFILES +=gnumeric-bonobo
endif
@@ -260,6 +260,15 @@
$(GNUMERIC_BASE_SOURCES) \
$(GNUMERIC_BONOBO_SOURCES)
+gnumeric_component_SOURCES = \
+ gnumeric-component.c \
+ corba-args.c \
+ main.c \
+ $(GNUMERIC_BASE_SOURCES) \
+ $(GNUMERIC_BONOBO_SOURCES)
+
+
+
gnumeric_LDFLAGS = -export-dynamic
gnumeric_libs = \
@@ -277,6 +286,16 @@
# $(PSPELL_LIBS)
gnumeric_bonobo_LDADD = \
+ $(gnumeric_libs) \
+ -lbonobo-print \
+ ../idl/libGnumericIDL.a \
+ $(EXTRA_GNOME_LIBS) \
+ $(GNOME_XML_LIB) \
+ $(GUILE_LIBS) \
+ $(PSPELL_LIBS) \
+ $(INTLLIBS)
+
+gnumeric_component_LDADD = \
$(gnumeric_libs) \
-lbonobo-print \
../idl/libGnumericIDL.a \
Index: src/gnumeric-component.c
===================================================================
RCS file: gnumeric-component.c
diff -N gnumeric-component.c
--- /dev/null Tue May 5 16:32:27 1998
+++ gnumeric-component.c Wed Nov 8 17:58:16 2000
@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
+
+#include <config.h>
+#include <gnome.h>
+#include <liboaf/liboaf.h>
+#include <bonobo.h>
+#include "workbook-control-gui.h"
+#include "workbook.h"
+#include "workbook-view.h"
+#include "main.h"
+
+
+static int
+open_cb (BonoboPersistFile *pf,
+ const CORBA_char *filename,
+ CORBA_Environment *ev,
+ void *closure)
+{
+ WorkbookControl *workbook_control;
+ WorkbookView *workbook_view;
+
+ g_assert (IS_WORKBOOK_CONTROL (closure));
+ workbook_control = (WorkbookControl *) closure;
+
+ workbook_view = workbook_read (WORKBOOK_CONTROL (workbook_control), filename);
+
+ return 0;
+}
+
+static int
+close_cb (BonoboPersistFile *pf,
+ const CORBA_char *filename,
+ CORBA_Environment *ev,
+ void *closure)
+{
+
+
+ return 0;
+}
+
+
+
+/* stupid very simple factory */
+static BonoboObject *
+gnumeric_control_factory (BonoboGenericFactory *Factory, void *closure)
+{
+ static BonoboControl *control = NULL;
+ BonoboPersistFile *persist_file;
+ WorkbookControl *workbook_control;
+ GtkWidget *sheet;
+
+ workbook_control = workbook_control_gui_new (NULL, workbook_new ());
+ sheet = wb_control_gui_table (WORKBOOK_CONTROL_GUI (workbook_control));
+ gtk_widget_show (sheet);
+
+ control = bonobo_control_new (sheet);
+
+ persist_file = bonobo_persist_file_new (open_cb, close_cb, workbook_control);
+
+ bonobo_object_add_interface (BONOBO_OBJECT (control),
+ BONOBO_OBJECT (persist_file));
+
+ return BONOBO_OBJECT (control);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ static BonoboGenericFactory *gnumeric_component_factory = NULL;
+ CORBA_Environment ev;
+ CORBA_ORB orb;
+
+ CORBA_exception_init (&ev);
+
+ if (gnumeric_component_factory != NULL)
+ return 0;
+
+ gnumeric_init (0, argc, argv);
+
+ gnumeric_component_factory =
+ bonobo_generic_factory_new ("OAFIID:gnumeric-component-factory:2000-11-07",
+ gnumeric_control_factory, NULL);
+
+ gnumeric_main ();
+
+ gnumeric_shutdown ();
+
+ return 0;
+}
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/main.c,v
retrieving revision 1.116
diff -u -r1.116 main.c
--- src/main.c 2000/10/31 16:17:31 1.116
+++ src/main.c 2000/11/08 22:58:16
@@ -6,6 +6,9 @@
* Author:
* Miguel de Icaza (miguel gnu org)
*/
+
+#define MATHIEU_HACK 0
+
#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -139,8 +142,11 @@
* FIXME: We hardcode the GUI command context. Change once we are able
* to tell whether we are in GUI or not.
*/
-static void
-gnumeric_main (void *closure, int argc, char *argv [])
+static void test (void) {}
+
+
+void
+gnumeric_init (void *closure, int argc, char *argv [])
{
gboolean opened_workbook = FALSE;
int i;
@@ -242,9 +248,19 @@
#ifdef ENABLE_BONOBO
bonobo_activate ();
#endif
- gtk_main ();
+
}
+}
+
+void
+gnumeric_main (void)
+{
+ gtk_main ();
+}
+void
+gnumeric_shutdown (void)
+{
excel_shutdown ();
print_shutdown ();
auto_format_shutdown ();
@@ -256,6 +272,7 @@
global_gnome_font_shutdown ();
gnome_config_drop_all ();
+
}
#ifdef HAVE_GUILE
@@ -307,10 +324,19 @@
return FALSE;
}
+#if MATHIEU_HACK
int
main (int argc, char *argv [])
{
- gnumeric_main (0, argc, argv);
+ gnumeric_init (0, argc, argv);
+
+ gnumeric_main ();
+
+ gnumeric_shutdown ();
+
return 0;
}
#endif
+#endif
+
+
Index: src/main.h
===================================================================
RCS file: /cvs/gnome/gnumeric/src/main.h,v
retrieving revision 1.11
diff -u -r1.11 main.h
--- src/main.h 2000/10/31 16:17:31 1.11
+++ src/main.h 2000/11/08 22:58:16
@@ -12,6 +12,11 @@
void gnumeric_arg_parse (int argc, char *argv []);
+
+void gnumeric_init (void *closure, int argc, char *argv []);
+void gnumeric_main (void);
+void gnumeric_shutdown (void);
+
/*
* A necessary bogosity that is required to avoid bug #7948 with current
* versions of guile
Index: src/workbook-control-gui.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/workbook-control-gui.c,v
retrieving revision 1.14
diff -u -r1.14 workbook-control-gui.c
--- src/workbook-control-gui.c 2000/11/02 19:39:19 1.14
+++ src/workbook-control-gui.c 2000/11/08 22:58:17
@@ -61,6 +61,12 @@
#include "pixmaps/equal-sign.xpm"
+GtkWidget *
+wb_control_gui_table (WorkbookControlGUI *wbcg)
+{
+ return wbcg->table;
+}
+
GtkWindow *
wb_control_gui_toplevel (WorkbookControlGUI *wbcg)
{
@@ -88,8 +94,10 @@
g_return_val_if_fail (sheet_view != NULL, NULL);
- gtk_window_set_focus (sheet_view->wbcg->toplevel,
- sheet_view->canvas);
+ if (wbcg->toplevel != NULL) {
+ gtk_window_set_focus (sheet_view->wbcg->toplevel,
+ sheet_view->canvas);
+ }
return sheet_view->sheet;
}
@@ -110,8 +118,9 @@
g_return_if_fail (title != NULL);
full_title = g_strconcat (title, _(" : Gnumeric"), NULL);
-
- gtk_window_set_title (wbcg->toplevel, full_title);
+ if (wbcg->toplevel != NULL) {
+ gtk_window_set_title (wbcg->toplevel, full_title);
+ }
g_free (full_title);
}
@@ -123,9 +132,11 @@
int const screen_height = gdk_screen_height ();
/* FIXME : This should really be sizing the notebook */
- gtk_window_set_default_size (wbcg->toplevel,
- MIN (screen_width - 64, width),
- MIN (screen_height - 64, height));
+ if (wbcg->toplevel != NULL) {
+ gtk_window_set_default_size (wbcg->toplevel,
+ MIN (screen_width - 64, width),
+ MIN (screen_height - 64, height));
+ }
}
static void
@@ -452,10 +463,12 @@
sheet_view = sheet_new_sheet_view (sheet);
sheet_view->wbcg = wbcg;
- gtk_signal_connect (
- GTK_OBJECT (sheet_view->canvas), "destroy",
- GTK_SIGNAL_FUNC (yield_focus),
- wbcg->toplevel);
+ if (wbcg->toplevel != NULL) {
+ gtk_signal_connect (
+ GTK_OBJECT (sheet_view->canvas), "destroy",
+ GTK_SIGNAL_FUNC (yield_focus),
+ wbcg->toplevel);
+ }
/*
* NB. this is so we can use editable_label_set_text since
@@ -665,10 +678,11 @@
gtk_widget_set_sensitive (menu_item, sensitive);
#else
CORBA_exception_init (&ev);
-
+ /*
bonobo_ui_component_set_prop (wbcg->uic, verb_path,
"sensitive", sensitive ? "1" : "0", &ev);
bonobo_ui_component_set_prop (wbcg->uic, menu_path, "label", text, &ev);
+ */
CORBA_exception_free (&ev);
#endif
g_free (text);
@@ -715,9 +729,14 @@
wbcg_claim_selection (WorkbookControl *wbc)
{
WorkbookControlGUI *wbcg = (WorkbookControlGUI *)wbc;
- return gtk_selection_owner_set (GTK_WIDGET (wbcg->toplevel),
- GDK_SELECTION_PRIMARY,
- GDK_CURRENT_TIME);
+ if (wbcg->toplevel != NULL) {
+ return gtk_selection_owner_set (GTK_WIDGET (wbcg->toplevel),
+ GDK_SELECTION_PRIMARY,
+ GDK_CURRENT_TIME);
+ } else {
+ return FALSE;
+ }
+
}
static void
@@ -1578,7 +1597,9 @@
static void
cb_dump_xml (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
- bonobo_window_dump (BONOBO_WINDOW(wbcg->toplevel), "on demand");
+ if (wbcg->toplevel != NULL) {
+ bonobo_window_dump (BONOBO_WINDOW(wbcg->toplevel), "on demand");
+ }
}
#endif
@@ -2474,9 +2495,11 @@
GtkSignalFunc func, char const *pixmap)
{
GtkWidget *button = gtk_button_new ();
- GtkWidget *pix = gnome_stock_pixmap_widget_new (
- GTK_WIDGET (wbcg->toplevel), pixmap);
- gtk_container_add (GTK_CONTAINER (button), pix);
+ if (wbcg->toplevel != NULL) {
+ GtkWidget *pix = gnome_stock_pixmap_widget_new (
+ GTK_WIDGET (wbcg->toplevel), pixmap);
+ gtk_container_add (GTK_CONTAINER (button), pix);
+ }
if (!sensitive)
gtk_widget_set_sensitive (button, FALSE);
GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
@@ -2623,16 +2646,20 @@
gtk_signal_disconnect_by_func (
GTK_OBJECT (wbcg->notebook),
GTK_SIGNAL_FUNC (cb_notebook_switch_page), wbcg);
- gtk_signal_disconnect_by_func (
- GTK_OBJECT (wbcg->toplevel),
- GTK_SIGNAL_FUNC (wbcg_set_focus), wbcg);
+ if (wbcg->toplevel != NULL) {
+ gtk_signal_disconnect_by_func (
+ GTK_OBJECT (wbcg->toplevel),
+ GTK_SIGNAL_FUNC (wbcg_set_focus), wbcg);
+ }
workbook_auto_complete_destroy (wbcg);
- gtk_window_set_focus (GTK_WINDOW (wbcg->toplevel), NULL);
+ if (wbcg->toplevel != NULL) {
+ gtk_window_set_focus (GTK_WINDOW (wbcg->toplevel), NULL);
- if (!GTK_OBJECT_DESTROYED (GTK_OBJECT (wbcg->toplevel)))
- gtk_object_destroy (GTK_OBJECT (wbcg->toplevel));
+ if (!GTK_OBJECT_DESTROYED (GTK_OBJECT (wbcg->toplevel)))
+ gtk_object_destroy (GTK_OBJECT (wbcg->toplevel));
+ }
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
}
@@ -2864,7 +2891,8 @@
void
workbook_control_gui_init (WorkbookControlGUI *wbcg,
- WorkbookView *optional_view, Workbook *optional_wb)
+ WorkbookView *optional_view, Workbook *optional_wb,
+ gboolean is_toplevel_window)
{
int sx, sy;
@@ -2874,11 +2902,15 @@
GtkWidget *tmp;
#ifdef ENABLE_BONOBO
- tmp = bonobo_window_new ("Gnumeric", "Gnumeric");
+ if (is_toplevel_window) {
+ wbcg->toplevel = GTK_WINDOW (bonobo_window_new ("Gnumeric", "Gnumeric"));
+ } else {
+ wbcg->toplevel = NULL;
+ }
#else
- tmp = gnome_app_new ("Gnumeric", "Gnumeric");
+ wbcg->toplevel = GTK_WINDOW (gnome_app_new ("Gnumeric", "Gnumeric"));
#endif
- wbcg->toplevel = GTK_WINDOW (tmp);
+
wbcg->table = gtk_table_new (0, 0, 0);
wbcg->notebook = NULL;
@@ -2901,12 +2933,15 @@
wbcg->menu_item_redo = workbook_menu_edit[1].widget;
wbcg->menu_item_paste_special = workbook_menu_edit[6].widget;
#else
- bonobo_window_set_contents (BONOBO_WINDOW (wbcg->toplevel), wbcg->table);
+ ui_container = bonobo_ui_container_new ();
+ if (is_toplevel_window && wbcg->toplevel != NULL) {
+ bonobo_window_set_contents (BONOBO_WINDOW (wbcg->toplevel), wbcg->table);
+ bonobo_ui_container_set_win (ui_container, BONOBO_WINDOW (wbcg->toplevel));
+ }
+
wbcg->uic = bonobo_ui_component_new_default ();
- ui_container = bonobo_ui_container_new ();
- bonobo_ui_container_set_win (ui_container, BONOBO_WINDOW (wbcg->toplevel));
bonobo_ui_component_set_container (
wbcg->uic, bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)));
@@ -2941,16 +2976,16 @@
wbcg->editing_sheet = NULL;
wbcg->editing_cell = NULL;
- gtk_signal_connect_after (
- GTK_OBJECT (wbcg->toplevel), "delete_event",
- GTK_SIGNAL_FUNC (wbcg_delete_event), wbcg);
- gtk_signal_connect_after (
- GTK_OBJECT (wbcg->toplevel), "set_focus",
- GTK_SIGNAL_FUNC (wbcg_set_focus), wbcg);
- gtk_signal_connect (GTK_OBJECT (wbcg->toplevel),
- "button-release-event",
- GTK_SIGNAL_FUNC (cb_scroll_wheel_support),
- wbcg);
+ if (is_toplevel_window && wbcg->toplevel != NULL) {
+ gtk_signal_connect_after (GTK_OBJECT (wbcg->toplevel), "delete_event",
+ GTK_SIGNAL_FUNC (wbcg_delete_event), wbcg);
+ gtk_signal_connect_after (GTK_OBJECT (wbcg->toplevel), "set_focus",
+ GTK_SIGNAL_FUNC (wbcg_set_focus), wbcg);
+ gtk_signal_connect (GTK_OBJECT (wbcg->toplevel),
+ "button-release-event",
+ GTK_SIGNAL_FUNC (cb_scroll_wheel_support),
+ wbcg);
+ }
#if 0
/* Enable toplevel as a drop target */
@@ -2966,14 +3001,16 @@
/* Now that everything is initialized set the size */
/* TODO : use gnome-config ? */
- gtk_window_set_policy (wbcg->toplevel, TRUE, TRUE, FALSE);
- sx = MAX (gdk_screen_width () - 64, 600);
- sy = MAX (gdk_screen_height () - 64, 200);
- sx = (sx * 3) / 4;
- sy = (sy * 3) / 4;
- wbcg_size_pixels_set (WORKBOOK_CONTROL (wbcg), sx, sy);
+ if (wbcg->toplevel != NULL) {
+ gtk_window_set_policy (wbcg->toplevel, TRUE, TRUE, FALSE);
+ sx = MAX (gdk_screen_width () - 64, 600);
+ sy = MAX (gdk_screen_height () - 64, 200);
+ sx = (sx * 3) / 4;
+ sy = (sy * 3) / 4;
+ wbcg_size_pixels_set (WORKBOOK_CONTROL (wbcg), sx, sy);
- gtk_widget_show_all (GTK_WIDGET (wbcg->toplevel));
+ gtk_widget_show_all (GTK_WIDGET (wbcg->toplevel));
+ }
}
static void
@@ -3032,7 +3069,7 @@
WorkbookControl *wbc;
wbcg = gtk_type_new (workbook_control_gui_get_type ());
- workbook_control_gui_init (wbcg, optional_view, wb);
+ workbook_control_gui_init (wbcg, optional_view, wb, FALSE);
wbc = WORKBOOK_CONTROL (wbcg);
g_return_val_if_fail (!wbcg->updating_ui, wbc);
Index: src/workbook-control-gui.h
===================================================================
RCS file: /cvs/gnome/gnumeric/src/workbook-control-gui.h,v
retrieving revision 1.3
diff -u -r1.3 workbook-control-gui.h
--- src/workbook-control-gui.h 2000/10/27 02:38:50 1.3
+++ src/workbook-control-gui.h 2000/11/08 22:58:17
@@ -17,9 +17,11 @@
Workbook *optional_wb);
void workbook_control_gui_init (WorkbookControlGUI *wbcg,
WorkbookView *optional_view,
- Workbook *optional_wb);
+ Workbook *optional_wb,
+ gboolean is_toplevel_window);
GtkWindow *wb_control_gui_toplevel (WorkbookControlGUI *wbcg);
+GtkWidget *wb_control_gui_table (WorkbookControlGUI *wbcg);
Sheet * wb_control_gui_focus_cur_sheet (WorkbookControlGUI *wbcg);
#endif /* GNUMERIC_WORKBOOK_CONTROL_GUI_H */
Index: src/workbook-control.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/workbook-control.c,v
retrieving revision 1.8
diff -u -r1.8 workbook-control.c
--- src/workbook-control.c 2000/11/01 17:12:47 1.8
+++ src/workbook-control.c 2000/11/08 22:58:17
@@ -189,6 +189,8 @@
g_return_if_fail (IS_WORKBOOK_CONTROL (wbc));
g_return_if_fail (wbc->wb_view == NULL);
+ g_print ("setting view\n");
+
wbc->wb_view = (optional_view != NULL) ? optional_view : workbook_view_new (optional_wb);
wb_view_attach_control (wbc);
}
--
Mathieu Lacage <mathieu eazel com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]