示例#1
0
/**
 * Set the current color profile according to requested
 *
 * @param id Name of requested color profile
 * @return TRUE on success, FALSE on failure
 */
static gboolean set_color_profile(const gchar *id)
{
	// NOTE: color profile support dropped, this just a stub

	gboolean status = FALSE;

	if( !id ) {
		goto EXIT;
	}

	if( color_profile_name && !strcmp(color_profile_name, id) ) {
		mce_log(LL_DEBUG, "No change in color profile, ignoring");
		status = TRUE;
		goto EXIT;
	}

	if( !color_profile_exists(id) ) {
		mce_log(LL_WARN, "%s: unsupported color profile", id);
		goto EXIT;
	}

	if( !save_color_profile(id) ) {
		mce_log(LL_WARN, "The current color profile id can't be saved");
		goto EXIT;
	}

	free(color_profile_name), color_profile_name = strdup(id);

	status = TRUE;

EXIT:
	return status;
}
示例#2
0
/** GConf callback for powerkey related settings
 *
 * @param gcc    (not used)
 * @param id     Connection ID from gconf_client_notify_add()
 * @param entry  The modified GConf entry
 * @param data   (not used)
 */
static void
fba_gconf_cb(GConfClient *const gcc, const guint id,
			    GConfEntry *const entry, gpointer const data)
{
	(void)gcc;
	(void)data;
	(void)id;

	const GConfValue *gcv = gconf_entry_get_value(entry);

	if( !gcv ) {
		mce_log(LL_DEBUG, "GConf Key `%s' has been unset",
			gconf_entry_get_key(entry));
		goto EXIT;
	}

	if( id == use_als_gconf_id ) {
		gboolean old = use_als_flag;
		use_als_flag = gconf_value_get_bool(gcv);

		if( use_als_flag != old ) {
			rethink_als_status();
		}
	}
	else if( id == als_input_filter_gconf_id ) {
		const char *val = gconf_value_get_string(gcv);

		if( !eq(als_input_filter, val) ) {
			g_free(als_input_filter);
			als_input_filter = g_strdup(val);
			inputflt_select(als_input_filter);
		}
	}
	else if( id == als_sample_time_gconf_id ) {
		gint old = als_sample_time;
		als_sample_time = gconf_value_get_int(gcv);

		if( als_sample_time != old ) {
			mce_log(LL_NOTICE, "als_sample_time: %d -> %d",
				old, als_sample_time);
			// NB: takes effect on the next sample timer restart
		}
	}
	else if (id == color_profile_gconf_id) {
		const gchar *val = gconf_value_get_string(gcv);

		if( !eq(color_profile_name, val) ) {
			if( !set_color_profile(val) )
				save_color_profile(color_profile_name);
		}
	}
	else {
		mce_log(LL_WARN, "Spurious GConf value received; confused!");
	}

EXIT:

	return;
}
示例#3
0
/**
 * GConf callback for CPA setting
 *
 * @param gcc Unused
 * @param id Connection ID from gconf_client_notify_add()
 * @param entry The modified GConf entry
 * @param data Unused
 */
static void color_profile_gconf_cb(GConfClient *const gcc, const guint id,
				   GConfEntry *const entry,
				   gpointer const data)
{
	const GConfValue *gcv = gconf_entry_get_value(entry);

	(void)gcc;
	(void)data;

	/* FIXME: we are changing the setting from setting changed
	 *        callback - make sure this does not backfire in
	 *        some nasty way ...
	 */

	/* Key is unset */
	if (gcv == NULL) {
		mce_log(LL_DEBUG,
			"GConf Key `%s' has been unset",
			gconf_entry_get_key(entry));
		save_color_profile(color_profile_name);
		goto EXIT;
	}

	if (id == color_profile_gconf_id) {
		const gchar *profile = gconf_value_get_string(gcv);

		if (set_color_profile(profile) == FALSE)
			save_color_profile(color_profile_name);
	} else {
		mce_log(LL_WARN,
			"Spurious GConf value received; confused!");
	}

EXIT:
	return;
}