コード例 #1
0
ファイル: producteditor.py プロジェクト: Guillon88/stoq
    def _add_infobar(self, message, message_type):
        infobar = MessageBar(message, message_type)
        infobar.show()

        self.main_box.pack_start(infobar, False, False, 0)
        self.main_box.reorder_child(infobar, 0)

        return infobar
コード例 #2
0
ファイル: producteditor.py プロジェクト: lucaslamounier/stoq
    def _add_infobar(self, message, message_type):
        infobar = MessageBar(message, message_type)
        infobar.show()

        self.main_box.pack_start(infobar, False, False, 0)
        self.main_box.reorder_child(infobar, 0)

        return infobar
コード例 #3
0
ファイル: baseguitest.py プロジェクト: Guillon88/stoq
    def add_info_bar(self, message_type, label, action_widget=None):
        infobar = MessageBar(label, message_type)
        assert infobar is not None

        if action_widget:
            infobar.add_action_widget(action_widget, 0)
            action_widget.show()
        infobar.show()

        self.main_vbox.pack_start(infobar, False, False, 0)
        self.main_vbox.reorder_child(infobar, 2)

        return infobar
コード例 #4
0
 def set_message(self, message, message_type=gtk.MESSAGE_INFO):
     """Sets a message for this editor
     :param message: message to add or None to remove previous message
     :param message_type: type of message to add
     """
     if self._message_bar is not None:
         self._message_bar.destroy()
         self._message_bar = None
     if message is None:
         return
     self._message_bar = MessageBar(message, message_type)
     self._main_vbox.pack_start(self._message_bar, False, False)
     self._main_vbox.reorder_child(self._message_bar, 0)
     self._message_bar.show_all()
     return self._message_bar
コード例 #5
0
ファイル: shellwindow.py プロジェクト: hackedbellini/stoq
    def add_info_bar(self, message_type, label, action_widget=None):
        """Show an information bar to the user.

        :param message_type: message type, a Gtk.MessageType
        :param label: label to display
        :param action_widget: optional, most likely a button
        :returns: the infobar
        """
        infobar = MessageBar(label, message_type)

        if action_widget:
            infobar.add_action_widget(action_widget, 0)
            action_widget.show()
        infobar.show()

        self.main_vbox.pack_start(infobar, False, False, 0)
        self.main_vbox.reorder_child(infobar, 0)
        return infobar
コード例 #6
0
ファイル: dialogs.py プロジェクト: romaia/stoq
 def set_message(self, message, message_type=gtk.MESSAGE_INFO):
     """Sets a message for this editor
     :param message: message to add or None to remove previous message
     :param message_type: type of message to add
     """
     if self._message_bar is not None:
         self._message_bar.destroy()
         self._message_bar = None
     if message is None:
         return
     self._message_bar = MessageBar(message, message_type)
     self._main_vbox.pack_start(self._message_bar, False, False)
     self._main_vbox.reorder_child(self._message_bar, 0)
     self._message_bar.show_all()
     return self._message_bar
コード例 #7
0
    def add_info_bar(self, message_type, label, action_widget=None):
        infobar = MessageBar(label, message_type)
        assert infobar is not None

        if action_widget:
            infobar.add_action_widget(action_widget, 0)
            action_widget.show()
        infobar.show()

        self.main_vbox.pack_start(infobar, False, False, 0)
        self.main_vbox.reorder_child(infobar, 2)

        return infobar
コード例 #8
0
ファイル: shellwindow.py プロジェクト: 5l1v3r1/stoq-1
    def add_info_bar(self, message_type, label, action_widget=None):
        """Show an information bar to the user.

        :param message_type: message type, a Gtk.MessageType
        :param label: label to display
        :param action_widget: optional, most likely a button
        :returns: the infobar
        """
        infobar = MessageBar(label, message_type)

        if action_widget:
            infobar.add_action_widget(action_widget, 0)
            action_widget.show()
        infobar.show()

        self.main_vbox.pack_start(infobar, False, False, 0)
        self.main_vbox.reorder_child(infobar, 0)
        return infobar
コード例 #9
0
ファイル: dialogs.py プロジェクト: rosalin/stoq
class BasicDialog(GladeDelegate, RunnableView):
    """Abstract class that offers a Dialog with two buttons. It should be
    subclassed and customized.
    """
    help_section = None
    gsignal('confirm', object, retval=bool)
    gsignal('cancel', object)

    def __init__(self,
                 main_label_text=None,
                 title=" ",
                 header_text="",
                 size=None,
                 hide_footer=False,
                 delete_handler=None,
                 help_section=None):
        self.enable_confirm_validation = False
        self._message_bar = None
        self._create_dialog_ui()
        self._setup_keyactions()
        if delete_handler is None:
            delete_handler = self._delete_handler
        GladeDelegate.__init__(self,
                               delete_handler=delete_handler,
                               gladefile=self.gladefile,
                               keyactions=self.keyactions)
        help_section = help_section or self.help_section
        if help_section:
            self._add_help_button(help_section)

        # FIXME: Create more widgets lazily when needed
        self.set_title(title)
        if size:
            self.get_toplevel().set_size_request(*size)
        if main_label_text:
            self.main_label.set_text(main_label_text)
        if header_text:
            header_label = gtk.Label()
            header_label.set_markup(header_text)
            self.header.add(header_label)
            header_label.show()
        if hide_footer:
            self.hide_footer()

        DialogCreateEvent.emit(self)

    #
    # Private
    #

    def _create_dialog_ui(self):
        self.toplevel = gtk.Dialog()
        self._main_vbox = self.toplevel.get_content_area()

        self.vbox = gtk.VBox()
        self._main_vbox.pack_start(self.vbox, True, True)
        self.vbox.show()

        # FIXME
        # stoqlib/gui/base/search.py - hides the header
        self.header = gtk.EventBox()
        self.vbox.pack_start(self.header, False, False)
        self.header.show()

        self.main = gtk.EventBox()
        self.vbox.pack_start(self.main)
        self.main.show()

        # FIXME
        # stoqlib/gui/dialogs/importerdialog.py - setting
        # stoqlib/gui/base/lists.py - removes the label
        # stoqlib/gui/base/search.py - removes the label
        # plugins/ecf/deviceconstanteditor.py - removes the label
        self.main_label = gtk.Label()
        self.main.add(self.main_label)
        self.main_label.show()

        hbox1 = gtk.HBox()
        self.vbox.pack_start(hbox1, False)
        hbox1.show()

        # FIXME
        # stoqlib/gui/dialogs/paymentmethod.py
        # stoqlib/gui/search/salesearch.py
        self.extra_holder = gtk.EventBox()
        hbox1.pack_start(self.extra_holder, True, True)
        self.extra_holder.show()

        # FIXME
        # stoqlib/gui/search/productsearch.py
        # stoqlib/gui/search/servicesearch.py
        self.print_holder = gtk.EventBox()
        hbox1.pack_start(self.print_holder, True, True)
        self.print_holder.show()

        # FIXME
        # stoqlib/gui/base/search.py
        # stoqlib/gui/slaves/productslave.py
        self.details_holder = gtk.EventBox()
        hbox1.pack_end(self.details_holder, False, False)
        self.details_holder.show()

        # FIXME
        # stoqlib/gui/dialogs/quotedialog.py
        self.notice = gtk.EventBox()
        hbox1.pack_start(self.notice, False)
        self.notice.show()

        action_area = self.toplevel.get_action_area()
        action_area.set_border_width(6)
        action_area.set_layout(gtk.BUTTONBOX_END)

        self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
        action_area.pack_start(self.cancel_button, True, True)
        self.cancel_button.show()

        self.ok_button = gtk.Button(stock=gtk.STOCK_OK)
        self.ok_button.set_use_underline(True)
        action_area.pack_start(self.ok_button, True, True)
        self.ok_button.show()

    def _setup_keyactions(self):
        self.keyactions = {keysyms.Escape: self.cancel}

    def _try_confirm(self, *args):
        """Only confirm if ok button is actually enabled.

        This is so that this dialog doesn't get confirmed in case the ok
        button was specifically disabled.
        """
        # FIXME: There should be a better way to findout valid status
        if self.ok_button.get_sensitive():
            self.confirm()

    def _add_help_button(self, section):
        def on_help__clicked(button):
            from stoqlib.gui.utils.help import show_section
            show_section(section)

        self.action_area.set_layout(gtk.BUTTONBOX_END)
        self.help_button = gtk.Button(stock=gtk.STOCK_HELP)
        self.help_button.connect('clicked', on_help__clicked)
        self.action_area.pack_start(self.help_button, expand=False, fill=False)
        self.action_area.set_child_secondary(self.help_button, True)
        self.help_button.show()

    #
    # Public API
    #

    def confirm(self):
        # SearchDialog and SellableSearch overrides this
        self.retval = True
        # FIXME: Confirm validation should be enabled by default,
        #        but we need to change the dialog API and existing
        #        callsites for that to work.
        if (self.enable_confirm_validation
                and not self.emit('confirm', self.retval)):
            return

        self.close()

    def cancel(self):
        # SearchDialog overrides this
        self.retval = False
        self.emit('cancel', self.retval)
        self.close()

    def hide_footer(self):
        self.ok_button.hide()
        self.cancel_button.hide()

    def enable_ok(self):
        self.ok_button.set_sensitive(True)

    def disable_ok(self):
        self.ok_button.set_sensitive(False)

    def set_ok_label(self, text, icon=None):
        if not icon:
            icon = gtk.STOCK_OK
        change_button_appearance(self.ok_button, icon, text)

    # FIXME: Remove
    # Callsites: stoqlib/gui/dialogs/sintegradialog.py
    def justify_label(self, just):
        self.main_label.set_justify(just)

    def set_confirm_widget(self, widget):
        """Enables widget as a confirm widget, the dialog will be closed as
        confirmed if the widget is activated.
        :param widget: a widget
        """
        dialog = self.get_toplevel()
        if not widget.is_ancestor(dialog):
            raise ValueError("dialog %r is not an ancestor of widget %r" %
                             (dialog, widget))
        widget.connect('activate', self._try_confirm)

    def add(self, widget):
        for child in self.main.get_children():
            self.main.remove(child)
        self.main.add(widget)

    @property
    def action_area(self):
        return self.get_toplevel().action_area

    def set_message(self, message, message_type=None):
        """Sets a message for this editor
        :param message: message to add or None to remove previous message
        :param message_type: type of message to add
        """
        if message_type is None:
            message_type = gtk.MESSAGE_INFO
        if self._message_bar is not None:
            self._message_bar.destroy()
            self._message_bar = None
        if message is None:
            return
        self._message_bar = MessageBar(message, message_type)
        self._main_vbox.pack_start(self._message_bar, False, False)
        self._main_vbox.reorder_child(self._message_bar, 0)
        self._message_bar.show_all()
        return self._message_bar

    #
    # Kiwi handlers
    #

    def on_ok_button__clicked(self, button):
        self.confirm()

    def on_cancel_button__clicked(self, button):
        self.cancel()

    def _delete_handler(self, window, event):
        self.cancel()
