[anjuta/git-shell] git: Implement the Create Tag pane



commit d57681fe91b62366066662ec9ccaac1d466b9e5d
Author: James Liggett <jrliggett cox net>
Date:   Thu Jul 22 22:48:48 2010 -0700

    git: Implement the Create Tag pane

 plugins/git/Makefile.am           |    4 +-
 plugins/git/anjuta-git.ui         |  246 +++++++++++++++++++++++++++++++++++++
 plugins/git/git-create-tag-pane.c |  243 ++++++++++++++++++++++++++++++++++++
 plugins/git/git-create-tag-pane.h |   60 +++++++++
 plugins/git/plugin.c              |   24 ++++-
 5 files changed, 575 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 78b7a74..641753b 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -197,7 +197,9 @@ libanjuta_git_la_SOURCES = \
 	git-resolve-conflicts-pane.c \
 	git-resolve-conflicts-pane.h \
 	git-tags-pane.c \
-	git-tags-pane.h
+	git-tags-pane.h \
+	git-create-tag-pane.c \
+	git-create-tag-pane.h
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index cd10683..d281aed 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -2498,4 +2498,250 @@
       </packing>
     </child>
   </object>
+  <object class="GtkVBox" id="create_tag_pane">
+    <property name="visible">True</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkVBox" id="vbox1">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkFrame" id="frame4">
+            <property name="visible">True</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment5">
+                <property name="visible">True</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkEntry" id="name_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">&#x25CF;</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label4">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Tag name:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <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="GtkVBox" id="vbox2">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <object class="GtkRadioButton" id="repository_head_radio">
+                        <property name="label" translatable="yes">Repository head</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="revision_radio">
+                        <property name="label" translatable="yes">Revision:</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">repository_head_radio</property>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkAlignment" id="alignment3">
+                        <property name="visible">True</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="AnjutaDropEntry" id="revision_entry">
+                            <property name="visible">True</property>
+                            <property name="sensitive">False</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">&#x25CF;</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Revision&lt;/b&gt;</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="GtkFrame" id="frame3">
+            <property name="visible">True</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment4">
+                <property name="visible">True</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkVBox" id="vbox3">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</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>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="sign_check">
+                        <property name="label" translatable="yes">Sign this tag</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>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="annotate_check">
+                        <property name="label" translatable="yes">Annotate this tag:</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>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkAlignment" id="alignment1">
+                        <property name="visible">True</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="AnjutaColumnTextView" id="log_view">
+                            <property name="visible">True</property>
+                            <property name="sensitive">False</property>
+                            <property name="can_focus">True</property>
+                            <property name="orientation">vertical</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkHButtonBox" id="hbuttonbox3">
+        <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="position">1</property>
+      </packing>
+    </child>
+  </object>
 </interface>
