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

Proposed by Curtis Hovey
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) Approve
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.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'commit.py'
--- commit.py 2012-02-29 14:04:24 +0000
+++ commit.py 2012-03-22 17:18:21 +0000
@@ -30,6 +30,7 @@
30 tsort,30 tsort,
31 )31 )
32from bzrlib.plugins.gtk.dialog import question_dialog32from bzrlib.plugins.gtk.dialog import question_dialog
33from bzrlib.plugins.gtk.diff import DiffView
33from bzrlib.plugins.gtk.errors import show_bzr_error34from bzrlib.plugins.gtk.errors import show_bzr_error
34from bzrlib.plugins.gtk.i18n import _i18n35from bzrlib.plugins.gtk.i18n import _i18n
35from bzrlib.plugins.gtk.commitmsgs import SavedCommitMessagesManager36from bzrlib.plugins.gtk.commitmsgs import SavedCommitMessagesManager
@@ -559,8 +560,6 @@
559 Gtk.CellRendererText(), text=3))560 Gtk.CellRendererText(), text=3))
560561
561 def _construct_diff_view(self):562 def _construct_diff_view(self):
562 from bzrlib.plugins.gtk.diff import DiffView
563
564 # TODO: jam 2007-10-30 The diff label is currently disabled. If we563 # TODO: jam 2007-10-30 The diff label is currently disabled. If we
565 # decide that we really don't ever want to display it, we should564 # decide that we really don't ever want to display it, we should
566 # actually remove it, and other references to it, along with the565 # actually remove it, and other references to it, along with the
@@ -575,6 +574,12 @@
575 self._add_to_right_table(self._diff_view, 4, True)574 self._add_to_right_table(self._diff_view, 4, True)
576 self._diff_view.show()575 self._diff_view.show()
577576
577 @staticmethod
578 def get_line_height(widget):
579 pango_layout = widget.create_pango_layout("X");
580 ink_rectangle, logical_rectangle = pango_layout.get_pixel_extents()
581 return logical_rectangle.height
582
578 def _construct_file_message(self):583 def _construct_file_message(self):
579 scroller = Gtk.ScrolledWindow()584 scroller = Gtk.ScrolledWindow()
580 scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)585 scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
@@ -587,6 +592,8 @@
587 self._file_message_text_view.modify_font(Pango.FontDescription("Monospace"))592 self._file_message_text_view.modify_font(Pango.FontDescription("Monospace"))
588 self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD)593 self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD)
589 self._file_message_text_view.set_accepts_tab(False)594 self._file_message_text_view.set_accepts_tab(False)
595 line_height = self.get_line_height(self._file_message_text_view)
596 self._file_message_text_view.set_size_request(-1, line_height * 2)
590 self._file_message_text_view.show()597 self._file_message_text_view.show()
591598
592 self._file_message_expander = Gtk.Expander(599 self._file_message_expander = Gtk.Expander(
593600
=== modified file 'tests/test_commit.py'
--- tests/test_commit.py 2012-02-17 15:03:17 +0000
+++ tests/test_commit.py 2012-03-22 17:18:21 +0000
@@ -235,6 +235,13 @@
235 dlg._on_treeview_files_cursor_changed(treeview)235 dlg._on_treeview_files_cursor_changed(treeview)
236 self.assertFalse(CommitDialogNoWidgets._update_per_file_info.called)236 self.assertFalse(CommitDialogNoWidgets._update_per_file_info.called)
237237
238 def test_get_line_height(self):
239 tree = self.make_branch_and_tree('tree')
240 dlg = CommitDialogNoWidgets(tree)
241 textview = Gtk.TextView()
242 line_height = dlg.get_line_height(textview)
243 self.assertIsInstance(line_height, int)
244
238245
239class TestCommitDialog(tests.TestCaseWithTransport):246class TestCommitDialog(tests.TestCaseWithTransport):
240247

Subscribers

People subscribed via source and target branches

to all changes: