aboutsummaryrefslogblamecommitdiffstats
path: root/shell/e-component-view.c
blob: faa9389475d238e6fdd5b4f757818c4d9a4b5c0d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                        

                                                                   













































































                                                                                                                                                                      
                                        















                                                                                                                                                                   
                                        















                                                                  
                                        





                                                                                 


                                                                            
                                        





                                                                                         

                                                                                                                 
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
 * e-component-view.c
 *
 * Copyright (C) 2004 Novell Inc.
 *
 * Author(s): Michael Zucchi <notzed@ximian.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program 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., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 * Helper class for evolution components to setup a view
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>

#include "e-component-view.h"

#include "bonobo/bonobo-control.h"

static BonoboObjectClass *parent_class = NULL;

static void
impl_ComponentView_getControls(PortableServer_Servant servant,
         Bonobo_Control *side_control,
         Bonobo_Control *view_control,
         Bonobo_Control *statusbar_control,
         CORBA_Environment *ev)
{
    EComponentView *ecv = (EComponentView *)bonobo_object_from_servant(servant);

    *side_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->side_control), ev);
    *view_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->view_control), ev);
    *statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->statusbar_control), ev);
}

/* GObject methods.  */

static void
impl_dispose (GObject *object)
{
    EComponentView *ecv = (EComponentView *)object;

    ecv->side_control = NULL;
    ecv->view_control = NULL;
    ecv->statusbar_control = NULL;

    ((GObjectClass *)parent_class)->dispose(object);
}

static void
impl_finalise (GObject *object)
{
    EComponentView *ecv = (EComponentView *)object;

    g_free(ecv->id);

    ((GObjectClass *)parent_class)->finalize(object);
}

static void
e_component_view_class_init (EComponentViewClass *klass)
{
    GObjectClass *object_class;
    POA_GNOME_Evolution_ComponentView__epv *epv;

    parent_class = g_type_class_ref(bonobo_object_get_type());

    object_class = G_OBJECT_CLASS (klass);
    object_class->dispose  = impl_dispose;
    object_class->finalize = impl_finalise;

    epv = & klass->epv;
    epv->getControls = impl_ComponentView_getControls;
}

static void
e_component_view_init (EComponentView *shell)
{
}

EComponentView *e_component_view_new(GNOME_Evolution_ShellView parent, const char *id, struct _GtkWidget *side, struct _GtkWidget *view, struct _GtkWidget *statusbar)
{
    EComponentView *new = g_object_new (e_component_view_get_type (), NULL);
    CORBA_Environment ev = { NULL };

    new->id = g_strdup(id);
    new->shell_view = CORBA_Object_duplicate(parent, &ev);
    CORBA_exception_free(&ev);

    /* FIXME: hook onto destroys */
    new->side_control = bonobo_control_new(side);
    new->view_control = bonobo_control_new(view);
    new->statusbar_control = bonobo_control_new(statusbar);

    return new;
}

EComponentView *e_component_view_new_controls(GNOME_Evolution_ShellView parent, const char *id, BonoboControl *side, BonoboControl *view, BonoboControl *statusbar)
{
    EComponentView *new = g_object_new (e_component_view_get_type (), NULL);
    CORBA_Environment ev = { NULL };

    new->id = g_strdup(id);
    new->shell_view = CORBA_Object_duplicate(parent, &ev);
    CORBA_exception_free(&ev);

    /* FIXME: hook onto destroys */
    new->side_control = side;
    new->view_control = view;
    new->statusbar_control = statusbar;

    return new;
}

void
e_component_view_set_title(EComponentView *ecv, const char *title)
{
    CORBA_Environment ev = { NULL };

    /* save roundtrips, check title is the same */
    GNOME_Evolution_ShellView_setTitle(ecv->shell_view, ecv->id, title, &ev);
    CORBA_exception_free(&ev);
}

void
e_component_view_set_button_icon (EComponentView *ecv, const char *iconName)
{
    CORBA_Environment ev = { NULL };

    /* save roundtrips, check title is the same */
    GNOME_Evolution_ShellView_setButtonIcon(ecv->shell_view, ecv->id, iconName, &ev);
    CORBA_exception_free(&ev);
}

BONOBO_TYPE_FUNC_FULL (EComponentView, GNOME_Evolution_ComponentView, bonobo_object_get_type(), e_component_view)