mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-26 10:03:54 +03:00
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:
parent
108fa864d7
commit
71f54c0112
@ -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
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user