예제 #1
0
static void
test_client (void)
{
    FcitxClient* client = fcitx_client_new();
    g_signal_connect(client, "connected", G_CALLBACK(_connect_cb), NULL);
    run_loop_with_timeout (10000);
}
예제 #2
0
static void
fcitx_im_context_init(FcitxIMContext *context)
{
    FcitxLog(LOG_LEVEL, "fcitx_im_context_init");
    context->client = NULL;
    context->area.x = -1;
    context->area.y = -1;
    context->area.width = 0;
    context->area.height = 0;
    context->use_preedit = TRUE;
    context->cursor_pos = 0;
    context->preedit_string = NULL;
    context->attrlist = NULL;
    context->capacity = CAPACITY_SURROUNDING_TEXT;

    context->slave = gtk_im_context_simple_new();
    gtk_im_context_simple_add_table(GTK_IM_CONTEXT_SIMPLE(context->slave),
                                    cedilla_compose_seqs,
                                    4,
                                    G_N_ELEMENTS(cedilla_compose_seqs) / (4 + 2));

    g_signal_connect(context->slave,
                     "commit",
                     G_CALLBACK(_slave_commit_cb),
                     context);
    g_signal_connect(context->slave,
                     "preedit-start",
                     G_CALLBACK(_slave_preedit_start_cb),
                     context);
    g_signal_connect(context->slave,
                     "preedit-end",
                     G_CALLBACK(_slave_preedit_end_cb),
                     context);
    g_signal_connect(context->slave,
                     "preedit-changed",
                     G_CALLBACK(_slave_preedit_changed_cb),
                     context);
    g_signal_connect(context->slave,
                     "retrieve-surrounding",
                     G_CALLBACK(_slave_retrieve_surrounding_cb),
                     context);
    g_signal_connect(context->slave,
                     "delete-surrounding",
                     G_CALLBACK(_slave_delete_surrounding_cb),
                     context);

    context->time = GDK_CURRENT_TIME;

    context->client = fcitx_client_new();
    g_signal_connect(context->client, "connected", G_CALLBACK(_fcitx_im_context_connect_cb), context);
    g_signal_connect(context->client, "enable-im", G_CALLBACK(_fcitx_im_context_enable_im_cb), context);
    g_signal_connect(context->client, "close-im", G_CALLBACK(_fcitx_im_context_close_im_cb), context);
    g_signal_connect(context->client, "forward-key", G_CALLBACK(_fcitx_im_context_forward_key_cb), context);
    g_signal_connect(context->client, "commit-string", G_CALLBACK(_fcitx_im_context_commit_string_cb), context);
    g_signal_connect(context->client, "delete-surrounding-text", G_CALLBACK(_fcitx_im_context_delete_surrounding_text_cb), context);
    g_signal_connect(context->client, "update-formatted-preedit", G_CALLBACK(_fcitx_im_context_update_formatted_preedit_cb), context);
}
예제 #3
0
파일: main.c 프로젝트: dram/configs
int main(void)
{
	GSocket *sock;

	sock = create_socket();
	committed = g_string_new("");

	puts("Emacs-fcitx is ready.");

	while (TRUE) {
		GSource *source;
		GSocket *connection;
		GMainLoop *main_loop;

		if ((connection = g_socket_accept(sock, NULL, NULL)) == NULL) {
			perror("g_socket_accept");
			exit(1);
		}

		puts("Opening connection.");

		client = fcitx_client_new();

		g_signal_connect(client, "connected",
				 G_CALLBACK(connect_cb), NULL);
		g_signal_connect(client, "disconnected",
				 G_CALLBACK(destroy_cb), NULL);
		g_signal_connect(client, "enable-im",
				 G_CALLBACK(enable_im_cb), NULL);
		g_signal_connect(client, "close-im",
				 G_CALLBACK(close_im_cb), NULL);
		g_signal_connect(client, "forward-key",
				 G_CALLBACK(forward_key_cb), NULL);
		g_signal_connect(client, "commit-string",
				 G_CALLBACK(commit_string_cb), NULL);
		g_signal_connect(client,
				 "update-client-side-ui",
				 G_CALLBACK(update_client_side_ui_cb),
				 connection);

		main_loop = g_main_loop_new(NULL, FALSE);

		source = g_socket_create_source(
			connection,
			(GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR), NULL);

		g_source_set_callback(
			source, (GSourceFunc)source_cb, main_loop, NULL);

		g_source_attach(source, NULL);

		g_main_loop_run(main_loop);

		puts("main loop finished.");

		g_socket_close(connection, NULL);

		g_object_unref(client);
		g_source_unref(source);
		g_object_unref(connection);
		g_main_loop_unref(main_loop);
	}

	g_object_unref(sock);
	g_string_free(committed, TRUE);

	return 0;
}