[gnome-calculator/wip/glade] Migrate HistoryView to use GtkBuilder templates
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/wip/glade] Migrate HistoryView to use GtkBuilder templates
- Date: Sat, 16 Jan 2016 21:44:41 +0000 (UTC)
commit 483257a493c495218a22c77eb0579539533c60d2
Author: Alberto Ruiz <aruiz gnome org>
Date: Sat Jan 16 21:43:19 2016 +0000
Migrate HistoryView to use GtkBuilder templates
data/gnome-calculator.gresource.xml | 1 +
data/history-view.ui | 30 ++++++++++++++++++++++++++++++
src/math-display.vala | 3 ++-
src/math-history.vala | 25 +++++--------------------
4 files changed, 38 insertions(+), 21 deletions(-)
---
diff --git a/data/gnome-calculator.gresource.xml b/data/gnome-calculator.gresource.xml
index 30630d9..8d33a98 100644
--- a/data/gnome-calculator.gresource.xml
+++ b/data/gnome-calculator.gresource.xml
@@ -5,6 +5,7 @@
<file preprocess="xml-stripblanks">buttons-basic.ui</file>
<file preprocess="xml-stripblanks">buttons-financial.ui</file>
<file preprocess="xml-stripblanks">buttons-programming.ui</file>
+ <file preprocess="xml-stripblanks">history-view.ui</file>
<file preprocess="xml-stripblanks">math-converter.ui</file>
<file preprocess="xml-stripblanks">math-window.ui</file>
<file preprocess="xml-stripblanks">menu.ui</file>
diff --git a/data/history-view.ui b/data/history-view.ui
new file mode 100644
index 0000000..ce0dcd5
--- /dev/null
+++ b/data/history-view.ui
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.19.0 -->
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="HistoryView" parent="GtkScrolledWindow">
+ <property name="width_request">100</property>
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">etched-out</property>
+ <signal name="size-allocate" handler="scroll_bottom" swapped="no"/>
+ <child>
+ <object class="GtkViewport" id="viewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkListBox" id="listbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <property name="border_width">5</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/math-display.vala b/src/math-display.vala
index 1d22300..f2aae97 100644
--- a/src/math-display.vala
+++ b/src/math-display.vala
@@ -31,7 +31,8 @@ public class MathDisplay : Gtk.Viewport
var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
add (main_box);
- history = new HistoryView (this);
+ history = new HistoryView ();
+ history.display = this;
main_box.add (history);
main_box.show_all ();
diff --git a/src/math-history.vala b/src/math-history.vala
index a9c1567..2433a74 100644
--- a/src/math-history.vala
+++ b/src/math-history.vala
@@ -8,33 +8,18 @@
* license.
*/
+[GtkTemplate (ui = "/org/gnome/calculator/history-view.ui")]
public class HistoryView : Gtk.ScrolledWindow
{
int no_ofitems = 0; /* No of entries in history-view listbox */
+
+ [GtkChild]
Gtk.ListBox listbox;
private MathDisplay _display;
- public MathDisplay display { get { return _display; } }
- /* Creates a History-View box */
- public HistoryView (MathDisplay display)
- {
- _display = display;
-
- listbox = new Gtk.ListBox ();
- listbox.set_selection_mode (Gtk.SelectionMode.NONE);
- listbox.set_border_width (5);
- listbox.set_vexpand (true);
- add (listbox);
-
- set_shadow_type (Gtk.ShadowType.ETCHED_OUT);
- set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
- set_placement (Gtk.CornerType.TOP_LEFT);
- set_vexpand (true);
-
- set_size_request (100, 100);
- size_allocate.connect (scroll_bottom);
- }
+ public MathDisplay display { set { _display = value; } get { return _display; } }
+ [GtkCallback]
public void scroll_bottom ()
{
var adjustment = get_vadjustment ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]