[gitg/wip/commit: 2/2] Add commit plugin



commit e0094485548a1b531a9a73868fa1d58034054650
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Mar 7 17:22:15 2013 +0100

    Add commit plugin

 configure.ac                            |    1 +
 plugins/Makefile.am                     |    2 +-
 plugins/commit/Makefile.am              |   51 ++++++++++++
 plugins/commit/commit.plugin            |   11 +++
 plugins/commit/gitg-commit.vala         |  131 +++++++++++++++++++++++++++++++
 plugins/commit/resources/commit-view.ui |   19 +++++
 plugins/commit/resources/resources.xml  |    8 ++
 7 files changed, 222 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a79f6a3..b58de63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,6 +311,7 @@ plugins/history/org.gnome.gitg.history.gschema.xml.in
 plugins/diff/Makefile
 plugins/diff/icons/Makefile
 plugins/files/Makefile
+plugins/commit/Makefile
 ])
 
 AC_OUTPUT
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d1fccaf..6c44c51 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = history diff files
+SUBDIRS = history diff files commit
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/commit/Makefile.am b/plugins/commit/Makefile.am
new file mode 100644
index 0000000..862b000
--- /dev/null
+++ b/plugins/commit/Makefile.am
@@ -0,0 +1,51 @@
+INCLUDES =                                                             \
+       -I$(top_srcdir)                                                 \
+       -I$(srcdir)                                                     \
+       $(GITG_PLUGIN_CFLAGS)                                           \
+       $(WARN_CFLAGS)                                                  \
+       -DDATADIR=\""$(datadir)"\"                                      \
+       -DLIBDIR=\""$(libdir)"\"
+
+plugindir = $(GITG_PLUGIN_LIBDIR)
+plugin_LTLIBRARIES = libcommit.la
+plugin_DATA = commit.plugin
+
+AM_VALAFLAGS = $(GITG_PLUGIN_VALAFLAGS)
+VALA_SOURCES =                                                         \
+       gitg-commit.vala
+
+libcommit_la_LDFLAGS = $(GITG_PLUGIN_LIBTOOL_FLAGS)
+libcommit_la_LIBADD = $(GITG_PLUGIN_LIBS)
+libcommit_la_CFLAGS = -w
+
+libcommit_la_SOURCES =                         \
+       $(VALA_SOURCES)                         \
+       gitg-commit-resources.c
+
+BUILT_SOURCES =                                \
+       gitg-commit-resources.c         \
+       gitg-commit-resources.h
+
+gitg-commit-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-commit-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)                        \
+       libcommit_la_vala.stamp
+
+install-data-hook:
+       rm -f $(GITG_PLUGIN_LIBDIR)/libcommit.la
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/commit/commit.plugin b/plugins/commit/commit.plugin
new file mode 100644
index 0000000..a9d5073
--- /dev/null
+++ b/plugins/commit/commit.plugin
@@ -0,0 +1,11 @@
+[Plugin]
+Loader=C
+Module=commit
+Name=Commit
+Description=gitg Commit
+Authors=Ignacio Casal Quinteiro <icq gnome org>
+Copyright=Copyright © 2013 Ignacio Casal Quinteiro
+Website=
+Hidden=1
+Builtin=1
+Version=1.0
diff --git a/plugins/commit/gitg-commit.vala b/plugins/commit/gitg-commit.vala
new file mode 100644
index 0000000..54060cf
--- /dev/null
+++ b/plugins/commit/gitg-commit.vala
@@ -0,0 +1,131 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2013 - Ignacio Casal Quinteiro
+ *
+ * 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
+{
+       public class View : Object, GitgExt.UIElement, GitgExt.View
+       {
+               // Do this to pull in config.h before glib.h (for gettext...)
+               private const string version = Gitg.Config.VERSION;
+
+               public GitgExt.Application? application { owned get; construct set; }
+
+               private Gtk.TextView d_view;
+               private Gtk.Widget d_main;
+
+               public string id
+               {
+                       owned get { return "/org/gnome/gitg/Views/Commit"; }
+               }
+
+               construct
+               {
+                       application.notify["repository"].connect((a, r) => {
+                               notify_property("available");
+                       });
+               }
+
+               public bool available
+               {
+                       get
+                       {
+                               // The history view is available only when there is a repository
+                               return application.repository != null;
+                       }
+               }
+
+               public string display_name
+               {
+                       owned get { return _("Commit"); }
+               }
+
+               public string? icon
+               {
+                       owned get { return null; }
+               }
+
+               public Gtk.Widget? widget
+               {
+                       owned get
+                       {
+                               if (d_main == null)
+                               {
+                                       build_ui();
+                               }
+
+                               return d_main;
+                       }
+               }
+
+               public GitgExt.Navigation? navigation
+               {
+                       owned get
+                       {
+                               return null;
+                       }
+               }
+
+               public bool is_default_for(string action)
+               {
+                       return application.repository != null && (action == "" || action == "commit");
+               }
+
+               private void build_ui()
+               {
+                       var ret = GitgExt.UI.from_builder("commit/commit-view.ui",
+                                                         "scrolled_window_commit",
+                                                         "commit_view");
+
+                       d_view = ret["commit_view"] as Gtk.TextView;
+                       d_main = ret["scrolled_window_commit"] as Gtk.Widget;
+               }
+
+               public bool enabled
+               {
+                       get
+                       {
+                               return true;
+                       }
+               }
+
+               public int negotiate_order(GitgExt.UIElement other)
+               {
+                       // Should appear after history
+                       if (other.id == "/org/gnome/gitg/Views/History")
+                       {
+                               return 1;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+       }
+}
+
+[ModuleInit]
+public void peas_register_types(TypeModule module)
+{
+       Peas.ObjectModule mod = module as Peas.ObjectModule;
+
+       mod.register_extension_type(typeof(GitgExt.View),
+                                   typeof(GitgCommit.View));
+}
+
+// ex: ts=4 noet
diff --git a/plugins/commit/resources/commit-view.ui b/plugins/commit/resources/commit-view.ui
new file mode 100644
index 0000000..62da8d5
--- /dev/null
+++ b/plugins/commit/resources/commit-view.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.3 -->
+  <object class="GtkScrolledWindow" id="scrolled_window_commit">
+    <property name="visible">True</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="can_focus">True</property>
+    <property name="shadow-type">none</property>
+    <child>
+      <object class="GtkTextView" id="commit_view">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+      </object>
+    </child>
+  </object>
+</interface>
+
+<!-- ex:set ts=2 et: -->
diff --git a/plugins/commit/resources/resources.xml b/plugins/commit/resources/resources.xml
new file mode 100644
index 0000000..4dd1aef
--- /dev/null
+++ b/plugins/commit/resources/resources.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/gitg/commit">
+    <file compressed="true" preprocess="xml-stripblanks">commit-view.ui</file>
+  </gresource>
+</gresources>
+
+<!-- ex: et ts=2 -->


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]