[anjuta] git: Extract the stash number from the stash ID
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] git: Extract the stash number from the stash ID
- Date: Fri, 24 Jul 2009 01:49:38 +0000 (UTC)
commit d326faf04d854b3de71b36908858383f9fcb5082
Author: James Liggett <jrliggett cox net>
Date: Thu Jul 23 16:49:20 2009 -0700
git: Extract the stash number from the stash ID
Put this number in the stash widget model and use it in the editor name for stash diffs.
plugins/git/anjuta-git.ui | 13 +++++++++++++
plugins/git/git-stash-list-command.c | 26 +++++++++++++-------------
plugins/git/git-stash-widget.c | 9 ++++++---
plugins/git/git-stash.c | 10 +++++++++-
plugins/git/git-stash.h | 3 ++-
plugins/git/git-ui-utils.c | 5 ++++-
6 files changed, 47 insertions(+), 19 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index dab4f33..a094205 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -41,6 +41,8 @@
<column type="gchararray"/>
<!-- column-name message -->
<column type="gchararray"/>
+ <!-- column-name number -->
+ <column type="guint"/>
</columns>
</object>
<object class="GtkDialog" id="commit_dialog">
@@ -5249,6 +5251,17 @@
<property name="model">stash_list_model</property>
<property name="headers_visible">False</property>
<child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn11">
+ <property name="title">column</property>
+ <child>
+ <object class="GtkCellRendererText" id="stash_widget_view_number_renderer"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkTreeViewColumn" id="treeviewcolumn9">
<property name="title">column</property>
<child>
diff --git a/plugins/git/git-stash-list-command.c b/plugins/git/git-stash-list-command.c
index 2169192..6e81a1f 100644
--- a/plugins/git/git-stash-list-command.c
+++ b/plugins/git/git-stash-list-command.c
@@ -25,7 +25,7 @@
#include "git-stash-list-command.h"
/* Splits the stash ID from the stash message */
-#define STASH_REGEX "(stash \\{\\d+\\})(?:\\:) (.*)"
+#define STASH_REGEX "(stash \\{(\\d+)\\})(?:\\:) (.*)"
struct _GitStashListCommandPriv
{
@@ -86,6 +86,7 @@ git_stash_list_command_handle_output (GitCommand *git_command,
GitStashListCommand *self;
GMatchInfo *match_info;
gchar *stash_id;
+ gchar *stash_number;
gchar *stash_message;
GitStash *stash;
@@ -99,22 +100,21 @@ git_stash_list_command_handle_output (GitCommand *git_command,
if (g_regex_match (self->priv->stash_regex, output, 0, &match_info))
{
stash_id = g_match_info_fetch (match_info, 1);
- stash_message = g_match_info_fetch (match_info, 2);
- }
-
- if (stash_id && stash_message)
- stash = git_stash_new (stash_id, stash_message);
-
- g_free (stash_id);
- g_free (stash_message);
+ stash_number = g_match_info_fetch (match_info, 2);
+ stash_message = g_match_info_fetch (match_info, 3);
+
+ stash = git_stash_new (stash_id, stash_message, atoi (stash_number));
+ g_free (stash_id);
+ g_free (stash_number);
+ g_free (stash_message);
+
+ g_queue_push_head (self->priv->output, stash);
+ anjuta_command_notify_data_arrived (ANJUTA_COMMAND (git_command));
+ }
if (match_info)
g_match_info_free (match_info);
-
- g_queue_push_head (self->priv->output, stash);
- anjuta_command_notify_data_arrived (ANJUTA_COMMAND (git_command));
-
}
static void
diff --git a/plugins/git/git-stash-widget.c b/plugins/git/git-stash-widget.c
index 02c286a..7a7b335 100644
--- a/plugins/git/git-stash-widget.c
+++ b/plugins/git/git-stash-widget.c
@@ -147,6 +147,7 @@ on_stash_widget_show_button_clicked (GtkButton *button, GitUIData *data)
GtkTreeSelection *selection;
GtkTreeIter iter;
gchar *stash;
+ guint stash_number;
gchar *editor_name;
IAnjutaDocumentManager *document_manager;
IAnjutaEditor *editor;
@@ -160,13 +161,15 @@ on_stash_widget_show_button_clicked (GtkButton *button, GitUIData *data)
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
{
- gtk_tree_model_get (GTK_TREE_MODEL (stash_list_model), &iter, 0,
- &stash, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (stash_list_model), &iter,
+ 0, &stash,
+ 2, &stash_number,
+ -1);
show_command = git_stash_show_command_new (data->plugin->project_root_directory,
stash);
- editor_name = g_strdup_printf ("%s.diff", stash);
+ editor_name = g_strdup_printf ("Stash %i.diff", stash_number);
document_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (data->plugin)->shell,
IAnjutaDocumentManager,
diff --git a/plugins/git/git-stash.c b/plugins/git/git-stash.c
index 0ced049..c66d9fd 100644
--- a/plugins/git/git-stash.c
+++ b/plugins/git/git-stash.c
@@ -28,6 +28,7 @@ struct _GitStashPriv
{
gchar *id;
gchar *message;
+ guint number;
};
G_DEFINE_TYPE (GitStash, git_stash, G_TYPE_OBJECT);
@@ -61,7 +62,7 @@ git_stash_class_init (GitStashClass *klass)
}
GitStash *
-git_stash_new (const gchar *id, const gchar *message)
+git_stash_new (const gchar *id, const gchar *message, guint number)
{
GitStash *self;
@@ -69,6 +70,7 @@ git_stash_new (const gchar *id, const gchar *message)
self->priv->id = g_strdup (id);
self->priv->message = g_strdup (message);
+ self->priv->number = number;
return self;
}
@@ -84,3 +86,9 @@ git_stash_get_message (GitStash *self)
{
return g_strdup (self->priv->message);
}
+
+guint
+git_stash_get_number (GitStash *self)
+{
+ return self->priv->number;
+}
\ No newline at end of file
diff --git a/plugins/git/git-stash.h b/plugins/git/git-stash.h
index e10c089..66b8cc3 100644
--- a/plugins/git/git-stash.h
+++ b/plugins/git/git-stash.h
@@ -53,9 +53,10 @@ struct _GitStash
};
GType git_stash_get_type (void) G_GNUC_CONST;
-GitStash *git_stash_new (const gchar *id, const gchar *message);
+GitStash *git_stash_new (const gchar *id, const gchar *message, guint number);
gchar *git_stash_get_id (GitStash *self);
gchar *git_stash_get_message (GitStash *self);
+guint git_stash_get_number (GitStash *self);
G_END_DECLS
diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c
index 839535d..3cb0aab 100644
--- a/plugins/git/git-ui-utils.c
+++ b/plugins/git/git-ui-utils.c
@@ -474,6 +474,7 @@ on_git_list_stash_command_data_arrived (AnjutaCommand *command,
GtkTreeIter iter;
gchar *id;
gchar *message;
+ guint number;
output_queue = git_stash_list_command_get_output (GIT_STASH_LIST_COMMAND (command));
@@ -482,11 +483,13 @@ on_git_list_stash_command_data_arrived (AnjutaCommand *command,
stash = g_queue_pop_head (output_queue);
id = git_stash_get_id (stash);
message = git_stash_get_message (stash);
+ number = git_stash_get_number (stash);
gtk_list_store_append (stash_list_model, &iter);
gtk_list_store_set (stash_list_model, &iter,
0, id,
- 1, message,
+ 1, message,
+ 2, number,
-1);
g_object_unref (stash);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]