Beispiel #1
0
def restart(widget):
    if WIN:
        pass
    if os.path.exists(APP_PATH1):
        subprocess.Popen(['python3', os.path.join(APP_PATH1, 'gis-weather.py')], stdout=subprocess.PIPE)
        dialog.hide()
        Gtk.main_quit() 
Beispiel #2
0
def start_gui(datadir):
    if not options.profile:
        if cfg.get_bool("app/noprofilemanager"):
            options.profile = cfg.get_string("app/last_profile")
        elif do_profiles():
            if solfege.splash_win:
                solfege.splash_win.hide()
            p = ProfileManager(cfg.get_string("app/last_profile"))
            ret = p.run()
            if ret == Gtk.ResponseType.ACCEPT:
                options.profile = p.get_profile()
                cfg.set_string("app/last_profile", "" if not options.profile else options.profile)
            elif ret in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT):
                Gtk.main_quit()
                return
            p.destroy()
            if solfege.splash_win:
                solfege.splash_win.show()

    cfg.set_bool('config/no_random', bool(options.no_random))

    lessonfile.infocache = lessonfile.InfoCache()

    def f(s):
        if solfege.splash_win:
            solfege.splash_win.show_progress(s)
    if solfege.splash_win:
        solfege.splash_win.show_progress(_("Opening statistics database"))
    try:
        solfege.db = statistics.DB(f, profile=options.profile)
    except sqlite3.OperationalError, e:
        solfege.splash_win.hide()
        gu.dialog_ok(_(u"Failed to open the statistics database:\n«%s»") % str(e).decode(sys.getfilesystemencoding(), 'replace'), secondary_text=_("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once."))
        sys.exit()
Beispiel #3
0
    def __key_function(self, entry, event):

        log.LOG("START __key_function")
        if event.keyval == Gdk.KEY_Return:

            self.entryCommandLine.emit_stop_by_name('key_press_event')

        elif event.keyval in (Gdk.KEY_KP_Up, Gdk.KEY_Up, Gdk.KEY_Page_Up):

            self.entryCommandLine.emit_stop_by_name('key_press_event')
            self.historyUp()

        elif event.keyval in (Gdk.KEY_KP_Down, Gdk.KEY_Down, Gdk.KEY_Page_Down):

            self.entryCommandLine.emit_stop_by_name('key_press_event')
            self.historyDown()

        elif event.keyval in (Gdk.KEY_D, Gdk.KEY_d) and\
                event.state & Gdk.ModifierType.CONTROL_MASK:

            self.entryCommandLine.emit_stop_by_name('key_press_event')
            self.setHisoryFile()
            gtk.main_quit()
            self.window.destroy()

        log.LOG("END __key_function")
	def on_close(self):
		""" Triggered when linstaller needs to close shop. """

		# Check if the frontend is glade (or a derivative), otherwise it's useless ;-)
		if "glade" in self.main_settings["frontend"]:
			self.main.hide()
			Gtk.main_quit()
Beispiel #5
0
    def _update_progress(self):
        if self._terminate:
            # give users time to realize they should stop typing
            time.sleep(3)
            Gtk.main_quit()
            # remove the method from idle queue
            return False
        else:
            self._num_loops += 1
            current_entropy = get_current_entropy()
            current_fraction = min(float(current_entropy) / self._desired_entropy, 1.0)
            remaining = (MAX_ENTROPY_WAIT * 1000 - self._num_loops * LOOP_TIMEOUT) / 1000 / 60.0

            self._progress_bar.set_fraction(current_fraction)
            self._progress_bar.set_text("%(pct)d %% (%(rem)d %(min)s remaining)" % {"pct": (int(current_fraction * 100)),
                                                                                    "rem": math.ceil(remaining),
                                                                                    "min": P_("minute", "minutes", int(remaining))})

            # if we have enough our time ran out, terminate the dialog, but let
            # the progress_bar refresh in the main loop
            self._terminate = (current_entropy >= self._desired_entropy) or (remaining <= 0)

            self.force_cont = (remaining <= 0)

            # keep updating
            return True
