[anjuta] Implement a very basic push dialog for Git.
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] Implement a very basic push dialog for Git.
- Date: Sun, 19 Apr 2009 18:19:48 -0400 (EDT)
commit 253f5de379d2ede25ab220aaa550cca122d1f64b
Author: James Liggett <jrliggett cox net>
Date: Sun Apr 19 15:13:20 2009 -0700
Implement a very basic push dialog for Git.
It doesn't do very much, but it should get us by until I have time to do something more complete.
---
plugins/git/Makefile.am | 6 +-
plugins/git/anjuta-git.glade | 162 ++++++++++++++++++++++++++++++++++++++++
plugins/git/anjuta-git.ui | 1 +
plugins/git/git-push-command.c | 106 ++++++++++++++++++++++++++
plugins/git/git-push-command.h | 64 ++++++++++++++++
plugins/git/git-push-dialog.c | 123 ++++++++++++++++++++++++++++++
plugins/git/git-push-dialog.h | 33 ++++++++
plugins/git/plugin.c | 9 ++
8 files changed, 503 insertions(+), 1 deletions(-)
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index ba24722..fa951a5 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -181,7 +181,11 @@ libanjuta_git_la_SOURCES = \
git-vcs-interface.c \
git-vcs-interface.h \
git-clone-command.h \
- git-clone-command.c
+ git-clone-command.c \
+ git-push-command.c \
+ git-push-command.h \
+ git-push-dialog.c \
+ git-push-dialog.h
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/anjuta-git.glade b/plugins/git/anjuta-git.glade
index 59e9bad..e2b4154 100644
--- a/plugins/git/anjuta-git.glade
+++ b/plugins/git/anjuta-git.glade
@@ -3806,4 +3806,166 @@
</widget>
</child>
</widget>
+ <widget class="GtkDialog" id="push_dialog">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Push</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox22">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkFrame" id="frame5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkEntry" id="push_url_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="width_chars">60</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"><b>Repository to push to:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkFrame" id="frame6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkCheckButton" id="push_all_check">
+ <property name="label" translatable="yes">Push all refs</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="push_tags_check">
+ <property name="label" translatable="yes">Push 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>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"><b>Options:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area22">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="layout_style">end</property>
+ <child>
+ <widget class="GtkButton" id="button5">
+ <property name="label">gtk-cancel</property>
+ <property name="response_id">-6</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button6">
+ <property name="label">gtk-ok</property>
+ <property name="response_id">-5</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 7f3a067..476e5c9 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -15,6 +15,7 @@
<menuitem name="Abort" action="ActionGitRebaseAbort" />
</menu>
</placeholder>
+ <menuitem name="Push..." action="ActionGitPush" />
<menuitem name="Create patch series..." action="ActionGitCreatePatchSeries" />
<menuitem name="Diff uncommitted changes" action="ActionGitDiffUncommitted" />
<separator />
diff --git a/plugins/git/git-push-command.c b/plugins/git/git-push-command.c
new file mode 100644
index 0000000..9871e99
--- /dev/null
+++ b/plugins/git/git-push-command.c
@@ -0,0 +1,106 @@
+/* -*- 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-push-command.h"
+
+struct _GitPushCommandPriv
+{
+ gchar *url;
+ gboolean push_all;
+ gboolean push_tags;
+};
+
+G_DEFINE_TYPE (GitPushCommand, git_push_command, GIT_TYPE_COMMAND);
+
+static void
+git_push_command_init (GitPushCommand *self)
+{
+ self->priv = g_new0 (GitPushCommandPriv, 1);
+}
+
+static void
+git_push_command_finalize (GObject *object)
+{
+ GitPushCommand *self;
+
+ self = GIT_PUSH_COMMAND (object);
+
+ g_free (self->priv->url);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (git_push_command_parent_class)->finalize (object);
+}
+
+static guint
+git_push_command_run (AnjutaCommand *command)
+{
+ GitPushCommand *self;
+
+ self = GIT_PUSH_COMMAND (command);
+
+ git_command_add_arg (GIT_COMMAND (command), "push");
+
+ if (self->priv->push_all)
+ git_command_add_arg (GIT_COMMAND (command), "--all");
+
+ if (self->priv->push_tags)
+ git_command_add_arg (GIT_COMMAND (command), "--tags");
+
+ git_command_add_arg (GIT_COMMAND (command), self->priv->url);
+
+ return 0;
+}
+
+static void
+git_push_command_class_init (GitPushCommandClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
+ AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
+
+ object_class->finalize = git_push_command_finalize;
+ parent_class->output_handler = git_command_send_output_to_info;
+ command_class->run = git_push_command_run;
+}
+
+
+GitPushCommand *
+git_push_command_new (const gchar *working_directory,
+ const gchar *url,
+ gboolean push_all,
+ gboolean push_tags)
+{
+ GitPushCommand *self;
+
+ self = g_object_new (GIT_TYPE_PUSH_COMMAND,
+ "working-directory", working_directory,
+ "single-line-output", TRUE,
+ NULL);
+
+ self->priv->url = g_strdup (url);
+ self->priv->push_all = push_all;
+ self->priv->push_tags = push_tags;
+
+ return self;
+}
diff --git a/plugins/git/git-push-command.h b/plugins/git/git-push-command.h
new file mode 100644
index 0000000..f7d8550
--- /dev/null
+++ b/plugins/git/git-push-command.h
@@ -0,0 +1,64 @@
+/* -*- 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_PUSH_COMMAND_H_
+#define _GIT_PUSH_COMMAND_H_
+
+#include <glib-object.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_PUSH_COMMAND (git_push_command_get_type ())
+#define GIT_PUSH_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_PUSH_COMMAND, GitPushCommand))
+#define GIT_PUSH_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_PUSH_COMMAND, GitPushCommandClass))
+#define GIT_IS_PUSH_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_PUSH_COMMAND))
+#define GIT_IS_PUSH_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_PUSH_COMMAND))
+#define GIT_PUSH_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_PUSH_COMMAND, GitPushCommandClass))
+
+typedef struct _GitPushCommandClass GitPushCommandClass;
+typedef struct _GitPushCommand GitPushCommand;
+typedef struct _GitPushCommandPriv GitPushCommandPriv;
+
+struct _GitPushCommandClass
+{
+ GitCommandClass parent_class;
+};
+
+struct _GitPushCommand
+{
+ GitCommand parent_instance;
+
+ GitPushCommandPriv *priv;
+};
+
+GType git_push_command_get_type (void) G_GNUC_CONST;
+GitPushCommand *git_push_command_new (const gchar *working_directory,
+ const gchar *url,
+ gboolean push_all,
+ gboolean push_tags);
+
+G_END_DECLS
+
+#endif /* _GIT_PUSH_COMMAND_H_ */
diff --git a/plugins/git/git-push-dialog.c b/plugins/git/git-push-dialog.c
new file mode 100644
index 0000000..676ac34
--- /dev/null
+++ b/plugins/git/git-push-dialog.c
@@ -0,0 +1,123 @@
+/* -*- 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-push-dialog.h"
+
+static void
+on_push_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: Push complete."), 5);
+
+ git_report_errors (command, return_code);
+
+ g_object_unref (command);
+}
+
+
+static void
+on_push_dialog_response (GtkDialog *dialog, gint response_id,
+ GitUIData *data)
+{
+ GtkWidget *push_url_entry;
+ GtkWidget *push_all_check;
+ GtkWidget *push_tags_check;
+ gchar *url;
+ GitPushCommand *push_command;
+ GitProgressData *progress_data;
+
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ push_url_entry = glade_xml_get_widget (data->gxml, "push_url_entry");
+ push_all_check = glade_xml_get_widget (data->gxml, "push_all_check");
+ push_tags_check = glade_xml_get_widget (data->gxml, "push_tags_check");
+
+ url = gtk_editable_get_chars (GTK_EDITABLE (push_url_entry), 0, -1);
+
+ if (git_check_input (GTK_WIDGET (dialog), push_url_entry, url,
+ _("Please enter the URL of the repository to push to.")))
+ {
+ push_command = git_push_command_new (data->plugin->project_root_directory,
+ url,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (push_all_check)),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (push_tags_check)));
+ progress_data = git_progress_data_new (data->plugin, _("Git: Pushing..."));
+
+ g_free (url);
+
+ git_create_message_view (data->plugin);
+
+
+ g_signal_connect (G_OBJECT (push_command), "data-arrived",
+ G_CALLBACK (on_git_command_info_arrived),
+ data->plugin);
+
+ g_signal_connect (G_OBJECT (push_command), "progress",
+ G_CALLBACK (on_git_command_progress),
+ progress_data);
+
+ g_signal_connect (G_OBJECT (push_command), "command-finished",
+ G_CALLBACK (on_push_command_finished),
+ data->plugin);
+
+ anjuta_command_start (ANJUTA_COMMAND (push_command));
+ }
+ else
+ return;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ git_ui_data_free (data);
+}
+
+static void
+push_dialog (Git *plugin)
+{
+ GladeXML *gxml;
+ GtkWidget *dialog;
+ GitUIData *data;
+
+ gxml = glade_xml_new (GLADE_FILE, "push_dialog", NULL);
+
+ dialog = glade_xml_get_widget (gxml, "push_dialog");
+
+ data = git_ui_data_new (plugin, gxml);
+
+ g_signal_connect(G_OBJECT (dialog), "response",
+ G_CALLBACK (on_push_dialog_response),
+ data);
+
+ gtk_widget_show_all (dialog);
+}
+
+void
+on_menu_git_push (GtkAction *action, Git *plugin)
+{
+ push_dialog (plugin);
+}
\ No newline at end of file
diff --git a/plugins/git/git-push-dialog.h b/plugins/git/git-push-dialog.h
new file mode 100644
index 0000000..16e4565
--- /dev/null
+++ b/plugins/git/git-push-dialog.h
@@ -0,0 +1,33 @@
+/* -*- 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_PUSH_DIALOG_H
+#define _GIT_PUSH_DIALOG_H
+
+#include "git-push-command.h"
+#include "git-ui-utils.h"
+
+void on_menu_git_push (GtkAction *action, Git *plugin);
+
+#endif
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index e7c7146..8e44c36 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -45,6 +45,7 @@
#include "git-create-patch-series-dialog.h"
#include "git-pull-dialog.h"
#include "git-cat-file-menu.h"
+#include "git-push-dialog.h"
#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.ui"
@@ -324,6 +325,14 @@ static GtkActionEntry actions_git[] =
NULL, /* short-cut */
NULL, /* Tooltip */
G_CALLBACK (on_menu_git_diff) /* action callback */
+ },
+ {
+ "ActionGitPush", /* Action name */
+ GTK_STOCK_GO_FORWARD, /* Stock icon, if any */
+ N_("_Push..."), /* Display label */
+ NULL, /* short-cut */
+ NULL, /* Tooltip */
+ G_CALLBACK (on_menu_git_push) /* action callback */
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]