The C version of looping over buttons and other items was weakly typed, causing runtime errors, and also C doesn't know how to iterate in abstract, so it was full of callbacks with user-defined data. Moving this to Rust, iteration is made of simple loops, and compile-time type-checked, at the cost of some more verbose code.
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/* 
 | 
						|
 * Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
 | 
						|
 * Copyright (C) 2010-2011 Red Hat, Inc.
 | 
						|
 * 
 | 
						|
 * This library is free software; you can redistribute it and/or
 | 
						|
 * modify it under the terms of the GNU Lesser General Public License
 | 
						|
 * as published by the Free Software Foundation; either version 2 of
 | 
						|
 * the License, or (at your option) any later version.
 | 
						|
 * 
 | 
						|
 * This library is distributed in the hope that it will be useful, but
 | 
						|
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
						|
 * Lesser General Public License for more details.
 | 
						|
 * 
 | 
						|
 * You should have received a copy of the GNU Lesser General Public
 | 
						|
 * License along with this library; if not, write to the Free Software
 | 
						|
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 | 
						|
 * 02110-1301 USA
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * SECTION:eek-layout
 | 
						|
 * @short_description: Base class of a layout engine
 | 
						|
 *
 | 
						|
 * The #EekLayout class is a base class of layout engine which
 | 
						|
 * arranges keyboard elements.
 | 
						|
 */
 | 
						|
 | 
						|
#include "config.h"
 | 
						|
 | 
						|
#include "eek-layout.h"
 | 
						|
#include "eek-keyboard.h"
 | 
						|
#include "eekboard/eekboard-context-service.h"
 | 
						|
#include "eek-xml-layout.h"
 | 
						|
 | 
						|
G_DEFINE_ABSTRACT_TYPE (EekLayout, eek_layout, G_TYPE_OBJECT)
 | 
						|
 | 
						|
static void
 | 
						|
eek_layout_class_init (EekLayoutClass *klass)
 | 
						|
{
 | 
						|
    klass->create_keyboard = NULL;
 | 
						|
}
 | 
						|
 | 
						|
void
 | 
						|
eek_layout_init (EekLayout *self)
 | 
						|
{
 | 
						|
}
 | 
						|
 | 
						|
void
 | 
						|
eek_layout_update_layout(LevelKeyboard *keyboard)
 | 
						|
{
 | 
						|
    squeek_view_place_contents(level_keyboard_current(keyboard), keyboard);
 | 
						|
}
 |