How to get previews from each childs in a notebook (Like in Terminolgy or sublime)



For example I have a window with a notebook widget and in this notebook I have two tabs which contains one vte widgets each The idea it to get a preview of each vte widgets (You know like in Terminology or sublime) here is the simple code I have so far:

#!/usr/bin/env python import
 gi import os
 gi.require_version('Gtk', '3.0')
 gi.require_version('Vte', '2.91')
 from gi.repository import Gtk
 from gi.repository import Vte
 from gi.repository import GLib
 from gi.repository import Gdk
 from gi.repository import GdkPixbuf
 win = Gtk.Window()
 win.connect('delete-event', Gtk.main_quit)
 notebook = Gtk.Notebook()
 win.add(notebook)
 directory = os.environ['HOME']
 env=[]
 term1 = Vte.Terminal()
 term1.spawn_sync( Vte.PtyFlags.DEFAULT, directory, ["/bin/bash"],
env, GLib.SpawnFlags.CHILD_INHERITS_STDIN | GLib.SpawnFlags.SEARCH_PATH,
                   None, None, )
 term1.show()
 term2 = Vte.Terminal()
 term2.spawn_sync( Vte.PtyFlags.DEFAULT, directory, ["/bin/bash"],
env, GLib.SpawnFlags.CHILD_INHERITS_STDIN | GLib.SpawnFlags.SEARCH_PATH,
                   None, None, )
 term2.show()
 notebook.append_page(term1)
 notebook.append_page(term2)
 notebook.show()
 notebook.next_page()

 def manage_key_press_events_cb(widget, event):
   keyval = event.keyval
if ((event.state & (Gdk.ModifierType.CONTROL_MASK|Gdk.ModifierType.SHIFT_MASK)) == (Gdk.ModifierType.CONTROL_MASK|Gdk.ModifierType.SHIFT_MASK)):
     if keyval == Gdk.KEY_O:
       for i in range(notebook.get_n_pages()):
         child = notebook.get_nth_page(i)
         child.get_window().show()
         width = child.get_allocation().width
         height = child.get_allocation().height
         x = child.translate_coordinates(notebook,0,0)[0]
         y = child.translate_coordinates(notebook,0,0)[1]
p = Gdk.pixbuf_get_from_window(child.get_window(), 0, 0, width, height)
         p.savev(str(i) + ".png", "png", (), ())
       return True
     else:
       return False
   else:
     return False

 win.show_all()

 win.connect('key-press-event', manage_key_press_events_cb)
 Gtk.main()

In one tab I launch htop and in another I launch glances (the applications doesn't matter, they just help me to differenciate the previews)

The problem I cannot solve is that each preview represents the currently focused tab. What ever I do I am not abble to have a preview of the
tabs that are not the current one.

FYI I use python in order to give you a simple working example but initialy I have this problem with ruby from the ruby-gnome2 project. So I guess this is not
related to python or ruby.

Regards

Cedlemo



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]