Beispiel #6
0
    def on_window_destroy(self, widget):
        """
        Handler for closing window.

        A quick clean kill of the entire app.
        """

        # need to save any changes first.
        context = self.statusbar.get_context_id('Quit')
        if self.__dirty:
            dialog = Gtk.MessageDialog(
                                       self.window,
                                       Gtk.DialogFlags.MODAL,
                                       Gtk.MessageType.QUESTION,
                                       Gtk.ButtonsType.YES_NO,
                                       'There are unsaved changes. Save now?',
                                       )
            dialog.set_decorated(False)
            response = dialog.run()
            dialog.destroy()
            if response == Gtk.ResponseType.YES:
                self.on_fileSaveAction_activate(widget)

        self.statusbar.push(context, 'Destroying main window')
        Gtk.main_quit()
 def Terminar(self, dos, tres):
     """Cierre do programa"""
     self.ventanaEntrada.connect("delete-event", Gtk.main_quit)
     self.ventanaIntroducir.connect("delete-event", Gtk.main_quit)
     self.ventanaEliminar.connect("delete-event", Gtk.main_quit)
     self.ventanaConsultas.connect("delete-event", Gtk.main_quit)
     Gtk.main_quit()
Beispiel #8
0
    def starterate(self):
        try:
            self.final_file = starterates.starterate(self.db, self.config_info, self.info, 
                gui=self, event=self.stop_thread)
            # print self.final_file
        except:
            if self.stop_thread.is_set():
                return
            self.db.close()
            self.stop = True
            Gdk.threads_enter()
            dialog = Gtk.MessageDialog(self.parent, 0, Gtk.MessageType.ERROR,
                Gtk.ButtonsType.CANCEL, "Starterator has encountered an error")
            dialog.format_secondary_text(
            "Please try again.")
            dialog.run()
            dialog.destroy()
            Gdk.threads_leave()
            # self.stop = True
            raise
 
        else:
            self.db.close()
            if self.stop_thread.is_set():
                # clean up files?
                # show dialog
                return
            Gdk.threads_enter()
            done_dialog = StarteratorFinishedDialog(self.parent, self.final_file)
            response = done_dialog.run()
            if response == Gtk.ResponseType.NO:
                Gtk.main_quit()
            done_dialog.destroy()
            Gdk.threads_leave()
    def on_hide_window(self, widget):
        configuration = self.serialize()

        if configuration == self._initial_configuration_data:
            Gtk.main_quit()
            return

        dialog = False

        def _msgrsp(widget, response):
            if dialog:
                dialog.destroy()
            if Gtk.ResponseType.YES == response:
                try:
                    with open(CONFIGURATION_FILE_PATH, "wb") as output:
                        output.write(configuration)
                    Gtk.main_quit()
                except:
                    error = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, "Failed to save configuration to ~/.config/fakexrandr.bin")
                    error.connect("response", lambda *a: Gtk.main_quit())
                    error.show()
                    return
            Gtk.main_quit()

        if not self._initial_configuration_data:
            _msgrsp(False, Gtk.ResponseType.YES)
            return

        dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, "Save new configuration?")
        dialog.connect("response", _msgrsp)
        dialog.show()
Beispiel #10
0
    def _on_continue_clicked(self, win, user_data=None):
        if not win.get_may_continue() or win != self._currentAction.window:
            return

        # If we're on the last screen, clicking Continue quits.
        if len(self._actions) == 1:
            Gtk.main_quit()
            return

        nextAction = None
        ndx = 0

        # If the current action wants us to jump to an arbitrary point ahead,
        # look for where that is now.
        if self._currentAction.skipTo:
            found = False
            for ndx in range(1, len(self._actions)):
                if self._actions[ndx].__class__.__name__ == self._currentAction.skipTo:
                    found = True
                    break

            # If we found the point in question, compose a new actions list
            # consisting of the current action, the one to jump to, and all
            # the ones after.  That means the rest of the code below doesn't
            # have to change.
            if found:
                self._actions = [self._actions[0]] + self._actions[ndx:]

        # _instantiateAction returns None for actions that should not be
        # displayed (because they're already completed, for instance) so skip
        # them here.
        while not nextAction:
            nextAction = self._instantiateAction(self._actions[1])
            if not nextAction:
                self._actions.pop(1)

            if not self._actions:
                sys.exit(0)
                return

        nextAction.initialize()
        nextAction.window.set_beta(self._currentAction.window.get_beta())
        nextAction.window.set_property("distribution", self._distributionText().upper())

        if not nextAction.showable:
            self._currentAction.window.hide()
            self._actions.pop(0)
            self._on_continue_clicked(nextAction)
            return

        self._currentAction.exit_logger()
        nextAction.entry_logger()

        nextAction.refresh()

        # Do this last.  Setting up curAction could take a while, and we want
        # to leave something on the screen while we work.
        self.mainWindow.setCurrentAction(nextAction)
        self._currentAction = nextAction
        self._actions.pop(0)
