[dev-console] - Interfaces fixed: memphis, logviewer
This commit is contained in:
parent
e28a1b27ee
commit
3dd0def247
@ -23,49 +23,78 @@ import gtk
|
||||
sys.path.append(os.path.dirname(__file__) + '/lib')
|
||||
sys.path.append(os.path.dirname(__file__) + '/interface')
|
||||
|
||||
# Console interfaces
|
||||
from xo import xo
|
||||
from memphis import memphis
|
||||
from logviewer import logviewer
|
||||
from terminal import terminal
|
||||
class Console:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# Main Window
|
||||
self.window = gtk.Window()
|
||||
self.window.set_title('Developer console')
|
||||
self.window.connect("delete-event", self._minimize_main_window)
|
||||
|
||||
self.default_width = gtk.gdk.screen_width() * 95 / 100
|
||||
self.default_height = gtk.gdk.screen_height() * 95 / 100
|
||||
self.default_mini_width = 150
|
||||
self.default_mini_height = 30
|
||||
|
||||
self.window.set_default_size(self.default_width, self.default_height)
|
||||
|
||||
self.window.realize()
|
||||
self.window.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
|
||||
# Minimize Window
|
||||
self.mini_fixed = gtk.Fixed()
|
||||
|
||||
# Minimize buttons
|
||||
button_restore = gtk.Button('Restore')
|
||||
button_restore.connect("clicked", self._restore_window)
|
||||
|
||||
button_quit = gtk.Button('Quit')
|
||||
button_quit.connect("clicked", gtk.main_quit)
|
||||
|
||||
mini_hbox = gtk.HBox()
|
||||
mini_hbox.pack_start(button_restore, True, True, 0)
|
||||
mini_hbox.pack_start(button_quit, True, True, 0)
|
||||
self.mini_fixed.add(mini_hbox)
|
||||
|
||||
# Notebook
|
||||
self.notebook = gtk.Notebook()
|
||||
|
||||
self._load_interface('xo', 'XO Resources')
|
||||
self._load_interface('memphis', 'Memphis')
|
||||
self._load_interface('logviewer', 'Log Viewer')
|
||||
self._load_interface('terminal', 'Terminal')
|
||||
|
||||
main_hbox = gtk.HBox()
|
||||
main_hbox.pack_start(self.notebook, True, True, 0)
|
||||
main_hbox.pack_start(self.mini_fixed, True, True, 0)
|
||||
main_hbox.show()
|
||||
|
||||
self.notebook.show()
|
||||
self.window.add(main_hbox)
|
||||
self.window.show()
|
||||
|
||||
self.mini_fixed.hide()
|
||||
|
||||
def _load_interface(self, interface, label):
|
||||
mod = __import__(interface)
|
||||
widget = mod.Interface().widget
|
||||
widget.show()
|
||||
|
||||
self.notebook.append_page(widget, gtk.Label(label))
|
||||
|
||||
window = gtk.Window()
|
||||
window.set_title('Developer console')
|
||||
window.connect("delete-event", gtk.main_quit)
|
||||
|
||||
width = gtk.gdk.screen_width() * 95 / 100
|
||||
height = gtk.gdk.screen_height() * 95 / 100
|
||||
|
||||
window.set_default_size(width, height)
|
||||
|
||||
window.realize()
|
||||
window.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
|
||||
# XO Interface
|
||||
xo_widget = xo.Interface().widget
|
||||
xo_widget.show()
|
||||
|
||||
# Memphis interface
|
||||
memphis_widget = memphis.Interface().widget
|
||||
memphis_widget.show()
|
||||
|
||||
# Log viewer interface
|
||||
logviewer_widget = logviewer.Interface().widget
|
||||
logviewer_widget.show()
|
||||
|
||||
# Terminal interface
|
||||
terminal_widget = terminal.Interface().widget
|
||||
terminal_widget.show()
|
||||
|
||||
# Notebook
|
||||
notebook = gtk.Notebook()
|
||||
notebook.append_page(xo_widget, gtk.Label('XO Resources'))
|
||||
notebook.append_page(memphis_widget, gtk.Label('Memphis'))
|
||||
notebook.append_page(logviewer_widget, gtk.Label('Log Viewer'))
|
||||
notebook.append_page(terminal_widget, gtk.Label('Terminal'))
|
||||
|
||||
notebook.show()
|
||||
|
||||
window.add(notebook)
|
||||
window.show()
|
||||
|
||||
def _restore_window(self, button):
|
||||
self.mini_fixed.hide_all()
|
||||
self.window.resize(self.default_mini_width, self.default_mini_height)
|
||||
self.notebook.show_all()
|
||||
|
||||
def _minimize_main_window(self, window, gdkevent):
|
||||
self.notebook.hide_all()
|
||||
window.resize(self.default_mini_width, self.default_mini_height)
|
||||
self.mini_fixed.show_all()
|
||||
return True
|
||||
|
||||
|
||||
CS = Console()
|
||||
gtk.main()
|
||||
|
@ -0,0 +1 @@
|
||||
from logviewer import Interface
|
@ -0,0 +1 @@
|
||||
from memphis import Interface
|
@ -37,9 +37,30 @@ class Interface:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# Our GtkTree (Treeview)
|
||||
# Our GtkTree (Treeview)
|
||||
self.treeview = gtk.TreeView()
|
||||
self.widget = self.treeview
|
||||
self.treeview.show()
|
||||
|
||||
self.button_start = gtk.Button('Start Memphis')
|
||||
self.button_stop = gtk.Button('Stop Memphis')
|
||||
|
||||
fixed = gtk.Fixed()
|
||||
fixed.add(self.button_start)
|
||||
fixed.add(self.button_stop)
|
||||
|
||||
vbox = gtk.VBox(False)
|
||||
vbox.set_border_width(5)
|
||||
vbox.pack_start(fixed, True, True, 0)
|
||||
|
||||
# Our GtkTree (Treeview)
|
||||
self.treeview = gtk.TreeView()
|
||||
t_width = gtk.gdk.screen_width()
|
||||
t_height = gtk.gdk.screen_height() * 83 / 100
|
||||
|
||||
self.treeview.set_size_request(t_width, t_height)
|
||||
vbox.pack_start(self.treeview, True, True, 0)
|
||||
vbox.show_all()
|
||||
self.widget = vbox
|
||||
|
||||
# Loading plugins
|
||||
self.plg = plugin.Plugin()
|
||||
@ -56,8 +77,12 @@ class Interface:
|
||||
# Creating a store model and loading process data to Treeview
|
||||
# self.store_data_types, ex [int, str, str, str, int,...]
|
||||
#self.store = gtk.TreeStore(*self.store_data_types)
|
||||
self.data = Data(self.treeview, self.plg.list)
|
||||
|
||||
self.data = Data(self, self.treeview, self.plg.list)
|
||||
|
||||
self.button_stop.hide()
|
||||
self.button_start.connect('clicked', self.data._start_memphis)
|
||||
self.button_stop.connect('clicked', self.data._stop_memphis)
|
||||
|
||||
class Data:
|
||||
|
||||
last_col_index = 0
|
||||
@ -66,8 +91,12 @@ class Data:
|
||||
store_data_types = []
|
||||
store_data_types_details = []
|
||||
|
||||
def __init__(self, treeview, plg_list):
|
||||
_running_status = False
|
||||
|
||||
def __init__(self, interface, treeview, plg_list):
|
||||
|
||||
self.interface = interface
|
||||
|
||||
# Top data types
|
||||
self.plg_list = plg_list
|
||||
|
||||
@ -101,9 +130,20 @@ class Data:
|
||||
self.store = gtk.TreeStore(*self.store_data_types)
|
||||
treeview.set_model(self.store)
|
||||
|
||||
# Update information every 1 second
|
||||
gobject.timeout_add(500, self.load_data, treeview)
|
||||
def _start_memphis(self, button):
|
||||
|
||||
# Update information every 1.5 second
|
||||
button.hide()
|
||||
self.interface.button_stop.show()
|
||||
self._running_status = True
|
||||
gobject.timeout_add(1500, self.load_data, self.treeview)
|
||||
|
||||
def _stop_memphis(self, button):
|
||||
|
||||
self._running_status = False
|
||||
button.hide()
|
||||
self.interface.button_start.show()
|
||||
|
||||
# Add a new column to the main treeview
|
||||
def add_column(self, column_name, index):
|
||||
cell = gtk.CellRendererText()
|
||||
@ -162,7 +202,7 @@ class Data:
|
||||
treeview.set_rules_hint(True)
|
||||
treeview.expand_all()
|
||||
|
||||
return True
|
||||
return self._running_status
|
||||
|
||||
def build_row(self, store, parent_iter, proc_data, pid):
|
||||
data = []
|
||||
|
@ -0,0 +1 @@
|
||||
from terminal import Interface
|
@ -149,7 +149,11 @@ class Multiple:
|
||||
|
||||
def __init__(self):
|
||||
self.notebook = gtk.Notebook()
|
||||
self.add_new_terminal()
|
||||
t_width = gtk.gdk.screen_width()
|
||||
t_height = gtk.gdk.screen_height() * 83 / 100
|
||||
self.notebook.set_size_request(t_width, t_height)
|
||||
|
||||
self.add_new_terminal()
|
||||
|
||||
open_terminal = gtk.Button('Open a new terminal')
|
||||
open_terminal.connect("clicked", self.add_new_terminal)
|
||||
|
@ -0,0 +1 @@
|
||||
from xo import Interface
|
Loading…
Reference in New Issue
Block a user