Updated Spanish translation
[anjuta-git-plugin.git] / plugins / profiler / gprof-view.c
blobd0755878861d4df6bc5a77f7677b5ef22e398d7f
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * gprof-view.c
4 * Copyright (C) James Liggett 2006 <jrliggett@cox.net>
5 *
6 * gprof-view.c is free software.
7 *
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"
26 struct _GProfViewPriv
28 GProfProfileData *profile_data;
29 IAnjutaSymbolManager *symbol_manager;
30 IAnjutaDocumentManager *document_manager;
33 static void
34 gprof_view_init (GProfView *self)
36 self->priv = g_new0 (GProfViewPriv, 1);
39 static void
40 gprof_view_finalize (GObject *obj)
42 GProfView *self;
44 self = (GProfView *) obj;
46 gprof_profile_data_free (self->priv->profile_data);
47 g_free(self->priv);
50 static void
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;
62 GType
63 gprof_view_get_type (void)
65 static GType obj_type = 0;
67 if (!obj_type)
69 static const GTypeInfo obj_info =
71 sizeof (GProfViewClass),
72 (GBaseInitFunc) NULL,
73 (GBaseFinalizeFunc) NULL,
74 (GClassInitFunc) gprof_view_class_init,
75 (GClassFinalizeFunc) NULL,
76 NULL, /* class_data */
77 sizeof (GProfView),
78 0, /* n_preallocs */
79 (GInstanceInitFunc) gprof_view_init,
80 NULL /* value_table */
82 obj_type = g_type_register_static (G_TYPE_OBJECT,
83 "GProfView", &obj_info, 0);
85 return obj_type;
88 void
89 gprof_view_set_data (GProfView *self, GProfProfileData *profile_data)
91 self->priv->profile_data = g_object_ref (profile_data);
94 GProfProfileData *
95 gprof_view_get_data (GProfView *self)
97 return self->priv->profile_data;
100 void
101 gprof_view_set_symbol_manager (GProfView *self,
102 IAnjutaSymbolManager *symbol_manager)
104 self->priv->symbol_manager = symbol_manager;
107 void
108 gprof_view_set_document_manager (GProfView *self,
109 IAnjutaDocumentManager *document_manager)
111 self->priv->document_manager = document_manager;
114 void
115 gprof_view_show_symbol_in_editor (GProfView *self,
116 const gchar *symbol_name)
118 IAnjutaIterable *symbol_iter;
119 IAnjutaSymbol *symbol;
120 const gchar *file;
121 guint line;
123 if (self->priv->symbol_manager &&
124 self->priv->document_manager)
126 symbol_iter = ianjuta_symbol_manager_search (self->priv->symbol_manager,
127 IANJUTA_SYMBOL_TYPE_FUNCTION,
128 symbol_name,
129 FALSE,
130 TRUE,
131 NULL);
133 if (symbol_iter &&
134 ianjuta_iterable_get_length (symbol_iter, NULL) > 0)
136 symbol = IANJUTA_SYMBOL (symbol_iter);
137 file = ianjuta_symbol_file (symbol, NULL);
138 line = ianjuta_symbol_line (symbol, NULL);
140 ianjuta_document_manager_goto_file_line (self->priv->document_manager,
141 file, line, NULL);
143 g_object_unref (symbol_iter);
148 void
149 gprof_view_refresh (GProfView *self)
151 /* Don't refresh views if we don't have any data to work with */
152 if (gprof_profile_data_has_data (self->priv->profile_data))
153 GPROF_VIEW_GET_CLASS (self)->refresh (self);
156 GtkWidget *
157 gprof_view_get_widget (GProfView *self)
159 return GPROF_VIEW_GET_CLASS (self)->get_widget (self);