示例#1
0
/* Checks a colon separated list of strings for the presence of a particular string.
 * This is useful to check the "extensions" gconf parameter which is a list of colon separated strings */
void keyboard_status_update(struct keyboard *keyboard, struct status *status)
{
	START_FUNC
	gboolean active=FALSE;
	gchar *allextstr=NULL;
	gchar **extstrs=NULL;
	gchar **extstr=NULL;
	if (keyboard->id) {
		if ((allextstr=settings_get_string(SETTINGS_EXTENSIONS))) {
			extstrs=g_strsplit(allextstr, ":", -1);
			extstr=extstrs;
			while (extstr && *extstr) {
				if (!strcmp(keyboard->id, *(extstr++))) { active=TRUE; break; }
			}
			g_strfreev(extstrs);
			g_free(allextstr);
		}
		if ((!active)&&keyboard->activated&&keyboard->onhide) {
			/* onhide trigger */
			if (!keyboard->onhide->key) flo_error(_("No key associated with onhide trigger"));
			else if (KEY_RELEASED!=keyboard->onhide->key->state) {
				status_pressed_set(status, keyboard->onhide->key);
				status_pressed_set(status, NULL);
			}
		}
		keyboard->activated=active;
	}
	END_FUNC
}
示例#2
0
文件: ramble.c 项目: Newterm/florence
/* Add a point to the path and update the window.
 * returns TRUE if an event is detected. */
gboolean ramble_add(struct ramble *ramble, GdkWindow *window, gint x, gint y, struct key *k)
{
	START_FUNC
	gchar *val;
	struct ramble_point *pt=g_malloc(sizeof(struct ramble_point));

	/* Add the point to the path */
	pt->p.x=x; pt->p.y=y; pt->k=k; pt->ev=FALSE;
	ramble->end=g_list_append(ramble->end, (gpointer)pt);
	if (!ramble->path) {
		ramble->path=ramble->end;
		pt->ev=TRUE;
	}
	if (ramble->end->next) ramble->end=ramble->end->next;
	ramble->n++;
	ramble_update_region(ramble->end, window);
	if (ramble->n > RAMBLE_MAX_POINTS) {
		ramble_update_region(ramble->path->next, window);
		g_free(ramble->path->data);
		ramble->path=g_list_delete_link(ramble->path, ramble->path);
		ramble->n--;
	}
	if (!k) return FALSE;

	/* Gesture detection */
	val=settings_get_string(SETTINGS_RAMBLE_ALGO);
	if (!strcmp("distance", val))
		ramble_distance(ramble);
	else if (!strcmp("time", val))
		ramble_time(ramble);
	else {
		flo_warn(_("Invalid ramble algorithm selected. Using default."));
		ramble_distance(ramble);
	}
	if (val) g_free(val);

	ramble->started=TRUE;
	END_FUNC
	return pt->ev;
}
示例#3
0
gboolean a_settings_get_string ( const gchar *name, gchar **val )
{
	return settings_get_string ( VIKING_SETTINGS_GROUP, name, val );
}
示例#4
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);
	}
}