[gitg/vala] Implemented diff commit panel
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Implemented diff commit panel
- Date: Tue, 17 Jul 2012 07:57:57 +0000 (UTC)
commit 929efac3704db60f5edd8ff8097fe137d9c33234
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Tue Jul 17 09:55:09 2012 +0200
Implemented diff commit panel
configure.ac | 4 +
icons.mk | 20 ++++++
plugins/Makefile.am | 2 +-
plugins/diff/Makefile.am | 54 +++++++++++++++
plugins/diff/diff.plugin | 11 +++
plugins/diff/gitg-diff.vala | 123 ++++++++++++++++++++++++++++++++++
plugins/diff/icons/Makefile.am | 4 +
plugins/diff/icons/diff-symbolic.svg | 90 +++++++++++++++++++++++++
plugins/diff/resources/resources.xml | 7 ++
9 files changed, 314 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4bd344a..b75d86f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,8 @@ AM_PROG_VALAC
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
+AC_PATH_PROG(GTK_UPDATE_ICON_CACHE, gtk-update-icon-cache-3.0)
+
AC_PATH_PROG(VALADOC, valadoc)
# Initialize libtool
@@ -293,6 +295,8 @@ tests/Makefile
plugins/Makefile
plugins/dash/Makefile
plugins/history/Makefile
+plugins/diff/Makefile
+plugins/diff/icons/Makefile
])
AC_OUTPUT
diff --git a/icons.mk b/icons.mk
new file mode 100644
index 0000000..cd6e7be
--- /dev/null
+++ b/icons.mk
@@ -0,0 +1,20 @@
+baseicondir = $(datadir)/gitg/icons/hicolor
+svgicondir = $(baseicondir)/scalable/actions
+svgicon_DATA = $(ICONS)
+
+gtk_update_icon_cache = $(GTK_UPDATE_ICON_CACHE) -f -t $(baseicondir)
+
+install-data-hook: update-icon-cache
+uninstall-hook: update-icon-cache
+
+update-icon-cache:
+ @-if test -z "$(DESTDIR)"; then \
+ echo "Updating Gtk icon cache."; \
+ $(gtk_update_icon_cache); \
+ else \
+ echo "*** Icon cache not updated. After (un)install, run this:"; \
+ echo "*** $(gtk_update_icon_cache)"; \
+ fi
+
+EXTRA_DIST = \
+ $(svgicon_DATA)
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 32e0a3a..378a083 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = dash history
+SUBDIRS = dash history diff
-include $(top_srcdir)/git.mk
diff --git a/plugins/diff/Makefile.am b/plugins/diff/Makefile.am
new file mode 100644
index 0000000..8d8d8d0
--- /dev/null
+++ b/plugins/diff/Makefile.am
@@ -0,0 +1,54 @@
+SUBDIRS = icons
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(srcdir) \
+ $(GITG_PLUGIN_CFLAGS) \
+ $(WARN_CFLAGS) \
+ -DDATADIR=\""$(datadir)"\" \
+ -DLIBDIR=\""$(libdir)"\"
+
+plugindir = $(GITG_PLUGIN_LIBDIR)
+plugin_LTLIBRARIES = libdiff.la
+plugin_DATA = diff.plugin
+
+VALAFLAGS = $(GITG_PLUGIN_VALAFLAGS)
+VALA_SOURCES = \
+ gitg-diff.vala
+
+libdiff_la_LDFLAGS = $(GITG_PLUGIN_LIBTOOL_FLAGS)
+
+libdiff_la_LIBADD = $(GITG_PLUGIN_LIBS)
+libdiff_la_CFLAGS = -w
+
+libdiff_la_SOURCES = \
+ $(VALA_SOURCES) \
+ gitg-diff-resources.c
+
+BUILT_SOURCES = \
+ gitg-diff-resources.c \
+ gitg-diff-resources.h
+
+gitg-diff-resources.c: resources/resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/resources resources/resources.xml)
+ $(GLIB_COMPILE_RESOURCES) --generate-source \
+ --sourcedir $(srcdir)/resources \
+ --target "$@" "$<"
+
+gitg-diff-resources.h: resources/resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/resources resources/resources.xml)
+ $(GLIB_COMPILE_RESOURCES) --generate-header \
+ --sourcedir $(srcdir)/resources \
+ --target "$@" "$<"
+
+EXTRA_DIST = $(plugin_DATA) \
+ resources/resources.xml \
+ $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/resources resources/resources.xml)
+
+CLEANFILES = \
+ $(VALA_SOURCES:.vala=.c) \
+ $(BUILT_SOURCES) \
+ libdiff_la_vala.stamp
+
+install-data-hook:
+ rm -f $(GITG_PLUGIN_LIBDIR)/libdiff.la
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/diff/diff.plugin b/plugins/diff/diff.plugin
new file mode 100644
index 0000000..a3026c1
--- /dev/null
+++ b/plugins/diff/diff.plugin
@@ -0,0 +1,11 @@
+[Plugin]
+Loader=C
+Module=diff
+Name=Diff
+Description=gitg repository diff
+Authors=Jesse van den Kieboom <jessevdk gnome org>
+Copyright=Copyright  2012 Jesse van den Kieboom
+Website=
+Hidden=1
+Builtin=1
+Version=1.0
diff --git a/plugins/diff/gitg-diff.vala b/plugins/diff/gitg-diff.vala
new file mode 100644
index 0000000..3d85f79
--- /dev/null
+++ b/plugins/diff/gitg-diff.vala
@@ -0,0 +1,123 @@
+/*
+ * 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 GitgDiff
+{
+ // Do this to pull in config.h before glib.h (for gettext...)
+ private const string version = Gitg.Config.VERSION;
+
+ public class Panel : Object, GitgExt.UIElement, GitgExt.Panel
+ {
+ public GitgExt.Application? application { owned get; construct set; }
+ private Gtk.ScrolledWindow d_sw;
+ private GitgGtk.DiffView d_diff;
+ private GitgExt.ObjectSelection? d_view;
+
+ construct
+ {
+ d_diff = new GitgGtk.DiffView(null);
+ d_sw = new Gtk.ScrolledWindow(null, null);
+
+ d_sw.show();
+ d_diff.show();
+
+ d_sw.add(d_diff);
+ }
+
+ public string id
+ {
+ owned get { return "/org/gnome/gitg/Panels/Diff"; }
+ }
+
+ public bool is_available()
+ {
+ var view = application.current_view;
+
+ if (view == null)
+ {
+ return false;
+ }
+
+ return (view is GitgExt.ObjectSelection);
+ }
+
+ public string display_name
+ {
+ owned get { return "Diff"; }
+ }
+
+ public Icon? icon
+ {
+ owned get { return new ThemedIcon("diff-symbolic"); }
+ }
+
+ private void on_selection_changed(GitgExt.ObjectSelection selection)
+ {
+ selection.foreach_selected((commit) => {
+ var c = commit as Ggit.Commit;
+
+ if (c != null)
+ {
+ d_diff.commit = c;
+ return false;
+ }
+
+ return true;
+ });
+ }
+
+ public Gtk.Widget? widget
+ {
+ owned get
+ {
+ var objsel = (GitgExt.ObjectSelection)application.current_view;
+
+ if (objsel != d_view)
+ {
+ if (d_view != null)
+ {
+ d_view.selection_changed.disconnect(on_selection_changed);
+ }
+
+ d_view = objsel;
+ d_view.selection_changed.connect(on_selection_changed);
+ }
+
+ return d_sw;
+ }
+ }
+
+ public bool is_enabled()
+ {
+ // TODO
+ return true;
+ }
+ }
+}
+
+[ModuleInit]
+public void peas_register_types(TypeModule module)
+{
+ Peas.ObjectModule mod = module as Peas.ObjectModule;
+
+ mod.register_extension_type(typeof(GitgExt.Panel),
+ typeof(GitgDiff.Panel));
+}
+
+// ex: ts=4 noet
diff --git a/plugins/diff/icons/Makefile.am b/plugins/diff/icons/Makefile.am
new file mode 100644
index 0000000..0a6ff1d
--- /dev/null
+++ b/plugins/diff/icons/Makefile.am
@@ -0,0 +1,4 @@
+ICONS = diff-symbolic.svg
+
+include $(top_srcdir)/icons.mk
+include $(top_srcdir)/git.mk
diff --git a/plugins/diff/icons/diff-symbolic.svg b/plugins/diff/icons/diff-symbolic.svg
new file mode 100644
index 0000000..1f97d2b
--- /dev/null
+++ b/plugins/diff/icons/diff-symbolic.svg
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg7384"
+ height="16"
+ width="16"
+ version="1.1"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="diff-symbolic.svg">
+ <defs
+ id="defs14" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1175"
+ inkscape:window-height="1078"
+ id="namedview12"
+ showgrid="false"
+ inkscape:zoom="32"
+ inkscape:cx="8.4556149"
+ inkscape:cy="7.5355536"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg7384" />
+ <metadata
+ id="metadata90">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <title
+ id="title9167">Gnome Symbolic Icon Theme</title>
+ <g
+ id="g3985"
+ transform="translate(-0.04915361,-1.5342538)">
+ <g
+ transform="matrix(1.4122315,0,0,1.4122315,-0.0441821,-1.7635987)"
+ id="g3919">
+ <path
+ style="fill:#bebebe;fill-opacity:1;stroke:none"
+ d="m 1.6548392,5.6223232 0,-1.3441487 1.3441488,0 -2e-7,1.3441487 1.3441487,0 0,1.3441494 -1.3441487,-7e-7 10e-8,1.3441487 -1.3441487,0 0,-1.3441487 -1.34414878,7e-7 0,-1.3441494 z"
+ id="rect3796"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccccc" />
+ <path
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0"
+ id="path3811"
+ d="m 4.3431365,10.377676 0,1.34415 -4.03244608,0 0,-1.34415 z"
+ style="fill:#bebebe;fill-opacity:1;stroke:none" />
+ </g>
+ <g
+ transform="matrix(1.4122315,0,0,1.4122315,1.5584969,-1.7635984)"
+ id="g3923">
+ <path
+ sodipodi:nodetypes="ccccccccccccc"
+ inkscape:connector-curvature="0"
+ id="path3799"
+ d="m 7.3279261,5.6223232 0,-1.3441487 1.3441488,0 -10e-8,1.3441487 1.3441482,0 0,1.3441494 -1.3441482,-7e-7 10e-8,1.3441487 -1.3441488,0 0,-1.3441487 -1.3441488,7e-7 0,-1.3441494 z"
+ style="fill:#bebebe;fill-opacity:1;stroke:none" />
+ <path
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0"
+ id="path3819"
+ d="m 10.016223,10.377676 0,1.34415 -4.0324459,0 0,-1.34415 z"
+ style="fill:#bebebe;fill-opacity:1;stroke:none" />
+ </g>
+ </g>
+</svg>
diff --git a/plugins/diff/resources/resources.xml b/plugins/diff/resources/resources.xml
new file mode 100644
index 0000000..300b1b1
--- /dev/null
+++ b/plugins/diff/resources/resources.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/gitg/diff">
+ </gresource>
+</gresources>
+
+<!-- ex: et ts=2 -->
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]