[gitg/wip/commit] Added basic commit dialog
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/commit] Added basic commit dialog
- Date: Wed, 3 Jul 2013 18:28:02 +0000 (UTC)
commit cad1fc8743ef7de2a9dd670cd6eb0fa4f1d18d5c
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Wed Jul 3 20:27:42 2013 +0200
Added basic commit dialog
gitg/Makefile.am | 4 +-
gitg/commit/gitg-commit-dialog.vala | 81 +++++++++++++++++
gitg/commit/gitg-commit.vala | 18 ++++
gitg/resources/gitg-resources.xml | 1 +
gitg/resources/ui/gitg-commit-dialog.ui | 145 +++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
6 files changed, 249 insertions(+), 1 deletions(-)
---
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index bc869fe..829d6f9 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -24,6 +24,7 @@ AM_VALAFLAGS = \
--pkg gee-0.8 \
--pkg gd-1.0 \
--pkg webkit2gtk-3.0 \
+ --pkg gtksourceview-3.0 \
--girdir "$(top_builddir)/libgd" \
--girdir "$(top_builddir)/libgitg" \
--girdir "$(top_builddir)/libgitg-ext" \
@@ -48,7 +49,8 @@ VALASOURCES = \
history/gitg-history-navigation.vala \
history/gitg-history-paned.vala \
commit/gitg-commit.vala \
- commit/gitg-commit-paned.vala
+ commit/gitg-commit-paned.vala \
+ commit/gitg-commit-dialog.vala
BUILT_SOURCES = \
gitg-resources.c \
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
new file mode 100644
index 0000000..2bee445
--- /dev/null
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -0,0 +1,81 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2012 - Jesse van den Kieboom
+ *
+ * gitg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gitg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace GitgCommit
+{
+
+[GtkTemplate (ui = "/org/gnome/gitg/ui/gitg-commit-dialog.ui")]
+class Dialog : Gtk.Dialog
+{
+ [GtkChild (name = "source_view_message")]
+ private GtkSource.View d_source_view_message;
+
+ [GtkChild (name = "ok-button")]
+ private Gtk.Button d_button_ok;
+
+ private Settings d_fontsettings;
+
+ public GtkSource.View source_view_message
+ {
+ get { return d_source_view_message; }
+ }
+
+ public string message
+ {
+ owned get
+ {
+ var b = d_source_view_message.buffer;
+
+ Gtk.TextIter start;
+ Gtk.TextIter end;
+
+ b.get_bounds(out start, out end);
+ return Ggit.message_prettify(b.get_text(start, end, false), false);
+ }
+ }
+
+ construct
+ {
+ d_fontsettings = new Settings("org.gnome.desktop.interface");
+
+ update_font_settings();
+
+ d_fontsettings.changed["monospace-font-name"].connect((s, k) => {
+ update_font_settings();
+ });
+
+ var b = d_source_view_message.buffer;
+
+ d_source_view_message.buffer.changed.connect(() => {
+ d_button_ok.sensitive = message != "";
+ });
+ }
+
+ private void update_font_settings()
+ {
+ var mfont = d_fontsettings.get_string("monospace-font-name");
+ var desc = Pango.FontDescription.from_string(mfont);
+
+ d_source_view_message.override_font(desc);
+ }
+}
+
+}
+
+// ex: ts=4 noet
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index 379f626..cfdf60f 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -384,6 +384,20 @@ namespace GitgCommit
reload();
}
+ private void on_commit_clicked()
+ {
+ var dlg = new Dialog();
+
+ dlg.set_transient_for((Gtk.Window)d_main.get_toplevel());
+ dlg.set_default_response(Gtk.ResponseType.OK);
+
+ dlg.response.connect((d, id) => {
+ d.destroy();
+ });
+
+ dlg.show();
+ }
+
private void build_ui()
{
d_main = new Paned();
@@ -391,6 +405,10 @@ namespace GitgCommit
d_main.sidebar.deselected.connect(() => {
d_main.diff_view.diff = null;
});
+
+ d_main.button_commit.clicked.connect(() => {
+ on_commit_clicked();
+ });
}
}
}
diff --git a/gitg/resources/gitg-resources.xml b/gitg/resources/gitg-resources.xml
index 78d254b..ac96dc6 100644
--- a/gitg/resources/gitg-resources.xml
+++ b/gitg/resources/gitg-resources.xml
@@ -10,6 +10,7 @@
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-user-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-history-paned.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-commit-paned.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/gitg-commit-dialog.ui</file>
<file compressed="true">ui/style.css</file>
<file alias="icons/gitg.svg" compressed="true"
preprocess="xml-stripblanks">../../data/icons/gitg.svg</file>
<file alias="icons/gitg128x128.png">../../data/icons/gitg128x128.png</file>
diff --git a/gitg/resources/ui/gitg-commit-dialog.ui b/gitg/resources/ui/gitg-commit-dialog.ui
new file mode 100644
index 0000000..7b66400
--- /dev/null
+++ b/gitg/resources/ui/gitg-commit-dialog.ui
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <template class="GitgCommitDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Commit</property>
+ <property name="resizable">True</property>
+ <property name="modal">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="default_width">600</property>
+ <property name="default_height">400</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancel-button">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok-button">
+ <property name="label" translatable="yes">C_ommit</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled_window_message">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkSourceView" id="source_view_message">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="auto-indent">True</property>
+ <property name="show-right-margin">True</property>
+ <property name="smart-home-end">after</property>
+ <property name="right-margin-position">72</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="check_button_amend">
+ <property name="label" translatable="yes">Amend previous commit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="check_button_signoff">
+ <property name="label" translatable="yes">Add signed-off-by signature</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">cancel-button</action-widget>
+ <action-widget response="-5">ok-button</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7faed90..2be7a5d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,5 +23,6 @@ plugins/files/gitg-files.vala
[type: gettext/glade]gitg/resources/ui/gitg-user-dialog.ui
[type: gettext/glade]gitg/resources/ui/gitg-history-paned.ui
[type: gettext/glade]gitg/resources/ui/gitg-commit-paned.ui
+[type: gettext/glade]gitg/resources/ui/gitg-commit-dialog.ui
[type: gettext/glade]gitg/resources/ui/gitg-window.ui
[type: gettext/glade]plugins/files/resources/view-files.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]