Esempio n. 1
0
File: gui.py Progetto: jmtd/debgtd
	def __init__(self,controller,gladefile):
		self.controller = controller
		self.wTree = gtk.glade.XML(gladefile,"triage_window")
		window = self.wTree.get_widget("triage_window")
		window.resize(640,400)

		# signals
		window.connect("destroy", lambda x: self.close())
		self.wTree.get_widget("closebutton").connect("clicked",
			lambda x: self.close())
		self.wTree.get_widget("applybutton").connect("clicked",
			self.apply_button)
		self.wTree.get_widget("nextaction").connect("activate",
			self.apply_button)
		self.wTree.get_widget("sleepbutton").connect("clicked",
			self.sleep_button)
		self.wTree.get_widget("ignorebutton").connect("clicked",
			self.ignore_button)
		gtk.link_button_set_uri_hook(lambda x,y: self.current_bug and \
			os.system("sensible-browser http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s &" \
			% self.current_bug['id']))
		# initialisation
		self.processed = 0
		self.target = 0
		self.current_bug = None
    def __init__(self):
        '''
        .. versionchanged:: 2.21
            Read glade file using ``pkgutil`` to also support loading from
            ``.zip`` files (e.g., in app packaged with Py2Exe).
        '''
        self._shutting_down = threading.Event()
        self.name = "microdrop.gui.main_window_controller"
        self.builder = None
        self.view = None
        self.label_control_board_status = None
        self.label_experiment_id = None
        self.label_device_name = None
        self.label_protocol_name = None
        self.checkbutton_realtime_mode = None
        self.menu_tools = None
        self.menu_view = None
        self.step_start_time = None
        self.step_timeout_id = None
        gtk.link_button_set_uri_hook(self.on_url_clicked)

        builder = gtk.Builder()
        # Read glade file using `pkgutil` to also support loading from `.zip`
        # files (e.g., in app packaged with Py2Exe).
        glade_str = pkgutil.get_data(__name__,
                                     'glade/text_input_dialog.glade')
        builder.add_from_string(glade_str)

        self.text_input_dialog = builder.get_object("window")
        self.text_input_dialog.textentry = builder.get_object("textentry")
        self.text_input_dialog.label = builder.get_object("label")
Esempio n. 3
0
    def __init__(self):
        gtk.VBox.__init__(self)

        self.table = gtk.Table(2, 2)
        self.pack_start(self.table)

        gtk.link_button_set_uri_hook(self.click_website)

        items = [_('Homepage'), _('Source URL'), _('Description')]
        for i, text in enumerate(items):
            label = gtk.Label()
            label.set_markup('<b>%s</b>' % text)

            self.table.attach(label,
                              0,
                              1,
                              i,
                              i + 1,
                              xoptions=gtk.FILL,
                              xpadding=10,
                              ypadding=5)

        self.homepage_button = gtk.LinkButton('http://ubuntu-tweak.com')
        self.table.attach(self.homepage_button, 1, 2, 0, 1)
        self.url_button = gtk.LinkButton('http://ubuntu-tweak.com')
        self.table.attach(self.url_button, 1, 2, 1, 2)
        self.description = gtk.Label(_('Description is here'))
        self.description.set_line_wrap(True)
        self.table.attach(self.description, 1, 2, 2, 3)
Esempio n. 4
0
    def __init__(self, parent, url):
        gtk.Dialog.__init__(self,
                            title=_("Flickr Uploader"),
                            parent=parent,
                            flags=gtk.DIALOG_NO_SEPARATOR,
                            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                     _("Continue"), gtk.RESPONSE_ACCEPT))
        vbox = gtk.VBox(spacing=8)
        vbox.set_border_width(8)

        label = gtk.Label(
            _("Postr needs to login to Flickr to upload your photos. "
              "Please click on the link below to login to Flickr."))
        label.set_line_wrap(True)
        vbox.add(label)

        # gtk.LinkButton is only in 2.10, so use a normal button if it isn't
        # available.
        if hasattr(gtk, "LinkButton"):
            gtk.link_button_set_uri_hook(on_url_clicked)
            button = gtk.LinkButton(url, _("Login to Flickr"))
        else:
            button = gtk.Button(_("Login to Flickr"))
            button.connect("clicked", on_url_clicked, url)
        vbox.add(button)

        self.vbox.add(vbox)
        self.show_all()
Esempio n. 5
0
    def __init__(self, parent, url):
        gtk.Dialog.__init__(self,
                            title=_("Yupoo Uploader"), parent=parent,
                            flags=gtk.DIALOG_NO_SEPARATOR,
                            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                     _("Continue"), gtk.RESPONSE_ACCEPT))
        vbox = gtk.VBox(spacing=8)
        vbox.set_border_width(8)
        
        label = gtk.Label(_("Postr needs to login to Yupoo to upload your photos. "
                          "Please click on the link below to login to Yupoo."))
        label.set_line_wrap(True)
        vbox.add(label)

        # gtk.LinkButton is only in 2.10, so use a normal button if it isn't
        # available.
        if hasattr(gtk, "LinkButton"):
            gtk.link_button_set_uri_hook(on_url_clicked)
            button = gtk.LinkButton(url, _("Login to Yupoo"))
        else:
            button = gtk.Button(_("Login to Yupoo"))
            button.connect("clicked", on_url_clicked, url)
        vbox.add(button)
        
        self.vbox.add(vbox)
        self.show_all()
Esempio n. 6
0
 def addContents(self):
     imageDir, retro = guiutils.getImageDir()
     imageType = "gif" if retro else "png"
     logoFile = os.path.join(imageDir, "texttest-logo." + imageType)
     logoPixbuf = gtk.gdk.pixbuf_new_from_file(logoFile)
     logo = gtk.Image()
     logo.set_from_pixbuf(logoPixbuf)
     logoFrame = gtk.Alignment(0.5, 0.5, 0.0, 0.0)
     logoFrame.set_padding(10, 10, 10, 10)
     logoFrame.add(logo)
     mainLabel = gtk.Label()
     mainLabel.set_markup("<span size='xx-large'>TextTest " +
                          texttest_version.version + "</span>\n")
     messageLabel = gtk.Label()
     message = "TextTest is an application-independent tool for text-based\nfunctional testing. This means running a batch-mode program\nin lots of different ways, and using the text output produced\nas a means of controlling the behaviour of that application."
     messageLabel.set_markup("<i>" + message + "</i>\n")
     messageLabel.set_justify(gtk.JUSTIFY_CENTER)
     # On Windows the default URI hook fails and causes trouble...
     # According to the docs you can set "None" here but that doesn't seem to work...
     gtk.link_button_set_uri_hook(lambda x, y: None)
     urlButton = gtk.LinkButton(self.website, self.website)
     urlButton.set_property("border-width", 0)
     urlButtonbox = gtk.HBox()
     urlButtonbox.pack_start(urlButton, expand=True, fill=False)
     urlButton.connect("clicked", self.urlClicked)
     licenseLabel = gtk.Label()
     licenseLabel.set_markup("<span size='small'>Copyright " + u'\xa9' +
                             " The authors</span>\n")
     self.dialog.vbox.pack_start(logoFrame, expand=False, fill=False)
     self.dialog.vbox.pack_start(mainLabel, expand=True, fill=True)
     self.dialog.vbox.pack_start(messageLabel, expand=False, fill=False)
     self.dialog.vbox.pack_start(urlButtonbox, expand=False, fill=False)
     self.dialog.vbox.pack_start(licenseLabel, expand=False, fill=False)
     self.dialog.set_resizable(False)
Esempio n. 7
0
    def __init__(self):
        '''
        .. versionchanged:: 2.21
            Read glade file using ``pkgutil`` to also support loading from
            ``.zip`` files (e.g., in app packaged with Py2Exe).

        .. versionchanged:: 2.31
            Remove control board status label; pack status labels in
            :class:`gtk.HBox` to allow other plugins to pack widgets
            horizontally adjacent.
        '''
        self._shutting_down = threading.Event()
        self.name = "microdrop.gui.main_window_controller"
        self.builder = None
        self.view = None
        self.label_experiment_id = None
        self.label_device_name = None
        self.label_protocol_name = None
        self.checkbutton_realtime_mode = None
        self.menu_tools = None
        self.menu_view = None
        self.step_start_time = None
        self.step_timeout_id = None
        gtk.link_button_set_uri_hook(self.on_url_clicked)

        builder = gtk.Builder()
        # Read glade file using `pkgutil` to also support loading from `.zip`
        # files (e.g., in app packaged with Py2Exe).
        glade_str = pkgutil.get_data(__name__, 'glade/text_input_dialog.glade')
        builder.add_from_string(glade_str)

        self.text_input_dialog = builder.get_object("window")
        self.text_input_dialog.textentry = builder.get_object("textentry")
        self.text_input_dialog.label = builder.get_object("label")
Esempio n. 8
0
 def addContents(self):
     logoFile = os.path.join(plugins.installationDir("images"), "texttest-logo.gif")
     logoPixbuf = gtk.gdk.pixbuf_new_from_file(logoFile)
     logo = gtk.Image()
     logo.set_from_pixbuf(logoPixbuf)
     logoFrame = gtk.Alignment(0.5, 0.5, 0.0, 0.0)
     logoFrame.set_padding(10, 10, 10, 10)
     logoFrame.add(logo)
     mainLabel = gtk.Label()
     mainLabel.set_markup("<span size='xx-large'>TextTest " + texttest_version.version + "</span>\n")
     messageLabel = gtk.Label()
     message = "TextTest is an application-independent tool for text-based\nfunctional testing. This means running a batch-mode program\nin lots of different ways, and using the text output produced\nas a means of controlling the behaviour of that application."
     messageLabel.set_markup("<i>" + message + "</i>\n")
     messageLabel.set_justify(gtk.JUSTIFY_CENTER)
     # On Windows the default URI hook fails and causes trouble...
     # According to the docs you can set "None" here but that doesn't seem to work...
     gtk.link_button_set_uri_hook(lambda x, y : None) 
     urlButton = gtk.LinkButton(self.website, self.website)
     urlButton.set_property("border-width", 0)
     urlButtonbox = gtk.HBox()
     urlButtonbox.pack_start(urlButton, expand=True, fill=False)
     urlButton.connect("clicked", self.urlClicked)
     licenseLabel = gtk.Label()
     licenseLabel.set_markup("<span size='small'>Copyright " + u'\xa9' + " The authors</span>\n")
     self.dialog.vbox.pack_start(logoFrame, expand=False, fill=False)
     self.dialog.vbox.pack_start(mainLabel, expand=True, fill=True)
     self.dialog.vbox.pack_start(messageLabel, expand=False, fill=False)
     self.dialog.vbox.pack_start(urlButtonbox, expand=False, fill=False)
     self.dialog.vbox.pack_start(licenseLabel, expand=False, fill=False)
     self.dialog.set_resizable(False)
Esempio n. 9
0
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Link Button")
        self.window.connect("delete_event", self.delete_event)
        self.window.set_border_width(12)

        link_button = gtk.LinkButton("http://mono-project.com/Accessibility", "Mono Accessibility Website")
        gtk.link_button_set_uri_hook(self.uri_hook)
        self.window.add(link_button)

        link_button.show()
        self.window.show()
 def __init__(self):
     self.doi = None
     self.node_scrolled_window = None
     self.node_information_window = gtk.Window()
     self.node_information_window.set_title("Article details")
     self.node_information_window.set_size_request(500, 300)
     self.vbox = gtk.VBox(False, 0)
     self.add_link_button()
     self.add_text_area()
     self.generate_node_scrolled_window()
     self.node_scrolled_window.show_all()
     self.add_request_doi_information_button()
     self.vbox.pack_start(self.node_scrolled_window, True, True, 0)
     self.node_information_window.add(self.vbox)
     self.node_information_window.show_all()
     gtk.link_button_set_uri_hook(open_url)
Esempio n. 11
0
 def __init__(self):
     self.doi = None
     self.nodescrolledwindow = None
     self.nodeinformationwindow = gtk.Window()
     self.nodeinformationwindow.set_title("Article details")
     self.nodeinformationwindow.set_size_request(500, 200)
     self.vbox = gtk.VBox(False, 0)
     self.addLinkButton()
     self.addTextArea()
     self.generateNodeScrolledWindow()
     self.nodescrolledwindow.show_all()
     self.addRequestDOIInformationButton()
     self.vbox.pack_start(self.nodescrolledwindow, True, True, 0)
     self.nodeinformationwindow.add(self.vbox)
     self.nodeinformationwindow.show_all()
     gtk.link_button_set_uri_hook(open_url)
