1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-delete-remote-dialog.h"
28 on_delete_remote_dialog_response (GtkDialog
*dialog
, gint response_id
,
29 GitBranchComboData
*data
)
31 GtkWidget
*delete_remote_branch_combo
;
34 GitRemoteDeleteCommand
*delete_command
;
36 if (response_id
== GTK_RESPONSE_OK
)
38 delete_remote_branch_combo
= glade_xml_get_widget (data
->gxml
,
39 "delete_remote_combo");
41 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (delete_remote_branch_combo
),
43 branch
= git_branch_combo_model_get_branch (data
->model
, &iter
);
45 delete_command
= git_remote_delete_command_new (data
->plugin
->project_root_directory
,
50 git_create_message_view (data
->plugin
);
52 g_signal_connect (G_OBJECT (delete_command
), "command-finished",
53 G_CALLBACK (on_git_command_finished
),
56 g_signal_connect (G_OBJECT (delete_command
), "data-arrived",
57 G_CALLBACK (on_git_command_info_arrived
),
60 anjuta_command_start (ANJUTA_COMMAND (delete_command
));
63 gtk_widget_destroy (GTK_WIDGET (dialog
));
64 git_branch_combo_data_free (data
);
68 on_remote_list_command_data_arrived (AnjutaCommand
*command
,
74 output_queue
= git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command
));
76 while (g_queue_peek_head (output_queue
))
78 remote_name
= g_queue_pop_head (output_queue
);
79 git_branch_combo_model_append_remote (model
, remote_name
);
85 on_remote_list_command_finished (AnjutaCommand
*command
, guint return_code
,
86 GitBranchComboData
*data
)
88 GtkWidget
*delete_remote_ok_button
;
89 GtkWidget
*delete_remote_combo
;
92 delete_remote_ok_button
= glade_xml_get_widget (data
->gxml
,
93 "delete_remote_ok_button");
94 delete_remote_combo
= glade_xml_get_widget (data
->gxml
,
95 "delete_remote_combo");
97 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (data
->model
),
100 gtk_widget_set_sensitive (delete_remote_ok_button
, TRUE
);
101 gtk_combo_box_set_active (GTK_COMBO_BOX (delete_remote_combo
), 0);
106 delete_remote_dialog (Git
*plugin
)
110 GtkWidget
*delete_remote_combo
;
111 GtkListStore
*branch_list_store
;
112 GitBranchComboData
*data
;
113 GitRemoteListCommand
*list_command
;
115 gxml
= glade_xml_new (GLADE_FILE
, "delete_remote_dialog", NULL
);
117 dialog
= glade_xml_get_widget (gxml
, "delete_remote_dialog");
118 delete_remote_combo
= glade_xml_get_widget (gxml
,
119 "delete_remote_combo");
120 branch_list_store
= git_branch_combo_model_new ();
122 gtk_combo_box_set_model (GTK_COMBO_BOX (delete_remote_combo
),
123 GTK_TREE_MODEL (branch_list_store
));
124 git_branch_combo_model_setup_widget (delete_remote_combo
);
126 data
= git_branch_combo_data_new (branch_list_store
,
127 GTK_COMBO_BOX (delete_remote_combo
), gxml
,
130 list_command
= git_remote_list_command_new (plugin
->project_root_directory
);
132 g_signal_connect (G_OBJECT (list_command
), "data-arrived",
133 G_CALLBACK (on_remote_list_command_data_arrived
),
136 g_signal_connect (G_OBJECT (list_command
), "command-finished",
137 G_CALLBACK (on_remote_list_command_finished
),
140 anjuta_command_start (ANJUTA_COMMAND (list_command
));
142 g_signal_connect (G_OBJECT (dialog
), "response",
143 G_CALLBACK (on_delete_remote_dialog_response
),
146 gtk_widget_show_all (dialog
);
150 on_menu_git_delete_remote (GtkAction
*action
, Git
*plugin
)
152 delete_remote_dialog (plugin
);