manager: Make code organization more readable

As has been done with other files, try to group similar functions in
commented blocks, and break apart massive __init__ functions into chunks.
This commit is contained in:
Cole Robinson 2009-11-28 20:49:44 -05:00
parent 108fa864d7
commit 71f54c0112
3 changed files with 523 additions and 471 deletions

View File

@ -27,11 +27,11 @@ import traceback
import os
import virtManager.addhardware
import virtManager.uihelpers as uihelpers
from virtManager.error import vmmErrorDialog
from virtManager.addhardware import vmmAddHardware
from virtManager.choosecd import vmmChooseCD
from virtManager.console import vmmConsolePages
from virtManager.manager import build_shutdown_button_menu
from virtManager.serialcon import vmmSerialConsole
from virtManager.graphwidgets import Sparkline
from virtManager import util as util
@ -285,7 +285,8 @@ class vmmDetails(gobject.GObject):
def init_menus(self):
# Shutdown button menu
build_shutdown_button_menu(self.config,
uihelpers.build_shutdown_button_menu(
self.config,
self.window.get_widget("control-shutdown"),
self.control_vm_shutdown,
self.control_vm_reboot,

File diff suppressed because it is too large Load Diff

View File

@ -230,3 +230,33 @@ def generate_macaddr(conn):
pass
return newmac
# Build toolbar shutdown button menu (manager and details toolbar)
def build_shutdown_button_menu(config, widget, shutdown_cb, reboot_cb,
destroy_cb):
icon_name = config.get_shutdown_icon_name()
widget.set_icon_name(icon_name)
menu = gtk.Menu()
widget.set_menu(menu)
rebootimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
shutdownimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
destroyimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
reboot = gtk.ImageMenuItem(_("_Reboot"))
reboot.set_image(rebootimg)
reboot.show()
reboot.connect("activate", reboot_cb)
menu.add(reboot)
shutdown = gtk.ImageMenuItem(_("_Shut Down"))
shutdown.set_image(shutdownimg)
shutdown.show()
shutdown.connect("activate", shutdown_cb)
menu.add(shutdown)
destroy = gtk.ImageMenuItem(_("_Force Off"))
destroy.set_image(destroyimg)
destroy.show()
destroy.connect("activate", destroy_cb)
menu.add(destroy)