summaryrefslogtreecommitdiff
path: root/src/nautilus-view-frame-bonobo-control.c
blob: ef52dbab1de10fa8b4316a27ade105c32612e615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */

/*
 *  Nautilus
 *
 *  Copyright (C) 1999, 2000 Red Hat, Inc.
 *  Copyright (C) 1999, 2000 Eazel, Inc.
 *
 *  Nautilus 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.
 *
 *  Nautilus 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.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Author: Elliot Lee <sopwith@redhat.com>
 *
 */

#include <config.h>

#include "nautilus-view-frame-private.h"
#include "nautilus-window.h"

#include <bonobo/bonobo-control-frame.h>

typedef struct {
  BonoboControlFrame *control_frame;
} BonoboControlInfo;

static void
destroy_bonobo_control_view(NautilusViewFrame *view, CORBA_Environment *ev)
{
  BonoboControlInfo *bci = view->component_data;
  g_free(bci);
}

static void
nautilus_view_frame_activate_uri(BonoboControlFrame *frame, const char *uri, gboolean relative, NautilusViewFrame *view)
{
  /* FIXME bugzilla.eazel.com 2580: Can we ship with this assert?
   * Why is this not going to happen?
   */
  g_assert(!relative);
  nautilus_view_frame_open_location(view, uri);
}

static gboolean
bonobo_control_try_load_client(NautilusViewFrame *view, CORBA_Object obj, CORBA_Environment *ev)
{
  BonoboControlInfo *bci;
  Bonobo_UIHandler uih;

  view->component_data = bci = g_new0(BonoboControlInfo, 1);

  uih = bonobo_object_corba_objref(BONOBO_OBJECT(view->ui_handler));
  bci->control_frame = bonobo_control_frame_new(uih);
  bonobo_object_add_interface(BONOBO_OBJECT(bci->control_frame), view->view_frame);

  bonobo_control_frame_bind_to_control(bci->control_frame, obj);

  view->client_widget = bonobo_control_frame_get_widget(bci->control_frame);
  
  gtk_signal_connect(GTK_OBJECT(bci->control_frame),
                     "activate_uri", GTK_SIGNAL_FUNC(nautilus_view_frame_activate_uri), view);

  return TRUE;
}

static void
bonobo_control_load_location(NautilusViewFrame *view, Nautilus_URI location, CORBA_Environment *ev)
{
  nautilus_view_frame_report_load_underway(view);
  nautilus_view_frame_report_load_complete(view);
}

NautilusViewComponentType bonobo_control_component_type = {
  "IDL:Bonobo/Control:1.0",
  &bonobo_control_try_load_client, /* try_load */
  &destroy_bonobo_control_view,    /* destroy */
  &bonobo_control_load_location,   /* load_location */
  NULL,                            /* stop_loading */
  NULL,                            /* selection_changed */
  NULL                             /* title_changed */
};