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/>.
20 #include "git-create-tag-pane.h"
22 struct _GitCreateTagPanePriv
27 G_DEFINE_TYPE (GitCreateTagPane
, git_create_tag_pane
, GIT_TYPE_PANE
);
30 on_ok_button_clicked (GtkButton
*button
, GitCreateTagPane
*self
)
34 AnjutaEntry
*revision_entry
;
35 GtkToggleButton
*force_check
;
36 GtkToggleButton
*sign_check
;
37 GtkToggleButton
*annotate_check
;
38 AnjutaColumnTextView
*log_view
;
40 const gchar
*revision
;
42 GitTagCreateCommand
*create_command
;
44 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self
)));
45 name_entry
= GTK_ENTRY (gtk_builder_get_object (self
->priv
->builder
,
47 revision_entry
= ANJUTA_ENTRY (gtk_builder_get_object (self
->priv
->builder
,
49 force_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
51 sign_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
53 annotate_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
55 log_view
= ANJUTA_COLUMN_TEXT_VIEW (gtk_builder_get_object (self
->priv
->builder
,
57 name
= gtk_editable_get_chars (GTK_EDITABLE (name_entry
), 0, -1);
58 revision
= anjuta_entry_get_text (revision_entry
);
61 if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin
)->shell
),
62 GTK_WIDGET (name_entry
), name
,
63 _("Please enter a tag name.")))
70 if (g_utf8_strlen (revision
, -1) == 0)
73 if (gtk_toggle_button_get_active (annotate_check
))
75 log
= anjuta_column_text_view_get_text (log_view
);
77 if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin
)->shell
),
78 GTK_WIDGET (log_view
), log
,
79 _("Please enter a log message.")))
88 create_command
= git_tag_create_command_new (plugin
->project_root_directory
,
92 gtk_toggle_button_get_active (sign_check
),
93 gtk_toggle_button_get_active (force_check
));
95 g_signal_connect (G_OBJECT (create_command
), "command-finished",
96 G_CALLBACK (git_pane_report_errors
),
100 g_signal_connect (G_OBJECT (create_command
), "command-finished",
101 G_CALLBACK (g_object_unref
),
104 anjuta_command_start (ANJUTA_COMMAND (create_command
));
110 git_pane_remove_from_dock (GIT_PANE (self
));
114 set_widget_sensitive (GtkToggleButton
*button
, GtkWidget
*widget
)
116 gtk_widget_set_sensitive (widget
,
117 gtk_toggle_button_get_active (button
));
121 git_create_tag_pane_init (GitCreateTagPane
*self
)
123 gchar
*objects
[] = {"create_tag_pane",
125 GError
*error
= NULL
;
126 GtkWidget
*ok_button
;
127 GtkWidget
*cancel_button
;
128 GtkWidget
*revision_entry
;
129 GtkWidget
*annotate_check
;
133 self
->priv
= g_new0 (GitCreateTagPanePriv
, 1);
134 self
->priv
->builder
= gtk_builder_new ();
136 if (!gtk_builder_add_objects_from_file (self
->priv
->builder
, BUILDER_FILE
,
140 g_warning ("Couldn't load builder file: %s", error
->message
);
141 g_error_free (error
);
144 ok_button
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
146 cancel_button
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
148 revision_entry
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
150 annotate_check
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
152 log_view
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
155 g_signal_connect (G_OBJECT (ok_button
), "clicked",
156 G_CALLBACK (on_ok_button_clicked
),
159 g_signal_connect_swapped (G_OBJECT (cancel_button
), "clicked",
160 G_CALLBACK (git_pane_remove_from_dock
),
163 g_signal_connect (G_OBJECT (annotate_check
), "toggled",
164 G_CALLBACK (set_widget_sensitive
),
169 git_create_tag_pane_finalize (GObject
*object
)
171 GitCreateTagPane
*self
;
173 self
= GIT_CREATE_TAG_PANE (object
);
175 g_object_unref (self
->priv
->builder
);
178 G_OBJECT_CLASS (git_create_tag_pane_parent_class
)->finalize (object
);
182 git_create_tag_pane_get_widget (AnjutaDockPane
*pane
)
184 GitCreateTagPane
*self
;
186 self
= GIT_CREATE_TAG_PANE (pane
);
188 return GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
193 git_create_tag_pane_class_init (GitCreateTagPaneClass
*klass
)
195 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
196 AnjutaDockPaneClass
*pane_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
198 object_class
->finalize
= git_create_tag_pane_finalize
;
199 pane_class
->get_widget
= git_create_tag_pane_get_widget
;
200 pane_class
->refresh
= NULL
;
205 git_create_tag_pane_new (Git
*plugin
)
207 return g_object_new (GIT_TYPE_CREATE_TAG_PANE
, "plugin", plugin
, NULL
);
211 on_create_tag_button_clicked (GtkAction
*action
, Git
*plugin
)
213 AnjutaDockPane
*pane
;
215 pane
= git_create_tag_pane_new (plugin
);
217 anjuta_dock_add_pane (ANJUTA_DOCK (plugin
->dock
), "CreateTag",
218 _("Create Tag"), NULL
, pane
, GDL_DOCK_BOTTOM
, NULL
, 0,