"Fossies" - the Fresh Open Source Software Archive

Member "gtkdatabox-1.0.0/gtk/gtkdatabox_cross_simple.c" (31 Mar 2021, 3078 Bytes) of package /linux/privat/gtkdatabox-1.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* $Id: gtkdatabox_cross_simple.c 4 2008-06-22 09:19:11Z rbock $ */
    2 /* GtkDatabox - An extension to the gtk+ library
    3  * Copyright (C) 1998 - 2008  Dr. Roland Bock
    4  *
    5  * This program is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU Lesser General Public License
    7  * as published by the Free Software Foundation; either version 2.1
    8  * of the License, or (at your option) any later version.
    9  * 
   10  * This program is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  * GNU Lesser General Public License for more details.
   14  * 
   15  * You should have received a copy of the GNU General Public License
   16  * along with this program; if not, write to the Free Software
   17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   18  */
   19 
   20 #include <gtkdatabox_cross_simple.h>
   21 
   22 G_DEFINE_TYPE(GtkDataboxCrossSimple, gtk_databox_cross_simple,
   23     GTK_DATABOX_TYPE_MARKERS)
   24 
   25 static void
   26 cross_simple_finalize (GObject * object)
   27 {
   28    gpointer pointer;
   29 
   30    pointer = gtk_databox_xyc_graph_get_X (GTK_DATABOX_XYC_GRAPH (object));
   31    if (pointer)
   32       g_free (pointer);
   33 
   34    pointer = gtk_databox_xyc_graph_get_Y (GTK_DATABOX_XYC_GRAPH (object));
   35    if (pointer)
   36       g_free (pointer);
   37 
   38    /* Chain up to the parent class */
   39    G_OBJECT_CLASS (gtk_databox_cross_simple_parent_class)->finalize (object);
   40 }
   41 
   42 static void
   43 gtk_databox_cross_simple_class_init (GtkDataboxCrossSimpleClass *klass)
   44 {
   45    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   46 
   47    gobject_class->finalize = cross_simple_finalize;
   48 }
   49 
   50 static void gtk_databox_cross_simple_init(GtkDataboxCrossSimple *cross) 
   51 {
   52    if (cross == NULL) g_warning ("cross_simple_init with NULL");
   53 }
   54 
   55 /**
   56  * gtk_databox_cross_simple_new:
   57  * @color: color of the markers
   58  * @size: marker size or line width (depending on the @type)
   59  *
   60  * Creates a new #GtkDataboxCrossSimple object which can be added to a #GtkDatabox widget as nice decoration for other graphs.
   61  *
   62  * Return value: A new #GtkDataboxCrossSimple object
   63  **/
   64 GtkDataboxGraph *
   65 gtk_databox_cross_simple_new (GdkRGBA * color, guint size)
   66 {
   67    GtkDataboxCrossSimple *cross_simple;
   68    gfloat *X = g_new0 (gfloat, 2);
   69    gfloat *Y = g_new0 (gfloat, 2);
   70    gint len = 2;
   71 
   72    cross_simple = g_object_new (GTK_DATABOX_TYPE_CROSS_SIMPLE,
   73                 "markers-type", GTK_DATABOX_MARKERS_SOLID_LINE,
   74                 "X-Values", X,
   75                 "Y-Values", Y,
   76                 "xstart", 0,
   77                 "ystart", 0,
   78                 "xstride", 1,
   79                 "ystride", 1,
   80                 "xtype", G_TYPE_FLOAT,
   81                 "ytype", G_TYPE_FLOAT,
   82                 "length", len,
   83                 "maxlen", len,
   84                 "color", color, "size", size, NULL);
   85 
   86    gtk_databox_markers_set_position (GTK_DATABOX_MARKERS (cross_simple), 0,
   87                     GTK_DATABOX_MARKERS_C);
   88    gtk_databox_markers_set_label (GTK_DATABOX_MARKERS (cross_simple), 0,
   89                  GTK_DATABOX_MARKERS_TEXT_SW, "0", FALSE);
   90    gtk_databox_markers_set_position (GTK_DATABOX_MARKERS (cross_simple), 1,
   91                     GTK_DATABOX_MARKERS_W);
   92 
   93    return GTK_DATABOX_GRAPH (cross_simple);
   94 }