diff --git a/plugins/git/git-create-tag-pane.c b/plugins/git/git-create-tag-pane.c
new file mode 100644
index 0000000..c5286ca
--- /dev/null
+++ b/plugins/git/git-create-tag-pane.c
@@ -0,0 +1,243 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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-create-tag-pane.h"
+
+struct _GitCreateTagPanePriv
+{
+	GtkBuilder *builder;
+};
+
+G_DEFINE_TYPE (GitCreateTagPane, git_create_tag_pane, GIT_TYPE_PANE);
+
+static void
+on_ok_button_clicked (GtkButton *button, GitCreateTagPane *self)
+{
+	Git *plugin;
+	GtkEntry *name_entry;
+	GtkToggleButton *revision_radio;
+	GtkEntry *revision_entry;
+	GtkToggleButton *force_check;
+	GtkToggleButton *sign_check;
+	GtkToggleButton *annotate_check;
+	AnjutaColumnTextView *log_view;
+	gchar *name;
+	gchar *revision;
+	gchar *log;
+	GitTagCreateCommand *create_command;
+
+	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
+	name_entry = GTK_ENTRY (gtk_builder_get_object (self->priv->builder,
+	                                                "name_entry"));
+	revision_radio = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+	                                                            "revision_radio"));
+	revision_entry = GTK_ENTRY (gtk_builder_get_object (self->priv->builder,
+	                                                    "revision_entry"));
+	force_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+	                                                         "force_check"));
+	sign_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+	                                                        "sign_check"));
+	annotate_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+	                                                            "annotate_check"));
+	log_view = ANJUTA_COLUMN_TEXT_VIEW (gtk_builder_get_object (self->priv->builder,
+	                                                            "log_view"));
+	name = gtk_editable_get_chars (GTK_EDITABLE (name_entry), 0, -1);
+	revision = NULL;
+	log = NULL;
+
+	if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
+	                           GTK_WIDGET (name_entry), name,
+	                           _("Please enter a tag name.")))
+	{
+		g_free (name);
+
+		return;
+	}
+
+	if (gtk_toggle_button_get_active (revision_radio))
+	{
+		revision = gtk_editable_get_chars (GTK_EDITABLE (revision_entry), 0, 
+		                                   -1);
+
+		if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
+		                           GTK_WIDGET (revision_entry), revision,
+		                           _("Please enter a revision.")))
+		{
+			g_free (name);
+			g_free (revision);
+
+			return;
+		}
+	}
+
+	if (gtk_toggle_button_get_active (annotate_check))
+	{
+		if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
+		                           GTK_WIDGET (log_view), revision,
+		                           _("Please enter a log message.")))
+		{
+			g_free (name);
+			g_free (revision);
+			g_free (log);
+
+			return;
+		}
+	}
+
+	create_command = git_tag_create_command_new (plugin->project_root_directory,
+	                                             name,
+	                                             revision,
+	                                             log,
+	                                             gtk_toggle_button_get_active (sign_check),
+	                                             gtk_toggle_button_get_active (force_check));
+
+	g_signal_connect (G_OBJECT (create_command), "command-finished",
+	                  G_CALLBACK (git_pane_report_errors),
+	                  plugin);
+
+
+	g_signal_connect (G_OBJECT (create_command), "command-finished",
+	                  G_CALLBACK (g_object_unref),
+	                  NULL);
+
+	anjuta_command_start (ANJUTA_COMMAND (create_command));
+
+
+	g_free (name);
+	g_free (revision);
+	g_free (log);
+
+	git_pane_remove_from_dock (GIT_PANE (self));
+}
+
+static void
+set_widget_sensitive (GtkToggleButton *button, GtkWidget *widget)
+{
+	gtk_widget_set_sensitive (widget,
+	                          gtk_toggle_button_get_active (button));
+}
+
+static void
+git_create_tag_pane_init (GitCreateTagPane *self)
+{
+	gchar *objects[] = {"create_tag_pane",
+						NULL};
+	GError *error = NULL;
+	GtkWidget *ok_button;
+	GtkWidget *cancel_button;
+	GtkWidget *revision_radio;
+	GtkWidget *revision_entry;
+	GtkWidget *annotate_check;
+	GtkWidget *log_view;
+	
+
+	self->priv = g_new0 (GitCreateTagPanePriv, 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"));
+	revision_radio = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                                     "revision_radio"));
+	revision_entry = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                                     "revision_entry"));
+	annotate_check = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                                     "annotate_check"));
+	log_view = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                               "log_view"));
+
+	g_signal_connect (G_OBJECT (ok_button), "clicked",
+	                  G_CALLBACK (on_ok_button_clicked),
+	                  self);
+
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
+
+	g_signal_connect (G_OBJECT (revision_radio), "toggled",
+	                  G_CALLBACK (set_widget_sensitive),
+	                  revision_entry);
+
+	g_signal_connect (G_OBJECT (annotate_check), "toggled",
+	                  G_CALLBACK (set_widget_sensitive),
+	                  log_view);
+}
+
+static void
+git_create_tag_pane_finalize (GObject *object)
+{
+	GitCreateTagPane *self;
+
+	self = GIT_CREATE_TAG_PANE (object);
+
+	g_object_unref (self->priv->builder);
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (git_create_tag_pane_parent_class)->finalize (object);
+}
+
+static GtkWidget *
+git_create_tag_pane_get_widget (AnjutaDockPane *pane)
+{
+	GitCreateTagPane *self;
+
+	self = GIT_CREATE_TAG_PANE (pane);
+
+	return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                           "create_tag_pane"));
+}
+
+static void
+git_create_tag_pane_class_init (GitCreateTagPaneClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	AnjutaDockPaneClass *pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
+
+	object_class->finalize = git_create_tag_pane_finalize;
+	pane_class->get_widget = git_create_tag_pane_get_widget;
+	pane_class->refresh = NULL;
+}
+
+
+AnjutaDockPane *
+git_create_tag_pane_new (Git *plugin)
+{
+	return g_object_new (GIT_TYPE_CREATE_TAG_PANE, "plugin", plugin, NULL);
+}
+
+void
+on_create_tag_button_clicked (GtkAction *action, Git *plugin)
+{
+	AnjutaDockPane *pane;
+
+	pane = git_create_tag_pane_new (plugin);
+
+	anjuta_dock_add_pane (ANJUTA_DOCK (plugin->dock), "CreateTag", 
+	                      _("Create Tag"), NULL, pane, GDL_DOCK_BOTTOM, NULL, 0,
+	                      NULL);
+}
\ No newline at end of file
diff --git a/plugins/git/git-create-tag-pane.h b/plugins/git/git-create-tag-pane.h
new file mode 100644
index 0000000..8404ee9
--- /dev/null
+++ b/plugins/git/git-create-tag-pane.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * git-shell-test 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.
+ * 
+ * git-shell-test 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_CREATE_TAG_PANE_H_
+#define _GIT_CREATE_TAG_PANE_H_
+
+#include <glib-object.h>
+#include <libanjuta/anjuta-column-text-view.h>
+#include "git-pane.h"
+#include "plugin.h"
+#include "git-tag-create-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_CREATE_TAG_PANE             (git_create_tag_pane_get_type ())
+#define GIT_CREATE_TAG_PANE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_CREATE_TAG_PANE, GitCreateTagPane))
+#define GIT_CREATE_TAG_PANE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_CREATE_TAG_PANE, GitCreateTagPaneClass))
+#define GIT_IS_CREATE_TAG_PANE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_CREATE_TAG_PANE))
+#define GIT_IS_CREATE_TAG_PANE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_CREATE_TAG_PANE))
+#define GIT_CREATE_TAG_PANE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_CREATE_TAG_PANE, GitCreateTagPaneClass))
+
+typedef struct _GitCreateTagPaneClass GitCreateTagPaneClass;
+typedef struct _GitCreateTagPane GitCreateTagPane;
+typedef struct _GitCreateTagPanePriv GitCreateTagPanePriv;
+
+struct _GitCreateTagPaneClass
+{
+	GitPaneClass parent_class;
+};
+
+struct _GitCreateTagPane
+{
+	GitPane parent_instance;
+
+	GitCreateTagPanePriv *priv;
+};
+
+GType git_create_tag_pane_get_type (void) G_GNUC_CONST;
+AnjutaDockPane *git_create_tag_pane_new (Git *plugin);
+void on_create_tag_button_clicked (GtkAction *action, Git *plugin);
+
+G_END_DECLS
+
+#endif /* _GIT_CREATE_TAG_PANE_H_ */
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 756ba51..14cddcc 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -41,6 +41,7 @@
 #include "git-fetch-pane.h"
 #include "git-resolve-conflicts-pane.h"
 #include "git-tags-pane.h"
