[anjuta] git: Add an advanced dialog for applying stashes to the Stash menu
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] git: Add an advanced dialog for applying stashes to the Stash menu
- Date: Fri, 24 Jul 2009 01:49:28 +0000 (UTC)
commit acb9d9a67182e973809ee6ffecd2f87111bcdadc
Author: James Liggett <jrliggett cox net>
Date: Tue Jul 21 22:24:14 2009 -0700
git: Add an advanced dialog for applying stashes to the Stash menu
plugins/git/Makefile.am | 4 +-
plugins/git/anjuta-git.ui | 153 ++++++++++++++++++++++++++++++++++
plugins/git/anjuta-git.xml | 3 +-
plugins/git/git-apply-stash-dialog.c | 108 ++++++++++++++++++++++++
plugins/git/git-apply-stash-dialog.h | 29 +++++++
plugins/git/git-stash-widget.c | 12 +++
plugins/git/git-stash-widget.h | 1 +
plugins/git/git-ui-utils.c | 36 ++++++++
plugins/git/git-ui-utils.h | 1 +
plugins/git/plugin.c | 9 ++
10 files changed, 354 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 30927d6..ee2195b 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -211,7 +211,9 @@ libanjuta_git_la_SOURCES = \
git-stash-list-command.c \
git-stash-list-command.h \
git-stash-apply-command.c \
- git-stash-apply-command.h
+ git-stash-apply-command.h \
+ git-apply-stash-dialog.c \
+ git-apply-stash-dialog.h
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index ffb8504..dab4f33 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -5392,4 +5392,157 @@
</packing>
</child>
</object>
+ <object class="GtkDialog" id="apply_stash_dialog">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Apply Stash</property>
+ <property name="window_position">center</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox42">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkVBox" id="vbox35">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkFrame" id="frame56">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment56">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow14">
+ <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="GtkTreeView" id="apply_stash_view">
+ <property name="width_request">600</property>
+ <property name="height_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">stash_list_model</property>
+ <property name="headers_visible">False</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn10">
+ <property name="title">column</property>
+ <child>
+ <object class="GtkCellRendererText" id="stash_apply_view_message_renderer"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label68">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Stash to Apply</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame57">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment57">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkCheckButton" id="apply_stash_restore_index_check">
+ <property name="label" translatable="yes">Restore index</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="label69">
+ <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">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area43">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button42">
+ <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="button43">
+ <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="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button42</action-widget>
+ <action-widget response="-5">button43</action-widget>
+ </action-widgets>
+ </object>
</interface>
diff --git a/plugins/git/anjuta-git.xml b/plugins/git/anjuta-git.xml
index a780cff..e3c423c 100644
--- a/plugins/git/anjuta-git.xml
+++ b/plugins/git/anjuta-git.xml
@@ -20,7 +20,8 @@
<menuitem name="Diff uncommitted changes" action="ActionGitDiffUncommitted" />
<placeholder name="PlaceholderStashMenu">
<menu name="Stash" action="ActionMenuGitStash">
- <menuitem name="Stash uncomitted changes" action="ActionGitStashUncommitted" />
+ <menuitem name="Stash uncomitted changes..." action="ActionGitStashUncommitted" />
+ <menuitem name="Apply stashed changes..." action="ActionGitApplyStash" />
</menu>
</placeholder>
<separator />
diff --git a/plugins/git/git-apply-stash-dialog.c b/plugins/git/git-apply-stash-dialog.c
new file mode 100644
index 0000000..612d381
--- /dev/null
+++ b/plugins/git/git-apply-stash-dialog.c
@@ -0,0 +1,108 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2009 <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-apply-stash-dialog.h"
+
+static void
+on_apply_stash_dialog_response (GtkDialog *dialog, gint response,
+ GitUIData *data)
+{
+ GtkWidget *apply_stash_view;
+ GtkWidget *apply_stash_restore_index_check;
+ GtkTreeSelection *selection;
+ gchar *stash;
+ GitStashApplyCommand *apply_command;
+
+ if (response == GTK_RESPONSE_OK)
+ {
+ apply_stash_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "apply_stash_view"));
+ apply_stash_restore_index_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "apply_stash_restore_index_check"));
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (apply_stash_view));
+ stash = NULL;
+
+ if (!git_get_selected_stash (selection, &stash))
+ return;
+
+ apply_command = git_stash_apply_command_new (data->plugin->project_root_directory,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (apply_stash_restore_index_check)),
+ stash);
+
+ git_create_message_view (data->plugin);
+
+ g_signal_connect (G_OBJECT (apply_command), "command-finished",
+ G_CALLBACK (on_git_stash_apply_command_finished),
+ data->plugin);
+
+ g_signal_connect (G_OBJECT (apply_command), "data-arrived",
+ G_CALLBACK (on_git_command_info_arrived),
+ data->plugin);
+
+ anjuta_command_start (ANJUTA_COMMAND (apply_command));
+ }
+
+ git_ui_data_free (data);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+apply_stash_dialog (Git *plugin)
+{
+ GtkBuilder *bxml;
+ gchar *objects[] = {"apply_stash_dialog", "stash_list_model", NULL};
+ GError *error;
+ GtkWidget *dialog;
+ GtkWidget *apply_stash_view;
+ GtkListStore *stash_widget_model;
+ GitUIData *data;
+
+ bxml = gtk_builder_new ();
+ error = NULL;
+
+ if (!gtk_builder_add_objects_from_file (bxml, BUILDER_FILE, objects,
+ &error))
+ {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+
+ dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "apply_stash_dialog"));
+ apply_stash_view = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "apply_stash_view"));
+ stash_widget_model = git_stash_widget_get_model (plugin);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (apply_stash_view),
+ GTK_TREE_MODEL (stash_widget_model));
+
+ data = git_ui_data_new (plugin, bxml);
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (on_apply_stash_dialog_response),
+ data);
+
+ gtk_widget_show_all (dialog);
+}
+
+void
+on_menu_git_apply_stash (GtkAction *action, Git *plugin)
+{
+ apply_stash_dialog (plugin);
+}
\ No newline at end of file
diff --git a/plugins/git/git-apply-stash-dialog.h b/plugins/git/git-apply-stash-dialog.h
new file mode 100644
index 0000000..eb0e281
--- /dev/null
+++ b/plugins/git/git-apply-stash-dialog.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2009 <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_APPLY_STASH_DIALOG_H
+#define _GIT_APPLY_STASH_DIALOG_H
+
+#include "git-stash-apply-command.h"
+#include "git-stash-widget.h"
+#include "git-ui-utils.h"
+
+void on_menu_git_apply_stash (GtkAction *action, Git *plugin);
+
+#endif
\ No newline at end of file
diff --git a/plugins/git/git-stash-widget.c b/plugins/git/git-stash-widget.c
index 0416248..a1aacbd 100644
--- a/plugins/git/git-stash-widget.c
+++ b/plugins/git/git-stash-widget.c
@@ -289,4 +289,16 @@ git_stash_widget_setup_refresh_monitor (Git *plugin)
g_object_unref (git_stash_file);
return git_stash_monitor;
+}
+
+GtkListStore *
+git_stash_widget_get_model (Git *plugin)
+{
+ GitUIData *data;
+ GtkListStore *stash_list_model;
+
+ data = g_object_get_data (G_OBJECT (plugin->stash_widget), "ui-data");
+ stash_list_model = GTK_LIST_STORE (gtk_builder_get_object (data->bxml,
+ "stash_list_model"));
+ return stash_list_model;
}
\ No newline at end of file
diff --git a/plugins/git/git-stash-widget.h b/plugins/git/git-stash-widget.h
index ce62860..61048bc 100644
--- a/plugins/git/git-stash-widget.h
+++ b/plugins/git/git-stash-widget.h
@@ -29,5 +29,6 @@ void git_stash_widget_create (Git *plugin, GtkWidget **stash_widget,
void git_stash_widget_refresh (Git *plugin);
void git_stash_widget_clear (Git *plugin);
GFileMonitor *git_stash_widget_setup_refresh_monitor (Git *plugin);
+GtkListStore *git_stash_widget_get_model (Git *plugin);
#endif
\ No newline at end of file
diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c
index 81e3eae..839535d 100644
--- a/plugins/git/git-ui-utils.c
+++ b/plugins/git/git-ui-utils.c
@@ -142,6 +142,42 @@ git_check_input (GtkWidget *parent, GtkWidget *widget, const gchar *input,
return ret;
}
+gboolean
+git_get_selected_stash (GtkTreeSelection *selection, gchar **stash)
+{
+ gboolean ret;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkWidget *stash_view;
+ GtkWidget *parent;
+ GtkWidget *dialog;
+
+ ret = FALSE;
+ *stash = NULL;
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ gtk_tree_model_get (model, &iter, 0, stash, -1);
+ ret = TRUE;
+ }
+ else
+ {
+ stash_view = GTK_WIDGET (gtk_tree_selection_get_tree_view (selection));
+ parent = gtk_widget_get_toplevel (stash_view);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s", _("Please select a stash"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+
+
+ return ret;
+}
+
gchar *
git_get_log_from_textview (GtkWidget* textview)
{
diff --git a/plugins/git/git-ui-utils.h b/plugins/git/git-ui-utils.h
index 67be4b6..5bf916f 100644
--- a/plugins/git/git-ui-utils.h
+++ b/plugins/git/git-ui-utils.h
@@ -55,6 +55,7 @@ void git_progress_data_free (GitProgressData *data);
void git_create_message_view (Git* plugin);
gboolean git_check_input (GtkWidget *parent, GtkWidget *widget,
const gchar *input, const gchar *error_message);
+gboolean git_get_selected_stash (GtkTreeSelection *selection, gchar **stash);
gchar *git_get_log_from_textview (GtkWidget* textview);
guint git_status_bar_progress_pulse (Git *plugin, gchar *text);
void git_clear_status_bar_progress_pulse (guint timer_id);
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index d51a99d..3950331 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -51,6 +51,7 @@
#include "git-delete-tag-dialog.h"
#include "git-stash-changes-dialog.h"
#include "git-stash-widget.h"
+#include "git-apply-stash-dialog.h"
#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.xml"
@@ -163,6 +164,14 @@ static GtkActionEntry actions_git[] =
G_CALLBACK (on_menu_git_stash_changes) /* action callback */
},
{
+ "ActionGitApplyStash", /* Action name */
+ NULL, /* Stock icon, if any */
+ N_("_Apply stashed changes..."), /* Display label */
+ NULL, /* short-cut */
+ N_("Apply stashed changes to the working tree"), /* Tooltip */
+ G_CALLBACK (on_menu_git_apply_stash) /* action callback */
+ },
+ {
"ActionGitAdd", /* Action name */
GTK_STOCK_ADD, /* Stock icon, if any */
N_("_Add..."), /* Display label */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]