1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2006 <jrliggett@cox.net>
6 * gprof-view.c is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2, or (at your option) any later version.
12 * plugin.c is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with plugin.c. See the file "COPYING". If not,
19 * write to: The Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "gprof-view.h"
28 GProfProfileData
*profile_data
;
29 IAnjutaSymbolManager
*symbol_manager
;
30 IAnjutaDocumentManager
*document_manager
;
34 gprof_view_init (GProfView
*self
)
36 self
->priv
= g_new0 (GProfViewPriv
, 1);
40 gprof_view_finalize (GObject
*obj
)
44 self
= (GProfView
*) obj
;
46 gprof_profile_data_free (self
->priv
->profile_data
);
51 gprof_view_class_init (GProfViewClass
*klass
)
53 GObjectClass
*object_class
;
55 object_class
= (GObjectClass
*) klass
;
56 object_class
->finalize
= gprof_view_finalize
;
58 klass
->refresh
= NULL
;
59 klass
->get_widget
= NULL
;
63 gprof_view_get_type (void)
65 static GType obj_type
= 0;
69 static const GTypeInfo obj_info
=
71 sizeof (GProfViewClass
),
73 (GBaseFinalizeFunc
) NULL
,
74 (GClassInitFunc
) gprof_view_class_init
,
75 (GClassFinalizeFunc
) NULL
,
76 NULL
, /* class_data */
79 (GInstanceInitFunc
) gprof_view_init
,
80 NULL
/* value_table */
82 obj_type
= g_type_register_static (G_TYPE_OBJECT
,
83 "GProfView", &obj_info
, 0);
89 gprof_view_set_data (GProfView
*self
, GProfProfileData
*profile_data
)
91 self
->priv
->profile_data
= g_object_ref (profile_data
);
95 gprof_view_get_data (GProfView
*self
)
97 return self
->priv
->profile_data
;
101 gprof_view_set_symbol_manager (GProfView
*self
,
102 IAnjutaSymbolManager
*symbol_manager
)
104 self
->priv
->symbol_manager
= symbol_manager
;
108 gprof_view_set_document_manager (GProfView
*self
,
109 IAnjutaDocumentManager
*document_manager
)
111 self
->priv
->document_manager
= document_manager
;
115 gprof_view_show_symbol_in_editor (GProfView
*self
,
116 const gchar
*symbol_name
)
118 IAnjutaIterable
*symbol_iter
;
119 IAnjutaSymbol
*symbol
;
122 if (self
->priv
->symbol_manager
&&
123 self
->priv
->document_manager
)
125 symbol_iter
= ianjuta_symbol_manager_search (self
->priv
->symbol_manager
,
126 IANJUTA_SYMBOL_TYPE_FUNCTION
,
128 IANJUTA_SYMBOL_FIELD_SIMPLE
,
138 ianjuta_iterable_get_length (symbol_iter
, NULL
) > 0)
141 symbol
= IANJUTA_SYMBOL (symbol_iter
);
142 file
= ianjuta_symbol_get_file (symbol
, NULL
);
143 line
= ianjuta_symbol_get_line (symbol
, NULL
);
145 ianjuta_document_manager_goto_file_line (self
->priv
->document_manager
,
148 g_object_unref (symbol_iter
);
149 g_object_unref (file
);
155 gprof_view_refresh (GProfView
*self
)
157 /* Don't refresh views if we don't have any data to work with */
158 if (gprof_profile_data_has_data (self
->priv
->profile_data
))
159 GPROF_VIEW_GET_CLASS (self
)->refresh (self
);
163 gprof_view_get_widget (GProfView
*self
)
165 return GPROF_VIEW_GET_CLASS (self
)->get_widget (self
);
169 gprof_view_format_float (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
,
170 GtkTreeModel
*model
, GtkTreeIter
*iter
,
171 gpointer column_number
)
174 gchar
*formatted_number
;
176 gtk_tree_model_get (model
, iter
, GPOINTER_TO_INT (column_number
), &number
,
179 formatted_number
= g_strdup_printf ("%0.2f", number
);
180 g_object_set (renderer
, "text", formatted_number
, NULL
);
182 g_free (formatted_number
);