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-switch-dialog.h"
28 on_checkout_command_finished (AnjutaCommand
*command
, guint return_code
,
33 status
= anjuta_shell_get_status (ANJUTA_PLUGIN (plugin
)->shell
,
36 anjuta_status (status
, _("Git: Branch checkout complete."), 5);
38 git_report_errors (command
, return_code
);
40 g_object_unref (command
);
45 on_switch_dialog_response (GtkDialog
*dialog
, gint response_id
,
46 GitBranchComboData
*data
)
48 GtkWidget
*switch_branch_combo
;
51 GitBranchCheckoutCommand
*checkout_command
;
53 if (response_id
== GTK_RESPONSE_OK
)
55 switch_branch_combo
= glade_xml_get_widget (data
->gxml
, "switch_branch_combo");
57 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (switch_branch_combo
), &iter
);
58 branch
= git_branch_combo_model_get_branch (data
->model
, &iter
);
60 checkout_command
= git_branch_checkout_command_new (data
->plugin
->project_root_directory
,
65 git_create_message_view (data
->plugin
);
67 g_signal_connect (G_OBJECT (checkout_command
), "command-finished",
68 G_CALLBACK (on_checkout_command_finished
),
71 g_signal_connect (G_OBJECT (checkout_command
), "data-arrived",
72 G_CALLBACK (on_git_command_info_arrived
),
75 anjuta_command_start (ANJUTA_COMMAND (checkout_command
));
78 gtk_widget_destroy (GTK_WIDGET (dialog
));
79 git_branch_combo_data_free (data
);
83 switch_dialog (Git
*plugin
)
87 GtkWidget
*switch_branch_combo
;
88 GtkListStore
*branch_list_store
;
89 GitBranchComboData
*data
;
90 GitBranchListCommand
*list_command
;
92 gxml
= glade_xml_new (GLADE_FILE
, "switch_dialog", NULL
);
94 dialog
= glade_xml_get_widget (gxml
, "switch_dialog");
95 switch_branch_combo
= glade_xml_get_widget (gxml
, "switch_branch_combo");
96 branch_list_store
= git_branch_combo_model_new ();
98 gtk_combo_box_set_model (GTK_COMBO_BOX (switch_branch_combo
),
99 GTK_TREE_MODEL (branch_list_store
));
100 git_branch_combo_model_setup_widget (switch_branch_combo
);
102 data
= git_branch_combo_data_new (branch_list_store
,
103 GTK_COMBO_BOX (switch_branch_combo
), gxml
,
106 list_command
= git_branch_list_command_new (plugin
->project_root_directory
,
107 GIT_BRANCH_TYPE_LOCAL
);
109 g_signal_connect (G_OBJECT (list_command
), "data-arrived",
110 G_CALLBACK (on_git_list_branch_command_data_arrived
),
113 g_signal_connect (G_OBJECT (list_command
), "command-finished",
114 G_CALLBACK (on_git_list_branch_command_finished
),
117 anjuta_command_start (ANJUTA_COMMAND (list_command
));
119 g_signal_connect (G_OBJECT (dialog
), "response",
120 G_CALLBACK (on_switch_dialog_response
),
123 gtk_widget_show_all (dialog
);
127 on_menu_git_switch (GtkAction
*action
, Git
*plugin
)
129 switch_dialog (plugin
);