nautilus-view-frame.c 17.9 KB
Newer Older
1 2 3 4 5
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */

/*
 *  Nautilus
 *
Elliot Lee's avatar
Elliot Lee committed
6
 *  Copyright (C) 1999, 2000 Red Hat, Inc.
7
 *  Copyright (C) 1999, 2000 Eazel, Inc.
8 9 10 11 12 13 14 15 16 17
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU 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
 *  General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
18
 *
19 20 21
 *  You should have received a copy of the GNU General Public License
 *  along with this library; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Elliot Lee's avatar
Elliot Lee committed
22
 *
23
 *  Author: Elliot Lee <sopwith@redhat.com>
Elliot Lee's avatar
Elliot Lee committed
24 25
 *
 */
26 27 28
/* ntl-view.c: Implementation of the object representing a data view,
   and its associated CORBA object for proxying requests into this
   object. */
Elliot Lee's avatar
Elliot Lee committed
29 30 31

#include <gtk/gtksignal.h>
#include <gtk/gtk.h>
32
#include "nautilus.h"
33
#include "ntl-view-private.h"
Elliot Lee's avatar
Elliot Lee committed
34 35

enum {
Maciej Stachowiak's avatar
Maciej Stachowiak committed
36 37 38 39
  REQUEST_LOCATION_CHANGE,
  REQUEST_SELECTION_CHANGE,
  REQUEST_STATUS_CHANGE,
  REQUEST_PROGRESS_CHANGE,
Elliot Lee's avatar
Elliot Lee committed
40
  LAST_SIGNAL
Elliot Lee's avatar
Elliot Lee committed
41 42 43
};

enum {
Elliot Lee's avatar
Elliot Lee committed
44 45
  ARG_0,
  ARG_MAIN_WINDOW
Elliot Lee's avatar
Elliot Lee committed
46 47
};

Elliot Lee's avatar
Elliot Lee committed
48

Maciej Stachowiak's avatar
Maciej Stachowiak committed
49 50


Elliot Lee's avatar
Elliot Lee committed
51
static void nautilus_view_init       (NautilusView      *view);
52
static void nautilus_view_destroy    (GtkObject      *view);
53
static void nautilus_view_constructed(NautilusView      *view);
Elliot Lee's avatar
Elliot Lee committed
54 55
static void nautilus_view_class_init (NautilusViewClass *klass);
static void nautilus_view_set_arg (GtkObject      *object,
56 57
                                   GtkArg         *arg,
                                   guint	      arg_id);
Elliot Lee's avatar
Elliot Lee committed
58
static void nautilus_view_get_arg (GtkObject      *object,
59 60
                                   GtkArg         *arg,
                                   guint	      arg_id);
Elliot Lee's avatar
Elliot Lee committed
61 62 63
static void nautilus_view_size_request (GtkWidget        *widget,
					GtkRequisition   *requisition);
static void nautilus_view_size_allocate (GtkWidget        *widget,
64
                                         GtkAllocation    *allocation);
Maciej Stachowiak's avatar
Maciej Stachowiak committed
65 66 67 68


static guint nautilus_view_signals[LAST_SIGNAL];

Elliot Lee's avatar
Elliot Lee committed
69 70 71 72

GtkType
nautilus_view_get_type (void)
{
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
  static GtkType view_type = 0;

  if (!view_type)	{
    const GtkTypeInfo view_info = {
      "NautilusView",
      sizeof (NautilusView),
      sizeof (NautilusViewClass),
      (GtkClassInitFunc) nautilus_view_class_init,
      (GtkObjectInitFunc) nautilus_view_init,
      /* reserved_1 */ NULL,
      /* reserved_2 */ NULL,
      (GtkClassInitFunc) NULL,
    };

    view_type = gtk_type_unique (gtk_bin_get_type(), &view_info);
  }
Elliot Lee's avatar
Elliot Lee committed
89
	
90
  return view_type;
Elliot Lee's avatar
Elliot Lee committed
91 92
}

Elliot Lee's avatar
Elliot Lee committed
93
#if 0
Elliot Lee's avatar
Elliot Lee committed
94 95 96 97 98 99 100 101 102 103 104
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)
{
105 106 107 108 109 110 111
  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);
Elliot Lee's avatar
Elliot Lee committed
112
}
Elliot Lee's avatar
Elliot Lee committed
113
#endif
Elliot Lee's avatar
Elliot Lee committed
114 115 116 117 118 119 120 121

static void
nautilus_view_class_init (NautilusViewClass *klass)
{
  GtkObjectClass *object_class;
  GtkWidgetClass *widget_class;

  object_class = (GtkObjectClass*) klass;
122
  object_class->destroy = nautilus_view_destroy;
Elliot Lee's avatar
Elliot Lee committed
123 124 125 126 127 128 129
  object_class->set_arg = nautilus_view_set_arg;
  object_class->get_arg = nautilus_view_get_arg;

  widget_class = (GtkWidgetClass*) klass;
  widget_class->size_request = nautilus_view_size_request;
  widget_class->size_allocate = nautilus_view_size_allocate;

Elliot Lee's avatar
Elliot Lee committed
130 131 132
  klass->servant_init_func = POA_Nautilus_ViewFrame__init;
  klass->servant_destroy_func = POA_Nautilus_ViewFrame__fini;
  klass->vepv = &impl_Nautilus_ViewFrame_vepv;
Elliot Lee's avatar
Elliot Lee committed
133 134

  klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type));
Maciej Stachowiak's avatar
Maciej Stachowiak committed
135 136 137 138
  /* klass->request_location_change = NULL; */
  /* klass->request_selection_change = NULL; */
  /* klass->request_status_change = NULL; */
  /* klass->request_progress_change = NULL; */
139
  klass->view_constructed = nautilus_view_constructed;
Maciej Stachowiak's avatar
Maciej Stachowiak committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

  nautilus_view_signals[REQUEST_LOCATION_CHANGE] = gtk_signal_new("request_location_change",
                                                                  GTK_RUN_LAST,
                                                                  object_class->type,
                                                                  GTK_SIGNAL_OFFSET (NautilusViewClass, 
                                                                                     request_location_change),
                                                                  gtk_marshal_NONE__BOXED,
                                                                  GTK_TYPE_NONE, 1, GTK_TYPE_BOXED);
  nautilus_view_signals[REQUEST_SELECTION_CHANGE] = gtk_signal_new("request_selection_change",
                                                                   GTK_RUN_LAST,
                                                                   object_class->type,
                                                                   GTK_SIGNAL_OFFSET (NautilusViewClass, 
                                                                                      request_selection_change),
                                                                   gtk_marshal_NONE__BOXED,
                                                                   GTK_TYPE_NONE, 1, GTK_TYPE_BOXED);
  nautilus_view_signals[REQUEST_STATUS_CHANGE] = gtk_signal_new("request_status_change",
                                                                GTK_RUN_LAST,
                                                                object_class->type,
                                                                GTK_SIGNAL_OFFSET (NautilusViewClass, 
                                                                                   request_status_change),
                                                                gtk_marshal_NONE__BOXED,
                                                                GTK_TYPE_NONE, 1, GTK_TYPE_BOXED);
  nautilus_view_signals[REQUEST_PROGRESS_CHANGE] = gtk_signal_new("request_progress_change",
                                                                   GTK_RUN_LAST,
                                                                   object_class->type,
                                                                   GTK_SIGNAL_OFFSET (NautilusViewClass, 
                                                                                      request_progress_change),
                                                                   gtk_marshal_NONE__BOXED,
                                                                   GTK_TYPE_NONE, 1, GTK_TYPE_BOXED);

  gtk_object_class_add_signals (object_class, nautilus_view_signals, LAST_SIGNAL);
  
Elliot Lee's avatar
Elliot Lee committed
172 173 174

  gtk_object_add_arg_type ("NautilusView::main_window",
			   GTK_TYPE_OBJECT,
175
			   GTK_ARG_READWRITE,
Elliot Lee's avatar
Elliot Lee committed
176
			   ARG_MAIN_WINDOW);
177
  klass->num_construct_args++;
Elliot Lee's avatar
Elliot Lee committed
178 179 180 181 182
}

static void
nautilus_view_set_arg (GtkObject      *object,
		       GtkArg         *arg,
183
		       guint	       arg_id)
Elliot Lee's avatar
Elliot Lee committed
184
{
185 186 187
  NautilusView *view;

  view = NAUTILUS_VIEW(object);
Elliot Lee's avatar
Elliot Lee committed
188 189
  switch(arg_id) {
  case ARG_MAIN_WINDOW:
190 191
    view->main_window = GTK_WIDGET(GTK_VALUE_OBJECT(*arg));
    nautilus_view_construct_arg_set(view);
Elliot Lee's avatar
Elliot Lee committed
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
    break;
  }
}

static void
nautilus_view_get_arg (GtkObject      *object,
		       GtkArg         *arg,
		       guint	        arg_id)
{
  switch(arg_id) {
  case ARG_MAIN_WINDOW:
    GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(NAUTILUS_VIEW(object)->main_window);
    break;
  }
}

