~midori/midori/trunk

« back to all changes in this revision

Viewing changes to extensions/tabby.vala

  • Committer: André Stösel
  • Date: 2013-09-28 14:13:22 UTC
  • mfrom: (6419 midori)
  • mto: This revision was merged to the branch mainline in revision 6427.
  • Revision ID: andre@stoesel.de-20130928141322-8g2nadq5gnm30gkh
merge lp:midori

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
 
72
72
            public abstract void add_item (Katze.Item item);
73
73
            public abstract void uri_changed (Midori.View view, string uri);
 
74
            public abstract void data_changed (Midori.View view);
74
75
            public abstract void tab_added (Midori.Browser browser, Midori.View view);
75
76
            public abstract void tab_removed (Midori.Browser browser, Midori.View view);
76
77
            public abstract void tab_switched (Midori.View? old_view, Midori.View? new_view);
81
82
                this.browser = browser;
82
83
 
83
84
                browser.add_tab.connect_after (this.tab_added);
84
 
                browser.add_tab.connect (this.helper_uri_changed);
 
85
                browser.add_tab.connect (this.helper_data_changed);
 
86
 
85
87
                browser.remove_tab.connect (this.tab_removed);
86
88
                browser.switch_tab.connect (this.tab_switched);
87
89
                browser.delete_event.connect_after(this.delete_event);
88
90
 
89
91
                foreach (Midori.View view in browser.get_tabs ()) {
90
92
                    this.tab_added (browser, view);
91
 
                    this.helper_uri_changed (browser, view);
 
93
                    this.helper_data_changed (browser, view);
92
94
                }
93
95
            }
94
96
 
104
106
                }
105
107
 
106
108
                browser.add_tab.connect_after (this.tab_added);
107
 
                browser.add_tab.connect (this.helper_uri_changed);
 
109
                browser.add_tab.connect (this.helper_data_changed);
 
110
 
108
111
                browser.remove_tab.connect (this.tab_removed);
109
112
                browser.switch_tab.connect (this.tab_switched);
110
113
                browser.delete_event.connect_after(this.delete_event);
146
149
 
147
150
            public virtual void close () {
148
151
                this.browser.add_tab.disconnect (this.tab_added);
149
 
                this.browser.add_tab.disconnect (this.helper_uri_changed);
 
152
                this.browser.add_tab.disconnect (this.helper_data_changed);
150
153
                this.browser.remove_tab.disconnect (this.tab_removed);
151
154
                this.browser.switch_tab.disconnect (this.tab_switched);
152
155
                this.browser.delete_event.disconnect (this.delete_event);
197
200
                return this_sorting;
198
201
            }
199
202
 
200
 
            private void helper_uri_changed (Midori.Browser browser, Midori.View view) {
201
 
                /* FixMe: skip first event while restoring the session */
202
 
                view.web_view.notify["uri"].connect ( () => {
203
 
                    this.uri_changed (view, view.web_view.uri);
 
203
            private void helper_data_changed (Midori.Browser browser, Midori.View view) {
 
204
                ulong sig_id = 0;
 
205
                sig_id = view.web_view.load_started.connect (() => {
 
206
                    unowned Katze.Item item = view.get_proxy_item ();
 
207
 
 
208
                    int64 delay = item.get_meta_integer ("delay");
 
209
                    if (delay == Midori.Delay.UNDELAYED) {
 
210
                        view.web_view.notify["uri"].connect ( () => {
 
211
                            this.uri_changed (view, view.web_view.uri);
 
212
                        });
 
213
                        view.web_view.notify["title"].connect ( () => {
 
214
                            this.data_changed (view);
 
215
                        });
 
216
 
 
217
                        GLib.SignalHandler.disconnect (view.web_view, sig_id);
 
218
                    }
204
219
                });
205
220
            }
206
221
 
275
290
            protected override void uri_changed (Midori.View view, string uri) {
276
291
                unowned Katze.Item item = view.get_proxy_item ();
277
292
                int64 tab_id = item.get_meta_integer ("tabby-id");
278
 
                string sqlcmd = "UPDATE `tabs` SET uri = :uri, title = :title WHERE session_id = :session_id AND id = :tab_id;";
 
293
                string sqlcmd = "UPDATE `tabs` SET uri = :uri WHERE session_id = :session_id AND id = :tab_id;";
279
294
                Sqlite.Statement stmt;
280
295
                if (this.db.prepare_v2 (sqlcmd, -1, out stmt, null) != Sqlite.OK)
281
296
                    critical (_("Failed to update database: %s"), db.errmsg ());
282
297
                stmt.bind_text (stmt.bind_parameter_index (":uri"), uri);
 
298
                stmt.bind_int64 (stmt.bind_parameter_index (":session_id"), this.id);
 
299
                stmt.bind_int64 (stmt.bind_parameter_index (":tab_id"), tab_id);
 
300
                if (stmt.step () != Sqlite.DONE)
 
301
                    critical (_("Failed to update database: %s"), db.errmsg ());
 
302
            }
 
303
 
 
304
            protected override void data_changed (Midori.View view) {
 
305
                unowned Katze.Item item = view.get_proxy_item ();
 
306
                int64 tab_id = item.get_meta_integer ("tabby-id");
 
307
                string sqlcmd = "UPDATE `tabs` SET title = :title WHERE session_id = :session_id AND id = :tab_id;";
 
308
                Sqlite.Statement stmt;
 
309
                if (this.db.prepare_v2 (sqlcmd, -1, out stmt, null) != Sqlite.OK)
 
310
                    critical (_("Failed to update database: %s"), db.errmsg ());
283
311
                stmt.bind_text (stmt.bind_parameter_index (":title"), view.get_display_title ());
284
312
                stmt.bind_int64 (stmt.bind_parameter_index (":session_id"), this.id);
285
313
                stmt.bind_int64 (stmt.bind_parameter_index (":tab_id"), tab_id);