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-checkout-pane.h"
22 struct _GitCheckoutPanePriv
27 G_DEFINE_TYPE (GitCheckoutPane
, git_checkout_pane
, GIT_TYPE_PANE
);
30 on_ok_action_activated (GtkAction
*action
, GitCheckoutPane
*self
)
33 GtkToggleAction
*force_action
;
35 GitCheckoutFilesCommand
*checkout_command
;
37 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self
)));
38 force_action
= GTK_TOGGLE_ACTION (gtk_builder_get_object (self
->priv
->builder
,
41 paths
= git_status_pane_get_checked_not_updated_items (GIT_STATUS_PANE (plugin
->status_pane
),
42 ANJUTA_VCS_STATUS_ALL
);
43 checkout_command
= git_checkout_files_command_new (plugin
->project_root_directory
,
45 gtk_toggle_action_get_active (force_action
));
47 anjuta_util_glist_strings_free (paths
);
49 g_signal_connect (G_OBJECT (checkout_command
), "command-finished",
50 G_CALLBACK (git_pane_report_errors
),
53 g_signal_connect (G_OBJECT (checkout_command
), "command-finished",
54 G_CALLBACK (g_object_unref
),
57 anjuta_command_start (ANJUTA_COMMAND (checkout_command
));
59 git_pane_remove_from_dock (GIT_PANE (self
));
64 git_checkout_pane_init (GitCheckoutPane
*self
)
66 gchar
*objects
[] = {"checkout_pane",
73 GtkAction
*cancel_action
;
75 self
->priv
= g_new0 (GitCheckoutPanePriv
, 1);
76 self
->priv
->builder
= gtk_builder_new ();
78 if (!gtk_builder_add_objects_from_file (self
->priv
->builder
, BUILDER_FILE
,
82 g_warning ("Couldn't load builder file: %s", error
->message
);
86 ok_action
= GTK_ACTION (gtk_builder_get_object (self
->priv
->builder
,
88 cancel_action
= GTK_ACTION (gtk_builder_get_object (self
->priv
->builder
,
91 g_signal_connect (G_OBJECT (ok_action
), "activate",
92 G_CALLBACK (on_ok_action_activated
),
95 g_signal_connect_swapped (G_OBJECT (cancel_action
), "activate",
96 G_CALLBACK (git_pane_remove_from_dock
),
101 git_checkout_pane_finalize (GObject
*object
)
103 GitCheckoutPane
*self
;
105 self
= GIT_CHECKOUT_PANE (object
);
107 g_object_unref (self
->priv
->builder
);
110 G_OBJECT_CLASS (git_checkout_pane_parent_class
)->finalize (object
);
114 get_widget (AnjutaDockPane
*pane
)
116 GitCheckoutPane
*self
;
118 self
= GIT_CHECKOUT_PANE (pane
);
120 return GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
125 git_checkout_pane_class_init (GitCheckoutPaneClass
*klass
)
127 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
128 AnjutaDockPaneClass
* pane_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
130 object_class
->finalize
= git_checkout_pane_finalize
;
131 pane_class
->get_widget
= get_widget
;
132 pane_class
->refresh
= NULL
;
137 git_checkout_pane_new (Git
*plugin
)
139 return g_object_new (GIT_TYPE_CHECKOUT_PANE
, "plugin", plugin
, NULL
);
143 on_checkout_button_clicked (GtkAction
*action
, Git
*plugin
)
145 AnjutaDockPane
*checkout_pane
;
147 checkout_pane
= git_checkout_pane_new (plugin
);
149 anjuta_dock_replace_command_pane (ANJUTA_DOCK (plugin
->dock
), "Checkout",
150 _("Check Out Files"), NULL
, checkout_pane
,
151 GDL_DOCK_BOTTOM
, NULL
, 0, NULL
);
155 on_git_status_checkout_activated (GtkAction
*action
, Git
*plugin
)
159 GitCheckoutFilesCommand
*checkout_command
;
161 path
= git_status_pane_get_selected_not_updated_path (GIT_STATUS_PANE (plugin
->status_pane
));
165 paths
= g_list_append (NULL
, path
);
167 checkout_command
= git_checkout_files_command_new (plugin
->project_root_directory
,
170 g_signal_connect (G_OBJECT (checkout_command
), "command-finished",
171 G_CALLBACK (git_pane_report_errors
),
174 g_signal_connect (G_OBJECT (checkout_command
), "command-finished",
175 G_CALLBACK (g_object_unref
),
178 anjuta_util_glist_strings_free (paths
);
180 anjuta_command_start (ANJUTA_COMMAND (checkout_command
));