Пример #1
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()
        def destroy(self, window):
            try:
                self.conn.destroy()
            except AttributeError:
                pass

            Gtk.main_quit()
Пример #3
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
Пример #4
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() 
Пример #5
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")
Пример #6
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()
Пример #7
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()
Пример #8
0
    def cancel (self):
        if self.watchers > 0:
            debugprint ("Command canceled")
            Gtk.main_quit ()
            self.watchers = 0

        return False
Пример #9
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
 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()
Пример #11
0
	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()
Пример #12
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()
Пример #13
0
 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()
Пример #14
0
 def on_destroy(self, widget):
     if self.interpreter:
         self.interpreter.cleanup()
     if self.parent:
         self.destroy()
     else:
         Gtk.main_quit()
Пример #15
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()
Пример #16
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)
Пример #17
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
Пример #18
0
 def close(self, *obj):
     """
     Close the assistant.
     """
     self.hide()
     if self.ownthread:
         Gtk.main_quit()
Пример #19
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()
Пример #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()
Пример #21
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()
Пример #22
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)
Пример #23
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()
Пример #24
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)
Пример #25
0
 def quit(self, *args):
     self.stop_blinking()
     Gdk.threads_leave()
     self.window.destroy()
     Gtk.main_quit()
     import sys
     sys.exit(0)
Пример #26
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()
Пример #27
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()
Пример #28
0
    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()
Пример #29
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)
Пример #30
0
	def on_win_sync_delete_event(self, *args):
		for root in self.roots:
			try:
				root.close()
			except:
				pass
		Gtk.main_quit()
Пример #31
0
 def quit(self, *args):
     Gtk.main_quit()
Пример #32
0
 def on_btnSalir_clicked(self, widget):
     Gtk.main_quit()
Пример #33
0
 def on_imagemenuitem5_activate(self, widget):
     Gtk.main_quit()
Пример #34
0
 def quit(*_):
     """Uninitialize everything and then quit"""
     Notify.uninit()
     Gtk.main_quit()
Пример #35
0
 def quit_and_kill_worker(self,widget):
     self.worker.quit = True
     self.worker.join()
     print("Quiting PyTracking")
     Gtk.main_quit()
Пример #36
0
 def exit(self, widget, *args):
     import sys
     print('exit')
     Gtk.main_quit()
     sys.exit()
Пример #37
0
        y = b + f2_amt * eff_ht
        return x, y

    def paint_foreground_cb(self, cr, wd, ht):
        x, y = self.get_position_for_color(self.get_managed_color())
        draw_marker_circle(cr, x, y)


if __name__ == '__main__':
    import os
    import sys
    from adjbases import ColorManager
    mgr = ColorManager(prefs={}, datapath='.')
    cube = HSVCubePage()
    cube.set_color_manager(mgr)
    mgr.set_color(RGBColor(0.3, 0.6, 0.7))
    if len(sys.argv) > 1:
        slice = HSVCubeSlice(cube)
        slice.set_color_manager(mgr)
        icon_name = cube.get_page_icon_name()
        for dir_name in sys.argv[1:]:
            slice.save_icon_tree(dir_name, icon_name)
    else:
        # Interactive test
        window = Gtk.Window()
        window.add(cube.get_page_widget())
        window.set_title(os.path.basename(sys.argv[0]))
        window.connect("destroy", lambda *a: Gtk.main_quit())
        window.show_all()
        Gtk.main()
Пример #38
0
 def quit(widget, event):
     Gtk.main_quit()
     return True
Пример #39
0
 def stop(self, *args):
     """Cleanly shut down, unmuting sound and saving the blocklist."""
     self.b.prepare_stop()
     log.debug("Exiting GUI.")
     Gtk.main_quit()
     sys.exit()
Пример #40
0
 def close(self):
     try:
         gtk.main_quit()
     except RuntimeError:
         raise SystemExit()
Пример #41
0
 def on_destroy(self, widget, data=None):
     """Called when the CompdaysrecorderWindow is closed."""
     # Clean up code for saving application state should be added here.
     Gtk.main_quit()
Пример #42
0
 def cb(window, event):
     Gtk.main_quit()
Пример #43
0
 def on_close_clicked(self, button):
     print("Closing application")
     Gtk.main_quit()
Пример #44
0
 def onDestroy(self, *args):
     Gtk.main_quit()
Пример #45
0
 def _destroy_cb(self, win, event):
     ''' Callback to handle quit '''
     Gtk.main_quit()