static void
nautilus_view_init (NautilusView *view)
{
  GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW);
212 213 214 215 216 217 218 219 220 221
}

static void
nautilus_view_destroy_client(NautilusView *view)
{
  if(!view->component_class)
    return;

  g_free(view->iid); view->iid = NULL;

222
  bonobo_object_destroy(BONOBO_OBJECT(view->client_object)); view->client_object = NULL;
223 224 225 226 227 228 229 230 231 232 233

  gtk_container_remove(GTK_CONTAINER(view), view->client_widget); view->client_widget = NULL;

  if(view->component_class->destroy)
    {
      CORBA_Environment ev;
      CORBA_exception_init(&ev);
      view->component_class->destroy(view, &ev);
      CORBA_exception_free(&ev);
    }

234
  bonobo_object_destroy(view->view_frame); view->view_frame = NULL;
235 236 237 238 239 240 241 242 243

  view->component_class = NULL;
  view->component_data = NULL;
}

static void
nautilus_view_destroy(GtkObject      *view)
{
  NautilusViewClass *klass = NAUTILUS_VIEW_CLASS(view->klass);
244
  NautilusView *nview = NAUTILUS_VIEW(view);
245

246
  if(nview->timer_id)
247 248 249 250
    {
      g_source_remove(nview->timer_id);
      nview->timer_id = 0;
    }
251 252

  nautilus_view_destroy_client(nview);
253 254 255

  if(GTK_OBJECT_CLASS(klass->parent_class)->destroy)
    GTK_OBJECT_CLASS(klass->parent_class)->destroy(view);
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
}

static void
nautilus_view_constructed(NautilusView *view)
{
}

void
nautilus_view_construct_arg_set(NautilusView *view)
{
  guint nca;
  NautilusViewClass *klass;

  klass = NAUTILUS_VIEW_CLASS(((GtkObject *)view)->klass);
  nca = klass->num_construct_args;
  if(view->construct_arg_count >= nca)
    return;

  view->construct_arg_count++;
  if((view->construct_arg_count >= nca)
     && klass->view_constructed)
    klass->view_constructed(view);
Elliot Lee's avatar
Elliot Lee committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
}

static void
nautilus_view_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_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);
}
315

316 317 318
extern NautilusViewComponentType nautilus_view_component_type; /* ntl-view-nautilus.c */
extern NautilusViewComponentType bonobo_subdoc_component_type; /* ntl-view-bonobo-subdoc.c */
extern NautilusViewComponentType bonobo_control_component_type; /* ntl-view-bonobo-control.c */
Elliot Lee's avatar
Elliot Lee committed
319

320 321 322 323 324 325 326 327 328 329
static gboolean
nautilus_view_handle_client_destroy(GtkWidget *widget, NautilusView *view)
{
  gtk_object_destroy(GTK_OBJECT(view));
  return TRUE;
}

static void
nautilus_view_handle_client_destroy_2(GtkObject *object, CORBA_Object cobject, CORBA_Environment *ev, NautilusView *view)
{
330 331 332 333 334
  /* ICK! */
  if(NAUTILUS_IS_META_VIEW(view))
    nautilus_window_remove_meta_view(NAUTILUS_WINDOW(view->main_window), view);
  else if(NAUTILUS_IS_CONTENT_VIEW(view))
    nautilus_window_set_content_view(NAUTILUS_WINDOW(view->main_window), NULL);
335 336
}

337
gboolean /* returns TRUE if successful */
338
nautilus_view_load_client(NautilusView *view, const char *iid)
339
{
340
  CORBA_Object obj;
Elliot Lee's avatar
Elliot Lee committed
341
  CORBA_Environment ev;
342 343 344 345 346 347 348
  int i;
  NautilusViewComponentType *component_types[] = {
    &nautilus_view_component_type,
    &bonobo_subdoc_component_type,
    &bonobo_control_component_type,
    NULL
  };
Elliot Lee's avatar
Elliot Lee committed
349

350 351
  if (iid == NULL)
    return FALSE;
352 353

  CORBA_exception_init(&ev);
354

355
  nautilus_view_destroy_client(view);
356

357
  view->client_object = bonobo_object_activate(iid, 0);
358 359
  if(!view->client_object)
    return FALSE;
360

361 362 363
  view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev);

  /* Now figure out which type of embedded object it is: */
364

365
  for(i = 0; component_types[i] && !view->component_class; i++)
366
    {
367
      obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)),
