Put all of the UI utility functions into the "git" namespace.
[anjuta-git-plugin.git] / plugins / git / git-create-patch-series-dialog.c
blobb2101c84d54e31d66b95d1b6d61ef4a3023bd21e
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-create-patch-series-dialog.h"
27 static void
28 on_create_patch_series_dialog_response (GtkDialog *dialog, gint response_id,
29 GitBranchComboData *data)
31 GtkWidget *patch_series_branch_combo;
32 GtkWidget *patch_series_file_chooser_button;
33 GtkWidget *patch_series_signoff_check;
34 gchar *branch;
35 gchar *output_directory;
36 GtkTreeIter iter;
37 GitFormatPatchCommand *format_patch_command;
39 if (response_id == GTK_RESPONSE_OK)
41 patch_series_branch_combo = glade_xml_get_widget (data->gxml,
42 "patch_series_branch_combo");
43 patch_series_file_chooser_button = glade_xml_get_widget (data->gxml,
44 "patch_series_file_chooser_button");
45 patch_series_signoff_check = glade_xml_get_widget (data->gxml,
46 "patch_series_signoff_check");
48 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (patch_series_branch_combo),
49 &iter);
50 branch = git_branch_combo_model_get_branch (data->model, &iter);
51 output_directory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (patch_series_file_chooser_button));
53 format_patch_command = git_format_patch_command_new (data->plugin->project_root_directory,
54 output_directory,
55 branch,
56 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (patch_series_signoff_check)));
58 g_free (branch);
59 g_free (output_directory);
61 git_create_message_view (data->plugin);
63 g_signal_connect (G_OBJECT (format_patch_command), "command-finished",
64 G_CALLBACK (on_git_command_finished),
65 data->plugin);
67 g_signal_connect (G_OBJECT (format_patch_command), "data-arrived",
68 G_CALLBACK (on_git_command_info_arrived),
69 data->plugin);
71 anjuta_command_start (ANJUTA_COMMAND (format_patch_command));
74 gtk_widget_destroy (GTK_WIDGET (dialog));
75 git_branch_combo_data_free (data);
78 static void
79 create_patch_series_dialog (Git *plugin)
81 GladeXML *gxml;
82 GtkWidget *dialog;
83 GtkWidget *patch_series_branch_combo;
84 GtkListStore *branch_list_store;
85 GitBranchComboData *data;
86 GitBranchListCommand *list_command;
88 gxml = glade_xml_new (GLADE_FILE, "patch_series_dialog", NULL);
90 dialog = glade_xml_get_widget (gxml, "patch_series_dialog");
91 patch_series_branch_combo = glade_xml_get_widget (gxml,
92 "patch_series_branch_combo");
93 branch_list_store = git_branch_combo_model_new ();
95 gtk_combo_box_set_model (GTK_COMBO_BOX (patch_series_branch_combo),
96 GTK_TREE_MODEL (branch_list_store));
97 git_branch_combo_model_setup_widget (patch_series_branch_combo);
99 data = git_branch_combo_data_new (branch_list_store,
100 GTK_COMBO_BOX (patch_series_branch_combo),
101 gxml, plugin);
103 list_command = git_branch_list_command_new (plugin->project_root_directory,
104 GIT_BRANCH_TYPE_ALL);
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_create_patch_series_dialog_response),
118 data);
120 gtk_widget_show_all (dialog);
123 void
124 on_menu_git_create_patch_series (GtkAction *action, Git *plugin)
126 create_patch_series_dialog (plugin);