static gboolean
can_edit_source (const char *source)
{
	MateConfEngine *engine;
	MateConfClient *client;
	MateConfEntry  *entry;
	GError      *error;
	gboolean     retval;

	if (!(engine = mateconf_engine_get_for_address (source, NULL)))
		return FALSE;

	error = NULL;
	client = mateconf_client_get_for_engine (engine);
	entry = mateconf_client_get_entry (client,
					"/apps/mateconf-editor/can_edit_source",
					NULL,
					FALSE,
					&error);
	if (error != NULL) {
		g_assert (entry == NULL);
		g_error_free (error);
		g_object_unref (client);
		mateconf_engine_unref (engine);
		return FALSE;
	}

	g_assert (entry != NULL);

	retval = mateconf_entry_get_is_writable (entry);

	mateconf_entry_unref (entry);
	g_object_unref (client);
	mateconf_engine_unref (engine);

	return retval;
}
void
mateconf_entry_free (MateConfEntry *entry)
{
  mateconf_entry_unref (entry);
}
static
gboolean
mateconf_tree_model_search_iter_foreach (GtkTreeModel *model, GtkTreePath *path,
				      GtkTreeIter *iter, gpointer data)
{
	Node    *node;
	SearchIter *st;
	gchar *found;
	GSList *values, *list;

	st = (SearchIter *) data;

	if (st->searching == NULL) {
		return TRUE;
	}

	if (st->res >= 1) {
		gtk_widget_show (GTK_WIDGET (st->output_window));
	}
	while (gtk_events_pending ())
		gtk_main_iteration ();

	node = iter->user_data;
	found = g_strrstr ((char*) node->path, (char*) st->pattern);

	if (found != NULL) {
		/* We found the pattern in the tree */
		gchar *key = mateconf_tree_model_get_mateconf_path (MATECONF_TREE_MODEL (model), iter);
		gedit_output_window_append_line (st->output_window, key, FALSE);
		g_free (key);
		st->res++;
		return FALSE;
	}

	if (!st->search_keys && !st->search_values) {
		return FALSE;
	}
	values = mateconf_client_all_entries (MATECONF_TREE_MODEL (model)->client, (const char*) node->path , NULL);
	for (list = values; list; list = list->next) {
		const gchar *key;
		MateConfEntry *entry = list->data;
		key = mateconf_entry_get_key (entry);
		/* Search in the key names */
		if (st->search_keys) {
			found = g_strrstr (key, (char*) st->pattern);
			if (found != NULL) {
				/* We found the pattern in the final key name */
				gedit_output_window_append_line (st->output_window, key, FALSE);
				st->res++;
				mateconf_entry_unref (entry);
				/* After finding an entry continue the list to find other matches */
				continue;
			}
		}

		/* Search in the values */
		if (st->search_values) {
			const char *mateconf_string;
			MateConfValue *mateconf_value = mateconf_entry_get_value (entry);

			/* FIXME: We are only looking into strings... should we do in
			 * int's? */
			if (mateconf_value != NULL && mateconf_value->type == MATECONF_VALUE_STRING)
				mateconf_string = mateconf_value_get_string (mateconf_value);
			else {
				mateconf_entry_unref (entry);
				continue;
			}

                	found = g_strrstr (mateconf_string, (char*) st->pattern);
			if (found != NULL) {
				/* We found the pattern in the key value */
				gedit_output_window_append_line (st->output_window, key, FALSE);
				st->res++;
				mateconf_entry_unref (entry);
				continue;
			}
		}
		mateconf_entry_unref (entry);
	}

	return FALSE;
}