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-add-remote-pane.h"
22 struct _GitAddRemotePanePriv
27 G_DEFINE_TYPE (GitAddRemotePane
, git_add_remote_pane
, GIT_TYPE_PANE
);
30 on_ok_button_clicked (GtkButton
*button
, GitAddRemotePane
*self
)
35 GtkToggleButton
*fetch_check
;
38 GitRemoteAddCommand
*add_remote_command
;
40 plugin
= ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self
)));
41 name_entry
= GTK_ENTRY (gtk_builder_get_object (self
->priv
->builder
,
43 url_entry
= GTK_ENTRY (gtk_builder_get_object (self
->priv
->builder
,
45 fetch_check
= GTK_TOGGLE_BUTTON (gtk_builder_get_object (self
->priv
->builder
,
47 name
= gtk_editable_get_chars (GTK_EDITABLE (name_entry
), 0, -1);
48 url
= gtk_editable_get_chars (GTK_EDITABLE (url_entry
), 0, -1);
50 if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin
)->shell
),
51 GTK_WIDGET (name_entry
), name
,
52 _("Please enter a remote name.")) ||
53 !git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin
)->shell
),
54 GTK_WIDGET (url_entry
), url
,
55 _("Please enter a URL")))
63 add_remote_command
= git_remote_add_command_new (plugin
->project_root_directory
,
65 gtk_toggle_button_get_active (fetch_check
));
67 /* Info outupt is only relevant if we're also fetching */
68 if (gtk_toggle_button_get_active (fetch_check
))
70 git_pane_create_message_view (plugin
);
72 g_signal_connect (G_OBJECT (add_remote_command
), "data-arrived",
73 G_CALLBACK (git_pane_on_command_info_arrived
),
77 g_signal_connect (G_OBJECT (add_remote_command
), "command-finished",
78 G_CALLBACK (git_pane_report_errors
),
82 g_signal_connect (G_OBJECT (add_remote_command
), "command-finished",
83 G_CALLBACK (g_object_unref
),
86 anjuta_command_start (ANJUTA_COMMAND (add_remote_command
));
92 git_pane_remove_from_dock (GIT_PANE (self
));
96 git_add_remote_pane_init (GitAddRemotePane
*self
)
98 gchar
*objects
[] = {"add_remote_pane",
100 GError
*error
= NULL
;
101 GtkWidget
*ok_button
;
102 GtkWidget
*cancel_button
;
104 self
->priv
= g_new0 (GitAddRemotePanePriv
, 1);
105 self
->priv
->builder
= gtk_builder_new ();
107 if (!gtk_builder_add_objects_from_file (self
->priv
->builder
, BUILDER_FILE
,
111 g_warning ("Couldn't load builder file: %s", error
->message
);
112 g_error_free (error
);
115 ok_button
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
117 cancel_button
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
120 g_signal_connect (G_OBJECT (ok_button
), "clicked",
121 G_CALLBACK (on_ok_button_clicked
),
124 g_signal_connect_swapped (G_OBJECT (cancel_button
), "clicked",
125 G_CALLBACK (git_pane_remove_from_dock
),
130 git_add_remote_pane_finalize (GObject
*object
)
132 GitAddRemotePane
*self
;
134 self
= GIT_ADD_REMOTE_PANE (object
);
136 g_object_unref (self
->priv
->builder
);
139 G_OBJECT_CLASS (git_add_remote_pane_parent_class
)->finalize (object
);
143 git_add_remote_pane_get_widget (AnjutaDockPane
*pane
)
145 GitAddRemotePane
*self
;
147 self
= GIT_ADD_REMOTE_PANE (pane
);
149 return GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
154 git_add_remote_pane_class_init (GitAddRemotePaneClass
*klass
)
156 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
157 AnjutaDockPaneClass
*pane_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
159 object_class
->finalize
= git_add_remote_pane_finalize
;
160 pane_class
->get_widget
= git_add_remote_pane_get_widget
;
161 pane_class
->refresh
= NULL
;
166 git_add_remote_pane_new (Git
*plugin
)
168 return g_object_new (GIT_TYPE_ADD_REMOTE_PANE
, "plugin", plugin
, NULL
);
172 on_add_remote_button_clicked (GtkAction
*action
, Git
*plugin
)
174 AnjutaDockPane
*pane
;
176 pane
= git_add_remote_pane_new (plugin
);
178 anjuta_dock_add_pane (ANJUTA_DOCK (plugin
->dock
), "AddRemote",
179 _("Add Remote"), NULL
, pane
, GDL_DOCK_BOTTOM
, NULL
, 0,