[anjuta/git-shell] git: Implement the Remove Files pane
- From: James Liggett <jrliggett src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/git-shell] git: Implement the Remove Files pane
- Date: Thu, 24 Jun 2010 03:07:47 +0000 (UTC)
commit bc22d95fa73cd0a23c8ad4bc1053a8d4fbd542a8
Author: James Liggett <jrliggett cox net>
Date: Wed Jun 23 19:32:50 2010 -0700
git: Implement the Remove Files pane
plugins/git/Makefile.am | 4 +-
plugins/git/anjuta-git.ui | 108 +++++++++++++++++++++++
plugins/git/git-remove-files-pane.c | 166 +++++++++++++++++++++++++++++++++++
plugins/git/git-remove-files-pane.h | 60 +++++++++++++
plugins/git/plugin.c | 10 ++-
5 files changed, 346 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 768255e..2be9e78 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -179,7 +179,9 @@ libanjuta_git_la_SOURCES = \
git-commit-pane.h \
git-commit-pane.c \
git-add-files-pane.c \
- git-add-files-pane.h
+ git-add-files-pane.h \
+ git-remove-files-pane.c \
+ git-remove-files-pane.h
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 864e3b7..8e84dde 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -1522,4 +1522,112 @@
</packing>
</child>
</object>
+ <object class="GtkVBox" id="remove_pane">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="AnjutaFileList" id="file_list">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Remove Files:</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkCheckButton" id="force_check">
+ <property name="label" translatable="yes">Force</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Options:</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok_button">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
</interface>
diff --git a/plugins/git/git-remove-files-pane.c b/plugins/git/git-remove-files-pane.c
new file mode 100644
index 0000000..ab714dd
--- /dev/null
+++ b/plugins/git/git-remove-files-pane.c
@@ -0,0 +1,166 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ *
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 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 this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "git-remove-files-pane.h"
+
+struct _GitRemoveFilesPanePriv
+{
+ GtkBuilder *builder;
+};
+
+G_DEFINE_TYPE (GitRemoveFilesPane, git_remove_files_pane, GIT_TYPE_PANE);
+
+static void
+on_ok_button_clicked (GtkButton *button, GitRemoveFilesPane *self)
+{
+ Git *plugin;
+ AnjutaFileList *file_list;
+ GtkToggleButton *force_check;
+ GList *paths;
+ GitRemoveCommand *remove_command;
+
+ plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
+ file_list = ANJUTA_FILE_LIST (gtk_builder_get_object (self->priv->builder,
+ "file_list"));
+ force_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "force_check"));
+ paths = anjuta_file_list_get_paths (file_list);
+ remove_command = git_remove_command_new_list (plugin->project_root_directory,
+ paths,
+ gtk_toggle_button_get_active (force_check));
+
+ git_command_free_string_list (paths);
+
+ g_signal_connect (G_OBJECT (remove_command), "command-finished",
+ G_CALLBACK (g_object_unref),
+ NULL);
+
+ anjuta_command_start (ANJUTA_COMMAND (remove_command));
+
+ anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock),
+ ANJUTA_DOCK_PANE (self));
+}
+
+static void
+on_cancel_button_clicked (GtkButton *button, GitRemoveFilesPane *self)
+{
+ Git *plugin;
+
+ plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
+
+ anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock),
+ ANJUTA_DOCK_PANE (self));
+}
+
+static void
+git_remove_files_pane_init (GitRemoveFilesPane *self)
+{
+ gchar *objects[] = {"remove_pane",
+ NULL};
+ GError *error = NULL;
+ GtkWidget *ok_button;
+ GtkWidget *cancel_button;
+
+ self->priv = g_new0 (GitRemoveFilesPanePriv, 1);
+ self->priv->builder = gtk_builder_new ();
+
+ if (!gtk_builder_add_objects_from_file (self->priv->builder, BUILDER_FILE,
+ objects,
+ &error))
+ {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+
+ ok_button = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "ok_button"));
+ cancel_button = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "cancel_button"));
+
+ g_signal_connect (G_OBJECT (ok_button), "clicked",
+ G_CALLBACK (on_ok_button_clicked),
+ self);
+
+ g_signal_connect (G_OBJECT (cancel_button), "clicked",
+ G_CALLBACK (on_cancel_button_clicked),
+ self);
+}
+
+static void
+git_remove_files_pane_finalize (GObject *object)
+{
+ GitRemoveFilesPane *self;
+
+ self = GIT_REMOVE_FILES_PANE (object);
+
+ g_object_unref (self->priv->builder);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (git_remove_files_pane_parent_class)->finalize (object);
+}
+
+static GtkWidget *
+git_remove_files_pane_get_widget (AnjutaDockPane *pane)
+{
+ GitRemoveFilesPane *self;
+
+ self = GIT_REMOVE_FILES_PANE (pane);
+
+ return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "remove_pane"));
+}
+
+static void
+git_remove_files_pane_class_init (GitRemoveFilesPaneClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ AnjutaDockPaneClass* pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
+
+ object_class->finalize = git_remove_files_pane_finalize;
+ pane_class->get_widget = git_remove_files_pane_get_widget;
+ pane_class->refresh = NULL;
+}
+
+AnjutaDockPane *
+git_remove_files_pane_new (Git *plugin)
+{
+ GitRemoveFilesPane *self;
+ AnjutaFileList *file_list;
+
+ self = g_object_new (GIT_TYPE_REMOVE_FILES_PANE, "plugin", plugin, NULL);
+ file_list = ANJUTA_FILE_LIST (gtk_builder_get_object (self->priv->builder,
+ "file_list"));
+
+ anjuta_file_list_set_relative_path (file_list,
+ plugin->project_root_directory);
+
+ return ANJUTA_DOCK_PANE (self);
+}
+
+void
+on_remove_button_clicked (GtkAction *action, Git* plugin)
+{
+ AnjutaDockPane *pane;
+
+ pane = git_remove_files_pane_new (plugin);
+
+ anjuta_dock_add_pane (ANJUTA_DOCK (plugin->dock), "RemoveFiles",
+ _("Remove Files"), NULL, pane, GDL_DOCK_BOTTOM,
+ NULL, 0, NULL);
+}
diff --git a/plugins/git/git-remove-files-pane.h b/plugins/git/git-remove-files-pane.h
new file mode 100644
index 0000000..a209dc0
--- /dev/null
+++ b/plugins/git/git-remove-files-pane.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ *
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 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 this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GIT_REMOVE_FILES_PANE_H_
+#define _GIT_REMOVE_FILES_PANE_H_
+
+#include <glib-object.h>
+#include <libanjuta/anjuta-file-list.h>
+#include "git-pane.h"
+#include "git-remove-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_REMOVE_FILES_PANE (git_remove_files_pane_get_type ())
+#define GIT_REMOVE_FILES_PANE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_REMOVE_FILES_PANE, GitRemoveFilesPane))
+#define GIT_REMOVE_FILES_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_REMOVE_FILES_PANE, GitRemoveFilesPaneClass))
+#define GIT_IS_REMOVE_FILES_PANE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_REMOVE_FILES_PANE))
+#define GIT_IS_REMOVE_FILES_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_REMOVE_FILES_PANE))
+#define GIT_REMOVE_FILES_PANE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_REMOVE_FILES_PANE, GitRemoveFilesPaneClass))
+
+typedef struct _GitRemoveFilesPaneClass GitRemoveFilesPaneClass;
+typedef struct _GitRemoveFilesPane GitRemoveFilesPane;
+typedef struct _GitRemoveFilesPanePriv GitRemoveFilesPanePriv;
+
+struct _GitRemoveFilesPaneClass
+{
+ GitPaneClass parent_class;
+};
+
+struct _GitRemoveFilesPane
+{
+ GitPane parent_instance;
+
+ GitRemoveFilesPanePriv *priv;
+};
+
+GType git_remove_files_pane_get_type (void) G_GNUC_CONST;
+AnjutaDockPane * git_remove_files_pane_new (Git *plugin);
+
+void on_remove_button_clicked (GtkAction *action, Git *plugin);
+
+G_END_DECLS
+
+#endif /* _GIT_ADD_FILES_PANE_H_ */
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 4bbb6d7..fe839b5 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -29,6 +29,7 @@
#include "git-status-pane.h"
#include "git-commit-pane.h"
#include "git-add-files-pane.h"
+#include "git-remove-files-pane.h"
AnjutaCommandBarEntry branch_entries[] =
{
@@ -106,8 +107,15 @@ AnjutaCommandBarEntry status_entries[] = {
N_("Add files to the index"),
GTK_STOCK_ADD,
G_CALLBACK (on_add_button_clicked)
+ },
+ {
+ ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
+ "RemoveFiles",
+ N_("Remove"),
+ N_("Remove files from the repository"),
+ GTK_STOCK_REMOVE,
+ G_CALLBACK (on_remove_button_clicked)
}
-
};
static gpointer parent_class;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]