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-add-files-pane.h"
22 struct _GitAddFilesPanePriv
27 G_DEFINE_TYPE (GitAddFilesPane
, git_add_files_pane
, GIT_TYPE_PANE
);
30 on_ok_button_clicked (GtkButton
*button
, GitAddFilesPane
*self
)
33 AnjutaFileList
*file_list
;
34 GtkToggleButton
*force_check
;
36 GitAddCommand
*add_command
;
38 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self
)));
39 file_list
= ANJUTA_FILE_LIST (gtk_builder_get_object (self
->priv
->builder
,
41 force_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
43 paths
= anjuta_file_list_get_paths (file_list
);
44 add_command
= git_add_command_new_list (plugin
->project_root_directory
,
46 gtk_toggle_button_get_active (force_check
));
48 git_command_free_string_list (paths
);
50 g_signal_connect (G_OBJECT (add_command
), "command-finished",
51 G_CALLBACK (g_object_unref
),
54 anjuta_command_start (ANJUTA_COMMAND (add_command
));
56 anjuta_dock_remove_pane (ANJUTA_DOCK (plugin
->dock
),
57 ANJUTA_DOCK_PANE (self
));
61 on_cancel_button_clicked (GtkButton
*button
, GitAddFilesPane
*self
)
65 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self
)));
67 anjuta_dock_remove_pane (ANJUTA_DOCK (plugin
->dock
),
68 ANJUTA_DOCK_PANE (self
));
72 git_add_files_pane_init (GitAddFilesPane
*self
)
74 gchar
*objects
[] = {"add_pane",
78 GtkWidget
*cancel_button
;
80 self
->priv
= g_new0 (GitAddFilesPanePriv
, 1);
81 self
->priv
->builder
= gtk_builder_new ();
83 if (!gtk_builder_add_objects_from_file (self
->priv
->builder
, BUILDER_FILE
,
87 g_warning ("Couldn't load builder file: %s", error
->message
);
91 ok_button
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
93 cancel_button
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
96 g_signal_connect (G_OBJECT (ok_button
), "clicked",
97 G_CALLBACK (on_ok_button_clicked
),
100 g_signal_connect (G_OBJECT (cancel_button
), "clicked",
101 G_CALLBACK (on_cancel_button_clicked
),
106 git_add_files_pane_finalize (GObject
*object
)
108 GitAddFilesPane
*self
;
110 self
= GIT_ADD_FILES_PANE (object
);
112 g_object_unref (self
->priv
->builder
);
115 G_OBJECT_CLASS (git_add_files_pane_parent_class
)->finalize (object
);
119 git_add_files_pane_get_widget (AnjutaDockPane
*pane
)
121 GitAddFilesPane
*self
;
123 self
= GIT_ADD_FILES_PANE (pane
);
125 return GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
130 git_add_files_pane_class_init (GitAddFilesPaneClass
*klass
)
132 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
133 AnjutaDockPaneClass
* pane_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
135 object_class
->finalize
= git_add_files_pane_finalize
;
136 pane_class
->get_widget
= git_add_files_pane_get_widget
;
137 pane_class
->refresh
= NULL
;
141 git_add_files_pane_new (Git
*plugin
)
143 GitAddFilesPane
*self
;
144 AnjutaFileList
*file_list
;
146 self
= g_object_new (GIT_TYPE_ADD_FILES_PANE
, "plugin", plugin
, NULL
);
147 file_list
= ANJUTA_FILE_LIST (gtk_builder_get_object (self
->priv
->builder
,
150 anjuta_file_list_set_relative_path (file_list
,
151 plugin
->project_root_directory
);
153 return ANJUTA_DOCK_PANE (self
);
157 on_add_button_clicked (GtkAction
*action
, Git
* plugin
)
159 AnjutaDockPane
*pane
;
161 pane
= git_add_files_pane_new (plugin
);
163 anjuta_dock_add_pane (ANJUTA_DOCK (plugin
->dock
), "AddFiles",
164 _("Add Files"), NULL
, pane
, GDL_DOCK_BOTTOM
,