Updated Spanish translation
[anjuta.git] / plugins / git / git-apply-mailbox-pane.c
blob0dd776256495ba3938ee9ef2d7b961ab160a9578
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * git-shell-test
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
5 *
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-apply-mailbox-pane.h"
22 struct _GitApplyMailboxPanePriv
24 GtkBuilder *builder;
27 G_DEFINE_TYPE (GitApplyMailboxPane, git_apply_mailbox_pane, GIT_TYPE_PANE);
29 static void
30 on_ok_action_activated (GtkAction *action, GitApplyMailboxPane *self)
32 Git *plugin;
33 AnjutaFileList *mailbox_list;
34 GtkToggleAction *signoff_action;
35 GList *paths;
36 GitApplyMailboxCommand *apply_mailbox_command;
38 plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
39 mailbox_list = ANJUTA_FILE_LIST (gtk_builder_get_object (self->priv->builder,
40 "mailbox_list"));
41 signoff_action = GTK_TOGGLE_ACTION (gtk_builder_get_object (self->priv->builder,
42 "signoff_action"));
43 paths = anjuta_file_list_get_paths (mailbox_list);
45 apply_mailbox_command = git_apply_mailbox_command_new (plugin->project_root_directory,
46 paths,
47 gtk_toggle_action_get_active (signoff_action));
49 git_pane_create_message_view (plugin);
51 g_signal_connect (G_OBJECT (apply_mailbox_command), "data-arrived",
52 G_CALLBACK (git_pane_on_command_info_arrived),
53 plugin);
55 g_signal_connect (G_OBJECT (apply_mailbox_command), "command-finished",
56 G_CALLBACK (git_pane_report_errors),
57 plugin);
60 g_signal_connect (G_OBJECT (apply_mailbox_command), "command-finished",
61 G_CALLBACK (g_object_unref),
62 NULL);
64 anjuta_command_start (ANJUTA_COMMAND (apply_mailbox_command));
66 anjuta_util_glist_strings_free (paths);
68 git_pane_remove_from_dock (GIT_PANE (self));
72 static void
73 git_apply_mailbox_pane_init (GitApplyMailboxPane *self)
75 gchar *objects[] = {"apply_mailbox_pane",
76 "ok_action",
77 "cancel_action",
78 "signoff_action",
79 NULL};
80 GError *error = NULL;
81 GtkAction *ok_action;
82 GtkAction *cancel_action;
84 self->priv = g_new0 (GitApplyMailboxPanePriv, 1);
85 self->priv->builder = gtk_builder_new ();
87 if (!gtk_builder_add_objects_from_file (self->priv->builder, BUILDER_FILE,
88 objects,
89 &error))
91 g_warning ("Couldn't load builder file: %s", error->message);
92 g_error_free (error);
95 ok_action = GTK_ACTION (gtk_builder_get_object (self->priv->builder,
96 "ok_action"));
97 cancel_action = GTK_ACTION (gtk_builder_get_object (self->priv->builder,
98 "cancel_action"));
100 g_signal_connect (G_OBJECT (ok_action), "activate",
101 G_CALLBACK (on_ok_action_activated),
102 self);
104 g_signal_connect_swapped (G_OBJECT (cancel_action), "activate",
105 G_CALLBACK (git_pane_remove_from_dock),
106 self);
109 static void
110 git_apply_mailbox_pane_finalize (GObject *object)
112 GitApplyMailboxPane *self;
114 self = GIT_APPLY_MAILBOX_PANE (object);
116 g_object_unref (self->priv->builder);
117 g_free (self->priv);
119 G_OBJECT_CLASS (git_apply_mailbox_pane_parent_class)->finalize (object);
122 static GtkWidget *
123 git_apply_mailbox_pane_get_widget (AnjutaDockPane *pane)
125 GitApplyMailboxPane *self;
127 self = GIT_APPLY_MAILBOX_PANE (pane);
129 return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
130 "apply_mailbox_pane"));
133 static void
134 git_apply_mailbox_pane_class_init (GitApplyMailboxPaneClass *klass)
136 GObjectClass* object_class = G_OBJECT_CLASS (klass);
137 AnjutaDockPaneClass *pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
139 object_class->finalize = git_apply_mailbox_pane_finalize;
140 pane_class->get_widget = git_apply_mailbox_pane_get_widget;
141 pane_class->refresh = NULL;
145 AnjutaDockPane *
146 git_apply_mailbox_pane_new (Git *plugin)
148 return g_object_new (GIT_TYPE_APPLY_MAILBOX_PANE, "plugin", plugin, NULL);
151 void
152 on_apply_mailbox_button_clicked (GtkAction *action, Git *plugin)
154 AnjutaDockPane *pane;
156 pane = git_apply_mailbox_pane_new (plugin);
158 anjuta_dock_replace_command_pane (ANJUTA_DOCK (plugin->dock), "ApplyMailbox",
159 _("Apply Mailbox Files"), NULL, pane,
160 GDL_DOCK_BOTTOM, NULL, 0, NULL);
163 void
164 on_apply_mailbox_continue_button_clicked (GtkAction *action, Git *plugin)
166 GitApplyMailboxContinueCommand *continue_command;
168 continue_command = git_apply_mailbox_continue_command_new (plugin->project_root_directory,
169 GIT_APPLY_MAILBOX_CONTINUE_ACTION_RESOLVED);
171 git_pane_create_message_view (plugin);
173 g_signal_connect (G_OBJECT (continue_command), "data-arrived",
174 G_CALLBACK (git_pane_on_command_info_arrived),
175 plugin);
177 g_signal_connect (G_OBJECT (continue_command), "command-finished",
178 G_CALLBACK (git_pane_report_errors),
179 plugin);
181 g_signal_connect (G_OBJECT (continue_command), "command-finished",
182 G_CALLBACK (g_object_unref),
183 NULL);
185 anjuta_command_start (ANJUTA_COMMAND (continue_command));
188 void
189 on_apply_mailbox_skip_button_clicked (GtkAction *action, Git *plugin)
191 GitApplyMailboxContinueCommand *continue_command;
193 continue_command = git_apply_mailbox_continue_command_new (plugin->project_root_directory,
194 GIT_APPLY_MAILBOX_CONTINUE_ACTION_SKIP);
196 git_pane_create_message_view (plugin);
198 g_signal_connect (G_OBJECT (continue_command), "data-arrived",
199 G_CALLBACK (git_pane_on_command_info_arrived),
200 plugin);
202 g_signal_connect (G_OBJECT (continue_command), "command-finished",
203 G_CALLBACK (git_pane_report_errors),
204 plugin);
206 g_signal_connect (G_OBJECT (continue_command), "command-finished",
207 G_CALLBACK (g_object_unref),
208 NULL);
210 anjuta_command_start (ANJUTA_COMMAND (continue_command));
213 void
214 on_apply_mailbox_abort_button_clicked (GtkAction *action, Git *plugin)
216 GitApplyMailboxContinueCommand *continue_command;
218 continue_command = git_apply_mailbox_continue_command_new (plugin->project_root_directory,
219 GIT_APPLY_MAILBOX_CONTINUE_ACTION_ABORT);
221 git_pane_create_message_view (plugin);
223 g_signal_connect (G_OBJECT (continue_command), "data-arrived",
224 G_CALLBACK (git_pane_on_command_info_arrived),
225 plugin);
227 g_signal_connect (G_OBJECT (continue_command), "command-finished",
228 G_CALLBACK (git_pane_report_errors),
229 plugin);
231 g_signal_connect (G_OBJECT (continue_command), "command-finished",
232 G_CALLBACK (g_object_unref),
233 NULL);
235 anjuta_command_start (ANJUTA_COMMAND (continue_command));