+#include "git-create-tag-pane.h"
 
 AnjutaCommandBarEntry branch_entries[] =
 {
@@ -86,6 +87,27 @@ AnjutaCommandBarEntry branch_entries[] =
 	}
 };
 
+AnjutaCommandBarEntry tag_entries[] =
+{
+	{
+		ANJUTA_COMMAND_BAR_ENTRY_FRAME,
+		"NULL",
+		N_("Tag tools"),
+		NULL,
+		NULL,
+		NULL
+	},
+	{
+		ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
+		"CreateTag",
+		N_("Create a tag"),
+		N_("Create a tag"),
+		GTK_STOCK_NEW,
+		G_CALLBACK (on_create_tag_button_clicked)
+	}
+};
+
+
 AnjutaCommandBarEntry status_entries[] = 
 {
 	{
@@ -479,7 +501,7 @@ git_activate_plugin (AnjutaPlugin *plugin)
 	git_plugin->tags_pane = git_tags_pane_new (git_plugin);
 	anjuta_dock_add_pane (ANJUTA_DOCK (git_plugin->dock), "Tags", _("Tags"),
 	                      NULL, git_plugin->tags_pane, GDL_DOCK_CENTER,
-	                      NULL, 0, NULL);
+	                      tag_entries, G_N_ELEMENTS (tag_entries), plugin);
 	
 	git_plugin->remotes_pane = git_remotes_pane_new (git_plugin);
 	anjuta_dock_add_pane (ANJUTA_DOCK (git_plugin->dock), "Remotes", 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]