glade: Fix make file some files were not installed
[anjuta.git] / plugins / git / git-stash-save-command.c
blobbb9bbe6f8f856fb1c28df48c30794c6e36b6473d
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2009 <jrliggett@cox.net>
5 *
6 * anjuta is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * anjuta is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "git-stash-save-command.h"
22 struct _GitStashSaveCommandPriv
24 gboolean keep_index;
25 gchar *message;
28 G_DEFINE_TYPE (GitStashSaveCommand, git_stash_save_command, GIT_TYPE_COMMAND);
30 static void
31 git_stash_save_command_init (GitStashSaveCommand *self)
33 self->priv = g_new0 (GitStashSaveCommandPriv, 1);
36 static void
37 git_stash_save_command_finalize (GObject *object)
39 GitStashSaveCommand *self;
41 self = GIT_STASH_SAVE_COMMAND (object);
43 g_free (self->priv->message);
44 g_free (self->priv);
46 G_OBJECT_CLASS (git_stash_save_command_parent_class)->finalize (object);
49 static guint
50 git_stash_save_command_run (AnjutaCommand *command)
52 GitStashSaveCommand *self;
54 self = GIT_STASH_SAVE_COMMAND (command);
56 git_command_add_arg (GIT_COMMAND (command), "stash");
57 git_command_add_arg (GIT_COMMAND (command), "save");
59 if (self->priv->keep_index)
60 git_command_add_arg (GIT_COMMAND (command), "--keep-index");
62 if (self->priv->message)
63 git_command_add_arg (GIT_COMMAND (command), self->priv->message);
65 return 0;
68 static void
69 git_stash_save_command_class_init (GitStashSaveCommandClass *klass)
71 GObjectClass* object_class = G_OBJECT_CLASS (klass);
72 GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
73 AnjutaCommandClass *command_class = ANJUTA_COMMAND_CLASS (klass);
75 object_class->finalize = git_stash_save_command_finalize;
76 parent_class->output_handler = git_command_send_output_to_info;
77 command_class->run = git_stash_save_command_run;
81 GitStashSaveCommand *
82 git_stash_save_command_new (const gchar *working_directory,
83 gboolean keep_index, const gchar *message)
85 GitStashSaveCommand *self;
87 self = g_object_new (GIT_TYPE_STASH_SAVE_COMMAND,
88 "working-directory", working_directory,
89 "single-line-output", TRUE,
90 NULL);
92 self->priv->keep_index = keep_index;
93 self->priv->message = g_strdup (message);
95 return self;