Put all of the UI utility functions into the "git" namespace.
[anjuta-git-plugin.git] / plugins / git / git-resolve-dialog.c
blobf4f3ca2053627d5bb3c057006ba8ab6869c6e3ff
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-resolve-dialog.h"
27 static void
28 on_add_command_finished (AnjutaCommand *command, guint return_code,
29 Git *plugin)
31 AnjutaStatus *status;
33 status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
34 NULL);
36 anjuta_status (status, _("Git: Resolve complete."), 5);
38 git_report_errors (command, return_code);
40 g_object_unref (command);
44 static void
45 on_resolve_dialog_response (GtkDialog *dialog, gint response_id,
46 GitUIData *data)
48 GtkWidget *resolve_status_view;
49 GList *selected_paths;
50 GitAddCommand *add_command;
52 if (response_id == GTK_RESPONSE_OK)
54 resolve_status_view = glade_xml_get_widget (data->gxml, "resolve_status_view");
55 selected_paths = anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (resolve_status_view));
56 add_command = git_add_command_new_list (data->plugin->project_root_directory,
57 selected_paths, FALSE);
59 git_command_free_path_list (selected_paths);
61 g_signal_connect (G_OBJECT (add_command), "command-finished",
62 G_CALLBACK (on_add_command_finished),
63 data->plugin);
65 anjuta_command_start (ANJUTA_COMMAND (add_command));
68 gtk_widget_destroy (GTK_WIDGET (dialog));
69 git_ui_data_free (data);
72 static void
73 resolve_dialog (Git *plugin)
75 GladeXML *gxml;
76 GtkWidget *dialog;
77 GtkWidget *resolve_select_all_button;
78 GtkWidget *resolve_clear_button;
79 GtkWidget *resolve_status_view;
80 GtkWidget *resolve_status_progress_bar;
81 GitStatusCommand *status_command;
82 GitUIData *data;
84 gxml = glade_xml_new (GLADE_FILE, "resolve_dialog", NULL);
86 dialog = glade_xml_get_widget (gxml, "resolve_dialog");
87 resolve_select_all_button = glade_xml_get_widget (gxml, "resolve_select_all_button");
88 resolve_clear_button = glade_xml_get_widget (gxml, "resolve_clear_button");
89 resolve_status_view = glade_xml_get_widget (gxml, "resolve_status_view");
90 resolve_status_progress_bar = glade_xml_get_widget (gxml, "resolve_status_progress_bar");
92 status_command = git_status_command_new (plugin->project_root_directory,
93 GIT_STATUS_SECTION_NOT_UPDATED);
95 g_signal_connect (G_OBJECT (resolve_select_all_button), "clicked",
96 G_CALLBACK (git_select_all_status_items),
97 resolve_status_view);
99 g_signal_connect (G_OBJECT (resolve_clear_button), "clicked",
100 G_CALLBACK (git_clear_all_status_selections),
101 resolve_status_view);
103 git_pulse_progress_bar (GTK_PROGRESS_BAR (resolve_status_progress_bar));
105 g_signal_connect (G_OBJECT (status_command), "command-finished",
106 G_CALLBACK (git_cancel_data_arrived_signal_disconnect),
107 resolve_status_view);
109 g_signal_connect (G_OBJECT (status_command), "command-finished",
110 G_CALLBACK (git_hide_pulse_progress_bar),
111 resolve_status_progress_bar);
113 g_signal_connect (G_OBJECT (status_command), "command-finished",
114 G_CALLBACK (on_git_command_finished),
115 NULL);
117 g_signal_connect (G_OBJECT (status_command), "data-arrived",
118 G_CALLBACK (on_git_status_command_data_arrived),
119 resolve_status_view);
121 g_object_weak_ref (G_OBJECT (resolve_status_view),
122 (GWeakNotify) git_disconnect_data_arrived_signals,
123 status_command);
125 anjuta_command_start (ANJUTA_COMMAND (status_command));
127 data = git_ui_data_new (plugin, gxml);
129 g_signal_connect(G_OBJECT (dialog), "response",
130 G_CALLBACK (on_resolve_dialog_response),
131 data);
133 gtk_widget_show_all (dialog);
136 void
137 on_menu_git_resolve (GtkAction *action, Git *plugin)
139 resolve_dialog (plugin);