File: stardict-application-server.cpp

package info (click to toggle)
stardict 2.4.3-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,148 kB
  • ctags: 1,199
  • sloc: cpp: 12,526; sh: 8,680; xml: 2,442; ansic: 2,167; makefile: 288; python: 114
file content (120 lines) | stat: -rw-r--r-- 3,576 bytes parent folder | download
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-context.h>
#include <bonobo-activation/bonobo-activation-register.h>

#include "stardict-application-server.h"
#include "GNOME_Stardict.h"
#include "stardict.h"


static void stardict_application_server_class_init (StardictApplicationServerClass *klass);
static void stardict_application_server_init (StardictApplicationServer *a);
static void stardict_application_server_object_finalize (GObject *object);
static GObjectClass *stardict_application_server_parent_class;

static BonoboObject *
stardict_application_server_factory (BonoboGenericFactory *this_factory,
			   const char *iid,
			   gpointer user_data)
{
        StardictApplicationServer *a;
        
        a  = (StardictApplicationServer *)g_object_new (STARDICT_APPLICATION_SERVER_TYPE, NULL);

        return BONOBO_OBJECT (a);
}

BonoboObject *
stardict_application_server_new (GdkScreen *screen)
{
	BonoboGenericFactory *factory;
	char                 *display_name;
	char                 *registration_id;

	/* We must ensure an instance of stardict per screen
	 * as stardict has no multiscreen support 
	 */
	display_name = gdk_screen_make_display_name (screen);
	registration_id = bonobo_activation_make_registration_id (
					"OAFIID:GNOME_Stardict_Factory",
					display_name);

	factory = bonobo_generic_factory_new (registration_id,
					      stardict_application_server_factory,
					      NULL);

	g_free (display_name);
	g_free (registration_id);

	return BONOBO_OBJECT (factory);
}

static void
impl_stardict_application_server_queryWord (PortableServer_Servant _servant,
				   const CORBA_char *str,
				   CORBA_Environment * ev)
{
	gpAppFrame->oAppCore.Query((const gchar *)str);
}

static void
impl_stardict_application_server_grabFocus (PortableServer_Servant _servant,
					 CORBA_Environment * ev)
{
	gtk_window_present (GTK_WINDOW (gpAppFrame->oAppCore.window));
}

static void
impl_stardict_application_server_hide (PortableServer_Servant _servant,
					 CORBA_Environment * ev)
{
	gtk_widget_hide(gpAppFrame->oAppCore.window);
}

static void
impl_stardict_application_server_quit (PortableServer_Servant _servant,
                                CORBA_Environment * ev)
{
	gpAppFrame->Quit();
}

static void
stardict_application_server_class_init (StardictApplicationServerClass *klass)
{
        GObjectClass *object_class = (GObjectClass *) klass;
        POA_GNOME_Stardict_Application__epv *epv = &klass->epv;

        stardict_application_server_parent_class = (GObjectClass *)g_type_class_peek_parent (klass);

        object_class->finalize = stardict_application_server_object_finalize;

        /* connect implementation callbacks */
	epv->queryWord              = impl_stardict_application_server_queryWord;
	epv->grabFocus              = impl_stardict_application_server_grabFocus;
	epv->hide              = impl_stardict_application_server_hide;	
	epv->quit              = impl_stardict_application_server_quit;
}

static void
stardict_application_server_init (StardictApplicationServer *c) 
{
}

static void
stardict_application_server_object_finalize (GObject *object)
{
        StardictApplicationServer *a = STARDICT_APPLICATION_SERVER (object);

        stardict_application_server_parent_class->finalize (G_OBJECT (a));
}

BONOBO_TYPE_FUNC_FULL (
        StardictApplicationServer,                    
        GNOME_Stardict_Application, 
        BONOBO_TYPE_OBJECT,           
        stardict_application_server);