[anjuta/git-shell: 19/20] git: Implement merging pane
- From: James Liggett <jrliggett src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/git-shell: 19/20] git: Implement merging pane
- Date: Tue, 1 Jun 2010 02:53:36 +0000 (UTC)
commit 22697c7325d2cf04bd26f339e2e2b638c9f2af53
Author: James Liggett <jrliggett cox net>
Date: Mon May 31 12:27:01 2010 -0700
git: Implement merging pane
plugins/git/Makefile.am | 8 +-
plugins/git/anjuta-git.ui | 180 +++++++++++++++++++++++++++++++++
plugins/git/git-merge-pane.c | 224 ++++++++++++++++++++++++++++++++++++++++++
plugins/git/git-merge-pane.h | 59 +++++++++++
plugins/git/git-pane.c | 17 +++
plugins/git/git-pane.h | 4 +
plugins/git/plugin.c | 9 ++
7 files changed, 499 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 9b5309d..7e70cc4 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -18,7 +18,9 @@ git_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin) \
git-branches-pane.c\
git-branches-pane.h\
git-pane.c \
- git-pane.h
+ git-pane.h \
+ git-merge-pane.c \
+ git-merge-pane.h
# NOTE :
# The naming convention is very intentional
@@ -167,7 +169,9 @@ libanjuta_git_la_SOURCES = \
git-delete-branches-pane.c \
git-delete-branch-pane.h \
git-switch-branch-pane.c \
- git-switch-branch-pane.h
+ git-switch-branch-pane.h \
+ git-merge-pane.c \
+ git-merge-pane.h
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 8a27cbd..a5630e6 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -902,4 +902,184 @@
</packing>
</child>
</object>
+ <object class="GtkVBox" id="merge_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="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="AnjutaDropEntry" id="revision_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Revision to merge with:</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">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="GtkCheckButton" id="do_not_commit_check">
+ <property name="label" translatable="yes">Do not commit</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="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="squash_check">
+ <property name="label" translatable="yes">Squash</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="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="use_custom_log_check">
+ <property name="label" translatable="yes">Use a custom log message:</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="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="log_text_view">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="column_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Column 0</property>
+ </object>
+ <packing>
+ <property name="position">4</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"><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>
+ </object>
+ <packing>
+ <property name="position">0</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="position">1</property>
+ </packing>
+ </child>
+ </object>
</interface>
diff --git a/plugins/git/git-merge-pane.c b/plugins/git/git-merge-pane.c
new file mode 100644
index 0000000..6fe09d4
--- /dev/null
+++ b/plugins/git/git-merge-pane.c
@@ -0,0 +1,224 @@
+/* -*- 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-merge-pane.h"
+
+struct _GitMergePanePriv
+{
+ GtkBuilder *builder;
+};
+
+G_DEFINE_TYPE (GitMergePane, git_merge_pane, GIT_TYPE_PANE);
+
+static void
+on_ok_button_clicked (GtkButton *button, GitMergePane *self)
+{
+ Git *plugin;
+ GtkEditable *revision_entry;
+ GtkToggleButton *do_not_commit_check;
+ GtkToggleButton *squash_check;
+ GtkToggleButton *use_custom_log_check;
+ gchar *revision;
+ gchar *log;
+ GtkTextView *log_text_view;
+ GtkTextBuffer *log_buffer;
+ GtkTextIter start_iter;
+ GtkTextIter end_iter;
+ GitMergeCommand *merge_command;
+
+ plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
+ revision_entry = GTK_EDITABLE (gtk_builder_get_object (self->priv->builder,
+ "revision_entry"));
+ do_not_commit_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "do_not_commit_check"));
+ squash_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "squash_check"));
+ use_custom_log_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "use_custom_log_check"));
+ revision = gtk_editable_get_chars (revision_entry, 0, -1);
+ log = NULL;
+
+ if (gtk_toggle_button_get_active (use_custom_log_check))
+ {
+ log_text_view = GTK_TEXT_VIEW (gtk_builder_get_object (self->priv->builder,
+ "log_text_view"));
+ log_buffer = gtk_text_view_get_buffer (log_text_view);
+
+ gtk_text_buffer_get_start_iter (log_buffer, &start_iter);
+ gtk_text_buffer_get_end_iter (log_buffer, &end_iter);
+
+ log = gtk_text_buffer_get_text (log_buffer, &start_iter, &end_iter,
+ FALSE);
+ }
+
+ merge_command = git_merge_command_new (plugin->project_root_directory,
+ revision, log,
+ gtk_toggle_button_get_active (do_not_commit_check),
+ gtk_toggle_button_get_active (squash_check));
+
+ g_free (revision);
+ g_free (log);
+
+ git_pane_create_message_view (plugin);
+
+ g_signal_connect (G_OBJECT (merge_command), "data-arrived",
+ G_CALLBACK (git_pane_on_command_info_arrived),
+ plugin);
+
+ g_signal_connect (G_OBJECT (merge_command), "command-finished",
+ G_CALLBACK (g_object_unref),
+ NULL);
+
+ anjuta_command_start (ANJUTA_COMMAND (merge_command));
+
+
+ anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock),
+ ANJUTA_DOCK_PANE (self));
+}
+
+static void
+on_cancel_button_clicked (GtkButton *button, GitMergePane *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
+on_use_custom_log_check_toggled (GtkToggleButton *button, GitMergePane *self)
+{
+ GtkWidget *log_text_view;
+ gboolean active;
+
+ log_text_view = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "log_text_view"));
+ active = gtk_toggle_button_get_active (button);
+
+ gtk_widget_set_sensitive (log_text_view, active);
+}
+
+static void
+git_merge_pane_init (GitMergePane *self)
+{
+ gchar *objects[] = {"merge_pane",
+ NULL};
+ GError *error = NULL;
+ GtkWidget *ok_button;
+ GtkWidget *cancel_button;
+ GtkWidget *use_custom_log_check;
+ GtkTextView *log_text_view;
+ GtkTextBuffer *log_buffer;
+ GtkWidget *column_label;
+
+ self->priv = g_new0 (GitMergePanePriv, 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"));
+ use_custom_log_check = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "use_custom_log_check"));
+ log_text_view = GTK_TEXT_VIEW (gtk_builder_get_object (self->priv->builder,
+ "log_text_view"));
+ log_buffer = gtk_text_view_get_buffer (log_text_view);
+ column_label = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "column_label"));
+
+ 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);
+
+ g_signal_connect (G_OBJECT (use_custom_log_check), "toggled",
+ G_CALLBACK (on_use_custom_log_check_toggled),
+ self);
+
+ g_signal_connect (G_OBJECT (log_buffer), "mark-set",
+ G_CALLBACK (git_pane_set_log_view_column_label),
+ column_label);
+}
+
+static void
+git_merge_pane_finalize (GObject *object)
+{
+ GitMergePane *self;
+
+ self = GIT_MERGE_PANE (object);
+
+ g_object_unref (self->priv->builder);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (git_merge_pane_parent_class)->finalize (object);
+}
+
+static GtkWidget *
+git_merge_pane_get_widget (AnjutaDockPane *pane)
+{
+ GitMergePane *self;
+
+ self = GIT_MERGE_PANE (pane);
+
+ return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "merge_pane"));
+}
+
+static void
+git_merge_pane_class_init (GitMergePaneClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ AnjutaDockPaneClass *pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
+
+ object_class->finalize = git_merge_pane_finalize;
+ pane_class->get_widget = git_merge_pane_get_widget;
+ pane_class->refresh = NULL;
+}
+
+
+AnjutaDockPane *
+git_merge_pane_new (Git *plugin)
+{
+ return g_object_new (GIT_TYPE_MERGE_PANE, "plugin", plugin, NULL);
+}
+
+void
+on_merge_button_clicked (GtkAction *action, Git *plugin)
+{
+ AnjutaDockPane *pane;
+
+ pane = git_merge_pane_new (plugin);
+
+ anjuta_dock_add_pane (ANJUTA_DOCK (plugin->dock), "Merge",
+ _("Merge"), NULL, pane, GDL_DOCK_BOTTOM, NULL, 0,
+ NULL);
+}
diff --git a/plugins/git/git-merge-pane.h b/plugins/git/git-merge-pane.h
new file mode 100644
index 0000000..96f0b4d
--- /dev/null
+++ b/plugins/git/git-merge-pane.h
@@ -0,0 +1,59 @@
+/* -*- 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_MERGE_PANE_H_
+#define _GIT_MERGE_PANE_H_
+
+#include <glib-object.h>
+#include "git-pane.h"
+#include "git-merge-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_MERGE_PANE (git_merge_pane_get_type ())
+#define GIT_MERGE_PANE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_MERGE_PANE, GitMergePane))
+#define GIT_MERGE_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_MERGE_PANE, GitMergePaneClass))
+#define GIT_IS_MERGE_PANE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_MERGE_PANE))
+#define GIT_IS_MERGE_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_MERGE_PANE))
+#define GIT_MERGE_PANE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_MERGE_PANE, GitMergePaneClass))
+
+typedef struct _GitMergePaneClass GitMergePaneClass;
+typedef struct _GitMergePane GitMergePane;
+typedef struct _GitMergePanePriv GitMergePanePriv;
+
+struct _GitMergePaneClass
+{
+ GitPaneClass parent_class;
+};
+
+struct _GitMergePane
+{
+ GitPane parent_instance;
+
+ GitMergePanePriv *priv;
+};
+
+GType git_merge_pane_get_type (void) G_GNUC_CONST;
+AnjutaDockPane *git_merge_pane_new (Git *plugin);
+
+void on_merge_button_clicked (GtkAction *action, Git *plugin);
+
+G_END_DECLS
+
+#endif /* _GIT_MERGE_PANE_H_ */
diff --git a/plugins/git/git-pane.c b/plugins/git/git-pane.c
index 61a8889..dc7cc04 100644
--- a/plugins/git/git-pane.c
+++ b/plugins/git/git-pane.c
@@ -97,4 +97,21 @@ git_pane_on_command_info_arrived (AnjutaCommand *command, Git *plugin)
message, "", NULL);
g_free (message);
}
+}
+
+void
+git_pane_set_log_view_column_label (GtkTextBuffer *buffer,
+ GtkTextIter *location,
+ GtkTextMark *mark,
+ GtkLabel *column_label)
+{
+ gint column;
+ gchar *text;
+
+ column = gtk_text_iter_get_line_offset (location) + 1;
+ text = g_strdup_printf (_("Column %i"), column);
+
+ gtk_label_set_text (column_label, text);
+
+ g_free (text);
}
\ No newline at end of file
diff --git a/plugins/git/git-pane.h b/plugins/git/git-pane.h
index 1003d7e..452e71b 100644
--- a/plugins/git/git-pane.h
+++ b/plugins/git/git-pane.h
@@ -52,6 +52,10 @@ GType git_pane_get_type (void) G_GNUC_CONST;
/* Static helper methods */
void git_pane_create_message_view (Git *plugin);
void git_pane_on_command_info_arrived (AnjutaCommand *command, Git *plugin);
+void git_pane_set_log_view_column_label (GtkTextBuffer *buffer,
+ GtkTextIter *location,
+ GtkTextMark *mark,
+ GtkLabel *column_label);
G_END_DECLS
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 264797d..4f505e6 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -25,6 +25,7 @@
#include "git-create-branch-pane.h"
#include "git-delete-branches-pane.h"
#include "git-switch-branch-pane.h"
+#include "git-merge-pane.h"
AnjutaCommandBarEntry branch_entries[] =
{
@@ -59,6 +60,14 @@ AnjutaCommandBarEntry branch_entries[] =
N_("Switch to the selected branch"),
GTK_STOCK_JUMP_TO,
G_CALLBACK (on_switch_branch_button_clicked)
+ },
+ {
+ ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
+ "Merge",
+ N_("Merge"),
+ N_("Merge a revision into the current branch"),
+ GTK_STOCK_CONVERT,
+ G_CALLBACK (on_merge_button_clicked)
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]