1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
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 "git-pull-pane.h"
22 struct _GitPullPanePriv
25 GtkWidget
*repository_selector
;
28 G_DEFINE_TYPE (GitPullPane
, git_pull_pane
, GIT_TYPE_PANE
);
31 on_ok_action_activated (GtkAction
*action
, GitPullPane
*self
)
34 GtkToggleButton
*rebase_check
;
35 GtkToggleAction
*no_commit_action
;
36 GtkToggleAction
*squash_action
;
37 GtkToggleButton
*append_fetch_data_check
;
38 GtkToggleButton
*fast_forward_commit_check
;
39 GtkToggleAction
*force_action
;
40 GtkToggleButton
*no_follow_tags_check
;
42 GitPullCommand
*pull_command
;
44 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self
)));
45 rebase_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
47 no_commit_action
= GTK_TOGGLE_ACTION (gtk_builder_get_object (self
->priv
->builder
,
49 squash_action
= GTK_TOGGLE_ACTION (gtk_builder_get_object (self
->priv
->builder
,
51 append_fetch_data_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
52 "append_fetch_data_check"));
53 fast_forward_commit_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
54 "fast_forward_commit_check"));
55 force_action
= GTK_TOGGLE_ACTION (gtk_builder_get_object (self
->priv
->builder
,
57 no_follow_tags_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
58 "no_follow_tags_check"));
60 repository
= git_repository_selector_get_repository (GIT_REPOSITORY_SELECTOR (self
->priv
->repository_selector
));
62 /* Check input. Input can only be bad if the selector is in URL mode */
63 if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin
)->shell
),
64 self
->priv
->repository_selector
,
66 _("Please enter a URL.")))
72 pull_command
= git_pull_command_new (plugin
->project_root_directory
,
74 gtk_toggle_button_get_active (rebase_check
),
75 gtk_toggle_action_get_active (no_commit_action
),
76 gtk_toggle_action_get_active (squash_action
),
77 gtk_toggle_button_get_active (append_fetch_data_check
),
78 gtk_toggle_button_get_active (fast_forward_commit_check
),
79 gtk_toggle_action_get_active (force_action
),
80 gtk_toggle_button_get_active (no_follow_tags_check
));
84 git_pane_create_message_view (plugin
);
86 g_signal_connect (G_OBJECT (pull_command
), "data-arrived",
87 G_CALLBACK (git_pane_on_command_info_arrived
),
90 g_signal_connect (G_OBJECT (pull_command
), "command-finished",
91 G_CALLBACK (git_pane_report_errors
),
94 g_signal_connect (G_OBJECT (pull_command
), "command-finished",
95 G_CALLBACK (git_plugin_status_changed_emit
),
98 g_signal_connect (G_OBJECT (pull_command
), "command-finished",
99 G_CALLBACK (g_object_unref
),
102 anjuta_command_start (ANJUTA_COMMAND (pull_command
));
104 git_pane_remove_from_dock (GIT_PANE (self
));
108 on_remote_selected (AnjutaDockPane
*pane
,
109 GitRepositorySelector
*repository_selector
)
113 remote
= git_remotes_pane_get_selected_remote (GIT_REMOTES_PANE (pane
));
114 git_repository_selector_set_remote (repository_selector
, remote
);
120 git_pull_pane_init (GitPullPane
*self
)
122 gchar
*objects
[] = {"pull_pane",
129 GError
*error
= NULL
;
130 GtkAction
*ok_action
;
131 GtkAction
*cancel_action
;
132 GtkContainer
*pull_repository_alignment
;
134 self
->priv
= g_new0 (GitPullPanePriv
, 1);
135 self
->priv
->builder
= gtk_builder_new ();
137 if (!gtk_builder_add_objects_from_file (self
->priv
->builder
, BUILDER_FILE
,
141 g_warning ("Couldn't load builder file: %s", error
->message
);
142 g_error_free (error
);
145 ok_action
= GTK_ACTION (gtk_builder_get_object (self
->priv
->builder
,
147 cancel_action
= GTK_ACTION (gtk_builder_get_object (self
->priv
->builder
,
149 pull_repository_alignment
= GTK_CONTAINER (gtk_builder_get_object (self
->priv
->builder
,
150 "pull_repository_alignment"));
151 self
->priv
->repository_selector
= git_repository_selector_new ();
153 gtk_container_add (pull_repository_alignment
, self
->priv
->repository_selector
);
155 g_signal_connect (G_OBJECT (ok_action
), "activate",
156 G_CALLBACK (on_ok_action_activated
),
159 g_signal_connect_swapped (G_OBJECT (cancel_action
), "activate",
160 G_CALLBACK (git_pane_remove_from_dock
),
165 git_pull_pane_finalize (GObject
*object
)
169 self
= GIT_PULL_PANE (object
);
171 g_object_unref (self
->priv
->builder
);
174 G_OBJECT_CLASS (git_pull_pane_parent_class
)->finalize (object
);
178 git_pull_pane_dispose (GObject
*object
)
183 self
= GIT_PULL_PANE (object
);
184 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (object
)));
186 g_signal_handlers_disconnect_by_func (plugin
->remotes_pane
,
188 self
->priv
->repository_selector
);
191 G_OBJECT_CLASS (git_pull_pane_parent_class
)->dispose (object
);
195 git_pull_pane_get_widget (AnjutaDockPane
*pane
)
199 self
= GIT_PULL_PANE (pane
);
201 return GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
206 git_pull_pane_class_init (GitPullPaneClass
*klass
)
208 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
209 AnjutaDockPaneClass
*pane_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
211 object_class
->finalize
= git_pull_pane_finalize
;
212 object_class
->dispose
= git_pull_pane_dispose
;
213 pane_class
->get_widget
= git_pull_pane_get_widget
;
218 git_pull_pane_new (Git
*plugin
)
222 self
= g_object_new (GIT_TYPE_PULL_PANE
, "plugin", plugin
, NULL
);
224 g_signal_connect (G_OBJECT (plugin
->remotes_pane
), "single_selection_changed",
225 G_CALLBACK (on_remote_selected
),
226 self
->priv
->repository_selector
);
228 /* Set the contents of the selected remote label */
229 on_remote_selected (plugin
->remotes_pane
,
230 GIT_REPOSITORY_SELECTOR (self
->priv
->repository_selector
));
232 return ANJUTA_DOCK_PANE (self
);
236 on_pull_button_clicked (GtkAction
*action
, Git
*plugin
)
238 AnjutaDockPane
*pane
;
240 pane
= git_pull_pane_new (plugin
);
242 anjuta_dock_replace_command_pane (ANJUTA_DOCK (plugin
->dock
), "Pull",
243 _("Pull"), NULL
, pane
, GDL_DOCK_BOTTOM
,