Esempio n. 12
0
 def __init__(self):
     self.doi = None
     self.nodescrolledwindow = None
     self.nodeinformationwindow = gtk.Window()
     self.nodeinformationwindow.set_title("Article details")
     self.nodeinformationwindow.set_size_request(500, 200)
     self.vbox = gtk.VBox(False, 0)
     self.addLinkButton()
     self.addTextArea()
     self.generateNodeScrolledWindow()
     self.nodescrolledwindow.show_all()
     self.addRequestDOIInformationButton()
     self.vbox.pack_start(self.nodescrolledwindow, True, True, 0)
     self.nodeinformationwindow.add(self.vbox)
     self.nodeinformationwindow.show_all()
     gtk.link_button_set_uri_hook(open_url)
Esempio n. 13
0
 def __init__(self,procurador):
     
     self.procurador = procurador
     
     #Set the Glade file
     self.gladefile = "proc.glade"  
     self.wTree = gtk.glade.XML(self.gladefile) 
     
     self.janela_pal = self.wTree.get_widget("window3")
     
     #Create our dictionay and connect it
     dic = { 
            "on_window3_destroy" : lambda x:self.janela_pal.hide(),
            "on_pal_cancel_clicked" : lambda x:self.janela_pal.hide(),
            "on_pal_ok_clicked" : self.pal_ok, 
            
            "on_alt2_clicked" : self.pal_mostrar,
            "on_alt1_clicked" : self.pal_mostrar,
            
            "on_window1_destroy" : self.fechar,
            "on_window2_destroy" : self.fechar,
            "on_ok_clicked" : self.fechar,
             "on_botao_clicked" : self.fechar }
     
     self.wTree.signal_autoconnect(dic)
     
     self.texto = self.wTree.get_widget("texto")
     self.texto2 = self.wTree.get_widget("texto2")
     self.link = self.wTree.get_widget("link")
     self.pal = self.wTree.get_widget("pal")
     
     self.link.set_label("Mostrar Página")
     self.link.set_uri(self.procurador.retornar_html())
     
     novos = self.procurador.num_anterior - self.procurador.num_antanterior
     info = self.procurador.nome+"\n\n"\
             +"Agora: "+str(self.procurador.num_anterior)+" itens\n"\
             +"Antes: "+str(self.procurador.num_antanterior)+" itens"
                 
     self.texto.set_text(info+"\n\n"+str(novos)+" novo(s) itens achados!")
     
     self.texto2.set_text(info)
     
     self.janelaAchou = self.wTree.get_widget("window1")
     self.janelaNada = self.wTree.get_widget("window2")
     
     gtk.link_button_set_uri_hook(self.abrir_url)
Esempio n. 14
0
    def setup_ui (self):
        """
        Hold a source box, a mozilla browser and a destination box
        """
        self.can_translate = False

        # Source box
        hbox = gtk.HBox (spacing=6)
        label = gtk.Label ("URL:")
        label.show ()
        hbox.pack_start (label, False)

        self.source_url = gtk.Entry ()
        self.source_url.connect ('changed', self.on_source_url_changed)
        self.entry_activate_handler = self.source_url.connect ('activate', lambda *args: self.translate_button.clicked ())
        self.source_url.handler_block (self.entry_activate_handler)
        self.source_url.show ()
        hbox.pack_start (self.source_url)
        
        hbox.pack_start (self.source_url_buttons (), False)

        hbox.show ()
        self.layout.pack_start (hbox, False)

        # Browser
        self.browser = gtkmozembed.MozEmbed ()
        self.browser.connect ('net-stop', self.on_browser_net_stop)
        self.browser.show ()
        self.layout.pack_start (self.browser)

        # Destination box
        self.dest_url_box = gtk.EventBox ()
        self.dest_url_box.set_visible_window (False)
        self.dest_url_box.modify_bg (gtk.STATE_NORMAL, self.DESTINATION_COLOR)
        self.dest_url_box.set_sensitive (False)
        hbox = gtk.HBox (spacing=6)
        self.dest_url_box.add (hbox)

        self.dest_url = gtk.LinkButton ("", "Translated URL")
        self.dest_url.show ()
        gtk.link_button_set_uri_hook (self.dest_url_hook)
        hbox.pack_start (self.dest_url)
        
        hbox.pack_start (self.dest_url_buttons (), False)

        hbox.show ()
        self.layout.pack_start (self.dest_url_box, False)
Esempio n. 15
0
    def __init__(self, procurador):

        self.procurador = procurador

        #Set the Glade file
        self.gladefile = "proc.glade"
        self.wTree = gtk.glade.XML(self.gladefile)

        self.janela_pal = self.wTree.get_widget("window3")

        #Create our dictionay and connect it
        dic = {
            "on_window3_destroy": lambda x: self.janela_pal.hide(),
            "on_pal_cancel_clicked": lambda x: self.janela_pal.hide(),
            "on_pal_ok_clicked": self.pal_ok,
            "on_alt2_clicked": self.pal_mostrar,
            "on_alt1_clicked": self.pal_mostrar,
            "on_window1_destroy": self.fechar,
            "on_window2_destroy": self.fechar,
            "on_ok_clicked": self.fechar,
            "on_botao_clicked": self.fechar
        }

        self.wTree.signal_autoconnect(dic)

        self.texto = self.wTree.get_widget("texto")
        self.texto2 = self.wTree.get_widget("texto2")
        self.link = self.wTree.get_widget("link")
        self.pal = self.wTree.get_widget("pal")

        self.link.set_label("Mostrar Página")
        self.link.set_uri(self.procurador.retornar_html())

        novos = self.procurador.num_anterior - self.procurador.num_antanterior
        info = self.procurador.nome+"\n\n"\
                +"Agora: "+str(self.procurador.num_anterior)+" itens\n"\
                +"Antes: "+str(self.procurador.num_antanterior)+" itens"

        self.texto.set_text(info + "\n\n" + str(novos) +
                            " novo(s) itens achados!")

        self.texto2.set_text(info)

        self.janelaAchou = self.wTree.get_widget("window1")
        self.janelaNada = self.wTree.get_widget("window2")

        gtk.link_button_set_uri_hook(self.abrir_url)
    def __init__(self):
        self._shutting_down_latch = False
        self.name = "microdrop.gui.main_window_controller"
        self.builder = None
        self.view = None
        self.label_control_board_status = None
        self.label_experiment_id = None
        self.label_device_name = None
        self.label_protocol_name = None
        self.checkbutton_realtime_mode = None
        self.menu_tools = None
        self.menu_view = None
        gtk.link_button_set_uri_hook(self.on_url_clicked)

        builder = gtk.Builder()
        builder.add_from_file(glade_path().joinpath("text_input_dialog.glade"))
        self.text_input_dialog = builder.get_object("window")
        self.text_input_dialog.textentry = builder.get_object("textentry")
        self.text_input_dialog.label = builder.get_object("label")
Esempio n. 17
0
    def __init__(self):
        self._shutting_down = threading.Event()
        self.name = "microdrop.gui.main_window_controller"
        self.builder = None
        self.view = None
        self.label_control_board_status = None
        self.label_experiment_id = None
        self.label_device_name = None
        self.label_protocol_name = None
        self.checkbutton_realtime_mode = None
        self.menu_tools = None
        self.menu_view = None
        self.step_start_time = None
        self.step_timeout_id = None
        gtk.link_button_set_uri_hook(self.on_url_clicked)

        builder = gtk.Builder()
        builder.add_from_file(glade_path().joinpath("text_input_dialog.glade"))
        self.text_input_dialog = builder.get_object("window")
        self.text_input_dialog.textentry = builder.get_object("textentry")
        self.text_input_dialog.label = builder.get_object("label")
Esempio n. 18
0
    def __init__(self):
        gtk.VBox.__init__(self)

        self.table = gtk.Table(2, 2)
        self.pack_start(self.table)

        gtk.link_button_set_uri_hook(self.click_website)

        items = [_('Homepage'), _('Source URL'), _('Description')]
        for i, text in enumerate(items):
            label = gtk.Label()
            label.set_markup('<b>%s</b>' % text)

            self.table.attach(label, 0, 1, i, i + 1, xoptions = gtk.FILL, xpadding = 10, ypadding = 5)

        self.homepage_button = gtk.LinkButton('http://ubuntu-tweak.com')
        self.table.attach(self.homepage_button, 1, 2, 0, 1)
        self.url_button = gtk.LinkButton('http://ubuntu-tweak.com')
        self.table.attach(self.url_button, 1, 2, 1, 2)
        self.description = gtk.Label(_('Description is here'))
        self.description.set_line_wrap(True)
        self.table.attach(self.description, 1, 2, 2, 3)
Esempio n. 19
0
 def about_init(self):
     about = gtk.AboutDialog()
     about.set_name('PyGlossary')
     about.set_version(VERSION)
     about.set_authors(authors)
     about.set_comments(aboutText)
     #about.set_license('PyGlossary is licensed by GNU General Public License version 3 (or later)')
     vbox = about.get_children()[0].get_children()[0]
     try:
         link=gtk.LinkButton(homePage)
     except:## May be an old PyGTK version, that has not gtk.LinkButton
         about.set_website(homePage) ## A palin label (not link)
     else:
         vbox.pack_start(link, 0, 0)
         link.show()
         gtk.link_button_set_uri_hook(click_website) ## click_website defined in text_utils.py
     about.set_license(licenseText)
     about.set_wrap_license(True)
     about.connect('delete-event', self.about_close)
     buttons = about.get_children()[0].get_children()[1].get_children()## List of buttons of about dialogs
     buttons[2].connect('clicked', self.about_close) ## Fix the PyGTK bug that Close button does not work!
     about.set_logo(gtk.gdk.pixbuf_new_from_file(logo))
     self.about = about
Esempio n. 20
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bauble.classic. If not, see <http://www.gnu.org/licenses/>.

import gtk

import bauble.utils.desktop as desktop
from bauble.i18n import _


def _open_link(func, data=None):
    desktop.open(data)


gtk.link_button_set_uri_hook(_open_link)


class StringLinkButton(gtk.LinkButton):

    _base_uri = "%s"
    _space = "_"

    def __init__(self, title=_("Search"), tooltip=None):
        super(StringLinkButton, self).__init__("", title)
        if not tooltip:
            self.set_tooltip_text(title)
        else:
            self.set_tooltip_text(tooltip)

    def set_string(self, search):
Esempio n. 21
0
    def __init__(self, notebookinfo=None, port=8080, public=True, **opts):
        '''Constructor
		@param notebookinfo: the notebook location
		@param port: the http port to serve on
		@param public: allow connections to the server from other
		computers - if C{False} can only connect from localhost
		@param opts: options for L{WWWInterface.__init__()}
		'''
        gtk.Window.__init__(self)
        self.set_title('Zim - ' + _('Web Server'))  # T: Window title
        self.set_border_width(10)
        self.connect('destroy', lambda a: gtk.main_quit())
        self.interface_opts = opts
        self.httpd = None
        self._source_id = None

        # Widgets
        self.status_label = gtk.Label()
        self.status_label.set_markup('<i>' + _('Server not started') + '</i>')
        # T: Status in web server gui
        self.start_button = IconButton('gtk-media-play')
        self.start_button.connect('clicked', lambda o: self.start())
        self.stop_button = IconButton('gtk-media-stop')
        self.stop_button.connect('clicked', lambda o: self.stop())
        self.stop_button.set_sensitive(False)

        if gtk.gtk_version >= (2, 10):
            self.link_button = gtk.LinkButton('')
            self.link_button.set_sensitive(False)
            gtk.link_button_set_uri_hook(lambda o, url: webbrowser.open(url))
        else:
            self.link_button = None

        self.notebookcombobox = NotebookComboBox(current=notebookinfo)
        self.open_button = IconButton('gtk-index')
        self.open_button.connect('clicked',
                                 lambda *a: NotebookDialog(self).run())

        self.portentry = gtk.SpinButton()
        self.portentry.set_numeric(True)
        self.portentry.set_range(80, 10000)
        self.portentry.set_increments(1, 80)
        self.portentry.set_value(port)

        self.public_checkbox = gtk.CheckButton(label=_('Allow public access'))
        # T: Checkbox in web server gui
        self.public_checkbox.set_active(public)

        # Build the interface
        vbox = gtk.VBox()
        self.add(vbox)

        hbox = gtk.HBox(spacing=12)
        hbox.pack_start(self.start_button, False)
        hbox.pack_start(self.stop_button, False)
        hbox.pack_start(self.status_label, False)
        vbox.add(hbox)

        table = input_table_factory((
            (_('Notebook'), self.notebookcombobox, self.open_button),
            # T: Field in web server gui
            (_('Port'), self.portentry),
            # T: Field in web server gui for HTTP port (e.g. port 80)
            self.public_checkbox))
        vbox.add(table)

        if self.link_button:
            hbox = gtk.HBox()
            hbox.pack_end(self.link_button, False)
            vbox.add(hbox)
Esempio n. 22
0
 def __init__(self, uri):
     gtk.LinkButton.__init__(self, uri, label=uri)
     self.set_property('can-focus', False)
     self._callback = None
     gtk.link_button_set_uri_hook(self.on_link_button_clicked)
Esempio n. 23
0
File: server.py Progetto: gdw2/zim
	def __init__(self, notebookinfo=None, port=8080, public=True, **opts):
		'''Constructor
		@param notebookinfo: the notebook location
		@param port: the http port to serve on
		@param public: allow connections to the server from other
		computers - if C{False} can only connect from localhost
		@param opts: options for L{WWWInterface.__init__()}
		'''
		gtk.Window.__init__(self)
		self.set_title('Zim - ' + _('Web Server')) # T: Window title
		self.set_border_width(10)
		self.connect('destroy', lambda a: gtk.main_quit())
		self.interface_opts = opts
		self.httpd = None
		self._source_id = None

		# Widgets
		self.status_label = gtk.Label()
		self.status_label.set_markup('<i>'+_('Server not started')+'</i>')
			# T: Status in web server gui
		self.start_button = IconButton('gtk-media-play')
		self.start_button.connect('clicked', lambda o: self.start())
		self.stop_button = IconButton('gtk-media-stop')
		self.stop_button.connect('clicked', lambda o: self.stop())
		self.stop_button.set_sensitive(False)

		if gtk.gtk_version >= (2, 10):
			self.link_button = gtk.LinkButton('')
			self.link_button.set_sensitive(False)
			gtk.link_button_set_uri_hook(lambda o, url: webbrowser.open(url))
		else:
			self.link_button = None

		self.notebookcombobox = NotebookComboBox(current=notebookinfo)
		self.open_button = IconButton('gtk-index')
		self.open_button.connect('clicked', lambda *a: NotebookDialog(self).run())

		self.portentry = gtk.SpinButton()
		self.portentry.set_numeric(True)
		self.portentry.set_range(80, 10000)
		self.portentry.set_increments(1, 80)
		self.portentry.set_value(port)

		self.public_checkbox = gtk.CheckButton(label=_('Allow public access'))
			# T: Checkbox in web server gui
		self.public_checkbox.set_active(public)


		# Build the interface
		vbox = gtk.VBox()
		self.add(vbox)

		hbox = gtk.HBox(spacing=12)
		hbox.pack_start(self.start_button, False)
		hbox.pack_start(self.stop_button, False)
		hbox.pack_start(self.status_label, False)
		vbox.add(hbox)

		table = input_table_factory((
			(_('Notebook'), self.notebookcombobox, self.open_button),
				# T: Field in web server gui
			(_('Port'), self.portentry),
				# T: Field in web server gui for HTTP port (e.g. port 80)
			self.public_checkbox
		))
		vbox.add(table)

		if self.link_button:
			hbox = gtk.HBox()
			hbox.pack_end(self.link_button, False)
			vbox.add(hbox)
Esempio n. 24
0
    def __init__(self):
        gobject.GObject.__init__(self)
        self.config = tgcm.core.Config.Config(tgcm.country_support)

        self.is_moving = False
        self.__is_maximized = False
        self.__unmaximized_width = 0
        self.__unmaximized_height = 0

        # Variables related to Wi-Fi Access Point status
        self._wifi_aap = False
        self._wifi_aap_listener_id = False

        self.XMLConf = tgcm.core.XMLConfig.XMLConfig()
        self.XMLConf.import_regional_info()

        self.XMLTheme = tgcm.core.XMLTheme.XMLTheme()
        self.XMLTheme.load_theme()
        self.dock_layout = self.XMLTheme.get_layout('dock.layout')

        # FIXME: Really ugly hack to set the correct size for a dock
        # with ads (e.g. Latam).
        # TGCM/Win uses a floating window to show the advertisements, but in
        # TGCM/Linux we need to have only one gtk.Window for the dock. The
        # size of our dock does not directly appear in themes.xml, so it is
        # needed to do some calculations to get it
        is_advertising = self.config.is_ads_available()
        if is_advertising:
            ad_layout = self.XMLTheme.get_layout('dock.advertising')

            orig_height = self.dock_layout['size']['height']
            ad_height = ad_layout['size']['height']
            self.dock_layout['size']['orig_height'] = orig_height
            self.dock_layout['size']['height'] = orig_height + ad_height

            orig_minY = self.dock_layout['border']['minY']
            self.dock_layout['border']['orig_minY'] = orig_minY
            self.dock_layout['border']['minY'] = orig_height + ad_height

        # Gnome 3 is an "application based" system, as opposed to "window based" (see
        # http://live.gnome.org/GnomeShell/ApplicationBased for more info). The interesting
        # thing with Gnome 3 is that it uses a different (and somewhat insane) algorithm to
        # look for the application name. That string is used e.g. in the title bar, alt+tab, etc.
        #
        # Currently, it seems that a .desktop file accessible world-wide (e.g. in
        # /usr/share/applications) is required, and the value of the X property "WM_CLASS" must
        # match with the name of that .desktop file. For example, if an application package
        # provides a file called 'xxxx.desktop', the WM_CLASS property of the application window
        # must be something like WM_CLASS(STRING) = "xxxx", "Xxxx".
        #
        # We have a problem with TGCM, because by default PyGTK uses the name of the main python
        # script to set the WM_CLASS value (in our case WM_CLASS(STRING) = "tgcm", "Tgcm"), so
        # Gnome 3 fails to find the appropriate .desktop file (eg. "tgcm-[es|ar|de|uy].desktop").
        # Instead of showing the correct application name, it shows "Tgcm".
        #
        # The following lines are intended to correctly establish the contents of the property
        # WM_CLASS to something like WM_CLASS(STRING) = "tgcm-es", "Tgcm-es". It unfortunately
        # fails but that is the documented way to do it.
        prg_name = 'tgcm-%s' % tgcm.country_support
        app_name = 'Tgcm-%s' % tgcm.country_support
        gobject.set_prgname(prg_name)
        gobject.set_application_name(app_name)

        gtk.window_set_default_icon(self.XMLTheme.get_window_icon())

        self.main_window = gtk.Window()
        self.main_window.set_name("tgcm_main_window")
        self.main_window.set_title(self.config.get_app_name())

        # WTF: Seems that PyGTK does not properly assign the property WM_CLASS with the
        # functions "gobject.set_prgname()". The following function indeed it does, but in
        # a very hostile and probably dangerous way. Keep it in mind!
        self.main_window.set_wmclass(prg_name, app_name)

        self.main_window.set_decorated(False)
        self.main_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
        self.main_window.connect("show", self.__on_show_window)
        self.main_window.connect("delete-event", self.__on_destroy_window)
        self.main_window.connect("check-resize", self.__on_check_resize)
        self.main_window.connect("configure-event", self.__on_configure_event)
        self.main_window.connect("motion-notify-event", self.__motion_notify_event)

        self.help_dialog = None

        self.__is_first_time = False
        if self.config.is_first_time():
            self.__is_first_time = True
            self.config.done_first_time()

        self.vbox = gtk.VBox()
        self.main_window.add(self.vbox)

        # Hidden menu, used for Ubuntu HUD and keyboard accelerators
        self.menubar = tgcm.ui.widgets.dock.Menubar.Menubar()
        self.vbox.pack_start(self.menubar.get_menubar(), False)

        self.main_box = gtk.Fixed()
        self.main_box.connect("size-allocate", self.__on_size_allocate)
        self.vbox.pack_start(self.main_box, True)

        self.vbox.show()
        self.menubar.get_menubar().hide()
        self.main_box.show()

        # Add a global URI hook to gtk.LinkButton widgets. This hook check if there is an
        # active connection before opening the URI, and if that is not the case it initiates
        # the SmartConnector logic
        gtk.link_button_set_uri_hook(self.__linkbutton_global_uri_hook)
Esempio n. 25
0
    # like gtk, set utf-8 encoding of str objects
    reload(sys) # hack access to setdefaultencoding
    sys.setdefaultencoding("utf-8")


## Global init:

from socket import setdefaulttimeout as socketsettimeout
socketsettimeout(5)

if not args.skip_gui:
    gtk.gdk.threads_init()

    # we don't use gtk.LinkButton, but gtk.AboutDialog does;
    # in gtk 2.16.0 without this, the about uri opens doubly:
    gtk.link_button_set_uri_hook(lambda *args:None)

## CLI actions:

args.execute_cmds()


## Load the main application:

from sonata import main

app = main.Base(args)
try:
    app.main()
except KeyboardInterrupt:
    pass
Esempio n. 26
0
    # like gtk, set utf-8 encoding of str objects
    reload(sys) # hack access to setdefaultencoding
    sys.setdefaultencoding("utf-8")


## Global init:

from socket import setdefaulttimeout as socketsettimeout
socketsettimeout(5)

if not args.skip_gui:
    gtk.gdk.threads_init()

    # we don't use gtk.LinkButton, but gtk.AboutDialog does;
    # in gtk 2.16.0 without this, the about uri opens doubly:
    gtk.link_button_set_uri_hook(lambda *args:None)

## CLI actions:

args.execute_cmds()


## Load the main application:

from sonata import main

app = main.Base(args)
try:
    app.main()
except KeyboardInterrupt:
    pass
Esempio n. 27
0
        save_location = os.path.split(self.m_filename)[0] + os.sep
        fh = pd.FileHeader(1, self.m_model)
        fh.save_file(self.m_filename)
        self.set_not_modified()
        # We do test for solfege.win since it is not available during testing
        if hasattr(solfege, 'win'):
            solfege.win.load_frontpage()
    def on_show_help(self, *w):
        return
    def get_save_as_dialog(self):
        dialog = gu.EditorDialogBase.get_save_as_dialog(self)
        ev2 = gtk.EventBox()
        ev2.set_name("DIALOGWARNING2")
        ev = gtk.EventBox()
        ev.set_border_width(gu.hig.SPACE_SMALL)
        ev2.add(ev)
        ev.set_name("DIALOGWARNING")
        label = gtk.Label()
        label.set_padding(gu.hig.SPACE_MEDIUM, gu.hig.SPACE_MEDIUM)
        ev.add(label)
        label.set_markup(_("<b>IMPORTANT:</b> Your front page file <b>must</b> be saved in a subdirectory below the directory named exercises. See the user manual for details."))
        dialog.set_extra_widget(ev2)
        ev2.show_all()
        return dialog

if __name__ == '__main__':
    gtk.link_button_set_uri_hook(lambda a, b: None)
    e = Editor()
    e.load_file("learningtrees/learningtree.txt")
    gtk.main()
Esempio n. 28
0
def url_show(url):
    try:
        launch_default_for_uri(url)
    except Exception, e:
        LOGGER.exception(e)
        message_dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE)
        message_dialog.set_markup("<span size='larger' weight='bold'>%s</span>\n\n '%s'" % (
            _("Cannot show URL:"), cgi.escape(url)))

        resp = message_dialog.run()
        if resp == gtk.RESPONSE_CLOSE:
            message_dialog.destroy()

# Make gtk.LinkButtons call url_show()
gtk.link_button_set_uri_hook (lambda button, url : url_show(url))

def get_proxy():
    # TODO: Very dirty, should use CoreImpl class
    deskbarapplet = GconfStore.get_instance()
    if deskbarapplet.get_use_http_proxy():
        proxy_string = "http://%s:%d/" % (deskbarapplet.get_proxy_host(), deskbarapplet.get_proxy_port())
        proxies = {'http' : proxy_string}
        return proxies
    else:
        return None
    
def get_locale_lang():
    """
    @returns language code corresponding to RFC 1766 of currently used locale
    or None when the code is unknown
Esempio n. 29
0
:var EXTENSIONS_URL: Web page listing third party extensions
:var HOMEPAGE_URL: Web page of the Gaupol project
:var PREVIEW_HELP_URL: Documentation on the preview function
:var REGEX_HELP_URL: Documentation on regular expressions
:var SPEECH_RECOGNITION_HELP_URL: Documentation on speech recognition
:var WIKI_URL: Wiki documentation
"""

import gaupol
import gtk

__all__ = ("BUG_REPORT_URL",
           "EXTENSIONS_URL",
           "HOMEPAGE_URL",
           "PREVIEW_HELP_URL",
           "REGEX_HELP_URL",
           "SPEECH_RECOGNITION_HELP_URL",
           "WIKI_URL")

BUG_REPORT_URL = "http://bugzilla.gnome.org/enter_bug.cgi?product=gaupol"
EXTENSIONS_URL = "http://live.gnome.org/Gaupol/Extensions"
HOMEPAGE_URL = "http://home.gna.org/gaupol/"
PREVIEW_HELP_URL = "http://live.gnome.org/Gaupol/Preview"
REGEX_HELP_URL = "http://docs.python.org/lib/re-syntax.html"
SPEECH_RECOGNITION_HELP_URL = "http://live.gnome.org/Gaupol/SpeechRecognition"
WIKI_URL = "http://live.gnome.org/Gaupol"

def _on_link_button_clicked(link_button, uri):
    return gaupol.util.show_uri(uri)
gtk.link_button_set_uri_hook(_on_link_button_clicked)
Esempio n. 30
0
	def __init__(self):
		"""Constructor de la interfaz"""
		self.previous_excepthook = sys.excepthook
        	sys.excepthook = self.excepthook
		
		# Main Window
		self.window = gtk.Window()
		self.window.set_title(_("Asistente de Migración a Guadalinex"))
		self.window.set_default_size(700, 570)
		self.window.set_border_width(0)
		self.window.move(150, 50)
		self.window.connect("destroy", self.destroy)
		self.window.set_icon_from_file(os.path.join(dir_imagenes, "icon_paginacion.png"))
		#self.window.set_icon_from_file('/home/fernando/Desktop/paquetes/amigu-0.5.3/imagenes/icon_paginacion.gif')
		# Atributos
		self.paso = 1
		self.usuarios = {}
		self.selected_user = None
		self.resumen = []
		self.tasks = []
		self.detalles = ""
		self.url = "http://forja.guadalinex.org/webs/amigu/"
		self.watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
		gtk.about_dialog_set_url_hook(self.open_url, self.url)
		try:
			gtk.link_button_set_uri_hook(self.open_url, self.url)
		except:
			print _("Está usando una versión anterior a python-gtk2 2.10")
		# ventana principal
		contenedor = gtk.VBox(False, 1)#Creo la caja vertical principal
		self.inicio = gtk.VBox(False, 1)
		self.segunda = gtk.VBox(False, 1)
		self.tercera = gtk.HBox(False, 1)
		self.cuarta = gtk.VBox(False, 1)
		self.quinta = gtk.VBox(False, 1)
		separador1 = gtk.HSeparator()
		separador2 = gtk.HSeparator()
		self.tooltips = gtk.Tooltips()
		principal = gtk.HBox(False, 1)#Creo lo que se va a quedar siempre en la ventana
		principal0 = gtk.HBox(False, 1)#Creo lo que se va a quedar siempre en la ventana
		principal1 = gtk.VBox(False, 1)#Creo lo que va a ir variando
		principal2 = gtk.HBox(False, 1)#Creo lo que se va a quedar siempre en la ventana
		principal2ver1 = gtk.HBox(False, 1)
		principal2ver2 = gtk.HBox(True, 1)
		principal2ver2.set_size_request(550,60)
		principal2ver2.set_border_width(10)
		image = gtk.Image()
		image.set_from_file(os.path.join(dir_imagenes, "cab_amigu.png"))
		#image.set_from_file('/home/fernando/Desktop/paquetes/amigu-0.5.3/imagenes/cab_amigu.jpg')
		image1 = gtk.Image()
		image1.set_from_file(os.path.join(dir_imagenes, "icon_paginacion.png"))
		#image1.set_from_file('/home/fernando/Desktop/paquetes/amigu-0.5.3/imagenes/icon_paginacion.gif')

		# botones
		self.boton = gtk.Button(stock = gtk.STOCK_CANCEL)
		self.boton1 = gtk.Button(stock = gtk.STOCK_GO_BACK)
		self.boton2 = gtk.Button(stock = gtk.STOCK_GO_FORWARD)
		self.boton3 = gtk.Button(stock = gtk.STOCK_APPLY)
		self.boton4 = gtk.Button(stock = gtk.STOCK_QUIT)
		self.boton5 = gtk.Button(label=_("Acerca de"))
		
		self.etapa = gtk.Label()
		self.etapa.set_use_markup(True)
		self.etapa.set_markup("<span face = \"arial\" size = \"8000\" foreground = \"chocolate\"><b>Paso %d de 5</b></span>"%self.paso)

		# añadir
		self.labelpri = gtk.Label("")
		espacio = gtk.Label()
		self.labelpri.set_line_wrap(True)
		self.labelpri.set_justify(gtk.JUSTIFY_LEFT)
		self.labelpri.set_use_markup(True)
		principal.pack_start(image, False, False, 0)
		principal0.pack_start(self.labelpri, False, False, 10)
		principal1.pack_start(self.inicio, True, False, 0)
		principal2.pack_start(principal2ver1, False, False, 0)
		principal2.pack_start(principal2ver2, True, False, 0)
		principal2ver1.pack_start(image1, True, True, 0)
		principal2ver1.pack_start(self.etapa, False, False, 1)
		principal2ver2.pack_start(self.boton1, False, False, 0)
		principal2ver2.pack_start(self.boton2, False, False, 0)
		principal2ver2.pack_start(self.boton3, False, False, 0)
		principal2ver2.pack_start(self.boton4, False, False, 0)
		principal2ver2.pack_start(self.boton5, False, False, 0)
		principal2ver2.pack_start(espacio, True, True, 2)
		principal2ver2.pack_start(self.boton, True, False, 5)
		contenedor.pack_start(principal, False, False, 1)
		contenedor.pack_start(separador1, False, True, 10)
		contenedor.pack_start(principal0, False, False, 1)
		contenedor.pack_start(principal1, True, True, 1)
		contenedor.pack_start(separador2, False, True, 10)
		contenedor.pack_start(principal2, False, True, 1)
		principal1.pack_start(self.segunda, True, False, 1)
		principal1.pack_start(self.tercera, True, False, 1)
		principal1.pack_start(self.cuarta, True, False, 1)
		principal1.pack_start(self.quinta, True, False, 1)
		self.window.add(contenedor)#Añado a la ventana el contenedor
		
		# eventos
		self.boton1.connect("clicked", self.etapa_anterior)
		self.boton2.connect("clicked", self.etapa_siguiente)
		self.boton3.connect("clicked", self.dialogo_confirmacion)
		self.boton4.connect("clicked", self.destroy)
		self.boton.connect_object("clicked", self.dialogo_cancelacion, self.window)
		self.boton5.connect_object("clicked", self.about, self.window)
		
		# mostrar ventana
		self.window.show_all()
		self.boton3.hide()
		self.boton4.hide()


################Primera Ventana	

		# crear
		label1 = gtk.Label()
		label1.set_use_markup(True)
		label1.set_line_wrap(True)
		label1.set_justify(gtk.JUSTIFY_CENTER)
		label1.set_markup('<b>'+_('Bienvenido al Asistente de MIgración de GUadalinex - AMIGU') + '\n\n' + _('Este asistente le guiará durante el proceso de migración de sus documentos y configuraciones de su sistema operativo Windows.') + '\n' + _('Pulse el botón Adelante para comenzar.') + '</b>')

		# añadir
		self.inicio.pack_start(label1, True, True, 10)
		
		# mostrar
		self.boton1.hide_all()
		self.inicio.show_all()


################Segunda Ventana

		#crear
		self.segundahor1 = gtk.HBox(False, 10)
		self.segundahor2 = gtk.HBox(False, 10)
		label2 = gtk.Label()
		label2.set_use_markup(True)
		label2.set_markup('<b>'+_('Seleccione uno de los usuarios de Windows')+'</b>')
		frame1 = gtk.Frame(_("Información"))
		sw = gtk.ScrolledWindow()
		sw.set_size_request(600, 175)
		sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		textview = gtk.TextView()
		textview.set_editable(False)
		self.textbuffer = textview.get_buffer()
		self.combo = gtk.combo_box_new_text()
		self.combo.append_text(_('Usuarios de Windows:'))
		self.combo.set_active(0)
		self.combo.connect("changed", self.actualizar_info)
		

		# añadir
		sw.add(textview)
		frame1.add(sw)
		self.segundahor1.pack_start(label2, False, True, 10)
		self.segundahor1.pack_start(self.combo, False, False, 10)
		self.segundahor2.pack_start(frame1, True, True, 10)
		self.segunda.pack_start(self.segundahor2, True, False, 10)
		self.segunda.pack_start(self.segundahor1, True, True, 10)
		
	


