コード例 #1
0
    def run():
        logger.debug('user_datapath: %r', userdatapath)
        logger.debug('user_confpath: %r', userconfpath)

        # User-configured locale (if enabled by user)
        set_user_configured_locale(userconfpath)

        # Locale setting
        from lib.gettext_setup import init_gettext
        init_gettext(localepath)

        # mypaintlib import is performed first in gui.application now.
        from gui import application

        app_state_dirs = application.StateDirs(
            app_data=datapath,
            app_icons=iconspath,
            user_data=userdatapath,
            user_config=userconfpath,
        )
        app = application.Application(
            filenames=args,
            state_dirs=app_state_dirs,
            version=version,
            fullscreen=options.fullscreen,
        )

        # Gtk must not be imported before init_gettext
        # has been run - else locales will not be set
        # up properly (e.g: left-to-right interfaces for right-to-left scripts)
        # Note that this is not the first import of Gtk in the __program__;
        # it is imported indirectly via the import of gui.application
        from lib.gibindings import Gtk
        settings = Gtk.Settings.get_default()
        dark = app.preferences.get("ui.dark_theme_variant", True)
        settings.set_property("gtk-application-prefer-dark-theme", dark)

        if debug and options.run_and_quit:
            from lib.gibindings import GLib
            GLib.timeout_add(1000, lambda *a: Gtk.main_quit())
        else:
            from gui import gtkexcepthook
            func = app.filehandler.confirm_destructive_action
            gtkexcepthook.quit_confirmation_func = func

        # temporary workaround for gtk3 Ctrl-C bug:
        # https://bugzilla.gnome.org/show_bug.cgi?id=622084
        import signal
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        Gtk.main()
コード例 #2
0
 def _queue_color_change(self, new_col, cm):
     self._queued_data = new_col, cm
     if not self._timeout_id:
         self._timeout_id = GLib.timeout_add(
             interval=16.66,  # 60 fps cap
             function=self._change_color,
         )
コード例 #3
0
 def _queue_movement(self, zone, args):
     self._move_item = (zone, args)
     if not self._move_timeout_id:
         self._move_timeout_id = GLib.timeout_add(
             interval=16.66,  # 60 fps cap
             function=self._do_move,
         )
コード例 #4
0
 def _restart_outside_popup_timeout(self):
     if not self.outside_popup_timeout:
         return
     self._stop_outside_popup_timeout()
     self._outside_popup_timeout_id = GLib.timeout_add(
         int(1000 * self.outside_popup_timeout),
         self._outside_popup_timeout_cb,
     )
コード例 #5
0
 def _restart_autoleave_timeout(self):
     if not self.autoleave_timeout:
         return
     self._stop_autoleave_timeout()
     self._autoleave_timeout_id = GLib.timeout_add(
         int(1000 * self.autoleave_timeout),
         self._autoleave_timeout_cb,
     )
コード例 #6
0
ファイル: framewindow.py プロジェクト: zero804/mypaint
 def _queue_frame_change(self, model, new_frame):
     """Queue a frame change (that may trigger a redraw)"""
     self._queued_frame = (model, new_frame)
     if not self._change_timeout_id:
         self._change_timeout_id = GLib.timeout_add(
             interval=33.33,  # 30 fps cap
             function=self._set_queued_frame,
         )
コード例 #7
0
    def map_cb(self, *junk):
        logger.info('Event statistics enabled.')

        self.app.doc.tdw.connect("event", self.event_cb)
        self.app.drawWindow.connect("event", self.event_cb)

        self._timer_id = GLib.timeout_add(1000,
                                          self.second_timer_cb,
                                          priority=GLib.PRIORITY_HIGH)
