static VALUE 
rg_initialize(VALUE self)
{
    G_INITIALIZE(self, gtk_im_context_simple_new());

    return Qnil;
}
void scim_bridge_client_imcontext_initialize (ScimBridgeClientIMContext *imcontext, ScimBridgeClientIMContextClass *klass)
{
    scim_bridge_pdebugln (5, "scim_bridge_client_imcontext_initialize  ()");

    /* slave exists for using gtk+'s table based input method */
    imcontext->slave_preedit = FALSE;
    imcontext->slave = gtk_im_context_simple_new ();
    g_signal_connect(G_OBJECT(imcontext->slave),
                     "commit",
                     G_CALLBACK(gtk_im_slave_commit_cb),
                     imcontext);
    
    g_signal_connect(G_OBJECT(imcontext->slave),
                     "preedit-changed",
                     G_CALLBACK(gtk_im_slave_preedit_changed_cb),
                     imcontext);
    
    g_signal_connect(G_OBJECT(imcontext->slave),
                     "preedit-start",
                     G_CALLBACK(gtk_im_slave_preedit_start_cb),
                     imcontext);
    
    g_signal_connect(G_OBJECT(imcontext->slave),
                     "preedit-end",
                     G_CALLBACK(gtk_im_slave_preedit_end_cb),
                     imcontext);

    imcontext->preedit_shown = FALSE;
    imcontext->preedit_started = FALSE;
    
    imcontext->preedit_cursor_position = 0;
    imcontext->preedit_cursor_flicking = FALSE;

    imcontext->preedit_string = malloc (sizeof (char));
    imcontext->preedit_string[0] = '\0';
    imcontext->preedit_string_capacity = 0;

    imcontext->preedit_attributes = NULL;

    imcontext->commit_string = malloc (sizeof (char));
    imcontext->commit_string[0] = '\0';
    imcontext->commit_string_capacity = 0;

    imcontext->enabled = FALSE;

    imcontext->client_window = NULL;

    imcontext->id = -1;

    if (!scim_bridge_client_is_messenger_opened ()) {
        scim_bridge_perrorln ("The messenger is now down");
    } else if (scim_bridge_client_register_imcontext (imcontext)) {
        scim_bridge_perrorln ("Failed to register the IMContext");
    } else {
        scim_bridge_pdebugln (1, "IMContext registered: id = %d", imcontext->id);
    }
}
Example #3
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);
}
/* Class Implementations */
void scim_bridge_client_imcontext_static_initialize ()
{
    gdk_color_parse ("gray92", &preedit_normal_background);
    gdk_color_parse ("black", &preedit_normal_foreground);
    gdk_color_parse ("light blue", &preedit_active_background);
    gdk_color_parse ("black", &preedit_active_foreground);

    focused_imcontext = NULL;

    fallback_imcontext = gtk_im_context_simple_new ();
    fallback_commit_handler = g_signal_connect (G_OBJECT (fallback_imcontext), "commit", G_CALLBACK (fallback_commit), NULL);
    fallback_preedit_changed_handler = g_signal_connect (G_OBJECT (fallback_imcontext), "preedit_changed", G_CALLBACK (fallback_preedit_changed), NULL);
}
Example #5
0
int
main
(
	int argc,
	char **argv
)
{
	GtkWindow* window;
	GtkDrawingArea* area;
	GtkIMContext* im;

	gtk_init(&argc, &argv);

	window = (GtkWindow*) gtk_window_new(GTK_WINDOW_TOPLEVEL);
	area = (GtkDrawingArea*) gtk_drawing_area_new();
        GTK_WIDGET_SET_FLAGS(area, GTK_CAN_FOCUS);

	gtk_container_add((GtkContainer*) window, (GtkWidget*) area);

	im = gtk_im_context_simple_new();

	g_signal_connect(area, "key-press-event", G_CALLBACK(keystroke_cb), im);
	g_signal_connect(area, "key-release-event", G_CALLBACK(keystroke_cb), im);
	g_signal_connect(im, "commit", G_CALLBACK(commit_cb), NULL);

	gtk_widget_show_all((GtkWidget*) window);

	/*
	 * Get the Window on screen and let GTK settle.
	 */

	while (gtk_events_pending()) {
		gtk_main_iteration();
	}

	/*
	 * Generate the compose sequence.
	 */

	gtk_test_widget_send_key((GtkWidget*) area, GDK_Multi_key, 0);
	gtk_test_widget_send_key((GtkWidget*) area, GDK_e, 0);
	gtk_test_widget_send_key((GtkWidget*) area, GDK_equal, 0);

	/*
	 * Will return if and only if commit is hit.
	 */

	gtk_main();

	return 0;
}
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkIMContextSimple_gtk_1im_1context_1simple_1new
(
	JNIEnv* env,
	jclass cls
)
{
	GtkIMContext* result;
	jlong _result;

	// call function
	result = gtk_im_context_simple_new();

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, TRUE);
	}

	// and finally
	return _result;
}