Пример #46
0
    def main_quit(self, event):
        for quadID in range (0, 4):
            self.quad[quadID].writeToFile()

        Gtk.main_quit(event)
Пример #47
0
 def on_main_window_destroy(self, window):
     Gtk.main_quit()
Пример #48
0
# Typing Turtle is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Typing Turtle.  If not, see <http://www.gnu.org/licenses/>.

import sys
import keyboard

from gi.repository import Gtk

window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
window.set_title("keyboard widget")
window.connect("destroy", lambda w: Gtk.main_quit())
window.show_all()
window.realize()

image = keyboard.KeyboardImages(800, 400)
image.load_images()

k = keyboard.KeyboardWidget(image, window, poll_keys=True)
try:
    k.load_letter_map(sys.argv[1])
except:
    pass
k.set_layout(keyboard.get_layout())

savebtn = Gtk.Button()
savebtn.add(Gtk.Label(label='Save Keys'))
Пример #49
0
def quit_all(widget):
    Gtk.main_quit()
    sys.exit(0)
Пример #50
0
 def on_window_main_destroy(self, widget, data=None):
     print("on_window_main_destory")
     Gtk.main_quit()
Пример #51
0
 def onDeleteWindow(self, *args):
     self.ShowDlFldigi(False)
     Gtk.main_quit(*args)
Пример #52
0
 def __main_quit(self):
     self.configuration_manager.configurationToXml()
     self.configuration_manager.removeTemporaryFolder()
     Gtk.main_quit()
