static gboolean
git_stash_list_command_start_automatic_monitor (AnjutaCommand *command)
{
	GitStashListCommand *self;
	gchar *working_directory;
	gchar *git_stash_path;
	GFile *git_stash_file;

	self = GIT_STASH_LIST_COMMAND (command);

	g_object_get (G_OBJECT (self), "working-directory", &working_directory,
	              NULL);

	git_stash_path = g_strjoin (G_DIR_SEPARATOR_S,
	                            working_directory,
	                            ".git",
	                            "refs",
	                            "stash",
	                            NULL);

	git_stash_file = g_file_new_for_path (git_stash_path);

	self->priv->file_monitor = g_file_monitor_file (git_stash_file, 0, NULL, 
	                                                NULL);

	g_signal_connect (G_OBJECT (self->priv->file_monitor), "changed",
	                  G_CALLBACK (on_file_monitor_changed),
	                  command);

	g_free (working_directory);
	g_free (git_stash_path);
	g_object_unref (git_stash_file);

	return TRUE;
}
Exemple #2
0
static void
on_stash_list_command_data_arrived (AnjutaCommand *command, 
                                    GtkListStore *stash_list_model)
{
	GQueue *output;
	GtkTreeIter iter;
	GitStash *stash;
	guint number;
	gchar *message;
	gchar *id;
	
	output = git_stash_list_command_get_output (GIT_STASH_LIST_COMMAND (command));

	while (g_queue_peek_head (output))
	{
		gtk_list_store_append (stash_list_model, &iter);

		stash = g_queue_pop_head (output);
		number = git_stash_get_number (stash);
		message = git_stash_get_message (stash);
		id = git_stash_get_id (stash);

		gtk_list_store_set (stash_list_model, &iter, 
		                    COL_NUMBER, number,
		                    COL_MESSAGE, message,
		                    COL_ID, id,
		                    -1);

		g_object_unref (stash);
		g_free (message);
		g_free (id);
	}
}
Exemple #3
0
static void
on_stash_list_command_data_arrived (AnjutaCommand *command, 
                                    GtkTreeStore *stash_model)
{
	GQueue *output;
	GtkTreeIter iter;
	GitStash *stash;
	guint number;
	gchar *message;
	gchar *id;
	gchar *working_directory;
	GitStashShowCommand *show_command;
	
	output = git_stash_list_command_get_output (GIT_STASH_LIST_COMMAND (command));

	while (g_queue_peek_head (output))
	{
		stash = g_queue_pop_head (output);
		number = git_stash_get_number (stash);
		message = git_stash_get_message (stash);
		id = git_stash_get_id (stash);


		gtk_tree_store_append (stash_model, &iter, NULL);
		gtk_tree_store_set (stash_model, &iter, 
		                    COL_NUMBER, number,
		                    COL_MESSAGE, message,
		                    COL_ID, id,
		                    -1);

		g_object_get (G_OBJECT (command), "working-directory", 
		              &working_directory, NULL);
		show_command = git_stash_show_command_new (working_directory, id);

		g_free (working_directory);

		g_object_set_data_full (G_OBJECT (show_command), "parent-path", 
		               			gtk_tree_model_get_path (GTK_TREE_MODEL (stash_model),
		                                        		 &iter),
		               			(GDestroyNotify) gtk_tree_path_free);

		g_signal_connect (G_OBJECT (show_command), "command-finished",
		                  G_CALLBACK (on_stash_diff_command_finished),
		                  stash_model);

		g_signal_connect (G_OBJECT (show_command), "command-finished",
		                  G_CALLBACK (g_object_unref),
		                  NULL);

		anjuta_command_start (ANJUTA_COMMAND (show_command));

		g_object_unref (stash);
		g_free (message);
		g_free (id);
	}
}
static guint
git_stash_list_command_run (AnjutaCommand *command)
{
	GitStashListCommand *self;
	
	self = GIT_STASH_LIST_COMMAND (command);
	
	git_command_add_arg (GIT_COMMAND (command), "stash");
	git_command_add_arg (GIT_COMMAND (command), "list");
	return 0;
}
static void
git_stash_list_command_stop_automatic_monitor (AnjutaCommand *command)
{
	GitStashListCommand *self;

	self = GIT_STASH_LIST_COMMAND (command);

	if (self->priv->file_monitor)
	{
		g_file_monitor_cancel (self->priv->file_monitor);
		g_object_unref (self->priv->file_monitor);
		self->priv->file_monitor = NULL;
	}
}
static void
git_stash_list_command_finalize (GObject *object)
{
	GitStashListCommand *self;
	GList *current_stash;
	
	self = GIT_STASH_LIST_COMMAND (object);
	current_stash = self->priv->output->head;
	
	g_regex_unref (self->priv->stash_regex);
	
	while (current_stash)
	{
		g_object_unref (current_stash->data);
		current_stash = g_list_next (current_stash);
	}
	
	g_queue_free (self->priv->output);
	anjuta_command_stop_automatic_monitor (ANJUTA_COMMAND (object));
	g_free (self->priv);

	G_OBJECT_CLASS (git_stash_list_command_parent_class)->finalize (object);
}
static void
git_stash_list_command_handle_output (GitCommand *git_command, 
									  const gchar *output)
{
	GitStashListCommand *self;
	GMatchInfo *match_info;
	gchar *stash_id;
	gchar *stash_number;
	gchar *stash_message;
	GitStash *stash;

	self = GIT_STASH_LIST_COMMAND (git_command);
	
	match_info = NULL;
	stash_id = NULL;
	stash_message = NULL;
	stash = NULL;
	
	if (g_regex_match (self->priv->stash_regex, output, 0, &match_info))
	{
		stash_id = g_match_info_fetch (match_info, 1);
		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);
}