Beispiel #11
0
 def quit(self, *args):
     self.stop_blinking()
     Gdk.threads_leave()
     self.window.destroy()
     Gtk.main_quit()
     import sys
     sys.exit(0)
Beispiel #12
0
def key_pressed(widget, ev):
    key = Gdk.keyval_name(ev.keyval)

    if key == "Left" or key == "Page_Up":
        set_page(page_idx - 1)
    elif key == "Right" or key == "space" or key == "Page_Down":
        set_page(page_idx + 1)
    elif key == "s":
        log_time("restarted")
        print()
        stopwatch.restart()
    elif key == "p":
        if stopwatch.is_paused():
            log_time("resumed")
            stopwatch.resume()
        else:
            log_time("paused")
            stopwatch.pause()
    elif key == "r":
        log_time("reloaded")
        slides_window.reload_document()
        notes_window.reload_document()
    elif key == "Escape" or key == "backslash":
        if slides_window.page_idx is None:
            slides_window.page_idx = page_idx
            log_time("froze")
        else:
            slides_window.page_idx = None
            log_time("unfroze")
        slides_window.queue_draw()
        notes_window.queue_draw()
    elif key == "q":
        Gtk.main_quit()
Beispiel #13
0
 def on_connect_clicked(self, widget):
     try:
         remote_ip=socket.gethostbyname(host)
     except socket.gaierror, e:
         # could not resolve
         printSocketError(e)
         Gtk.main_quit()
Beispiel #14
0
def connection_ready_cb(connection):
    # The connection's status has changed to CONNECTED and its supported
    # interfaces have been checked

    print('connected and ready')
    handle = conn[CONN_INTERFACE].GetSelfHandle()
    tokens = conn[CONN_INTERFACE_AVATARS].GetAvatarTokens([handle])
    print('token:', tokens[0])

    if len(sys.argv) > 2:
        avatar = file(sys.argv[2]).read()
        new_token = conn[CONN_INTERFACE_AVATARS].SetAvatar(avatar, 'image/png')
        print('new token:', new_token)
        Gtk.main_quit()
        return

    image, mime = conn[CONN_INTERFACE_AVATARS].RequestAvatar(handle)
    image = ''.join(chr(i) for i in image)

    window = Gtk.Window()
    loader = Gtk.gdk.PixbufLoader()
    loader.write(image)
    loader.close()
    image = Gtk.Image()
    image.set_from_pixbuf(loader.get_pixbuf())
    window.add(image)
    window.show_all()
    window.connect('destroy', Gtk.main_quit)
