def popup_monitor_dialog(self, widget, data): def xmlesc(s): s = string.replace(s, "&", "&") s = string.replace(s, "<", "<") s = string.replace(s, ">", ">") return s (model, iter) = self.name_map['monitor_vender_list_treeview'].get_selection( ).get_selected() if not iter: return vender = model.get_value(iter, 0) if not self.mondb.has_key(vender): return xmlstr = '' for (m_name, dummy, m_vert, m_horiz) in self.mondb[vender]: xmlstr = xmlstr + '<row c0="%s" c1="%s" c2="%s"/>' % ( xmlesc(m_name), xmlesc(m_horiz), xmlesc(m_vert)) xmldoc = parseString('<?xml version="1.0"?><data><monlist>' + xmlstr + '</monlist></data>') self.mondlg = magicpopup.magicpopup( self, self.uixmldoc, _("Please choose your monitor here."), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, "monitor.dialog", "mondlg_") self.mondlg.topwin.set_size_request(600, 400) self.mondlg.fill_values(xmldoc.documentElement)
def popup_srcpos_dialog(self): valdoc = Document() self.srcpos_value_doc = valdoc topele = valdoc.createElement('data') valdoc.appendChild(topele) valtopele = valdoc.createElement('srcposlist') topele.appendChild(valtopele) try: for (pafile, dev, fstype, reldir, isofn) in CF.G.pkgarr_probe_result: rowele = valdoc.createElement('row') rowele.setAttribute('c0', pafile) rowele.setAttribute('c1', dev) rowele.setAttribute('c2', fstype) rowele.setAttribute('c3', '/' + reldir) rowele.setAttribute('c4', isofn) valtopele.appendChild(rowele) except: raise MiNotSatisfied( '''Can not get information from CF.G.pkgarr_probe_result TYPE %s VALUE: %s''' % (type(CF.G.pkgarr_probe_result), CF.G.pkgarr_probe_result)) self.srcpos_dialog = magicpopup.magicpopup( \ self, self.uixmldoc, _('You want fetch packages from...'), magicpopup.magicpopup.MB_OK, 'srcpos.dialog', 'srcpos_') self.srcpos_dialog.topwin.set_size_request(480, 320) self.srcpos_dialog.fill_values(topele)
def popup_xglines(self, widget, data): framexml = parseString( '<?xml version="1.0"?><frame type="in"><frame name="slot" type="out"/></frame>' ) self.gamebox = magicpopup.magicpopup(None, framexml, _('XGlines'), 0) self.gameobj = xglines('games', self.help_gamebox, self.close_gamebox) self.gameobj.widget.show() self.gamebox.name_map['slot'].add(self.gameobj.widget)
def btntheme_clicked(self, widget, data): xml_data = ''' <themedlg> <vbox> <label line_wrap="true" fill="true" text="((Click the button to choose the theme that you like.))"/> <hbox name="themes" expand="true" fill="true"> <image file="images/gnome-ccthemes.png" fill="true"/> </hbox> </vbox> </themedlg> ''' self.themedlg = magicpopup.magicpopup(self, xml_data, _('Theme Choice'), magicpopup.magicpopup.MB_OK, 'themedlg', 'theme') themesdoc = parse('/etc/gtk-2.0/themes.xml') themelist = themesdoc.getElementsByTagName('theme') rows = 2 thetable = gtk.Table(rows, (len(themelist) + rows - 1) / rows, True) thetable.set_col_spacings(4) thetable.set_row_spacings(4) left = 0 top = 0 for themenode in themelist: path = themenode.getAttribute('dir') pic = themenode.getAttribute('pic') if pic: thebutton = gtk.Button() theimage = gtk.Image() theimage.set_from_file('/etc/gtk-2.0/pics/' + pic) theimage.show() thebutton.add(theimage) thebutton.show() else: name = themenode.getAttribute('name') if not name: if path: name = path else: name = _('Default') thebutton = gtk.Button(name) thebutton.connect('clicked', self.theme_clicked, path) thetable.attach(thebutton, left, left + 1, top, top + 1, 0, 0, 0, 0) top = top + 1 if top == rows: top = 0 left = left + 1 thetable.show() self.themedlg.name_map['themes'].pack_start(thetable, True, True)
def popup_srcpos_dialog(self): valdoc = Document() self.srcpos_value_doc = valdoc topele = valdoc.createElement('data') valdoc.appendChild(topele) valtopele = valdoc.createElement('srcposlist') topele.appendChild(valtopele) for (pafile, dev, fstype, reldir, isofn) in CF.G.pkgarr_probe_result: rowele = valdoc.createElement('row') rowele.setAttribute('c0', pafile) rowele.setAttribute('c1', dev) rowele.setAttribute('c2', fstype) rowele.setAttribute('c3', '/' + reldir) rowele.setAttribute('c4', isofn) valtopele.appendChild(rowele) self.srcpos_dialog = magicpopup.magicpopup( \ self, self.uixmldoc, _('You want fetch packages from...'), magicpopup.magicpopup.MB_OK, 'srcpos.dialog', 'srcpos_') self.srcpos_dialogger.topwin.set_size_request(480, 320) self.srcpos_dialogger.fill_values(topele)
def popup_monitor_dialog(self, widget, data): def xmlesc(s): s = string.replace(s, "&", "&") s = string.replace(s, "<", "<") s = string.replace(s, ">", ">") return s (model, iter) = self.name_map['monitor_vender_list_treeview'].get_selection().get_selected() if not iter: return vender = model.get_value(iter, 0) if not self.mondb.has_key(vender): return xmlstr = '' for (m_name, dummy, m_vert, m_horiz) in self.mondb[vender]: xmlstr = xmlstr + '<row c0="%s" c1="%s" c2="%s"/>' % (xmlesc(m_name), xmlesc(m_horiz), xmlesc(m_vert)) xmldoc = parseString('<?xml version="1.0"?><data><monlist>' + xmlstr + '</monlist></data>') self.mondlg = magicpopup.magicpopup(self, self.uixmldoc, _("Please choose your monitor here."), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, "monitor.dialog", "mondlg_") self.mondlg.topwin.set_size_request(600, 400) self.mondlg.fill_values(xmldoc.documentElement)
def btntheme_clicked(self, widget, data): self.themedlg = magicpopup.magicpopup(self, self.uixml, _('Theme Choice'), magicpopup.magicpopup.MB_OK, 'themedlg', 'theme') themesdoc = parse('/etc/gtk-2.0/themes.xml') themelist = themesdoc.getElementsByTagName('theme') rows = 2 thetable = gtk.Table(rows, (len(themelist) + rows - 1) / rows, True) thetable.set_col_spacings(4) thetable.set_row_spacings(4) left = 0 top = 0 for themenode in themelist: path = themenode.getAttribute('dir') pic = themenode.getAttribute('pic') if pic: thebutton = gtk.Button() theimage = gtk.Image() theimage.set_from_file('/etc/gtk-2.0/pics/' + pic) theimage.show() thebutton.add(theimage) thebutton.show() else: name = themenode.getAttribute('name') if not name: if path: name = path else: name = _('Default') thebutton = gtk.Button(name) thebutton.connect('clicked', self.theme_clicked, path) thetable.attach(thebutton, left, left + 1, top, top + 1, 0, 0, 0, 0) top = top + 1 if top == rows: top = 0 left = left + 1 thetable.show() self.themedlg.name_map['themes'].pack_start(thetable, True, True)
def edit_entry(self, widget, data): (self.model, self.iter ) = self.name_map['bootlist_treeview'].get_selection().get_selected() if not self.iter: magicpopup.magicmsgbox(None, _('Please choose an entry to edit.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return label = self.model.get_value(self.iter, 1) device = self.model.get_value(self.iter, 2) default = self.model.get_value(self.iter, 3) self.edit_values = parseString( """<?xml version="1.0"?><data> <default>%s</default><o_default>%s</o_default> <label>%s</label><o_label>%s</o_label> <device>%s</device></data>""" % (default, default, label, label, device)) self.edit_dialog = magicpopup.magicpopup( self, self.uixmldoc, _('Edit a boot entry.'), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, 'bootentry.dialog', 'edit_') self.edit_dialog.fill_values(self.edit_values.documentElement) self.edit_dialog.name_map[CF.G.root_device].set_text(device)
def edit_entry(self, widget, data): (self.model, self.iter) = self.name_map['bootlist_treeview'].get_selection().get_selected() if not self.iter: magicpopup.magicmsgbox(None, _('Please choose an entry to edit.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return label = self.model.get_value(self.iter, 1) device = self.model.get_value(self.iter, 2) default = self.model.get_value(self.iter, 3) self.edit_values = parseString( """<?xml version="1.0"?><data> <default>%s</default><o_default>%s</o_default> <label>%s</label><o_label>%s</o_label> <device>%s</device></data>""" % (default, default, label, label, device)) self.edit_dialog = magicpopup.magicpopup(self, self.uixmldoc, _('Edit a boot entry.'), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, 'bootentry.dialog', 'edit_') self.edit_dialog.fill_values(self.edit_values.documentElement) self.edit_dialog.name_map[CF.G.root_device].set_text(device)
def popup_srcpos_dialog(self): valdoc = Document() self.srcpos_value_doc = valdoc topele = valdoc.createElement('data') valdoc.appendChild(topele) valtopele = valdoc.createElement('srcposlist') topele.appendChild(valtopele) try: for (pafile, dev, fstype, reldir, isofn) in CF.G.pkgarr_probe_result: rowele = valdoc.createElement('row') rowele.setAttribute('c0', pafile) rowele.setAttribute('c1', dev) rowele.setAttribute('c2', fstype) rowele.setAttribute('c3', '/' + reldir) rowele.setAttribute('c4', isofn) valtopele.appendChild(rowele) except: raise MiNotSatisfied('''Can not get information from CF.G.pkgarr_probe_result TYPE %s VALUE: %s''' % (type(CF.G.pkgarr_probe_result), CF.G.pkgarr_probe_result)) self.srcpos_dialog = magicpopup.magicpopup( \ self, self.uixmldoc, _('You want fetch packages from...'), magicpopup.magicpopup.MB_OK, 'srcpos.dialog', 'srcpos_') self.srcpos_dialog.topwin.set_size_request(480, 320) self.srcpos_dialog.fill_values(topele)
def popup_xglines(self, widget, data): framexml = parseString('<?xml version="1.0"?><frame type="in"><frame name="slot" type="out"/></frame>') self.gamebox = magicpopup.magicpopup(None, framexml, _('XGlines'), 0) self.gameobj = xglines('games', self.help_gamebox, self.close_gamebox) self.gameobj.widget.show() self.gamebox.name_map['slot'].add(self.gameobj.widget)