1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* |
---|
3 | * bonobo-moniker-simple: Simplified object naming abstraction |
---|
4 | * |
---|
5 | * Author: |
---|
6 | * Michael Meeks (michael@helixcode.com) |
---|
7 | * |
---|
8 | * Copyright 2000, Helix Code, Inc. |
---|
9 | */ |
---|
10 | #include <config.h> |
---|
11 | |
---|
12 | #include <bonobo/bonobo-moniker.h> |
---|
13 | #include <bonobo/bonobo-moniker-simple.h> |
---|
14 | |
---|
15 | static Bonobo_Unknown |
---|
16 | simple_resolve (BonoboMoniker *moniker, |
---|
17 | const Bonobo_ResolveOptions *options, |
---|
18 | const CORBA_char *requested_interface, |
---|
19 | CORBA_Environment *ev) |
---|
20 | { |
---|
21 | BonoboMonikerSimple *simple; |
---|
22 | |
---|
23 | g_return_val_if_fail (BONOBO_IS_MONIKER_SIMPLE (moniker), |
---|
24 | CORBA_OBJECT_NIL); |
---|
25 | |
---|
26 | simple = BONOBO_MONIKER_SIMPLE (moniker); |
---|
27 | |
---|
28 | return simple->resolve_fn (moniker, options, requested_interface, ev); |
---|
29 | } |
---|
30 | |
---|
31 | static void |
---|
32 | bonobo_moniker_simple_class_init (BonoboMonikerClass *klass) |
---|
33 | { |
---|
34 | klass->resolve = simple_resolve; |
---|
35 | } |
---|
36 | |
---|
37 | static void |
---|
38 | bonobo_moniker_simple_init (GtkObject *object) |
---|
39 | { |
---|
40 | /* nothing to do */ |
---|
41 | } |
---|
42 | |
---|
43 | BONOBO_X_TYPE_FUNC (BonoboMonikerSimple, |
---|
44 | bonobo_moniker_get_type (), |
---|
45 | bonobo_moniker_simple); |
---|
46 | |
---|
47 | /** |
---|
48 | * bonobo_moniker_simple_construct: |
---|
49 | * @moniker: the moniker to construct |
---|
50 | * @name: the name of the moniker eg. 'file:' |
---|
51 | * @resolve_fn: the function used to resolve the moniker |
---|
52 | * |
---|
53 | * Constructs a simple moniker |
---|
54 | * |
---|
55 | * Return value: the constructed moniker or NULL on failure. |
---|
56 | **/ |
---|
57 | BonoboMoniker * |
---|
58 | bonobo_moniker_simple_construct (BonoboMonikerSimple *moniker, |
---|
59 | const char *name, |
---|
60 | BonoboMonikerSimpleResolveFn resolve_fn) |
---|
61 | { |
---|
62 | g_return_val_if_fail (resolve_fn != NULL, NULL); |
---|
63 | |
---|
64 | moniker->resolve_fn = resolve_fn; |
---|
65 | |
---|
66 | return bonobo_moniker_construct ( |
---|
67 | BONOBO_MONIKER (moniker), name); |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * bonobo_moniker_simple_new: |
---|
72 | * @name: the display name for the moniker |
---|
73 | * @resolve_fn: a resolve function for the moniker |
---|
74 | * |
---|
75 | * Create a new instance of a simplified moniker. |
---|
76 | * |
---|
77 | * Return value: the moniker object |
---|
78 | **/ |
---|
79 | BonoboMoniker * |
---|
80 | bonobo_moniker_simple_new (const char *name, |
---|
81 | BonoboMonikerSimpleResolveFn resolve_fn) |
---|
82 | { |
---|
83 | BonoboMoniker *moniker; |
---|
84 | |
---|
85 | moniker = gtk_type_new (bonobo_moniker_simple_get_type ()); |
---|
86 | |
---|
87 | return bonobo_moniker_simple_construct ( |
---|
88 | BONOBO_MONIKER_SIMPLE (moniker), |
---|
89 | name, resolve_fn); |
---|
90 | } |
---|
91 | |
---|