Beispiel #15
0
    def quit_application(self, *args):
        if not self.close_dialog:
            self.close_dialog = Gtk.MessageDialog(
                parent=self._window,
                flags=Gtk.DialogFlags.MODAL,
                type=Gtk.MessageType.WARNING)
            self.close_dialog.add_buttons(
                _(u"Close without saving"), Gtk.ResponseType.CLOSE,
                Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
            self.close_dialog.set_markup(
                _(u"<b>Save the project before closing?</b>\n\nIf you do not save you may loose data."))
            self.close_dialog.set_default_response(Gtk.ResponseType.CANCEL)

        response = self.close_dialog.run()
        self.close_dialog.hide()

        if response == Gtk.ResponseType.CLOSE:
            Gtk.main_quit()
            return False
        elif response == Gtk.ResponseType.OK:
            self.save_project()
            Gtk.main_quit()
            return False
        else:
            return True
Beispiel #16
0
    def exit_app(self, src):
        if self.err is None:
            # Already in cleanup
            return

        self.cleanup()

        if debug_ref_leaks:
            objs = self.config.get_objects()

            # Engine will always appear to leak
            objs.remove(self.object_key)

            if src.object_key in objs:
                # UI that initiates the app exit will always appear to leak
                objs.remove(src.object_key)

            for name in objs:
                logging.debug("Leaked %s", name)

        logging.debug("Exiting app normally.")

        # We need this if there are any asyncdialog fobjs running
        if Gtk.main_level():
            logging.debug("%s other gtk main loops running, killing them.",
                          Gtk.main_level())
            for ignore in range(Gtk.main_level()):
                Gtk.main_quit()

        self.application.remove_window(self._appwindow)
Beispiel #17
0
 def on_destroy(self, widget):
     if self.interpreter:
         self.interpreter.cleanup()
     if self.parent:
         self.destroy()
     else:
         Gtk.main_quit()
Beispiel #18
0
	def on_win_sync_delete_event(self, *args):
		for root in self.roots:
			try:
				root.close()
			except:
				pass
		Gtk.main_quit()
Beispiel #19
0
	def sair(self, widget):
		os.remove('imagem_dia.jpg')
		os.remove('imagem_dia1.jpg')
		os.remove('imagem_dia2.jpg')
		os.remove('imagem_dia3.jpg')
		os.remove('imagem_dia4.jpg')
		Gtk.main_quit()
Beispiel #20
0
def close_window(self, event):
    # ctrl+q or ctrl+w
    if event.state & Gdk.ModifierType.CONTROL_MASK and (event.keyval == 113 or event.keyval == 119):
        if self.get_name() == 'GtkWindow':
            Gtk.main_quit()
        else:
            self.destroy()
 def lock_screen(self, data):
     message = self.entry.get_text()
     if (message != ""):
         os.system("cinnamon-screensaver-command --lock --away-message \"%s\" &" % self.entry.get_text())
     else:
         os.system("cinnamon-screensaver-command --lock &")
     Gtk.main_quit()
Beispiel #22
0
def quit_tlp_config(self, tlpconfig, window):
    changedproperties = get_changed_properties(tlpconfig)
    if len(changedproperties) == 0:
        Gtk.main_quit()
        return

    dialog = Gtk.Dialog(T_('Changed values'), window, 0, (
        Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
        Gtk.STOCK_OK, Gtk.ResponseType.OK
    ))
    dialog.set_default_size(150, 100)

    changeditemstext = T_('Do you really want to quit?\nFollowing items have changed:') + '\n\n'
    for property in changedproperties:
        changeditemstext += (property[0] + " -> " + property[2] + "\n\n")
    changeditemstext += T_('No changes will be saved.')

    label = Gtk.Label()
    label.set_markup(changeditemstext)
    label.set_valign(Gtk.Align.CENTER)
    box = dialog.get_content_area()
    box.pack_start(label, True, True, 0)

    dialog.show_all()
    response = dialog.run()

    if response == Gtk.ResponseType.OK:
        Gtk.main_quit()

    dialog.destroy()
Beispiel #23
0
    def cancel (self):
        if self.watchers > 0:
            debugprint ("Command canceled")
            Gtk.main_quit ()
            self.watchers = 0

        return False
 def close(self, *obj):
     """
     Close the assistant.
     """
     self.hide()
     if self.ownthread:
         Gtk.main_quit()
Beispiel #25
0
 def on_usbcreator_destroy(self, widget):
     # Unmount devices
     for device in self.devices:
         if self.get_device_mount(device) != "":
             self.unmount_device(device)
     # Close the app
     Gtk.main_quit()
Beispiel #26
0
 def __on_quit(self, widget):
     """Does various cleaning necessary before quitting
     """
     self.__on_active_window_changed(self.__screen, self.__current_window)
     self.__model.close()
     logging.info("Quitting")
     Gtk.main_quit()
Beispiel #27
0
    def done(self, button):
        """Confirm choice"""
        dialog = Gtk.Dialog(txt.I_CONFIRM_SELECTION, None, 0, (
            Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
            Gtk.STOCK_OK, Gtk.ResponseType.OK))
        dialog.set_transient_for(self)
        dialog.set_border_width(10)
        box = dialog.get_content_area()
        box.set_spacing(10)
        box.add(Gtk.Label(txt.I_USE_THESE_MIRRORS))
        dialog.show_all()
        response = dialog.run()

        if response == Gtk.ResponseType.OK:
            # Quit GUI
            dialog.destroy()
            for line in self.custom_list:
                line["last_sync"] = line["last_sync"].replace(" ", ":").replace("h", "").replace("m", "")
            if self.random:
                shuffle(self.custom_list)
            else:
                self.custom_list.sort(key=itemgetter("resp_time"))
            self.is_done = True
            Gtk.main_quit()
        elif response == Gtk.ResponseType.CANCEL:
            dialog.destroy()  # Go back to selection
Beispiel #28
0
    def _on_operation_status_changed(self, operation):
        if (self._in_nested_main_loop and
                self._is_rendering_finished()):
            Gtk.main_quit()

        if self.get_status() == Gtk.PrintStatus.FINISHED_ABORTED:
            terminate_thread(self._rendering_thread)
        def destroy(self, window):
            try:
                self.conn.destroy()
            except AttributeError:
                pass

            Gtk.main_quit()
Beispiel #30
0
	def on_mainWindow_destroy(self, widget,arg=None):
		"""Fin de l'application"""
		if self.engine:
			self.curs.close()
			self.engine.close()
			print "Base sauvegardee"
		Gtk.main_quit()