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-apply-mailbox-pane.h"
22 struct _GitApplyMailboxPanePriv
27 G_DEFINE_TYPE (GitApplyMailboxPane
, git_apply_mailbox_pane
, GIT_TYPE_PANE
);
30 on_ok_action_activated (GtkAction
*action
, GitApplyMailboxPane
*self
)
33 AnjutaFileList
*mailbox_list
;
34 GtkToggleAction
*signoff_action
;
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
,
41 signoff_action
= GTK_TOGGLE_ACTION (gtk_builder_get_object (self
->priv
->builder
,
43 paths
= anjuta_file_list_get_paths (mailbox_list
);
45 apply_mailbox_command
= git_apply_mailbox_command_new (plugin
->project_root_directory
,
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
),
55 g_signal_connect (G_OBJECT (apply_mailbox_command
), "command-finished",
56 G_CALLBACK (git_pane_report_errors
),
60 g_signal_connect (G_OBJECT (apply_mailbox_command
), "command-finished",
61 G_CALLBACK (g_object_unref
),
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
));
73 git_apply_mailbox_pane_init (GitApplyMailboxPane
*self
)
75 gchar
*objects
[] = {"apply_mailbox_pane",
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
,
91 g_warning ("Couldn't load builder file: %s", error
->message
);
95 ok_action
= GTK_ACTION (gtk_builder_get_object (self
->priv
->builder
,
97 cancel_action
= GTK_ACTION (gtk_builder_get_object (self
->priv
->builder
,
100 g_signal_connect (G_OBJECT (ok_action
), "activate",
101 G_CALLBACK (on_ok_action_activated
),
104 g_signal_connect_swapped (G_OBJECT (cancel_action
), "activate",
105 G_CALLBACK (git_pane_remove_from_dock
),
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
);
119 G_OBJECT_CLASS (git_apply_mailbox_pane_parent_class
)->finalize (object
);
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"));
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
;
146 git_apply_mailbox_pane_new (Git
*plugin
)
148 return g_object_new (GIT_TYPE_APPLY_MAILBOX_PANE
, "plugin", plugin
, NULL
);
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
);
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
),
177 g_signal_connect (G_OBJECT (continue_command
), "command-finished",
178 G_CALLBACK (git_pane_report_errors
),
181 g_signal_connect (G_OBJECT (continue_command
), "command-finished",
182 G_CALLBACK (g_object_unref
),
185 anjuta_command_start (ANJUTA_COMMAND (continue_command
));
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
),
202 g_signal_connect (G_OBJECT (continue_command
), "command-finished",
203 G_CALLBACK (git_pane_report_errors
),
206 g_signal_connect (G_OBJECT (continue_command
), "command-finished",
207 G_CALLBACK (g_object_unref
),
210 anjuta_command_start (ANJUTA_COMMAND (continue_command
));
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
),
227 g_signal_connect (G_OBJECT (continue_command
), "command-finished",
228 G_CALLBACK (git_pane_report_errors
),
231 g_signal_connect (G_OBJECT (continue_command
), "command-finished",
232 G_CALLBACK (g_object_unref
),
235 anjuta_command_start (ANJUTA_COMMAND (continue_command
));