Put all of the UI utility functions into the "git" namespace.
[anjuta-git-plugin.git] / plugins / git / git-rebase-dialog.c
blobc7aa01251a281fa0f54c7d2f55f1307022593713
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
5 *
6 * anjuta is free software.
7 *
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)
11 * any later version.
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-rebase-dialog.h"
27 static void
28 on_rebase_dialog_response (GtkDialog *dialog, gint response_id,
29 GitBranchComboData *data)
31 GtkWidget *rebase_branch_combo;
32 gchar *branch;
33 GtkTreeIter iter;
34 GitRebaseStartCommand *rebase_command;
35 GitProgressData *progress_data;
37 if (response_id == GTK_RESPONSE_OK)
39 rebase_branch_combo = glade_xml_get_widget (data->gxml,
40 "rebase_branch_combo");
42 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (rebase_branch_combo),
43 &iter);
44 branch = git_branch_combo_model_get_branch (data->model, &iter);
46 rebase_command = git_rebase_start_command_new (data->plugin->project_root_directory,
47 branch);
48 progress_data = git_progress_data_new (data->plugin,
49 _("Git: Rebasing"));
51 g_free (branch);
53 git_create_message_view (data->plugin);
55 g_signal_connect (G_OBJECT (rebase_command), "command-finished",
56 G_CALLBACK (on_git_command_finished),
57 data->plugin);
59 g_signal_connect (G_OBJECT (rebase_command), "data-arrived",
60 G_CALLBACK (on_git_command_info_arrived),
61 data->plugin);
63 g_signal_connect (G_OBJECT (rebase_command), "progress",
64 G_CALLBACK (on_git_command_progress),
65 data->plugin);
67 g_signal_connect_swapped (G_OBJECT (rebase_command),
68 "command-finished",
69 G_CALLBACK (git_progress_data_free),
70 progress_data);
72 anjuta_command_start (ANJUTA_COMMAND (rebase_command));
75 gtk_widget_destroy (GTK_WIDGET (dialog));
76 git_branch_combo_data_free (data);
79 static void
80 rebase_dialog (Git *plugin)
82 GladeXML *gxml;
83 GtkWidget *dialog;
84 GtkWidget *rebase_branch_combo;
85 GtkListStore *branch_list_store;
86 GitBranchComboData *data;
87 GitBranchListCommand *list_command;
89 gxml = glade_xml_new (GLADE_FILE, "rebase_dialog", NULL);
91 dialog = glade_xml_get_widget (gxml, "rebase_dialog");
92 rebase_branch_combo = glade_xml_get_widget (gxml, "rebase_branch_combo");
93 branch_list_store = git_branch_combo_model_new ();
95 gtk_combo_box_set_model (GTK_COMBO_BOX (rebase_branch_combo),
96 GTK_TREE_MODEL (branch_list_store));
97 git_branch_combo_model_setup_widget (rebase_branch_combo);
99 data = git_branch_combo_data_new (branch_list_store,
100 GTK_COMBO_BOX (rebase_branch_combo), gxml,
101 plugin);
103 list_command = git_branch_list_command_new (plugin->project_root_directory,
104 GIT_BRANCH_TYPE_REMOTE);
106 g_signal_connect (G_OBJECT (list_command), "data-arrived",
107 G_CALLBACK (on_git_list_branch_command_data_arrived),
108 data);
110 g_signal_connect (G_OBJECT (list_command), "command-finished",
111 G_CALLBACK (on_git_list_branch_command_finished),
112 data);
114 anjuta_command_start (ANJUTA_COMMAND (list_command));
116 g_signal_connect (G_OBJECT (dialog), "response",
117 G_CALLBACK (on_rebase_dialog_response),
118 data);
120 gtk_widget_show_all (dialog);
123 static void
124 rebase_continue (Git *plugin, GitRebaseContinueAction action)
126 GitRebaseContinueCommand *rebase_command;
128 git_create_message_view (plugin);
130 rebase_command = git_rebase_continue_command_new (plugin->project_root_directory,
131 action);
133 g_signal_connect (G_OBJECT (rebase_command), "command-finished",
134 G_CALLBACK (on_git_command_finished),
135 plugin);
137 g_signal_connect (G_OBJECT (rebase_command), "data-arrived",
138 G_CALLBACK (on_git_command_info_arrived),
139 plugin);
141 anjuta_command_start (ANJUTA_COMMAND (rebase_command));
144 void
145 on_menu_git_rebase_start (GtkAction *action, Git *plugin)
147 rebase_dialog (plugin);
150 void
151 on_menu_git_rebase_continue (GtkAction *action, Git *plugin)
153 rebase_continue (plugin, GIT_REBASE_CONTINUE_ACTION_CONTINUE);
156 void
157 on_menu_git_rebase_skip (GtkAction *action, Git *plugin)
159 rebase_continue (plugin, GIT_REBASE_CONTINUE_ACTION_SKIP);
162 void
163 on_menu_git_rebase_abort (GtkAction *action, Git *plugin)
165 rebase_continue (plugin, GIT_REBASE_CONTINUE_ACTION_ABORT);