summaryrefslogtreecommitdiffstats
path: root/initial_setup
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2013-01-17 14:35:30 +0100
committerMartin Sivak <msivak@redhat.com>2013-01-17 14:35:30 +0100
commit168e0379dfcdf6cba2be09d958ea6bbe1f197500 (patch)
tree2dd050b5844a42f8a65a06292546a31a8a11c37a /initial_setup
parent3d7cce6a292a405b90a053f1b4b12fd7cfd6064b (diff)
downloadfirstboot2-168e0379dfcdf6cba2be09d958ea6bbe1f197500.tar.gz
firstboot2-168e0379dfcdf6cba2be09d958ea6bbe1f197500.tar.xz
firstboot2-168e0379dfcdf6cba2be09d958ea6bbe1f197500.zip
Fix a typo in project name and add some files under version control
Diffstat (limited to 'initial_setup')
-rw-r--r--initial_setup/Makefile66
-rw-r--r--initial_setup/__init__.py0
-rw-r--r--initial_setup/gui/__init__.py0
-rw-r--r--initial_setup/gui/__main__.py41
-rw-r--r--initial_setup/gui/gui.py46
-rw-r--r--initial_setup/gui/hubs/__init__.py1
-rw-r--r--initial_setup/gui/hubs/initial_setup.glade112
-rw-r--r--initial_setup/gui/hubs/initial_setup.py58
-rw-r--r--initial_setup/gui/spokes/__init__.py0
9 files changed, 324 insertions, 0 deletions
diff --git a/initial_setup/Makefile b/initial_setup/Makefile
new file mode 100644
index 0000000..c3919fc
--- /dev/null
+++ b/initial_setup/Makefile
@@ -0,0 +1,66 @@
+# 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}/pyanaconda/isys/.libs:${ANACONDA_PATH}/widgets/python/:${ANACONDA_PATH}/widgets/src/.libs/:${ANACONDA_PATH} \
+ LD_LIBRARY_PATH=${ANACONDA_PATH}/widgets/src/.libs \
+ UIPATH=gui/:${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 \
+ 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=gui/:${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/initial_setup/__init__.py b/initial_setup/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/initial_setup/__init__.py
diff --git a/initial_setup/gui/__init__.py b/initial_setup/gui/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/initial_setup/gui/__init__.py
diff --git a/initial_setup/gui/__main__.py b/initial_setup/gui/__main__.py
new file mode 100644
index 0000000..af8c5e9
--- /dev/null
+++ b/initial_setup/gui/__main__.py
@@ -0,0 +1,41 @@
+import os
+
+# We need this so we can tell GI to look for overrides objects
+# also in anaconda source directories
+import gi.overrides
+for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"):
+ gi.overrides.__path__.insert(0, p)
+
+# set the root path to / so the imported spokes
+# know where to apply their changes
+from pyanaconda.constants import ROOT_PATH
+ROOT_PATH = "/"
+
+from pyanaconda.addons import collect_addon_paths
+
+addon_paths = ["/usr/share/initial-setup/modules", "/usr/share/anaconda/addons"]
+addon_module_paths = collect_addon_paths(addon_paths)
+
+# Too bad anaconda does not have modularized logging
+from pyanaconda import anaconda_log
+anaconda_log.init()
+
+# Prepare new data object
+from pyanaconda import kickstart
+data = kickstart.AnacondaKSHandler(addon_module_paths["ks"])
+
+# Import IS gui specifics
+import gui
+
+# Add addons to search paths
+gui.InitalSetupGraphicalUserInterface.update_paths(addon_module_paths)
+
+# Initialize the UI
+g = gui.InitalSetupGraphicalUserInterface(None, None, None)
+g.setup(data)
+
+# Start the application
+g.run()
+
+# Print the kickstart file
+print data
diff --git a/initial_setup/gui/gui.py b/initial_setup/gui/gui.py
new file mode 100644
index 0000000..ea280b3
--- /dev/null
+++ b/initial_setup/gui/gui.py
@@ -0,0 +1,46 @@
+from pyanaconda.ui.gui import QuitDialog, GUIObject, GraphicalUserInterface
+#from .product import productName, productVersion
+from .hubs import InitalSetupMainHub
+from pyanaconda.ui.gui.spokes import StandaloneSpoke
+import pyanaconda.ui.gui.spokes
+from pyanaconda.ui.common import collect, FirstbootSpokeMixIn
+import os
+from gi.repository import Gdk
+import logging
+from di import inject, usesclassinject
+
+# localization
+_ = lambda t: t
+N_ = lambda t: t
+
+productTitle = lambda: "Inital Setup of Fedora"
+isFinal = lambda: False
+
+class InitalSetupQuitDialog(QuitDialog):
+ MESSAGE = N_("Are you sure you want to quit the configuration process?\n"
+ "You might end up with unusable system if you do.")
+
+@inject(Gdk, productTitle = productTitle, isFinal = isFinal)
+class InitalSetupGraphicalUserInterface(GraphicalUserInterface):
+ """This is the main Gtk based firstboot interface. It inherits from
+ anaconda to make the look & feel as similar as possible.
+ """
+
+ screenshots_directory = "/tmp/initial-setup-screenshots"
+
+ @usesclassinject
+ def __init__(self, storage, payload, instclass):
+ GraphicalUserInterface.__init__(self, storage, payload, instclass,
+ productTitle, isFinal,
+ quitDialog = InitalSetupQuitDialog)
+
+ def _list_hubs(self):
+ return [InitalSetupMainHub]
+
+ basemask = "firstboot.gui"
+ basepath = os.path.dirname(__file__)
+ paths = GraphicalUserInterface.paths + {
+ "spokes": [(basemask + ".spokes.%s", os.path.join(basepath, "spokes"))],
+ "categories": [(basemask + ".categories.%s", os.path.join(basepath, "categories"))],
+ }
+
diff --git a/initial_setup/gui/hubs/__init__.py b/initial_setup/gui/hubs/__init__.py
new file mode 100644
index 0000000..b6f577d
--- /dev/null
+++ b/initial_setup/gui/hubs/__init__.py
@@ -0,0 +1 @@
+from initial_setup import InitalSetupMainHub
diff --git a/initial_setup/gui/hubs/initial_setup.glade b/initial_setup/gui/hubs/initial_setup.glade
new file mode 100644
index 0000000..75ff936
--- /dev/null
+++ b/initial_setup/gui/hubs/initial_setup.glade
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <!-- interface-requires AnacondaWidgets 1.0 -->
+ <object class="AnacondaHubWindow" id="summaryWindow">
+ <property name="startup_id">filler</property>
+ <property name="can_focus">False</property>
+ <property name="startup_id">filler</property>
+ <property name="mnemonics_visible">False</property>
+ <property name="focus_visible">False</property>
+ <property name="distribution">DISTRIBUTION SETUP</property>
+ <property name="window_name">INITAL SETUP</property>
+ <child internal-child="main_box">
+ <object class="GtkBox" id="AnacondaHubWindow-main_box1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child internal-child="nav_area">
+ <object class="GtkGrid" id="AnacondaHubWindow-nav_area1">
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="alignment">
+ <object class="GtkAlignment" id="AnacondaHubWindow-alignment1">
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <property name="xscale">0.5</property>
+ <child internal-child="action_area">
+ <object class="GtkBox" id="summaryWindow-actionArea">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child internal-child="scrolled_window">
+ <object class="GtkScrolledWindow" id="summaryWindow-scroll">
+ <property name="can_focus">True</property>
+ <property name="is_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox" id="buttonbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_bottom">6</property>
+ <child>
+ <object class="GtkButton" id="quitButton">
+ <property name="label" translatable="yes">_QUIT</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="continueButton">
+ <property name="label" translatable="yes">_FINISH CONFIGURATION</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">end</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/initial_setup/gui/hubs/initial_setup.py b/initial_setup/gui/hubs/initial_setup.py
new file mode 100644
index 0000000..a0f87db
--- /dev/null
+++ b/initial_setup/gui/hubs/initial_setup.py
@@ -0,0 +1,58 @@
+from pyanaconda.ui.gui.hubs import Hub
+from pyanaconda.ui.gui.spokes import Spoke
+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: issubclass(obj, Spoke) and obj.should_run("firstboot", None)))
+
+ print spokes
+ return spokes
+
+
+class InitalSetupMainHub(Hub):
+ uiFile = "initial_setup.glade"
+ builderObjects = ["summaryWindow"]
+ mainWidgetName = "summaryWindow"
+
+ 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.
+ candidate_spokes = collect_spokes(self.paths["spokes"])
+ spokes = [spoke for spoke in candidate_spokes \
+ if spoke.should_run("firstboot", self.data)]
+
+ for spoke in spokes:
+ ret.setdefault(spoke.category, [])
+ ret[spoke.category].append(spoke)
+
+ return ret
+
+ @property
+ def continueButton(self):
+ return self.builder.get_object("continueButton")
+
+ @property
+ def quitButton(self):
+ return self.builder.get_object("quitButton")
diff --git a/initial_setup/gui/spokes/__init__.py b/initial_setup/gui/spokes/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/initial_setup/gui/spokes/__init__.py