This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 src/kvm-launcher       |  185 ++++++++++++++++++++++---------------
 src/kvm-launcher.glade |  234 ++++++++++++++++++++++++++++++++++++------------
 src/kvm-launcher.py    |  110 ----------------------
 3 files changed, 288 insertions(+), 241 deletions(-)

New commits:
commit 8dca1ae825eb557887147b48f0f96b23105adc4c
Author: Bob Spencer <[email protected]>
Date:   Tue Jan 13 12:19:54 2009 -0700

    Updated look of glade.  Added cancel button and link button
    Hooked up cancel button in code.
    To do: hook up link button, get app icon, get KVM/QEMU icons,
    get Browse btn to not show an error


Diff in this email is a maximum of 400 lines.
diff --git a/src/kvm-launcher b/src/kvm-launcher
index cb8295f..7af465f 100755
--- a/src/kvm-launcher
+++ b/src/kvm-launcher
@@ -1,87 +1,122 @@
-#!/usr/bin/python -ttu
+#!/usr/bin/python -tt
 # vim: ai ts=4 sts=4 et sw=4
+
+#    Copyright (c) 2009 Intel Corporation
 #
-# kvm-launcher contains main().  
-# The starting point of the application
-#
-# Copyright (C) 2009, Intel Corporation.
+#    This program is free software; you can redistribute it and/or modify it
+#    under the terms of the GNU General Public License as published by the Free
+#    Software Foundation; version 2 of the License
 #
-# Author: Praj Karur Mohan <[email protected]>\nBob Spencer 
<[email protected]>
-# 
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#     * Redistributions of source code must retain the above copyright
-#       notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above copyright
-#       notice, this list of conditions and the following disclaimer in the
-#       documentation and/or other materials provided with the distribution.
-#     * Neither the name of the PG_ORGANIZATION nor the
-#       names of its contributors may be used to endorse or promote products
-#       derived from this software without specific prior written permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS-IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
+#    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 General Public License
+#    for more details.
 #
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc., 59
+#    Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import string
+import gettext
+import gnome
+import gobject
+import gtk
+import gtk.glade
+import os
+import pygtk
+import re
+import shutil
 import sys
-from sample_utils import printUserInfo
+import time
+import traceback
+import signal
 
