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.

bootstrap()[source]
stoq.gui.shell.bootstrap.boot_shell(options, initial=True)[source]

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
connect()[source]
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
quit(restart=False, app=None)[source]

Quit the shell and exit the application. This will save user settings and then forcefully terminate the application

Parameters:
  • restart – if True restart after terminating
  • app (str) – if not None, name of the application to restart
stoq.gui.shell.shell.get_shell()[source]

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()

get_title()[source]
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

new_activate()[source]

Called when the New toolbar item is activated

search_activate()[source]

Called when the Search toolbar item is activated

print_activate()[source]

Called when the Print toolbar item is activated

export_spreadsheet_activate()[source]

Called when the Export menu item is activated

create_filters()[source]

Implement this to provide filters for the search container

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_ui_actions(ui_string, actions, name='Actions', action_type='normal', filename=None)[source]
add_tool_menu_actions(actions)[source]
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_help_section(label, section)[source]
get_statusbar_message_area()[source]
print_report(report_class, *args, **kwargs)[source]
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 value

Parameters:
  • 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 or False.
  • args – args that will be passed to validation_func
run_dialog(dialog_class, *args, **kwargs)[source]

Encapsuled method for running dialogs.

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

set_text_field_columns(columns)[source]

See SearchSlave.set_text_field_columns

create_branch_filter(label=None, column=None)[source]
refresh(rollback=True)[source]

See stoqlib.gui.search.searchslave.SearchSlave.refresh

clear()[source]

See stoqlib.gui.search.searchslave.SearchSlave.clear

select_result(result)[source]

Select the object in the result list

If the object is not in the list (filtered out, for instance), no error is thrown and nothing is selected

on_search__search_completed(search, results, states)[source]

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)}
show_app(app, app_window, **params)[source]
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]
add_tool_menu_actions(actions)[source]
set_help_section(label, section)[source]
add_debug_ui()[source]
set_new_menu_sensitive(sensitive)[source]
add_new_items(actions)[source]
add_search_items(actions)[source]
new_window()[source]

Creates a new shell window, with an application selector in it

close()[source]

Closes this window

switch_application(app_name, **params)[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 application

Return type:

ShellApp

get_available_applications()[source]
key_F5()[source]
on_uimanager__connect_proxy(uimgr, action, widget)[source]
on_uimanager__disconnect_proxy(uimgr, action, widget)[source]
on_NewToolItem__activate(action)[source]
on_SearchToolItem__activate(action)[source]
on_NewWindow__activate(action)[source]
on_Print__activate(action)[source]
on_ExportSpreadSheet__activate(action)[source]
on_Close__activate(action)[source]
on_ChangePassword__activate(action)[source]
on_SignOut__activate(action)[source]
on_Quit__activate(action)[source]
on_HomeToolItem__activate(action)[source]
on_Preferences__activate(action)[source]
on_HelpContents__activate(action)[source]
on_HelpTranslate__activate(action)[source]
on_HelpChat__activate(action)[source]
on_HelpSupport__activate(action)[source]
on_HelpAbout__activate(action)[source]
on_Introspect__activate(action)[source]
on_RemoveSettingsCache__activate(action)[source]
class stoq.gui.shell.shellwindow.VersionChecker(store, window)[source]

Bases: object

DAYS_BETWEEN_CHECKS = 1
check_new_version()[source]

statusbar Module

class stoq.gui.shell.statusbar.StatusDialog(*args, **kwargs)[source]

Bases: stoqlib.gui.base.dialogs.BasicDialog

size = (700, 400)
title = 'System Status'
class stoq.gui.shell.statusbar.StatusButton[source]

Bases: gtk.Button

class stoq.gui.shell.statusbar.ShellStatusbar(window)[source]

Bases: gtk.Statusbar

do_text_popped(ctx, text)[source]
do_text_pushed(ctx, text)[source]