summaryrefslogtreecommitdiff
path: root/midori/midori-panedaction.vala
blob: 32cdb76457d6474e9ea5e03eb851d42b37067247 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 Copyright (C) 2011 Peter Hatina <phatina@redhat.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 See the file COPYING for the full license text.
*/

namespace Midori {
    public class PanedAction : Gtk.Action {
        Gtk.HPaned? hpaned = null;
        Gtk.ToolItem? toolitem = null;
        Child child1 = new Child();
        Child child2 = new Child();

        public PanedAction () {
            GLib.Object (name: "LocationSearch");
        }

        private struct Child {
            public Gtk.Widget widget;
            string name;
            bool resize;
            bool shrink;
        }

        public override unowned Gtk.Widget create_tool_item () {
            Gtk.Alignment alignment = new Gtk.Alignment (0.0f, 0.5f, 1.0f, 0.1f);
            hpaned = new Gtk.HPaned ();
            toolitem = new Gtk.ToolItem ();
            toolitem.set_expand (true);
            toolitem.add (alignment);
            alignment.add (hpaned);

            hpaned.pack1 (child1.widget, child1.resize, child1.shrink);
            hpaned.pack2 (child2.widget, child2.resize, child2.shrink);
            toolitem.show_all ();
            return toolitem;
        }

        public void set_child1 (Gtk.Widget widget, string name, bool resize, bool shrink) {
            child1.widget = widget;
            child1.name = name;
            child1.resize = resize;
            child1.shrink = shrink;
        }

        public void set_child2 (Gtk.Widget widget, string name, bool resize, bool shrink) {
            child2.widget = widget;
            child2.name = name;
            child2.resize = resize;
            child2.shrink = shrink;
        }

        public Gtk.Widget? get_child1 () {
            return child1.widget;
        }

        public Gtk.Widget? get_child2 () {
            return child2.widget;
        }

        public Gtk.Widget? get_child_by_name (string name) {
            if (name == child1.name)
                return child1.widget;
            else if (name == child2.name)
                return child2.widget;
            return null;
        }

        public string get_child1_name () {
            return child1.name;
        }

        public string get_child2_name () {
            return child2.name;
        }
    }
}