libanjuta: bgo #696984 - Fix function argument name typos in documentation comments
[anjuta.git] / libanjuta / anjuta-column-text-view.c
blob9858b1d55e9406719cd9cb61a5342b4acbd5aaa3
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
5 *
6 * anjuta is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * anjuta is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "anjuta-column-text-view.h"
22 struct _AnjutaColumnTextViewPriv
24 GtkWidget *text_view;
25 GtkWidget *column_label;
28 G_DEFINE_TYPE (AnjutaColumnTextView, anjuta_column_text_view, GTK_TYPE_VBOX);
30 static void
31 set_text_view_column_label (GtkTextBuffer *buffer,
32 GtkTextIter *location,
33 GtkTextMark *mark,
34 GtkLabel *column_label)
36 gint column;
37 gchar *text;
39 column = gtk_text_iter_get_line_offset (location) + 1;
40 text = g_strdup_printf (_("Column %i"), column);
42 gtk_label_set_text (column_label, text);
44 g_free (text);
47 static void
48 anjuta_column_text_view_init (AnjutaColumnTextView *self)
50 GtkWidget *scrolled_window;
51 GtkTextBuffer *text_buffer;
53 self->priv = g_new0 (AnjutaColumnTextViewPriv, 1);
55 /* Text view */
56 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
58 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
59 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
60 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
61 GTK_SHADOW_IN);
63 self->priv->text_view = gtk_text_view_new ();
65 gtk_container_add (GTK_CONTAINER (scrolled_window), self->priv->text_view);
66 gtk_box_pack_start (GTK_BOX (self), scrolled_window, TRUE, TRUE, 0);
68 /* Column label */
69 self->priv->column_label = gtk_label_new (_("Column 1"));
71 /* Right justify the label text */
72 g_object_set (G_OBJECT (self->priv->column_label), "xalign", 1.0, NULL);
74 /* Column change handling */
75 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->text_view));
77 g_signal_connect (G_OBJECT (text_buffer), "mark-set",
78 G_CALLBACK (set_text_view_column_label),
79 self->priv->column_label);
81 gtk_box_pack_start (GTK_BOX (self), self->priv->column_label, FALSE, FALSE,
82 0);
84 /* Allow focusing */
85 gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
87 gtk_widget_show_all (GTK_WIDGET (self));
90 static void
91 anjuta_column_text_view_finalize (GObject *object)
93 AnjutaColumnTextView *self;
95 self = ANJUTA_COLUMN_TEXT_VIEW (object);
97 g_free (self->priv);
99 G_OBJECT_CLASS (anjuta_column_text_view_parent_class)->finalize (object);
102 static void
103 anjuta_column_text_view_grab_focus (GtkWidget *widget)
105 AnjutaColumnTextView *self;
107 self = ANJUTA_COLUMN_TEXT_VIEW (widget);
109 gtk_widget_grab_focus (self->priv->text_view);
112 static void
113 anjuta_column_text_view_class_init (AnjutaColumnTextViewClass *klass)
115 GObjectClass* object_class = G_OBJECT_CLASS (klass);
116 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
118 object_class->finalize = anjuta_column_text_view_finalize;
119 widget_class->grab_focus = anjuta_column_text_view_grab_focus;
123 GtkWidget *
124 anjuta_column_text_view_new (void)
126 return g_object_new (ANJUTA_TYPE_COLUMN_TEXT_VIEW, NULL);
129 gchar *
130 anjuta_column_text_view_get_text (AnjutaColumnTextView *self)
132 GtkTextBuffer *text_buffer;
133 GtkTextIter start_iter;
134 GtkTextIter end_iter;
135 gchar *text;
137 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->text_view));
139 gtk_text_buffer_get_start_iter (text_buffer, &start_iter);
140 gtk_text_buffer_get_end_iter (text_buffer, &end_iter) ;
142 text = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, FALSE);
144 return text;
147 GtkTextBuffer *
148 anjuta_column_text_view_get_buffer (AnjutaColumnTextView *self)
150 return gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->text_view));