-from optparse import OptionParser
+debug = False
+
+_ = gettext.lgettext
+
+ENVIRONMENT_VARS = {
+    'PATH' : '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+}
+
+class App(object):
+    """This is our main"""
+    def __init__(self):
+        self.gladefile = "kvm-launcher.glade" #os.path.join(self.sdk.path, 
"kvm-launcher.glade")
+        if not os.path.isfile(self.gladefile):
+            raise IOError, "Glade file is missing from: %s" % self.gladefile
+        gnome.init('kvm-launcher', "1.0", properties = {'app-datadir':""})
+        self.widgets = gtk.glade.XML (self.gladefile, 'main')
+        dic = {"on_main_destroy_event" : self.quit,
+                "on_main_key_press_event" : self.main_key_press_event,
+                "on_cancel_clicked" : self.cancel_clicked,
+                "on_browse_clicked" : self.browse_clicked,
+                "on_launch_kvm_clicked" : self.launch_kvm_clicked,
+                "on_launch_qemu_clicked" : self.launch_qemu_clicked
+              }
+        self.widgets.signal_autoconnect(dic)
+
+        main_window = self.widgets.get_widget("main")
+        main_window.set_resizable(True)
+        main_window.show_all()
+        self.image_path_entry = self.widgets.get_widget("image_path_entry")
+
+    def run(self):
+        gtk.main()
+
+    def quit(self, value):
+        gtk.main_quit()
+
+    def main_key_press_event(self, widget, event):
+        if event.keyval == gtk.keysyms.Escape:
+            self.cancel_clicked(widget)
+
+
+    def cancel_clicked(self, widget):
+        dialog = gtk.MessageDialog(flags=gtk.MESSAGE_QUESTION, 
buttons=gtk.BUTTONS_OK_CANCEL, 
+                                   message_format="Do you want to exit?")
+        if dialog.run() == gtk.RESPONSE_OK:
+            gtk.main_quit()
+        dialog.destroy()
+
+
+    def browse_clicked(self, widget):
+        dialog = gtk.FileChooserDialog(action=gtk.FILE_CHOOSER_ACTION_OPEN, 
title=_("Choose an image"))
+        dialog.set_current_folder("~/")
+        dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
+        dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+        filter_image = gtk.FileFilter()
+        filter_image.set_name("Image files");
+        filter_image.add_pattern("*.img");
+        dialog.add_filter(filter_image);
+        filter_any = gtk.FileFilter();
+        filter_any.set_name("Any files");
+        filter_any.add_pattern("*");
+        dialog.add_filter(filter_any);
+        if dialog.run() == gtk.RESPONSE_OK:
+            live_img = dialog.get_filename()
+            self.image_path_entry.set_text(live_img)
+            dialog.destroy()
+        else:
+            dialog.destroy()
+            return
+
+    def launch_kvm_clicked(self, widget):
+        # boot the live usb image in KVM in background
+        image_path = self.image_path_entry.get_text()
+        print "Launching KVM: %s" % image_path
+        os.popen("kvm -no-acpi -m 512 -hda " + image_path + \
+                 " -hdb /var/lib/moblin-image-creator/kvm/mic_vm_share.img 
-boot c &")
+        
+    def launch_qemu_clicked(self, widget):
+        image_path = self.image_path_entry.get_text()
+        print "Launching QEMU: %s" % image_path
+        os.popen("qemu-kvm -no-acpi -m 512 -hda " + image_path + \
+                 " -hdb /var/lib/moblin-image-creator/kvm/mic_vm_share.img 
-boot c &")
 
-# TBD: how to document in python
-# SECTION:main
-# @short_description: Parses cmd-line. Runs simple console app.
-#
-# @see_also: #For more information, see <ulink role="online-location" 
-#             url="http://moblin.org";>http://moblin.org</ulink>
-# @stability: Stable
-#
-# Parses command-line.  Starts sample console app.
-#
 def main():
-    if sys.hexversion < 0x2040000:
-        print >> sys.stderr, ("Error: %s depends on a Python version of " \
-                                  "at least 2.4!") % (sys.argv[0])
-        sys.exit(1)
-
-    print ("\nProgram: Moblin KVM Launcher\n");
-    name = ""
-    age = -1
-    if len(sys.argv) > 1:
-        (options,args) = parseCommandLine()
-        name = options.name 
-        age = options.age   
-
-    while name == "":
-        name = raw_input ("Please enter your name: ")
-        name.strip()
-    while age <0 or age > 200:
-        try:
-            age = int(raw_input ("Please enter your age: "))
-        except ValueError:
-            continue
-    printUserInfo(name, age)
-    return 0
-
-def parseCommandLine():
-    parser = OptionParser()
-    parser.add_option("-n", "--name", dest="name", default="",    
-                      help="Your name")
-    parser.add_option("-a", "--age", type="int", dest="age", default=-1,
-                      help="Your age", type="int")
-    (options, args) = parser.parse_args()
-    return options, args
+    App().run()
+
 
 if __name__ == '__main__':
+    if debug: sys.excepthook = print_exc_plus
     sys.exit(main())
diff --git a/src/kvm-launcher.glade b/src/kvm-launcher.glade
index cd660cf..beb0c84 100755
--- a/src/kvm-launcher.glade
+++ b/src/kvm-launcher.glade
@@ -1,97 +1,219 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Mon Jan 12 22:07:11 2009 -->
+<!--Generated with glade3 3.4.5 on Tue Jan 13 12:06:09 2009 -->
 <glade-interface>
   <widget class="GtkWindow" id="main">
     <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+    <property name="title" translatable="yes">Moblin KVM Launcher</property>
+    <property name="window_position">GTK_WIN_POS_CENTER</property>
+    <signal name="key_press_event" handler="on_main_key_press_event"/>
     <signal name="destroy" handler="on_main_destroy_event"/>
     <child>
-      <widget class="GtkVBox" id="vbox1">
+      <widget class="GtkAlignment" id="alignment1">
         <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+        <property name="top_padding">10</property>
+        <property name="bottom_padding">10</property>
+        <property name="left_padding">10</property>
+        <property name="right_padding">10</property>
         <child>
-          <widget class="GtkLabel" id="launcher_label1">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-            <property name="label" translatable="yes">KVM Launcher</property>
-          </widget>
-        </child>
-        <child>
-          <widget class="GtkHBox" id="hbox2">
+          <widget class="GtkVBox" id="vbox1">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+            <property name="spacing">10</property>
             <child>
-              <widget class="GtkLabel" id="path">
+              <widget class="GtkLabel" id="launcherLabel">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Path</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">To start the Moblin 
v2 operating system in a virtual environment first download a prebuilt Moblin 
v2 image to your local workstation, then enter the local path to the image.  
Online Moblin v2 images and descriptions can be found at the URL 
below.</property>
+                <property name="wrap">True</property>
+                <property name="width_chars">55</property>
               </widget>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
             </child>
             <child>
-              <widget class="GtkEntry" id="image_path_entry">
+              <widget class="GtkTable" id="table1">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+                <property name="n_rows">2</property>
+                <property name="n_columns">3</property>
+                <property name="column_spacing">6</property>
+                <property name="row_spacing">10</property>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="browse">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" 
translatable="yes">_Browse...</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_browse_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="image_path_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="pathLabel">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Local 
_Path:</property>
+                    <property name="use_underline">True</property>
+                    <property 
name="mnemonic_widget">image_path_entry</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="linkLabel">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Images 
online:</property>
+                    <property name="use_underline">True</property>
+                    <property name="justify">GTK_JUSTIFY_FILL</property>
+                    <property name="mnemonic_widget">linkBtn</property>
+                  </widget>
+                  <packing>
+                    <property name="x_options"></property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLinkButton" id="linkBtn">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" 
translatable="yes">http://git.moblin.org</property>
+                    <property name="relief">GTK_RELIEF_NONE</property>
+                    <property name="xalign">0</property>
+                    <property name="response_id">0</property>
+                    <property name="uri">http://glade.gnome.org</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="browse">
+              <widget class="GtkHSeparator" id="hseparator1">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Browse</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="on_browse_clicked"/>
               </widget>
               <packing>
+                <property name="expand">False</property>
                 <property name="position">2</property>
               </packing>
             </child>
-          </widget>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="GtkHBox" id="hbox1">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-            <child>
-              <widget class="GtkButton" id="launch_kvm">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Launch KVM</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="on_launch_kvm_clicked"/>
-              </widget>
-            </child>
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to