[gitg] Directly show when trying to commit without staged changes
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Directly show when trying to commit without staged changes
- Date: Sun, 9 Aug 2015 17:48:04 +0000 (UTC)
commit 884aca34dfcaffef7d3eeba8feecb6b4a51a1650
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Aug 9 19:47:37 2015 +0200
Directly show when trying to commit without staged changes
gitg/commit/gitg-commit-dialog.vala | 46 +++++++++++++++++++++++++------
gitg/commit/gitg-commit.vala | 2 +-
gitg/resources/ui/gitg-commit-dialog.ui | 16 -----------
3 files changed, 38 insertions(+), 26 deletions(-)
---
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
index 80d8730..1f97441 100644
--- a/gitg/commit/gitg-commit-dialog.vala
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -59,9 +59,6 @@ class Dialog : Gtk.Dialog
[GtkChild (name = "infobar_secondary_label")]
private Gtk.Label d_infobar_secondary_label;
- [GtkChild (name = "infobar_close_button")]
- private Gtk.Button d_infobar_close_button;
-
[GtkChild (name = "list_box_stats")]
private Gtk.ListBox d_list_box_stats;
@@ -83,6 +80,7 @@ class Dialog : Gtk.Dialog
private string? d_spell_checking_language;
private GtkSpell.Checker? d_spell_checker;
private Ggit.Diff d_diff;
+ private bool d_infobar_shown;
public Ggit.Diff? diff
{
@@ -137,7 +135,35 @@ class Dialog : Gtk.Dialog
}
}
- public bool amend { get; set; }
+ private bool d_amend;
+
+ public bool amend
+ {
+ get { return d_amend; }
+
+ set
+ {
+ d_amend = value;
+
+ if (value)
+ {
+ d_infobar_revealer.set_reveal_child(false);
+
+ }
+ else if (d_infobar_shown)
+ {
+ d_infobar_revealer.set_reveal_child(true);
+ }
+
+ update_sensitivity();
+ }
+ }
+
+ private void update_sensitivity()
+ {
+ set_response_sensitive(Gtk.ResponseType.OK, !d_infobar_revealer.get_reveal_child() &&
pretty_message != "");
+ }
+
public bool sign_off { get; set; }
public bool show_markup
@@ -395,7 +421,7 @@ class Dialog : Gtk.Dialog
var b = d_source_view_message.buffer;
d_source_view_message.buffer.changed.connect(() => {
- d_button_ok.sensitive = pretty_message != "";
+ update_sensitivity();
});
d_check_button_amend.bind_property("active",
@@ -463,12 +489,15 @@ class Dialog : Gtk.Dialog
init_message_area();
- if (diff != null)
+ if (diff != null && diff.get_num_deltas() != 0)
{
iterate_diff();
}
else
{
+ show_infobar(_("There are no changes to be committed"),
+ _("Use amend to change the commit message of the previous commit"),
+ Gtk.MessageType.WARNING);
}
}
@@ -722,6 +751,7 @@ class Dialog : Gtk.Dialog
string secondary_msg,
Gtk.MessageType type)
{
+ d_infobar_shown = true;
d_infobar.message_type = type;
var primary = "<b>%s</b>".printf(Markup.escape_text(primary_msg));
@@ -731,9 +761,7 @@ class Dialog : Gtk.Dialog
d_infobar_secondary_label.set_label(secondary);
d_infobar_revealer.set_reveal_child(true);
- d_infobar_close_button.clicked.connect(() => {
- d_infobar_revealer.set_reveal_child(false);
- });
+ set_response_sensitive(Gtk.ResponseType.OK, false);
}
}
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index 1dcea81..a2c4399 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -1063,7 +1063,7 @@ namespace GitgCommit
{
dlg.show_infobar(_("There are no changes to be committed"),
_("Use amend to change the commit message of the previous
commit"),
- Gtk.MessageType.INFO);
+ Gtk.MessageType.WARNING);
return;
}
diff --git a/gitg/resources/ui/gitg-commit-dialog.ui b/gitg/resources/ui/gitg-commit-dialog.ui
index 48c2527..3c88b78 100644
--- a/gitg/resources/ui/gitg-commit-dialog.ui
+++ b/gitg/resources/ui/gitg-commit-dialog.ui
@@ -206,22 +206,6 @@
<property name="position">1</property>
</packing>
</child>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="infobar_action_area">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="infobar_close_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Close</property>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]