[ease/sourceview] Split SourceView, added a base class.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/sourceview] Split SourceView, added a base class.
- Date: Sat, 12 Jun 2010 20:42:01 +0000 (UTC)
commit d2121c76f93b75bb5c81c743a70f936a37837f42
Author: Nate Stedman <natesm gmail com>
Date: Sat Jun 12 16:39:58 2010 -0400
Split SourceView, added a base class.
- SourceBaseView, an abstract base for source view widgets
- SourcePaneView, a SourceBaseView with an HPaned
- SourceView now inherits from SourceBaseView.
Makefile.am | 2 +
src/Main.vala | 16 ++++++++--
src/SourceBaseView.vala | 71 +++++++++++++++++++++++++++++++++++++++++++++++
src/SourcePaneView.vala | 60 +++++++++++++++++++++++++++++++++++++++
src/SourceView.vala | 42 ++++++---------------------
5 files changed, 155 insertions(+), 36 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1bd1c99..e20a442 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,9 +42,11 @@ ease_SOURCES = \
src/SlidePane.vala \
src/SlideSet.vala \
src/Slide.vala \
+ src/SourceBaseView.vala \
src/SourceGroup.vala \
src/SourceItem.vala \
src/SourceList.vala \
+ src/SourcePaneView.vala \
src/SourceView.vala \
src/Temp.vala \
src/TextActor.vala \
diff --git a/src/Main.vala b/src/Main.vala
index 6e0fce6..471a147 100644
--- a/src/Main.vala
+++ b/src/Main.vala
@@ -244,8 +244,19 @@ public static class Ease.Main : GLib.Object
public static void test_sourceview()
{
- Source.View view = new Source.View();
+ Source.BaseView view = new Source.View();
+ view.list_width_request = 150;
+ build_test_sourceview(view);
+ view = new Source.PaneView(false);
+ build_test_sourceview(view);
+
+ view = new Source.PaneView(true);
+ build_test_sourceview(view);
+ }
+
+ private static void build_test_sourceview(Source.BaseView view)
+ {
var group = new Source.Group("Test Group 1");
var text = new Gtk.TextView();
var item = new Source.Item.from_stock("gtk-new", text);
@@ -277,11 +288,8 @@ public static class Ease.Main : GLib.Object
item.selected = true;
- text = new Gtk.TextView();
-
var window = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
window.add(view);
- //window.add(new Source.Item.from_stock("gtk-new", text));
window.set_size_request(640, 480);
window.show_all();
}
diff --git a/src/SourceBaseView.vala b/src/SourceBaseView.vala
new file mode 100644
index 0000000..2b16720
--- /dev/null
+++ b/src/SourceBaseView.vala
@@ -0,0 +1,71 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * Abstract base for a simple implementation of a widget using
+ * { link Source.List}.
+ *
+ * Source.BaseView creates a { link Source.List} and a Gtk.Bin. These can be
+ * placed into container widgets by subclasses.
+ */
+public abstract class Source.BaseView : Gtk.Alignment
+{
+ /**
+ * The content view.
+ */
+ protected Gtk.Alignment bin;
+
+ /**
+ * The { link Source.List} for this Source.BaseView.
+ */
+ protected Source.List list;
+
+ /**
+ * The width request of this Source.BaseView's { link Source.List}.
+ */
+ public int list_width_request
+ {
+ get { return list.width_request; }
+ set { list.width_request = value; }
+ }
+
+ /**
+ * Creates the list and bin widgets. Should be called by subclass
+ * constructors.
+ */
+ public BaseView()
+ {
+ // create widgets
+ bin = new Gtk.Alignment(0, 0, 1, 1);
+ list = new Source.List(bin);
+
+ // set properties
+ set(0, 0, 1, 1);
+ }
+
+ /**
+ * Adds a { link Source.Group} to this Source.BaseView's
+ * { link Source.List}.
+ *
+ * @param group The group to add.
+ */
+ public void add_group(Source.Group group)
+ {
+ list.add_group(group);
+ }
+}
+
diff --git a/src/SourcePaneView.vala b/src/SourcePaneView.vala
new file mode 100644
index 0000000..021296f
--- /dev/null
+++ b/src/SourcePaneView.vala
@@ -0,0 +1,60 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * An implementation of { link Source.BaseView} with a Gtk.HPaned
+ *
+ * Source.View consists of a { link Source.List}, a separator, and a Gtk.Bin
+ * packed into a Gtk.HBox.
+ */
+public class Source.PaneView : BaseView
+{
+ /**
+ * Creates an empty Source.View. Add groups with add_group().
+ *
+ * @param with_separator If true, a Gtk.Separator is included to the right
+ * of the drag handle.
+ */
+ public PaneView(bool with_separator)
+ {
+ // create base widgets
+ base();
+
+ // create pane widgets and build the view
+ var hpane = new Gtk.HPaned();
+ hpane.pack1(list, false, false);
+
+ // if a separator is requested, build an hbox with it and the bin
+ if (with_separator)
+ {
+ var hbox = new Gtk.HBox(false, 0);
+ hbox.pack_start(new Gtk.VSeparator(), false, false, 0);
+ hbox.pack_start(bin, true, true, 0);
+ hpane.pack2(hbox, true, false);
+ }
+
+ // otherwise, just pack the bin in
+ else
+ {
+ hpane.pack2(bin, true, false);
+ }
+
+ // add the hpaned to the view
+ add(hpane);
+ }
+}
+
diff --git a/src/SourceView.vala b/src/SourceView.vala
index 3d6990c..30644ba 100644
--- a/src/SourceView.vala
+++ b/src/SourceView.vala
@@ -21,44 +21,22 @@
* Source.View consists of a { link Source.List}, a separator, and a Gtk.Bin
* packed into a Gtk.HBox.
*/
-public class Source.View : Gtk.HBox
-{
- /**
- * The content view.
- */
- private Gtk.Alignment bin;
-
- /**
- * The { link Source.List} for this Source.View.
- */
- private Source.List list;
-
+public class Source.View : BaseView
+{
/**
* Creates an empty Source.View. Add groups with add_group().
*/
public View()
{
- // create widgets
- bin = new Gtk.Alignment(0, 0, 1, 1);
- list = new Source.List(bin);
-
- // set properties
- homogeneous = false;
+ // create the bin and list widgets
+ base();
- // assemble
- pack_start(list, false, false, 0);
- pack_start(new Gtk.VSeparator(), false, false, 0);
- pack_start(bin, true, true, 0);
- }
-
- /**
- * Adds a { link Source.Group} to this Source.View's { link Source.List}.
- *
- * @param group The group to add.
- */
- public void add_group(Source.Group group)
- {
- list.add_group(group);
+ // create the hbox widget and build the full view
+ var hbox = new Gtk.HBox(false, 0);
+ hbox.pack_start(list, false, false, 0);
+ hbox.pack_start(new Gtk.VSeparator(), false, false, 0);
+ hbox.pack_start(bin, true, true, 0);
+ add(hbox);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]