コード例 #10
0
ファイル: dialogs.py プロジェクト: Joaldino/stoq
class BasicDialog(GladeDelegate, RunnableView):
    """Abstract class that offers a Dialog with two buttons. It should be
    subclassed and customized.
    """
    help_section = None
    gsignal('confirm', object, retval=bool)
    gsignal('cancel', object)

    def __init__(self, main_label_text=None, title=" ",
                 header_text="", size=None, hide_footer=False,
                 delete_handler=None, help_section=None):
        self.enable_confirm_validation = False
        self._message_bar = None
        self._create_dialog_ui()
        self._setup_keyactions()
        if delete_handler is None:
            delete_handler = self._delete_handler
        GladeDelegate.__init__(self, delete_handler=delete_handler,
                               gladefile=self.gladefile,
                               keyactions=self.keyactions)
        help_section = help_section or self.help_section
        if help_section:
            self._add_help_button(help_section)

        # FIXME: Create more widgets lazily when needed
        self.set_title(title)
        if size:
            self.get_toplevel().set_size_request(*size)
        if main_label_text:
            self.main_label.set_text(main_label_text)
        if header_text:
            header_label = gtk.Label()
            header_label.set_markup(header_text)
            self.header.add(header_label)
            header_label.show()
        if hide_footer:
            self.hide_footer()

        DialogCreateEvent.emit(self)

    #
    # Private
    #

    def _create_dialog_ui(self):
        self.toplevel = gtk.Dialog()
        self._main_vbox = self.toplevel.get_content_area()

        self.vbox = gtk.VBox()
        self._main_vbox.pack_start(self.vbox, True, True)
        self.vbox.show()

        # FIXME
        # stoqlib/gui/base/search.py - hides the header
        self.header = gtk.EventBox()
        self.vbox.pack_start(self.header, False, False)
        self.header.show()

        self.main = gtk.EventBox()
        self.vbox.pack_start(self.main, padding=6)
        self.main.show()

        # FIXME
        # stoqlib/gui/dialogs/importerdialog.py - setting
        # stoqlib/gui/base/lists.py - removes the label
        # stoqlib/gui/base/search.py - removes the label
        # plugins/ecf/deviceconstanteditor.py - removes the label
        self.main_label = gtk.Label()
        self.main.add(self.main_label)
        self.main_label.show()

        hbox1 = gtk.HBox()
        self.vbox.pack_start(hbox1, False, 6)
        hbox1.show()

        # FIXME
        # stoqlib/gui/dialogs/paymentmethod.py
        # stoqlib/gui/search/salesearch.py
        self.extra_holder = gtk.EventBox()
        hbox1.pack_start(self.extra_holder, True, True, 6)
        self.extra_holder.show()

        # FIXME
        # stoqlib/gui/search/productsearch.py
        # stoqlib/gui/search/servicesearch.py
        self.print_holder = gtk.EventBox()
        hbox1.pack_start(self.print_holder, True, True)
        self.print_holder.show()

        # FIXME
        # stoqlib/gui/base/search.py
        # stoqlib/gui/slaves/productslave.py
        self.details_holder = gtk.EventBox()
        hbox1.pack_end(self.details_holder, False, False, 6)
        self.details_holder.show()

        # FIXME
        # stoqlib/gui/dialogs/quotedialog.py
        self.notice = gtk.EventBox()
        hbox1.pack_start(self.notice, False, 6)
        self.notice.show()

        action_area = self.toplevel.get_action_area()
        action_area.set_border_width(6)
        action_area.set_layout(gtk.BUTTONBOX_END)

        self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
        action_area.pack_start(self.cancel_button, True, True, 6)
        self.cancel_button.show()

        self.ok_button = gtk.Button(stock=gtk.STOCK_OK)
        self.ok_button.set_use_underline(True)
        action_area.pack_start(self.ok_button, True, True, 6)
        self.ok_button.show()

    def _setup_keyactions(self):
        self.keyactions = {keysyms.Escape: self.cancel}

    def _try_confirm(self, *args):
        """Only confirm if ok button is actually enabled.

        This is so that this dialog doesn't get confirmed in case the ok
        button was specifically disabled.
        """
        # FIXME: There should be a better way to findout valid status
        if self.ok_button.get_sensitive():
            self.confirm()

    def _add_help_button(self, section):
        def on_help__clicked(button):
            from stoqlib.gui.utils.help import show_section
            show_section(section)

        self.action_area.set_layout(gtk.BUTTONBOX_END)
        self.help_button = gtk.Button(stock=gtk.STOCK_HELP)
        self.help_button.connect('clicked', on_help__clicked)
        self.action_area.pack_start(self.help_button, False, False, 6)
        self.action_area.set_child_secondary(self.help_button, True)
        self.help_button.show()

    #
    # Public API
    #

    def confirm(self):
        # SearchDialog and SellableSearch overrides this
        self.retval = True
        # FIXME: Confirm validation should be enabled by default,
        #        but we need to change the dialog API and existing
        #        callsites for that to work.
        if (self.enable_confirm_validation and not
            self.emit('confirm', self.retval)):
            return

        self.close()

    def cancel(self):
        # SearchDialog overrides this
        self.retval = False
        self.emit('cancel', self.retval)
        self.close()

    def hide_footer(self):
        self.ok_button.hide()
        self.cancel_button.hide()

    def enable_ok(self):
        self.ok_button.set_sensitive(True)

    def disable_ok(self):
        self.ok_button.set_sensitive(False)

    def set_ok_label(self, text, icon=None):
        if not icon:
            icon = gtk.STOCK_OK
        change_button_appearance(self.ok_button, icon, text)

    def set_cancel_label(self, text, icon=None):
        if not icon:
            icon = gtk.STOCK_CANCEL
        change_button_appearance(self.cancel_button, icon, text)

    def set_confirm_widget(self, widget):
        """Enables widget as a confirm widget, the dialog will be closed as
        confirmed if the widget is activated.
        :param widget: a widget
        """
        dialog = self.get_toplevel()
        if not widget.is_ancestor(dialog):
            raise ValueError("dialog %r is not an ancestor of widget %r" % (
                dialog, widget))
        widget.connect('activate', self._try_confirm)

    def add(self, widget):
        for child in self.main.get_children():
            self.main.remove(child)
        self.main.add(widget)

    @property
    def action_area(self):
        return self.get_toplevel().action_area

    def set_message(self, message, message_type=None):
        """Sets a message for this editor
        :param message: message to add or None to remove previous message
        :param message_type: type of message to add
        """
        if message_type is None:
            message_type = gtk.MESSAGE_INFO
        if self._message_bar is not None:
            self._message_bar.destroy()
            self._message_bar = None
        if message is None:
            return
        self._message_bar = MessageBar(message, message_type)
        self._main_vbox.pack_start(self._message_bar, False, False)
        self._main_vbox.reorder_child(self._message_bar, 0)
        self._message_bar.show_all()
        return self._message_bar

    #
    # Kiwi handlers
    #

    def on_ok_button__clicked(self, button):
        self.confirm()

    def on_cancel_button__clicked(self, button):
        self.cancel()

    def _delete_handler(self, window, event):
        self.cancel()