368
                                          component_types[i]->primary_repoid, &ev);
369
      if(ev._major != CORBA_NO_EXCEPTION)
370
        obj = CORBA_OBJECT_NIL;
371

372 373 374 375 376 377
      if(CORBA_Object_is_nil(obj, &ev))
        continue;

      if(component_types[i]->try_load(view, obj, &ev))
        view->component_class = component_types[i];

378
      Bonobo_Unknown_unref(obj, &ev);
379
      CORBA_Object_release(obj, &ev);
380 381 382

      if (view->component_class)
        break;
383 384 385 386 387 388 389 390
    }

  if (!view->component_class)
    {
      /* Nothing matched */
      nautilus_view_destroy_client(view);

      return FALSE;
391
    }
392
      
393
  view->iid = g_strdup(iid);
Elliot Lee's avatar
Elliot Lee committed
394

395 396 397 398 399 400 401 402 403
  gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy",
                                 GTK_SIGNAL_FUNC(nautilus_view_handle_client_destroy), view,
                                 GTK_OBJECT(view));
  gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone",
                                 GTK_SIGNAL_FUNC(nautilus_view_handle_client_destroy_2), view,
                                 GTK_OBJECT(view));
  gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception",
                                 GTK_SIGNAL_FUNC(nautilus_view_handle_client_destroy_2), view,
                                 GTK_OBJECT(view));
404
  gtk_container_add(GTK_CONTAINER(view), view->client_widget);
405
  gtk_widget_show(view->client_widget);
Elliot Lee's avatar
Elliot Lee committed
406
  CORBA_exception_free(&ev);
407 408

  return TRUE;
409
}
Elliot Lee's avatar
Elliot Lee committed
410

Maciej Stachowiak's avatar
Maciej Stachowiak committed
411
void
412 413 414 415
nautilus_view_notify_location_change(NautilusView *view,
				     Nautilus_NavigationInfo *nav_context)
{
  Nautilus_NavigationInfo real_nav_ctx;
416
  CORBA_Environment ev;
417

418 419
  g_return_if_fail(view);
  g_return_if_fail(view->component_class);
420
  g_return_if_fail(NAUTILUS_VIEW(view));
421

422 423
  real_nav_ctx = *nav_context;
  g_assert(real_nav_ctx.requested_uri);
424
#define DEFAULT_STRING(x) if(!real_nav_ctx.x) real_nav_ctx.x = ""
425 426
  if(!real_nav_ctx.actual_uri) real_nav_ctx.actual_uri = real_nav_ctx.requested_uri;
  DEFAULT_STRING(content_type);
427

428
  DEFAULT_STRING(referring_uri);
429
  if(!real_nav_ctx.actual_referring_uri) real_nav_ctx.actual_referring_uri = real_nav_ctx.referring_uri;
430
  DEFAULT_STRING(referring_content_type);
431

432 433 434 435
  CORBA_exception_init(&ev);
  if(view->component_class->notify_location_change)
    view->component_class->notify_location_change(view, &real_nav_ctx, &ev);
  CORBA_exception_free(&ev);
Elliot Lee's avatar
Elliot Lee committed
436 437
}

Maciej Stachowiak's avatar
Maciej Stachowiak committed
438
void
Elliot Lee's avatar
Elliot Lee committed
439 440 441 442
nautilus_view_notify_selection_change(NautilusView *view,
				      Nautilus_SelectionInfo *nav_context)
{
  CORBA_Environment ev;
443 444 445

  g_return_if_fail(view);
  g_return_if_fail(view->component_class);
446
  g_return_if_fail(NAUTILUS_VIEW(view));
447

Elliot Lee's avatar
Elliot Lee committed
448 449
  CORBA_exception_init(&ev);

450 451
  if(view->component_class->notify_selection_change)
    view->component_class->notify_selection_change(view, nav_context, &ev);
Elliot Lee's avatar
Elliot Lee committed
452 453 454 455

  CORBA_exception_free(&ev);
}

Maciej Stachowiak's avatar
Maciej Stachowiak committed
456
void
Elliot Lee's avatar
Elliot Lee committed
457 458 459
nautilus_view_load_state(NautilusView *view, const char *config_path)
{
  CORBA_Environment ev;
460

461 462
  g_return_if_fail(view);
  g_return_if_fail(view->component_class);
463
  g_return_if_fail(NAUTILUS_VIEW(view));
464

Elliot Lee's avatar
Elliot Lee committed
465 466
  CORBA_exception_init(&ev);

467 468
  if(view->component_class->load_state)
    view->component_class->load_state(view, config_path, &ev);
Elliot Lee's avatar
Elliot Lee committed
469 470 471 472

  CORBA_exception_free(&ev);
}

