Example #1
0
static void regen_loopuptable(GtkWidget * widget, IBusHandwriteEngine * engine)
{
	int i;
	MatchedChar *matched;
	char drawtext[32]={0};
	GtkWidget * bt;

	gtk_container_foreach(GTK_CONTAINER(widget),(GtkCallback)gtk_widget_destroy,0);

	int munber = ibus_handwrite_recog_getmatch(engine->engine,&matched,0);

	//画10个侯选字
	for (i = 0; i < MIN(munber,10) ; ++i)
	{
		sprintf(drawtext,"%d.%s",i,matched[i].chr);

		bt = gtk_button_new_with_label(drawtext);

		g_object_set(G_OBJECT(bt), "expand", TRUE, NULL);

		gtk_grid_attach(GTK_TABLE(widget), bt, i%5, i/5, 1, 1);

		gtk_widget_show(bt);

		void clicked(GtkButton *button, IBusHandwriteEngine *engine)
		{
			ibus_handwrite_engine_commit_text(engine,GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"order")));
		}

		g_object_set_data(G_OBJECT(bt),"order",GINT_TO_POINTER(i));
		g_signal_connect(bt,"clicked",G_CALLBACK(clicked),engine);

		gtk_widget_show(bt);
	}
Example #2
0
static gboolean ibus_handwrite_engine_process_key_event(IBusEngine *engine,
		guint keyval, guint keycode, guint modifiers)
{
	IBusHandwriteEngine *handwrite = (IBusHandwriteEngine *) engine;

	clutter_actor_queue_redraw(handwrite->drawpanel);

	if (!modifiers)
		return FALSE;

	if(!handwrite->engine->strokes->len )
		return FALSE;

	switch (keyval)
	{
	case IBUS_BackSpace:
		if(handwrite->needclear)
			return FALSE;
		if (handwrite->engine->strokes->len)
		{
			ibus_handwrite_recog_remove_stroke(handwrite->engine, 1);
			return TRUE;
		}
		//ibus_handwrite_engine_disable(handwrite);
		return FALSE;
	case IBUS_space:
		return ibus_handwrite_engine_commit_text(handwrite,0);

	case IBUS_0 ... IBUS_9:
	case IBUS_KP_0 ... IBUS_KP_9:
		return ibus_handwrite_engine_commit_text(handwrite,
				(keyval > IBUS_KP_0) ? (keyval - IBUS_KP_0) : (keyval - IBUS_0));

	case IBUS_Escape:
		ibus_handwrite_recog_clear_stroke(handwrite->engine);
		return TRUE;
	}
	return FALSE;
}
Example #3
0
static gboolean ibus_handwrite_engine_process_key_event(IBusEngine *engine,
		guint keyval, guint keycode, guint modifiers)
{
	IBusHandwriteEngine *handwrite = (IBusHandwriteEngine *) engine;

	gtk_widget_queue_draw(handwrite->drawpanel);

        /* filter out the key release event. */
	if (modifiers & IBUS_RELEASE_MASK)
		return TRUE;

	switch (keyval)
	{
	case IBUS_BackSpace:
		if(handwrite->needclear)
			return FALSE;
		if (handwrite->engine->strokes->len)
		{
			ibus_handwrite_recog_remove_stroke(handwrite->engine, 1);
			return TRUE;
		}
		//ibus_handwrite_engine_disable(handwrite);
		return FALSE;
	case IBUS_space:
		return ibus_handwrite_engine_commit_text(handwrite,0);

	case IBUS_0 ... IBUS_9:
	case IBUS_KP_0 ... IBUS_KP_9:
		return ibus_handwrite_engine_commit_text(handwrite,
				(keyval > IBUS_KP_0) ? (keyval - IBUS_KP_0) : (keyval - IBUS_0));

	case IBUS_Escape:
		ibus_handwrite_recog_clear_stroke(handwrite->engine);
		return TRUE;
	}
	return FALSE;
}