Commit 4380e1f8 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Finish implementing this routine for responding to monikers.

1999-08-19  Miguel de Icaza  <miguel@gnu.org>

	* src/workbook.c (workbook_container_get_object): Finish
	implementing this routine for responding to monikers.
	(create_graphic_cmd): temporarily bind this to
	Generic Bonobo object insertion.
	(cb_sheet_check_dirty): Make the dialog parent be the workbook
	window.

	* src/workbook.h (Workbook): Include a GnomeUIHandler.

	* src/sheet.c (sheet_insert_object): Enable this function again
	and update it to match the latest Bonobo developments.

	* src/sheet.h (Sheet): Include a pointer to the active object
	frame.

	* src/sheet-object.c (sheet_set_mode_type): Do deactivation of
	Bonobo frames here.

	*  src/gnumeric-sheet.c (gnumeric_drag_data_get): Beginning of
	drag and drop support for Bonobo monikers.

	* src/item-grid.c (drag_start): More DnD support for Gnumeric
	selections using Monikers.

	* src/sheet-object-container.c (user_activation_request_cb,
	view_activated_cb, get_file_name): New routines for dealing with
	the Bonobo object action in Gnumeric.

	(sheet_object_container_land): Do object selection here for now.
	Support both PersistStream and PersistFile

	* src/sheet-object.c:

	* src/workbook.c (cb_sheet_check_dirty): Bind the dialog to the
	main window.
