def __init__(self): self._setup_params() self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) PrintReportEvent.connect(self._on_PrintReportEvent) SearchDialogSetupSearchEvent.connect( self._on_SearchDialogSetupSearchEvent) WorkOrderStatusChangedEvent.connect( self._on_WorkOrderStatusChangedEvent) ApplicationSetupSearchEvent.connect( self._on_ApplicationSetupSearchEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ('plugin.optical.search_medics', ''), ]) # Whenever the model of WorkOrderActions change, we should also change ours actions = WorkOrderActions.get_instance() actions.connect('model-set', self._on_work_order_actions__model_set) # Add a new option to the WorkOrderRow options menu WorkOrderRow.options.append((_('Create new purchase...'), 'optical_work_order.OpticalNewPurchase'))
def __init__(self): self._ui = None self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) EditorSlaveCreateEvent.connect(self._on_EditorSlaveCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ])
def __init__(self): self._ui = None self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) EditorSlaveCreateEvent.connect(self._on_EditorSlaveCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ])
def __init__(self): self._ui = None self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) PrintReportEvent.connect(self._on_PrintReportEvent) SearchDialogSetupSearchEvent.connect(self._on_SearchDialogSetupSearchEvent) ApplicationSetupSearchEvent.connect(self._on_ApplicationSetupSearchEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ('plugin.optical.search_medics', ''), ])
def run_dialog(dialog, parent=None, *args, **kwargs): """Runs a dialog and return the return value of it. If dialog is a class it will be instantiated before running the dialog. :param dialog: the dialog class :param parent: parent of the dialog :param args: custom positional arguments :param kwargs: custom keyword arguments """ if dialog is None: raise TypeError("dialog cannot be None") dialog = RunDialogEvent.emit(dialog, parent, *args, **kwargs) if not issubclass(dialog, RunnableView): raise TypeError("dialog %r must be subclass of RunnableView" % ( dialog, )) # FIXME: Move this into RunnableView parent = getattr(parent, 'main_dialog', parent) parent = parent or get_current_toplevel() if inspect.isclass(dialog): dialog_name = dialog.__name__ else: dialog_name = dialog.__class__.__name__ dialog = get_dialog(parent, dialog, *args, **kwargs) orig_dialog = dialog toplevel = dialog.get_current_toplevel() add_current_toplevel(toplevel) if _fullscreen is not None: toplevel.set_position(gtk.WIN_POS_CENTER) elif parent and isinstance(parent, gtk.Window) and parent.props.visible: toplevel.set_transient_for(parent) toplevel.set_position(gtk.WIN_POS_CENTER_ON_PARENT) else: if parent: toplevel.set_position(gtk.WIN_POS_CENTER_ON_PARENT) else: toplevel.set_position(gtk.WIN_POS_CENTER) # FIXME: This should not be necessary, but gnome shell hides window # decorations for HINT_DIALOG. We should study what dialogs should # have HINT_NORMAL (with window decorations) and what can have # HINT_DIALOG toplevel.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) log.info("%s: Opening" % dialog_name) if hasattr(parent, 'on_dialog__opened'): parent.on_dialog__opened(orig_dialog) retval = run_dialog_internal(dialog, parent, toplevel) _pop_current_toplevel() return retval
def __init__(self): # This will contain a mapping of (appname, uimanager) -> extra_ui # We need to store that like this because each windows has it's unique # uimanager, and we have an extra_ui for different apps self._app_ui = dict() self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) PrintReportEvent.connect(self._on_PrintReportEvent) SearchDialogSetupSearchEvent.connect(self._on_SearchDialogSetupSearchEvent) ApplicationSetupSearchEvent.connect(self._on_ApplicationSetupSearchEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ('plugin.optical.search_medics', ''), ])
def __init__(self): # This will contain a mapping of (appname, uimanager) -> extra_ui # We need to store that like this because each windows has it's unique # uimanager, and we have an extra_ui for different apps self._app_ui = dict() self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) PrintReportEvent.connect(self._on_PrintReportEvent) SearchDialogSetupSearchEvent.connect( self._on_SearchDialogSetupSearchEvent) ApplicationSetupSearchEvent.connect( self._on_ApplicationSetupSearchEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ('plugin.optical.search_medics', ''), ])
def test_run_dialog_event(self): self.event_call_count = 0 def _run_dialog_event(dialog, parent, *args, **kwargs): self.event_call_count += 1 return None RunDialogEvent.connect(_run_dialog_event) fake_run = mock.Mock() # The real get dialog returns an instance of the given class, and then, # run_dialog calls the method run() on the toplevel of the instance. We def _get_dialog(*args, **kwargs): real_dialog = get_dialog(*args, **kwargs) toplevel = real_dialog.get_current_toplevel() toplevel.run = fake_run return real_dialog with mock.patch('stoqlib.gui.base.dialogs.get_dialog', new=_get_dialog): run_dialog(PaymentCategoryDialog, parent=None, store=self.store) fake_run.assert_called_once_with() self.assertEqual(self.event_call_count, 1)
def __init__(self): self._setup_params() self.default_store = get_default_store() StartApplicationEvent.connect(self._on_StartApplicationEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) RunDialogEvent.connect(self._on_RunDialogEvent) PrintReportEvent.connect(self._on_PrintReportEvent) SearchDialogSetupSearchEvent.connect(self._on_SearchDialogSetupSearchEvent) WorkOrderStatusChangedEvent.connect(self._on_WorkOrderStatusChangedEvent) ApplicationSetupSearchEvent.connect(self._on_ApplicationSetupSearchEvent) add_bindings([ ('plugin.optical.pre_sale', ''), ('plugin.optical.search_medics', ''), ]) # Whenever the model of WorkOrderActions change, we should also change ours actions = WorkOrderActions.get_instance() actions.connect('model-set', self._on_work_order_actions__model_set) # Add a new option to the WorkOrderRow options menu WorkOrderRow.options.append((_('Create new purchase...'), 'optical_work_order.OpticalNewPurchase'))
def test_run_dialog_event(self): self.event_call_count = 0 def _run_dialog_event(dialog, parent, *args, **kwargs): self.event_call_count += 1 return None RunDialogEvent.connect(_run_dialog_event) fake_run = mock.Mock() # The real get dialog returns an instance of the given class, and then, # run_dialog calls the method run() on the toplevel of the instance. We def _get_dialog(*args, **kwargs): real_dialog = get_dialog(*args, **kwargs) toplevel = real_dialog.get_current_toplevel() toplevel.run = fake_run return real_dialog with mock.patch('stoqlib.gui.base.dialogs.get_dialog', new=_get_dialog): run_dialog(PaymentCategoryDialog, parent=None, store=self.store) fake_run.assert_called_once_with() self.assertEqual(self.event_call_count, 1)
def run_dialog(dialog, parent=None, *args, **kwargs): """Runs a dialog and return the return value of it. If dialog is a class it will be instantiated before running the dialog. :param dialog: the dialog class :param parent: parent of the dialog :param args: custom positional arguments :param kwargs: custom keyword arguments """ if dialog is None: raise TypeError("dialog cannot be None") dialog = RunDialogEvent.emit(dialog, parent, *args, **kwargs) if not issubclass(dialog, RunnableView): raise TypeError("dialog %r must be subclass of RunnableView" % (dialog, )) # FIXME: Move this into RunnableView parent = getattr(parent, 'main_dialog', parent) parent = parent or get_current_toplevel() if inspect.isclass(dialog): dialog_name = dialog.__name__ else: dialog_name = dialog.__class__.__name__ dialog = get_dialog(parent, dialog, *args, **kwargs) orig_dialog = dialog toplevel = dialog.get_current_toplevel() add_current_toplevel(toplevel) if _fullscreen is not None: toplevel.set_position(gtk.WIN_POS_CENTER) elif parent and isinstance(parent, gtk.Window) and parent.props.visible: toplevel.set_transient_for(parent) toplevel.set_position(gtk.WIN_POS_CENTER_ON_PARENT) else: if parent: toplevel.set_position(gtk.WIN_POS_CENTER_ON_PARENT) else: toplevel.set_position(gtk.WIN_POS_CENTER) # FIXME: This should not be necessary, but gnome shell hides window # decorations for HINT_DIALOG. We should study what dialogs should # have HINT_NORMAL (with window decorations) and what can have # HINT_DIALOG toplevel.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) if hasattr(parent, 'on_dialog__opened'): parent.on_dialog__opened(orig_dialog) log.info("%s: Opening" % dialog_name) # FIXME: We should avoid calling dialog.run() here # See http://tinyurl.com/lj6ske4 toplevel.run() retval = dialog.retval dialog.destroy() _pop_current_toplevel() return retval
def run_dialog(dialog, parent=None, *args, **kwargs): """Runs a dialog and return the return value of it. If dialog is a class it will be instantiated before running the dialog. :param dialog: the dialog class :param parent: parent of the dialog :param args: custom positional arguments :param kwargs: custom keyword arguments """ if dialog is None: raise TypeError("dialog cannot be None") dialog = RunDialogEvent.emit(dialog, parent, *args, **kwargs) if not issubclass(dialog, RunnableView): raise TypeError("dialog %r must be subclass of RunnableView" % (dialog, )) # FIXME: Move this into RunnableView #XXX: When create a new Stoq window, even using the parent correctly: # The called dialog will be a modal of the latest created window # (not necessarily the window that called). parent = getattr(parent, 'main_dialog', parent) parent = parent or get_current_toplevel() if inspect.isclass(dialog): dialog_name = dialog.__name__ else: dialog_name = dialog.__class__.__name__ dialog = get_dialog(parent, dialog, *args, **kwargs) orig_dialog = dialog toplevel = dialog.get_current_toplevel() add_current_toplevel(toplevel) if _fullscreen is not None: toplevel.set_position(Gtk.WindowPosition.CENTER) elif parent and isinstance(parent, Gtk.Window) and parent.props.visible: toplevel.set_transient_for(parent) toplevel.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) else: if parent: toplevel.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) else: toplevel.set_position(Gtk.WindowPosition.CENTER) # FIXME: This should not be necessary, but gnome shell hides window # decorations for HINT_DIALOG. We should study what dialogs should # have HINT_NORMAL (with window decorations) and what can have # HINT_DIALOG toplevel.set_type_hint(Gdk.WindowTypeHint.NORMAL) log.info("%s: Opening" % dialog_name) if hasattr(parent, 'on_dialog__opened'): parent.on_dialog__opened(orig_dialog) retval = run_dialog_internal(dialog, parent, toplevel) _pop_current_toplevel() return retval