コード例 #8
0
ファイル: fill.py プロジェクト: skfinlayson1/mypaint
def status_callback(handler):
    """
    Set up and run fill info/cancellation dialog
    :param handler: handler for fill info/cancellation
    :return: False if the fill is cancelled, None otherwise
    """
    app = gui.application.get_app()

    # Prevent escape release (always) triggering mode stack popping
    app.kbm.enabled = False

    # Create new dialog for each occurrence, hopefully
    # occurrences are rare enough for it not to matter very much.
    status_dialog = Gtk.MessageDialog(parent=app.drawWindow,
                                      buttons=Gtk.ButtonsType.CANCEL)

    curr_stage = [None]

    # Status update ticker callback - also handles dialog destruction
    def status_update():
        if handler.running():
            # Only update the header when the stage has changed
            if curr_stage[0] != handler.stage:
                curr_stage[0] = handler.stage
                status_dialog.set_property("text", handler.stage_string)
            status_dialog.set_property("secondary-text",
                                       handler.progress_string)
            return True
        else:
            # Destroy dialog when fill is done, whether cancelled or not
            status_dialog.response(Gtk.ResponseType.OK)
            return False

    # Update the status message 20 times/s
    GLib.timeout_add(50, status_update)
    result = status_dialog.run()
    if result != Gtk.ResponseType.OK:
        handler.cancel()
    status_dialog.hide()
    handler.wait()
    status_dialog.destroy()
    app.kbm.enabled = True
    return result == Gtk.ResponseType.OK
コード例 #9
0
 def _popup_leave_notify_cb(self, widget, event):
     if not self.active:
         return
     # allow to leave the window for a short time
     if self._outside_popup_timeout_id:
         GLib.source_remove(self._outside_popup_timeout_id)
         self._outside_popup_timeout_id = None
     self._outside_popup_timeout_id = GLib.timeout_add(
         int(1000 * self.outside_popup_timeout),
         self._outside_popup_timeout_cb,
     )
コード例 #10
0
 def _start_autohide_timeout(self):
     """Start a timer to hide the UI after a brief period of inactivity"""
     if not self._autohide_timeout:
         logger.debug("Starting autohide timeout (%d milliseconds)",
                      self.AUTOHIDE_TIMEOUT)
     else:
         self._cancel_autohide_timeout()
     srcid = GLib.timeout_add(
         self.AUTOHIDE_TIMEOUT,
         self._autohide_timeout_cb,
     )
     self._autohide_timeout = srcid
コード例 #11
0
 def _start_autoreveal_timeout(self, widget):
     """Start a timer to reveal the widget after a brief period
     of edge contact
     """
     if not self._autoreveal_timeout:
         logger.debug("Starting autoreveal timeout (%d milliseconds)",
                      self.AUTOHIDE_REVEAL_TIMEOUT)
     else:
         self._cancel_autoreveal_timeout()
     srcid = GLib.timeout_add(
         self.AUTOHIDE_REVEAL_TIMEOUT,
         self._autoreveal_timeout_cb,
         widget,
     )
     self._autoreveal_timeout.append(srcid)
コード例 #12
0
 def _restart_hover_expand_timer(self, path, x, y):
     self._stop_hover_expand_timer()
     root = self._docmodel.layer_stack
     layer = root.deepget(path)
     if not isinstance(layer, lib.layer.LayerStack):
         return
     if self.row_expanded(Gtk.TreePath(path)):
         return
     self._hover_expand_timer_id = GLib.timeout_add(
         int(self.DRAG_HOVER_EXPAND_TIME * 1000),
         self._hover_expand_timer_cb,
         path,
         x,
         y,
     )
コード例 #13
0
 def _toplevel_configure_cb(self, toplevel, event):
     """Record the toplevel window's position ("configure-event" callback)
     """
     # Avoid saving fullscreen positions. The timeout is a bit of hack, but
     # it's necessary because the state change event and the configure event
     # when fullscreening don't have a sensible order.
     w, h = event.width, event.height
     srcid = self._save_toplevel_pos_timeout
     if srcid:
         GLib.source_remove(srcid)
     srcid = GLib.timeout_add(
         250,
         self._save_toplevel_pos_timeout_cb,
         w,
         h,
     )
     self._save_toplevel_pos_timeout = srcid
コード例 #14
0
ファイル: overlays.py プロジェクト: zero804/mypaint
 def __restart_anim_if_needed(self):
     """Restart if not currently running, without changing the alpha.
     """
     if self.__anim_srcid is None:
         delay = int(1000 // self.fade_fps)
         self.__anim_srcid = GLib.timeout_add(delay, self.anim_cb)