parent 3bec7268
1999-08-19 Miguel de Icaza <miguel@gnu.org>
* src/workbook.c (workbook_container_get_object): Finish
implementing this routine for responding to monikers.
(create_graphic_cmd): temporarily bind this to
Generic Bonobo object insertion.
(cb_sheet_check_dirty): Make the dialog parent be the workbook
window.
* src/workbook.h (Workbook): Include a GnomeUIHandler.
* src/sheet.c (sheet_insert_object): Enable this function again
and update it to match the latest Bonobo developments.
* src/sheet.h (Sheet): Include a pointer to the active object
frame.
* src/sheet-object.c (sheet_set_mode_type): Do deactivation of
Bonobo frames here.
* src/gnumeric-sheet.c (gnumeric_drag_data_get): Beginning of
drag and drop support for Bonobo monikers.
* src/item-grid.c (drag_start): More DnD support for Gnumeric
selections using Monikers.
* src/sheet-object-container.c (user_activation_request_cb,
view_activated_cb, get_file_name): New routines for dealing with
the Bonobo object action in Gnumeric.
(sheet_object_container_land): Do object selection here for now.
Support both PersistStream and PersistFile
* src/sheet-object.c:
* src/workbook.c (cb_sheet_check_dirty): Bind the dialog to the
main window.
1999-08-20 Michael Meeks <michael@imaginator.com>
* src/cell.c (cell_set_text_simple): Add checks for over/under
......
1999-08-19 Miguel de Icaza <miguel@gnu.org>
* src/workbook.c (workbook_container_get_object): Finish
implementing this routine for responding to monikers.
(create_graphic_cmd): temporarily bind this to
Generic Bonobo object insertion.
(cb_sheet_check_dirty): Make the dialog parent be the workbook
window.
* src/workbook.h (Workbook): Include a GnomeUIHandler.
* src/sheet.c (sheet_insert_object): Enable this function again
and update it to match the latest Bonobo developments.
* src/sheet.h (Sheet): Include a pointer to the active object
frame.
* src/sheet-object.c (sheet_set_mode_type): Do deactivation of
Bonobo frames here.
* src/gnumeric-sheet.c (gnumeric_drag_data_get): Beginning of
drag and drop support for Bonobo monikers.
* src/item-grid.c (drag_start): More DnD support for Gnumeric
selections using Monikers.
* src/sheet-object-container.c (user_activation_request_cb,
view_activated_cb, get_file_name): New routines for dealing with
the Bonobo object action in Gnumeric.
(sheet_object_container_land): Do object selection here for now.
Support both PersistStream and PersistFile
* src/sheet-object.c:
* src/workbook.c (cb_sheet_check_dirty): Bind the dialog to the
main window.
1999-08-20 Michael Meeks <michael@imaginator.com>
* src/cell.c (cell_set_text_simple): Add checks for over/under
......
......@@ -886,6 +886,37 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
}
}
static void
gnumeric_sheet_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GnomeMoniker *moniker;
Sheet *sheet = GNUMERIC_SHEET (widget)->sheet_view->sheet;
Workbook *wb = sheet->workbook;
char *s;
if (wb->filename == NULL)
workbook_save (wb);
if (wb->filename == NULL)
return;
moniker = gnome_moniker_new ();
gnome_moniker_set_server (
moniker,
"IDL:GNOME:Gnumeric:Workbook:1.0",
wb->filename);
gnome_moniker_append_item_name (
moniker, "Sheet1");
s = gnome_moniker_get_as_string (moniker);
gtk_object_destroy (GTK_OBJECT (moniker));
gtk_selection_data_set (selection_data, selection_data->target, 8, s, strlen (s)+1);
}
GtkWidget *
gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
{
......@@ -939,6 +970,10 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
widget = GTK_WIDGET (gsheet);
gtk_signal_connect (
GTK_OBJECT (widget), "drag_data_get",
GTK_SIGNAL_FUNC (gnumeric_sheet_drag_data_get), NULL);
return widget;
}
......
......@@ -886,6 +886,37 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
}
}
static void
gnumeric_sheet_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GnomeMoniker *moniker;
Sheet *sheet = GNUMERIC_SHEET (widget)->sheet_view->sheet;
Workbook *wb = sheet->workbook;
char *s;
if (wb->filename == NULL)
workbook_save (wb);
if (wb->filename == NULL)
return;
moniker = gnome_moniker_new ();
gnome_moniker_set_server (
moniker,
"IDL:GNOME:Gnumeric:Workbook:1.0",
wb->filename);
gnome_moniker_append_item_name (
moniker, "Sheet1");
s = gnome_moniker_get_as_string (moniker);
gtk_object_destroy (GTK_OBJECT (moniker));
gtk_selection_data_set (selection_data, selection_data->target, 8, s, strlen (s)+1);
}
GtkWidget *
gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
{
......@@ -939,6 +970,10 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
widget = GTK_WIDGET (gsheet);
gtk_signal_connect (
GTK_OBJECT (widget), "drag_data_get",
GTK_SIGNAL_FUNC (gnumeric_sheet_drag_data_get), NULL);
return widget;
}
......
......@@ -839,6 +839,24 @@ item_grid_start_sliding (GnomeCanvasItem *item)
100, item_grid_sliding_callback, item);
}
static void
drag_start (GtkWidget *widget, GdkEvent *event, Sheet *sheet)
{
GtkTargetList *list;
GdkDragContext *context;
static GtkTargetEntry drag_types [] = {
{ "bonobo/moniker", 0, 1 },
};
list = gtk_target_list_new (drag_types, 1);
context = gtk_drag_begin (widget, list,
(GDK_ACTION_COPY | GDK_ACTION_MOVE
| GDK_ACTION_LINK | GDK_ACTION_ASK),
event->button.button, event);
gtk_drag_set_icon_default (context);
}
/*
* Handle the selection
*/
......@@ -974,6 +992,11 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
case 1:
return item_grid_button_1 (sheet, event, item_grid, col, row, x, y);
case 2:
g_warning ("This is here just for demo purposes");
drag_start (GTK_WIDGET (item->canvas), event, sheet);
return 1;
case 3:
item_grid_popup_menu (item_grid->sheet,
event, col, row);
......
......@@ -75,13 +75,94 @@ sheet_object_container_destroy_views (SheetObject *so)
so->realized_list = NULL;
}
static gint
user_activation_request_cb (GnomeViewFrame *view_frame, SheetObject *so)
{
Sheet *sheet = so->sheet;
printf ("user activation rqeuest\n");
if (sheet->active_object_frame){
gnome_view_frame_view_deactivate (sheet->active_object_frame);
if (sheet->active_object_frame != NULL)
gnome_view_frame_set_covered (sheet->active_object_frame, TRUE);
sheet->active_object_frame = NULL;
}
gnome_view_frame_view_activate (view_frame);
sheet_object_make_current (sheet, so);
return FALSE;
}
static gint
view_activated_cb (GnomeViewFrame *view_frame, gboolean activated, SheetObject *so)
{
Sheet *sheet = so->sheet;
if (activated) {
if (sheet->active_object_frame != NULL) {
g_warning ("View requested to be activated but there is already "
"an active View!\n");
return FALSE;
}
/*
* Otherwise, uncover it so that it can receive
* events, and set it as the active View.
*/
gnome_view_frame_set_covered (view_frame, FALSE);
sheet->active_object_frame = view_frame;
} else {
/*
* If the View is asking to be deactivated, always
* oblige. We may have already deactivated it (see
* user_activation_request_cb), but there's no harm in
* doing it again. There is always the possibility
* that a View will ask to be deactivated when we have
* not told it to deactivate itself, and that is
* why we cover the view here.
*/
gnome_view_frame_set_covered (view_frame, TRUE);
if (view_frame == sheet->active_object_frame)
sheet->active_object_frame = NULL;
}
return FALSE;
}
static char *
get_file_name (void)
{
GtkFileSelection *fs;
gchar *filename;
fs = GTK_FILE_SELECTION (gtk_file_selection_new ("Select filename"));
gtk_signal_connect (GTK_OBJECT (fs->ok_button),
"clicked",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_signal_connect (GTK_OBJECT (fs->cancel_button),
"clicked",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_widget_show (fs);
gtk_main ();
filename = g_strdup (gtk_file_selection_get_filename (fs));
gtk_object_destroy (GTK_OBJECT (fs));
return filename;
}
void
sheet_object_container_land (SheetObject *so)
{
SheetObjectContainer *soc;
GnomeObjectClient *component;
GList *l;
g_return_if_fail (so != NULL);
g_return_if_fail (IS_SHEET_OBJECT (so));
......@@ -102,8 +183,71 @@ sheet_object_container_land (SheetObject *so)
/*
* 3. Bind it to our object
*/
if (!soc->repoid)
soc->repoid = gnome_bonobo_select_goad_id (_("Select an object"), NULL);
if (!soc->repoid)
return;
soc->object_server = gnome_object_activate_with_goad_id (NULL, soc->repoid, 0, NULL);
if (!soc->object_server)
return;
if (!gnome_client_site_bind_embeddable (soc->client_site, soc->object_server))
return;
/*
* 3.a
*/
{
CORBA_Environment ev;
GNOME_PersistFile ret;
CORBA_exception_init (&ev);
ret = GNOME_Unknown_query_interface (
gnome_object_corba_objref (GNOME_OBJECT (soc->object_server)),
"IDL:GNOME/PersistFile:1.0", &ev);
if (ev._major == CORBA_NO_EXCEPTION && ret != CORBA_OBJECT_NIL){
char *file;
file = get_file_name ();
if (file){
GNOME_PersistFile_load (ret, file, &ev);
}
GNOME_Unknown_unref ((GNOME_Unknown) ret, &ev);
CORBA_Object_release (ret, &ev);
g_free (file);
} else {
GNOME_PersistStream ret;
ret = GNOME_Unknown_query_interface (
gnome_object_corba_objref (GNOME_OBJECT (soc->object_server)),
"IDL:GNOME/PersistStream:1.0", &ev);
if (ev._major == CORBA_NO_EXCEPTION){
if (ret != CORBA_OBJECT_NIL){
char *file;
file = get_file_name ();
if (file){
GnomeStream *stream;
stream = gnome_stream_fs_open (file, GNOME_Storage_READ);
if (stream){
GNOME_PersistStream_load (
ret,
(GNOME_Stream) gnome_object_corba_objref (
GNOME_OBJECT (stream)), &ev);
}
}
GNOME_Unknown_unref ((GNOME_Unknown) ret, &ev);
CORBA_Object_release (ret, &ev);
g_free (file);
}
}
}
CORBA_exception_free (&ev);
}
/*
* 4. Instatiate the views of the object across the sheet views
......@@ -116,6 +260,16 @@ sheet_object_container_land (SheetObject *so)
view_frame = gnome_client_site_new_view (
soc->client_site);
gnome_view_frame_set_ui_handler (
view_frame,
so->sheet->workbook->uih);
gtk_signal_connect (GTK_OBJECT (view_frame), "user_activate",
GTK_SIGNAL_FUNC (user_activation_request_cb), so);
gtk_signal_connect (GTK_OBJECT (view_frame), "view_activated",
GTK_SIGNAL_FUNC (view_activated_cb), so);
view_widget = gnome_view_frame_get_wrapper (view_frame);
item = make_container_item (so, sheet_view, view_widget);
so->realized_list = g_list_prepend (so->realized_list, item);
......@@ -270,7 +424,7 @@ SheetObject *
sheet_object_container_new (Sheet *sheet,
double x1, double y1,
double x2, double y2,
char *repoid)
const char *objref)
{
SheetObjectContainer *c;
SheetObject *so;
......@@ -281,7 +435,6 @@ sheet_object_container_new (Sheet *sheet,
g_return_val_if_fail (x1 <= x2, NULL);
g_return_val_if_fail (y1 <= y2, NULL);
object_server = gnome_object_activate_with_goad_id (NULL, repoid, 0, NULL);
if (!object_server)
return NULL;
......@@ -313,8 +466,7 @@ sheet_object_container_new (Sheet *sheet,
vf = GNOME_Plot_PlotComponent_get_vector_factory (component, &ev);
if (vf == NULL){
printf ("it is null");
abort ();
printf ("it is null"); abort ();
}
printf ("11\n");
......@@ -365,9 +517,8 @@ sheet_object_container_new (Sheet *sheet,
so->bbox_points->coords [2] = x2;
so->bbox_points->coords [3] = y2;
c->repoid = g_strdup (repoid);
c->object_server = object_server;
c->repoid = g_strdup (objref);
return SHEET_OBJECT (c);
}
......@@ -376,5 +527,5 @@ sheet_object_graphic_new (Sheet *sheet,
double x1, double y1,
double x2, double y2)
{
return sheet_object_container_new (sheet, x1, y1, x2, y2, "Guppi_component");
return sheet_object_container_new (sheet, x1, y1, x2, y2, NULL);
}
......@@ -42,7 +42,7 @@ GtkType sheet_object_container_get_type (void);
SheetObject *sheet_object_container_new (Sheet *sheet,
double x1, double y1,
double x2, double y2,
char *repoid);
const char *object_name);
void sheet_object_container_land (SheetObject *so);
/*
......
......@@ -498,6 +498,14 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
}
if (mode == SHEET_MODE_SHEET){
#ifdef ENABLE_BONOBO
if (sheet->active_object_frame){
gnome_view_frame_view_deactivate (sheet->active_object_frame);
if (sheet->active_object_frame != NULL)
gnome_view_frame_set_covered (sheet->active_object_frame, TRUE);
sheet->active_object_frame = NULL;
}
#endif
sheet_show_cursor (sheet);
if (sheet->current_object){
sheet_object_stop_editing (sheet->current_object);
......
......@@ -4210,19 +4210,22 @@ sheet_lookup_by_name (Workbook *wb, const char *name)
return NULL;
}
#if 0
void
sheet_insert_object (Sheet *sheet, char *repoid)
{
GnomeClientSite *client_site;
GnomeUnknown *object_server;
GnomeObjectClient *object_server;
GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (repoid != NULL);
object_server = gnome_object_activate_with_repo_id (NULL, repoid, 0, NULL);
if (strncmp (repoid, "moniker_url:", 12) == 0)
object_server = gnome_object_activate (repoid, 0);
else
object_server = gnome_object_activate_with_repo_id (NULL, repoid, 0, NULL);
if (!object_server){
char *msg;
......@@ -4236,7 +4239,7 @@ sheet_insert_object (Sheet *sheet, char *repoid)
client_site = gnome_client_site_new (sheet->workbook->gnome_container);
gnome_container_add (sheet->workbook->gnome_container, GNOME_OBJECT (client_site));
if (!gnome_client_site_bind_component (client_site, object_server)){
if (!gnome_client_site_bind_embeddable (client_site, object_server)){
gnumeric_notice (sheet->workbook, GNOME_MESSAGE_BOX_ERROR,
_("I was unable to the bind object"));
gtk_object_unref (GTK_OBJECT (object_server));
......@@ -4245,5 +4248,3 @@ sheet_insert_object (Sheet *sheet, char *repoid)
}
}
#endif
......@@ -113,7 +113,8 @@ struct _Sheet {
GList *objects; /* List of objects in the spreadsheet */
GList *coords; /* During creation time: keeps click coordinates */
void *current_object;
void *active_object_frame;
/*
* When editing a cell: the cell (may be NULL) and
* the original text of the cell
......
......@@ -41,6 +41,8 @@ struct _Workbook {
/* A list of EmbeddableGrids exported to the world */
GList *bonobo_regions;
GnomeUIHandler *uih;
#else
GtkObject gtk_object;
#endif
......
......@@ -24,6 +24,7 @@
#include "utils.h"
#include "widget-editable-label.h"
#include "print-info.h"
#include "ranges.h"
#ifdef ENABLE_BONOBO
#include <bonobo/gnome-persist-file.h>
......@@ -206,17 +207,10 @@ italic_cmd (GtkWidget *widget, Workbook *wb)
static void
create_graphic_cmd (GtkWidget *widget, Workbook *wb)
{
#if 0
Sheet *sheet;
if (graphic_wizard_hook){
printf ("Invoking graphic wizard...\n");
graphic_wizard_hook (wb);
} else {
sheet = workbook_get_current_sheet (wb);
sheet_set_mode_type (sheet, SHEET_MODE_CREATE_GRAPHIC);
}
#endif
sheet = workbook_get_current_sheet (wb);
sheet_set_mode_type (sheet, SHEET_MODE_CREATE_GRAPHIC);
}
#endif
......@@ -280,7 +274,7 @@ workbook_do_destroy (Workbook *wb)
gtk_signal_disconnect_by_func (
GTK_OBJECT (wb->toplevel),
GTK_SIGNAL_FUNC (workbook_set_focus), wb);
/*
* Do all deletions that leave the workbook in a working
* order.
......@@ -465,6 +459,7 @@ cb_sheet_check_dirty (gpointer key, gpointer value, gpointer user_data)
GNOME_STOCK_BUTTON_NO,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gnome_dialog_set_parent (GNOME_DIALOG (d), GTK_WINDOW (sheet->workbook->toplevel));
if (sheet->workbook->filename)
s = g_strdup_printf (
......@@ -900,12 +895,12 @@ filenames_dropped (GtkWidget * widget,
static void
insert_object_cmd (GtkWidget *widget, Workbook *wb)
{
#if 0
Sheet *sheet = workbook_get_current_sheet (wb);
char *repoid = "IDL:Sample/server:1.0";
char *repoid;
sheet_insert_object (sheet, repoid);
#endif
repoid = gnome_bonobo_select_goad_id (_("Select an object"), NULL);
if (repoid != NULL)
sheet_insert_object (sheet, repoid);
}
#endif
......@@ -1097,7 +1092,11 @@ static GnomeUIInfo workbook_menu [] = {
{ GNOME_APP_UI_SUBTREE, N_("_Insert"), NULL, workbook_menu_insert },
{ GNOME_APP_UI_SUBTREE, N_("F_ormat"), NULL, workbook_menu_format },
{ GNOME_APP_UI_SUBTREE, N_("_Tools"), NULL, workbook_menu_tools },
#ifdef ENABLE_BONOBO
#warning Should enable this when Bonobo gets menu help support
#else
GNOMEUIINFO_MENU_HELP_TREE(workbook_menu_help),
#endif
GNOMEUIINFO_END
};
......@@ -1823,6 +1822,11 @@ workbook_container_get_object (GnomeObject *container, CORBA_char *item_name,
char *p;
Value *range = NULL;
sheet = workbook_sheet_lookup (wb, item_name);
if (!sheet)
return CORBA_OBJECT_NIL;
p = strchr (item_name, '!');
if (p){
*p++ = 0;
......@@ -1843,11 +1847,6 @@ workbook_container_get_object (GnomeObject *container, CORBA_char *item_name,
}
}
sheet = workbook_sheet_lookup (wb, item_name);
if (!sheet)
return CORBA_OBJECT_NIL;
eg = embeddable_grid_new (wb, sheet);
if (!eg)
return CORBA_OBJECT_NIL;
......@@ -2022,8 +2021,20 @@ workbook_new (void)
workbook_setup_edit_area (wb);
workbook_setup_sheets (wb);
gnome_app_set_contents (GNOME_APP (wb->toplevel), wb->table);
#ifndef ENABLE_BONOBO
gnome_app_create_menus_with_data (GNOME_APP (wb->toplevel), workbook_menu, wb);
gnome_app_install_menu_hints(GNOME_APP (wb->toplevel), workbook_menu);
#else
{
GnomeUIHandlerMenuItem *list;
wb->uih = gnome_ui_handler_new ();
gnome_ui_handler_set_app (wb->uih, GNOME_APP (wb->toplevel));
gnome_ui_handler_create_menubar (wb->uih);
list = gnome_ui_handler_menu_parse_uiinfo_list_with_data (workbook_menu, wb);
gnome_ui_handler_menu_add_list (wb->uih, "/", list);
}
#endif
wb->toolbar = g_malloc (sizeof (workbook_toolbar));
memcpy (wb->toolbar, &workbook_toolbar, sizeof (workbook_toolbar));
......
......@@ -41,6 +41,8 @@ struct _Workbook {
/* A list of EmbeddableGrids exported to the world */
GList *bonobo_regions;
GnomeUIHandler *uih;
#else
GtkObject gtk_object;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment