How to use the kiwi.utils.gsignal function in kiwi

To help you get started, we’ve selected a few kiwi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoq / stoq / stoqlib / gui / base / search.py View on Github external
called when a signal is emitted by 'Filter' or 'Clear' buttons and
        also when a list item is selected. """

    def search_completed(self, results, states):
        pass


class SearchEditorToolBar(GladeSlaveDelegate):
    """ Slave for internal use of SearchEditor, offering an eventbox for a
    toolbar and managing the 'New' and 'Edit' buttons. """

    toplevel_name = 'ToolBar'
    gladefile = 'SearchEditor'
    domain = 'stoqlib'

    gsignal('edit')
    gsignal('add')

    #
    # Kiwi handlers
    #

    def on_edit_button__clicked(self, button):
        self.emit('edit')

    def on_new_button__clicked(self, button):
        self.emit('add')


class SearchEditor(SearchDialog):
    """ Base class for a search "editor" dialog, that offers a 'new' and
    'edit' button on the dialog footer. The 'new' and 'edit' buttons will
github stoq / stoq / stoqlib / gui / search / searchdialog.py View on Github external
from stoqlib.lib.decorators import public
from stoqlib.lib.translation import stoqlib_gettext

_ = stoqlib_gettext

log = logging.getLogger(__name__)


class _SearchDialogDetailsSlave(GladeSlaveDelegate):
    """ Slave for internal use of SearchEditor, offering an eventbox for a
    toolbar and managing the 'New' and 'Edit' buttons. """

    domain = 'stoq'
    gladefile = 'SearchDialogDetailsSlave'

    gsignal('details')
    gsignal('print')

    #
    # Kiwi handlers
    #

    def on_details_button__clicked(self, button):
        self.emit('details')

    def on_print_button__clicked(self, button):
        self.emit('print')


