git: Use AnjutaColumnTextView in the Merge pane
[anjuta.git] / plugins / git / git-reset-tree-command.c
blobe1cb5802f7583bc0b318902c0feed53c36951318
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
5 *
6 * anjuta is free software.
7 *
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-reset-tree-command.h"
27 struct _GitResetTreeCommandPriv
29 gchar *revision;
30 GitResetTreeMode mode;
33 G_DEFINE_TYPE (GitResetTreeCommand, git_reset_tree_command, GIT_TYPE_COMMAND);
35 static guint
36 git_reset_tree_command_run (AnjutaCommand *command)
38 GitResetTreeCommand *self;
40 self = GIT_RESET_TREE_COMMAND (command);
42 git_command_add_arg (GIT_COMMAND (command), "reset");
44 switch (self->priv->mode)
46 case GIT_RESET_TREE_MODE_MIXED:
47 git_command_add_arg (GIT_COMMAND (command), "--mixed");
48 break;
49 case GIT_RESET_TREE_MODE_SOFT:
50 git_command_add_arg (GIT_COMMAND (command), "--soft");
51 break;
52 case GIT_RESET_TREE_MODE_HARD:
53 git_command_add_arg (GIT_COMMAND (command), "--hard");
54 break;
55 default:
56 break;
59 git_command_add_arg (GIT_COMMAND (command), self->priv->revision);
61 return 0;
64 static void
65 git_reset_tree_command_init (GitResetTreeCommand *self)
67 self->priv = g_new0 (GitResetTreeCommandPriv, 1);
70 static void
71 git_reset_tree_command_finalize (GObject *object)
73 GitResetTreeCommand *self;
75 self = GIT_RESET_TREE_COMMAND (object);
77 g_free (self->priv->revision);
78 g_free (self->priv);
80 G_OBJECT_CLASS (git_reset_tree_command_parent_class)->finalize (object);
83 static void
84 git_reset_tree_command_class_init (GitResetTreeCommandClass *klass)
86 GObjectClass* object_class = G_OBJECT_CLASS (klass);
87 GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
88 AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
90 object_class->finalize = git_reset_tree_command_finalize;
91 parent_class->output_handler = git_command_send_output_to_info;
92 command_class->run = git_reset_tree_command_run;
96 GitResetTreeCommand *
97 git_reset_tree_command_new (const gchar *working_directory,
98 const gchar *revision, GitResetTreeMode mode)
100 GitResetTreeCommand *self;
102 self = g_object_new (GIT_TYPE_RESET_TREE_COMMAND,
103 "working-directory", working_directory,
104 "single-line-output", TRUE,
105 NULL);
107 self->priv->revision = g_strdup (revision);
108 self->priv->mode = mode;
110 return self;