Rename to start_default_server_async () and don't run a nested main loop.
2002-08-20 Hans Petter Jansson <hpj@ximian.com> * gui/e-itip-control.c (start_defalt_server): Rename to start_default_server_async () and don't run a nested main loop. Let the caller deal with the client object and signals. (default_server_started_cb): Implement. Async signal handler for 'cal_opened' signal, does the embedding. (object_requested_cb): Rewritten to work asynchronously, and finish the embedding when default_server_started_cb() is called. svn path=/trunk/; revision=22317
This commit is contained in:

committed by
Hans Petter

parent
c37df16604
commit
eacc240747
@ -1,3 +1,13 @@
|
|||||||
|
2002-08-20 Hans Petter Jansson <hpj@ximian.com>
|
||||||
|
|
||||||
|
* gui/e-itip-control.c (start_defalt_server): Rename to
|
||||||
|
start_default_server_async () and don't run a nested main loop. Let
|
||||||
|
the caller deal with the client object and signals.
|
||||||
|
(default_server_started_cb): Implement. Async signal handler for
|
||||||
|
'cal_opened' signal, does the embedding.
|
||||||
|
(object_requested_cb): Rewritten to work asynchronously, and finish
|
||||||
|
the embedding when default_server_started_cb() is called.
|
||||||
|
|
||||||
2003-08-20 Rodrigo Moya <rodrigo@ximian.com>
|
2003-08-20 Rodrigo Moya <rodrigo@ximian.com>
|
||||||
|
|
||||||
* gui/e-calendar-table.c (setup_popup_icons): new function to set icons
|
* gui/e-calendar-table.c (setup_popup_icons): new function to set icons
|
||||||
|
@ -63,7 +63,7 @@ struct _EItipControlPrivate {
|
|||||||
CalClient *event_client;
|
CalClient *event_client;
|
||||||
GPtrArray *task_clients;
|
GPtrArray *task_clients;
|
||||||
CalClient *task_client;
|
CalClient *task_client;
|
||||||
|
|
||||||
char *vcalendar;
|
char *vcalendar;
|
||||||
CalComponent *comp;
|
CalComponent *comp;
|
||||||
icalcomponent *main_comp;
|
icalcomponent *main_comp;
|
||||||
@ -187,43 +187,13 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CalClient *
|
static gboolean
|
||||||
start_default_server (EItipControl *itip, gboolean tasks)
|
start_default_server_async (EItipControl *itip, CalClient *client, gboolean tasks)
|
||||||
{
|
{
|
||||||
CalClient *client;
|
if (tasks)
|
||||||
gboolean success = FALSE;
|
return cal_client_open_default_tasks (client, FALSE);
|
||||||
|
else
|
||||||
client = cal_client_new ();
|
return cal_client_open_default_calendar (client, FALSE);
|
||||||
|
|
||||||
g_signal_connect (client, "cal_opened", G_CALLBACK (start_calendar_server_cb), &success);
|
|
||||||
|
|
||||||
if (tasks) {
|
|
||||||
if (!cal_client_open_default_tasks (client, FALSE))
|
|
||||||
goto error;
|
|
||||||
} else {
|
|
||||||
if (!cal_client_open_default_calendar (client, FALSE))
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* run a sub event loop to turn cal-client's async load
|
|
||||||
notification into a synchronous call */
|
|
||||||
if (!itip->priv->destroyed) {
|
|
||||||
gtk_signal_connect (GTK_OBJECT (itip), "destroy",
|
|
||||||
gtk_main_quit, NULL);
|
|
||||||
|
|
||||||
gtk_main ();
|
|
||||||
|
|
||||||
gtk_signal_disconnect_by_func (GTK_OBJECT (itip),
|
|
||||||
gtk_main_quit, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
return client;
|
|
||||||
|
|
||||||
error:
|
|
||||||
g_object_unref (client);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPtrArray *
|
static GPtrArray *
|
||||||
@ -2209,16 +2179,34 @@ url_requested_cb (GtkHTML *html, const gchar *url, GtkHTMLStream *handle, gpoint
|
|||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
typedef struct
|
||||||
object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
|
|
||||||
{
|
{
|
||||||
EItipControl *itip = E_ITIP_CONTROL (data);
|
EItipControl *itip;
|
||||||
|
GtkHTMLEmbedded *eb;
|
||||||
|
CalClient *client;
|
||||||
|
}
|
||||||
|
ObjectRequestContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
default_server_started_cb (CalClient *client, CalClientOpenStatus status, gpointer data)
|
||||||
|
{
|
||||||
|
ObjectRequestContext *context = data;
|
||||||
EItipControlPrivate *priv;
|
EItipControlPrivate *priv;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
CalComponentVType vtype;
|
CalComponentVType vtype;
|
||||||
|
|
||||||
priv = itip->priv;
|
|
||||||
|
|
||||||
|
priv = context->itip->priv;
|
||||||
|
|
||||||
|
if (status != CAL_CLIENT_OPEN_SUCCESS ||
|
||||||
|
context->itip->priv->destroyed ||
|
||||||
|
context->itip->priv->html == NULL) {
|
||||||
|
g_object_unref (context->client);
|
||||||
|
g_object_unref (context->itip);
|
||||||
|
g_free (context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->event_client = client;
|
||||||
vtype = cal_component_get_vtype (priv->comp);
|
vtype = cal_component_get_vtype (priv->comp);
|
||||||
|
|
||||||
switch (vtype) {
|
switch (vtype) {
|
||||||
@ -2227,24 +2215,65 @@ object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
|
|||||||
global_shell_client, _("Select Calendar Folder"),
|
global_shell_client, _("Select Calendar Folder"),
|
||||||
calendar_config_default_calendar_folder (),
|
calendar_config_default_calendar_folder (),
|
||||||
calendar_types);
|
calendar_types);
|
||||||
priv->event_client = start_default_server (itip, FALSE);
|
|
||||||
break;
|
break;
|
||||||
case CAL_COMPONENT_TODO:
|
case CAL_COMPONENT_TODO:
|
||||||
button = evolution_folder_selector_button_new (
|
button = evolution_folder_selector_button_new (
|
||||||
global_shell_client, _("Select Tasks Folder"),
|
global_shell_client, _("Select Tasks Folder"),
|
||||||
calendar_config_default_tasks_folder (),
|
calendar_config_default_tasks_folder (),
|
||||||
tasks_types);
|
tasks_types);
|
||||||
priv->task_client = start_default_server (itip, TRUE);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
button = NULL;
|
button = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect (button, "selected", G_CALLBACK (button_selected_cb), itip);
|
g_signal_connect (button, "selected", G_CALLBACK (button_selected_cb), context->itip);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (eb), button);
|
gtk_container_add (GTK_CONTAINER (context->eb), button);
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
|
|
||||||
|
g_object_unref (context->itip);
|
||||||
|
g_free (context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
|
||||||
|
{
|
||||||
|
EItipControl *itip = E_ITIP_CONTROL (data);
|
||||||
|
ObjectRequestContext *context;
|
||||||
|
EItipControlPrivate *priv;
|
||||||
|
CalComponentVType vtype;
|
||||||
|
gboolean success;
|
||||||
|
|
||||||
|
priv = itip->priv;
|
||||||
|
vtype = cal_component_get_vtype (priv->comp);
|
||||||
|
|
||||||
|
context = g_new0 (ObjectRequestContext, 1);
|
||||||
|
context->itip = itip;
|
||||||
|
context->eb = eb;
|
||||||
|
context->client = cal_client_new ();
|
||||||
|
|
||||||
|
g_object_ref (itip);
|
||||||
|
g_signal_connect (context->client, "cal_opened",
|
||||||
|
G_CALLBACK (default_server_started_cb), context);
|
||||||
|
|
||||||
|
switch (vtype) {
|
||||||
|
case CAL_COMPONENT_EVENT:
|
||||||
|
success = start_default_server_async (itip, context->client, FALSE);
|
||||||
|
break;
|
||||||
|
case CAL_COMPONENT_TODO:
|
||||||
|
success = start_default_server_async (itip, context->client, TRUE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
success = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
g_object_unref (itip);
|
||||||
|
g_object_unref (context->client);
|
||||||
|
g_free (context);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user