Maciej Stachowiak's avatar
Maciej Stachowiak committed
473
void
Elliot Lee's avatar
Elliot Lee committed
474 475 476
nautilus_view_save_state(NautilusView *view, const char *config_path)
{
  CORBA_Environment ev;
477

478 479 480
  g_return_if_fail(view);
  g_return_if_fail(view->component_class);

Elliot Lee's avatar
Elliot Lee committed
481 482
  CORBA_exception_init(&ev);

483 484
  if(view->component_class->save_state)
    view->component_class->save_state(view, config_path, &ev);
Elliot Lee's avatar
Elliot Lee committed
485 486 487 488

  CORBA_exception_free(&ev);
}

Maciej Stachowiak's avatar
Maciej Stachowiak committed
489
void
Elliot Lee's avatar
Elliot Lee committed
490 491 492
nautilus_view_show_properties(NautilusView *view)
{
  CORBA_Environment ev;
493 494 495 496

  g_return_if_fail(view);
  g_return_if_fail(view->component_class);

Elliot Lee's avatar
Elliot Lee committed
497
  CORBA_exception_init(&ev);
498

499 500
  if(view->component_class->show_properties)
    view->component_class->show_properties(view, &ev);
Elliot Lee's avatar
Elliot Lee committed
501 502 503 504

  CORBA_exception_free(&ev);
}

505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
void
nautilus_view_stop_location_change(NautilusView *view)
{
  CORBA_Environment ev;

  g_return_if_fail(view);
  g_return_if_fail(view->component_class);

  CORBA_exception_init(&ev);

  if(view->component_class->stop_location_change)
    view->component_class->stop_location_change(view, &ev);

  CORBA_exception_free(&ev);
}


522 523 524 525 526 527 528 529 530
const char *
nautilus_view_get_iid(NautilusView *view)
{
  return view->iid;
}

CORBA_Object
nautilus_view_get_client_objref(NautilusView *view)
{
531
  return view?bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)):NULL;
532 533 534 535 536
}

CORBA_Object
nautilus_view_get_objref(NautilusView *view)
{
537
  return view?bonobo_object_corba_objref(view->view_frame):NULL;
538
}
Maciej Stachowiak's avatar
Maciej Stachowiak committed
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568


void
nautilus_view_request_location_change(NautilusView *view,
                                      Nautilus_NavigationRequestInfo *loc)
{
  gtk_signal_emit(GTK_OBJECT(view), nautilus_view_signals[REQUEST_LOCATION_CHANGE], loc);
}

void
nautilus_view_request_selection_change (NautilusView              *view,
                                        Nautilus_SelectionRequestInfo *loc)
{
  gtk_signal_emit(GTK_OBJECT(view), nautilus_view_signals[REQUEST_SELECTION_CHANGE], loc);
}

void
nautilus_view_request_status_change    (NautilusView              *view,
                                        Nautilus_StatusRequestInfo *loc)
{
  gtk_signal_emit(GTK_OBJECT(view), nautilus_view_signals[REQUEST_STATUS_CHANGE], loc);
}

void
nautilus_view_request_progress_change(NautilusView              *view,
                                      Nautilus_ProgressRequestInfo *loc)
{
  gtk_signal_emit(GTK_OBJECT(view), nautilus_view_signals[REQUEST_PROGRESS_CHANGE], loc);
}

569 570 571 572 573 574 575
static gboolean
check_object(NautilusView *view)
{
  CORBA_Environment ev;
  gboolean retval = TRUE;
  CORBA_exception_init(&ev);

576 577 578 579
  g_assert(!view->checking);

  view->checking++;

580
  if(CORBA_Object_non_existent(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), &ev))
581 582 583 584 585 586 587
    {
      view->timer_id = 0;
      gtk_object_destroy(GTK_OBJECT(view));
      retval = FALSE;
    }

  CORBA_exception_free(&ev);
588 589
  view->checking--;

590 591 592 593 594 595 596 597 598
  return retval;
}

void
nautilus_view_set_active_errors(NautilusView *view, gboolean enabled)
{
  if(enabled)
    {
      if(!view->timer_id)
599
        view->timer_id = g_timeout_add(2000, (GSourceFunc)check_object, view);
600 601 602 603 604 605 606 607 608 609
    }
  else
    {
      if(view->timer_id)
        {
          g_source_remove(view->timer_id);
          view->timer_id = 0;
        }
    }
}