~ubuntu-branches/ubuntu/trusty/xiphos/trusty

« back to all changes in this revision

Viewing changes to editkit/editkit.vala

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs, Dmitrijs Ledkovs
  • Date: 2012-03-11 18:43:32 UTC
  • mfrom: (17.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120311184332-splq3ecpx7tyi87d
Tags: 3.1.5+dfsg-1
[ Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com> ]  
* New upstream release.
* Build using webkit backend
* Contains unpacked source for waf binary (Closes: #654511)
* Update debian/copyright to latest specification

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
private class EditKit : Window {
9
9
 
10
10
        private const string MAIN_UI  = "main.ui";
11
 
    private WebView web_view;
 
11
        private WebView web_view;
12
12
 
13
13
        private const ActionEntry[] entries = {
14
14
                {"menuFile", null, "_File"},
15
 
                {"new", STOCK_NEW, "_New", null, null, on_new},
16
 
                {"open", STOCK_OPEN, "_Open", null, null, on_open},
17
 
                {"save", STOCK_SAVE, "_Save", null, null, on_save},
18
 
                {"print", STOCK_PRINT, "_Print", null, null, on_action},
 
15
                {"new", Gtk.Stock.NEW, "_New", null, null, on_new},
 
16
                {"open", Gtk.Stock.OPEN, "_Open", null, null, on_open},
 
17
                {"save", Gtk.Stock.SAVE, "_Save", null, null, on_save},
 
18
                {"print", Gtk.Stock.PRINT, "_Print", null, null, on_action},
19
19
                {"menuEdit", null, "_Edit"},
20
 
                {"undo", STOCK_UNDO, "_Undo", null, null, on_action},
21
 
                {"redo", STOCK_REDO, "_Redo", null, null, on_action},
22
 
                {"cut", STOCK_CUT, "_Cut", null, null, on_action},
23
 
                {"copy", STOCK_COPY, "_Copy", null, null, on_action},
24
 
                {"paste", STOCK_PASTE, "_Paste", null, null, on_paste},
 
20
                {"undo", Gtk.Stock.UNDO, "_Undo", null, null, on_action},
 
21
                {"redo", Gtk.Stock.REDO, "_Redo", null, null, on_action},
 
22
                {"cut", Gtk.Stock.CUT, "_Cut", null, null, on_action},
 
23
                {"copy", Gtk.Stock.COPY, "_Copy", null, null, on_action},
 
24
                {"paste", Gtk.Stock.PASTE, "_Paste", null, null, on_paste},
25
25
                {"menuInsert", null, "_Insert"},
26
26
                {"insertimage", "insert-image", "Insert _Image", null, null, on_insert_image},
27
27
                {"insertlink", "insert-link", "Insert _Link", null, null, on_insert_link},
28
28
                {"menuFormat", null, "_Format"},
29
 
                {"bold", STOCK_BOLD, "_Bold", """<ctrl>B""", null, on_action},
30
 
                {"italic", STOCK_ITALIC, "_Italic", """<ctrl>I""", null, on_action},
31
 
                {"underline", STOCK_UNDERLINE, "_Underline", """<ctrl>U""", null, on_action},
32
 
                {"strikethrough", STOCK_STRIKETHROUGH, "_Strike", """<ctrl>T""", null, on_action},
33
 
                {"font", STOCK_SELECT_FONT, "Select _Font", """<ctrl>F""", null, on_select_font},
34
 
                {"color", STOCK_SELECT_COLOR, "Select _Color", null, null, on_select_color},
35
 
                {"justifyleft", STOCK_JUSTIFY_LEFT, "Justify _Left", null, null, on_action},
36
 
                {"justifyright", STOCK_JUSTIFY_RIGHT, "Justify _Right", null, null, on_action},
37
 
                {"justifycenter", STOCK_JUSTIFY_CENTER, "Justify _Center", null, null, on_action},
38
 
                {"justifyfull", STOCK_JUSTIFY_FILL, "Justify _Full", null, null, on_action},
39
 
                {"indent", STOCK_INDENT, "_Icrease Indent", "<Control>bracketright", "Increase Indent", on_action},
40
 
                {"outdent", STOCK_UNINDENT, "_Decrease Indent", "<Control>bracketleft", "Decrease Indent", on_action}
 
29
                {"bold", Gtk.Stock.BOLD, "_Bold", """<ctrl>B""", null, on_action},
 
30
                {"italic", Gtk.Stock.ITALIC, "_Italic", """<ctrl>I""", null, on_action},
 
31
                {"underline", Gtk.Stock.UNDERLINE, "_Underline", """<ctrl>U""", null, on_action},
 
32
                {"strikethrough", Gtk.Stock.STRIKETHROUGH, "_Strike", """<ctrl>T""", null, on_action},
 
33
                {"font", Gtk.Stock.SELECT_FONT, "Select _Font", """<ctrl>F""", null, on_select_font},
 
34
                {"color", Gtk.Stock.SELECT_COLOR, "Select _Color", null, null, on_select_color},
 
35
                {"justifyleft", Gtk.Stock.JUSTIFY_LEFT, "Justify _Left", null, null, on_action},
 
36
                {"justifyright", Gtk.Stock.JUSTIFY_RIGHT, "Justify _Right", null, null, on_action},
 
37
                {"justifycenter", Gtk.Stock.JUSTIFY_CENTER, "Justify _Center", null, null, on_action},
 
38
                {"justifyfull", Gtk.Stock.JUSTIFY_FILL, "Justify _Full", null, null, on_action},
 
39
                {"indent", Gtk.Stock.INDENT, "_Icrease Indent", "<Control>bracketright", "Increase Indent", on_action},
 
40
                {"outdent", Gtk.Stock.UNINDENT, "_Decrease Indent", "<Control>bracketleft", "Decrease Indent", on_action}
41
41
        };
42
42
 
43
43
    private EditKit () {
49
49
 
50
50
        private void create_widgets () {
51
51
 
52
 
                var actions = new ActionGroup("Actions");
 
52
                var actions = new Gtk.ActionGroup("Actions");
53
53
                actions.set_translation_domain("xiphos");
54
54
                actions.add_actions(entries, this);
55
55
 
73
73
 
74
74
                this.web_view = new WebView ();
75
75
                web_view.set_editable(true);
76
 
                web_view.load_html_string("", "file:///");
 
76
                web_view.load_html_string("This is some text", "file:///");
77
77
                var scrolled_window = new ScrolledWindow (null, null);
78
78
                scrolled_window.set_policy (PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
79
79
                scrolled_window.add (this.web_view);
90
90
        this.destroy.connect (Gtk.main_quit);
91
91
    }
92
92
 
93
 
        private void on_action(Action action) {
 
93
        private void on_action(Gtk.Action action) {
94
94
                this.web_view.execute_script("document.execCommand('" + action.get_name() + "', false, false);");
95
95
        }
96
96
 
103
103
                        "Select an HTML file",
104
104
                        this,
105
105
                        Gtk.FileChooserAction.OPEN,
106
 
                        Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
107
 
                        Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT,
 
106
                        Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,
 
107
                        Gtk.Stock.OPEN, Gtk.ResponseType.ACCEPT,
108
108
                        null);
109
109
 
110
110
                if (dialog.run() == Gtk.ResponseType.ACCEPT) {
133
133
                        "Select an HTML file",
134
134
                        this,
135
135
                        Gtk.FileChooserAction.SAVE,
136
 
                        Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
137
 
                        Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT,
 
136
                        Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,
 
137
                        Gtk.Stock.OPEN, Gtk.ResponseType.ACCEPT,
138
138
                        null);
139
139
 
140
140
                dialog.set_do_overwrite_confirmation(true);
190
190
 
191
191
    private static int main (string[] args) {
192
192
 
193
 
        Gtk.init (ref args);
 
193
        //Gtk.init (ref args);
194
194
        var editor = new EditKit ();
195
195
                editor.show_all();
196
196
        Gtk.main ();