[anjuta] git: Add support for clearing all stashes
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] git: Add support for clearing all stashes
- Date: Fri, 24 Jul 2009 01:49:58 +0000 (UTC)
commit 687cbd43c9bfdea104796292ebd8dc049422e38a
Author: James Liggett <jrliggett cox net>
Date: Thu Jul 23 18:47:13 2009 -0700
git: Add support for clearing all stashes
plugins/git/Makefile.am | 4 +-
plugins/git/git-stash-clear-command.c | 77 +++++++++++++++++++++++++++++++++
plugins/git/git-stash-clear-command.h | 58 +++++++++++++++++++++++++
plugins/git/git-stash-widget.c | 37 ++++++++++++++++
plugins/git/git-stash-widget.h | 1 +
5 files changed, 176 insertions(+), 1 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index f375813..ca680cc 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -217,7 +217,9 @@ libanjuta_git_la_SOURCES = \
git-stash-show-command.c \
git-stash-show-command.h \
git-stash-drop-command.c \
- git-stash-drop-command.h
+ git-stash-drop-command.h \
+ git-stash-clear-command.c \
+ git-stash-clear-command.h
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/git-stash-clear-command.c b/plugins/git/git-stash-clear-command.c
new file mode 100644
index 0000000..bcef2c9
--- /dev/null
+++ b/plugins/git/git-stash-clear-command.c
@@ -0,0 +1,77 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ *
+ * 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-stash-clear-command.h"
+
+G_DEFINE_TYPE (GitStashClearCommand, git_stash_clear_command,
+ GIT_TYPE_COMMAND);
+
+static void
+git_stash_clear_command_init (GitStashClearCommand *self)
+{
+
+}
+
+static void
+git_stash_clear_command_finalize (GObject *object)
+{
+ GitStashClearCommand *self;
+
+ self = GIT_STASH_CLEAR_COMMAND (object);
+
+ G_OBJECT_CLASS (git_stash_clear_command_parent_class)->finalize (object);
+}
+
+static guint
+git_stash_clear_command_run (AnjutaCommand *command)
+{
+ GitStashClearCommand *self;
+
+ self = GIT_STASH_CLEAR_COMMAND (command);
+
+ git_command_add_arg (GIT_COMMAND (command), "stash");
+ git_command_add_arg (GIT_COMMAND (command), "clear");
+
+ return 0;
+}
+
+static void
+git_stash_clear_command_class_init (GitStashClearCommandClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ AnjutaCommandClass *command_class = ANJUTA_COMMAND_CLASS (klass);
+
+ object_class->finalize = git_stash_clear_command_finalize;
+ command_class->run = git_stash_clear_command_run;
+}
+
+
+GitStashClearCommand *
+git_stash_clear_command_new (const gchar *working_directory)
+{
+ return g_object_new (GIT_TYPE_STASH_CLEAR_COMMAND,
+ "working-directory", working_directory,
+ NULL);
+}
+
diff --git a/plugins/git/git-stash-clear-command.h b/plugins/git/git-stash-clear-command.h
new file mode 100644
index 0000000..1f2f7b2
--- /dev/null
+++ b/plugins/git/git-stash-clear-command.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ *
+ * 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_STASH_CLEAR_COMMAND_H_
+#define _GIT_STASH_CLEAR_COMMAND_H_
+
+#include <glib-object.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_STASH_CLEAR_COMMAND (git_stash_clear_command_get_type ())
+#define GIT_STASH_CLEAR_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_STASH_CLEAR_COMMAND, GitStashClearCommand))
+#define GIT_STASH_CLEAR_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_STASH_CLEAR_COMMAND, GitStashClearCommandClass))
+#define GIT_IS_STASH_CLEAR_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_STASH_CLEAR_COMMAND))
+#define GIT_IS_STASH_CLEAR_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_STASH_CLEAR_COMMAND))
+#define GIT_STASH_CLEAR_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_STASH_CLEAR_COMMAND, GitStashClearCommandClass))
+
+typedef struct _GitStashClearCommandClass GitStashClearCommandClass;
+typedef struct _GitStashClearCommand GitStashClearCommand;
+
+struct _GitStashClearCommandClass
+{
+ GitCommandClass parent_class;
+};
+
+struct _GitStashClearCommand
+{
+ GitCommand parent_instance;
+};
+
+GType git_stash_clear_command_get_type (void) G_GNUC_CONST;
+GitStashClearCommand *git_stash_clear_command_new (const gchar *working_directory);
+
+G_END_DECLS
+
+#endif /* _GIT_STASH_CLEAR_COMMAND_H_ */
diff --git a/plugins/git/git-stash-widget.c b/plugins/git/git-stash-widget.c
index 61bc010..7a646c0 100644
--- a/plugins/git/git-stash-widget.c
+++ b/plugins/git/git-stash-widget.c
@@ -263,6 +263,36 @@ on_stash_widget_drop_button_clicked (GtkButton *button, GitUIData *data)
}
}
+static void
+on_stash_clear_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: All stashes cleared."), 5);
+
+ git_report_errors (command, return_code);
+
+ g_object_unref (command);
+}
+
+static void
+on_stash_widget_clear_button_clicked (GtkButton *button, GitUIData *data)
+{
+ GitStashClearCommand *clear_command;
+
+ clear_command = git_stash_clear_command_new (data->plugin->project_root_directory);
+
+ g_signal_connect (G_OBJECT (clear_command), "command-finished",
+ G_CALLBACK (on_stash_clear_command_finished),
+ data->plugin);
+
+ anjuta_command_start (ANJUTA_COMMAND (clear_command));
+}
+
void
git_stash_widget_create (Git *plugin, GtkWidget **stash_widget,
GtkWidget **stash_widget_grip)
@@ -280,6 +310,7 @@ git_stash_widget_create (Git *plugin, GtkWidget **stash_widget,
GtkWidget *stash_widget_apply_button;
GtkWidget *stash_widget_show_button;
GtkWidget *stash_widget_drop_button;
+ GtkWidget *stash_widget_clear_button;
GtkTreeSelection *selection;
bxml = gtk_builder_new ();
@@ -307,6 +338,8 @@ git_stash_widget_create (Git *plugin, GtkWidget **stash_widget,
"stash_widget_show_button"));
stash_widget_drop_button = GTK_WIDGET (gtk_builder_get_object (bxml,
"stash_widget_drop_button"));
+ stash_widget_clear_button = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "stash_widget_clear_button"));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (stash_widget_view));
gtk_tree_selection_set_select_function (selection,
@@ -329,6 +362,10 @@ git_stash_widget_create (Git *plugin, GtkWidget **stash_widget,
G_CALLBACK (on_stash_widget_drop_button_clicked),
data);
+ g_signal_connect (G_OBJECT (stash_widget_clear_button), "clicked",
+ G_CALLBACK (on_stash_widget_clear_button_clicked),
+ data);
+
g_object_set_data_full (G_OBJECT (stash_widget_scrolled_window), "ui-data",
data, (GDestroyNotify) git_ui_data_free);
diff --git a/plugins/git/git-stash-widget.h b/plugins/git/git-stash-widget.h
index 26975ee..b6e9eb4 100644
--- a/plugins/git/git-stash-widget.h
+++ b/plugins/git/git-stash-widget.h
@@ -25,6 +25,7 @@
#include "git-stash-apply-command.h"
#include "git-stash-show-command.h"
#include "git-stash-drop-command.h"
+#include "git-stash-clear-command.h"
void git_stash_widget_create (Git *plugin, GtkWidget **stash_widget,
GtkWidget **stash_widget_grip);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]