1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
6 * git-shell-test 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 * git-shell-test 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/>.
24 G_DEFINE_ABSTRACT_TYPE (GitPane
, git_pane
, ANJUTA_TYPE_DOCK_PANE
);
27 git_pane_init (GitPane
*object
)
29 /* TODO: Add initialization code here */
33 git_pane_finalize (GObject
*object
)
35 /* TODO: Add deinitalization code here */
37 G_OBJECT_CLASS (git_pane_parent_class
)->finalize (object
);
41 git_pane_class_init (GitPaneClass
*klass
)
43 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
45 AnjutaDockPaneClass
* parent_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
48 object_class
->finalize
= git_pane_finalize
;
52 on_message_view_destroyed (Git
* plugin
, gpointer destroyed_view
)
54 plugin
->message_view
= NULL
;
58 git_pane_create_message_view (Git
*plugin
)
60 IAnjutaMessageManager
*message_manager
;
63 message_manager
= anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin
)->shell
,
64 IAnjutaMessageManager
, NULL
);
65 plugin
->message_view
= ianjuta_message_manager_get_view_by_name (message_manager
,
68 if (!plugin
->message_view
)
70 plugin
->message_view
= ianjuta_message_manager_add_view (message_manager
,
74 g_object_weak_ref (G_OBJECT (plugin
->message_view
),
75 (GWeakNotify
) on_message_view_destroyed
, plugin
);
78 ianjuta_message_view_clear (plugin
->message_view
, NULL
);
79 ianjuta_message_manager_set_current_view (message_manager
,
85 git_pane_on_command_info_arrived (AnjutaCommand
*command
, Git
*plugin
)
90 info
= git_command_get_info_queue (GIT_COMMAND (command
));
92 while (g_queue_peek_head (info
))
94 message
= g_queue_pop_head (info
);
95 ianjuta_message_view_append (plugin
->message_view
,
96 IANJUTA_MESSAGE_VIEW_TYPE_NORMAL
,
103 git_pane_set_log_view_column_label (GtkTextBuffer
*buffer
,
104 GtkTextIter
*location
,
106 GtkLabel
*column_label
)
111 column
= gtk_text_iter_get_line_offset (location
) + 1;
112 text
= g_strdup_printf (_("Column %i"), column
);
114 gtk_label_set_text (column_label
, text
);
120 git_pane_get_log_from_text_view (GtkTextView
*text_view
)
122 GtkTextBuffer
*log_buffer
;
123 GtkTextIter start_iter
;
124 GtkTextIter end_iter
;
127 log_buffer
= gtk_text_view_get_buffer(text_view
);
129 gtk_text_buffer_get_start_iter(log_buffer
, &start_iter
);
130 gtk_text_buffer_get_end_iter(log_buffer
, &end_iter
) ;
132 log
= gtk_text_buffer_get_text(log_buffer
, &start_iter
, &end_iter
, FALSE
);