evolution-3.6.4/shell/es-event.c

No issues found

  1 /*
  2  * This program is free software; you can redistribute it and/or
  3  * modify it under the terms of the GNU Lesser General Public
  4  * License as published by the Free Software Foundation; either
  5  * version 2 of the License, or (at your option) version 3.
  6  *
  7  * This program is distributed in the hope that it will be useful,
  8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 10  * Lesser General Public License for more details.
 11  *
 12  * You should have received a copy of the GNU Lesser General Public
 13  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 14  *
 15  *
 16  * Authors:
 17  *		Michael Zucchi <notzed@ximian.com>
 18  *
 19  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 20  *
 21  */
 22 
 23 #ifdef HAVE_CONFIG_H
 24 #include <config.h>
 25 #endif
 26 
 27 #include <string.h>
 28 #include <stdlib.h>
 29 
 30 #include "es-event.h"
 31 #include "e-shell.h"
 32 
 33 static ESEvent *es_event;
 34 
 35 G_DEFINE_TYPE (ESEvent, es_event, E_TYPE_EVENT)
 36 
 37 static void
 38 es_event_class_init (ESEventClass *class)
 39 {
 40 }
 41 
 42 static void
 43 es_event_init (ESEvent *event)
 44 {
 45 }
 46 
 47 /**
 48  * es_event_peek:
 49  *
 50  * Get the singular instance of the shell event handler.
 51  *
 52  * Return: the shell event handler
 53  **/
 54 ESEvent *
 55 es_event_peek (void)
 56 {
 57 	if (es_event == NULL) {
 58 		es_event = g_object_new (es_event_get_type (), NULL);
 59 		/** @HookPoint: Shell Events Hookpoint
 60 		 * Id: org.gnome.evolution.shell.events
 61 		 *
 62 		 * This is the hook point which emits shell events.
 63 		 */
 64 		e_event_construct (&es_event->event, "org.gnome.evolution.shell.events");
 65 	}
 66 
 67 	return es_event;
 68 }
 69 
 70 ESEventTargetUpgrade *
 71 es_event_target_new_upgrade (ESEvent *eme,
 72                              gint major,
 73                              gint minor,
 74                              gint revision)
 75 {
 76 	ESEventTargetUpgrade *t;
 77 
 78 	t = e_event_target_new (
 79 		&eme->event, ES_EVENT_TARGET_UPGRADE, sizeof (*t));
 80 	t->major = major;
 81 	t->minor = minor;
 82 	t->revision = revision;
 83 
 84 	return t;
 85 }
 86 
 87 /* ********************************************************************** */
 88 
 89 G_DEFINE_TYPE (ESEventHook, es_event_hook, E_TYPE_EVENT_HOOK)
 90 
 91 static const EEventHookTargetMap emeh_targets[] = {
 92 	{ "upgrade", ES_EVENT_TARGET_UPGRADE, NULL },
 93 	{ NULL }
 94 };
 95 
 96 static void
 97 es_event_hook_class_init (ESEventHookClass *class)
 98 {
 99 	EPluginHookClass *plugin_hook_class;
100 	EEventHookClass *event_hook_class;
101 	gint i;
102 
103 	/** @HookClass: Shell Main Menu
104 	 * @Id: org.gnome.evolution.shell.events:1.0
105 	 * @Target: ESEventTargetState
106 	 *
107 	 * A hook for events coming from the shell.
108 	 **/
109 
110 	plugin_hook_class = E_PLUGIN_HOOK_CLASS (class);
111 	plugin_hook_class->id = "org.gnome.evolution.shell.events:1.0";
112 
113 	for (i = 0; emeh_targets[i].type; i++)
114 		e_event_hook_class_add_target_map (
115 			(EEventHookClass *) class, &emeh_targets[i]);
116 
117 	event_hook_class = E_EVENT_HOOK_CLASS (class);
118 	event_hook_class->event = (EEvent *) es_event_peek ();
119 }
120 
121 static void
122 es_event_hook_init (ESEventHook *hook)
123 {
124 }