aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2002-12-07 03:38:26 +0800
committerHans Petter <hansp@src.gnome.org>2002-12-07 03:38:26 +0800
commit7bb980e76d7207855e87ffefbffaa304dd779372 (patch)
treeff1524650853ff2749729a8edf5bf9f20c75a3a5 /calendar/cal-client
parent4b1cfd51be51cc0ff40a5439ea9bf008f71405e8 (diff)
downloadgsoc2013-evolution-7bb980e76d7207855e87ffefbffaa304dd779372.tar.gz
gsoc2013-evolution-7bb980e76d7207855e87ffefbffaa304dd779372.tar.zst
gsoc2013-evolution-7bb980e76d7207855e87ffefbffaa304dd779372.zip
Create a non-abstract enumeration type derived from GEnum.
2002-12-06 Hans Petter Jansson <hpj@ximian.com> * cal-client/cal-client.c (cal_client_open_status_enum_get_type): Create a non-abstract enumeration type derived from GEnum. (cal_client_set_mode_status_enum_get_type): Ditto. (cal_mode_enum_get_type): Ditto. (cal_client_class_init): Use our enumerations and not the abstract one. (cal_client_finalize): Don't destroy factories, since the CalClient doesn't own them anymore. They're shared between CalClients now. (get_factories): Implement. Move the factory setup code here from cal_client_construct (), and cache the factories. This is hopefully temporary, until wombat goes away or is fixed. (cal_client_construct): Most of the code moved to get_factories (). * cal-client/cal-client.h: Add enumeration type macros and protos. * gui/cal-search-bar.c (cal_search_bar_get_type): Removed in favour of E_MAKE_TYPE, which uses GObject calls. (cal_search_bar_class_init): Use g_type_class_peek_parent (). * gui/calendar-model.c (calendar_model_get_type): (calendar_model_class_init): Ditto, like above file. * gui/calendar-view.c (calendar_view_get_type): (calendar_view_class_init): Ditto. * gui/e-calendar-table.c (e_calendar_table_get_type): (e_calendar_table_class_init): Ditto. * gui/e-comp-editor-registry.c (e_comp_editor_registry_get_type): (class_init): Ditto. * gui/e-day-view-main-item.c (e_day_view_main_item_get_type): (e_day_view_main_item_class_init): Ditto. * gui/e-day-view-time-item.c (e_day_view_time_item_get_type): (e_day_view_time_item_class_init): Ditto. * gui/e-day-view-top-item.c (e_day_view_top_item_get_type): (e_day_view_top_item_class_init): Ditto. * gui/e-day-view.c (e_day_view_get_type): (e_day_view_class_init): Ditto. * gui/e-itip-control.c (e_itip_control_get_type): (class_init): Ditto. * gui/e-meeting-attendee.c (e_meeting_attendee_get_type): (class_init): Ditto. * gui/e-meeting-model.c (e_meeting_model_get_type): (class_init): Ditto. * gui/e-meeting-time-sel-item.c (e_meeting_time_selector_item_get_type): (e_meeting_time_selector_item_class_init): Ditto. * gui/e-meeting-time-sel.c (e_meeting_time_selector_get_type): (e_meeting_time_selector_class_init): Ditto. * gui/e-timezone-entry.c (e_timezone_entry_get_type): (e_timezone_entry_class_init): Ditto. * gui/e-week-view-event-item.c (e_week_view_event_item_get_type): (e_week_view_event_item_class_init): Ditto. * gui/e-week-view-main-item.c (e_week_view_main_item_get_type): (e_week_view_main_item_class_init): Ditto. * gui/e-week-view-titles-item.c (e_week_view_titles_item_get_type): (e_week_view_titles_item_class_init): Ditto. * gui/gnome-cal.c (gnome_calendar_get_type): (gnome_calendar_class_init): Ditto. * gui/weekday-picker.c (weekday_picker_get_type): (weekday_picker_class_init): Ditto. * gui/e-week-view.c (e_week_view_get_type): (e_week_view_class_init): Ditto, but parent_class init was moved from get_type() to class_init(). * gui/calendar-view-factory.c (calendar_view_factory_get_type): (calendar_view_factory_class_init): Ditto, and set up finalize callback instead of destroy. (calendar_view_factory_finalize): It's a GObject, so implement this. (celendar_view_factory_destroy): Move code to _finalize() and remove. * gui/main.c (init_bonobo): Remove extraneous bonobo_activation_init(). svn path=/trunk/; revision=19043
Diffstat (limited to 'calendar/cal-client')
-rw-r--r--calendar/cal-client/cal-client.c126
-rw-r--r--calendar/cal-client/cal-client.h8
2 files changed, 110 insertions, 24 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index d6d92b6239..ddf3617072 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -143,6 +143,67 @@ cal_client_get_type (void)
return cal_client_type;
}
+GType
+cal_client_open_status_enum_get_type (void)
+{
+ static GType cal_client_open_status_enum_type = 0;
+
+ if (!cal_client_open_status_enum_type) {
+ static GEnumValue values [] = {
+ { CAL_CLIENT_OPEN_SUCCESS, "CalClientOpenSuccess", "success" },
+ { CAL_CLIENT_OPEN_ERROR, "CalClientOpenError", "error" },
+ { CAL_CLIENT_OPEN_NOT_FOUND, "CalClientOpenNotFound", "not-found" },
+ { CAL_CLIENT_OPEN_PERMISSION_DENIED, "CalClientOpenPermissionDenied", "denied" },
+ { CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED, "CalClientOpenMethodNotSupported", "unsupported" },
+ { -1, NULL, NULL }
+ };
+
+ cal_client_open_status_enum_type = g_enum_register_static ("CalClientOpenStatusEnum", values);
+ }
+
+ return cal_client_open_status_enum_type;
+}
+
+GType
+cal_client_set_mode_status_enum_get_type (void)
+{
+ static GType cal_client_set_mode_status_enum_type = 0;
+
+ if (!cal_client_set_mode_status_enum_type) {
+ static GEnumValue values [] = {
+ { CAL_CLIENT_SET_MODE_SUCCESS, "CalClientSetModeSuccess", "success" },
+ { CAL_CLIENT_SET_MODE_ERROR, "CalClientSetModeError", "error" },
+ { CAL_CLIENT_SET_MODE_NOT_SUPPORTED, "CalClientSetModeNotSupported", "unsupported" },
+ { -1, NULL, NULL }
+ };
+
+ cal_client_set_mode_status_enum_type =
+ g_enum_register_static ("CalClientSetModeStatusEnum", values);
+ }
+
+ return cal_client_set_mode_status_enum_type;
+}
+
+GType
+cal_mode_enum_get_type (void)
+{
+ static GType cal_mode_enum_type = 0;
+
+ if (!cal_mode_enum_type) {
+ static GEnumValue values [] = {
+ { CAL_MODE_INVALID, "CalModeInvalid", "invalid" },
+ { CAL_MODE_LOCAL, "CalModeLocal", "local" },
+ { CAL_MODE_REMOTE, "CalModeRemote", "remote" },
+ { CAL_MODE_ANY, "CalModeAny", "any" },
+ { -1, NULL, NULL }
+ };
+
+ cal_mode_enum_type = g_enum_register_static ("CalModeEnum", values);
+ }
+
+ return cal_mode_enum_type;
+}
+
/* Class initialization function for the calendar client */
static void
cal_client_class_init (CalClientClass *klass)
@@ -161,7 +222,7 @@ cal_client_class_init (CalClientClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__ENUM,
G_TYPE_NONE, 1,
- G_TYPE_ENUM);
+ CAL_CLIENT_OPEN_STATUS_ENUM_TYPE);
cal_client_signals[CAL_SET_MODE] =
g_signal_new ("cal_set_mode",
G_TYPE_FROM_CLASS (klass),
@@ -170,8 +231,8 @@ cal_client_class_init (CalClientClass *klass)
NULL, NULL,
cal_util_marshal_VOID__ENUM_ENUM,
G_TYPE_NONE, 2,
- G_TYPE_ENUM,
- G_TYPE_ENUM);
+ CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE,
+ CAL_MODE_ENUM_TYPE);
cal_client_signals[OBJ_UPDATED] =
g_signal_new ("obj_updated",
G_TYPE_FROM_CLASS (klass),
@@ -372,7 +433,7 @@ cal_client_finalize (GObject *object)
}
priv->w_client = NULL;
- destroy_factories (client);
+ /* destroy_factories (client); */
destroy_cal (client);
priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
@@ -645,29 +706,17 @@ client_forget_password_cb (WombatClient *w_client,
-/**
- * cal_client_construct:
- * @client: A calendar client.
- *
- * Constructs a calendar client object by contacting all available
- * calendar factories.
- *
- * Return value: The same object as the @client argument, or NULL if the
- * calendar factory could not be contacted.
- **/
-CalClient *
-cal_client_construct (CalClient *client)
+static GList *
+get_factories (void)
{
- CalClientPrivate *priv;
+ static GList *factories = NULL;
GNOME_Evolution_Calendar_CalFactory factory;
Bonobo_ServerInfoList *servers;
CORBA_Environment ev;
int i;
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
+ if (factories != NULL)
+ return factories;
CORBA_exception_init (&ev);
@@ -689,18 +738,47 @@ cal_client_construct (CalClient *client)
factory = (GNOME_Evolution_Calendar_CalFactory)
bonobo_activation_activate_from_id (info->iid, 0, NULL, &ev);
if (BONOBO_EX (&ev)) {
+#if 0
g_warning ("cal_client_construct: Could not activate calendar server %s", info->iid);
CORBA_free (servers);
CORBA_exception_free (&ev);
return NULL;
+#endif
}
-
- priv->factories = g_list_prepend (priv->factories, factory);
+ else
+ factories = g_list_prepend (factories, factory);
}
CORBA_free (servers);
-
CORBA_exception_free (&ev);
+ return factories;
+}
+
+/**
+ * cal_client_construct:
+ * @client: A calendar client.
+ *
+ * Constructs a calendar client object by contacting all available
+ * calendar factories.
+ *
+ * Return value: The same object as the @client argument, or NULL if the
+ * calendar factory could not be contacted.
+ **/
+CalClient *
+cal_client_construct (CalClient *client)
+{
+ CalClientPrivate *priv;
+ GNOME_Evolution_Calendar_CalFactory factory;
+ Bonobo_ServerInfoList *servers;
+ CORBA_Environment ev;
+ int i;
+
+ g_return_val_if_fail (client != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
+
+ priv = client->priv;
+ priv->factories = get_factories ();
+
return client;
}
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 3d6a4fe85d..3ea0b1a213 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -36,6 +36,10 @@ G_BEGIN_DECLS
#define IS_CAL_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_CLIENT_TYPE))
#define IS_CAL_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_TYPE))
+#define CAL_CLIENT_OPEN_STATUS_ENUM_TYPE (cal_client_open_status_enum_get_type ())
+#define CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE (cal_client_set_mode_status_enum_get_type ())
+#define CAL_MODE_ENUM_TYPE (cal_mode_enum_get_type ())
+
typedef struct _CalClient CalClient;
typedef struct _CalClientClass CalClientClass;
@@ -122,6 +126,10 @@ typedef gchar * (* CalClientAuthFunc) (CalClient *client,
GType cal_client_get_type (void);
+GType cal_client_open_status_enum_get_type (void);
+GType cal_client_set_mode_status_enum_get_type (void);
+GType cal_mode_enum_get_type (void);
+
CalClient *cal_client_construct (CalClient *client);
CalClient *cal_client_new (void);