~debian-bazaar/+junk/anjuta-bzr-debian

« back to all changes in this revision

Viewing changes to src/bzr-bind-cmd.c

  • Committer: Jelmer Vernooij
  • Date: 2008-11-10 19:13:03 UTC
  • mfrom: (60.1.117 trunk)
  • Revision ID: jelmer@samba.org-20081110191303-gh3te5q0bq9owqbm
Merge new upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 
2
/*
 
3
 * Anjuta
 
4
 * Copyright (C) William Fagan 2008 
 
5
 *
 
6
 * Portions based on the Subversion plugin
 
7
 * Copyright (C) James Liggett 2007
 
8
 * Copyright (C) Johannes Schmid 2005
 
9
 *
 
10
 * Anjuta is free software.
 
11
 * 
 
12
 * You may redistribute it and/or modify it under the terms of the
 
13
 * GNU General Public License, as published by the Free Software
 
14
 * Foundation; either version 2 of the License, or (at your option)
 
15
 * any later version.
 
16
 * 
 
17
 * Anjuta is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
20
 * See the GNU General Public License for more details.
 
21
 * 
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with Anjuta.  If not, write to:
 
24
 *      The Free Software Foundation, Inc.,
 
25
 *      51 Franklin Street, Fifth Floor
 
26
 *      Boston, MA  02110-1301, USA.
 
27
 */
 
28
 
 
29
 
 
30
#include "bzr-bind-cmd.h"
 
31
#include "bazaar-tools-etc.h"
 
32
 
 
33
struct _BzrBindCmdPriv
 
34
{
 
35
        gchar *branch;
 
36
};
 
37
 
 
38
G_DEFINE_TYPE (BzrBindCmd, bzr_bind_cmd, BZR_TYPE_CMD);
 
39
 
 
40
static void
 
41
bzr_bind_cmd_init (BzrBindCmd *self)
 
42
{
 
43
        self->priv = g_new0 (BzrBindCmdPriv, 1);
 
44
}
 
45
 
 
46
BzrBindCmd*
 
47
bzr_bind_cmd_new (const gchar *working_dir, const gchar *branch)
 
48
{
 
49
        BzrBindCmd *self = 0;
 
50
        
 
51
        self = g_object_new (BZR_TYPE_BIND_CMD, "working-directory", working_dir, NULL);
 
52
        
 
53
        self->priv->branch = g_strdup (branch);
 
54
        
 
55
        return self;
 
56
}
 
57
 
 
58
static void
 
59
bzr_bind_cmd_finalize (GObject *object)
 
60
{
 
61
        BzrBindCmd *command = NULL;
 
62
        
 
63
        command = BZR_BIND_CMD (object);
 
64
        
 
65
        g_free (command->priv->branch);
 
66
        g_free (command->priv);
 
67
 
 
68
        G_OBJECT_CLASS (bzr_bind_cmd_parent_class)->finalize (object);
 
69
}
 
70
 
 
71
static guint
 
72
bzr_bind_cmd_run (AnjutaCommand *command)
 
73
{
 
74
        BzrBindCmd *self = NULL;
 
75
        
 
76
        self = BZR_BIND_CMD (command);
 
77
        
 
78
        bzr_cmd_add_arg (BZR_CMD (self), "bind");
 
79
 
 
80
        bzr_cmd_add_arg (BZR_CMD (self), self->priv->branch);
 
81
        
 
82
        return 0;
 
83
}
 
84
 
 
85
static void
 
86
bzr_bind_cmd_class_init (BzrBindCmdClass *klass)
 
87
{
 
88
        GObjectClass *object_class = NULL;
 
89
        AnjutaCommandClass *command_class = NULL;
 
90
        
 
91
        object_class = G_OBJECT_CLASS (klass);
 
92
        command_class = ANJUTA_COMMAND_CLASS (klass);
 
93
 
 
94
        object_class->finalize = bzr_bind_cmd_finalize;
 
95
        command_class->run = bzr_bind_cmd_run;
 
96
}
 
97
 
 
98
void
 
99
bzr_bind_cmd_destroy (BzrBindCmd *self)
 
100
{
 
101
        g_object_unref (self);
 
102
}
 
103
 
 
104
void
 
105
bzr_bind_cmd_finished (AnjutaCommand *command, guint return_code, 
 
106
                                  gpointer user_data)
 
107
{
 
108
        g_object_unref (command);
 
109
}
 
110
 
 
111
void bzr_bind_cmd_execute (const gchar *working_dir, const gchar *branch)
 
112
{
 
113
        BzrBindCmd *cmd = NULL;
 
114
        
 
115
        cmd = bzr_bind_cmd_new (working_dir, branch);
 
116
                                           
 
117
        g_signal_connect (G_OBJECT (cmd), "command-finished",
 
118
                                          G_CALLBACK (bzr_bind_cmd_finished), NULL);
 
119
 
 
120
        anjuta_command_start (ANJUTA_COMMAND (cmd));                                       
 
121
}