/* * Copyright (C) 2004-2005 Vadim Berezniker * http://www.kryptolus.com * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "stdafx.h" #include "kry_marker.h" #include "kry_region.h" enum { SELECTED, LAST_SIGNAL }; static void kry_region_class_init (KryRegionClass *klass); static void kry_region_init (KryRegion *marker); static guint kry_region_signals[LAST_SIGNAL] = { 0 }; GType kry_region_get_type (void) { static GType kry_region_type = 0; if (!kry_region_type) { static const GTypeInfo kry_region_info = { sizeof (KryRegionClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) kry_region_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (KryRegion), 0, /* n_preallocs */ (GInstanceInitFunc) kry_region_init, }; kry_region_type = g_type_register_static (G_TYPE_OBJECT, "KryRegion", &kry_region_info, (GTypeFlags) 0); } return kry_region_type; } static void kry_region_class_init (KryRegionClass *klass) { klass->changed = NULL; klass->value_changed = NULL; kry_region_signals[SELECTED] = g_signal_new ("selected", G_OBJECT_CLASS_TYPE (klass), (GSignalFlags) (G_SIGNAL_RUN_FIRST), G_STRUCT_OFFSET (KryRegionClass, value_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } static void kry_region_init (KryRegion *region) { region->color_id = -1; region->marker_start = NULL; region->marker_end = NULL; } GObject* kry_region_new (KryMarker *marker_start, KryMarker *marker_end, int colorid) { KryRegion *region; region = KRY_REGION(g_object_new (KRY_TYPE_REGION, NULL)); region->marker_start = marker_start; region->marker_end = marker_end; region->color_id = colorid; return G_OBJECT (region); } void kry_region_selected (KryRegion *region) { g_return_if_fail (KRY_IS_REGION (region)); g_signal_emit (region, kry_region_signals[SELECTED], 0); } KryMarker *kry_region_get_marker_start(KryRegion *region) { g_return_val_if_fail(KRY_IS_REGION(region), NULL); return region->marker_start; } KryMarker *kry_region_get_marker_end(KryRegion *region) { g_return_val_if_fail(KRY_IS_REGION(region), NULL); return region->marker_end; } int kry_region_get_colorid(KryRegion *region) { g_return_val_if_fail(KRY_IS_REGION(region), -1); return region->color_id; } gboolean kry_region_is_highlighted(KryRegion *region) { g_return_val_if_fail(KRY_IS_REGION(region), -1); return region->color_id != -1; }