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

« back to all changes in this revision

Viewing changes to src/bzr-removed-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:
27
27
 */
28
28
 
29
29
 
30
 
#include "bazaar-list-command-removed.h"
 
30
#include "bzr-removed-cmd.h"
31
31
 
32
 
struct _BazaarListRemovedCommandPriv
 
32
struct _BzrRemovedCmdPriv
33
33
{
 
34
        GFunc user_func;
 
35
        gpointer user_data;
34
36
};
35
37
 
36
 
G_DEFINE_TYPE (BazaarListRemovedCommand, bazaar_list_removed_command, BAZAAR_TYPE_LIST_COMMAND);
 
38
G_DEFINE_TYPE (BzrRemovedCmd, bzr_removed_cmd, BZR_TYPE_CMD);
37
39
 
38
40
static void
39
 
bazaar_list_removed_command_init (BazaarListRemovedCommand *self)
 
41
bzr_removed_cmd_init (BzrRemovedCmd *self)
40
42
{
41
 
        self->priv = g_new0 (BazaarListRemovedCommandPriv, 1);
 
43
        self->priv = g_new0 (BzrRemovedCmdPriv, 1);
42
44
}
43
45
 
44
 
BazaarListRemovedCommand*
45
 
bazaar_list_removed_command_new (const gchar *working_dir)
 
46
BzrRemovedCmd*
 
47
bzr_removed_cmd_new (const gchar *working_dir, GFunc user_func, gpointer user_data)
46
48
{
47
 
        BazaarListRemovedCommand *command;
 
49
        BzrRemovedCmd *command;
48
50
        
49
 
        command = g_object_new (BAZAAR_TYPE_LIST_REMOVED_COMMAND, 
 
51
        command = g_object_new (BZR_TYPE_REMOVED_CMD, 
50
52
                                                        "working-directory", working_dir, 
51
53
                                                        "single-line-output", TRUE,
52
54
                                                        NULL);  
 
55
                                                        
 
56
        command->priv->user_func = user_func;
 
57
        command->priv->user_data = user_data;
53
58
        
54
59
        return command;
55
60
}
56
61
 
57
62
static void
58
 
bazaar_list_removed_command_finalize (GObject *object)
 
63
bzr_removed_cmd_finalize (GObject *object)
59
64
{
60
 
        BazaarListRemovedCommand *command = NULL;
 
65
        BzrRemovedCmd *command = NULL;
61
66
        
62
 
        command = BAZAAR_LIST_REMOVED_COMMAND (object);
 
67
        command = BZR_REMOVED_CMD (object);
63
68
        
64
69
        g_free (command->priv);
65
70
 
66
 
        G_OBJECT_CLASS (bazaar_list_removed_command_parent_class)->finalize (object);
 
71
        G_OBJECT_CLASS (bzr_removed_cmd_parent_class)->finalize (object);
67
72
}
68
73
 
69
74
static guint
70
 
bazaar_list_removed_command_run (AnjutaCommand *command)
 
75
bzr_removed_cmd_run (AnjutaCommand *command)
71
76
{
72
 
        BazaarListRemovedCommand *self = NULL;
 
77
        BzrRemovedCmd *self = NULL;
73
78
        
74
 
        self = BAZAAR_LIST_REMOVED_COMMAND (command);   
 
79
        self = BZR_REMOVED_CMD (command);       
75
80
 
76
 
        bazaar_command_add_arg (BAZAAR_COMMAND (self), "status");
77
 
        bazaar_command_add_arg (BAZAAR_COMMAND (self), "-S");
78
 
        bazaar_command_add_arg (BAZAAR_COMMAND (self), "|");
79
 
        bazaar_command_add_arg (BAZAAR_COMMAND (self), "awk");
80
 
        bazaar_command_add_arg (BAZAAR_COMMAND (self), "'/^-D/ {print $2}'");
 
81
        bzr_cmd_add_arg (BZR_CMD (self), "status");
 
82
        bzr_cmd_add_arg (BZR_CMD (self), "-S");
 
83
        bzr_cmd_add_arg (BZR_CMD (self), "|");
 
84
        bzr_cmd_add_arg (BZR_CMD (self), "awk");
 
85
        bzr_cmd_add_arg (BZR_CMD (self), "'/^-D/ {print $2}'");
81
86
        
82
87
        return 0;
83
88
}
84
89
 
 
90
void removed_output_handler (BzrCmd *cmd, const gchar *filename)
 
91
{       
 
92
        if (strcmp (filename, "") != 0)
 
93
        {
 
94
                BZR_REMOVED_CMD (cmd)->priv->user_func (filename, BZR_REMOVED_CMD (cmd)->priv->user_data);      
 
95
        }
 
96
}
 
97
 
85
98
static void
86
 
bazaar_list_removed_command_class_init (BazaarListRemovedCommandClass *klass)
 
99
bzr_removed_cmd_class_init (BzrRemovedCmdClass *klass)
87
100
{
88
101
        GObjectClass *object_class = NULL;
 
102
        BzrCmdClass *parent_class = NULL;
89
103
        AnjutaCommandClass *command_class = NULL;
90
104
        
91
105
        object_class = G_OBJECT_CLASS (klass);
 
106
        parent_class = BZR_CMD_CLASS (klass);
92
107
        command_class = ANJUTA_COMMAND_CLASS (klass);
93
108
 
94
 
        object_class->finalize = bazaar_list_removed_command_finalize;
95
 
        command_class->run = bazaar_list_removed_command_run;
 
109
        object_class->finalize = bzr_removed_cmd_finalize;
 
110
        command_class->run = bzr_removed_cmd_run;
 
111
        parent_class->output_handler = removed_output_handler;
96
112
}
97
113
 
98
114
void
99
 
bazaar_list_removed_command_destroy (BazaarListRemovedCommand *self)
 
115
bzr_removed_cmd_destroy (BzrRemovedCmd *self)
100
116
{
101
117
        g_object_unref (self);
102
118
}
103
119
 
104
 
 
105
 
 
 
120
void
 
121
bzr_removed_cmd_finished (AnjutaCommand *command, guint return_code, 
 
122
                            gpointer user_data)
 
123
{
 
124
        g_object_unref (command);
 
125
}
 
126
 
 
127
void bzr_removed_cmd_execute (const gchar *working_dir, GFunc user_func, gpointer user_data)
 
128
{
 
129
        BzrRemovedCmd *cmd = NULL;
 
130
        
 
131
        cmd = bzr_removed_cmd_new (working_dir, user_func, user_data);
 
132
                                           
 
133
        g_signal_connect (G_OBJECT (cmd), "command-finished",
 
134
                                          G_CALLBACK (bzr_removed_cmd_finished), NULL);
 
135
        
 
136
        anjuta_command_start (ANJUTA_COMMAND (cmd));
 
137
}