[gitg] Show extended git message as part of the scrolled area
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Show extended git message as part of the scrolled area
- Date: Fri, 19 Aug 2016 07:05:46 +0000 (UTC)
commit 73d6b6e61b3dae86a666b28d3c9f1d637e1e2ffa
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Fri Aug 19 09:01:53 2016 +0200
Show extended git message as part of the scrolled area
https://bugzilla.gnome.org/show_bug.cgi?id=769239
libgitg/gitg-diff-view-commit-details.vala | 6 ++--
libgitg/gitg-diff-view.vala | 33 ++++++++++++++++++++
.../resources/ui/gitg-diff-view-commit-details.ui | 2 +-
libgitg/resources/ui/gitg-diff-view.ui | 27 +++++++++++++++-
libgitg/resources/ui/libgitg-style.css | 5 +++
5 files changed, 68 insertions(+), 5 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-commit-details.vala b/libgitg/gitg-diff-view-commit-details.vala
index 0e53b27..3927d83 100644
--- a/libgitg/gitg-diff-view-commit-details.vala
+++ b/libgitg/gitg-diff-view-commit-details.vala
@@ -35,8 +35,8 @@ class Gitg.DiffViewCommitDetails : Gtk.Grid
[GtkChild( name = "label_committer_date" )]
private Gtk.Label d_label_committer_date;
- [GtkChild( name = "label_message" )]
- private Gtk.Label d_label_message;
+ [GtkChild( name = "label_subject" )]
+ private Gtk.Label d_label_subject;
[GtkChild( name = "label_sha1" )]
private Gtk.Label d_label_sha1;
@@ -185,7 +185,7 @@ class Gitg.DiffViewCommitDetails : Gtk.Grid
return;
}
- d_label_message.label = commit.get_message();
+ d_label_subject.label = commit.get_subject();
d_label_sha1.label = commit.get_id().to_string();
var author = commit.get_author();
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 2ebcdd0..fedde41 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -38,6 +38,9 @@ public class Gitg.DiffView : Gtk.Grid
[GtkChild( name = "diff_view_options" )]
private DiffViewOptions d_diff_view_options;
+ [GtkChild( name = "text_view_message" )]
+ private Gtk.TextView d_text_view_message;
+
private Ggit.Diff? d_diff;
private Commit? d_commit;
private Ggit.DiffOptions? d_options;
@@ -217,6 +220,29 @@ public class Gitg.DiffView : Gtk.Grid
}
}
+ private static Regex s_message_regexp;
+
+ static construct
+ {
+ try
+ {
+ s_message_regexp = new Regex(".*[\\R\\s]*(?P<message>(?:.|\\R)*?)\\s*$");
+ } catch (Error e) { stderr.printf(@"Failed to compile regex: $(e.message)\n"); }
+ }
+
+ private string message_without_subject(Commit commit)
+ {
+ var message = commit.get_message();
+ MatchInfo minfo;
+
+ if (s_message_regexp.match(message, 0, out minfo))
+ {
+ return minfo.fetch_named("message");
+ }
+
+ return "";
+ }
+
private void update(bool preserve_expanded)
{
// If both `d_diff` and `d_commit` are null, clear
@@ -262,11 +288,18 @@ public class Gitg.DiffView : Gtk.Grid
d_diff = d_commit.get_diff(options, parent);
d_commit_details.show();
+
+ var message = message_without_subject(d_commit);
+
+ d_text_view_message.buffer.set_text(message);
+ d_text_view_message.visible = (message != "");
}
else
{
d_commit_details.commit = null;
d_commit_details.hide();
+
+ d_text_view_message.hide();
}
if (d_diff != null)
diff --git a/libgitg/resources/ui/gitg-diff-view-commit-details.ui
b/libgitg/resources/ui/gitg-diff-view-commit-details.ui
index f8d4b22..70c3a36 100644
--- a/libgitg/resources/ui/gitg-diff-view-commit-details.ui
+++ b/libgitg/resources/ui/gitg-diff-view-commit-details.ui
@@ -121,7 +121,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_message">
+ <object class="GtkLabel" id="label_subject">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
diff --git a/libgitg/resources/ui/gitg-diff-view.ui b/libgitg/resources/ui/gitg-diff-view.ui
index 76df5ec..8f534ef 100644
--- a/libgitg/resources/ui/gitg-diff-view.ui
+++ b/libgitg/resources/ui/gitg-diff-view.ui
@@ -41,11 +41,36 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkGrid" id="grid_files">
+ <object class="GtkGrid" id="grid_content">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <child>
+ <object class="GtkTextView" id="text_view_message">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="cursor_visible">False</property>
+ <property name="hexpand">True</property>
+ <property name="pixels_above_lines">1</property>
+ <property name="pixels_below_lines">1</property>
+ <property name="margin_bottom">6</property>
+ <property name="margin_start">18</property>
+ <property name="margin_end">18</property>
+ <style>
+ <class name="commit-message"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid_files">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/libgitg/resources/ui/libgitg-style.css b/libgitg/resources/ui/libgitg-style.css
index 877a758..494e7fe 100644
--- a/libgitg/resources/ui/libgitg-style.css
+++ b/libgitg/resources/ui/libgitg-style.css
@@ -32,6 +32,11 @@ GitgDiffView GitgDiffViewCommitDetails {
border-bottom: 1px outset lighter(@borders);
}
+textview.commit-message text {
+ background-color: @theme_bg_color;
+ color: @theme_text_color;
+}
+
gitg-diffstat {
border: 1px inset shade(@borders, 1.2);
border-radius: 5px;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]