예제 #1
0
파일: ramble.c 프로젝트: Newterm/florence
/* Detect gesture based on distance */
void ramble_distance(struct ramble *ramble)
{
	START_FUNC
	GList *list;
	gint dw, dh;
	gdouble d=0.0, w, h, threshold;
	struct ramble_point *pt, *pt1, *pt2;

	list=ramble->end;
	pt=(struct ramble_point *)ramble->end->data;
	pt1=pt;
	/* Calculate path distance on that key */
	while (list) {
		pt2=(struct ramble_point *)list->data;
		if ( (!pt2->ev) && (pt2->k==pt->k) ) {
			dw=pt1->p.x-pt2->p.x;
			dh=pt1->p.y-pt2->p.y;
			w=((gdouble)dw)/pt->k->w;
			h=((gdouble)dh)/pt->k->h;
			d+=sqrt((w*w)+(h*h));
			pt1=pt2;
			list=list->prev;
		} else {
			list=NULL;
		}
	}
	if (pt2->ev) threshold=settings_get_double(SETTINGS_RAMBLE_THRESHOLD2);
	else threshold=settings_get_double(SETTINGS_RAMBLE_THRESHOLD1);
	threshold*=(settings_get_double(SETTINGS_SCALEX)+settings_get_double(SETTINGS_SCALEY))/2.0;
	if (d>=threshold) {
		pt->ev=TRUE;
		list=NULL;
	}
	END_FUNC
}
예제 #2
0
파일: ramble.c 프로젝트: Newterm/florence
/* Detect gesture based on time */
void ramble_time(struct ramble *ramble)
{
	START_FUNC
	struct ramble_point *pt;
	pt=(struct ramble_point *)ramble->end->data;
	if (pt->k) {
		/* TODO:
		 * reset the timer when pointer is near the border */
		if ( (!ramble->end->prev) ||
			(((struct ramble_point *)ramble->end->prev->data)->k!=pt->k) ) {
			if (ramble->timer)
				g_timer_start(ramble->timer);
			else
				ramble->timer=g_timer_new();
		} else if (g_timer_elapsed(ramble->timer, NULL)>=
			(settings_get_double(SETTINGS_RAMBLE_TIMER)/1000.0)) {
			pt->ev=TRUE;
			g_timer_start(ramble->timer);
			g_timer_stop(ramble->timer);
		}
	} else if (ramble->timer) {
		g_timer_destroy(ramble->timer);
		ramble->timer=NULL;
	}
	END_FUNC
}
예제 #3
0
gboolean a_settings_get_double ( const gchar *name, gdouble *val )
{
	return settings_get_double ( VIKING_SETTINGS_GROUP, name, val );
}
예제 #4
0
static void
init_settings(void)
{
    settings_init();
    settings_load();

    hotkey_t hk;
    settings_get(TRIGGER_KEY, &hk);
    INIT_KEY_SETTING(trigger);

    settings_get(ENG_KEY, &hk);
    INIT_KEY_SETTING(english);

    varchar colorstr;
    settings_get(PREEDIT_COLOR, colorstr);
    INIT_COLOR_SETTING(background_color_btn);

    settings_get(PREEDIT_FONT_COLOR, colorstr);
    INIT_COLOR_SETTING(font_color_btn);

    varchar fontstr;
    settings_get(PREEDIT_FONT, fontstr);
    gtk_font_button_set_font_name(font_btn, fontstr);


    gtk_adjustment_set_value(opacity_value,
                             settings_get_double(PREEDIT_OPACITY));

    gtk_adjustment_set_value(ncandidates, settings_get_int(CANDIDATES_SIZE));

    gtk_toggle_button_set_active(minus_plus_check,
                                 settings_get_int(PAGE_MINUS_PLUS));
    gtk_toggle_button_set_active(comma_period_check,
                                 settings_get_int(PAGE_COMMA_PERIOD));
    gtk_toggle_button_set_active(paren_check,
                                 settings_get_int(PAGE_PAREN));

    gtk_toggle_button_set_active(fuzzy_seg_check,
                                 settings_get_int(FUZZY_SEGMENTATION));
    gtk_toggle_button_set_active(fuzzy_inner_seg_check,
                                 settings_get_int(FUZZY_INNER_SEGMENTATION));

    gtk_toggle_button_set_active(cancel_on_backspace_check,
                                 settings_get_int(CANCEL_ON_BACKSPACE));

    gtk_toggle_button_set_active(smart_punct_check,
                                 settings_get_int(SMART_PUNCT));

    gtk_toggle_button_set_active(shuangpin_check,
                                 settings_get_int(SHUANGPIN));
    varchar scheme;
    int i;
    settings_get(SHUANGPIN_SCHEME, scheme);
    for (i = 0; i < UI_SHUANGPIN_SCHEMES_NUM; i++) {
        if (strcmp(ui_shuangpin_schemes[i], scheme) == 0) {
            gtk_combo_box_set_active(shuangpin_combo, i);
            break;
        }
    }

    /* init status */
    settings_get_int(INIT_PUNC_TYPE)?
        gtk_toggle_button_set_active(punc_english_radio, TRUE):
        gtk_toggle_button_set_active(punc_chinese_radio, TRUE);
    settings_get_int(INIT_WIDTH)?
        gtk_toggle_button_set_active(half_width_radio, TRUE):
        gtk_toggle_button_set_active(full_width_radio, TRUE);
    settings_get_int(INIT_LANGUAGE)?
        gtk_toggle_button_set_active(lang_english_radio, TRUE):
        gtk_toggle_button_set_active(lang_chinese_radio, TRUE);

    /* skin */
    varchar skin_name;
    settings_get(SKIN_NAME, skin_name);
    int idx = list_skins(skin_name);
    gtk_combo_box_set_active(skin_combo, idx);

    gtk_toggle_button_set_active(hide_icbar_check,
                                 settings_get_int(HIDE_ICBAR));

}
예제 #5
0
파일: status.c 프로젝트: ilyak/vimol
void
status_render(struct status *status, cairo_t *cairo)
{
	cairo_font_extents_t exfont;
	cairo_text_extents_t extext;
	color_t color;
	double size;
	int width, height;
	const char *font;
	char *text;

	font = settings_get_string("status.font");
	size = settings_get_double("status.font.size");

	cairo_reset_clip(cairo);
	cairo_identity_matrix(cairo);
	cairo_select_font_face(cairo, font, CAIRO_FONT_SLANT_NORMAL,
	    CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size(cairo, size);
	cairo_font_extents(cairo, &exfont);

	width = cairo_image_surface_get_width(cairo_get_target(cairo));
	height = cairo_image_surface_get_height(cairo_get_target(cairo));

	if (!settings_get_bool("status.transparent")) {
		color = settings_get_color("status.color");
		cairo_set_source_rgb(cairo, color.r, color.g, color.b);
		cairo_rectangle(cairo, 0, height - exfont.height - 10,
		    width, exfont.height + 10);
		cairo_fill(cairo);
	}

	color = settings_get_color("status.text.color");
	cairo_set_source_rgb(cairo, color.r, color.g, color.b);

	cairo_text_extents(cairo, status->info, &extext);
	cairo_move_to(cairo, width - extext.x_advance - 5,
	    height - exfont.descent - 5);
	cairo_show_text(cairo, status->info);

	cairo_rectangle(cairo, 0, height - exfont.height - 10,
	    width - extext.x_advance - 10, exfont.height + 10);
	cairo_clip(cairo);

	if (status->is_error) {
		color = settings_get_color("status.error.color");
		cairo_set_source_rgb(cairo, color.r, color.g, color.b);
	}

	cairo_move_to(cairo, 5, height - exfont.descent - 5);
	cairo_show_text(cairo, status->text);

	if (status->cursor_pos > -1) {
		text = xstrndup(status->text, (size_t)status->cursor_pos);
		cairo_text_extents(cairo, text, &extext);
		cairo_move_to(cairo, extext.x_advance + 5,
		    height - exfont.descent - 5);
		cairo_show_text(cairo, "_");
		free(text);
	}
}