Пример #53
0
    def _handle_action(self, action, *args):
        log.debug("_handle_action({0}, {1})".format(action, args))
        main = self.main_window
        page = main.current_page
        flow_graph = page.flow_graph if page else None

        def flow_graph_update(fg=flow_graph):
            main.vars.update_gui(fg.blocks)
            fg.update()

        ##################################################
        # Initialize/Quit
        ##################################################
        if action == Actions.APPLICATION_INITIALIZE:
            log.debug("APPLICATION_INITIALIZE")
            file_path_to_show = self.config.file_open()
            for file_path in (self.init_file_paths
                              or self.config.get_open_files()):
                if os.path.exists(file_path):
                    main.new_page(file_path,
                                  show=file_path_to_show == file_path)
            if not main.current_page:
                main.new_page()  # ensure that at least a blank page exists

            main.btwin.search_entry.hide()
            """
            Only disable certain actions on startup. Each of these actions are
            conditionally enabled in _handle_action, so disable them first.
             - FLOW_GRAPH_UNDO/REDO are set in gui/StateCache.py
             - XML_PARSER_ERRORS_DISPLAY is set in RELOAD_BLOCKS

            TODO: These 4 should probably be included, but they are not currently
            enabled anywhere else:
             - PORT_CONTROLLER_DEC, PORT_CONTROLLER_INC
             - BLOCK_INC_TYPE, BLOCK_DEC_TYPE

            TODO: These should be handled better. They are set in
            update_exec_stop(), but not anywhere else
             - FLOW_GRAPH_GEN, FLOW_GRAPH_EXEC, FLOW_GRAPH_KILL
            """
            for action in (Actions.ERRORS_WINDOW_DISPLAY,
                           Actions.ELEMENT_DELETE, Actions.BLOCK_PARAM_MODIFY,
                           Actions.BLOCK_ROTATE_CCW, Actions.BLOCK_ROTATE_CW,
                           Actions.BLOCK_VALIGN_TOP,
                           Actions.BLOCK_VALIGN_MIDDLE,
                           Actions.BLOCK_VALIGN_BOTTOM,
                           Actions.BLOCK_HALIGN_LEFT,
                           Actions.BLOCK_HALIGN_CENTER,
                           Actions.BLOCK_HALIGN_RIGHT, Actions.BLOCK_CUT,
                           Actions.BLOCK_COPY, Actions.BLOCK_PASTE,
                           Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE,
                           Actions.BLOCK_BYPASS, Actions.BLOCK_CREATE_HIER,
                           Actions.OPEN_HIER, Actions.BUSSIFY_SOURCES,
                           Actions.BUSSIFY_SINKS, Actions.FLOW_GRAPH_SAVE,
                           Actions.FLOW_GRAPH_UNDO, Actions.FLOW_GRAPH_REDO,
                           Actions.XML_PARSER_ERRORS_DISPLAY):
                action.disable()

            # Load preferences
            for action in (
                    Actions.TOGGLE_BLOCKS_WINDOW,
                    Actions.TOGGLE_CONSOLE_WINDOW,
                    Actions.TOGGLE_HIDE_DISABLED_BLOCKS,
                    Actions.TOGGLE_SCROLL_LOCK,
                    Actions.TOGGLE_AUTO_HIDE_PORT_LABELS,
                    Actions.TOGGLE_SNAP_TO_GRID,
                    Actions.TOGGLE_SHOW_BLOCK_COMMENTS,
                    Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB,
                    Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY,
                    Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR,
                    Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR,
                    Actions.TOGGLE_HIDE_VARIABLES,
                    Actions.TOGGLE_SHOW_BLOCK_IDS,
            ):
                action.set_enabled(True)
                if hasattr(action, 'load_from_preferences'):
                    action.load_from_preferences()

            # Hide the panels *IF* it's saved in preferences
            main.update_panel_visibility(
                main.BLOCKS, Actions.TOGGLE_BLOCKS_WINDOW.get_active())
            main.update_panel_visibility(
                main.CONSOLE, Actions.TOGGLE_CONSOLE_WINDOW.get_active())
            main.update_panel_visibility(
                main.VARIABLES,
                Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR.get_active())

            # Force an update on the current page to match loaded preferences.
            # In the future, change the __init__ order to load preferences first
            page = main.current_page
            if page:
                page.flow_graph.update()

            self.init = True
        elif action == Actions.APPLICATION_QUIT:
            if main.close_pages():
                while Gtk.main_level():
                    Gtk.main_quit()
                exit(0)
        ##################################################
        # Selections
        ##################################################
        elif action == Actions.ELEMENT_SELECT:
            pass  #do nothing, update routines below
        elif action == Actions.NOTHING_SELECT:
            flow_graph.unselect()
        elif action == Actions.SELECT_ALL:
            if main.btwin.search_entry.has_focus():
                main.btwin.search_entry.select_region(0, -1)
            else:
                flow_graph.select_all()
        ##################################################
        # Enable/Disable
        ##################################################
        elif action in (Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE,
                        Actions.BLOCK_BYPASS):
            changed = flow_graph.change_state_selected(
                new_state={
                    Actions.BLOCK_ENABLE: 'enabled',
                    Actions.BLOCK_DISABLE: 'disabled',
                    Actions.BLOCK_BYPASS: '******',
                }[action])
            if changed:
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        ##################################################
        # Cut/Copy/Paste
        ##################################################
        elif action == Actions.BLOCK_CUT:
            Actions.BLOCK_COPY()
            Actions.ELEMENT_DELETE()
        elif action == Actions.BLOCK_COPY:
            self.clipboard = flow_graph.copy_to_clipboard()
        elif action == Actions.BLOCK_PASTE:
            if self.clipboard:
                flow_graph.paste_from_clipboard(self.clipboard)
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        ##################################################
        # Create hier block
        ##################################################
        elif action == Actions.BLOCK_CREATE_HIER:

            selected_blocks = []

            pads = []
            params = set()

            for block in flow_graph.selected_blocks():
                selected_blocks.append(block)
                # Check for string variables within the blocks
                for param in block.params.values():
                    for variable in flow_graph.get_variables():
                        # If a block parameter exists that is a variable, create a parameter for it
                        if param.get_value() == variable.name:
                            params.add(param.get_value())
                    for flow_param in flow_graph.get_parameters():
                        # If a block parameter exists that is a parameter, create a parameter for it
                        if param.get_value() == flow_param.name:
                            params.add(param.get_value())

            x_min = min(block.coordinate[0] for block in selected_blocks)
            y_min = min(block.coordinate[1] for block in selected_blocks)

            for connection in flow_graph.connections:

                # Get id of connected blocks
                source = connection.source_block
                sink = connection.sink_block

                if source not in selected_blocks and sink in selected_blocks:
                    # Create Pad Source
                    pads.append({
                        'key': connection.sink_port.key,
                        'coord': source.coordinate,
                        'block_index': selected_blocks.index(sink) +
                        1,  # Ignore the options block
                        'direction': 'source'
                    })

                elif sink not in selected_blocks and source in selected_blocks:
                    # Create Pad Sink
                    pads.append({
                        'key': connection.source_port.key,
                        'coord': sink.coordinate,
                        'block_index': selected_blocks.index(source) +
                        1,  # Ignore the options block
                        'direction': 'sink'
                    })

            # Copy the selected blocks and paste them into a new page
            #   then move the flowgraph to a reasonable position
            Actions.BLOCK_COPY()
            main.new_page()
            flow_graph = main.current_page.flow_graph
            Actions.BLOCK_PASTE()
            coords = (x_min, y_min)
            flow_graph.move_selected(coords)

            # Set flow graph to heir block type
            top_block = flow_graph.get_block("top_block")
            top_block.params['generate_options'].set_value('hb')

            # this needs to be a unique name
            top_block.params['id'].set_value('new_hier')

            # Remove the default samp_rate variable block that is created
            remove_me = flow_graph.get_block("samp_rate")
            flow_graph.remove_element(remove_me)

            # Add the param blocks along the top of the window
            x_pos = 150
            for param in params:
                param_id = flow_graph.add_new_block('parameter', (x_pos, 10))
                param_block = flow_graph.get_block(param_id)
                param_block.params['id'].set_value(param)
                x_pos = x_pos + 100

            for pad in pads:
                # add the pad sources and sinks within the new hier block
                if pad['direction'] == 'sink':

                    # add new pad_sink block to the canvas
                    pad_id = flow_graph.add_new_block('pad_sink', pad['coord'])

                    # setup the references to the sink and source
                    pad_block = flow_graph.get_block(pad_id)
                    pad_sink = pad_block.sinks[0]

                    source_block = flow_graph.get_block(
                        flow_graph.blocks[pad['block_index']].name)
                    source = source_block.get_source(pad['key'])

                    # ensure the port types match
                    if pad_sink.dtype != source.dtype:
                        if pad_sink.dtype == 'complex' and source.dtype == 'fc32':
                            pass
                        else:
                            pad_block.params['type'].value = source.dtype
                            pad_sink.dtype = source.dtype

                    # connect the pad to the proper sinks
                    new_connection = flow_graph.connect(source, pad_sink)

                elif pad['direction'] == 'source':
                    pad_id = flow_graph.add_new_block('pad_source',
                                                      pad['coord'])

                    # setup the references to the sink and source
                    pad_block = flow_graph.get_block(pad_id)
                    pad_source = pad_block.sources[0]

                    sink_block = flow_graph.get_block(
                        flow_graph.blocks[pad['block_index']].name)
                    sink = sink_block.get_sink(pad['key'])

                    # ensure the port types match
                    if pad_source.dtype != sink.dtype:
                        if pad_source.dtype == 'complex' and sink.dtype == 'fc32':
                            pass
                        else:
                            pad_block.params['type'].value = sink.dtype
                            pad_source.dtype = sink.dtype

                    # connect the pad to the proper sinks
                    new_connection = flow_graph.connect(pad_source, sink)

            flow_graph_update(flow_graph)
        ##################################################
        # Move/Rotate/Delete/Create
        ##################################################
        elif action == Actions.BLOCK_MOVE:
            page.state_cache.save_new_state(flow_graph.export_data())
            page.saved = False
        elif action in Actions.BLOCK_ALIGNMENTS:
            if flow_graph.align_selected(action):
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        elif action == Actions.BLOCK_ROTATE_CCW:
            if flow_graph.rotate_selected(90):
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        elif action == Actions.BLOCK_ROTATE_CW:
            if flow_graph.rotate_selected(-90):
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        elif action == Actions.ELEMENT_DELETE:
            if flow_graph.remove_selected():
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                Actions.NOTHING_SELECT()
                page.saved = False
        elif action == Actions.ELEMENT_CREATE:
            flow_graph_update()
            page.state_cache.save_new_state(flow_graph.export_data())
            Actions.NOTHING_SELECT()
            page.saved = False
        elif action == Actions.BLOCK_INC_TYPE:
            if flow_graph.type_controller_modify_selected(1):
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        elif action == Actions.BLOCK_DEC_TYPE:
            if flow_graph.type_controller_modify_selected(-1):
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        elif action == Actions.PORT_CONTROLLER_INC:
            if flow_graph.port_controller_modify_selected(1):
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        elif action == Actions.PORT_CONTROLLER_DEC:
            if flow_graph.port_controller_modify_selected(-1):
                flow_graph_update()
                page.state_cache.save_new_state(flow_graph.export_data())
                page.saved = False
        ##################################################
        # Window stuff
        ##################################################
        elif action == Actions.ABOUT_WINDOW_DISPLAY:
            Dialogs.show_about(main, self.platform.config)
        elif action == Actions.HELP_WINDOW_DISPLAY:
            Dialogs.show_help(main)
        elif action == Actions.GET_INVOLVED_WINDOW_DISPLAY:
            Dialogs.show_get_involved(main)
        elif action == Actions.TYPES_WINDOW_DISPLAY:
            Dialogs.show_types(main)
        elif action == Actions.KEYBOARD_SHORTCUTS_WINDOW_DISPLAY:
            Dialogs.show_keyboard_shortcuts(main)
        elif action == Actions.ERRORS_WINDOW_DISPLAY:
            Dialogs.ErrorsDialog(main, flow_graph).run_and_destroy()
        elif action == Actions.TOGGLE_CONSOLE_WINDOW:
            action.set_active(not action.get_active())
            main.update_panel_visibility(main.CONSOLE, action.get_active())
            action.save_to_preferences()
        elif action == Actions.TOGGLE_BLOCKS_WINDOW:
            # This would be better matched to a Gio.PropertyAction, but to do
            # this, actions would have to be defined in the window not globally
            action.set_active(not action.get_active())
            main.update_panel_visibility(main.BLOCKS, action.get_active())
            action.save_to_preferences()
        elif action == Actions.TOGGLE_SCROLL_LOCK:
            action.set_active(not action.get_active())
            active = action.get_active()
            main.console.text_display.scroll_lock = active
            if active:
                main.console.text_display.scroll_to_end()
            action.save_to_preferences()
        elif action == Actions.CLEAR_CONSOLE:
            main.console.text_display.clear()
        elif action == Actions.SAVE_CONSOLE:
            file_path = FileDialogs.SaveConsole(main, page.file_path).run()
            if file_path is not None:
                main.console.text_display.save(file_path)
        elif action == Actions.TOGGLE_HIDE_DISABLED_BLOCKS:
            action.set_active(not action.get_active())
            flow_graph_update()
            action.save_to_preferences()
            page.state_cache.save_new_state(flow_graph.export_data())
            Actions.NOTHING_SELECT()
        elif action == Actions.TOGGLE_AUTO_HIDE_PORT_LABELS:
            action.set_active(not action.get_active())
            action.save_to_preferences()
            for page in main.get_pages():
                page.flow_graph.create_shapes()
        elif action in (Actions.TOGGLE_SNAP_TO_GRID,
                        Actions.TOGGLE_SHOW_BLOCK_COMMENTS,
                        Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB):
            action.set_active(not action.get_active())
            action.save_to_preferences()
        elif action == Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY:
            action.set_active(not action.get_active())
            action.save_to_preferences()
            for page in main.get_pages():
                flow_graph_update(page.flow_graph)
        elif action == Actions.TOGGLE_HIDE_VARIABLES:
            action.set_active(not action.get_active())
            active = action.get_active()
            # Either way, triggering this should simply trigger the variable editor
            # to be visible.
            varedit = Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR
            if active:
                log.debug(
                    "Variables are hidden. Forcing the variable panel to be visible."
                )
                varedit.disable()
            else:
                varedit.enable()
            # Just force it to show.
            varedit.set_active(True)
            main.update_panel_visibility(main.VARIABLES)
            Actions.NOTHING_SELECT()
            action.save_to_preferences()
            varedit.save_to_preferences()
            flow_graph_update()
        elif action == Actions.TOGGLE_SHOW_BLOCK_IDS:
            action.set_active(not action.get_active())
            active = action.get_active()
            Actions.NOTHING_SELECT()
            action.save_to_preferences()
            flow_graph_update()
        elif action == Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR:
            # TODO: There may be issues at startup since these aren't triggered
            # the same was as Gtk.Actions when loading preferences.
            action.set_active(not action.get_active())
            # Just assume this was triggered because it was enabled.
            main.update_panel_visibility(main.VARIABLES, action.get_active())
            action.save_to_preferences()

            # Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR.set_enabled(action.get_active())
            action.save_to_preferences()
        elif action == Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR:
            action.set_active(not action.get_active())
            if self.init:
                Dialogs.MessageDialogWrapper(
                    main,
                    Gtk.MessageType.INFO,
                    Gtk.ButtonsType.CLOSE,
                    markup=
                    "Moving the variable editor requires a restart of GRC."
                ).run_and_destroy()
                action.save_to_preferences()
        ##################################################
        # Param Modifications
        ##################################################
        elif action == Actions.BLOCK_PARAM_MODIFY:
            selected_block = args[0] if args[0] else flow_graph.selected_block
            if selected_block:
                self.dialog = PropsDialog(self.main_window, selected_block)
                response = Gtk.ResponseType.APPLY
                while response == Gtk.ResponseType.APPLY:  # rerun the dialog if Apply was hit
                    response = self.dialog.run()
                    if response in (Gtk.ResponseType.APPLY,
                                    Gtk.ResponseType.ACCEPT):
                        page.state_cache.save_new_state(
                            flow_graph.export_data())
                        ### Following  line forces a complete update of io ports
                        flow_graph_update()
                        page.saved = False
                    else:  # restore the current state
                        n = page.state_cache.get_current_state()
                        flow_graph.import_data(n)
                        flow_graph_update()
                    if response == Gtk.ResponseType.APPLY:
                        # null action, that updates the main window
                        Actions.ELEMENT_SELECT()
                self.dialog.destroy()
                self.dialog = None
        elif action == Actions.EXTERNAL_UPDATE:
            page.state_cache.save_new_state(flow_graph.export_data())
            flow_graph_update()
            if self.dialog is not None:
                self.dialog.update_gui(force=True)
            page.saved = False
        elif action == Actions.VARIABLE_EDITOR_UPDATE:
            page.state_cache.save_new_state(flow_graph.export_data())
            flow_graph_update()
            page.saved = False
        ##################################################
        # View Parser Errors
        ##################################################
        elif action == Actions.XML_PARSER_ERRORS_DISPLAY:
            pass
        ##################################################
        # Undo/Redo
        ##################################################
        elif action == Actions.FLOW_GRAPH_UNDO:
            n = page.state_cache.get_prev_state()
            if n:
                flow_graph.unselect()
                flow_graph.import_data(n)
                flow_graph_update()
                page.saved = False
        elif action == Actions.FLOW_GRAPH_REDO:
            n = page.state_cache.get_next_state()
            if n:
                flow_graph.unselect()
                flow_graph.import_data(n)
                flow_graph_update()
                page.saved = False
        ##################################################
        # New/Open/Save/Close
        ##################################################
        elif action == Actions.FLOW_GRAPH_NEW:
            main.new_page()
            args = (GLib.Variant('s', 'qt_gui'), )
            flow_graph = main.current_page.flow_graph
            flow_graph.options_block.params['generate_options'].set_value(
                str(args[0])[1:-1])
            flow_graph.options_block.params['author'].set_value(getuser())
            flow_graph_update(flow_graph)
        elif action == Actions.FLOW_GRAPH_NEW_TYPE:
            main.new_page()
            if args:
                flow_graph = main.current_page.flow_graph
                flow_graph.options_block.params['generate_options'].set_value(
                    str(args[0])[1:-1])
                flow_graph_update(flow_graph)
        elif action == Actions.FLOW_GRAPH_OPEN:
            file_paths = args[0] if args[0] else FileDialogs.OpenFlowGraph(
                main, page.file_path).run()
            if file_paths:  # Open a new page for each file, show only the first
                for i, file_path in enumerate(file_paths):
                    main.new_page(file_path, show=(i == 0))
                    self.config.add_recent_file(file_path)
                    main.tool_bar.refresh_submenus()
                    main.menu.refresh_submenus()
        elif action == Actions.FLOW_GRAPH_OPEN_QSS_THEME:
            file_paths = FileDialogs.OpenQSS(
                main, self.platform.config.install_prefix +
                '/share/gnuradio/themes/').run()
            if file_paths:
                self.platform.config.default_qss_theme = file_paths[0]
        elif action == Actions.FLOW_GRAPH_CLOSE:
            main.close_page()
        elif action == Actions.FLOW_GRAPH_OPEN_RECENT:
            file_path = str(args[0])[1:-1]
            main.new_page(file_path, show=True)
            self.config.add_recent_file(file_path)
            main.tool_bar.refresh_submenus()
            main.menu.refresh_submenus()
        elif action == Actions.FLOW_GRAPH_SAVE:
            #read-only or undefined file path, do save-as
            if page.get_read_only() or not page.file_path:
                Actions.FLOW_GRAPH_SAVE_AS()
            #otherwise try to save
            else:
                try:
                    self.platform.save_flow_graph(page.file_path, flow_graph)
                    flow_graph.grc_file_path = page.file_path
                    page.saved = True
                except IOError:
                    Messages.send_fail_save(page.file_path)
                    page.saved = False
        elif action == Actions.FLOW_GRAPH_SAVE_AS:
            file_path = FileDialogs.SaveFlowGraph(main, page.file_path).run()

            if file_path is not None:
                if flow_graph.options_block.params['id'].get_value(
                ) == 'default':
                    file_name = os.path.basename(file_path).replace(".grc", "")
                    flow_graph.options_block.params['id'].set_value(file_name)
                    flow_graph_update(flow_graph)

                page.file_path = os.path.abspath(file_path)
                try:
                    self.platform.save_flow_graph(page.file_path, flow_graph)
                    flow_graph.grc_file_path = page.file_path
                    page.saved = True
                except IOError:
                    Messages.send_fail_save(page.file_path)
                    page.saved = False
                self.config.add_recent_file(file_path)
                main.tool_bar.refresh_submenus()
                main.menu.refresh_submenus()
        elif action == Actions.FLOW_GRAPH_SAVE_COPY:
            try:
                if not page.file_path:
                    # Make sure the current flowgraph has been saved
                    Actions.FLOW_GRAPH_SAVE_AS()
                else:
                    dup_file_path = page.file_path
                    dup_file_name = '.'.join(
                        dup_file_path.split('.')[:-1]
                    ) + "_copy"  # Assuming .grc extension at the end of file_path
                    dup_file_path_temp = dup_file_name + Constants.FILE_EXTENSION
                    count = 1
                    while os.path.exists(dup_file_path_temp):
                        dup_file_path_temp = '{}({}){}'.format(
                            dup_file_name, count, Constants.FILE_EXTENSION)
                        count += 1
                    dup_file_path_user = FileDialogs.SaveFlowGraph(
                        main, dup_file_path_temp).run()
                    if dup_file_path_user is not None:
                        self.platform.save_flow_graph(dup_file_path_user,
                                                      flow_graph)
                        Messages.send('Saved Copy to: "' + dup_file_path_user +
                                      '"\n')
            except IOError:
                Messages.send_fail_save(
                    "Can not create a copy of the flowgraph\n")
        elif action == Actions.FLOW_GRAPH_DUPLICATE:
            previous = flow_graph
            # Create a new page
            main.new_page()
            page = main.current_page
            new_flow_graph = page.flow_graph
            # Import the old data and mark the current as not saved
            new_flow_graph.import_data(previous.export_data())
            flow_graph_update(new_flow_graph)
            page.state_cache.save_new_state(new_flow_graph.export_data())
            page.saved = False
        elif action == Actions.FLOW_GRAPH_SCREEN_CAPTURE:
            file_path, background_transparent = FileDialogs.SaveScreenShot(
                main, page.file_path).run()
            if file_path is not None:
                try:
                    Utils.make_screenshot(flow_graph, file_path,
                                          background_transparent)
                except ValueError:
                    Messages.send('Failed to generate screen shot\n')
        ##################################################
        # Gen/Exec/Stop
        ##################################################
        elif action == Actions.FLOW_GRAPH_GEN:
            self.generator = None
            if not page.process:
                if not page.saved or not page.file_path:
                    Actions.FLOW_GRAPH_SAVE(
                    )  # only save if file path missing or not saved
                if page.saved and page.file_path:
                    generator = page.get_generator()
                    try:
                        Messages.send_start_gen(generator.file_path)
                        generator.write()
                        self.generator = generator
                    except Exception as e:
                        Messages.send_fail_gen(e)

        elif action == Actions.FLOW_GRAPH_EXEC:
            if not page.process:
                Actions.FLOW_GRAPH_GEN()
                if self.generator:
                    xterm = self.platform.config.xterm_executable
                    if self.config.xterm_missing() != xterm:
                        if not os.path.exists(xterm):
                            Dialogs.show_missing_xterm(main, xterm)
                        self.config.xterm_missing(xterm)
                    if page.saved and page.file_path:
                        # Save config before execution
                        self.config.save()
                        Executor.ExecFlowGraphThread(
                            flow_graph_page=page,
                            xterm_executable=xterm,
                            callback=self.update_exec_stop)
        elif action == Actions.FLOW_GRAPH_KILL:
            if page.process:
                try:
                    page.process.terminate()
                except OSError:
                    print("could not terminate process: %d" % page.process.pid)

        elif action == Actions.PAGE_CHANGE:  # pass and run the global actions
            flow_graph_update()
        elif action == Actions.RELOAD_BLOCKS:
            self.platform.build_library()
            main.btwin.repopulate()

            #todo: implement parser error dialog for YAML

            # Force a redraw of the graph, by getting the current state and re-importing it
            main.update_pages()

        elif action == Actions.FIND_BLOCKS:
            main.update_panel_visibility(main.BLOCKS, True)
            main.btwin.search_entry.show()
            main.btwin.search_entry.grab_focus()
        elif action == Actions.OPEN_HIER:
            for b in flow_graph.selected_blocks():
                grc_source = b.extra_data.get('grc_source', '')
                if grc_source:
                    main.new_page(grc_source, show=True)
        elif action == Actions.BUSSIFY_SOURCES:
            for b in flow_graph.selected_blocks():
                b.bussify('source')
            flow_graph._old_selected_port = None
            flow_graph._new_selected_port = None
            Actions.ELEMENT_CREATE()

        elif action == Actions.BUSSIFY_SINKS:
            for b in flow_graph.selected_blocks():
                b.bussify('sink')
            flow_graph._old_selected_port = None
            flow_graph._new_selected_port = None
            Actions.ELEMENT_CREATE()

        elif action == Actions.TOOLS_RUN_FDESIGN:
            subprocess.Popen('gr_filter_design',
                             shell=True,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT)

        else:
            log.warning('!!! Action "%s" not handled !!!' % action)
        ##################################################
        # Global Actions for all States
        ##################################################
        page = main.current_page  # page and flow graph might have changed
        flow_graph = page.flow_graph if page else None

        selected_blocks = list(flow_graph.selected_blocks())
        selected_block = selected_blocks[0] if selected_blocks else None

        #update general buttons
        Actions.ERRORS_WINDOW_DISPLAY.set_enabled(not flow_graph.is_valid())
        Actions.ELEMENT_DELETE.set_enabled(bool(flow_graph.selected_elements))
        Actions.BLOCK_PARAM_MODIFY.set_enabled(bool(selected_block))
        Actions.BLOCK_ROTATE_CCW.set_enabled(bool(selected_blocks))
        Actions.BLOCK_ROTATE_CW.set_enabled(bool(selected_blocks))
        #update alignment options
        for act in Actions.BLOCK_ALIGNMENTS:
            if act:
                act.set_enabled(len(selected_blocks) > 1)
        #update cut/copy/paste
        Actions.BLOCK_CUT.set_enabled(bool(selected_blocks))
        Actions.BLOCK_COPY.set_enabled(bool(selected_blocks))
        Actions.BLOCK_PASTE.set_enabled(bool(self.clipboard))
        #update enable/disable/bypass
        can_enable = any(block.state != 'enabled' for block in selected_blocks)
        can_disable = any(block.state != 'disabled'
                          for block in selected_blocks)
        can_bypass_all = (all(block.can_bypass() for block in selected_blocks)
                          and any(not block.get_bypassed()
                                  for block in selected_blocks))
        Actions.BLOCK_ENABLE.set_enabled(can_enable)
        Actions.BLOCK_DISABLE.set_enabled(can_disable)
        Actions.BLOCK_BYPASS.set_enabled(can_bypass_all)

        Actions.BLOCK_CREATE_HIER.set_enabled(bool(selected_blocks))
        Actions.OPEN_HIER.set_enabled(bool(selected_blocks))
        Actions.BUSSIFY_SOURCES.set_enabled(bool(selected_blocks))
        Actions.BUSSIFY_SINKS.set_enabled(bool(selected_blocks))
        Actions.RELOAD_BLOCKS.enable()
        Actions.FIND_BLOCKS.enable()

        self.update_exec_stop()

        Actions.FLOW_GRAPH_SAVE.set_enabled(not page.saved)
        main.update()

        flow_graph.update_selected()
        page.drawing_area.queue_draw()

        return True  # Action was handled
Пример #54
0
 def on_window1_destroy (self, widget, data=None):
     Gtk.main_quit()
     sys.exit(0)
Пример #55
0
 def cleanup(self, widget, event):
     #GLib.Source().remove(self.timeout)
     if self.idle:
         GLib.Source().remove(self.idle)
     Gtk.main_quit()
Пример #56
0
def on_key_press(widget, event):
    # print(event.keyval)
    if event.keyval == 65307:
        Gtk.main_quit()
Пример #57
0
def window_closed(widget, event, pipeline):
    # print("window closed")
    widget.hide()
    pipeline.set_state(Gst.State.NULL)
    Gtk.main_quit()
Пример #58
0
 def exit_window(self):
     self.window.destroy()
     Gtk.main_quit()
Пример #59
0
 def quit(self):
     self.debugger.terminate()
     Gtk.main_quit()
Пример #60
0
def sigint_handler(signal, frame):
    Gtk.main_quit()