[anjuta/git-shell: 13/14] git: Implement the pull pane
- From: James Liggett <jrliggett src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/git-shell: 13/14] git: Implement the pull pane
- Date: Thu, 8 Jul 2010 07:07:30 +0000 (UTC)
commit 34a4763b366ad2fbfa2b88c4cccb5b02e89d5f87
Author: James Liggett <jrliggett cox net>
Date: Wed Jul 7 22:56:51 2010 -0700
git: Implement the pull pane
plugins/git/Makefile.am | 4 +-
plugins/git/anjuta-git.ui | 198 +++++++++++++++++++++++++++++++++++
plugins/git/git-pull-pane.c | 244 +++++++++++++++++++++++++++++++++++++++++++
plugins/git/git-pull-pane.h | 61 +++++++++++
plugins/git/plugin.c | 9 ++
5 files changed, 515 insertions(+), 1 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index f608679..7e0636f 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -179,7 +179,9 @@ libanjuta_git_la_SOURCES = \
git-push-pane.c \
git-push-pane.h \
git-repository-selector.c \
- git-repository-selector.h
+ git-repository-selector.h \
+ git-pull-pane.h \
+ git-pull-pane.c
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 81c8ba6..14ddb56 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -1987,4 +1987,202 @@
</packing>
</child>
</object>
+ <object class="GtkVBox" id="pull_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="repository_alignment">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xpad">1</property>
+ <property name="label" translatable="yes"><b>Repository to pull from:</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="alignment1">
+ <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="rebase_check">
+ <property name="label" translatable="yes">Rebase</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="GtkCheckButton" id="no_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">1</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">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="append_fetch_data_check">
+ <property name="label" translatable="yes">Append fetch data</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">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="fast_forward_commit_check">
+ <property name="label" translatable="yes">Commit on fast-forward merges</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">4</property>
+ </packing>
+ </child>
+ <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="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="no_follow_tags_check">
+ <property name="label" translatable="yes">Do not follow tags</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">6</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="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
</interface>
diff --git a/plugins/git/git-pull-pane.c b/plugins/git/git-pull-pane.c
new file mode 100644
index 0000000..04be8aa
--- /dev/null
+++ b/plugins/git/git-pull-pane.c
@@ -0,0 +1,244 @@
+/* -*- 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-pull-pane.h"
+
+struct _GitPullPanePriv
+{
+ GtkBuilder *builder;
+ GtkWidget *repository_selector;
+};
+
+G_DEFINE_TYPE (GitPullPane, git_pull_pane, GIT_TYPE_PANE);
+
+static void
+on_ok_button_clicked (GtkButton *button, GitPullPane *self)
+{
+ Git *plugin;
+ GtkToggleButton *rebase_check;
+ GtkToggleButton *no_commit_check;
+ GtkToggleButton *squash_check;
+ GtkToggleButton *append_fetch_data_check;
+ GtkToggleButton *fast_forward_commit_check;
+ GtkToggleButton *force_check;
+ GtkToggleButton *no_follow_tags_check;
+ gchar *repository;
+ GitPullCommand *pull_command;
+
+ plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
+ rebase_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "rebase_check"));
+ no_commit_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "no_commit_check"));
+ squash_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "squash_check"));
+ append_fetch_data_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "append_fetch_data_check"));
+ fast_forward_commit_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "fast_forward_commit_check"));
+ force_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "force_check"));
+ no_follow_tags_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
+ "no_follow_tags_check"));
+
+ repository = git_repository_selector_get_repository (GIT_REPOSITORY_SELECTOR (self->priv->repository_selector));
+
+ /* Check input. Input can only be bad if the selector is in URL mode */
+ if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
+ self->priv->repository_selector,
+ repository,
+ _("Please enter a URL.")))
+ {
+ g_free (repository);
+ return;
+ }
+
+ pull_command = git_pull_command_new (plugin->project_root_directory,
+ repository,
+ gtk_toggle_button_get_active (rebase_check),
+ gtk_toggle_button_get_active (no_commit_check),
+ gtk_toggle_button_get_active (squash_check),
+ gtk_toggle_button_get_active (append_fetch_data_check),
+ gtk_toggle_button_get_active (fast_forward_commit_check),
+ gtk_toggle_button_get_active (force_check),
+ gtk_toggle_button_get_active (no_follow_tags_check));
+
+ g_free (repository);
+
+ git_pane_create_message_view (plugin);
+
+ g_signal_connect (G_OBJECT (pull_command), "data_arrived",
+ G_CALLBACK (git_pane_on_command_info_arrived),
+ plugin);
+
+ g_signal_connect (G_OBJECT (pull_command), "command-finished",
+ G_CALLBACK (g_object_unref),
+ NULL);
+
+ anjuta_command_start (ANJUTA_COMMAND (pull_command));
+
+ anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock),
+ ANJUTA_DOCK_PANE (self));
+}
+
+static void
+on_cancel_button_clicked (GtkButton *button, GitPullPane *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_remote_selected (AnjutaDockPane *pane,
+ GitRepositorySelector *repository_selector)
+{
+ gchar *remote;
+
+ remote = git_remotes_pane_get_selected_remote (GIT_REMOTES_PANE (pane));
+ git_repository_selector_set_remote (repository_selector, remote);
+
+ g_free (remote);
+}
+
+static void
+git_pull_pane_init (GitPullPane *self)
+{
+ gchar *objects[] = {"pull_pane",
+ NULL};
+ GError *error = NULL;
+ GtkWidget *ok_button;
+ GtkWidget *cancel_button;
+ GtkContainer *repository_alignment;
+
+ self->priv = g_new0 (GitPullPanePriv, 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"));
+ repository_alignment = GTK_CONTAINER (gtk_builder_get_object (self->priv->builder,
+ "repository_alignment"));
+ self->priv->repository_selector = git_repository_selector_new ();
+
+ gtk_container_add (repository_alignment, self->priv->repository_selector);
+
+ 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_pull_pane_finalize (GObject *object)
+{
+ GitPullPane *self;
+
+ self = GIT_PULL_PANE (object);
+
+ g_object_unref (self->priv->builder);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (git_pull_pane_parent_class)->finalize (object);
+}
+
+static void
+git_pull_pane_dispose (GObject *object)
+{
+ GitPullPane *self;
+ Git *plugin;
+
+ self = GIT_PULL_PANE (object);
+ plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (object)));
+
+ g_signal_handlers_disconnect_by_func (plugin->remotes_pane,
+ on_remote_selected,
+ self->priv->repository_selector);
+
+
+ G_OBJECT_CLASS (git_pull_pane_parent_class)->dispose (object);
+}
+
+static GtkWidget *
+git_pull_pane_get_widget (AnjutaDockPane *pane)
+{
+ GitPullPane *self;
+
+ self = GIT_PULL_PANE (pane);
+
+ return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "pull_pane"));
+}
+
+static void
+git_pull_pane_class_init (GitPullPaneClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ AnjutaDockPaneClass *pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
+
+ object_class->finalize = git_pull_pane_finalize;
+ object_class->dispose = git_pull_pane_dispose;
+ pane_class->get_widget = git_pull_pane_get_widget;
+}
+
+
+AnjutaDockPane *
+git_pull_pane_new (Git *plugin)
+{
+ GitPullPane *self;
+
+ self = g_object_new (GIT_TYPE_PULL_PANE, "plugin", plugin, NULL);
+
+ g_signal_connect (G_OBJECT (plugin->remotes_pane), "single_selection_changed",
+ G_CALLBACK (on_remote_selected),
+ self->priv->repository_selector);
+
+ /* Set the contents of the selected remote label */
+ on_remote_selected (plugin->remotes_pane,
+ GIT_REPOSITORY_SELECTOR (self->priv->repository_selector));
+
+ return ANJUTA_DOCK_PANE (self);
+}
+
+void
+on_pull_button_clicked (GtkAction *action, Git *plugin)
+{
+ AnjutaDockPane *pane;
+
+ pane = git_pull_pane_new (plugin);
+
+ anjuta_dock_add_pane (ANJUTA_DOCK (plugin->dock), "Pull",
+ _("Pull"), NULL, pane, GDL_DOCK_BOTTOM,
+ NULL, 0, NULL);
+}
diff --git a/plugins/git/git-pull-pane.h b/plugins/git/git-pull-pane.h
new file mode 100644
index 0000000..606947b
--- /dev/null
+++ b/plugins/git/git-pull-pane.h
@@ -0,0 +1,61 @@
+/* -*- 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_PULL_PANE_H_
+#define _GIT_PULL_PANE_H_
+
+#include <glib-object.h>
+#include "git-pane.h"
+#include "git-remotes-pane.h"
+#include "git-repository-selector.h"
+#include "git-pull-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_PULL_PANE (git_pull_pane_get_type ())
+#define GIT_PULL_PANE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_PULL_PANE, GitPullPane))
+#define GIT_PULL_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_PULL_PANE, GitPullPaneClass))
+#define GIT_IS_PULL_PANE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_PULL_PANE))
+#define GIT_IS_PULL_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_PULL_PANE))
+#define GIT_PULL_PANE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_PULL_PANE, GitPullPaneClass))
+
+typedef struct _GitPullPaneClass GitPullPaneClass;
+typedef struct _GitPullPane GitPullPane;
+typedef struct _GitPullPanePriv GitPullPanePriv;
+
+struct _GitPullPaneClass
+{
+ GitPaneClass parent_class;
+};
+
+struct _GitPullPane
+{
+ GitPane parent_instance;
+
+ GitPullPanePriv *priv;
+};
+
+GType git_pull_pane_get_type (void) G_GNUC_CONST;
+AnjutaDockPane *git_pull_pane_new (Git *plugin);
+
+void on_pull_button_clicked (GtkAction *action, Git *plugin);
+
+G_END_DECLS
+
+#endif /* _GIT_PULL_PANE_H_ */
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index ee0702d..793cc2c 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -32,6 +32,7 @@
#include "git-remove-files-pane.h"
#include "git-remotes-pane.h"
#include "git-push-pane.h"
+#include "git-pull-pane.h"
AnjutaCommandBarEntry branch_entries[] =
{
@@ -138,6 +139,14 @@ AnjutaCommandBarEntry remotes_entries[] =
N_("Push changes to a remote repository"),
GTK_STOCK_GO_FORWARD,
G_CALLBACK (on_push_button_clicked)
+ },
+ {
+ ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
+ "Pull",
+ N_("Pull"),
+ N_("Pull changes from a remote repository"),
+ GTK_STOCK_GO_BACK,
+ G_CALLBACK (on_pull_button_clicked)
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]