static void emeh_class_init(EPluginHookClass *klass) { int i; ((GObjectClass *)klass)->finalize = emeh_finalise; ((EPluginHookClass *)klass)->id = "org.gnome.evolution.mail.events:1.0"; for (i=0;emeh_targets[i].type;i++) e_event_hook_class_add_target_map((EEventHookClass *)klass, &emeh_targets[i]); ((EEventHookClass *)klass)->event = (EEvent *)em_event_peek(); }
static struct _send_data * build_dialog (EAccountList *accounts, CamelFolder *outbox, const char *destination) { GtkDialog *gd; GtkWidget *table; int row, num_sources; GList *list = NULL; struct _send_data *data; GtkWidget *send_icon; GtkWidget *recv_icon; GtkWidget *scrolled_window; GtkWidget *label; GtkWidget *status_label; GtkWidget *progress_bar; GtkWidget *cancel_button; struct _send_info *info; char *pretty_url; EAccount *account; EIterator *iter; GList *icon_list; EMEventTargetSendReceive *target; gd = (GtkDialog *)(send_recv_dialog = gtk_dialog_new_with_buttons(_("Send & Receive Mail"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL)); gtk_window_set_modal ((GtkWindow *) gd, FALSE); gconf_bridge_bind_window_size ( gconf_bridge_get (), GCONF_KEY_PREFIX, GTK_WINDOW (send_recv_dialog)); gtk_widget_ensure_style ((GtkWidget *)gd); gtk_container_set_border_width ((GtkContainer *)gd->vbox, 0); gtk_container_set_border_width ((GtkContainer *)gd->action_area, 6); cancel_button = gtk_button_new_with_mnemonic (_("Cancel _All")); gtk_button_set_image ( GTK_BUTTON (cancel_button), gtk_image_new_from_stock ( GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); gtk_widget_show (cancel_button); gtk_dialog_add_action_widget (gd, cancel_button, GTK_RESPONSE_CANCEL); icon_list = e_icon_factory_get_icon_list ("mail-send-receive"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (gd), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } num_sources = 0; iter = e_list_get_iterator ((EList *) accounts); while (e_iterator_is_valid (iter)) { account = (EAccount *) e_iterator_get (iter); if (account->source->url) num_sources++; e_iterator_next (iter); } g_object_unref (iter); table = gtk_table_new (num_sources, 4, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 6); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width ( GTK_CONTAINER (scrolled_window), 6); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (scrolled_window), table); gtk_box_pack_start ( GTK_BOX (gd->vbox), scrolled_window, TRUE, TRUE, 0); gtk_widget_show (scrolled_window); /* must bet setup after send_recv_dialog as it may re-trigger send-recv button */ data = setup_send_data (); row = 0; iter = e_list_get_iterator ((EList *) accounts); while (e_iterator_is_valid (iter)) { EAccountService *source; account = (EAccount *) e_iterator_get (iter); source = account->source; if (!account->enabled || !source->url) { e_iterator_next (iter); continue; } /* see if we have an outstanding download active */ info = g_hash_table_lookup (data->active, source->url); if (info == NULL) { send_info_t type; type = get_receive_type (source->url); if (type == SEND_INVALID || type == SEND_SEND) { e_iterator_next (iter); continue; } info = g_malloc0 (sizeof (*info)); info->type = type; d(printf("adding source %s\n", source->url)); info->uri = g_strdup (source->url); info->keep = source->keep_on_server; info->cancel = camel_operation_new (operation_status, info); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); g_hash_table_insert (data->active, info->uri, info); list = g_list_prepend (list, info); } else if (info->progress_bar != NULL) { /* incase we get the same source pop up again */ e_iterator_next (iter); continue; } else if (info->timeout_id == 0) info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); recv_icon = e_icon_factory_get_image ( "mail-inbox", E_ICON_SIZE_LARGE_TOOLBAR); pretty_url = format_url (source->url, account->name); label = gtk_label_new (NULL); gtk_label_set_ellipsize ( GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_label_set_markup (GTK_LABEL (label), pretty_url); g_free (pretty_url); progress_bar = gtk_progress_bar_new (); cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); status_label = gtk_label_new ( (info->type == SEND_UPDATE) ? _("Updating...") : _("Waiting...")); gtk_label_set_ellipsize ( GTK_LABEL (status_label), PANGO_ELLIPSIZE_END); /* g_object_set(data->label, "bold", TRUE, NULL); */ gtk_misc_set_alignment (GTK_MISC (label), 0, .5); gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5); gtk_table_attach ( GTK_TABLE (table), recv_icon, 0, 1, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), label, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), progress_bar, 2, 3, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), cancel_button, 3, 4, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), status_label, 1, 2, row+1, row+2, GTK_EXPAND | GTK_FILL, 0, 0, 0); info->progress_bar = progress_bar; info->status_label = status_label; info->cancel_button = cancel_button; info->data = data; g_signal_connect ( cancel_button, "clicked", G_CALLBACK (receive_cancel), info); e_iterator_next (iter); row = row + 2; } g_object_unref (iter); /* Hook: If some one wants to hook on to the sendreceive dialog, this is the way to go. */ target = em_event_target_new_send_receive (em_event_peek(), table, data, row, EM_EVENT_SEND_RECEIVE); e_event_emit ((EEvent *)em_event_peek (), "mail.sendreceive", (EEventTarget *) target); if (outbox && destination) { info = g_hash_table_lookup (data->active, SEND_URI_KEY); if (info == NULL) { info = g_malloc0 (sizeof (*info)); info->type = SEND_SEND; d(printf("adding dest %s\n", destination)); info->uri = g_strdup (destination); info->keep = FALSE; info->cancel = camel_operation_new (operation_status, info); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); g_hash_table_insert (data->active, SEND_URI_KEY, info); list = g_list_prepend (list, info); } else if (info->timeout_id == 0) info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); send_icon = e_icon_factory_get_image ( "mail-outbox", E_ICON_SIZE_LARGE_TOOLBAR); pretty_url = format_url (destination, NULL); label = gtk_label_new (NULL); gtk_label_set_ellipsize ( GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_label_set_markup (GTK_LABEL (label), pretty_url); g_free (pretty_url); progress_bar = gtk_progress_bar_new (); cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); status_label = gtk_label_new (_("Waiting...")); gtk_label_set_ellipsize ( GTK_LABEL (status_label), PANGO_ELLIPSIZE_END); gtk_misc_set_alignment (GTK_MISC (label), 0, .5); gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5); gtk_table_attach ( GTK_TABLE (table), send_icon, 0, 1, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), label, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), progress_bar, 2, 3, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), cancel_button, 3, 4, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), status_label, 1, 2, row+1, row+2, GTK_EXPAND | GTK_FILL, 0, 0, 0); info->progress_bar = progress_bar; info->cancel_button = cancel_button; info->data = data; info->status_label = status_label; g_signal_connect ( cancel_button, "clicked", G_CALLBACK (receive_cancel), info); gtk_widget_show_all (table); } gtk_widget_show (GTK_WIDGET (gd)); g_signal_connect (gd, "response", G_CALLBACK (dialog_response), data); g_object_weak_ref ((GObject *) gd, (GWeakNotify) dialog_destroy_cb, data); data->infos = list; data->gd = gd; return data; }
{ "composer", EM_EVENT_TARGET_COMPOSER, composer_masks }, { "sendreceive", EM_EVENT_TARGET_SEND_RECEIVE, send_receive_masks }, { "customicon", EM_EVENT_TARGET_CUSTOM_ICON, custom_icon_masks }, { NULL } }; static void mail_event_hook_class_init (EEventHookClass *class) { EPluginHookClass *plugin_hook_class; gint ii; plugin_hook_class = E_PLUGIN_HOOK_CLASS (class); plugin_hook_class->id = "org.gnome.evolution.mail.events:1.0"; class->event = (EEvent *) em_event_peek (); for (ii = 0; targets[ii].type != NULL; ii++) e_event_hook_class_add_target_map ( (EEventHookClass *) class, &targets[ii]); } void e_mail_event_hook_register_type (GTypeModule *type_module) { const GTypeInfo type_info = { sizeof (EEventHookClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mail_event_hook_class_init, (GClassFinalizeFunc) NULL,