/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
254.1.1 by Jelmer Vernooij
Add Merge Directive option to revision menu.
1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
try:
18
    import pygtk
19
    pygtk.require("2.0")
20
except:
21
    pass
22
23
import bzrlib
24
import gtk
25
324 by Jelmer Vernooij
Add very simple "Send Merge Directive" window.
26
from bzrlib.plugins.gtk.branchbox import BranchSelectionBox
27
254.1.1 by Jelmer Vernooij
Add Merge Directive option to revision menu.
28
class CreateMergeDirectiveDialog(gtk.Dialog):
29
    def __init__(self, branch, stop_revid=None):
30
        super(CreateMergeDirectiveDialog, self).__init__()
31
        self.branch = branch
32
        self.stop_revid = stop_revid
33
        self._create()
34
35
    def _create(self):
36
        # TODO: Create a frame with information about the revision that will be 
37
        # submittted
38
39
        # TODO: Create a frame with a the ability to select a branch
40
        
41
        # TODO: Create a frame with a button for selecting a file name 
42
        # for the bundle
43
        pass
44
45
46
class SendMergeDirectiveDialog(gtk.Dialog):
324 by Jelmer Vernooij
Add very simple "Send Merge Directive" window.
47
    def __init__(self, branch, parent=None):
48
        super(SendMergeDirectiveDialog, self).__init__(parent)
323 by Jelmer Vernooij
Add gsend command.
49
        self.branch = branch
324 by Jelmer Vernooij
Add very simple "Send Merge Directive" window.
50
        self.set_title("Send Merge Directive")
323 by Jelmer Vernooij
Add gsend command.
51
        self._create()
52
53
    def _create(self):
324 by Jelmer Vernooij
Add very simple "Send Merge Directive" window.
54
        table = gtk.Table(rows=3, columns=2)
55
        self.vbox.add(table)
56
57
        label = gtk.Label()
58
        label.set_markup("<b>Branch to Submit:</b>")
59
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
60
61
        label = gtk.Label(str(self.branch))
62
        table.attach(label, 1, 2, 0, 1, gtk.FILL, gtk.FILL)
63
64
        label = gtk.Label()
65
        label.set_markup("<b>Target Branch:</b>")
66
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
67
68
        self.submit_branch = BranchSelectionBox(self.branch.get_submit_branch())
69
        table.attach(self.submit_branch, 1, 2, 1, 2, gtk.FILL, gtk.FILL)
70
71
        # TODO: Display number of revisions to be send whenever 
72
        # submit branch changes
73
74
        label = gtk.Label()
75
        label.set_markup("<b>Email To:</b>")
76
        table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
77
78
        self.mail_to = gtk.ComboBoxEntry()
79
        mail_to = self.branch.get_config().get_user_option('submit_to')
449.1.2 by Jelmer Vernooij
Honor child_submit_to in the submit_branch if no email address was specified.
80
        if mail_to is None:
81
            submit_branch = self.submit_branch.get_branch()
82
            if submit_branch is not None:
83
                mail_to = submit_branch.get_config().get_user_option(
84
                            'child_submit_to')
324 by Jelmer Vernooij
Add very simple "Send Merge Directive" window.
85
        if mail_to is not None:
86
            self.mail_to.get_child().set_text(mail_to)
87
        table.attach(self.mail_to, 1, 2, 2, 3, gtk.FILL, gtk.FILL)
88
89
        self.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, 
90
                         gtk.STOCK_OK, gtk.RESPONSE_OK)
91
92
        self.show_all()
93
94
    def get_mail_to(self):
95
        return self.mail_to.get_child().get_text()
96
97
    def get_merge_directive(self):
98
        from bzrlib.merge_directive import MergeDirective2
99
        from bzrlib import osutils
100
        import time
101
        return MergeDirective2.from_objects(self.branch.repository,
102
                                            self.branch.last_revision(),
103
                                            time.time(),
104
                                            osutils.local_time_offset(),
105
                                            self.submit_branch.get_url(),
106
                                            public_branch=None,
107
                                            include_patch=True,
108
                                            include_bundle=True,
109
                                            message=None,
110
                                            base_revision_id=None)
111
254.1.1 by Jelmer Vernooij
Add Merge Directive option to revision menu.
112
113
114
class ApplyMergeDirectiveDialog(gtk.Dialog):
115
    def __init__(self):
116
        super(ApplyMergeDirectiveDialog, self).__init__()