summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2012-10-03 15:22:30 +0200
committerMartin Sivak <msivak@redhat.com>2012-10-03 15:22:30 +0200
commit85213fb5ba9c2ace55f071ea3e3ef611db625311 (patch)
tree79f0ac77949afeb625d4f7d79c1cb4552f2c0a7b
Firstboot user interface and hub inheriting from Anaconda
-rw-r--r--.gitignore6
-rw-r--r--firstboot/Makefile64
-rw-r--r--firstboot/gui/__init__.py0
-rw-r--r--firstboot/gui/__main__.py10
-rw-r--r--firstboot/gui/gui.py29
-rw-r--r--firstboot/gui/hubs/__init__.py1
-rw-r--r--firstboot/gui/hubs/firstboot.py45
-rw-r--r--firstboot/gui/spokes/__init__.py0
8 files changed, 155 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8db5ada
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.ropeproject
+*.pyc
+*.pyo
+~.~
+.#*
+
diff --git a/firstboot/Makefile b/firstboot/Makefile
new file mode 100644
index 0000000..f01bf4b
--- /dev/null
+++ b/firstboot/Makefile
@@ -0,0 +1,64 @@
+# Makefile.am for anaconda
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Martin Sivak <msivak@redhat.com>
+
+ANACONDA_PATH=${HOME}/Work/anaconda/firstboot
+
+# GUI TESTING
+rungui:
+ ANACONDA_DATA=${ANACONDA_PATH}/data \
+ ANACONDA_WIDGETS_OVERRIDES=${ANACONDA_PATH}/widgets/python \
+ ANACONDA_WIDGETS_DATA=${ANACONDA_PATH}/widgets/data \
+ ANACONDA_INSTALL_CLASSES=${ANACONDA_PATH}/pyanaconda/installclasses \
+ PYTHONPATH=.:${ANACONDA_PATH}:${ANACONDA_PATH}/pyanaconda/isys/.libs:${ANACONDA_PATH}/widgets/python/:${ANACONDA_PATH}/widgets/src/.libs/ \
+ LD_LIBRARY_PATH=${ANACONDA_PATH}/widgets/src/.libs \
+ UIPATH=${ANACONDA_PATH}/pyanaconda/ui/gui/ \
+ GI_TYPELIB_PATH=${ANACONDA_PATH}/widgets/src/ \
+ python -m gui
+
+runtui:
+ ANACONDA_DATA=${ANACONDA_PATH}/data \
+ ANACONDA_INSTALL_CLASSES=${ANACONDA_PATH}/pyanaconda/installclasses \
+ PYTHONPATH=.:${ANACONDA_PATH}:${ANACONDA_PATH}/pyanaconda/isys/.libs \
+ python -m tui
+
+runglade:
+ ANACONDA_DATA=${ANACONDA_PATH}/data \
+ ANACONDA_WIDGETS_OVERRIDES=${ANACONDA_PATH}/widgets/python \
+ ANACONDA_WIDGETS_DATA=${ANACONDA_PATH}/widgets/data \
+ ANACONDA_INSTALL_CLASSES=${ANACONDA_PATH}/pyanaconda/installclasses \
+ PYTHONPATH=.:${ANACONDA_PATH}:${ANACONDA_PATH}/pyanaconda/isys/.libs:${ANACONDA_PATH}/widgets/python/:${ANACONDA_PATH}/widgets/src/.libs/ \
+ LD_LIBRARY_PATH=${ANACONDA_PATH}/widgets/src/.libs \
+ UIPATH=${ANACONDA_PATH}/pyanaconda/ui/gui/ \
+ GI_TYPELIB_PATH=${ANACONDA_PATH}/widgets/src/ \
+ GLADE_CATALOG_SEARCH_PATH=${ANACONDA_PATH}/widgets/glade \
+ GLADE_MODULE_SEARCH_PATH=${ANACONDA_PATH}/widgets/src/.libs \
+ glade ${GLADE_FILE}
+
+runpy:
+ ANACONDA_DATA=${ANACONDA_PATH}/data \
+ ANACONDA_WIDGETS_OVERRIDES=${ANACONDA_PATH}/widgets/python \
+ ANACONDA_WIDGETS_DATA=${ANACONDA_PATH}/widgets/data \
+ ANACONDA_INSTALL_CLASSES=${ANACONDA_PATH}/pyanaconda/installclasses \
+ PYTHONPATH=.:${ANACONDA_PATH}:${ANACONDA_PATH}/pyanaconda/isys/.libs:${ANACONDA_PATH}/widgets/python/:${ANACONDA_PATH}/widgets/src/.libs/ \
+ LD_LIBRARY_PATH=${ANACONDA_PATH}/widgets/src/.libs \
+ UIPATH=${ANACONDA_PATH}/pyanaconda/ui/gui/ \
+ GI_TYPELIB_PATH=${ANACONDA_PATH}/widgets/src/ \
+ GLADE_CATALOG_SEARCH_PATH=${ANACONDA_PATH}/widgets/glade \
+ GLADE_MODULE_SEARCH_PATH=${ANACONDA_PATH}/widgets/src/.libs \
+ ipython
diff --git a/firstboot/gui/__init__.py b/firstboot/gui/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/firstboot/gui/__init__.py
diff --git a/firstboot/gui/__main__.py b/firstboot/gui/__main__.py
new file mode 100644
index 0000000..0006e41
--- /dev/null
+++ b/firstboot/gui/__main__.py
@@ -0,0 +1,10 @@
+import gui
+
+class O(object):
+ pass
+
+g = gui.FirstbootGraphicalUserInterface(None, None, None)
+data = O()
+g.setup(data)
+g.run()
+
diff --git a/firstboot/gui/gui.py b/firstboot/gui/gui.py
new file mode 100644
index 0000000..db87882
--- /dev/null
+++ b/firstboot/gui/gui.py
@@ -0,0 +1,29 @@
+from pyanaconda.ui.gui import GUIObject, GraphicalUserInterface
+#from .product import productName, productVersion
+from .hubs import FirstbootHub
+from pyanaconda.ui.gui.spokes import StandaloneSpoke
+import pyanaconda.ui.gui.spokes
+from pyanaconda.ui.common import collect, FirstbootSpokeMixIn
+import os.path
+
+class FirstbootGraphicalUserInterface(GraphicalUserInterface):
+ """This is the standard GTK+ interface we try to steer everything to using.
+ It is suitable for use both directly and via VNC.
+ """
+ def _list_hubs(self):
+ return [FirstbootHub]
+
+ @property
+ def basemask(self):
+ return "firstboot.gui"
+
+ @property
+ def paths(self):
+ firstboot_path = os.path.join(os.path.dirname(__file__), "spokes")
+
+ _anaconda_paths = GraphicalUserInterface.paths.fget(self)
+ _anaconda_paths["spokes"].append((self.basemask + ".spokes.%s",
+ os.path.join(self.basepath, "spokes")))
+ _anaconda_paths["categories"].append((self.basemask + ".categories.%s",
+ os.path.join(self.basepath, "categories")))
+ return _anaconda_paths
diff --git a/firstboot/gui/hubs/__init__.py b/firstboot/gui/hubs/__init__.py
new file mode 100644
index 0000000..d20b6cc
--- /dev/null
+++ b/firstboot/gui/hubs/__init__.py
@@ -0,0 +1 @@
+from firstboot import FirstbootHub
diff --git a/firstboot/gui/hubs/firstboot.py b/firstboot/gui/hubs/firstboot.py
new file mode 100644
index 0000000..82aa9ef
--- /dev/null
+++ b/firstboot/gui/hubs/firstboot.py
@@ -0,0 +1,45 @@
+from pyanaconda.ui.gui.hubs.summary import SummaryHub
+from pyanaconda.ui.common import collect
+import os
+
+def collect_spokes(mask_paths):
+ """Return a list of all spoke subclasses that should appear for a given
+ category. Look for them in files imported as module_path % basename(f)
+
+ :param mask_paths: list of mask, path tuples to search for classes
+ :type mask_paths: list of (mask, path)
+
+ :return: list of Spoke classes belonging to category
+ :rtype: list of Spoke classes
+
+ """
+ spokes = []
+ for mask, path in mask_paths:
+ spokes.extend(collect(mask, path,
+ lambda obj: hasattr(obj, "category")
+ and obj.category != None))
+
+ return spokes
+
+
+class FirstbootHub(SummaryHub):
+
+ def _collectCategoriesAndSpokes(self):
+ """collects categories and spokes to be displayed on this Hub
+
+ :return: dictionary mapping category class to list of spoke classes
+ :rtype: dictionary[category class] -> [ list of spoke classes ]
+ """
+
+ ret = {}
+
+ # Collect all the categories this hub displays, then collect all the
+ # spokes belonging to all those categories.
+ spokes = [spoke for spoke in collect_spokes(self.paths["spokes"]) \
+ if hasattr(spoke, "firstboot") and spoke.firstboot()]
+
+ for spoke in spokes:
+ ret[spoke.category] = spoke
+
+ return ret
+
diff --git a/firstboot/gui/spokes/__init__.py b/firstboot/gui/spokes/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/firstboot/gui/spokes/__init__.py