@public(since="1.5.0")
class SearchDialog(BasicDialog):
    """  Base class for *all* the search dialogs, responsible for the list
github stoq / kiwi / kiwi / ui / search.py View on Github external
class SearchContainer(gtk.VBox):
    """
    A search container is a widget which consists of:
    - search entry (w/ a label) (:class:`StringSearchFilter`)
    - search button
    - objectlist result (:class:`SearchResults` or class:`SearchResultsTree)
    - a query executer (:class:`kiwi.db.query.QueryExecuter`)

    Additionally you can add a number of search filters to the SearchContainer.
    You can chose if you want to add the filter in the top-left corner
    of bottom, see :class:`SearchFilterPosition`
    """
    __gtype_name__ = 'SearchContainer'
    filter_label = gobject.property(type=str)
    results_class = SearchResults
    gsignal("search-completed", object, object)

    def __init__(self, columns=None, tree=False, chars=25):
        """
        Create a new SearchContainer object.
        :param columns: a list of :class:`kiwi.ui.objectlist.Column`
        :param tree: if we should list the results as a tree
        :param chars: maximum number of chars used by the search entry
        """
        if tree:
            self.results_class = SearchResultsTree

        gtk.VBox.__init__(self)
        self._auto_search = True
        self._columns = columns
        self._lazy_updater = None
        self._model = None
github stoq / stoq / stoqlib / gui / search / searchslave.py View on Github external
"""
    A search container is a widget which consists of:
    - search entry (w/ a label) (:class:`StringSearchFilter`)
    - search button
    - result view (:class:`SearchResultListView` or class:`SearchResultTreeView`)
    - a query executer (:class:`stoqlib.database.queryexecuter.QueryExecuter`)

    Additionally you can add a number of search filters to the SearchContainer.
    You can chose if you want to add the filter in the top-left corner
    of bottom, see :class:`SearchFilterPosition`
    """
    result_view_class = SearchResultListView

    gsignal("search-completed", object, object)
    gsignal("result-item-activated", object)
    gsignal("result-item-popup-menu", object, object, object)
    gsignal("result-selection-changed")

    def __init__(self, columns=None,
                 tree=False,
                 restore_name=None,
                 chars=25,
                 store=None,
                 search_spec=None,
                 fast_iter=False,
                 result_view_class=None):
        """
        Create a new SearchContainer object.
        :param columns: a list of :class:`kiwi.ui.objectlist.Column`
        :param tree: if we should list the results as a tree
        :param restore_name:
        :param chars: maximum number of chars used by the search entry
github stoq / stoq / stoqlib / gui / base / searchbar.py View on Github external
class _DateInterval:
    """A basic class for a range of dates used by DateSearchSlave as the
    model object
    """
    start_date = None
    end_date = None

class _DateSearchSlave(GladeSlaveDelegate):

    implements(ISearchBarEntrySlave)

    gladefile = 'DateSearchSlave'
    proxy_widgets = ('start_date',
                     'end_date')
    gsignal('start-date-selected')
    gsignal('end-date-selected')

    def __init__(self, filter_slave, fields):
        GladeSlaveDelegate.__init__(self, gladefile=self.gladefile)
        # As we want to use kiwi validators with date fields we need to set
        # proxies here.
        self._model = _DateInterval()
        self._fields = fields
        self.add_proxy(self._model, self.proxy_widgets)
        self._slave = _SearchBarEntry(filter_slave)
        self.attach_slave('searchentry_holder', self._slave)
        self._update_view()

    def _update_view(self):
        enable_dates = self.date_check.get_active()
        self.start_date.set_sensitive(enable_dates)
github stoq / stoq / stoqlib / gui / widgets / fieldgrid.py View on Github external
return _get_cursor(Gdk.CursorType.BOTTOM_SIDE)


class FieldGrid(Gtk.Layout):
    """FieldGrid is a Grid like widget which you can add fields to

    * **field-added** (object): Emitted when a field is added to the grid
    * **field-removed** (object): Emitted when a field is removed
      from the grid
    * ** selection-changed** (object): Emitted when a field is selected or
      deselected by the user.
    """

    gsignal('selection-changed', object,
            flags=GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION)
    gsignal('field-added', object)
    gsignal('field-removed', object)

    def __init__(self, font, width, height):
        super(FieldGrid, self).__init__()

        self.set_can_focus(True)
        self.drag_dest_set(
            Gtk.DestDefaults.ALL,
            [Gtk.TargetEntry.new('OBJECTLIST_ROW', 0, 10),
             Gtk.TargetEntry.new('text/uri-list', 0, 11),
             Gtk.TargetEntry.new('_NETSCAPE_URL', 0, 12)],
            Gdk.DragAction.LINK | Gdk.DragAction.COPY | Gdk.DragAction.MOVE)

        self.font = Pango.FontDescription(font)
        self.width = width
        self.height = height
github stoq / kiwi / kiwi / ui / hyperlink.py View on Github external
"""

    __gtype_name__ = 'HyperLink'

    text = GObject.Property(type=str, default='')
    normal_color = GObject.Property(type=str, default='#0000c0')
    normal_underline = GObject.Property(type=bool, default=False)
    normal_bold = GObject.Property(type=bool, default=False)
    hover_color = GObject.Property(type=str, default='#0000c0')
    hover_underline = GObject.Property(type=bool, default=True)
    hover_bold = GObject.Property(type=bool, default=False)
    active_color = GObject.Property(type=str, default='#c00000')
    active_underline = GObject.Property(type=bool, default=True)
    active_bold = GObject.Property(type=bool, default=False)

    gsignal('clicked')
    gsignal('right-clicked')

    def __init__(self, text=None, menu=None):
        """
        Create a new hyperlink.

        :param text: The text of the hyperlink.
        :type text: str
        """
        super(HyperLink, self).__init__()

        self.set_above_child(False)
        self.set_visible_window(False)
        self._gproperties = {}
        if text is not None:
            self.set_property('text', text)
github stoq / stoq / stoqlib / gui / widgets / kanbanview.py View on Github external
"""
    This is a kanban view which can be used to display a set
    of columns with boxes that can be rearranged.

    """
    __gtype_name__ = 'KanbanView'

    TREEVIEW_DND_TARGETS = [
        ('text/plain', 0, 1),
    ]

    # item activated
    gsignal('item-activated', object)
    gsignal('item-dragged', object, object, retval=bool)
    gsignal('item-popup-menu', object, object, object)
    gsignal('selection-changed', object)
    gsignal('activate-link', object)

    def __init__(self):
        super(KanbanView, self).__init__()
        self.hbox = Gtk.HBox()
        self.add(self.hbox)
        self.hbox.show()

        self.set_shadow_type(Gtk.ShadowType.ETCHED_IN)

        # column title -> column
        self._columns = {}
        # column title -> objectlist
        self._treeviews = {}
        self._selected_iter = None
        self._selected_treeview = None
github stoq / kiwi / kiwi / ui / widgets / spinbutton.py View on Github external
"""
    A SpinButton subclass which adds supports for the Kiwi Framework.
    This widget supports validation
    The only allowed types for spinbutton are int and float.

    """
    __gtype_name__ = 'ProxySpinButton'

    data_type = GObject.Property(
        getter=ProxyWidgetMixin.get_data_type,
        setter=ProxyWidgetMixin.set_data_type,
        type=str, blurb='Data Type')
    mandatory = GObject.Property(type=bool, default=False)
    model_attribute = GObject.Property(type=str, blurb='Model attribute')
    gsignal('content-changed')
    gsignal('validation-changed', bool)
    gsignal('validate', object, retval=object)

    allowed_data_types = number

    def __init__(self, data_type=int):
        # since the default data_type is str we need to set it to int
        # or float for spinbuttons
        Gtk.SpinButton.__init__(self)
        ValidatableProxyWidgetMixin.__init__(self)
        self.props.data_type = data_type
        self.set_property('xalign', 1.0)
        self.set_property("truncate-multiline", True)

        # We need to do this because spinbuttons are supposed to accept only
        # numbers.
        self.set_numeric(True)
github stoq / stoq / stoqlib / gui / dialogs / progressdialog.py View on Github external
class ProgressDialog(GladeDelegate):
    """This is a dialog you use to show the progress of a certain task.
    It's just a label, progress bar and button.
    it'll always be displayed in the center of a screen.
    The progress is pulsating and updated every 100 ms.

    Signals:

    * *cancel* (): Emitted when a the cancel button is clicked

    """
    domain = 'stoq'
    gladefile = "ProgressDialog"
    toplevel_name = "ProgressDialog"

    gsignal('cancel')

    def __init__(self, label='', pulse=True):
        """
        Create a new ProgressDialog object.
        :param label: initial content of the label
        """
        GladeDelegate.__init__(self, gladefile=self.gladefile)
        self.set_title(label)
        self._pulse = pulse
        self._timeout_id = -1
        self._start_id = -1
        self.label.set_label(label)
        self.toplevel.set_position(Gtk.WindowPosition.CENTER)

    def start(self, wait=50):
        """Start the task, it'll pulsate the progress bar until stop() is called