~midori/midori/trunk

« back to all changes in this revision

Viewing changes to midori/midori-notebook.vala

  • Committer: Christian Dywan
  • Date: 2014-03-06 23:51:16 UTC
  • mto: This revision was merged to the branch mainline in revision 6590.
  • Revision ID: christian.dywan@canonical.com-20140306235116-sbpabnqbyb2b7afi
Add first notebook test verifying escaping

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
            notebook.create_window.disconnect (window_created);
261
261
        }
262
262
 
 
263
        /* Since: 0.5.8 */
 
264
        public ContextAction get_context_action () {
 
265
            var menu = new Midori.ContextAction ("NotebookContextMenu", null, null, null);
 
266
            uint counter = 0;
 
267
            foreach (var child in notebook.get_children ()) {
 
268
                var tab = child as Midori.Tab;
 
269
                var tally = notebook.get_tab_label (tab) as Tally;
 
270
                var action = new Midori.ContextAction.escaped ("Tab%u".printf (counter), tally.label.label, null, null);
 
271
                action.gicon = tally.icon.gicon;
 
272
                action.activate.connect (()=>{
 
273
                    notebook.set_current_page (notebook.page_num (tab));
 
274
                });
 
275
                menu.add (action);
 
276
                counter++;
 
277
            }
 
278
            context_menu (menu);
 
279
            return menu;
 
280
        }
 
281
 
263
282
        bool button_pressed (Gdk.EventButton event) {
264
283
            /* Propagate events in logical label area */
265
284
            foreach (var child in notebook.get_children ()) {
280
299
                return true;
281
300
            }
282
301
            else if (event.button == 3) {
283
 
                var menu = new Midori.ContextAction ("NotebookContextMenu", null, null, null);
284
 
                uint counter = 0;
285
 
                foreach (var child in notebook.get_children ()) {
286
 
                    var tab = child as Midori.Tab;
287
 
                    var tally = notebook.get_tab_label (tab) as Tally;
288
 
                    var action = new Midori.ContextAction.escaped ("Tab%u".printf (counter), tally.label.label, null, null);
289
 
                    action.gicon = tally.icon.gicon;
290
 
                    action.activate.connect (()=>{
291
 
                        notebook.set_current_page (notebook.page_num (tab));
292
 
                    });
293
 
                    menu.add (action);
294
 
                    counter++;
295
 
                }
296
 
                context_menu (menu);
 
302
                var menu = get_context_action ();
297
303
                var popup = menu.create_menu (null, false);
298
304
                popup.show ();
299
305
                popup.attach_to_widget (this, null);