Merge lp:~sinzui/bzr-gtk/per-file-commit into lp:bzr-gtk

Proposed by Curtis Hovey on 2012-03-22
Status: Merged
Merged at revision: 789
Proposed branch: lp:~sinzui/bzr-gtk/per-file-commit
Merge into: lp:bzr-gtk
Diff against target: 59 lines (+16/-2)
2 files modified
commit.py (+9/-2)
tests/test_commit.py (+7/-0)
To merge this branch: bzr merge lp:~sinzui/bzr-gtk/per-file-commit
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) 2012-03-22 Approve on 2012-03-22
Review via email: mp+98882@code.launchpad.net

Commit message

Ensure that the per/file message widget fits at least one line.

Description of the change

When I do bzr gcommit, a window is shown in which I can enter the per
file commit messages. But this per file commit window is too small. And
I am unable to make it big (and usable)

--------------------------------------------------------------------

RULES

    * This is a Gtk3 issue where the rules of expand and fill changed.
      The TextView was allocated 1 pixel which is not enough to see the
      text of the line.
    * This issue was partially addressed in a previously when the expand
      and fill rules were adjusted to solve other layout issues; the message
      has space for one line in trunk on precise at this movement.
    * There is no way to guarantee that space is allocated, but the widget
      could request the height of two lines when Gtk is allocating space.

    * ADDENDUM
      ./setup.py check -m commit had errors because DiffView could not
      be imported. I moved the inline import to a global import. If this
      should not happen, test_commit.py could import DiffView to ensure
      it is available for all the tests.

QA

    * Add
      per_file_commits = on
      to your bazaar or locations conf file.
    * Issue this command with this merged branch
      BZR_PLUGINS_AT=gtk@./ bzr gci
    * Select commit.py from the listed files.
    * Verify that "Commit message for commit.py" is expanded
      and that there is about 2 lines of space. (works for me)

To post a comment you must log in.
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'commit.py'
2--- commit.py 2012-02-29 14:04:24 +0000
3+++ commit.py 2012-03-22 17:18:21 +0000
4@@ -30,6 +30,7 @@
5 tsort,
6 )
7 from bzrlib.plugins.gtk.dialog import question_dialog
8+from bzrlib.plugins.gtk.diff import DiffView
9 from bzrlib.plugins.gtk.errors import show_bzr_error
10 from bzrlib.plugins.gtk.i18n import _i18n
11 from bzrlib.plugins.gtk.commitmsgs import SavedCommitMessagesManager
12@@ -559,8 +560,6 @@
13 Gtk.CellRendererText(), text=3))
14
15 def _construct_diff_view(self):
16- from bzrlib.plugins.gtk.diff import DiffView
17-
18 # TODO: jam 2007-10-30 The diff label is currently disabled. If we
19 # decide that we really don't ever want to display it, we should
20 # actually remove it, and other references to it, along with the
21@@ -575,6 +574,12 @@
22 self._add_to_right_table(self._diff_view, 4, True)
23 self._diff_view.show()
24
25+ @staticmethod
26+ def get_line_height(widget):
27+ pango_layout = widget.create_pango_layout("X");
28+ ink_rectangle, logical_rectangle = pango_layout.get_pixel_extents()
29+ return logical_rectangle.height
30+
31 def _construct_file_message(self):
32 scroller = Gtk.ScrolledWindow()
33 scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
34@@ -587,6 +592,8 @@
35 self._file_message_text_view.modify_font(Pango.FontDescription("Monospace"))
36 self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD)
37 self._file_message_text_view.set_accepts_tab(False)
38+ line_height = self.get_line_height(self._file_message_text_view)
39+ self._file_message_text_view.set_size_request(-1, line_height * 2)
40 self._file_message_text_view.show()
41
42 self._file_message_expander = Gtk.Expander(
43
44=== modified file 'tests/test_commit.py'
45--- tests/test_commit.py 2012-02-17 15:03:17 +0000
46+++ tests/test_commit.py 2012-03-22 17:18:21 +0000
47@@ -235,6 +235,13 @@
48 dlg._on_treeview_files_cursor_changed(treeview)
49 self.assertFalse(CommitDialogNoWidgets._update_per_file_info.called)
50
51+ def test_get_line_height(self):
52+ tree = self.make_branch_and_tree('tree')
53+ dlg = CommitDialogNoWidgets(tree)
54+ textview = Gtk.TextView()
55+ line_height = dlg.get_line_height(textview)
56+ self.assertIsInstance(line_height, int)
57+
58
59 class TestCommitDialog(tests.TestCaseWithTransport):
60

Subscribers

People subscribed via source and target branches

to all changes: