shell Package¶
bootstrap
Module¶
-
class
stoq.gui.shell.bootstrap.
ShellBootstrap
(options, initial)[source]¶ Bases:
object
Bootstraps the Stoq application, it’s responsible for:
- Setting up log files
- Checking dependencies
- Setting up libraries (gobject, gtk, kiwi)
- Checking version
- Locale
- User settings and keybindings
When this is completed Stoq is ready to connect to a database.
shell
Module¶
Stoq shell routines
-
class
stoq.gui.shell.shell.
ShellDatabaseConnection
(options)[source]¶ Bases:
object
Sets up a database connection
- Connects to a database
- Telling why if it failed
- Runs database wizard if needed
- Runs schema migration
- Activates plugins
- Sets up main branch
-
class
stoq.gui.shell.shell.
Shell
(bootstrap, options, initial=True)[source]¶ Bases:
object
The main application shell - bootstraps via ShellBootstrap - connects to the database via ShellDatabaseConnection - handles login - runs applications
-
login
()[source]¶ Do a login @param try_cookie: Try to use a cookie if one is available @returns: True if login succeed, otherwise false
-
get_current_app_name
()[source]¶ Get the name of the currently running application @returns: the name @rtype: str
-
create_window
()[source]¶ Creates a new shell window.
Note that it will not contain any applications and it will be hidden.
Returns: the shell_window
-
close_window
(shell_window)[source]¶ Close a currently open window :param ShellWindow shell_window: the shell_window
-
main
(appname, action_name=None)[source]¶ Start the shell. This will: - connect to the database - login the current user - create a new window - run the launcher/application selector app - run a mainloop
This will only exit when the complete stoq application is shutdown.
Parameters: - appname – name of the application to run
- action_name – action to activate or
None
-
shellapp
Module¶
Base classes for application’s GUI
-
class
stoq.gui.shell.shellapp.
ShellApp
(window, store=None)[source]¶ Bases:
kiwi.ui.delegates.GladeDelegate
Base class for shell applications.
The main use is to interact with a shell window and reduce duplication between other applications.
-
domain
= 'stoq'¶
-
app_title
= None¶ This attribute is used when generating titles for applications. It’s also useful if we get a list of available applications with the application names translated. This list is going to be used when creating new user profiles.
-
app_name
= None¶ name of the application, ‘pos’, ‘payable’, etc
-
search
= None¶ If this application has a search like interface
-
action_permissions
= {}¶ This dictionary holds information about required permissions to access certain actions. Keys should be the name of the action (for instance SearchEmployess), and the value should be a tuple with the permission key (domain object or action identifier) and the required permission. In this case: (‘Employee’, perm.PERM_SEARCH). See <stoqlib.lib.permissions>
-
search_spec
= None¶ The spec for store.find() to perform the search on
-
search_label
= 'Search:'¶ Label left of the search entry
-
report_table
= None¶ the report class for printing the object list embedded on app.
-
create_actions
()[source]¶ This is called before the BaseWindow constructor, so we can create actions that can be autoconnected. The widgets and actions loaded from builder files are not set yet
-
create_ui
()[source]¶ This is called when the UI such as GtkWidgets should be created. Glade widgets are now created and can be accessed in the instance.
-
activate
(refresh=True)[source]¶ This is when you switch to an application.
You should setup widget sensitivity here and refresh lists etc
Parameters: refresh – if we should refresh the search
-
setup_focus
()[source]¶ Define this method on child when it’s needed. This is for calling grab_focus(), it’s called after the window is shown. focus chains should be created in create_ui()
-
can_change_application
()[source]¶ Define if we can change the current application or not.
Returns: True if we can change the application, False otherwise.
-
can_close_application
()[source]¶ Define if we can close the current application or not.
Returns: True if we can close the application, False otherwise.
-
set_open_inventory
()[source]¶ Subclasses should overide this if they call
check_open_inventory
.This method will be called it there is an open inventory, so the application can disable some funcionalities
-
search_completed
(results, states)[source]¶ Implement this if you want to know when a search has been completed.
Parameters: - results – the search results
- states – search states used to construct the search query search
-
add_columns
(columns)[source]¶ Add some columns to the default ones.
Note that this method must be called during the setup of this search, which right now is only possible for those who capture the <stoqlib.gui.events.ApplicationSetupSearchEvent>
-
set_sensitive
(widgets, value)[source]¶ Set the widgets sensitivity based on value
If a sensitive group was registered for any widget, it’s validation function will be tested and, if
False
is returned, it will be set insensitive, ignoring valueParameters: - widgets – a list of widgets
- value – either True or False
-
register_sensitive_group
(widgets, validation_func, *args)[source]¶ Register widgets on a sensitive group.
Everytime
set_sensitive()
is called, if there is any validation function for a given widget on sensitive group, then that will be used to decide if it gets sensitive or insensitive.Parameters: - widgets – a list of widgets
- validation_func – a function for validation. It should
return either
True
orFalse
. - args – args that will be passed to validation_func
-
has_open_inventory
(*args, **kwargs)¶
-
check_open_inventory
()[source]¶ Checks if there is an open inventory.
In the case there is one, will call set_open_inventory (subclasses should implement it).
Returns True if there is an open inventory. False otherwise
-
add_filter
(search_filter, position=<SearchFilterPosition value BOTTOM>, columns=None, callback=None)[source]¶ See
SearchSlave.add_filter
-
shellwindow
Module¶
-
class
stoq.gui.shell.shellwindow.
ShellWindow
(options, shell, store)[source]¶ Bases:
kiwi.ui.delegates.GladeDelegate
A Shell window is a
- Window
- Menubar
- Toolbar
- Application box
- Statusbar w/ Feedback button
- It contain common menu items for:
- Opening a new Window
- Signing out
- Changing password
- Closing the application
- Printing
- Editing user preferences
- Spreedshet
- Toggle toolbar and statusbar visibility
- View Fullscreen
- Help menu (Chat, Content, Translation, Support, About)
The main function is to create the common ui and switch between different applications.
-
app_title
= 'Stoq'¶
-
action_permissions
= {}¶
-
common_action_permissions
= {'HelpHelp': ('app.common.help', 1), 'HelpSupport': ('app.common.help_support', 1), 'HelpContents': ('app.common.help_contents', 1), 'HelpTranslate': ('app.common.help_translate', 1), 'HelpChat': ('app.common.help_chat', 1)}¶
-
hide_app
(empty=False)[source]¶ Hide the current application in this window
Parameters: empty (bool) – if True
, do not add the default launcher application
-
add_info_bar
(message_type, label, action_widget=None)[source]¶ Show an information bar to the user.
Parameters: - message_type – message type, a gtk.MessageType
- label – label to display
- action_widget – optional, most likely a button
Returns: the infobar
-
add_ui_actions
(ui_string, actions, name='Actions', action_type='normal', filename=None, instance=None)[source]¶
-
run_application
(app_name, **params)[source]¶ Load and show an application in a shell window.
Parameters: - shell_window (ShellWindow) – shell window to run application in
- appname (str) – the name of the application to run
- params – extra arguments passed to the application
Returns: the shell application or
None
if the user doesn’t have access to open the applicationReturn type: