Beispiel #1
0
 def __init__(self, parent, inputUuid, parentWin=None, inputSaveMode=IlUtil.NS):
     # ---data initiailize---
     # init data
     self.saveMode = inputSaveMode
     self.parent = parent
     self.uuid = inputUuid
     # init ssml
     ssml.init(IlUtil.SetupModuleDic[self.uuid])
     # ---ui initiailize---
     # initiailize locale
     gettext.bindtextdomain(IlUtil.RcDomain, IlUtil.LocaleDir)
     gettext.textdomain(IlUtil.RcDomain)
     gettext.install(IlUtil.RcDomain, IlUtil.LocaleDir, unicode=1)
     # create window
     window = gtk.Window(gtk.WINDOW_TOPLEVEL)
     window.connect("delete_event", self.delete_event)
     window.connect("destroy", self.destroy)
     window.set_size_request(IlUtil.mainW, IlUtil.mainH)
     window.set_resizable(False)
     window.set_modal(True)
     window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
     window.set_title(_("Input Method Settings"))
     window.set_keep_above(True)
     if parentWin != None:
         window.set_transient_for(parentWin)
     if inputSaveMode == IlUtil.IS:
         window.set_decorated(False)
     self.window = window
     # create main box
     mainBox = gtk.VBox(False)
     mainBox.set_border_width(IlUtil.padW)
     window.add(mainBox)
     # lable
     titleLb = gtk.Label(_(ssml.getname()))
     titleAlign = gtk.Alignment(0.5, 0.5, 0, 0)
     titleAlign.add(titleLb)
     mainBox.pack_start(titleAlign, False, True)
     # setup widget
     self.setupWidget = ssml.getwidget()
     ssml.loadconfig()
     mainBox.pack_start(self.setupWidget)
     # create buttons box
     btnsBox = gtk.HBox(False, IlUtil.padW * 3)
     btnsBox.set_size_request(IlUtil.mainW, IlUtil.botH)
     btnsBox.set_border_width(IlUtil.padW * 3)
     mainBox.pack_start(btnsBox, False, False)
     # ok btn
     okBtn = gtk.Button(_("Apply"))
     okBtn.set_size_request(IlUtil.btnW, IlUtil.btnH)
     okBtn.connect("button-press-event", self.onOkPressed)
     okAlign = gtk.Alignment(1, 0.5, 0, 0)
     okAlign.add(okBtn)
     btnsBox.pack_start(okAlign, True, True)
     # cancel btn
     cancelBtn = gtk.Button(_("Cancel"))
     cancelBtn.set_size_request(IlUtil.btnW, IlUtil.btnH)
     cancelBtn.connect("button-press-event", self.onCancelPressed)
     cancelAlign = gtk.Alignment(1, 0.5, 0, 0)
     cancelAlign.add(cancelBtn)
     btnsBox.pack_start(cancelAlign, False, True)
     # show all ui
     self.window.show_all()
Beispiel #2
0
    def __init__(self,parent,inputIl,inputKb,inputImInfoDic={},\
                 parentWin=None,inputPage=IlUtil.AddRmImPage,inputSaveMode=IlUtil.NS):
        
        #class variables
        self.curIl=inputIl
        self.curKb=inputKb          #No use now, prepare for keyboard checking
        self.curImInfoDic={}
        self.parent=parent
        self.window=None
        self.saveMode=inputSaveMode
        self.imTv=None

        #---data initialize---

        if inputImInfoDic=={} or inputImInfoDic==None:
            self.curImInfoDic=IlUtil.getImInfoDicWithLang(inputIl).copy()
        else:
            self.curImInfoDic=inputImInfoDic.copy()

        #initialize ssml
        ssml.init(PanelSetupModule);

        #---ui initialize---

        #initiailize locale
        gettext.bindtextdomain(IlUtil.RcDomain,IlUtil.LocaleDir)
        gettext.textdomain(IlUtil.RcDomain)
        gettext.install(IlUtil.RcDomain,IlUtil.LocaleDir,unicode=1)

        #main window
        window=gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.connect("delete_event",self.delete_event)
        window.connect("destroy",self.destroy)
        window.set_size_request(IlUtil.mainW,IlUtil.mainH)
        window.set_resizable(False)
        window.set_modal(True)
        window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        window.set_title(_("Advanced Input Language Settings"))
        window.set_keep_above(True)
        if parentWin!=None:
            window.set_transient_for(parentWin)
        if inputSaveMode==IlUtil.IS:
            window.set_decorated(False)
        self.window=window

        #main vbox
        mainBox=gtk.VBox(False,IlUtil.padW)
        mainBox.set_border_width(IlUtil.padW)
        self.window.add(mainBox)

        #--im notebook--
        imNotebook=gtk.Notebook()
        self.imNotebook=imNotebook
        mainBox.pack_start(self.imNotebook,True,True)

        #-add/remove input method page-
        addRmImBox=gtk.VBox(False,IlUtil.padW)
        addRmImBox.set_border_width(IlUtil.padW)
        addRmPageLb=gtk.Label(_("Add/Remove Input Method"))
        self.imNotebook.append_page(addRmImBox,addRmPageLb)

        #add/remove im label
        addRmLb=gtk.Label(_("The installed input method services:"))
        addRmLbAlign=gtk.Alignment(0,0,0,0)
        addRmLbAlign.add(addRmLb)
        addRmImBox.pack_start(addRmLbAlign,False,False)

        #add/remove im treeview
        sw=gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        addRmImBox.pack_start(sw,True,True)
        model=self.createImModel(inputIl)
        self.imTv=gtk.TreeView(model)
        self.imTv.set_rules_hint(True)
        #create name col
        column=gtk.TreeViewColumn()
        column.set_title(_("Name"))
        renderer=gtk.CellRendererPixbuf()
        column.pack_start(renderer,expand=False)
        column.add_attribute(renderer,'pixbuf',IconCol)
        renderer=gtk.CellRendererText()
        column.pack_start(renderer,expand=True)
        column.add_attribute(renderer,'text',NameCol)
        self.imTv.append_column(column)
        #create enable col
        renderer=gtk.CellRendererToggle();
        renderer.set_property("xalign",0.0)
        renderer.set_data("column",EnableCol)
        renderer.connect("toggled",self.onEnableToggled)
        column=gtk.TreeViewColumn(_("Enable"),renderer,active=EnableCol,inconsistent=IncCol)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(100)
        column.set_clickable(True)
        self.imTv.append_column(column)
        self.updateIncState()
        sw.add(self.imTv)

        #add/remove im btns
        addRmBtnsBox=gtk.HBox(False,IlUtil.padW)
        addRmBtnsBox.set_border_width(IlUtil.padW)
        addRmImBox.pack_start(addRmBtnsBox,False,False)

        expBtn=gtk.Button(_("Expand"))
        expBtn.set_size_request(IlUtil.btnW,IlUtil.btnH)
        expBtn.connect("button-press-event",self.onExpPressed)
        addRmBtnsBox.pack_start(expBtn,False,False)

        colBtn=gtk.Button(_("Collapse"))
        colBtn.set_size_request(IlUtil.btnW,IlUtil.btnH)
        colBtn.connect("button-press-event",self.onColPressed)
        addRmBtnsBox.pack_start(colBtn,False,False)

        enAllBtn=gtk.Button(_("Enable All"))
        enAllBtn.set_size_request(IlUtil.btnW,IlUtil.btnH)
        enAllBtn.connect("button-press-event",self.onEnAllPressed)
        addRmBtnsBox.pack_start(enAllBtn,False,False)

        disAllBtn=gtk.Button(_("Disable All"))
        disAllBtn.set_size_request(IlUtil.btnW,IlUtil.btnH)
        disAllBtn.connect("button-press-event",self.onDisAllPressed)
        addRmBtnsBox.pack_start(disAllBtn,False,False)

        #-toolbar page-
        self.setupWidget=ssml.getwidget()
        ssml.loadconfig()
        self.setupWidget.show()
        toolPageLb=gtk.Label(_("Toolbar"))
        self.imNotebook.append_page(self.setupWidget,toolPageLb)
        
        #--bottom btns hbox--
        btnsBox=gtk.HBox(False,IlUtil.padW*3)
        btnsBox.set_border_width(IlUtil.padW*3)
        bbAlign=gtk.Alignment(1,0,0,0)
        bbAlign.add(btnsBox)
        mainBox.pack_start(bbAlign,False,False)

        #ok btn
        okBtn=gtk.Button(_("Apply"))
        okBtn.set_size_request(IlUtil.btnW,IlUtil.btnH)
        okBtn.connect("button-press-event",self.onOkPressed)
        btnsBox.pack_start(okBtn)
        
        #cancel btn
        cancelBtn=gtk.Button(_("Cancel"))
        cancelBtn.set_size_request(IlUtil.btnW,IlUtil.btnH)
        cancelBtn.connect("button-press-event",self.onCancelPressed)
        btnsBox.pack_start(cancelBtn)

        #show all ui
        self.window.show_all()

        #XXX:set current page must be called at the last,
        #    because it only works when all widgets in notebook are shown.
        self.imNotebook.set_current_page(inputPage)