###############################Tercera Ventana

		# crear
		self.terceraver1 = gtk.HBox(False, 10)
		self.terceraver2 = gtk.HBox(False, 10)
		self.tercerahor1 = gtk.VBox(False, 10)
		self.tercerahor2 = gtk.VBox(False, 10)
		frame2 = gtk.Frame(_("Destino"))
		self.entry = gtk.Entry()
		self.entry.set_max_length(50)
		f = folder(os.path.expanduser('~'))
		self.required_space = 0
		self.espaciolib = gtk.Label(_("Espacio libre en disco") + ": %dKB" % f.get_free_space())
		self.espacioreq = gtk.Label(_("Espacio requerido") + ": %dKB" % self.required_space)
		self.entry.connect("activate", self.actualizar_espacio_libre, self.entry)
		self.entry.set_text(os.path.expanduser('~'))
		boton22 = gtk.Button(label = _("Seleccionar otra carpeta"), stock = None)
		frame5 = gtk.Frame(_("Opciones de migración"))
		self.arbol_inicializado = False
		self.tree_options = gtk.TreeStore( gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
		self.sw3 = gtk.ScrolledWindow()
		self.sw3.set_size_request(280, 200)
		self.sw3.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		self.sw3.add(self.generar_vista(self.tree_options))
		
		# añadir
		self.tercera.pack_start(self.terceraver1, False, False, 0)
		self.tercera.pack_start(self.terceraver2, True, True, 0)
		self.terceraver1.pack_start(self.tercerahor1, False, False, 10)
		self.terceraver2.pack_start(self.tercerahor2, True, True, 10)
		frame5.add(self.sw3)
		frame2.add(self.entry)
		self.tercerahor1.pack_start(frame2, True, False, 0)
		self.tercerahor1.pack_start(boton22, True, False, 0)
		self.tooltips.set_tip(boton22, _("Elija la carpeta Destino donde quiere guardar los archivos"))
		boton22.connect_object("clicked", self.buscar, self.window)
		self.tercerahor1.pack_start(self.espaciolib, True, True, 5)
		self.tercerahor1.pack_start(self.espacioreq, True, True, 5)
		self.tercerahor2.pack_start(frame5, True, False, 0)


################Cuarta Ventana

		# crear
		self.cuartahor1 = gtk.HBox(False, 10)
		frame3 = gtk.Frame(_("Tareas a realizar"))
		sw1 = gtk.ScrolledWindow()
		sw1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		sw1.set_size_request(600, 225)
		textview1 = gtk.TextView()
		self.textbuffer1 = textview1.get_buffer()
		textview1.set_editable(False)

		#añadir
		self.cuarta.pack_start(self.cuartahor1, True, True, 0)
		self.cuartahor1.pack_start(frame3, True, True, 10)
		frame3.add(sw1)
		sw1.add(textview1)


################Quinta Ventana
		
		# crear
		self.quintahor1 = gtk.VBox(False, 10)
		frame4 = gtk.Frame(_("Detalles de tareas"))
		sw4 = gtk.ScrolledWindow()
		sw4.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		sw4.set_size_request(580, 200)
		textview4 = gtk.TextView()
		self.textbuffer4 = textview4.get_buffer()
		self.textbuffer4.set_text(_('Comenzando el proceso de migración...') + '\n ' + _('Esto puede llevar cierto tiempo en función del tamaño de los archivos y de la velocidad de su equipo.') + '\n ' + _('Por favor espere...'))
		textview4.set_editable(False)
		self.progreso = gtk.ProgressBar(None)
		self.progreso.set_fraction(0.0)
		self.progreso.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
		self.progreso.set_text(_("Realizando las tareas solicitadas..."))
		
		# añadir
		self.quinta.pack_start(self.quintahor1, True, False, 10)
		self.quintahor1.pack_start(frame4, True, True, 10)
		self.quintahor1.pack_start(self.progreso, False, False, 5)
		frame4.add(sw4)
		sw4.add(textview4)
		global barra
		barra = self.progreso
		global text_view
		text_view = textview4	
		global detalle
		detalle = self.textbuffer4
		try:
			child = gtk.EventBox()
			b =  gtk.LinkButton(self.url, label=_("Más información sobre Amigu"))
			child.add(b)
			text_view.add_child_in_window(child, gtk.TEXT_WINDOW_TEXT, 480, 173)
		except: 
			pass
Esempio n. 31
0
	def __init__(self, server):
		'''Constructor needs a Server object to control'''
		gtk.Window.__init__(self)
		self.set_icon_from_file(data_file('zim.png').path)
			# TODO new icon for WWW frontend
		self.set_border_width(10)
		self.connect('destroy', lambda a: gtk.main_quit())

		self.server = server
		self.server.connect_after('started', self.do_server_started)
		self.server.connect_after('stopped', self.do_server_stopped)

		def _start(*a):
			self.server.set_notebook(
				self.notebookcombobox.get_notebook() )
			self.server.start()

		def _stop(*a): self.server.stop()

		# Build the interface
		vbox = gtk.VBox()
		self.add(vbox)

		# first some art work
		#~ path = data_file('globe_banner_small.png').path
		#~ image = gtk.Image()
		#~ image.set_from_file(path) # new_from_file not in 2.6
		#~ align = gtk.Alignment(0,0.5, 0,0)
		#~ align.add(image)
		#~ vbox.add(align)

		# Table with status
		table = gtk.Table(4, 2, False)
		table.set_col_spacings(12)
		table.set_row_spacings(5)
		hbox = gtk.HBox()
		hbox.pack_start(table, False)
		vbox.pack_start(hbox, False)

		self.status_icon = gtk.image_new_from_stock(*stock_stopped)
		table.attach(self.status_icon, 0,2, 0,2)
		self.status_label = gtk.Label()
		self.status_label.set_markup('<i>'+_('Server not started')+'</i>')
			# T: Status in web server gui
		table.attach(self.status_label, 4,5, 0,1)
		self.link_button = gtk.LinkButton('') # FIXME since 2.10
		self.link_button.set_sensitive(False)
		gtk.link_button_set_uri_hook(lambda o, url: webbrowser.open(url))
		table.attach(self.link_button, 4,5, 1,2)

		start_button = IconButton('gtk-media-play')
		start_button.connect('clicked', _start)
		table.attach(start_button, 2,3, 0,1)
		stop_button = IconButton('gtk-media-stop')
		stop_button.connect('clicked', _stop)
		table.attach(stop_button, 3,4, 0,1)

		# Table with server properties
		table = gtk.Table(3, 3, False)
		table.set_col_spacings(12)
		table.set_row_spacings(5)
		vbox.add(table)

		table.attach(gtk.Label(_('Notebook')+': '), 0,1, 0,1)
			# T: Field in web server gui
		self.notebookcombobox = NotebookComboBox(current=server.interface.notebook)
		self.notebookcombobox.connect('changed', _stop)
		table.attach(self.notebookcombobox, 1,2, 0,1)

		open_button = IconButton('gtk-index')
		open_button.connect('clicked', lambda *a: NotebookDialog(self).run())
		table.attach(open_button, 2,3, 0,1)

		table.attach(gtk.Label(_('Port')+': '), 0,1, 1,2)
			# T: Field in web server gui for HTTLP port (e.g. port 80)
		self.portentry = gtk.SpinButton()
		self.portentry.set_numeric(True)
		self.portentry.set_range(80, 10000)
		self.portentry.set_increments(1, 80)
		self.portentry.set_value(self.server.port)
		self.portentry.connect('value-changed', _stop)
		self.portentry.connect('value-changed',
			lambda o: self.server.set_port(self.portentry.get_value_as_int()))
		table.attach(self.portentry, 1,2, 1,2)
Esempio n. 32
0
# check_rcfile has to be called before and
# functions that use the cfg module.
application.check_rcfile()

opt_parser = optionparser.SolfegeOptionParser()
options, args = opt_parser.parse_args()

from solfege import runtime
runtime.init(options)
import gtk
import gobject

# We need to set a uri hook that does nothing, since ubuntu 9.04 rc give
# GConf errors and GtkWarnings without it.
gtk.link_button_set_uri_hook(lambda a, b: None)


if options.debug or options.debug_level:
    # We import all exercise modules here even though it is not necessary
    # since the modules are loaded one by one when needed. But by importing
    # all here, we catch SyntaxErrors at once.
    from solfege.exercises import *

    handler = logging.StreamHandler()
    logging.getLogger().addHandler(handler)
    if options.debug_level:
        options.debug = True
    level = {'debug': logging.DEBUG,
             'info': logging.INFO,
             'warning': logging.WARNING,
Esempio n. 33
0
    def __init__(self):
        gobject.GObject.__init__(self)
        self.config = tgcm.core.Config.Config(tgcm.country_support)

        self.is_moving = False
        self.__is_maximized = False
        self.__unmaximized_width = 0
        self.__unmaximized_height = 0

        # Variables related to Wi-Fi Access Point status
        self._wifi_aap = False
        self._wifi_aap_listener_id = False

        self.XMLConf = tgcm.core.XMLConfig.XMLConfig()
        self.XMLConf.import_regional_info()

        self.XMLTheme = tgcm.core.XMLTheme.XMLTheme()
        self.XMLTheme.load_theme()
        self.dock_layout = self.XMLTheme.get_layout('dock.layout')

        # FIXME: Really ugly hack to set the correct size for a dock
        # with ads (e.g. Latam).
        # TGCM/Win uses a floating window to show the advertisements, but in
        # TGCM/Linux we need to have only one gtk.Window for the dock. The
        # size of our dock does not directly appear in themes.xml, so it is
        # needed to do some calculations to get it
        is_advertising = self.config.is_ads_available()
        if is_advertising:
            ad_layout = self.XMLTheme.get_layout('dock.advertising')

            orig_height = self.dock_layout['size']['height']
            ad_height = ad_layout['size']['height']
            self.dock_layout['size']['orig_height'] = orig_height
            self.dock_layout['size']['height'] = orig_height + ad_height

            orig_minY = self.dock_layout['border']['minY']
            self.dock_layout['border']['orig_minY'] = orig_minY
            self.dock_layout['border']['minY'] = orig_height + ad_height

        # Gnome 3 is an "application based" system, as opposed to "window based" (see
        # http://live.gnome.org/GnomeShell/ApplicationBased for more info). The interesting
        # thing with Gnome 3 is that it uses a different (and somewhat insane) algorithm to
        # look for the application name. That string is used e.g. in the title bar, alt+tab, etc.
        #
        # Currently, it seems that a .desktop file accessible world-wide (e.g. in
        # /usr/share/applications) is required, and the value of the X property "WM_CLASS" must
        # match with the name of that .desktop file. For example, if an application package
        # provides a file called 'xxxx.desktop', the WM_CLASS property of the application window
        # must be something like WM_CLASS(STRING) = "xxxx", "Xxxx".
        #
        # We have a problem with TGCM, because by default PyGTK uses the name of the main python
        # script to set the WM_CLASS value (in our case WM_CLASS(STRING) = "tgcm", "Tgcm"), so
        # Gnome 3 fails to find the appropriate .desktop file (eg. "tgcm-[es|ar|de|uy].desktop").
        # Instead of showing the correct application name, it shows "Tgcm".
        #
        # The following lines are intended to correctly establish the contents of the property
        # WM_CLASS to something like WM_CLASS(STRING) = "tgcm-es", "Tgcm-es". It unfortunately
        # fails but that is the documented way to do it.
        prg_name = 'tgcm-%s' % tgcm.country_support
        app_name = 'Tgcm-%s' % tgcm.country_support
        gobject.set_prgname(prg_name)
        gobject.set_application_name(app_name)

        gtk.window_set_default_icon(self.XMLTheme.get_window_icon())

        self.main_window = gtk.Window()
        self.main_window.set_name("tgcm_main_window")
        self.main_window.set_title(self.config.get_app_name())

        # WTF: Seems that PyGTK does not properly assign the property WM_CLASS with the
        # functions "gobject.set_prgname()". The following function indeed it does, but in
        # a very hostile and probably dangerous way. Keep it in mind!
        self.main_window.set_wmclass(prg_name, app_name)

        self.main_window.set_decorated(False)
        self.main_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
        self.main_window.connect("show", self.__on_show_window)
        self.main_window.connect("delete-event", self.__on_destroy_window)
        self.main_window.connect("check-resize", self.__on_check_resize)
        self.main_window.connect("configure-event", self.__on_configure_event)
        self.main_window.connect("motion-notify-event",
                                 self.__motion_notify_event)

        self.help_dialog = None

        self.__is_first_time = False
        if self.config.is_first_time():
            self.__is_first_time = True
            self.config.done_first_time()

        self.vbox = gtk.VBox()
        self.main_window.add(self.vbox)

        # Hidden menu, used for Ubuntu HUD and keyboard accelerators
        self.menubar = tgcm.ui.widgets.dock.Menubar.Menubar()
        self.vbox.pack_start(self.menubar.get_menubar(), False)

        self.main_box = gtk.Fixed()
        self.main_box.connect("size-allocate", self.__on_size_allocate)
        self.vbox.pack_start(self.main_box, True)

        self.vbox.show()
        self.menubar.get_menubar().hide()
        self.main_box.show()

        # Add a global URI hook to gtk.LinkButton widgets. This hook check if there is an
        # active connection before opening the URI, and if that is not the case it initiates
        # the SmartConnector logic
        gtk.link_button_set_uri_hook(self.__linkbutton_global_uri_hook)
Esempio n. 34
0
 def __init__(self, no_dialog=False):
     self.settings = EventCore()
     self.gui_is_active = False
     # during initialization any dialog (e.g. "Unit change") is not allowed
     # we set the final value later
     self.no_dialog = True
     self._batch_queue = []
     self._undo_states = []
     self.gui = gtk.Builder()
     gtk_build_file = get_ui_file_location(GTKBUILD_FILE)
     if gtk_build_file is None:
         gtk.main_quit()
     self.gui.add_from_file(gtk_build_file)
     if pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
         gtkrc_file = get_ui_file_location(GTKRC_FILE_WINDOWS)
         if gtkrc_file:
             gtk.rc_add_default_file(gtkrc_file)
             gtk.rc_reparse_all_for_settings(gtk.settings_get_default(), True)
     self.window = self.gui.get_object("ProjectWindow")
     self.settings.set("main_window", self.window)
     # show stock items on buttons
     # increase the initial width of the window (due to hidden elements)
     self.window.set_default_size(400, -1)
     # initialize the RecentManager (TODO: check for Windows)
     if False and pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
         # The pyinstaller binary for Windows fails mysteriously when trying
         # to display the stock item.
         # Error message: Gtk:ERROR:gtkrecentmanager.c:1942:get_icon_fallback: assertion failed: (retval != NULL)
         self.recent_manager = None
     else:
         try:
             self.recent_manager = gtk.recent_manager_get_default()
         except AttributeError:
             # GTK 2.12.1 seems to have problems with "RecentManager" on
             # Windows. Sadly this is the version, that is shipped with the
             # "appunti" GTK packages for Windows (April 2010).
             # see http://www.daa.com.au/pipermail/pygtk/2009-May/017052.html
             self.recent_manager = None
     # file loading
     self.last_dirname = None
     self.last_task_settings_uri = None
     self.last_model_uri = None
     # define callbacks and accelerator keys for the menu actions
     for objname, callback, data, accel_key in (
             ("LoadTaskSettings", self.load_task_settings_file, None, "<Control>t"),
             ("SaveTaskSettings", self.save_task_settings_file, lambda: self.last_task_settings_uri, None),
             ("SaveAsTaskSettings", self.save_task_settings_file, None, None),
             ("OpenModel", self.load_model_file, None, "<Control>o"),
             ("Quit", self.destroy, None, "<Control>q"),
             ("GeneralSettings", self.toggle_preferences_window, None, "<Control>p"),
             ("UndoButton", self._restore_undo_state, None, "<Control>z"),
             ("HelpUserManual", self.show_help, "User_Manual", "F1"),
             ("HelpIntroduction", self.show_help, "Introduction", None),
             ("HelpSupportedFormats", self.show_help, "SupportedFormats", None),
             ("HelpModelTransformations", self.show_help, "ModelTransformations", None),
             ("HelpToolTypes", self.show_help, "ToolTypes", None),
             ("HelpProcessSettings", self.show_help, "ProcessSettings", None),
             ("HelpBoundsSettings", self.show_help, "BoundsSettings", None),
             ("HelpTaskSetup", self.show_help, "TaskSetup", None),
             ("HelpGCodeExport", self.show_help, "GCodeExport", None),
             ("HelpTouchOff", self.show_help, "TouchOff", None),
             ("HelpSimulation", self.show_help, "Simulation", None),
             ("Help3DView", self.show_help, "3D_View", None),
             ("HelpServerMode", self.show_help, "ServerMode", None),
             ("HelpCommandLine", self.show_help, "CommandlineExamples", None),
             ("HelpHotkeys", self.show_help, "KeyboardShortcuts", None),
             ("ProjectWebsite", self.show_help, "http://pycam.sourceforge.net", None),
             ("DevelopmentBlog", self.show_help, "http://fab.senselab.org/pycam", None),
             ("Forum", self.show_help, "http://sourceforge.net/projects/pycam/forums", None),
             ("BugTracker", self.show_help, "http://sourceforge.net/tracker/?group_id=237831&atid=1104176", None),
             ("FeatureRequest", self.show_help, "http://sourceforge.net/tracker/?group_id=237831&atid=1104179", None)):
         item = self.gui.get_object(objname)
         action = "activate"
         if data is None:
             item.connect(action, callback)
         else:
             item.connect(action, callback, data)
         if accel_key:
             key, mod = gtk.accelerator_parse(accel_key)
             accel_path = "<pycam>/%s" % objname
             item.set_accel_path(accel_path)
             gtk.accel_map_change_entry(accel_path, key, mod, True)
     # LinkButton does not work on Windows: https://bugzilla.gnome.org/show_bug.cgi?id=617874
     if pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
         def open_url(widget, data=None):
             webbrowser.open(widget.get_uri())
         gtk.link_button_set_uri_hook(open_url)
     # no undo is allowed at the beginning
     self.gui.get_object("UndoButton").set_sensitive(False)
     self.settings.register_event("model-change-before",
             self._store_undo_state)
     self.settings.register_event("model-change-after",
             lambda: self.settings.emit_event("visual-item-updated"))
     # set the availability of ODE
     self.enable_ode_control = self.gui.get_object("SettingEnableODE")
     self.settings.add_item("enable_ode", self.enable_ode_control.get_active,
             self.enable_ode_control.set_active)
     self.settings.register_event("parallel-processing-changed",
             self.update_ode_settings)
     # configure drag-n-drop for config files and models
     self.settings.set("configure-drag-drop-func",
             self.configure_drag_and_drop)
     self.settings.get("configure-drag-drop-func")(self.window)
     # other events
     self.window.connect("destroy", self.destroy)
     self.window.connect("delete-event", self.destroy)
     # the settings window
     self.gui.get_object("CloseSettingsWindow").connect("clicked", self.toggle_preferences_window, False)
     self.gui.get_object("ResetPreferencesButton").connect("clicked", self.reset_preferences)
     self.preferences_window = self.gui.get_object("GeneralSettingsWindow")
     self.preferences_window.connect("delete-event", self.toggle_preferences_window, False)
     self._preferences_window_position = None
     self._preferences_window_visible = False
     # "about" window
     self.about_window = self.gui.get_object("AboutWindow")
     self.about_window.set_version(VERSION)
     self.gui.get_object("About").connect("activate", self.toggle_about_window, True)
     # we assume, that the last child of the window is the "close" button
     # TODO: fix this ugly hack!
     self.gui.get_object("AboutWindowButtons").get_children()[-1].connect("clicked", self.toggle_about_window, False)
     self.about_window.connect("delete-event", self.toggle_about_window, False)
     # menu bar
     uimanager = gtk.UIManager()
     self.settings.set("gtk-uimanager", uimanager)
     self._accel_group = uimanager.get_accel_group()
     # send a "delete" event on "CTRL-w" for every window
     def handle_window_close(accel_group, window, *args):
         window.emit("delete-event", gtk.gdk.Event(gtk.gdk.DELETE))
     self._accel_group.connect_group(ord('w'), gtk.gdk.CONTROL_MASK,
             gtk.ACCEL_LOCKED, handle_window_close)
     self.settings.add_item("gtk-accel-group", lambda: self._accel_group)
     for obj in self.gui.get_objects():
         if isinstance(obj, gtk.Window):
             obj.add_accel_group(self._accel_group)
     # preferences tab
     preferences_book = self.gui.get_object("PreferencesNotebook")
     def clear_preferences():
         for child in preferences_book.get_children():
             preferences_book.remove(child)
     def add_preferences_item(item, name):
         preferences_book.append_page(item, gtk.Label(name))
     self.settings.register_ui_section("preferences",
             add_preferences_item, clear_preferences)
     for obj_name, label, priority in (
             ("GeneralSettingsPrefTab", "General", -50),
             ("ProgramsPrefTab", "Programs", 50)):
         obj = self.gui.get_object(obj_name)
         obj.unparent()
         self.settings.register_ui("preferences", label, obj, priority)
     # general preferences
     general_prefs = self.gui.get_object("GeneralPreferencesBox")
     def clear_general_prefs():
         for item in general_prefs.get_children():
             general_prefs.remove(item)
     def add_general_prefs_item(item, name):
         general_prefs.pack_start(item, expand=False, padding=3)
     self.settings.register_ui_section("preferences_general",
             add_general_prefs_item, clear_general_prefs)
     for obj_name, priority in (("SettingEnableODE", 10),
             ("TaskSettingsDefaultFileBox", 30)):
         obj = self.gui.get_object(obj_name)
         obj.unparent()
         self.settings.register_ui("preferences_general", None,
                 obj, priority)
     # set defaults
     self.cutter = None
     # add some dummies - to be implemented later ...
     self.settings.add_item("cutter", lambda: self.cutter)
     main_tab = self.gui.get_object("MainTabs")
     def clear_main_tab():
         while main_tab.get_n_pages() > 0:
             main_tab.remove_page(0)
     def add_main_tab_item(item, name):
         main_tab.append_page(item, gtk.Label(name))
     # TODO: move these to plugins, as well
     self.settings.register_ui_section("main", add_main_tab_item,
             clear_main_tab)
     main_window = self.gui.get_object("WindowBox")
     def clear_main_window():
         main_window.foreach(lambda x: main_window.remove(x))
     def add_main_window_item(item, name, **extra_args):
         # some widgets may want to override the defaults
         args = {"expand": False, "fill": False}
         args.update(extra_args)
         main_window.pack_start(item, **args)
     main_tab.unparent()
     self.settings.register_ui_section("main_window", add_main_window_item,
             clear_main_window)
     self.settings.register_ui("main_window", "Tabs", main_tab, -20,
             args_dict={"expand": True, "fill": True})
     # autoload task settings file on startup
     autoload_enable = self.gui.get_object("AutoLoadTaskFile")
     autoload_box = self.gui.get_object("StartupTaskFileBox")
     autoload_source = self.gui.get_object("StartupTaskFile")
     # TODO: fix the extension filter
     #for one_filter in get_filters_from_list(FILTER_CONFIG):
     #    autoload_source.add_filter(one_filter)
     #    autoload_source.set_filter(one_filter)
     def get_autoload_task_file(autoload_source=autoload_source):
         if autoload_enable.get_active():
             return autoload_source.get_filename()
         else:
             return ""
     def set_autoload_task_file(filename):
         if filename:
             autoload_enable.set_active(True)
             autoload_box.show()
             autoload_source.set_filename(filename)
         else:
             autoload_enable.set_active(False)
             autoload_box.hide()
             autoload_source.unselect_all()
     def autoload_enable_switched(widget, box):
         if not widget.get_active():
             set_autoload_task_file(None)
         else:
             autoload_box.show()
     autoload_enable.connect("toggled", autoload_enable_switched,
             autoload_box)
     self.settings.add_item("default_task_settings_file",
             get_autoload_task_file, set_autoload_task_file)
     def disable_gui():
         self.menubar.set_sensitive(False)
         main_tab.set_sensitive(False)
     def enable_gui():
         self.menubar.set_sensitive(True)
         main_tab.set_sensitive(True)
     self.settings.register_event("gui-disable", disable_gui)
     self.settings.register_event("gui-enable", enable_gui)
     # configure locations of external programs
     for auto_control_name, location_control_name, browse_button, key in (
             ("ExternalProgramInkscapeAuto",
             "ExternalProgramInkscapeControl",
             "ExternalProgramInkscapeBrowse", "inkscape"),
             ("ExternalProgramPstoeditAuto",
             "ExternalProgramPstoeditControl",
             "ExternalProgramPstoeditBrowse", "pstoedit")):
         self.gui.get_object(auto_control_name).connect("clicked",
                 self._locate_external_program, key)
         location_control = self.gui.get_object(location_control_name)
         self.settings.add_item("external_program_%s" % key,
                 location_control.get_text, location_control.set_text)
         self.gui.get_object(browse_button).connect("clicked",
                 self._browse_external_program_location, key)
     # set the icons (in different sizes) for all windows
     gtk.window_set_default_icon_list(*get_icons_pixbuffers())
     # load menu data
     gtk_menu_file = get_ui_file_location(GTKMENU_FILE)
     if gtk_menu_file is None:
         gtk.main_quit()
     uimanager.add_ui_from_file(gtk_menu_file)
     # make the actions defined in the GTKBUILD file available in the menu
     actiongroup = gtk.ActionGroup("menubar")
     for action in [action for action in self.gui.get_objects()
             if isinstance(action, gtk.Action)]:
         actiongroup.add_action(action)
     # the "pos" parameter is optional since 2.12 - we can remove it later
     uimanager.insert_action_group(actiongroup, pos=-1)
     # the "recent files" sub-menu
     if not self.recent_manager is None:
         recent_files_menu = gtk.RecentChooserMenu(self.recent_manager)
         recent_files_menu.set_name("RecentFilesMenu")
         recent_menu_filter = gtk.RecentFilter()
         case_converter = pycam.Utils.get_case_insensitive_file_pattern
         for filter_name, patterns in FILTER_MODEL:
             if not isinstance(patterns, (list, set, tuple)):
                 patterns = [patterns]
             # convert it into a mutable list (instead of set/tuple)
             patterns = list(patterns)
             for index in range(len(patterns)):
                 patterns[index] = case_converter(patterns[index])
             for pattern in patterns:
                 recent_menu_filter.add_pattern(pattern)
         recent_files_menu.add_filter(recent_menu_filter)
         recent_files_menu.set_show_numbers(True)
         # non-local files (without "file://") are not supported. yet
         recent_files_menu.set_local_only(False)
         # most recent files to the top
         recent_files_menu.set_sort_type(gtk.RECENT_SORT_MRU)
         # show only ten files
         recent_files_menu.set_limit(10)
         uimanager.get_widget("/MenuBar/FileMenu/OpenRecentModelMenu")\
                 .set_submenu(recent_files_menu)
         recent_files_menu.connect("item-activated",
                 self.load_recent_model_file)
     else:
         self.gui.get_object("OpenRecentModel").set_visible(False)
     # load the menubar and connect functions to its items
     self.menubar = uimanager.get_widget("/MenuBar")
     # dict of all merge-ids
     menu_merges = {}
     def clear_menu(menu_key):
         for merge in menu_merges.get(menu_key, []):
             uimanager.remove_ui(merge)
     def append_menu_item(menu_key, base_path, widget, name):
         merge_id = uimanager.new_merge_id()
         if widget:
             action_group = widget.props.action_group
             if not action_group in uimanager.get_action_groups():
                 uimanager.insert_action_group(action_group, -1)
             widget_name = widget.get_name()
             item_type = gtk.UI_MANAGER_MENUITEM
         else:
             widget_name = name
             item_type = gtk.UI_MANAGER_SEPARATOR
         uimanager.add_ui(merge_id, base_path, name, widget_name, item_type,
                 False)
         if not menu_key in menu_merges:
             menu_merges[menu_key] = []
         menu_merges[menu_key].append(merge_id)
     def get_menu_funcs(menu_key, base_path):
         append_func = lambda widget, name: \
                 append_menu_item(menu_key, base_path, widget, name)
         clear_func = lambda: clear_menu(menu_key)
         return append_func, clear_func
     for ui_name, base_path in (("view_menu", "/MenuBar/ViewMenu"),
             ("file_menu", "/MenuBar/FileMenu"),
             ("edit_menu", "/MenuBar/EditMenu"),
             ("export_menu", "/MenuBar/FileMenu/ExportMenu")):
         append_func, clear_func = get_menu_funcs(ui_name, base_path)
         self.settings.register_ui_section(ui_name, append_func, clear_func)
     self.settings.register_ui("file_menu", "Quit",
             self.gui.get_object("Quit"), 100)
     self.settings.register_ui("file_menu", "QuitSeparator", None, 95)
     self.settings.register_ui("main_window", "Main", self.menubar, -100)
     # initialize plugins
     self.plugin_manager = pycam.Plugins.PluginManager(core=self.settings)
     self.plugin_manager.import_plugins()
     # some more initialization
     self.reset_preferences()
     # TODO: preferences are not loaded until the new format is stable
     #self.load_preferences()
     #self.load_task_settings()
     self.settings.register_event("notify-file-saved",
             self.add_to_recent_file_list)
     self.settings.register_event("notify-file-opened",
             self.add_to_recent_file_list)
     # fallback - in case of a failure when opening a model file
     model = pycam.Importers.TestModel.get_test_model()
     self.settings.get("models").add_model(model, "Tiny pyramid")
     # Without this "gkt.main_iteration" loop the task settings file
     # control would not be updated in time.
     while gtk.events_pending():
         gtk.main_iteration()
     autoload_task_filename = self.settings.get("default_task_settings_file")
     if autoload_task_filename:
         self.open_task_settings_file(autoload_task_filename)
     self.update_all_controls()
     self.no_dialog = no_dialog
     if not self.no_dialog:
         # register a logging handler for displaying error messages
         pycam.Utils.log.add_gtk_gui(self.window, logging.ERROR)
         self.window.show()
Esempio n. 35
0
        #self.updateToolbarClock()## FIXME
        #self.updateTrayClock()
        self.trayUpdate()


###########################################################################3


#core.COMMAND = sys.argv[0] ## OR __file__ ## ????????


gtk.init_check()

clickWebsite = lambda widget, url: core.openUrl(url)
try:
    gtk.link_button_set_uri_hook(clickWebsite)
except:## old PyGTK (older than 2.10)
    pass

try:
    gtk.about_dialog_set_url_hook(clickWebsite)
except:## old PyGTK (older than 2.10)
    pass


"""
themeDir = join(rootDir, 'themes')
theme = 'Dark' # 'Default
if theme!=None:
    gtkrc = join(themeDir, theme, 'gtkrc')
    try:
Esempio n. 36
0
 def __init__(self, uri):
     gtk.LinkButton.__init__(self, uri, label=uri)
     self.set_property('can-focus', False)
     self._callback = None
     gtk.link_button_set_uri_hook(self.on_link_button_clicked)
Esempio n. 37
0
    except Exception, e:
        LOGGER.exception(e)
        message_dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
                                           type=gtk.MESSAGE_ERROR,
                                           buttons=gtk.BUTTONS_CLOSE)
        message_dialog.set_markup(
            "<span size='larger' weight='bold'>%s</span>\n\n '%s'" %
            (_("Cannot show URL:"), cgi.escape(url)))

        resp = message_dialog.run()
        if resp == gtk.RESPONSE_CLOSE:
            message_dialog.destroy()


# Make gtk.LinkButtons call url_show()
gtk.link_button_set_uri_hook(lambda button, url: url_show(url))


def get_proxy():
    # TODO: Very dirty, should use CoreImpl class
    deskbarapplet = GconfStore.get_instance()
    if deskbarapplet.get_use_http_proxy():
        proxy_string = "http://%s:%d/" % (deskbarapplet.get_proxy_host(),
                                          deskbarapplet.get_proxy_port())
        proxies = {'http': proxy_string}
        return proxies
    else:
        return None


def get_locale_lang():
Esempio n. 38
0
    def __init__(self, no_dialog=False):
        self.settings = EventCore()
        self.gui_is_active = False
        # during initialization any dialog (e.g. "Unit change") is not allowed
        # we set the final value later
        self.no_dialog = True
        self._batch_queue = []
        self._undo_states = []
        self.gui = gtk.Builder()
        gtk_build_file = get_ui_file_location(GTKBUILD_FILE)
        if gtk_build_file is None:
            gtk.main_quit()
        self.gui.add_from_file(gtk_build_file)
        if pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
            gtkrc_file = get_ui_file_location(GTKRC_FILE_WINDOWS)
            if gtkrc_file:
                gtk.rc_add_default_file(gtkrc_file)
                gtk.rc_reparse_all_for_settings(gtk.settings_get_default(),
                                                True)
        self.window = self.gui.get_object("ProjectWindow")
        self.settings.set("main_window", self.window)
        # show stock items on buttons
        # increase the initial width of the window (due to hidden elements)
        self.window.set_default_size(400, -1)
        # initialize the RecentManager (TODO: check for Windows)
        if False and pycam.Utils.get_platform(
        ) == pycam.Utils.PLATFORM_WINDOWS:
            # The pyinstaller binary for Windows fails mysteriously when trying
            # to display the stock item.
            # Error message: Gtk:ERROR:gtkrecentmanager.c:1942:get_icon_fallback: assertion failed: (retval != NULL)
            self.recent_manager = None
        else:
            try:
                self.recent_manager = gtk.recent_manager_get_default()
            except AttributeError:
                # GTK 2.12.1 seems to have problems with "RecentManager" on
                # Windows. Sadly this is the version, that is shipped with the
                # "appunti" GTK packages for Windows (April 2010).
                # see http://www.daa.com.au/pipermail/pygtk/2009-May/017052.html
                self.recent_manager = None
        # file loading
        self.last_dirname = None
        self.last_task_settings_uri = None
        self.last_model_uri = None
        # define callbacks and accelerator keys for the menu actions
        for objname, callback, data, accel_key in (
            ("LoadTaskSettings", self.load_task_settings_file, None,
             "<Control>t"), ("SaveTaskSettings", self.save_task_settings_file,
                             lambda: self.last_task_settings_uri, None),
            ("SaveAsTaskSettings", self.save_task_settings_file, None,
             None), ("OpenModel", self.load_model_file, None,
                     "<Control>o"), ("Quit", self.destroy, None, "<Control>q"),
            ("GeneralSettings", self.toggle_preferences_window, None,
             "<Control>p"), ("UndoButton", self._restore_undo_state, None,
                             "<Control>z"), ("HelpUserManual", self.show_help,
                                             "User_Manual", "F1"),
            ("HelpIntroduction", self.show_help, "Introduction", None),
            ("HelpSupportedFormats", self.show_help, "SupportedFormats",
             None), ("HelpModelTransformations", self.show_help,
                     "ModelTransformations",
                     None), ("HelpToolTypes", self.show_help, "ToolTypes",
                             None), ("HelpProcessSettings", self.show_help,
                                     "ProcessSettings", None),
            ("HelpBoundsSettings", self.show_help, "BoundsSettings",
             None), ("HelpTaskSetup", self.show_help, "TaskSetup", None),
            ("HelpGCodeExport", self.show_help, "GCodeExport",
             None), ("HelpTouchOff", self.show_help, "TouchOff",
                     None), ("HelpSimulation", self.show_help, "Simulation",
                             None), ("Help3DView", self.show_help, "3D_View",
                                     None), ("HelpServerMode", self.show_help,
                                             "ServerMode", None),
            ("HelpCommandLine", self.show_help, "CommandlineExamples",
             None), ("HelpHotkeys", self.show_help, "KeyboardShortcuts",
                     None), ("ProjectWebsite", self.show_help,
                             "http://pycam.sourceforge.net",
                             None), ("DevelopmentBlog", self.show_help,
                                     "http://fab.senselab.org/pycam", None),
            ("Forum", self.show_help,
             "http://sourceforge.net/projects/pycam/forums", None),
            ("BugTracker", self.show_help,
             "http://sourceforge.net/tracker/?group_id=237831&atid=1104176",
             None),
            ("FeatureRequest", self.show_help,
             "http://sourceforge.net/tracker/?group_id=237831&atid=1104179",
             None)):
            item = self.gui.get_object(objname)
            action = "activate"
            if data is None:
                item.connect(action, callback)
            else:
                item.connect(action, callback, data)
            if accel_key:
                key, mod = gtk.accelerator_parse(accel_key)
                accel_path = "<pycam>/%s" % objname
                item.set_accel_path(accel_path)
                gtk.accel_map_change_entry(accel_path, key, mod, True)
        # LinkButton does not work on Windows: https://bugzilla.gnome.org/show_bug.cgi?id=617874
        if pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:

            def open_url(widget, data=None):
                webbrowser.open(widget.get_uri())

            gtk.link_button_set_uri_hook(open_url)
        # no undo is allowed at the beginning
        self.gui.get_object("UndoButton").set_sensitive(False)
        self.settings.register_event("model-change-before",
                                     self._store_undo_state)
        self.settings.register_event(
            "model-change-after",
            lambda: self.settings.emit_event("visual-item-updated"))
        # set the availability of ODE
        self.enable_ode_control = self.gui.get_object("SettingEnableODE")
        self.settings.add_item("enable_ode",
                               self.enable_ode_control.get_active,
                               self.enable_ode_control.set_active)
        self.settings.register_event("parallel-processing-changed",
                                     self.update_ode_settings)
        # configure drag-n-drop for config files and models
        self.settings.set("configure-drag-drop-func",
                          self.configure_drag_and_drop)
        self.settings.get("configure-drag-drop-func")(self.window)
        # other events
        self.window.connect("destroy", self.destroy)
        self.window.connect("delete-event", self.destroy)
        # the settings window
        self.gui.get_object("CloseSettingsWindow").connect(
            "clicked", self.toggle_preferences_window, False)
        self.gui.get_object("ResetPreferencesButton").connect(
            "clicked", self.reset_preferences)
        self.preferences_window = self.gui.get_object("GeneralSettingsWindow")
        self.preferences_window.connect("delete-event",
                                        self.toggle_preferences_window, False)
        self._preferences_window_position = None
        self._preferences_window_visible = False
        # "about" window
        self.about_window = self.gui.get_object("AboutWindow")
        self.about_window.set_version(VERSION)
        self.gui.get_object("About").connect("activate",
                                             self.toggle_about_window, True)
        # we assume, that the last child of the window is the "close" button
        # TODO: fix this ugly hack!
        self.gui.get_object("AboutWindowButtons").get_children()[-1].connect(
            "clicked", self.toggle_about_window, False)
        self.about_window.connect("delete-event", self.toggle_about_window,
                                  False)
        # menu bar
        uimanager = gtk.UIManager()
        self.settings.set("gtk-uimanager", uimanager)
        self._accel_group = uimanager.get_accel_group()

        # send a "delete" event on "CTRL-w" for every window
        def handle_window_close(accel_group, window, *args):
            window.emit("delete-event", gtk.gdk.Event(gtk.gdk.DELETE))

        self._accel_group.connect_group(ord('w'), gtk.gdk.CONTROL_MASK,
                                        gtk.ACCEL_LOCKED, handle_window_close)
        self.settings.add_item("gtk-accel-group", lambda: self._accel_group)
        for obj in self.gui.get_objects():
            if isinstance(obj, gtk.Window):
                obj.add_accel_group(self._accel_group)
        # preferences tab
        preferences_book = self.gui.get_object("PreferencesNotebook")

        def clear_preferences():
            for child in preferences_book.get_children():
                preferences_book.remove(child)

        def add_preferences_item(item, name):
            preferences_book.append_page(item, gtk.Label(name))

        self.settings.register_ui_section("preferences", add_preferences_item,
                                          clear_preferences)
        for obj_name, label, priority in (("GeneralSettingsPrefTab", "General",
                                           -50), ("ProgramsPrefTab",
                                                  "Programs", 50)):
            obj = self.gui.get_object(obj_name)
            obj.unparent()
            self.settings.register_ui("preferences", label, obj, priority)
        # general preferences
        general_prefs = self.gui.get_object("GeneralPreferencesBox")

        def clear_general_prefs():
            for item in general_prefs.get_children():
                general_prefs.remove(item)

        def add_general_prefs_item(item, name):
            general_prefs.pack_start(item, expand=False, padding=3)

        self.settings.register_ui_section("preferences_general",
                                          add_general_prefs_item,
                                          clear_general_prefs)
        for obj_name, priority in (("SettingEnableODE", 10),
                                   ("TaskSettingsDefaultFileBox", 30)):
            obj = self.gui.get_object(obj_name)
            obj.unparent()
            self.settings.register_ui("preferences_general", None, obj,
                                      priority)
        # set defaults
        self.cutter = None
        # add some dummies - to be implemented later ...
        self.settings.add_item("cutter", lambda: self.cutter)
        main_tab = self.gui.get_object("MainTabs")

        def clear_main_tab():
            while main_tab.get_n_pages() > 0:
                main_tab.remove_page(0)

        def add_main_tab_item(item, name):
            main_tab.append_page(item, gtk.Label(name))

        # TODO: move these to plugins, as well
        self.settings.register_ui_section("main", add_main_tab_item,
                                          clear_main_tab)
        main_window = self.gui.get_object("WindowBox")

        def clear_main_window():
            main_window.foreach(lambda x: main_window.remove(x))

        def add_main_window_item(item, name, **extra_args):
            # some widgets may want to override the defaults
            args = {"expand": False, "fill": False}
            args.update(extra_args)
            main_window.pack_start(item, **args)

        main_tab.unparent()
        self.settings.register_ui_section("main_window", add_main_window_item,
                                          clear_main_window)
        self.settings.register_ui("main_window",
                                  "Tabs",
                                  main_tab,
                                  -20,
                                  args_dict={
                                      "expand": True,
                                      "fill": True
                                  })
        # autoload task settings file on startup
        autoload_enable = self.gui.get_object("AutoLoadTaskFile")
        autoload_box = self.gui.get_object("StartupTaskFileBox")
        autoload_source = self.gui.get_object("StartupTaskFile")

        # TODO: fix the extension filter
        #for one_filter in get_filters_from_list(FILTER_CONFIG):
        #    autoload_source.add_filter(one_filter)
        #    autoload_source.set_filter(one_filter)
        def get_autoload_task_file(autoload_source=autoload_source):
            if autoload_enable.get_active():
                return autoload_source.get_filename()
            else:
                return ""

        def set_autoload_task_file(filename):
            if filename:
                autoload_enable.set_active(True)
                autoload_box.show()
                autoload_source.set_filename(filename)
            else:
                autoload_enable.set_active(False)
                autoload_box.hide()
                autoload_source.unselect_all()

        def autoload_enable_switched(widget, box):
            if not widget.get_active():
                set_autoload_task_file(None)
            else:
                autoload_box.show()

        autoload_enable.connect("toggled", autoload_enable_switched,
                                autoload_box)
        self.settings.add_item("default_task_settings_file",
                               get_autoload_task_file, set_autoload_task_file)

        def disable_gui():
            self.menubar.set_sensitive(False)
            main_tab.set_sensitive(False)

        def enable_gui():
            self.menubar.set_sensitive(True)
            main_tab.set_sensitive(True)

        self.settings.register_event("gui-disable", disable_gui)
        self.settings.register_event("gui-enable", enable_gui)
        # configure locations of external programs
        for auto_control_name, location_control_name, browse_button, key in (
            ("ExternalProgramInkscapeAuto", "ExternalProgramInkscapeControl",
             "ExternalProgramInkscapeBrowse", "inkscape"),
            ("ExternalProgramPstoeditAuto", "ExternalProgramPstoeditControl",
             "ExternalProgramPstoeditBrowse", "pstoedit")):
            self.gui.get_object(auto_control_name).connect(
                "clicked", self._locate_external_program, key)
            location_control = self.gui.get_object(location_control_name)
            self.settings.add_item("external_program_%s" % key,
                                   location_control.get_text,
                                   location_control.set_text)
            self.gui.get_object(browse_button).connect(
                "clicked", self._browse_external_program_location, key)
        # set the icons (in different sizes) for all windows
        gtk.window_set_default_icon_list(*get_icons_pixbuffers())
        # load menu data
        gtk_menu_file = get_ui_file_location(GTKMENU_FILE)
        if gtk_menu_file is None:
            gtk.main_quit()
        uimanager.add_ui_from_file(gtk_menu_file)
        # make the actions defined in the GTKBUILD file available in the menu
        actiongroup = gtk.ActionGroup("menubar")
        for action in [
                action for action in self.gui.get_objects()
                if isinstance(action, gtk.Action)
        ]:
            actiongroup.add_action(action)
        # the "pos" parameter is optional since 2.12 - we can remove it later
        uimanager.insert_action_group(actiongroup, pos=-1)
        # the "recent files" sub-menu
        if not self.recent_manager is None:
            recent_files_menu = gtk.RecentChooserMenu(self.recent_manager)
            recent_files_menu.set_name("RecentFilesMenu")
            recent_menu_filter = gtk.RecentFilter()
            case_converter = pycam.Utils.get_case_insensitive_file_pattern
            for filter_name, patterns in FILTER_MODEL:
                if not isinstance(patterns, (list, set, tuple)):
                    patterns = [patterns]
                # convert it into a mutable list (instead of set/tuple)
                patterns = list(patterns)
                for index in range(len(patterns)):
                    patterns[index] = case_converter(patterns[index])
                for pattern in patterns:
                    recent_menu_filter.add_pattern(pattern)
            recent_files_menu.add_filter(recent_menu_filter)
            recent_files_menu.set_show_numbers(True)
            # non-local files (without "file://") are not supported. yet
            recent_files_menu.set_local_only(False)
            # most recent files to the top
            recent_files_menu.set_sort_type(gtk.RECENT_SORT_MRU)
            # show only ten files
            recent_files_menu.set_limit(10)
            uimanager.get_widget("/MenuBar/FileMenu/OpenRecentModelMenu")\
                    .set_submenu(recent_files_menu)
            recent_files_menu.connect("item-activated",
                                      self.load_recent_model_file)
        else:
            self.gui.get_object("OpenRecentModel").set_visible(False)
        # load the menubar and connect functions to its items
        self.menubar = uimanager.get_widget("/MenuBar")
        # dict of all merge-ids
        menu_merges = {}

        def clear_menu(menu_key):
            for merge in menu_merges.get(menu_key, []):
                uimanager.remove_ui(merge)

        def append_menu_item(menu_key, base_path, widget, name):
            merge_id = uimanager.new_merge_id()
            if widget:
                action_group = widget.props.action_group
                if not action_group in uimanager.get_action_groups():
                    uimanager.insert_action_group(action_group, -1)
                widget_name = widget.get_name()
                item_type = gtk.UI_MANAGER_MENUITEM
            else:
                widget_name = name
                item_type = gtk.UI_MANAGER_SEPARATOR
            uimanager.add_ui(merge_id, base_path, name, widget_name, item_type,
                             False)
            if not menu_key in menu_merges:
                menu_merges[menu_key] = []
            menu_merges[menu_key].append(merge_id)

        def get_menu_funcs(menu_key, base_path):
            append_func = lambda widget, name: \
                    append_menu_item(menu_key, base_path, widget, name)
            clear_func = lambda: clear_menu(menu_key)
            return append_func, clear_func

        for ui_name, base_path in (("view_menu", "/MenuBar/ViewMenu"),
                                   ("file_menu", "/MenuBar/FileMenu"),
                                   ("edit_menu", "/MenuBar/EditMenu"),
                                   ("export_menu",
                                    "/MenuBar/FileMenu/ExportMenu")):
            append_func, clear_func = get_menu_funcs(ui_name, base_path)
            self.settings.register_ui_section(ui_name, append_func, clear_func)
        self.settings.register_ui("file_menu", "Quit",
                                  self.gui.get_object("Quit"), 100)
        self.settings.register_ui("file_menu", "QuitSeparator", None, 95)
        self.settings.register_ui("main_window", "Main", self.menubar, -100)
        # initialize plugins
        self.plugin_manager = pycam.Plugins.PluginManager(core=self.settings)
        self.plugin_manager.import_plugins()
        # some more initialization
        self.reset_preferences()
        # TODO: preferences are not loaded until the new format is stable
        #self.load_preferences()
        #self.load_task_settings()
        self.settings.register_event("notify-file-saved",
                                     self.add_to_recent_file_list)
        self.settings.register_event("notify-file-opened",
                                     self.add_to_recent_file_list)
        # fallback - in case of a failure when opening a model file
        model = pycam.Importers.TestModel.get_test_model()
        self.settings.get("models").add_model(model, "Tiny pyramid")
        # Without this "gkt.main_iteration" loop the task settings file
        # control would not be updated in time.
        while gtk.events_pending():
            gtk.main_iteration()
        autoload_task_filename = self.settings.get(
            "default_task_settings_file")
        if autoload_task_filename:
            self.open_task_settings_file(autoload_task_filename)
        self.update_all_controls()
        self.no_dialog = no_dialog
        if not self.no_dialog:
            # register a logging handler for displaying error messages
            pycam.Utils.log.add_gtk_gui(self.window, logging.ERROR)
            self.window.show()
Esempio n. 39
0
PAGE_GENERAL = 0
PAGE_RELATIONS = 1
PAGE_SIGNATURE = 2
PAGE_BUGS = 3


def _open_link(widget, uri):
    for cmd in ['sensible-browser', 'xdg-open']:
        if webbrowser._iscommand(cmd):
            webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
    webbrowser.open(uri)

if getattr(gtk, 'link_button_set_uri_hook', None) is not None:
    # Not available before PyGtk-2.10
    gtk.link_button_set_uri_hook(_open_link)

class BugsTab(gtk.VBox):

    def __init__(self):
        super(BugsTab, self).__init__(False, 6)

        table = gtk.Table(rows=2, columns=2)

        table.set_row_spacings(6)
        table.set_col_spacing(0, 16)

        image = gtk.Image()
        image.set_from_file(icon_path("bug.png"))
        table.attach(image, 0, 1, 0, 1, gtk.FILL)
Esempio n. 40
0
    def __init__(self, app_name, tc_url='', help_text='',
                 window_id=0, login_only=False):
        """Create the GUI and initialize widgets."""
        gtk.link_button_set_uri_hook(NO_OP)

        self._captcha_filename = tempfile.mktemp()
        self._captcha_id = None
        self._signals_receivers = {}
        self._done = False  # whether the whole process was completed or not

        self.app_name = app_name
        self.app_label = '<b>%s</b>' % self.app_name
        self.tc_url = tc_url
        self.help_text = help_text
        self.login_only = login_only

        self.close_callback = NO_OP
        self.login_success_callback = NO_OP
        self.registration_success_callback = NO_OP
        self.user_cancellation_callback = NO_OP

        self.user_email = None
        self.user_password = None

        ui_filename = get_data_file('gtk', 'ui.glade')
        builder = gtk.Builder()
        builder.add_from_file(ui_filename)
        builder.connect_signals(self)

        self.widgets = []
        self.warnings = []
        self.cancels = []
        self.labels = []
        for obj in builder.get_objects():
            name = getattr(obj, 'name', None)
            if name is None and isinstance(obj, gtk.Buildable):
                # work around bug lp:507739
                name = gtk.Buildable.get_name(obj)
            if name is None:
                logging.warn("%s has no name (??)", obj)
            else:
                self.widgets.append(name)
                setattr(self, name, obj)
                if 'warning' in name:
                    self.warnings.append(obj)
                    obj.set_text('')
                if 'cancel_button' in name:
                    obj.connect('clicked', self.on_close_clicked)
                    self.cancels.append(obj)
                if 'label' in name:
                    obj.connect('size-allocate', self.on_size_allocate)
                    self.labels.append(obj)

        self.entries = (u'name_entry', u'email1_entry', u'email2_entry',
                        u'password1_entry', u'password2_entry',
                        u'captcha_solution_entry', u'email_token_entry',
                        u'login_email_entry', u'login_password_entry',
                        u'reset_email_entry', u'reset_code_entry',
                        u'reset_password1_entry', u'reset_password2_entry')

        for name in self.entries:
            label = getattr(self, name.upper())
            is_password = '******' in name
            entry = LabeledEntry(label=label, is_password=is_password)
            entry.set_activates_default(True)
            setattr(self, name, entry)

        self.window.set_icon_name('ubuntu-logo')

        self.bus = dbus.SessionBus()
        obj = self.bus.get_object(bus_name=DBUS_BUS_NAME,
                                  object_path=DBUS_ACCOUNT_PATH,
                                  follow_name_owner_changes=True)
        self.iface_name = DBUS_IFACE_USER_NAME
        self.backend = dbus.Interface(object=obj,
                                      dbus_interface=self.iface_name)
        logger.debug('UbuntuSSOClientGUI: backend created: %r', self.backend)

        self.pages = (self.enter_details_vbox, self.processing_vbox,
                      self.verify_email_vbox, self.finish_vbox,
                      self.tc_browser_vbox, self.login_vbox,
                      self.request_password_token_vbox,
                      self.set_new_password_vbox)

        self._append_pages()

        self._signals = {
            'CaptchaGenerated':
             self._filter_by_app_name(self.on_captcha_generated),
            'CaptchaGenerationError':
             self._filter_by_app_name(self.on_captcha_generation_error),
            'UserRegistered':
             self._filter_by_app_name(self.on_user_registered),
            'UserRegistrationError':
             self._filter_by_app_name(self.on_user_registration_error),
            'EmailValidated':
             self._filter_by_app_name(self.on_email_validated),
            'EmailValidationError':
             self._filter_by_app_name(self.on_email_validation_error),
            'LoggedIn':
             self._filter_by_app_name(self.on_logged_in),
            'LoginError':
             self._filter_by_app_name(self.on_login_error),
            'UserNotValidated':
             self._filter_by_app_name(self.on_user_not_validated),
            'PasswordResetTokenSent':
             self._filter_by_app_name(self.on_password_reset_token_sent),
            'PasswordResetError':
             self._filter_by_app_name(self.on_password_reset_error),
            'PasswordChanged':
             self._filter_by_app_name(self.on_password_changed),
            'PasswordChangeError':
             self._filter_by_app_name(self.on_password_change_error),
        }
        self._setup_signals()

        if window_id != 0:
            # be as robust as possible:
            # if the window_id is not "good", set_transient_for will fail
            # awfully, and we don't want that: if the window_id is bad we can
            # still do everything as a standalone window. Also,
            # window_foreign_new may return None breaking set_transient_for.
            try:
                win = gtk.gdk.window_foreign_new(window_id)
                self.window.realize()
                self.window.window.set_transient_for(win)
            except:  # pylint: disable=W0702
                msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'
                logger.exception(msg, window_id)

        self.yes_to_updates_checkbutton.hide()

        self.window.show()