Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 May 2007 20:52:51 GMT
From:      Ivan Voras <ivoras@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 120077 for review
Message-ID:  <200705192052.l4JKqpPa076892@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=120077

Change 120077 by ivoras@ivoras_beastie on 2007/05/19 20:51:54

	* Separate basic window UI support in a separate class (BaseWin)
	* Add "Help" button to MainWin

Affected files ...

.. //depot/projects/soc2007/ivoras_finstall/installer/basewin.py#1 add
.. //depot/projects/soc2007/ivoras_finstall/installer/finstall.py#6 edit
.. //depot/projects/soc2007/ivoras_finstall/installer/glade/mainwin.glade#5 edit

Differences ...

==== //depot/projects/soc2007/ivoras_finstall/installer/finstall.py#6 (text+ko) ====

@@ -2,8 +2,9 @@
 from types import MethodType
 import gtk, gtk.gdk, gtk.glade
 
+from basewin import BaseWin
 
-class MainWin:
+class MainWin(BaseWin):
 
 	# Configured tracks
 	Steps_Novice = [
@@ -13,10 +14,8 @@
 
 
 	def __init__(self):
+		BaseWin.__init__(self, "mainwin")
 		self.tile_xml = None	# will be used for tiles
-		self.xml = gtk.glade.XML("glade/mainwin.glade")
-		self.window = self.xml.get_widget("mainwin")
-		self.xml.signal_autoconnect(self._get_event_handlers(None))
 		self["img_logo"].set_from_file("img/logo.jpg")
 		# img_logo stretches the window vertically, so calling window.set_position() has no affect
 		self._center_window(self.window)
@@ -39,41 +38,6 @@
 			return self.xml.get_widget(key)
 
 
-	def _center_window(self, window):
-		"""Centers window on screen """
-		ws = window.get_size()
-		window.move((gtk.gdk.screen_width() - ws[0]) / 2, (gtk.gdk.screen_height() - ws[1]) / 2)
-
-
-	def _get_event_handlers(self, prefix):
-		"""Returns a dictionary of form {'on_method' : self.on_method} for all
-		methods of self begining with "on_". This is useful for binding signal
-		handlers."""
-		dict = {}
-		if prefix != None:
-			prefix2 = "%s_on_" % prefix
-		else:
-			prefix2 = "on_"
-		for name in dir(self):
-			if not name.startswith(prefix2):
-				continue
-			attr = getattr(self, name)
-			if isinstance(attr, MethodType):
-				dict[name[len(prefix2)-3:]] = attr
-		return dict
-
-
-	def _load_label(self, file_name):
-		"""Returns the content of a text/* file with formatting replacements
-		so it looks decent when Pango renders it"""
-		return file("text/%s" % file_name).read().replace("\n", " ").replace("<br>", "\n").replace("\n ", "\n")
-
-
-	def _clear_container(self, cont):
-		for child in cont.get_children():
-			cont.remove(child)
-
-
 	def _load_tile(self, tile_name):
 		"""Loads a tile by it's name and integrates it in the wizard window"""
 		self._clear_container(self.xml.get_widget("vbox_container"))
@@ -145,7 +109,7 @@
 
 	def intro_on_next(self):
 		if self["radio_novice"].get_active():
-			pass # The default track is already Novice
+			pass # The default track is Novice
 		elif self["radio_standard"].get_active():
 			print "standard"
 		elif self["radio_expert"].get_active():

==== //depot/projects/soc2007/ivoras_finstall/installer/glade/mainwin.glade#5 (text+ko) ====

@@ -33,6 +33,7 @@
             <child>
               <widget class="GtkVBox" id="vbox_container">
                 <property name="width_request">530</property>
+                <property name="height_request">420</property>
                 <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="border_width">3</property>
@@ -159,6 +160,17 @@
               <widget class="GtkHButtonBox" id="hbuttonbox1">
                 <property name="visible">True</property>
                 <child>
+                  <widget class="GtkButton" id="button_help">
+                    <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">gtk-help</property>
+                    <property name="use_stock">True</property>
+                    <signal name="clicked" handler="on_button_help_clicked"/>
+                  </widget>
+                </child>
+                <child>
                   <widget class="GtkButton" id="button_cancel">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -166,6 +178,9 @@
                     <property name="label">gtk-cancel</property>
                     <property name="use_stock">True</property>
                   </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
                 <child>
                   <widget class="GtkButton" id="button_previous">
@@ -177,7 +192,7 @@
                     <signal name="clicked" handler="on_button_previous_clicked"/>
                   </widget>
                   <packing>
-                    <property name="position">1</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
                 <child>
@@ -190,7 +205,7 @@
                     <signal name="clicked" handler="on_button_next_clicked"/>
                   </widget>
                   <packing>
-                    <property name="position">2</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
               </widget>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705192052.l4JKqpPa076892>