From 0071ad8ed694b6208798084ef912f7ebc9424fd4 Mon Sep 17 00:00:00 2001 From: James Liggett Date: Mon, 21 Apr 2008 17:09:31 -0700 Subject: [PATCH] Implement commit support. Also add a glade file. We have a UI now... ;) --- TODO.tasks | 10 +- plugins/git/Makefile.am | 10 +- plugins/git/anjuta-git.glade | 209 +++++++++++++++++++++++++++++++++++++++ plugins/git/anjuta-git.ui | 4 +- plugins/git/git-command.c | 69 +++++++++++++ plugins/git/git-command.h | 9 ++ plugins/git/git-commit-command.c | 98 ++++++++++++++++++ plugins/git/git-commit-command.h | 63 ++++++++++++ plugins/git/git-commit-dialog.c | 179 +++++++++++++++++++++++++++++++++ plugins/git/git-commit-dialog.h | 33 +++++++ plugins/git/git-ui-utils.c | 16 +-- plugins/git/git-ui-utils.h | 5 +- plugins/git/plugin.c | 9 ++ 13 files changed, 696 insertions(+), 18 deletions(-) create mode 100644 plugins/git/anjuta-git.glade create mode 100644 plugins/git/git-commit-command.c create mode 100644 plugins/git/git-commit-command.h create mode 100644 plugins/git/git-commit-dialog.c create mode 100644 plugins/git/git-commit-dialog.h diff --git a/TODO.tasks b/TODO.tasks index 2db93d29..d4bd5634 100644 --- a/TODO.tasks +++ b/TODO.tasks @@ -648,11 +648,6 @@ Fix c++/gobject class generator to allow adding members, methods, signals, prope - - Committing changes - - - Resolving conflicts @@ -735,6 +730,11 @@ Fix c++/gobject class generator to allow adding members, methods, signals, prope Implement GitCommand class + + + + + Committing changes diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am index 789dff52..4d39b52e 100644 --- a/plugins/git/Makefile.am +++ b/plugins/git/Makefile.am @@ -1,5 +1,9 @@ # Sample Makefile for a anjuta plugin. +# Plugin glade file +git_gladedir = $(anjuta_glade_dir) +git_glade_DATA = anjuta-git.glade + # Plugin UI file git_uidir = $(anjuta_ui_dir) git_ui_DATA = anjuta-git.ui @@ -51,7 +55,11 @@ libanjuta_git_la_SOURCES = \ git-status.c \ git-status.h \ git-status-command.c \ - git-status-command.h + git-status-command.h \ + git-commit-command.h \ + git-commit-command.c \ + git-commit-dialog.c \ + git-commit-dialog.h libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) diff --git a/plugins/git/anjuta-git.glade b/plugins/git/anjuta-git.glade new file mode 100644 index 00000000..f2f5b4b3 --- /dev/null +++ b/plugins/git/anjuta-git.glade @@ -0,0 +1,209 @@ + + + + + + + 600 + 400 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + Commit Changes + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Log Message:</b> + True + + + label_item + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + 0 + ANJUTA_VCS_STATUS_MODIFIED | ANJUTA_VCS_STATUS_ADDED | ANJUTA_VCS_STATUS_DELETED + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Select Files to Commit:</b> + True + + + label_item + + + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + Retrieving status... + + + False + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + GTK_BUTTONBOX_START + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-select-all + True + 0 + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-clear + True + 0 + + + 1 + + + + + 3 + + + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_END + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-cancel + True + -6 + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-ok + True + -5 + + + 1 + + + + + False + GTK_PACK_END + + + + + + diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui index 5ce5dca5..53bea9cc 100644 --- a/plugins/git/anjuta-git.ui +++ b/plugins/git/anjuta-git.ui @@ -3,7 +3,9 @@ - + + + diff --git a/plugins/git/git-command.c b/plugins/git/git-command.c index 26eae0f5..01c6cedf 100644 --- a/plugins/git/git-command.c +++ b/plugins/git/git-command.c @@ -366,6 +366,23 @@ git_command_add_arg (GitCommand *self, const gchar *arg) self->priv->num_args++; } +void +git_command_add_list_to_args (GitCommand *self, GList *list) +{ + GList *current_arg; + + current_arg = list; + + while (current_arg) + { + self->priv->args = g_list_append (self->priv->args, + g_strdup (current_arg->data)); + self->priv->num_args++; + + current_arg = g_list_next (current_arg); + } +} + void git_command_append_error (GitCommand *self, const gchar *error_line) { @@ -379,6 +396,7 @@ void git_command_push_info (GitCommand *self, const gchar *info) { g_queue_push_tail (self->priv->info_queue, g_strdup (info)); + anjuta_command_notify_data_arrived (ANJUTA_COMMAND (self)); } GQueue * @@ -386,3 +404,54 @@ git_command_get_info_queue (GitCommand *self) { return self->priv->info_queue; } + +void +git_command_send_output_to_info (GitCommand *git_command, const gchar *output) +{ + gchar *newline; + gchar *info_string; + + /* Strip off the newline before sending it to the queue */ + newline = strchr (output, '\n'); + + if (newline) + info_string = g_strndup (output, (newline - output)); + else + info_string = g_strdup (output); + + git_command_push_info (git_command, info_string); +} + +GList * +git_command_copy_path_list (GList *list) +{ + GList *current_path; + GList *new_list; + + new_list = NULL; + current_path = list; + + while (current_path) + { + new_list = g_list_append (new_list, g_strdup (current_path->data)); + current_path = g_list_next (current_path); + } + + return new_list; +} + +void +git_command_free_path_list (GList *list) +{ + GList *current_path; + + current_path = list; + + while (current_path) + { + g_free (current_path->data); + current_path = g_list_next (current_path); + } + + g_list_free (list); +} diff --git a/plugins/git/git-command.h b/plugins/git/git-command.h index 19596efb..e78038f2 100644 --- a/plugins/git/git-command.h +++ b/plugins/git/git-command.h @@ -63,10 +63,19 @@ struct _GitCommand GType git_command_get_type (void) G_GNUC_CONST; void git_command_add_arg (GitCommand *self, const gchar *arg); +void git_command_add_list_to_args (GitCommand *self, GList *list); void git_command_append_error (GitCommand *self, const gchar *error_line); void git_command_push_info (GitCommand *self, const gchar *info); GQueue *git_command_get_info_queue (GitCommand *self); +/* Generic output handlers */ +void git_command_send_output_to_info (GitCommand *git_command, + const gchar *output); + +/* Static helper methods */ +GList *git_command_copy_path_list (GList *path_list); +void git_command_free_path_list (GList *path_list); + G_END_DECLS #endif /* _GIT_COMMAND_H_ */ diff --git a/plugins/git/git-commit-command.c b/plugins/git/git-commit-command.c new file mode 100644 index 00000000..b4c5033c --- /dev/null +++ b/plugins/git/git-commit-command.c @@ -0,0 +1,98 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2008 + * + * anjuta is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#include "git-commit-command.h" + +struct _GitCommitCommandPriv +{ + GList *paths; + gchar *log; +}; + +G_DEFINE_TYPE (GitCommitCommand, git_commit_command, GIT_TYPE_COMMAND); + +static guint +git_commit_command_run (AnjutaCommand *command) +{ + GitCommitCommand *self; + + self = GIT_COMMIT_COMMAND (command); + + git_command_add_arg (GIT_COMMAND (self), "commit"); + git_command_add_arg (GIT_COMMAND (self), "-m"); + git_command_add_arg (GIT_COMMAND (self), self->priv->log); + git_command_add_list_to_args (GIT_COMMAND (self), self->priv->paths); + + return 0; +} + +static void +git_commit_command_init (GitCommitCommand *self) +{ + self->priv = g_new0 (GitCommitCommandPriv, 1); +} + +static void +git_commit_command_finalize (GObject *object) +{ + GitCommitCommand *self; + + self = GIT_COMMIT_COMMAND (object); + + git_command_free_path_list (self->priv->paths); + g_free (self->priv->log); + g_free (self->priv); + + G_OBJECT_CLASS (git_commit_command_parent_class)->finalize (object); +} + +static void +git_commit_command_class_init (GitCommitCommandClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass); + AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass); + + object_class->finalize = git_commit_command_finalize; + parent_class->output_handler = git_command_send_output_to_info; + command_class->run = git_commit_command_run; +} + + +GitCommitCommand * +git_commit_command_new (const gchar *working_directory, const gchar *log, + GList *paths) +{ + GitCommitCommand *self; + + self = g_object_new (GIT_TYPE_COMMIT_COMMAND, + "working-directory", working_directory, + "single-line-output", TRUE, + NULL); + + self->priv->paths = git_command_copy_path_list (paths); + self->priv->log = g_strdup (log); + + return self; +} diff --git a/plugins/git/git-commit-command.h b/plugins/git/git-commit-command.h new file mode 100644 index 00000000..bdf4e459 --- /dev/null +++ b/plugins/git/git-commit-command.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2008 + * + * anjuta is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GIT_COMMIT_COMMAND_H_ +#define _GIT_COMMIT_COMMAND_H_ + +#include +#include "git-command.h" + +G_BEGIN_DECLS + +#define GIT_TYPE_COMMIT_COMMAND (git_commit_command_get_type ()) +#define GIT_COMMIT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_COMMIT_COMMAND, GitCommitCommand)) +#define GIT_COMMIT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_COMMIT_COMMAND, GitCommitCommandClass)) +#define GIT_IS_COMMIT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_COMMIT_COMMAND)) +#define GIT_IS_COMMIT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_COMMIT_COMMAND)) +#define GIT_COMMIT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_COMMIT_COMMAND, GitCommitCommandClass)) + +typedef struct _GitCommitCommandClass GitCommitCommandClass; +typedef struct _GitCommitCommand GitCommitCommand; +typedef struct _GitCommitCommandPriv GitCommitCommandPriv; + +struct _GitCommitCommandClass +{ + GitCommandClass parent_class; +}; + +struct _GitCommitCommand +{ + GitCommand parent_instance; + + GitCommitCommandPriv *priv; +}; + +GType git_commit_command_get_type (void) G_GNUC_CONST; +GitCommitCommand *git_commit_command_new (const gchar *working_directory, + const gchar *log, GList *paths); + + +G_END_DECLS + +#endif /* _GIT_COMMIT_COMMAND_H_ */ diff --git a/plugins/git/git-commit-dialog.c b/plugins/git/git-commit-dialog.c new file mode 100644 index 00000000..6146e1cc --- /dev/null +++ b/plugins/git/git-commit-dialog.c @@ -0,0 +1,179 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2008 + * + * anjuta is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#include "git-commit-dialog.h" + +static void +on_commit_command_finished (AnjutaCommand *command, guint return_code, + Git *plugin) +{ + AnjutaStatus *status; + + status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell, + NULL); + + anjuta_status (status, _("Git: Commit complete."), 5); + + report_errors (command, return_code); + + g_object_unref (command); +} + + +static void +on_commit_dialog_response (GtkDialog *dialog, gint response_id, + GitUIData *data) +{ + GtkWidget *log_view; + gchar *log; + GtkWidget *log_prompt_dialog; + gint prompt_response; + GtkWidget *status_view; + GList *selected_paths; + GitCommitCommand *commit_command; + + if (response_id == GTK_RESPONSE_OK) + { + log_view = glade_xml_get_widget (data->gxml, "log_view"); + log = get_log_from_textview (log_view); + + if (!g_utf8_strlen(log, -1)) + { + log_prompt_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_YES_NO, + _("Are you sure that you want to pass an empty log message?")); + + prompt_response = gtk_dialog_run(GTK_DIALOG (log_prompt_dialog)); + gtk_widget_destroy (log_prompt_dialog); + + if (prompt_response == GTK_RESPONSE_NO) + return; + } + + status_view = glade_xml_get_widget (data->gxml, "status_view"); + selected_paths = anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (status_view)); + commit_command = git_commit_command_new (data->plugin->project_root_directory, + log, + selected_paths); + + git_command_free_path_list (selected_paths); + + create_message_view (data->plugin); + + g_signal_connect (G_OBJECT (commit_command), "command-finished", + G_CALLBACK (on_commit_command_finished), + data->plugin); + + g_signal_connect (G_OBJECT (commit_command), "data-arrived", + G_CALLBACK (on_command_info_arrived), + data->plugin); + + anjuta_command_start (ANJUTA_COMMAND (commit_command)); + } + + gtk_widget_destroy (GTK_WIDGET (dialog)); + git_ui_data_free (data); +} + +static void +select_all_files (AnjutaCommand *command, guint return_code, + AnjutaVcsStatusTreeView *status_view) +{ + anjuta_vcs_status_tree_view_select_all (status_view); +} + +static void +commit_dialog (Git *plugin) +{ + GladeXML *gxml; + GtkWidget *dialog; + GtkWidget *select_all_button; + GtkWidget *clear_button; + GtkWidget *status_view; + GtkWidget *status_progress_bar; + GitStatusCommand *status_command; + GitUIData *data; + + gxml = glade_xml_new (GLADE_FILE, "commit_dialog", NULL); + + dialog = glade_xml_get_widget (gxml, "commit_dialog"); + select_all_button = glade_xml_get_widget (gxml, "select_all_button"); + clear_button = glade_xml_get_widget (gxml, "clear_button"); + status_view = glade_xml_get_widget (gxml, "status_view"); + status_progress_bar = glade_xml_get_widget (gxml, "status_progress_bar"); + + status_command = git_status_command_new (plugin->project_root_directory); + + g_signal_connect (G_OBJECT (select_all_button), "clicked", + G_CALLBACK (select_all_status_items), + status_view); + + g_signal_connect (G_OBJECT (clear_button), "clicked", + G_CALLBACK (clear_all_status_selections), + status_view); + + g_signal_connect (G_OBJECT (status_command), "command-finished", + G_CALLBACK (select_all_files), + status_view); + + pulse_progress_bar (GTK_PROGRESS_BAR (status_progress_bar)); + + g_signal_connect (G_OBJECT (status_command), "command-finished", + G_CALLBACK (cancel_data_arrived_signal_disconnect), + status_view); + + g_signal_connect (G_OBJECT (status_command), "command-finished", + G_CALLBACK (hide_pulse_progress_bar), + status_progress_bar); + + g_signal_connect (G_OBJECT (status_command), "command-finished", + G_CALLBACK (on_status_command_finished), + NULL); + + g_signal_connect (G_OBJECT (status_command), "data-arrived", + G_CALLBACK (on_status_command_data_arrived), + status_view); + + g_object_weak_ref (G_OBJECT (status_view), + (GWeakNotify) disconnect_data_arrived_signals, + status_command); + + anjuta_command_start (ANJUTA_COMMAND (status_command)); + + data = git_ui_data_new (plugin, gxml); + + g_signal_connect(G_OBJECT (dialog), "response", + G_CALLBACK (on_commit_dialog_response), + data); + + gtk_widget_show_all (dialog); +} + +void +on_menu_git_commit (GtkAction *action, Git *plugin) +{ + commit_dialog (plugin); +} diff --git a/plugins/git/git-commit-dialog.h b/plugins/git/git-commit-dialog.h new file mode 100644 index 00000000..9decd257 --- /dev/null +++ b/plugins/git/git-commit-dialog.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2008 + * + * anjuta is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GIT_COMMIT_DIALOG_H +#define _GIT_COMMIT_DIALOG_H + +#include "git-commit-command.h" +#include "git-ui-utils.h" + +void on_menu_git_commit (GtkAction *action, Git *plugin); + +#endif diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c index d9bf143e..ce9cdc41 100644 --- a/plugins/git/git-ui-utils.c +++ b/plugins/git/git-ui-utils.c @@ -44,6 +44,7 @@ git_ui_data_new (Git* plugin, GladeXML* gxml) void git_ui_data_free (GitUIData* data) { + g_object_unref (data->gxml); g_free (data); } @@ -180,8 +181,11 @@ report_errors (AnjutaCommand *command, guint return_code) { message = anjuta_command_get_error_message (command); - anjuta_util_dialog_error (NULL, message); - g_free (message); + if (message) + { + anjuta_util_dialog_error (NULL, message); + g_free (message); + } } } @@ -220,14 +224,13 @@ get_filename_from_full_path (gchar *path) return g_strdup (""); } -#if 0 void on_status_command_finished (AnjutaCommand *command, guint return_code, gpointer user_data) { report_errors (command, return_code); - git_status_command_destroy (GIT_STATUS_COMMAND (command)); + g_object_unref (command); } void @@ -235,7 +238,7 @@ on_status_command_data_arrived (AnjutaCommand *command, AnjutaVcsStatusTreeView *tree_view) { GQueue *status_queue; - GitStatusStatus *status; + GitStatus *status; gchar *path; status_queue = git_status_command_get_status_queue (GIT_STATUS_COMMAND (command)); @@ -249,11 +252,10 @@ on_status_command_data_arrived (AnjutaCommand *command, git_status_get_vcs_status (status), FALSE); - git_status_destroy (status); + g_object_unref (status); g_free (path); } } -#endif void on_command_info_arrived (AnjutaCommand *command, Git *plugin) diff --git a/plugins/git/git-ui-utils.h b/plugins/git/git-ui-utils.h index b4c839f4..85ed5156 100644 --- a/plugins/git/git-ui-utils.h +++ b/plugins/git/git-ui-utils.h @@ -30,8 +30,7 @@ #include #include #include "plugin.h" -/* Uncomment these when they get implemented */ -/*#include "git-status-command.h"*/ +#include "git-status-command.h" #include "git-diff-command.h" typedef struct @@ -53,12 +52,10 @@ void report_errors (AnjutaCommand *command, guint return_code); gchar *get_filename_from_full_path (gchar *path); /* Stock signal handlers */ -#if 0 void on_status_command_finished (AnjutaCommand *command, guint return_code, gpointer user_data); void on_status_command_data_arrived (AnjutaCommand *command, AnjutaVcsStatusTreeView *tree_view); -#endif void on_command_info_arrived (AnjutaCommand *command, Git *plugin); void select_all_status_items (GtkButton *select_all_button, AnjutaVcsStatusTreeView *tree_view); diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c index e7b953ed..1edf4516 100644 --- a/plugins/git/plugin.c +++ b/plugins/git/plugin.c @@ -21,6 +21,7 @@ #include "plugin.h" #include "git-diff-dialog.h" +#include "git-commit-dialog.h" #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.ui" @@ -36,6 +37,14 @@ static GtkActionEntry actions_git[] = { NULL /* action callback */ }, { + "ActionGitCommit", /* Action name */ + GTK_STOCK_YES, /* Stock icon, if any */ + N_("_Commit..."), /* Display label */ + NULL, /* short-cut */ + NULL, /* Tooltip */ + G_CALLBACK (on_menu_git_commit) /* action callback */ + }, + { "ActionGitDiffUncommitted", /* Action name */ GTK_STOCK_ZOOM_100, /* Stock icon, if any */ N_("_Diff uncommitted changes"), /* Display label */ -- 2.11.4.GIT