示例#1
0
文件: limit.py 项目: coopengo/tryton
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = gtk.Dialog(_('Limit'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                gtk.RESPONSE_OK))
        self.win.set_default_response(gtk.RESPONSE_OK)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_has_separator(True)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(gtk.Label(
            _('Search Limit Settings')), expand=False, fill=True)
        self.win.vbox.pack_start(gtk.HSeparator())
        hbox = gtk.HBox(spacing=3)
        label = gtk.Label(_('Limit:'))
        hbox.pack_start(label, expand=True, fill=True)
        adjustment = gtk.Adjustment(value=CONFIG['client.limit'],
            lower=1, upper=sys.maxint, step_incr=10, page_incr=100)
        self.spin_limit = gtk.SpinButton(adjustment, climb_rate=1, digits=0)
        self.spin_limit.set_numeric(False)
        self.spin_limit.set_activates_default(True)
        label.set_mnemonic_widget(self.spin_limit)
        hbox.pack_start(self.spin_limit, expand=True, fill=True)
        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        self.win.show_all()
示例#2
0
    def toggle_color(self, button, name, textview):
        text_buffer = textview.get_buffer()
        insert = text_buffer.get_insert()
        try:
            start, end = text_buffer.get_selection_bounds()
        except ValueError:
            start = end = None
        else:
            # Use offset position to preserve across buffer modification
            start = start.get_offset()
            end = end.get_offset()

        dialog = Gtk.ColorChooserDialog(title=_('Select a color'),
                                        transient_for=get_toplevel_window(),
                                        use_alpha=False)
        color = Gdk.RGBA()
        if name in self.colors:
            color.parse(self.colors[name])
            dialog.set_rgba(color)
        if dialog.run() == Gtk.ResponseType.OK:
            color = dialog.get_rgba()
            if start is not None and end is not None:
                start = text_buffer.get_iter_at_offset(start)
                end = text_buffer.get_iter_at_offset(end)
                tag = register_foreground(text_buffer, color)
                remove_tags(text_buffer, start, end, name)
                text_buffer.apply_tag(tag, start, end)
        dialog.destroy()
        text_buffer.place_cursor(text_buffer.get_iter_at_mark(insert))
示例#3
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = gtk.Dialog(
            _('Limit'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
             gtk.RESPONSE_OK))
        self.win.set_default_response(gtk.RESPONSE_OK)
        self.win.set_icon(TRYTON_ICON)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(gtk.Label(_('Search Limit Settings')),
                                 expand=False,
                                 fill=True)
        self.win.vbox.pack_start(gtk.HSeparator())
        hbox = gtk.HBox(spacing=3)
        label = gtk.Label(_('Limit:'))
        hbox.pack_start(label, expand=True, fill=True)
        adjustment = gtk.Adjustment(value=CONFIG['client.limit'],
                                    lower=1,
                                    upper=sys.maxint,
                                    step_incr=10,
                                    page_incr=100)
        self.spin_limit = gtk.SpinButton()
        self.spin_limit.configure(adjustment, climb_rate=1, digits=0)
        self.spin_limit.set_numeric(False)
        self.spin_limit.set_activates_default(True)
        label.set_mnemonic_widget(self.spin_limit)
        hbox.pack_start(self.spin_limit, expand=True, fill=True)
        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        self.win.show_all()
示例#4
0
    def toggle_color(self, button, name):
        insert = self.text_buffer.get_insert()
        try:
            start, end = self.text_buffer.get_selection_bounds()
        except ValueError:
            start = end = None
        else:
            # Use offset position to preserve across buffer modification
            start = start.get_offset()
            end = end.get_offset()

        dialog = gtk.ColorSelectionDialog(_('Select a color'))
        dialog.set_transient_for(get_toplevel_window())
        dialog.colorsel.set_has_palette(True)
        color = self.colors.get(name)
        if color:
            dialog.colorsel.set_current_color(color)
        if dialog.run() == gtk.RESPONSE_OK:
            color = dialog.colorsel.get_current_color()
            self.colors[name] = color
            if start is not None and end is not None:
                start = self.text_buffer.get_iter_at_offset(start)
                end = self.text_buffer.get_iter_at_offset(end)
                tag = register_foreground(self.text_buffer, color)
                remove_tags(self.text_buffer, start, end, name)
                self.text_buffer.apply_tag(tag, start, end)
        dialog.destroy()
        self.text_buffer.place_cursor(
            self.text_buffer.get_iter_at_mark(insert))
    def cal_open(self, widget):
        parent = get_toplevel_window()
        win = gtk.Dialog(_('Date Selection'), parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                gtk.RESPONSE_OK))
        win.set_has_separator(True)
        win.set_icon(TRYTON_ICON)

        cal = gtk.Calendar()
        cal.set_display_options(gtk.CALENDAR_SHOW_HEADING | \
                gtk.CALENDAR_SHOW_DAY_NAMES | \
                gtk.CALENDAR_SHOW_WEEK_NUMBERS | \
                gtk.CALENDAR_WEEK_START_MONDAY)
        cal.connect('day-selected-double-click',
                lambda *x: win.response(gtk.RESPONSE_OK))
        win.vbox.pack_start(cal, expand=True, fill=True)
        win.show_all()

        self.set_value(self.record, self.field)
        val = self.field.get(self.record)
        if val:
            cal.select_month(val.month - 1, val.year)
            cal.select_day(val.day)

        response = win.run()
        if response == gtk.RESPONSE_OK:
            year, month, day = cal.get_date()
            date = datetime.date(year, month + 1, day)
            self.field.set_client(self.record, date)
            self.display(self.record, self.field)
        self._focus_out()
        parent.present()
        win.destroy()
示例#6
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.dialog = gtk.Dialog(_('Keyboard Shortcuts'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
            | gtk.WIN_POS_CENTER_ON_PARENT | gtk.gdk.WINDOW_TYPE_HINT_DIALOG,
            (gtk.STOCK_OK, gtk.RESPONSE_OK))
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.set_has_separator(True)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        notebook = gtk.Notebook()
        self.dialog.vbox.pack_start(notebook)

        shortcuts = [
            (_('Text Entries Shortcuts'),),
            ('<Ctrl> + X', _('Cut selected text')),
            ('<Ctrl> + C', _('Copy selected text')),
            ('<Ctrl> + V', _('Paste copied text')),
            ('<Tab>', _('Next widget')),
            ('<Shift> + <Tab>', _('Previous widget')),
            (_('Relation Entries Shortcuts'),),
            ('<F3>', _('Create new relation')),
            ('<F2>', _('Open/Search relation')),
            (_('List Entries Shortcuts'),),
            ('<F3>', _('Create new line')),
            ('<F2>', _('Open relation')),
            ('<Del>', _('Mark line for deletion')),
            ('<Ins>', _('Unmark line for deletion')),
            ]
        notebook.append_page(self._fill_table(shortcuts),
                gtk.Label(_('Edition Widgets')))

        self.dialog.show_all()
示例#7
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.dialog = gtk.Dialog(
            _('Keyboard Shortcuts'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
            | gtk.WIN_POS_CENTER_ON_PARENT | gtk.gdk.WINDOW_TYPE_HINT_DIALOG,
            (gtk.STOCK_OK, gtk.RESPONSE_OK))
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.set_has_separator(True)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        notebook = gtk.Notebook()
        self.dialog.vbox.pack_start(notebook)

        shortcuts = [
            (_('Text Entries Shortcuts'), ),
            ('<Ctrl> + X', _('Cut selected text')),
            ('<Ctrl> + C', _('Copy selected text')),
            ('<Ctrl> + V', _('Paste copied text')),
            ('<Tab>', _('Next widget')),
            ('<Shift> + <Tab>', _('Previous widget')),
            (_('Relation Entries Shortcuts'), ),
            ('<F3>', _('Create new relation')),
            ('<F2>', _('Open/Search relation')),
            (_('List Entries Shortcuts'), ),
            ('<F3>', _('Create new line')),
            ('<F2>', _('Open relation')),
            ('<Del>', _('Mark line for deletion')),
            ('<Ins>', _('Unmark line for deletion')),
        ]
        notebook.append_page(self._fill_table(shortcuts),
                             gtk.Label(_('Edition Widgets')))

        self.dialog.show_all()
示例#8
0
    def toggle_color(self, button, name):
        insert = self.text_buffer.get_insert()
        try:
            start, end = self.text_buffer.get_selection_bounds()
        except ValueError:
            start = end = None
        else:
            # Use offset position to preserve across buffer modification
            start = start.get_offset()
            end = end.get_offset()

        dialog = gtk.ColorSelectionDialog(_('Select a color'))
        dialog.set_transient_for(get_toplevel_window())
        colorsel = dialog.get_color_selection()
        colorsel.set_has_palette(True)
        color = self.colors.get(name)
        if color:
            colorsel.set_current_color(color)
        if dialog.run() == gtk.RESPONSE_OK:
            color = colorsel.get_current_color()
            self.colors[name] = color
            if start is not None and end is not None:
                start = self.text_buffer.get_iter_at_offset(start)
                end = self.text_buffer.get_iter_at_offset(end)
                tag = register_foreground(self.text_buffer, color)
                remove_tags(self.text_buffer, start, end, name)
                self.text_buffer.apply_tag(tag, start, end)
        dialog.destroy()
        self.text_buffer.place_cursor(
            self.text_buffer.get_iter_at_mark(insert))
示例#9
0
文件: graph.py 项目: sm2x/gnuHealth
    def save(self, widget):
        parent = get_toplevel_window()
        dia = gtk.Dialog(_('Image Size'), parent,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                          gtk.RESPONSE_OK))
        dia.set_icon(GNUHEALTH_ICON)
        dia.set_default_response(gtk.RESPONSE_OK)

        hbox = gtk.HBox(spacing=3)
        dia.vbox.pack_start(hbox, False, True)

        hbox.pack_start(gtk.Label(_('Width:')), False, True)
        spinwidth = gtk.SpinButton()
        spinwidth.configure(gtk.Adjustment(400.0, 0.0, sys.maxint, 1.0, 10.0),
                            climb_rate=1,
                            digits=0)
        spinwidth.set_numeric(True)
        spinwidth.set_activates_default(True)
        hbox.pack_start(spinwidth, True, True)

        hbox.pack_start(gtk.Label(_('Height:')), False, True)
        spinheight = gtk.SpinButton()
        spinheight.configure(gtk.Adjustment(200.0, 0.0, sys.maxint, 1.0, 10.0),
                             climb_rate=1,
                             digits=0)
        spinheight.set_numeric(True)
        spinheight.set_activates_default(True)
        hbox.pack_start(spinheight, True, True)
        dia.show_all()

        filter = gtk.FileFilter()
        filter.set_name(_('PNG image (*.png)'))
        filter.add_mime_type('image/png')
        filter.add_pattern('*.png')

        while True:
            response = dia.run()
            width = spinwidth.get_value_as_int()
            height = spinheight.get_value_as_int()
            if response == gtk.RESPONSE_OK:
                filename = file_selection(_('Save As'),
                                          action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                          preview=False,
                                          filters=[filter])
                if width and height and filename:
                    if not filename.endswith('.png'):
                        filename = filename + '.png'
                    try:
                        self.widgets['root'].export_png(
                            filename, width, height)
                        break
                    except MemoryError:
                        message(_('Image size too large.'), dia,
                                gtk.MESSAGE_ERROR)
            else:
                break
        parent.present()
        dia.destroy()
示例#10
0
 def __init__(self, revisions, revision=None, format_='%x %H:%M:%S.%f'):
     self.parent = get_toplevel_window()
     self.win = gtk.Dialog(
         _('Revision'), self.parent,
         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
     Main().add_window(self.win)
     cancel_button = self.win.add_button(set_underline(_("Cancel")),
                                         gtk.RESPONSE_CANCEL)
     cancel_button.set_image(
         IconFactory.get_image('tryton-cancel', gtk.ICON_SIZE_BUTTON))
     cancel_button.set_always_show_image(True)
     ok_button = self.win.add_button(set_underline(_("OK")),
                                     gtk.RESPONSE_OK)
     ok_button.set_image(
         IconFactory.get_image('tryton-ok', gtk.ICON_SIZE_BUTTON))
     ok_button.set_always_show_image(True)
     self.win.set_default_response(gtk.RESPONSE_OK)
     self.win.set_icon(TRYTON_ICON)
     self.win.vbox.set_spacing(3)
     self.win.vbox.pack_start(gtk.Label(_('Select a revision')),
                              expand=False,
                              fill=True)
     self.win.vbox.pack_start(gtk.HSeparator())
     hbox = gtk.HBox(spacing=3)
     label = gtk.Label(_('Revision:'))
     hbox.pack_start(label, expand=True, fill=True)
     list_store = gtk.ListStore(str, str)
     # Set model on instantiation to get the default cellrenderer as text
     combobox = gtk.ComboBoxEntry(model=list_store)
     # JCA : Force set text colmn for gtk2
     combobox.set_text_column(0)
     self.entry = combobox.get_child()
     self.entry.connect('focus-out-event', self.focus_out)
     self.entry.connect('activate', self.activate)
     label.set_mnemonic_widget(self.entry)
     combobox.connect('changed', self.changed)
     self.entry.set_property('activates_default', True)
     self._format = format_
     if revision:
         self.entry.set_text(datetime_strftime(revision, self._format))
         self._value = revision
         active = -1
     else:
         self._value = None
         active = 0
     list_store.append(('', ''))
     for i, (rev, id_, name) in enumerate(revisions, 1):
         list_store.append((datetime_strftime(rev, self._format), name))
         if rev == revision:
             active = i
     combobox.set_active(active)
     cell = gtk.CellRendererText()
     combobox.pack_start(cell, True)
     combobox.add_attribute(cell, 'text', 1)
     hbox.pack_start(combobox, expand=True, fill=True)
     combobox.set_entry_text_column(0)
     self.win.vbox.pack_start(hbox, expand=True, fill=True)
     self.win.show_all()
示例#11
0
 def __init__(self):
     self.parent = common.get_toplevel_window()
     self.sensible_widget = common.get_sensible_widget(self.parent)
     self.page = None
     self.parent_focus = []
     focus = self.parent.get_focus()
     while focus:
         self.parent_focus.append(focus)
         focus = focus.get_parent()
示例#12
0
 def __init__(self):
     self.parent = common.get_toplevel_window()
     self.sensible_widget = common.get_sensible_widget(self.parent)
     self.page = None
     self.parent_focus = []
     focus = self.parent.get_focus()
     while focus:
         self.parent_focus.append(focus)
         focus = focus.get_parent()
    def cal_open(self, widget):
        parent = get_toplevel_window()
        win = gtk.Dialog(_('Date Time Selection'), parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                gtk.RESPONSE_OK))
        win.set_has_separator(True)
        win.set_icon(TRYTON_ICON)
        win.vbox.set_spacing(2)

        hbox = gtk.HBox(spacing=2)
        hbox.pack_start(gtk.Label(_('Hour:')), expand=False, fill=False)
        widget_hour = gtk.SpinButton(gtk.Adjustment(0, 0, 23, 1, 5), 1, 0)
        hbox.pack_start(widget_hour, expand=True, fill=True)
        hbox.pack_start(gtk.Label(_('Minute:')), expand=False, fill=False)
        widget_minute = gtk.SpinButton(
                gtk.Adjustment(0, 0, 59, 1, 10), 1, 0)
        hbox.pack_start(widget_minute, expand=True, fill=True)
        win.vbox.pack_start(hbox, expand=False, fill=True)

        cal = gtk.Calendar()
        cal.set_display_options(gtk.CALENDAR_SHOW_HEADING | \
                gtk.CALENDAR_SHOW_DAY_NAMES | \
                gtk.CALENDAR_SHOW_WEEK_NUMBERS | \
                gtk.CALENDAR_WEEK_START_MONDAY)
        cal.connect('day-selected-double-click',
                lambda *x: win.response(gtk.RESPONSE_OK))
        win.vbox.pack_start(cal, expand=True, fill=True)
        win.show_all()

        self.set_value(self.record, self.field)
        val = self.field.get(self.record)
        if val:
            val = timezoned_date(val)
            widget_hour.set_value(val.hour)
            widget_minute.set_value(val.minute)
            cal.select_month(val.month - 1, val.year)
            cal.select_day(val.day)
        else:
            widget_hour.set_value(time.localtime()[3])
            widget_minute.set_value(time.localtime()[4])
        response = win.run()
        if response == gtk.RESPONSE_OK:
            hour = int(widget_hour.get_value())
            minute = int(widget_minute.get_value())
            year = int(cal.get_date()[0])
            month = int(cal.get_date()[1]) + 1
            day = int(cal.get_date()[2])
            date = untimezoned_date(datetime.datetime(year, month, day, hour,
                    minute))
            self.field.set_client(self.record, date)
            self.display(self.record, self.field)
        self._focus_out()
        parent.present()
        win.destroy()
    def __init__(self, user):
        self.parent = common.get_toplevel_window()
        self.win = gtk.Dialog(_("Preferences"), self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_has_separator(False)
        self.win.set_icon(TRYTON_ICON)

        self.accel_group = gtk.AccelGroup()
        self.win.add_accel_group(self.accel_group)

        self.but_cancel = self.win.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.but_ok = self.win.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.but_ok.add_accelerator(
            "clicked", self.accel_group, gtk.keysyms.Return, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE
        )

        self.win.set_default_response(gtk.RESPONSE_OK)

        try:
            view = RPCExecute("model", "res.user", "get_preferences_fields_view")
        except RPCException:
            self.win.destroy()
            self.win = None
            return

        title = gtk.Label(_("Edit User Preferences"))
        title.show()
        self.win.vbox.pack_start(title, expand=False, fill=True)
        self.screen = Screen("res.user", mode=[])
        self.screen.add_view(view)
        self.screen.new(default=False)

        try:
            preferences = RPCExecute("model", "res.user", "get_preferences", False)
        except RPCException:
            self.win.destroy()
            self.win = None
            return
        self.screen.current_record.set(preferences)
        self.screen.current_record.validate(softvalidation=True)
        self.screen.screen_container.set(self.screen.current_view.widget)
        self.screen.display(set_cursor=True)

        self.screen.widget.show()
        self.win.vbox.pack_start(self.screen.widget)
        self.win.set_title(_("Preference"))

        width, height = self.parent.get_size()
        self.win.set_default_size(int(width * 0.9), int(height * 0.9))

        self.win.show()
示例#15
0
文件: about.py 项目: mdn57/health
    def __init__(self):
        parent = get_toplevel_window()
        self.win = Gtk.AboutDialog()
        self.win.set_transient_for(parent)
        self.win.set_name(CONFIG['client.title'])
        self.win.set_version(__version__)
        self.win.set_comments(POWERED_BY)
        self.win.set_license(LICENSE)
        self.win.set_website('http://www.gnuhealth.org/')
        self.win.set_logo(GNUHEALTH_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
    def __init__(self):
        self.parent = get_toplevel_window()
        self.dialog = gtk.Dialog(_('Keyboard Shortcuts'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
            | gtk.WIN_POS_CENTER_ON_PARENT | gtk.gdk.WINDOW_TYPE_HINT_DIALOG,
            (gtk.STOCK_OK, gtk.RESPONSE_OK))
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.set_has_separator(True)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        notebook = gtk.Notebook()
        self.dialog.vbox.pack_start(notebook)

        shortcuts = [
            (_('Text Entries Shortcuts'),),
            ('<Ctrl> + X', _('Cut selected text')),
            ('<Ctrl> + C', _('Copy selected text')),
            ('<Ctrl> + V', _('Paste copied text')),
            ('<Tab>', _('Next widget')),
            ('<Shift> + <Tab>', _('Previous widget')),
            (_('Relation Entries Shortcuts'),),
            ('<F3>', _('Create new relation')),
            ('<F2>', _('Open/Search relation')),
            (_('List Entries Shortcuts'),),
            ('<F3>', _('Create new line')),
            ('<F2>', _('Open relation')),
            ('<Del>', _('Mark line for deletion')),
            ('<Ins>', _('Unmark line for deletion')),
            (_('Date/Datetime Entries Shortcuts'),),
            (_('''You can use special operators:
* + to increase the date
* - to decrease the date or clear
* = to set the date or the current date

Available variables are:
h for hours
d for days
w for weeks (only with +/-)
m for months
y for years

Examples:
"+21d" increase of 21 days the date
"=11m" set the date to the 11th month of the year
"-2w" decrease of 2 weeks the date'''),),
        ]
        notebook.append_page(self._fill_table(shortcuts),
                gtk.Label(_('Edition Widgets')))

        self.dialog.show_all()
示例#17
0
    def value_from_text(self, record, text, callback=None):
        field = record.group.fields[self.attrs['name']]
        model = self.get_model(record, field)
        if not text:
            field.set_client(record, self.value_from_id(model, None, ''))
            if callback:
                callback()
            return

        if model and common.get_toplevel_window().get_focus():
            field = record[self.attrs['name']]
            win = self.search_remote(record, field, text, callback=callback)
            if len(win.screen.group) == 1:
                win.response(None, Gtk.ResponseType.OK)
            else:
                win.show()
示例#18
0
 def __init__(self, revisions, revision=None, format_='%x %X.%f'):
     self.parent = get_toplevel_window()
     self.win = gtk.Dialog(
         _('Revision'), self.parent,
         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
         (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
          gtk.RESPONSE_OK))
     self.win.set_default_response(gtk.RESPONSE_OK)
     self.win.set_icon(TRYTON_ICON)
     self.win.set_has_separator(True)
     self.win.vbox.set_spacing(3)
     self.win.vbox.pack_start(gtk.Label(_('Select a revision')),
                              expand=False,
                              fill=True)
     self.win.vbox.pack_start(gtk.HSeparator())
     hbox = gtk.HBox(spacing=3)
     label = gtk.Label(_('Revision:'))
     hbox.pack_start(label, expand=True, fill=True)
     list_store = gtk.ListStore(str, str)
     combobox = gtk.ComboBoxEntry(list_store)
     self.entry = combobox.child
     self.entry.connect('focus-out-event', self.focus_out)
     self.entry.connect('activate', self.activate)
     label.set_mnemonic_widget(self.entry)
     combobox.connect('changed', self.changed)
     self.entry.set_property('activates_default', True)
     self._format = format_
     if revision:
         self.entry.set_text(datetime_strftime(revision, self._format))
         self._value = revision
         active = -1
     else:
         self._value = None
         active = 0
     list_store.append(('', ''))
     for i, (rev, id_, name) in enumerate(revisions, 1):
         list_store.append((datetime_strftime(rev, self._format), name))
         if rev == revision:
             active = i
     combobox.set_active(active)
     cell = gtk.CellRendererText()
     combobox.pack_start(cell, True)
     combobox.add_attribute(cell, 'text', 1)
     hbox.pack_start(combobox, expand=True, fill=True)
     combobox.set_entry_text_column(0)
     self.win.vbox.pack_start(hbox, expand=True, fill=True)
     self.win.show_all()
示例#19
0
 def __init__(self, revisions, revision=None, format_="%x %X.%f"):
     self.parent = get_toplevel_window()
     self.win = gtk.Dialog(
         _("Revision"),
         self.parent,
         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
         (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK),
     )
     self.win.set_default_response(gtk.RESPONSE_OK)
     self.win.set_icon(TRYTON_ICON)
     self.win.set_has_separator(True)
     self.win.vbox.set_spacing(3)
     self.win.vbox.pack_start(gtk.Label(_("Select a revision")), expand=False, fill=True)
     self.win.vbox.pack_start(gtk.HSeparator())
     hbox = gtk.HBox(spacing=3)
     label = gtk.Label(_("Revision:"))
     hbox.pack_start(label, expand=True, fill=True)
     list_store = gtk.ListStore(str, str)
     combobox = gtk.ComboBoxEntry(list_store)
     self.entry = combobox.child
     self.entry.connect("focus-out-event", self.focus_out)
     self.entry.connect("activate", self.activate)
     label.set_mnemonic_widget(self.entry)
     combobox.connect("changed", self.changed)
     self.entry.set_property("activates_default", True)
     self._format = format_
     if revision:
         self.entry.set_text(datetime_strftime(revision, self._format))
         self._value = revision
         active = -1
     else:
         self._value = None
         active = 0
     list_store.append(("", ""))
     for i, (rev, id_, name) in enumerate(revisions, 1):
         list_store.append((datetime_strftime(rev, self._format), name))
         if rev == revision:
             active = i
     combobox.set_active(active)
     cell = gtk.CellRendererText()
     combobox.pack_start(cell, True)
     combobox.add_attribute(cell, "text", 1)
     hbox.pack_start(combobox, expand=True, fill=True)
     combobox.set_entry_text_column(0)
     self.win.vbox.pack_start(hbox, expand=True, fill=True)
     self.win.show_all()
示例#20
0
文件: limit.py 项目: mdn57/health
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = Gtk.Dialog(title=_('Limit'),
                              transient_for=self.parent,
                              modal=True,
                              destroy_with_parent=True)
        Main().add_window(self.win)
        cancel_button = self.win.add_button(set_underline(_("Cancel")),
                                            Gtk.ResponseType.CANCEL)
        cancel_button.set_image(
            IconFactory.get_image('tryton-cancel', Gtk.IconSize.BUTTON))
        cancel_button.set_always_show_image(True)
        ok_button = self.win.add_button(set_underline(_("OK")),
                                        Gtk.ResponseType.OK)
        ok_button.set_image(
            IconFactory.get_image('tryton-ok', Gtk.IconSize.BUTTON))
        ok_button.set_always_show_image(True)
        self.win.set_default_response(Gtk.ResponseType.OK)
        self.win.set_icon(GNUHEALTH_ICON)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(Gtk.Label(label=_('Search Limit Settings')),
                                 expand=False,
                                 fill=True,
                                 padding=0)
        self.win.vbox.pack_start(Gtk.HSeparator(),
                                 expand=True,
                                 fill=True,
                                 padding=0)
        hbox = Gtk.HBox(spacing=3)
        label = Gtk.Label(label=_('Limit:'))
        hbox.pack_start(label, expand=True, fill=True, padding=0)
        adjustment = Gtk.Adjustment(value=CONFIG['client.limit'],
                                    lower=1,
                                    upper=sys.maxsize,
                                    step_incr=10,
                                    page_incr=100)
        self.spin_limit = Gtk.SpinButton()
        self.spin_limit.configure(adjustment, climb_rate=1, digits=0)
        self.spin_limit.set_numeric(False)
        self.spin_limit.set_activates_default(True)
        label.set_mnemonic_widget(self.spin_limit)
        hbox.pack_start(self.spin_limit, expand=True, fill=True, padding=0)
        self.win.vbox.pack_start(hbox, expand=True, fill=True, padding=0)

        self.win.show_all()
示例#21
0
    def __init__(self):
        gtk.about_dialog_set_email_hook(
            lambda widget, link: webbrowser.open(link, new=2))
        gtk.about_dialog_set_url_hook(
            lambda widget, link: webbrowser.open(link, new=2))
        parent = get_toplevel_window()
        self.win = gtk.AboutDialog()
        self.win.set_transient_for(parent)
        self.win.set_name('Tryton')
        self.win.set_version(VERSION)
        self.win.set_copyright(COPYRIGHT)
        self.win.set_license(LICENSE)
        self.win.set_website(WEBSITE)
        self.win.set_authors(AUTHORS)
        self.win.set_logo(TRYTON_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
示例#22
0
文件: about.py 项目: xyzlat/tryton
 def __init__(self):
     parent = get_toplevel_window()
     self.win = Gtk.AboutDialog()
     self.win.set_transient_for(parent)
     self.win.set_name(CONFIG['client.title'])
     self.win.set_version(__version__)
     self.win.set_comments(_("modularity, scalability and security"))
     self.win.set_copyright(COPYRIGHT)
     self.win.set_license_type(Gtk.License.GPL_3_0)
     self.win.set_website('http://www.tryton.org/')
     self.win.set_website_label("Tryton")
     self.win.set_authors(AUTHORS)
     self.win.set_translator_credits(_('translator-credits'))
     self.win.set_logo(
         GdkPixbuf.Pixbuf.new_from_file(
             os.path.join(PIXMAPS_DIR, 'tryton.svg')))
     self.win.run()
     parent.present()
     self.win.destroy()
示例#23
0
    def __init__(self):
        gtk.about_dialog_set_email_hook(lambda widget, link:
                webbrowser.open(link, new=2))
        gtk.about_dialog_set_url_hook(lambda widget, link:
                webbrowser.open(link, new=2))
        parent = get_toplevel_window()
        self.win = gtk.AboutDialog()
        self.win.set_transient_for(parent)
        self.win.set_name('Tryton')
        self.win.set_version(__version__)
        self.win.set_copyright(COPYRIGHT)
        self.win.set_license(LICENSE)
        self.win.set_website('http://www.tryton.org/')
        self.win.set_authors(AUTHORS)
        self.win.set_logo(TRYTON_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
示例#24
0
 def action_prop_font(self, widget, tag):
     '''
     Apply style to text (selected or not) tag (color foreground, color
     background, font-family and font-size)
     '''
     content = None
     if tag in ['foreground', 'background']:
         # Deactivate focus_out to not lose selection
         self.focus_out = False
         labels = {
             'foreground': _('Select a foreground color'),
             'background': _('Select a background color'),
             }
         dialog = gtk.ColorSelectionDialog(labels[tag])
         dialog.set_transient_for(get_toplevel_window())
         dialog.set_resizable(False)
         dialog.colorsel.set_has_palette(True)
         dialog.colorsel.set_current_color(self.current_font_prop[tag])
         res = dialog.run()
         if res == gtk.RESPONSE_OK:
             content = dialog.colorsel.get_current_color()
             self.current_font_prop[tag] = content
         dialog.destroy()
         self.focus_out = True
     else:
         content = self.tools[tag].child.get_active_text()
         font = self.current_font_prop[tag]
         self.current_font_prop[tag] = content
     bounds = self.text_buffer.get_selection_bounds()
     if bounds:
         start, end = bounds
         if tag in ('font_family', 'size'):
             self.text_buffer.remove_tag(
                 self.gen_tag(font, tag), start, end)
         self.text_buffer.apply_tag(self.gen_tag(content, tag), start, end)
     else:
         mark = self.text_buffer.get_iter_at_mark(
             self.text_buffer.get_insert())
         start = self.text_buffer.create_mark(None, mark, True)
         end = self.text_buffer.create_mark(None, mark, False)
         self.start_tags[tag] = start
         self.end_tags[tag] = end
示例#25
0
 def action_prop_font(self, widget, tag):
     '''
     Apply style to text (selected or not) tag (color foreground, color
     background, font-family and font-size)
     '''
     content = None
     if tag in ['foreground', 'background']:
         # Deactivate focus_out to not lose selection
         self.focus_out = False
         labels = {
             'foreground': _('Select a foreground color'),
             'background': _('Select a background color'),
         }
         dialog = gtk.ColorSelectionDialog(labels[tag])
         dialog.set_transient_for(get_toplevel_window())
         dialog.set_resizable(False)
         dialog.colorsel.set_has_palette(True)
         dialog.colorsel.set_current_color(self.current_font_prop[tag])
         res = dialog.run()
         if res == gtk.RESPONSE_OK:
             content = dialog.colorsel.get_current_color()
             self.current_font_prop[tag] = content
         dialog.destroy()
         self.focus_out = True
     else:
         content = self.tools[tag].child.get_active_text()
         font = self.current_font_prop[tag]
         self.current_font_prop[tag] = content
     bounds = self.text_buffer.get_selection_bounds()
     if bounds:
         start, end = bounds
         if tag in ('font_family', 'size'):
             self.text_buffer.remove_tag(self.gen_tag(font, tag), start,
                                         end)
         self.text_buffer.apply_tag(self.gen_tag(content, tag), start, end)
     else:
         mark = self.text_buffer.get_iter_at_mark(
             self.text_buffer.get_insert())
         start = self.text_buffer.create_mark(None, mark, True)
         end = self.text_buffer.create_mark(None, mark, False)
         self.start_tags[tag] = start
         self.end_tags[tag] = end
示例#26
0
    def sig_goto(self, widget=None):
        if not self.modified_save():
            return
        parent = common.get_toplevel_window()
        win = gtk.Dialog(_('Go to ID'), parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                gtk.RESPONSE_OK))
        win.set_icon(TRYTON_ICON)
        win.set_has_separator(True)
        win.set_default_response(gtk.RESPONSE_OK)

        table = gtk.Table(2, 2)
        table.attach(gtk.Label(_('Go to ID:')), 1, 2, 0, 1, gtk.FILL)
        img = gtk.Image()
        img.set_from_stock('tryton-go-jump', gtk.ICON_SIZE_DIALOG)
        table.attach(img, 0, 1, 0, 2, gtk.FILL)

        entry = gtk.Entry()
        entry.set_property('activates_default', True)
        entry.set_max_length(0)
        entry.set_alignment(1.0)

        def sig_insert_text(widget, new_text, new_text_length, position):
            value = widget.get_text()
            position = widget.get_position()
            new_value = value[:position] + new_text + value[position:]
            try:
                locale.atoi(new_value)
            except ValueError:
                widget.stop_emission('insert-text')
        entry.connect('insert_text', sig_insert_text)
        table.attach(entry, 1, 2, 1, 2)

        win.vbox.pack_start(table, expand=True, fill=True)
        win.show_all()

        response = win.run()
        if response == gtk.RESPONSE_OK:
            self.screen.display(locale.atoi(entry.get_text()), set_cursor=True)
        win.destroy()
        parent.present()
示例#27
0
 def __init__(self):
     parent = get_toplevel_window()
     self.win = Gtk.AboutDialog()
     self.win.set_transient_for(parent)
     self.win.set_name(CONFIG['client.title'])
     # MAR : Fix #5107 : Replace tryton references with Coog
     self.win.set_version(__version_coog__)
     self.win.set_comments(_("modularity, scalability and security"))
     self.win.set_copyright(COPYRIGHT)
     self.win.set_license_type(Gtk.License.GPL_3_0)
     self.win.set_website('http://coopengo.com/')
     self.win.set_website_label("Coopengo")
     self.win.set_authors(AUTHORS)
     self.win.set_translator_credits(_('translator-credits'))
     self.win.set_logo(
         GdkPixbuf.Pixbuf.new_from_file(
             os.path.join(PIXMAPS_DIR, 'tryton.png').encode('utf-8')))
     self.win.run()
     parent.present()
     self.win.destroy()
示例#28
0
    def __init__(self):
        if hasattr(gtk, 'about_dialog_set_email_hook'):
            gtk.about_dialog_set_email_hook(lambda widget, link:
                    webbrowser.open(link, new=2))
        if hasattr(gtk, 'about_dialog_set_url_hook'):
            gtk.about_dialog_set_url_hook(lambda widget, link:
                    webbrowser.open(link, new=2))
        parent = get_toplevel_window()
        self.win = gtk.AboutDialog()
        self.win.set_transient_for(parent)
        self.win.set_name(CONFIG['client.title'])
        self.win.set_version(__version__)
        self.win.set_comments(COMMENTS)
        self.win.set_license(LICENSE)
        self.win.set_website('http://health.gnu.org/')
        self.win.set_logo(GNUHEALTH_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
示例#29
0
文件: about.py 项目: coopengo/tryton
    def __init__(self):
        gtk.about_dialog_set_email_hook(lambda widget, link:
                webbrowser.open(link, new=2))
        gtk.about_dialog_set_url_hook(lambda widget, link:
                webbrowser.open(link, new=2))
        parent = get_toplevel_window()
        self.win = gtk.AboutDialog()
        self.win.set_transient_for(parent)
        # MAR : Fix #5107 : Replace tryton references with Coog
        self.win.set_name('Coog')
        self.win.set_version(__version_coog__)
        self.win.set_copyright(COPYRIGHT)
        self.win.set_license(LICENSE)
        self.win.set_website('http://coopengo.com/')
        self.win.set_authors(AUTHORS)
        self.win.set_logo(TRYTON_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
示例#30
0
    def __init__(self):
        if hasattr(gtk, 'about_dialog_set_email_hook'):
            gtk.about_dialog_set_email_hook(
                lambda widget, link: webbrowser.open(link, new=2))
        if hasattr(gtk, 'about_dialog_set_url_hook'):
            gtk.about_dialog_set_url_hook(
                lambda widget, link: webbrowser.open(link, new=2))
        parent = get_toplevel_window()
        self.win = gtk.AboutDialog()
        self.win.set_transient_for(parent)
        self.win.set_name(CONFIG['client.title'])
        self.win.set_version('4.2.1.0')
        #self.win.set_copyright(COPYRIGHT)
        self.win.set_license('Licencia Nodux')
        self.win.set_website('http://nodux.ec/')
        #self.win.set_authors(AUTHORS)
        self.win.set_logo(TRYTON_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
示例#31
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = gtk.Dialog(
            _('Limit'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        Main().add_window(self.win)
        cancel_button = self.win.add_button(set_underline(_("Cancel")),
                                            gtk.RESPONSE_CANCEL)
        cancel_button.set_image(
            IconFactory.get_image('tryton-cancel', gtk.ICON_SIZE_BUTTON))
        cancel_button.set_always_show_image(True)
        ok_button = self.win.add_button(set_underline(_("OK")),
                                        gtk.RESPONSE_OK)
        ok_button.set_image(
            IconFactory.get_image('tryton-ok', gtk.ICON_SIZE_BUTTON))
        ok_button.set_always_show_image(True)
        self.win.set_default_response(gtk.RESPONSE_OK)
        self.win.set_icon(TRYTON_ICON)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(gtk.Label(_('Search Limit Settings')),
                                 expand=False,
                                 fill=True)
        self.win.vbox.pack_start(gtk.HSeparator())
        hbox = gtk.HBox(spacing=3)
        label = gtk.Label(_('Limit:'))
        hbox.pack_start(label, expand=True, fill=True)
        adjustment = gtk.Adjustment(value=CONFIG['client.limit'],
                                    lower=1,
                                    upper=sys.maxsize,
                                    step_incr=10,
                                    page_incr=100)
        self.spin_limit = gtk.SpinButton()
        self.spin_limit.configure(adjustment, climb_rate=1, digits=0)
        self.spin_limit.set_numeric(False)
        self.spin_limit.set_activates_default(True)
        label.set_mnemonic_widget(self.spin_limit)
        hbox.pack_start(self.spin_limit, expand=True, fill=True)
        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        self.win.show_all()
示例#32
0
    def __init__(self):
        if hasattr(gtk, 'about_dialog_set_email_hook'):
            gtk.about_dialog_set_email_hook(
                lambda widget, link: webbrowser.open(link, new=2))
        if hasattr(gtk, 'about_dialog_set_url_hook'):
            gtk.about_dialog_set_url_hook(
                lambda widget, link: webbrowser.open(link, new=2))
        parent = get_toplevel_window()
        self.win = gtk.AboutDialog()
        self.win.set_transient_for(parent)
        self.win.set_name(CONFIG['client.title'])
        # MAR : Fix #5107 : Replace tryton references with Coog
        self.win.set_version(__version_coog__)
        self.win.set_copyright(COPYRIGHT)
        self.win.set_license(LICENSE)
        self.win.set_website('http://coopengo.com/')
        self.win.set_authors(AUTHORS)
        self.win.set_logo(TRYTON_ICON)

        self.win.run()
        parent.present()
        self.win.destroy()
示例#33
0
    def __init__(self, function=None):
        # This widget is used for creating and droping a database!
        if function == "backup":
            dialog_title = _("Backup a database")
            button_ok_text = _("Backup")
            button_ok_tooltip = _("Backup the choosen database.")
            button_ok_icon = "tryton-save-as"
            label_subtitle_text = _("Choose a Tryton database to backup:")
        elif function == "drop":
            dialog_title = _("Delete a database")
            button_ok_text = _("Delete")
            button_ok_tooltip = _("Delete the choosen database.")
            button_ok_icon = "tryton-delete"
            label_subtitle_text = _("Choose a Tryton database to delete:")
        else:
            return None

        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=dialog_title, parent=self.parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
            | gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_has_separator(True)
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.connect("key-press-event", self.event_show_button_ok)
        self.tooltips = common.Tooltips()
        self.dialog.add_button("gtk-cancel",
            gtk.RESPONSE_CANCEL)
        self.button_ok = gtk.Button(button_ok_text)
        self.button_ok.set_flags(gtk.CAN_DEFAULT)
        self.button_ok.set_flags(gtk.HAS_DEFAULT)
        self.button_ok.set_sensitive(False)
        img_connect = gtk.Image()
        img_connect.set_from_stock(button_ok_icon, gtk.ICON_SIZE_BUTTON)
        self.button_ok.set_image(img_connect)
        self.tooltips.set_tip(self.button_ok, button_ok_tooltip)
        self.dialog.add_action_widget(self.button_ok, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        self.dialog_vbox = gtk.VBox()

        table = gtk.Table(5, 3, False)
        table.set_border_width(10)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        self.dialog_vbox.pack_start(table, True, False, 0)

        label_subtitle = gtk.Label()
        label_subtitle.set_markup("<b>" + label_subtitle_text + "</b>")
        label_subtitle.set_justify(gtk.JUSTIFY_LEFT)
        label_subtitle.set_alignment(0, 1)
        label_subtitle.set_padding(9, 5)
        table.attach(label_subtitle, 0, 3, 0, 1, yoptions=False,
            xoptions=gtk.FILL)

        hseparator = gtk.HSeparator()
        table.attach(hseparator, 0, 3, 1, 2, yoptions=False)

        self.label_server = gtk.Label(_("Server Connection:"))
        self.label_server.set_alignment(1, 0.5)
        self.label_server.set_padding(3, 3)
        table.attach(self.label_server, 0, 1, 2, 3, yoptions=False,
            xoptions=gtk.FILL)

        self.entry_server_connection = gtk.Entry()
        self.entry_server_connection.set_sensitive(False)
        self.entry_server_connection.unset_flags(gtk.CAN_FOCUS)
        self.entry_server_connection.set_editable(False)
        self.label_server.set_mnemonic_widget(self.entry_server_connection)
        self.tooltips.set_tip(self.entry_server_connection, _("This is the "
                "URL of the server. Use server 'localhost' and port '8000' "
                "if the server is installed on this computer. "
                "Click on 'Change' to change the address."))
        table.attach(self.entry_server_connection, 1, 2, 2, 3,
                yoptions=gtk.FILL)

        self.button_server_change = gtk.Button(_("C_hange"), stock=None,
            use_underline=True)
        img_button_server_change = gtk.Image()
        img_button_server_change.set_from_stock('tryton-preferences-system',
            gtk.ICON_SIZE_BUTTON)
        self.button_server_change.set_image(img_button_server_change)
        table.attach(self.button_server_change, 2, 3, 2, 3, yoptions=False)

        self.label_database = gtk.Label()
        self.label_database.set_text(_("Database:"))
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        table.attach(self.label_database, 0, 1, 3, 4, yoptions=False,
            xoptions=gtk.FILL)

        vbox_combo = gtk.VBox(homogeneous=True)
        self.combo_database = gtk.ComboBox()
        dbstore = gtk.ListStore(gobject.TYPE_STRING)
        cell = gtk.CellRendererText()
        self.combo_database.pack_start(cell, True)
        self.combo_database.add_attribute(cell, 'text', 0)
        self.combo_database.set_model(dbstore)
        self.db_progressbar = gtk.ProgressBar()
        self.combo_database_label = gtk.Label()
        self.combo_database_label.set_use_markup(True)
        self.combo_database_label.set_alignment(0, 1)
        self.combo_database_entry = gtk.Entry()
        vbox_combo.pack_start(self.combo_database)
        vbox_combo.pack_start(self.combo_database_label)
        vbox_combo.pack_start(self.db_progressbar)
        vbox_combo.pack_start(self.combo_database_entry)
        width, height = 0, 0
        # Compute size_request of box in order to prevent "form jumping"
        for child in vbox_combo.get_children():
            cwidth, cheight = child.size_request()
            width, height = max(width, cwidth), max(height, cheight)
        vbox_combo.set_size_request(width, height)
        table.attach(vbox_combo, 1, 3, 3, 4, yoptions=False)

        self.label_serverpasswd = gtk.Label(_("Tryton Server Password:"******"This is the "
                "password of the Tryton server. It doesn't belong to a "
                "real user. This password is usually defined in the trytond "
                "configuration."))
        table.attach(self.entry_serverpasswd, 1, 3, 4, 5, yoptions=False)

        self.entry_serverpasswd.grab_focus()
        self.dialog.vbox.pack_start(self.dialog_vbox)
def save(widget, graph):
    parent = common.get_toplevel_window()
    dia = gtk.Dialog(_('Save As'), parent,
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
    dia.set_icon(TRYTON_ICON)
    dia.set_has_separator(True)
    dia.set_default_response(gtk.RESPONSE_OK)

    dia.vbox.set_spacing(5)
    dia.vbox.set_homogeneous(False)

    title = gtk.Label('<b>' + _('Image Size') + '</b>')
    title.set_alignment(0.0, 0.5)
    title.set_use_markup(True)
    dia.vbox.pack_start(title)

    table = gtk.Table(2, 2)
    table.set_col_spacings(3)
    table.set_row_spacings(3)
    table.set_border_width(1)
    table.attach(gtk.Label(_('Width:')), 0, 1, 0, 1, yoptions=False,
            xoptions=gtk.FILL)
    spinwidth = gtk.SpinButton(gtk.Adjustment(400.0,
            0.0, sys.maxint, 1.0, 10.0))
    spinwidth.set_numeric(True)
    spinwidth.set_activates_default(True)
    table.attach(spinwidth, 1, 2, 0, 1, yoptions=False, xoptions=gtk.FILL)
    table.attach(gtk.Label(_('Height:')), 0, 1, 1, 2, yoptions=False,
            xoptions=gtk.FILL)
    spinheight = gtk.SpinButton(gtk.Adjustment(200.0,
            0.0, sys.maxint, 1.0, 10.0))
    spinheight.set_numeric(True)
    spinheight.set_activates_default(True)
    table.attach(spinheight, 1, 2, 1, 2, yoptions=False, xoptions=gtk.FILL)
    dia.vbox.pack_start(table)

    filechooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE, None)
    filechooser.set_current_folder(CONFIG['client.default_path'])
    filter = gtk.FileFilter()
    filter.set_name(_('PNG image (*.png)'))
    filter.add_mime_type('image/png')
    filter.add_pattern('*.png')
    filechooser.add_filter(filter)
    dia.vbox.pack_start(filechooser)

    dia.show_all()

    while True:
        response = dia.run()
        width = spinwidth.get_value_as_int()
        height = spinheight.get_value_as_int()
        filename = filechooser.get_filename()
        if filename:
            filename = filename.decode('utf-8')
            try:
                CONFIG['client.default_path'] = \
                       os.path.dirname(filename)
                CONFIG.save()
            except IOError:
                pass
        if response == gtk.RESPONSE_OK:
            if width and height and filename:
                if not filename.endswith('.png'):
                    filename = filename + '.png'
                try:
                    graph.export_png(filename, width, height)
                    break
                except MemoryError:
                    common.message(_('Image size too large!'), dia,
                            gtk.MESSAGE_ERROR)
        else:
            break
    parent.present()
    dia.destroy()
    return
示例#35
0
文件: email.py 项目: coopengo/tryton
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = gtk.Dialog(_('Email'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                gtk.RESPONSE_OK))
        self.win.set_default_response(gtk.RESPONSE_OK)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_has_separator(True)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(gtk.Label(
            _('Email Program Settings')), expand=False, fill=True)
        self.win.vbox.pack_start(gtk.HSeparator())
        hbox = gtk.HBox(spacing=3)
        label = gtk.Label(_('Command Line:'))
        hbox.pack_start(label, expand=True, fill=True)
        self.entry = gtk.Entry()
        self.entry.set_property('activates_default', True)
        self.entry.set_width_chars(50)
        self.entry.set_text(CONFIG['client.email'])
        label.set_mnemonic_widget(label)
        hbox.pack_start(self.entry, expand=True, fill=True)
        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        label = gtk.Label(_('Legend of Available Placeholders:'))
        label.set_alignment(0.0, 0.5)
        label.set_padding(0, 10)
        self.win.vbox.pack_start(label, expand=False, fill=True)

        hbox = gtk.HBox(spacing=3)
        vboxl = gtk.VBox(homogeneous=True, spacing=3)
        label = gtk.Label(_('To:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('CC:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('Subject:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('Body:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('Attachment:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)

        vboxr = gtk.VBox(homogeneous=True, spacing=3)
        label = gtk.Label(' ${to}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${cc}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${subject}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${body}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${attachment}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)

        hbox.pack_start(vboxl, expand=False, fill=False)
        hbox.pack_start(vboxr, expand=False, fill=False)

        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        self.win.show_all()
示例#36
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = Gtk.Dialog(title=_('Email'),
                              transient_for=self.parent,
                              modal=True,
                              destroy_with_parent=True)
        Main().add_window(self.win)
        cancel_button = self.win.add_button(set_underline(_("Cancel")),
                                            Gtk.ResponseType.CANCEL)
        cancel_button.set_image(
            IconFactory.get_image('tryton-cancel', Gtk.IconSize.BUTTON))
        cancel_button.set_always_show_image(True)
        ok_button = self.win.add_button(set_underline(_("OK")),
                                        Gtk.ResponseType.OK)
        ok_button.set_image(
            IconFactory.get_image('tryton-ok', Gtk.IconSize.BUTTON))
        ok_button.set_always_show_image(True)
        self.win.set_default_response(Gtk.ResponseType.OK)
        self.win.set_icon(TRYTON_ICON)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(Gtk.Label(_('Email Program Settings')),
                                 expand=False,
                                 fill=True,
                                 padding=0)
        self.win.vbox.pack_start(Gtk.HSeparator(),
                                 expand=True,
                                 fill=True,
                                 padding=0)
        hbox = Gtk.HBox(spacing=3)
        label = Gtk.Label(label=_('Command Line:'))
        hbox.pack_start(label, expand=True, fill=True, padding=0)
        self.entry = Gtk.Entry()
        self.entry.set_property('activates_default', True)
        self.entry.set_width_chars(50)
        self.entry.set_text(CONFIG['client.email'])
        label.set_mnemonic_widget(label)
        hbox.pack_start(self.entry, expand=True, fill=True, padding=0)
        self.win.vbox.pack_start(hbox, expand=True, fill=True, padding=0)

        label = Gtk.Label(label=_('Legend of Available Placeholders:'),
                          halign=Gtk.Align.START,
                          margin_top=10,
                          margin_bottom=5)
        self.win.vbox.pack_start(label, expand=False, fill=True, padding=0)

        hbox = Gtk.HBox(spacing=3)
        vboxl = Gtk.VBox(homogeneous=True, spacing=3)
        label = Gtk.Label(label=_('To:'), halign=Gtk.Align.START)
        vboxl.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=_('CC:'), halign=Gtk.Align.START)
        vboxl.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=_('Subject:'), halign=Gtk.Align.START)
        vboxl.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=_('Body:'), halign=Gtk.Align.START)
        vboxl.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=_('Attachment:'), halign=Gtk.Align.START)
        vboxl.pack_start(label, expand=False, fill=False, padding=0)

        vboxr = Gtk.VBox(homogeneous=True, spacing=3)
        label = Gtk.Label(label=' ${to}', halign=Gtk.Align.START)
        vboxr.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=' ${cc}', halign=Gtk.Align.START)
        vboxr.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=' ${subject}', halign=Gtk.Align.START)
        vboxr.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=' ${body}', halign=Gtk.Align.START)
        vboxr.pack_start(label, expand=False, fill=False, padding=0)
        label = Gtk.Label(label=' ${attachment}', halign=Gtk.Align.START)
        vboxr.pack_start(label, expand=False, fill=False, padding=0)

        hbox.pack_start(vboxl, expand=False, fill=False, padding=0)
        hbox.pack_start(vboxr, expand=False, fill=False, padding=0)

        self.win.vbox.pack_start(hbox, expand=True, fill=True, padding=0)

        self.win.show_all()
示例#37
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.win = gtk.Dialog(_('Email'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        cancel_button = self.win.add_button('gtk-cancel', gtk.RESPONSE_CANCEL)
        cancel_button.set_always_show_image(True)
        ok_button = self.win.add_button('gtk-ok', gtk.RESPONSE_OK)
        ok_button.set_always_show_image(True)
        self.win.set_default_response(gtk.RESPONSE_OK)
        self.win.set_icon(TRYTON_ICON)
        self.win.vbox.set_spacing(3)
        self.win.vbox.pack_start(gtk.Label(
            _('Email Program Settings')), expand=False, fill=True)
        self.win.vbox.pack_start(gtk.HSeparator())
        hbox = gtk.HBox(spacing=3)
        label = gtk.Label(_('Command Line:'))
        hbox.pack_start(label, expand=True, fill=True)
        self.entry = gtk.Entry()
        self.entry.set_property('activates_default', True)
        self.entry.set_width_chars(50)
        self.entry.set_text(CONFIG['client.email'])
        label.set_mnemonic_widget(label)
        hbox.pack_start(self.entry, expand=True, fill=True)
        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        label = gtk.Label(_('Legend of Available Placeholders:'))
        label.set_alignment(0.0, 0.5)
        label.set_padding(0, 10)
        self.win.vbox.pack_start(label, expand=False, fill=True)

        hbox = gtk.HBox(spacing=3)
        vboxl = gtk.VBox(homogeneous=True, spacing=3)
        label = gtk.Label(_('To:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('CC:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('Subject:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('Body:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)
        label = gtk.Label(_('Attachment:'))
        label.set_alignment(0, 0)
        label.set_padding(10, 0)
        vboxl.pack_start(label, expand=False, fill=False)

        vboxr = gtk.VBox(homogeneous=True, spacing=3)
        label = gtk.Label(' ${to}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${cc}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${subject}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${body}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)
        label = gtk.Label(' ${attachment}')
        label.set_alignment(0, 0)
        vboxr.pack_start(label, expand=False, fill=False)

        hbox.pack_start(vboxl, expand=False, fill=False)
        hbox.pack_start(vboxr, expand=False, fill=False)

        self.win.vbox.pack_start(hbox, expand=True, fill=True)

        self.win.show_all()
示例#38
0
 def __init__(self, revisions, revision=None, format_='%x %H:%M:%S.%f'):
     self.parent = get_toplevel_window()
     self.win = Gtk.Dialog(title=_('Revision'),
                           transient_for=self.parent,
                           modal=True,
                           destroy_with_parent=True)
     Main().add_window(self.win)
     cancel_button = self.win.add_button(set_underline(_("Cancel")),
                                         Gtk.ResponseType.CANCEL)
     cancel_button.set_image(
         IconFactory.get_image('tryton-cancel', Gtk.IconSize.BUTTON))
     cancel_button.set_always_show_image(True)
     ok_button = self.win.add_button(set_underline(_("OK")),
                                     Gtk.ResponseType.OK)
     ok_button.set_image(
         IconFactory.get_image('tryton-ok', Gtk.IconSize.BUTTON))
     ok_button.set_always_show_image(True)
     self.win.set_default_response(Gtk.ResponseType.OK)
     self.win.set_icon(GNUHEALTH_ICON)
     self.win.vbox.set_spacing(3)
     self.win.vbox.pack_start(Gtk.Label(label=_('Select a revision')),
                              expand=False,
                              fill=True,
                              padding=0)
     self.win.vbox.pack_start(Gtk.HSeparator(),
                              expand=True,
                              fill=True,
                              padding=0)
     hbox = Gtk.HBox(spacing=3)
     label = Gtk.Label(label=_('Revision:'))
     hbox.pack_start(label, expand=True, fill=True, padding=0)
     list_store = Gtk.ListStore(str, str)
     # Set model on instantiation to get the default cellrenderer as text
     combobox = Gtk.ComboBox(model=list_store, has_entry=True)
     self.entry = combobox.get_child()
     self.entry.connect('focus-out-event', self.focus_out)
     self.entry.connect('activate', self.activate)
     label.set_mnemonic_widget(self.entry)
     combobox.connect('changed', self.changed)
     self.entry.set_property('activates_default', True)
     self._format = format_
     if revision:
         self.entry.set_text(revision.strftime(self._format))
         self._value = revision
         active = -1
     else:
         self._value = None
         active = 0
     list_store.append(('', ''))
     for i, (rev, id_, name) in enumerate(revisions, 1):
         list_store.append(
             (timezoned_date(rev).strftime(self._format), name))
         if rev == revision:
             active = i
     combobox.set_active(active)
     cell = Gtk.CellRendererText()
     combobox.pack_start(cell, expand=True)
     combobox.add_attribute(cell, 'text', 1)
     hbox.pack_start(combobox, expand=True, fill=True, padding=0)
     combobox.set_entry_text_column(0)
     self.win.vbox.pack_start(hbox, expand=True, fill=True, padding=0)
     self.win.show_all()
示例#39
0
    def save(self, widget):
        parent = get_toplevel_window()
        dia = gtk.Dialog(_('Save As'), parent,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                          gtk.RESPONSE_OK))
        dia.set_icon(TRYTON_ICON)
        dia.set_has_separator(True)
        dia.set_default_response(gtk.RESPONSE_OK)

        dia.vbox.set_spacing(5)
        dia.vbox.set_homogeneous(False)

        title = gtk.Label('<b>' + _('Image Size') + '</b>')
        title.set_alignment(0.0, 0.5)
        title.set_use_markup(True)
        dia.vbox.pack_start(title)

        table = gtk.Table(2, 2)
        table.set_col_spacings(3)
        table.set_row_spacings(3)
        table.set_border_width(1)
        table.attach(gtk.Label(_('Width:')),
                     0,
                     1,
                     0,
                     1,
                     yoptions=False,
                     xoptions=gtk.FILL)
        spinwidth = gtk.SpinButton(
            gtk.Adjustment(400.0, 0.0, sys.maxint, 1.0, 10.0))
        spinwidth.set_numeric(True)
        spinwidth.set_activates_default(True)
        table.attach(spinwidth, 1, 2, 0, 1, yoptions=False, xoptions=gtk.FILL)
        table.attach(gtk.Label(_('Height:')),
                     0,
                     1,
                     1,
                     2,
                     yoptions=False,
                     xoptions=gtk.FILL)
        spinheight = gtk.SpinButton(
            gtk.Adjustment(200.0, 0.0, sys.maxint, 1.0, 10.0))
        spinheight.set_numeric(True)
        spinheight.set_activates_default(True)
        table.attach(spinheight, 1, 2, 1, 2, yoptions=False, xoptions=gtk.FILL)
        dia.vbox.pack_start(table)

        filechooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE, None)
        filter = gtk.FileFilter()
        filter.set_name(_('PNG image (*.png)'))
        filter.add_mime_type('image/png')
        filter.add_pattern('*.png')
        filechooser.add_filter(filter)
        dia.vbox.pack_start(filechooser)

        dia.show_all()

        while True:
            response = dia.run()
            width = spinwidth.get_value_as_int()
            height = spinheight.get_value_as_int()
            filename = filechooser.get_filename()
            if response == gtk.RESPONSE_OK:
                if width and height and filename:
                    if not filename.endswith('.png'):
                        filename = filename + '.png'
                    try:
                        self.widgets['root'].export_png(
                            filename, width, height)
                        break
                    except MemoryError:
                        message(_('Image size too large!'), dia,
                                gtk.MESSAGE_ERROR)
            else:
                break
        parent.present()
        dia.destroy()
    def __init__(self, model):
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(
                title=_("Import from CSV"), parent=self.parent,
                flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
                | gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)

        dialog_vbox = gtk.VBox()
        hbox_mapping = gtk.HBox(True)
        dialog_vbox.pack_start(hbox_mapping, True, True, 0)

        frame_fields = gtk.Frame()
        frame_fields.set_shadow_type(gtk.SHADOW_NONE)
        viewport_fields = gtk.Viewport()
        scrolledwindow_fields = gtk.ScrolledWindow()
        scrolledwindow_fields.set_policy(gtk.POLICY_AUTOMATIC,
                gtk.POLICY_AUTOMATIC)
        viewport_fields.add(scrolledwindow_fields)
        frame_fields.add(viewport_fields)
        label_all_fields = gtk.Label(_("<b>All fields</b>"))
        label_all_fields.set_use_markup(True)
        frame_fields.set_label_widget(label_all_fields)
        hbox_mapping.pack_start(frame_fields, True, True, 0)

        vbox_buttons = gtk.VBox()
        vbox_buttons.set_border_width(5)
        hbox_mapping.pack_start(vbox_buttons, False, True, 0)

        button_add = gtk.Button(_("_Add"), stock=None, use_underline=True)
        button_add.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-list-add', gtk.ICON_SIZE_BUTTON)
        button_add.set_image(img_button)
        button_add.connect_after('clicked',  self.sig_sel)
        vbox_buttons.pack_start(button_add, False, False, 0)

        button_remove = gtk.Button(_("_Remove"), stock=None,
                use_underline=True)
        button_remove.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_BUTTON)
        button_remove.set_image(img_button)
        button_remove.connect_after('clicked',  self.sig_unsel)
        vbox_buttons.pack_start(button_remove, False, False, 0)

        button_remove_all = gtk.Button(_("Clear"), stock=None,
                use_underline=True)
        button_remove_all.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-clear', gtk.ICON_SIZE_BUTTON)
        button_remove_all.set_image(img_button)
        button_remove_all.connect_after('clicked',  self.sig_unsel_all)
        vbox_buttons.pack_start(button_remove_all, False, False, 0)

        hseparator_buttons = gtk.HSeparator()
        vbox_buttons.pack_start(hseparator_buttons, False, False, 3)

        button_autodetect = gtk.Button(_("Auto-Detect"), stock=None,
                use_underline=True)
        button_autodetect.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-find', gtk.ICON_SIZE_BUTTON)
        button_autodetect.set_image(img_button)
        button_autodetect.connect_after('clicked',  self.sig_autodetect)
        vbox_buttons.pack_start(button_autodetect, False, False, 0)

        frame_import = gtk.Frame()
        frame_import.set_shadow_type(gtk.SHADOW_NONE)
        viewport_import = gtk.Viewport()
        scrolledwindow_import = gtk.ScrolledWindow()
        scrolledwindow_import.set_policy(gtk.POLICY_AUTOMATIC,
                gtk.POLICY_AUTOMATIC)
        viewport_import.add(scrolledwindow_import)
        frame_import.add(viewport_import)
        label_fields_import = gtk.Label(_("<b>Fields to import</b>"))
        label_fields_import.set_use_markup(True)
        frame_import.set_label_widget(label_fields_import)
        hbox_mapping.pack_start(frame_import, True, True, 0)

        frame_csv_param = gtk.Frame(None)
        frame_csv_param.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        dialog_vbox.pack_start(frame_csv_param, False, True, 0)
        alignment_csv_param = gtk.Alignment(0.5, 0.5, 1, 1)
        alignment_csv_param.set_padding(7, 7, 7, 7)
        frame_csv_param.add(alignment_csv_param)

        vbox_csv_param = gtk.VBox()
        alignment_csv_param.add(vbox_csv_param)
        hbox_csv_import = gtk.HBox()
        vbox_csv_param.pack_start(hbox_csv_import, False, True, 4)
        label_csv_import = gtk.Label(_("File to Import:"))
        hbox_csv_import.pack_start(label_csv_import, False, False, 0)
        self.import_csv_file = gtk.FileChooserButton(_("Open..."))
        hbox_csv_import.pack_start(self.import_csv_file, True, True, 0)

        expander_csv_import = gtk.Expander(None)
        expander_csv_import.set_expanded(True)
        vbox_csv_param.pack_start(expander_csv_import, False, True, 0)
        label_import_csv_param = gtk.Label(_("CSV Parameters"))
        expander_csv_import.set_label_widget(label_import_csv_param)
        table = gtk.Table(2, 4, False)
        table.set_border_width(8)
        table.set_row_spacings(9)
        table.set_col_spacings(8)
        expander_csv_import.add(table)

        label_import_csv_sep = gtk.Label(_("Field Separator:"))
        label_import_csv_sep.set_alignment(1, 0.5)
        table.attach(label_import_csv_sep, 0, 1, 0, 1)
        self.import_csv_sep = gtk.Entry()
        self.import_csv_sep.set_max_length(1)
        self.import_csv_sep.set_text(",")
        self.import_csv_sep.set_width_chars(1)
        table.attach(self.import_csv_sep, 1, 2, 0, 1)

        label_import_csv_del = gtk.Label(_("Text Delimiter:"))
        label_import_csv_del.set_alignment(1, 0.5)
        table.attach(label_import_csv_del, 2, 3, 0, 1)
        self.import_csv_del = gtk.Entry()
        self.import_csv_del.set_text("\"")
        self.import_csv_del.set_width_chars(1)
        table.attach(self.import_csv_del, 3, 4, 0, 1)

        label_import_csv_enc = gtk.Label(_("Encoding:"))
        label_import_csv_enc.set_alignment(1, 0.5)
        table.attach(label_import_csv_enc, 0, 1, 1, 2)
        self.import_csv_enc = gtk.combo_box_new_text()
        self.import_csv_enc.append_text("UTF-8")
        self.import_csv_enc.append_text("Latin1")
        table.attach(self.import_csv_enc, 1, 2, 1, 2)

        label_import_csv_skip = gtk.Label(_("Lines to Skip:"))
        label_import_csv_skip.set_alignment(1, 0.5)
        table.attach(label_import_csv_skip, 2, 3, 1, 2)

        self.import_csv_skip_adj = gtk.Adjustment(0, 0, 100, 1, 10)
        self.import_csv_skip = gtk.SpinButton(self.import_csv_skip_adj, 1, 0)
        table.attach(self.import_csv_skip, 3, 4, 1, 2)

        button_cancel = gtk.Button("gtk-cancel", stock="gtk-cancel")
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        button_ok = gtk.Button("gtk-ok", stock="gtk-ok")
        self.dialog.add_action_widget(button_ok, gtk.RESPONSE_OK)
        button_ok.set_flags(gtk.CAN_DEFAULT)

        self.dialog.vbox.pack_start(dialog_vbox)

        self.model = model
        self.fields_data = {}

        self.dialog.show_all()
        self.import_csv_file.set_current_folder(CONFIG['client.default_path'])

        self.view1 = gtk.TreeView()
        self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.view1.connect('row-expanded', self.on_row_expanded)
        scrolledwindow_fields.add(self.view1)
        self.view2 = gtk.TreeView()
        self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        scrolledwindow_import.add(self.view2)
        self.view1.set_headers_visible(False)
        self.view2.set_headers_visible(False)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Field name'), cell, text=0,
                background=2)
        self.view1.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Field name'), cell, text=0)
        self.view2.append_column(column)

        self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                gobject.TYPE_STRING)
        self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

        self.fields = {}
        self.fields_invert = {}

        self.model_populate(self._get_fields(model))

        self.view1.set_model(self.model1)
        self.view2.set_model(self.model2)
        self.view1.show_all()
        self.view2.show_all()
示例#41
0
    def __init__(self):

        self.tips = [
            _('''<b>Welcome to Akara Services</b>


'''),
            
            _('''<b>Export list records</b>

You can copy records from any list with Ctrl + C
and paste in any application with Ctrl + V
'''),
            _('''<b>Export graphs</b>

You can save any graphs in PNG file with right-click on it.
'''),
        ]

        parent = get_toplevel_window()
        
        self.win = gtk.Dialog(_('Tips'), parent,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_has_separator(True)
        self.win.set_size_request(500, 400)

        self.win.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        self.win.set_default_response(gtk.RESPONSE_CLOSE)
        vbox = gtk.VBox()
        #img = gtk.Image()
        #img.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        #vbox.pack_start(img, False, False)
        self.label = gtk.Label()
        self.label.set_alignment(0, 0)
        vbox.pack_start(self.label, True, True)
        separator = gtk.HSeparator()
        vbox.pack_start(separator, False, False)

        hbox = gtk.HBox()
        self.check = gtk.CheckButton(_('_Display a new tip next time'), True)
        self.check.set_active(True)
        hbox.pack_start(self.check)
        but_previous = gtk.Button()
        hbox_previous = gtk.HBox()
        img_previous = gtk.Image()
        img_previous.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_BUTTON)
        hbox_previous.pack_start(img_previous)
        label_previous = gtk.Label(_('Previous'))
        hbox_previous.pack_start(label_previous)
        but_previous.add(hbox_previous)
        but_previous.set_relief(gtk.RELIEF_NONE)
        but_previous.connect('clicked', self.tip_previous)
        hbox.pack_start(but_previous)
        hbox_next = gtk.HBox()
        label_next = gtk.Label(_('Next'))
        hbox_next.pack_start(label_next)
        but_next = gtk.Button()
        img_next = gtk.Image()
        img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_BUTTON)
        hbox_next.pack_start(img_next)
        but_next.add(hbox_next)
        but_next.set_relief(gtk.RELIEF_NONE)
        but_next.connect('clicked', self.tip_next)
        hbox.pack_start(but_next)
        vbox.pack_start(hbox, False, False)
        self.win.vbox.pack_start(vbox)
        self.win.show_all()

        try:
            self.number = int(CONFIG['tip.position'])
        except ValueError:
            self.number = 0

        self.tip_set()

        self.win.run()
        CONFIG['tip.autostart'] = self.check.get_active()
        CONFIG['tip.position'] = self.number + 1
        CONFIG.save()
        parent.present()
        self.win.destroy()
示例#42
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.dialog = gtk.Dialog(_('Keyboard Shortcuts'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
            | gtk.WIN_POS_CENTER_ON_PARENT | gtk.gdk.WINDOW_TYPE_HINT_DIALOG,
            (gtk.STOCK_OK, gtk.RESPONSE_OK))
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.set_has_separator(True)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        notebook = gtk.Notebook()
        self.dialog.vbox.pack_start(notebook)

        shortcuts = [
            (_('Text Entries Shortcuts'),),
            ('<Ctrl> + X', _('Cut selected text')),
            ('<Ctrl> + C', _('Copy selected text')),
            ('<Ctrl> + V', _('Paste copied text')),
            ('<Tab>', _('Next widget')),
            ('<Shift> + <Tab>', _('Previous widget')),
            (_('Relation Entries Shortcuts'),),
            ('<F3>', _('Create new relation')),
            ('<F2>', _('Open/Search relation')),
            (_('List Entries Shortcuts'),),
            ('<F3>', _('Create new line')),
            ('<F2>', _('Open relation')),
            ('<Del>', _('Mark line for deletion')),
            ('<Ins>', _('Unmark line for deletion')),
            ]
        notebook.append_page(self._fill_table(shortcuts),
                gtk.Label(_('Edition Widgets')))

        shortcuts = [
            (_('Move Cursor'),),
            ('<Right>', _('Move to right')),
            ('<Left>', _('Move to left')),
            ('<Up>', _('Move up')),
            ('<Down>', _('Move down')),
            ('<Page Up>', _('Move up of one page')),
            ('<Page Down>', _('Move down of one page')),
            ('<Home>', _('Move to top')),
            ('<End>', _('Move to bottom')),
            ('<Backspace>', _('Move to parent')),
            (_('Selection'),),
            ('<Ctrl> + a', _('Select all')),
            ('<Ctrl> + /', _('Select all')),
            ('<Shift> + <Ctrl> + a', _('Unselect all')),
            ('<Shift> + <Ctrl> + /', _('Unselect all')),
            ('<Backspace>', _('Select parent')),
            ('<Space>', _('Select/Activate current row')),
            ('<Shift> + <Space>', _('Select/Activate current row')),
            ('<Return>', _('Select/Activate current row')),
            ('<Enter>', _('Select/Activate current row')),
            ('<Ctrl> + <Space>', _('Toggle selection')),
            (_('Expand/Collapse'),),
            ('+', _('Expand row')),
            ('-', _('Collapse row')),
            ('<Space>', _('Toggle row')),
            ('<Shift> + <Left>', _('Expand all rows')),
            ('<Shift> + <Right>', _('Collapse all rows')),
            ]
        notebook.append_page(self._fill_table(shortcuts),
                gtk.Label(_('Tree view')))

        self.dialog.show_all()
示例#43
0
文件: graph.py 项目: mpaulmier/tryton
    def save(self, widget):
        parent = get_toplevel_window()
        dia = Gtk.Dialog(
            title=_('Image Size'), transient_for=parent, modal=True,
            destroy_with_parent=True)
        Main().add_window(dia)
        cancel_button = dia.add_button(
            set_underline(_("Cancel")), Gtk.ResponseType.CANCEL)
        cancel_button.set_image(IconFactory.get_image(
                'tryton-cancel', Gtk.IconSize.BUTTON))
        cancel_button.set_always_show_image(True)
        ok_button = dia.add_button(
            set_underline(_("OK")), Gtk.ResponseType.OK)
        ok_button.set_image(IconFactory.get_image(
                'tryton-ok', Gtk.IconSize.BUTTON))
        ok_button.set_always_show_image(True)
        dia.set_icon(TRYTON_ICON)
        dia.set_default_response(Gtk.ResponseType.OK)

        hbox = Gtk.HBox(spacing=3)
        dia.vbox.pack_start(hbox, expand=False, fill=True, padding=0)

        hbox.pack_start(
            Gtk.Label(label=_('Width:')), expand=False, fill=True, padding=0)
        spinwidth = Gtk.SpinButton()
        spinwidth.configure(Gtk.Adjustment(
                value=400.0, lower=0.0, upper=sys.maxsize,
                step_increment=1.0, page_increment=10.0),
            climb_rate=1, digits=0)
        spinwidth.set_numeric(True)
        spinwidth.set_activates_default(True)
        hbox.pack_start(spinwidth, expand=True, fill=True, padding=0)

        hbox.pack_start(
            Gtk.Label(label=_('Height:')), expand=False, fill=True, padding=0)
        spinheight = Gtk.SpinButton()
        spinheight.configure(Gtk.Adjustment(
                value=200.0, lower=0.0, upper=sys.maxsize,
                step_increment=1.0, page_increment=10.0),
            climb_rate=1, digits=0)
        spinheight.set_numeric(True)
        spinheight.set_activates_default(True)
        hbox.pack_start(spinheight, expand=True, fill=True, padding=0)
        dia.show_all()

        filter = Gtk.FileFilter()
        filter.set_name(_('PNG image (*.png)'))
        filter.add_mime_type('image/png')
        filter.add_pattern('*.png')

        while True:
            response = dia.run()
            width = spinwidth.get_value_as_int()
            height = spinheight.get_value_as_int()
            if response == Gtk.ResponseType.OK:
                filename = file_selection(
                    _('Save As'),
                    action=Gtk.FileChooserAction.SAVE,
                    preview=False,
                    filters=[filter])
                if width and height and filename:
                    if not filename.endswith('.png'):
                        filename = filename + '.png'
                    try:
                        self.widgets['root'].export_png(
                            filename, width, height)
                        break
                    except MemoryError:
                        message(
                            _('Image size too large.'), dia,
                            Gtk.MessageType.ERROR)
            else:
                break
        parent.present()
        dia.destroy()
示例#44
0
    def run(self):
        parent = common.get_toplevel_window()
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        self.dialog.set_transient_for(parent)
        self.dialog.show_all()

        pass_widget = self.entry_serverpasswd
        change_button = self.button_server_change
        admin_passwd = self.entry_adminpasswd
        admin_passwd2 = self.entry_adminpasswd2
        change_button.connect_after('clicked', self.server_change)

        if self.host and self.port:
            url = '%s:%d' % (self.host, self.port)
        else:
            url = ''
        self.entry_server_connection.set_text(url)

        liststore = gtk.ListStore(str, str)
        self.combo_language.set_model(liststore)
        try:
            common.refresh_langlist(self.combo_language, self.host, self.port)
        except TrytonServerError:
            self.button_create.set_sensitive(False)

        while True:
            self.dialog.props.sensitive = True
            res = self.dialog.run()
            dbname = self.entry_dbname.get_text()
            netloc = self.entry_server_connection.get_text()
            host = common.get_hostname(netloc)
            port = common.get_port(netloc)
            langidx = self.combo_language.get_active_iter()
            langreal = langidx \
                and self.combo_language.get_model().get_value(langidx, 1)
            passwd = pass_widget.get_text()
            if res == gtk.RESPONSE_OK:
                if admin_passwd.get_text() != admin_passwd2.get_text():
                    common.warning(
                        _("The new admin password "
                            "doesn't match the confirmation field.\n"),
                        _("Passwords doesn't match!"))
                    continue
                try:
                    exist = rpc.db_exec(host, port, 'db_exist', dbname)
                except TrytonServerError, exception:
                    common.process_exception(exception)
                    continue
                if exist:
                    common.warning(_("A database with the same name "
                            "already exists.\n"
                            "Try another database name."),
                        _("This database name already exist!"))
                    self.entry_dbname.set_text("")
                    self.entry_dbname.grab_focus()
                    continue
                else:  # Everything runs fine, break the block here
                    self.dialog.props.sensitive = False
                    try:
                        rpcprogress = common.RPCProgress('db_exec',
                            (host, port, 'create', dbname, passwd, langreal,
                                admin_passwd.get_text()))
                        rpcprogress.run(False)
                    except TrytonServerError, exception:
                        if str(exception.faultCode) == "AccessDenied":
                            common.warning(_("Sorry, wrong password for "
                                    "the Tryton server. "
                                    "Please try again."),
                                _("Access denied!"))
                            self.entry_serverpasswd.set_text("")
                            self.entry_serverpasswd.grab_focus()
                            continue
                        else:  # Unclassified error
                            common.warning(_("Can't create the "
                                "database, caused by an unknown reason.\n"
                                "If there is a database created, it could "
                                "be broken. Maybe drop this database! "
                                "Please check the error message for "
                                "possible informations.\n"
                                "Error message:\n")
                                + str(exception.faultCode),
                                _("Error creating database!"))
                        parent.present()
                        self.dialog.destroy()
                        rpc.logout()
                        break
                    parent.present()
                    self.dialog.destroy()
                    if self.sig_login:
                        CONFIG['login.server'] = host
                        CONFIG['login.port'] = str(port)
                        CONFIG['login.db'] = dbname
                        CONFIG['login.login'] = '******'
                        self.sig_login()
                    break
示例#45
0
    def shortcuts(self):
        if self._shortcuts:
            self._shortcuts.destroy()
        self._shortcuts = window = Gtk.ShortcutsWindow()
        window.set_transient_for(common.get_toplevel_window())
        window.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        window.set_destroy_with_parent(True)
        self.add_window(window)

        section = Gtk.ShortcutsSection()
        section.props.section_name = 'app'
        section.props.title = _("Application Shortcuts")
        section.props.visible = True

        group = Gtk.ShortcutsGroup()
        group.props.title = _("Global")
        section.add(group)

        for action, title in [
            ('app.preferences', _("Preferences")),
            ('app.menu-search', _("Search menu")),
            ('app.menu-toggle', _("Toggle menu")),
            (
                'app.tab-previous',
                _("Previous tab"),
            ),
            ('app.tab-next', _("Next tab")),
            ('app.shortcuts', _("Shortcuts")),
            ('app.quit', _("Quit")),
        ]:
            shortcut = Gtk.ShortcutsShortcut()
            shortcut.props.title = title
            accels = self.get_accels_for_action(action)
            if accels:
                shortcut.props.accelerator = ' '.join(accels)
                group.add(shortcut)

        window.add(section)

        for name, title, groups in [
            ('entry', _("Edition Shortcuts"), [
                (_("Text Entries"), [
                    ('<Primary>x', _("Cut selected text")),
                    ('<Primary>c', _("Copy selected text")),
                    ('<Primary>v', _("Paste copied text")),
                    ('Tab', _("Next entry")),
                    ('<Shift>Tab', _("Previous entry")),
                ]),
                (_("Relation Entries"), [
                    ('F3', _("Create new relation")),
                    ('F2', _("Open/Search relation")),
                ]),
                (_("List Entries"), [
                    ('F4', _("Switch view")),
                    ('F3', _("Create/Select new line")),
                    ('F2', _("Open relation")),
                    ('Delete', _("Mark line for deletion/removal")),
                    ('<Ctrl>Delete', _("Mark line for removal")),
                    ('Insert', _("Unmark line for deletion")),
                ]),
            ]),
            ('tree', _("List/Tree Shortcuts"), [
                (_("Move Cursor"), [
                    ('Right', _("Move right")),
                    ('Left', _("Move left")),
                    ('Up', _("Move up")),
                    ('Down', _("Move down")),
                    ('Page_Up', _("Move up of one page")),
                    ('Page_Down', _("Move down of one page")),
                    ('Home', _("Move to top")),
                    ('End', _("Move to bottom")),
                    ('BackSpace', _("Move to parent")),
                ]),
                (_("Selection"), [
                    ('<Ctrl>a <Ctrl>slash', _("Select all")),
                    ('<Shift><Ctrl>a <Shift><Ctrl>slash', _("Unselect all")),
                    ('BackSpace', _("Select parent")),
                    ('space', _("Select/Activate current row")),
                    ('<Shift>space Return', _("Select/Activate current row")),
                    ('<Ctrl>space', _("Toggle selection")),
                ]),
                (_("Expand/Collapse"), [
                    ('plus', _("Expand row")),
                    ('minus', _("Collapse row")),
                    ('space', _("Toggle row")),
                    ('<Shift>Left', _("Collapse all rows")),
                    ('<Shift>Right', _("Expand all rows")),
                ]),
            ]),
        ]:
            section = Gtk.ShortcutsSection()
            section.props.section_name = name
            section.props.title = title
            section.props.visible = True

            for title, shortcuts in groups:
                group = Gtk.ShortcutsGroup()
                group.props.title = title
                section.add(group)

                for accelerator, title in shortcuts:
                    shortcut = Gtk.ShortcutsShortcut()
                    shortcut.props.title = title
                    shortcut.props.accelerator = accelerator
                    group.add(shortcut)

            window.add(section)

        window.show_all()
示例#46
0
    def __init__(self):
        # GTK Stuffs
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_('Login'), parent=self.parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(GNUHEALTH_ICON)

        tooltips = common.Tooltips()
        button_cancel = gtk.Button(_('_Cancel'), use_underline=True)
        img_cancel = gtk.Image()
        img_cancel.set_from_stock('gtk-cancel', gtk.ICON_SIZE_BUTTON)
        button_cancel.set_image(img_cancel)
        tooltips.set_tip(button_cancel,
            _('Cancel connection to the GNU Health server'))
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        self.button_connect = gtk.Button(_('C_onnect'), use_underline=True)
        img_connect = gtk.Image()
        img_connect.set_from_stock('tryton-connect', gtk.ICON_SIZE_BUTTON)
        self.button_connect.set_image(img_connect)
        self.button_connect.set_can_default(True)
        tooltips.set_tip(self.button_connect, _('Connect the GNU Health server'))
        self.dialog.add_action_widget(self.button_connect, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        alignment = gtk.Alignment(yalign=0, yscale=0, xscale=1)
        self.table_main = gtk.Table(3, 3, False)
        self.table_main.set_border_width(0)
        self.table_main.set_row_spacings(3)
        self.table_main.set_col_spacings(3)
        alignment.add(self.table_main)
        self.dialog.vbox.pack_start(alignment, True, True, 0)

        image = gtk.Image()
        # Use custom banner if set in the custom_banner param
        if (CONFIG['client.banner']):
            image.set_from_file(CONFIG['client.banner'])
        else:
            image.set_from_file(os.path.join(PIXMAPS_DIR, BANNER))
        image.set_alignment(0.5, 1)
        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019"))
        ebox.add(image)
        self.table_main.attach(ebox, 0, 3, 0, 1, ypadding=2)

        self.profile_store = gtk.ListStore(gobject.TYPE_STRING,
            gobject.TYPE_BOOLEAN)
        self.combo_profile = gtk.ComboBox()
        cell = gtk.CellRendererText()
        self.combo_profile.pack_start(cell, True)
        self.combo_profile.add_attribute(cell, 'text', 0)
        self.combo_profile.add_attribute(cell, 'sensitive', 1)
        self.combo_profile.set_model(self.profile_store)
        self.combo_profile.connect('changed', self.profile_changed)
        self.profile_label = gtk.Label(_(u'Profile:'))
        self.profile_label.set_justify(gtk.JUSTIFY_RIGHT)
        self.profile_label.set_alignment(1, 0.5)
        self.profile_label.set_padding(3, 3)
        self.profile_button = gtk.Button(_('_Manage profiles'),
            use_underline=True)
        self.profile_button.connect('clicked', self.profile_manage)
        self.table_main.attach(self.profile_label, 0, 1, 1, 2,
            xoptions=gtk.FILL)
        self.table_main.attach(self.combo_profile, 1, 2, 1, 2)
        self.table_main.attach(self.profile_button, 2, 3, 1, 2,
            xoptions=gtk.FILL)
        image = gtk.Image()
        image.set_from_stock('gtk-edit', gtk.ICON_SIZE_BUTTON)
        self.profile_button.set_image(image)
        self.expander = gtk.Expander()
        self.expander.set_label(_('Host / Database information'))
        self.expander.connect('notify::expanded', self.expand_hostspec)
        self.table_main.attach(self.expander, 0, 3, 3, 4)
        self.label_host = gtk.Label(_('Host:'))
        self.label_host.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_host.set_alignment(1, 0.5)
        self.label_host.set_padding(3, 3)
        self.entry_host = gtk.Entry()
        self.entry_host.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_host.set_activates_default(True)
        self.label_host.set_mnemonic_widget(self.entry_host)
        self.table_main.attach(self.label_host, 0, 1, 4, 5, xoptions=gtk.FILL)
        self.table_main.attach(self.entry_host, 1, 3, 4, 5)
        self.label_database = gtk.Label(_('Database:'))
        self.label_database.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        self.entry_database = gtk.Entry()
        self.entry_database.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_database.set_activates_default(True)
        self.label_database.set_mnemonic_widget(self.entry_database)
        self.table_main.attach(self.label_database, 0, 1, 5, 6,
            xoptions=gtk.FILL)
        self.table_main.attach(self.entry_database, 1, 3, 5, 6)
        self.entry_login = gtk.Entry()
        self.entry_login.set_activates_default(True)
        self.table_main.attach(self.entry_login, 1, 3, 6, 7)
        label_username = gtk.Label(_("User name:"))
        label_username.set_alignment(1, 0.5)
        label_username.set_padding(3, 3)
        label_username.set_mnemonic_widget(self.entry_login)
        self.table_main.attach(label_username, 0, 1, 6, 7, xoptions=gtk.FILL)

        # Profile informations
        self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg')
        self.profiles = ConfigParser.SafeConfigParser({'port': '8000'})
        if not os.path.exists(self.profile_cfg):
            short_version = '.'.join(__version__.split('.', 2)[:2])
            name = 'health.gnusolidario.org'
            self.profiles.add_section(name)
            self.profiles.set(name, 'host', name)
            self.profiles.set(name, 'port', '8000')
            self.profiles.set(name, 'database', 'health32')
            self.profiles.set(name, 'username', 'admin')
        else:
            self.profiles.read(self.profile_cfg)
        for section in self.profiles.sections():
            active = all(self.profiles.has_option(section, option)
                for option in ('host', 'port', 'database'))
            self.profile_store.append([section, active])
示例#47
0
    def __init__(self, function=None):
        # This widget is used for creating and droping a database!
        if function == "backup":
            dialog_title = _("Backup a database")
            button_ok_text = _("Backup")
            button_ok_tooltip = _("Backup the choosen database.")
            button_ok_icon = "tryton-save-as"
            label_subtitle_text = _("Choose a Tryton database to backup:")
        elif function == "drop":
            dialog_title = _("Delete a database")
            button_ok_text = _("Delete")
            button_ok_tooltip = _("Delete the choosen database.")
            button_ok_icon = "tryton-delete"
            label_subtitle_text = _("Choose a Tryton database to delete:")
        else:
            return None

        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=dialog_title,
                                 parent=self.parent,
                                 flags=gtk.DIALOG_MODAL
                                 | gtk.DIALOG_DESTROY_WITH_PARENT
                                 | gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_has_separator(True)
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.connect("key-press-event", self.event_show_button_ok)
        self.tooltips = common.Tooltips()
        self.dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL)
        self.button_ok = gtk.Button(button_ok_text)
        self.button_ok.set_flags(gtk.CAN_DEFAULT)
        self.button_ok.set_flags(gtk.HAS_DEFAULT)
        self.button_ok.set_sensitive(False)
        img_connect = gtk.Image()
        img_connect.set_from_stock(button_ok_icon, gtk.ICON_SIZE_BUTTON)
        self.button_ok.set_image(img_connect)
        self.tooltips.set_tip(self.button_ok, button_ok_tooltip)
        self.dialog.add_action_widget(self.button_ok, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        self.dialog_vbox = gtk.VBox()

        table = gtk.Table(5, 3, False)
        table.set_border_width(10)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        self.dialog_vbox.pack_start(table, True, False, 0)

        label_subtitle = gtk.Label()
        label_subtitle.set_markup("<b>" + label_subtitle_text + "</b>")
        label_subtitle.set_justify(gtk.JUSTIFY_LEFT)
        label_subtitle.set_alignment(0, 1)
        label_subtitle.set_padding(9, 5)
        table.attach(label_subtitle,
                     0,
                     3,
                     0,
                     1,
                     yoptions=False,
                     xoptions=gtk.FILL)

        hseparator = gtk.HSeparator()
        table.attach(hseparator, 0, 3, 1, 2, yoptions=False)

        self.label_server = gtk.Label(_("Server Connection:"))
        self.label_server.set_alignment(1, 0.5)
        self.label_server.set_padding(3, 3)
        table.attach(self.label_server,
                     0,
                     1,
                     2,
                     3,
                     yoptions=False,
                     xoptions=gtk.FILL)

        self.entry_server_connection = gtk.Entry()
        self.entry_server_connection.set_sensitive(False)
        self.entry_server_connection.unset_flags(gtk.CAN_FOCUS)
        self.entry_server_connection.set_editable(False)
        self.tooltips.set_tip(
            self.entry_server_connection,
            _("This is the "
              "URL of the server. Use server 'localhost' and port '8000' "
              "if the server is installed on this computer. "
              "Click on 'Change' to change the address."))
        table.attach(self.entry_server_connection,
                     1,
                     2,
                     2,
                     3,
                     yoptions=gtk.FILL)

        self.button_server_change = gtk.Button(_("C_hange"),
                                               stock=None,
                                               use_underline=True)
        img_button_server_change = gtk.Image()
        img_button_server_change.set_from_stock('tryton-preferences-system',
                                                gtk.ICON_SIZE_BUTTON)
        self.button_server_change.set_image(img_button_server_change)
        table.attach(self.button_server_change, 2, 3, 2, 3, yoptions=False)

        self.label_database = gtk.Label()
        self.label_database.set_text(_("Database:"))
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        table.attach(self.label_database,
                     0,
                     1,
                     3,
                     4,
                     yoptions=False,
                     xoptions=gtk.FILL)

        vbox_combo = gtk.VBox(homogeneous=True)
        self.combo_database = gtk.ComboBox()
        dbstore = gtk.ListStore(gobject.TYPE_STRING)
        cell = gtk.CellRendererText()
        self.combo_database.pack_start(cell, True)
        self.combo_database.add_attribute(cell, 'text', 0)
        self.combo_database.set_model(dbstore)
        self.db_progressbar = gtk.ProgressBar()
        self.combo_database_label = gtk.Label()
        self.combo_database_label.set_use_markup(True)
        self.combo_database_label.set_alignment(0, 1)
        self.combo_database_entry = gtk.Entry()
        vbox_combo.pack_start(self.combo_database)
        vbox_combo.pack_start(self.combo_database_label)
        vbox_combo.pack_start(self.db_progressbar)
        vbox_combo.pack_start(self.combo_database_entry)
        width, height = 0, 0
        # Compute size_request of box in order to prevent "form jumping"
        for child in vbox_combo.get_children():
            cwidth, cheight = child.size_request()
            width, height = max(width, cwidth), max(height, cheight)
        vbox_combo.set_size_request(width, height)
        table.attach(vbox_combo, 1, 3, 3, 4, yoptions=False)

        self.label_serverpasswd = gtk.Label(_("Tryton Server Password:"******"This is the "
              "password of the Tryton server. It doesn't belong to a "
              "real user. This password is usually defined in the trytond "
              "configuration."))
        table.attach(self.entry_serverpasswd, 1, 3, 4, 5, yoptions=False)

        self.entry_serverpasswd.grab_focus()
        self.dialog.vbox.pack_start(self.dialog_vbox)
    def run(self):
        parent = common.get_toplevel_window()
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        self.dialog.set_transient_for(parent)
        self.dialog.show_all()

        pass_widget = self.entry_serverpasswd
        change_button = self.button_server_change
        admin_passwd = self.entry_adminpasswd
        admin_passwd2 = self.entry_adminpasswd2
        change_button.connect_after('clicked', self.server_change)

        if self.host and self.port:
            url = '%s:%d' % (self.host, self.port)
        else:
            url = ''
        self.entry_server_connection.set_text(url)

        liststore = gtk.ListStore(str, str)
        self.combo_language.set_model(liststore)
        try:
            common.refresh_langlist(self.combo_language, self.host, self.port)
        except TrytonServerError:
            self.button_create.set_sensitive(False)

        while True:
            res = self.dialog.run()
            dbname = self.entry_dbname.get_text()
            url = self.entry_server_connection.get_text()
            url_m = re.match('^([\w.\-]+):(\d{1,5})', \
                url or '')
            langidx = self.combo_language.get_active_iter()
            langreal = langidx \
                and self.combo_language.get_model().get_value(langidx, 1)
            passwd = pass_widget.get_text()
            if res == gtk.RESPONSE_OK:
                if (not dbname) \
                    or (not re.match('^[a-zA-Z0-9_]+$', dbname)):
                    common.warning(_('The database name is restricted to ' \
                        'alpha-nummerical characters and "_" (underscore). ' \
                        'Avoid all accents, space ' \
                        'and any other special characters.'),
                        _('Wrong characters in database name!'))
                    continue
                elif admin_passwd.get_text() != admin_passwd2.get_text():
                    common.warning(
                        _("The new admin password " \
                              "doesn't match the confirmation field.\n"),
                        _("Passwords doesn't match!"))
                    continue
                elif not admin_passwd.get_text():
                    common.warning(_("Admin password and confirmation are " \
                        "required to create a new database."), \
                        _('Missing admin password!'))
                    continue
                elif url_m.group(1) \
                        and int(url_m.group(2)) \
                        and dbname \
                        and langreal \
                        and passwd \
                        and admin_passwd.get_text():
                    try:
                        exist = rpc.db_exec(url_m.group(1),
                                int(url_m.group(2)), 'db_exist', dbname)
                    except TrytonServerError, exception:
                        common.process_exception(exception)
                        continue
                    if exist:
                        common.warning(_("A database with the same name "
                                "already exists.\n"
                                "Try another database name."),
                            _("This database name already exist!"))
                        self.entry_dbname.set_text("")
                        self.entry_dbname.grab_focus()
                        continue
                    else:  # Everything runs fine, break the block here
                        host = url_m.group(1)
                        port = url_m.group(2)
                        try:
                            rpcprogress = common.RPCProgress('db_exec',
                                    (host, int(port), 'create', dbname, passwd,
                                        langreal, admin_passwd.get_text()))
                            rpcprogress.run(False)
                        except TrytonServerError, exception:
                            if str(exception.faultCode) == "AccessDenied":
                                common.warning(_("Sorry, wrong password for " \
                                    "the Tryton server. Please try again."),
                                    _("Access denied!"))
                                self.entry_serverpasswd.set_text("")
                                self.entry_serverpasswd.grab_focus()
                                continue
                            else:  # Unclassified error
                                common.warning(_("Can't create the "
                                    "database, caused by an unknown reason.\n"
                                    "If there is a database created, it could "
                                    "be broken. Maybe drop this database! "
                                    "Please check the error message for "
                                    "possible informations.\n"
                                    "Error message:\n")
                                    + str(exception.faultCode),
                                    _("Error creating database!"))
                            parent.present()
                            self.dialog.destroy()
                            rpc.logout()
                            from tryton.gui.main import Main
                            Main.get_main().refresh_ssl()
                            break
                        from tryton.gui.main import Main
                        Main.get_main().refresh_ssl()
                        parent.present()
                        self.dialog.destroy()
                        if self.sig_login:
                            CONFIG['login.server'] = host
                            CONFIG['login.port'] = port
                            CONFIG['login.db'] = dbname
                            CONFIG['login.login'] = '******'
                            self.sig_login()
                        break
示例#49
0
    def __init__(self):
        # GTK Stuffs
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_('Login'), parent=self.parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_has_separator(True)
        self.dialog.set_icon(TRYTON_ICON)

        tooltips = common.Tooltips()
        button_cancel = gtk.Button(_('_Cancel'))
        img_cancel = gtk.Image()
        img_cancel.set_from_stock('gtk-cancel', gtk.ICON_SIZE_BUTTON)
        button_cancel.set_image(img_cancel)
        tooltips.set_tip(button_cancel,
            _('Cancel connection to the Tryton server'))
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        self.button_connect = gtk.Button(_('C_onnect'))
        img_connect = gtk.Image()
        img_connect.set_from_stock('tryton-connect', gtk.ICON_SIZE_BUTTON)
        self.button_connect.set_image(img_connect)
        self.button_connect.set_flags(gtk.CAN_DEFAULT)
        tooltips.set_tip(self.button_connect, _('Connect the Tryton server'))
        self.dialog.add_action_widget(self.button_connect, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        alignment = gtk.Alignment(yalign=0, yscale=0, xscale=1)
        self.table_main = gtk.Table(3, 3, False)
        self.table_main.set_border_width(0)
        self.table_main.set_row_spacings(3)
        self.table_main.set_col_spacings(3)
        alignment.add(self.table_main)
        self.dialog.vbox.pack_start(alignment, True, True, 0)

        image = gtk.Image()
        image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        image.set_alignment(0.5, 1)
        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019"))
        ebox.add(image)
        self.table_main.attach(ebox, 0, 3, 0, 1, ypadding=2)

        self.profile_store = gtk.ListStore(gobject.TYPE_STRING,
            gobject.TYPE_BOOLEAN)
        self.combo_profile = gtk.ComboBox()
        cell = gtk.CellRendererText()
        self.combo_profile.pack_start(cell, True)
        self.combo_profile.add_attribute(cell, 'text', 0)
        self.combo_profile.add_attribute(cell, 'sensitive', 1)
        self.combo_profile.set_model(self.profile_store)
        self.combo_profile.connect('changed', self.profile_changed)
        self.profile_label = gtk.Label(_(u'Profile:'))
        self.profile_label.set_justify(gtk.JUSTIFY_RIGHT)
        self.profile_label.set_alignment(1, 0.5)
        self.profile_label.set_padding(3, 3)
        self.profile_button = gtk.Button(_('_Manage profiles'))
        self.profile_button.connect('clicked', self.profile_manage)
        self.table_main.attach(self.profile_label, 0, 1, 1, 2,
            xoptions=gtk.FILL)
        self.table_main.attach(self.combo_profile, 1, 2, 1, 2)
        self.table_main.attach(self.profile_button, 2, 3, 1, 2,
            xoptions=gtk.FILL)
        image = gtk.Image()
        image.set_from_stock('gtk-edit', gtk.ICON_SIZE_BUTTON)
        self.profile_button.set_image(image)
        self.expander = gtk.Expander(_('Host / Database information'))
        self.expander.connect('notify::expanded', self.expand_hostspec)
        self.table_main.attach(self.expander, 0, 3, 3, 4)
        self.label_host = gtk.Label(_('Host:'))
        self.label_host.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_host.set_alignment(1, 0.5)
        self.label_host.set_padding(3, 3)
        self.entry_host = gtk.Entry()
        self.entry_host.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_host.set_activates_default(True)
        self.label_host.set_mnemonic_widget(self.entry_host)
        self.table_main.attach(self.label_host, 0, 1, 4, 5, xoptions=gtk.FILL)
        self.table_main.attach(self.entry_host, 1, 3, 4, 5)
        self.label_database = gtk.Label(_('Database:'))
        self.label_database.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        self.entry_database = gtk.Entry()
        self.entry_database.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_database.set_activates_default(True)
        self.label_database.set_mnemonic_widget(self.entry_database)
        self.table_main.attach(self.label_database, 0, 1, 5, 6,
            xoptions=gtk.FILL)
        self.table_main.attach(self.entry_database, 1, 3, 5, 6)
        self.entry_password = gtk.Entry()
        self.entry_password.set_visibility(False)
        self.entry_password.set_activates_default(True)
        self.table_main.attach(self.entry_password, 1, 3, 7, 8)
        self.entry_login = gtk.Entry()
        self.entry_login.set_activates_default(True)
        self.table_main.attach(self.entry_login, 1, 3, 6, 7)
        label_password = gtk.Label(str=_("Password:"******"User name:"))
        label_username.set_alignment(1, 0.5)
        label_username.set_padding(3, 3)
        label_username.set_mnemonic_widget(self.entry_login)
        self.table_main.attach(label_username, 0, 1, 6, 7, xoptions=gtk.FILL)

        # Date stuff
        if CONFIG['login.date']:
            self.label_date = gtk.Label(str=_('Date:'))
            self.label_date.set_justify(gtk.JUSTIFY_RIGHT)
            self.label_date.set_alignment(1, .5)
            self.label_date.set_padding(3, 3)
            self.table_main.attach(self.label_date, 0, 1, 8, 9,
                xoptions=gtk.FILL)
            self.date_entry = Date()
            self.date_entry.props.format = '%d/%m/%Y'
            self.date_entry.props.value = datetime.date.today()
            self.table_main.attach(self.date_entry, 1, 3, 8, 9)

        # Profile informations
        self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg')
        self.profiles = ConfigParser.SafeConfigParser({'port': '8000'})
        if not os.path.exists(self.profile_cfg) and False:
            short_version = '.'.join(__version__.split('.', 2)[:2])
            name = 'demo%s.tryton.org' % short_version
            self.profiles.add_section(name)
            self.profiles.set(name, 'host', name)
            self.profiles.set(name, 'port', '8000')
            self.profiles.set(name, 'database', 'demo%s' % short_version)
            self.profiles.set(name, 'username', 'demo')
        else:
            self.profiles.read(self.profile_cfg)
        for section in self.profiles.sections():
            active = all(self.profiles.has_option(section, option)
                for option in ('host', 'port', 'database'))
            self.profile_store.append([section, active])
示例#50
0
    def __init__(self, filename=None):
        """
        Database restore widget
        """
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_("Restore Database"),
                                 parent=self.parent,
                                 flags=gtk.DIALOG_MODAL
                                 | gtk.WIN_POS_CENTER_ON_PARENT)
        vbox = gtk.VBox()
        self.dialog.vbox.pack_start(vbox)
        self.tooltips = common.Tooltips()
        table = gtk.Table(6, 3, False)
        table.set_border_width(9)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        vbox.pack_start(table)
        self.label_server_url = gtk.Label(_("Server Connection:"))
        self.label_server_url.set_size_request(117, -1)
        self.label_server_url.set_alignment(1, 0.5)
        self.label_server_url.set_padding(3, 3)
        table.attach(self.label_server_url, 0, 1, 0, 1, yoptions=gtk.FILL)
        self.entry_server_url = gtk.Entry()
        self.entry_server_url.set_sensitive(False)
        self.entry_server_url.unset_flags(gtk.CAN_FOCUS)
        self.entry_server_url.set_editable(False)
        self.entry_server_url.set_activates_default(True)
        self.entry_server_url.set_width_chars(16)
        self.label_server_url.set_mnemonic_widget(self.entry_server_url)
        self.tooltips.set_tip(
            self.entry_server_url,
            _("This is the URL of "
              "the server. Use server 'localhost' and port '8000' if "
              "the server is installed on this computer. Click on "
              "'Change' to change the address."))
        table.attach(self.entry_server_url, 1, 2, 0, 1, yoptions=gtk.FILL)
        self.button_server_change = gtk.Button(_("C_hange"),
                                               stock=None,
                                               use_underline=True)
        img_button_server_change = gtk.Image()
        img_button_server_change.set_from_stock('tryton-preferences-system',
                                                gtk.ICON_SIZE_BUTTON)
        self.button_server_change.set_image(img_button_server_change)
        self.tooltips.set_tip(self.button_server_change,
                              _("Setup the "
                                "server connection..."))
        table.attach(self.button_server_change, 2, 3, 0, 1, yoptions=gtk.FILL)
        self.label_server_password = gtk.Label(_("Tryton Server Password:"******"This is the "
              "password of the Tryton server. It doesn't belong to a "
              "real user. This password is usually defined in the trytond "
              "configuration."))
        table.attach(self.entry_server_password, 1, 3, 1, 2, yoptions=gtk.FILL)
        self.hseparator = gtk.HSeparator()
        table.attach(self.hseparator, 0, 3, 2, 3, yoptions=gtk.FILL)
        label_filename = gtk.Label()
        label_filename.set_markup(_("File to Restore:"))
        label_filename.set_alignment(1, 0.5)
        table.attach(label_filename, 0, 1, 3, 4, yoptions=gtk.FILL)
        entry_filename = gtk.Label()
        entry_filename.set_markup("<tt>" + filename + "</tt>")
        table.attach(entry_filename, 1, 3, 3, 4, yoptions=gtk.FILL)
        self.entry_db_name = gtk.Entry()
        self.entry_db_name.set_visibility(True)
        self.entry_db_name.set_activates_default(True)
        self.entry_db_name.set_width_chars(16)
        self.entry_db_name.set_max_length(63)
        handlerid = self.entry_db_name.connect("insert-text",
                                               self.entry_insert_text)
        self.entry_db_name.set_data('handlerid', handlerid)
        self.tooltips.set_tip(
            self.entry_db_name,
            _("Choose the name of "
              "the database to be restored.\n"
              "Allowed characters are alphanumerical or _ (underscore)\n"
              "You need to avoid all accents, space or special "
              "characters! \nExample: tryton"))
        table.attach(self.entry_db_name, 1, 3, 4, 5, yoptions=gtk.FILL)
        label_db_name = gtk.Label(_("New Database Name:"))
        label_db_name.set_alignment(1, 0.5)
        label_db_name.set_mnemonic_widget(self.entry_db_name)
        table.attach(label_db_name, 0, 1, 4, 5, yoptions=gtk.FILL)
        label_db_update = gtk.Label(_('Update Database:'))
        label_db_update.set_alignment(1, 0.5)
        table.attach(label_db_update, 0, 1, 5, 6, yoptions=gtk.FILL)
        self.check_update = gtk.CheckButton()
        label_db_update.set_mnemonic_widget(self.check_update)
        self.tooltips.set_tip(
            self.check_update,
            _('Check for an automatic '
              'database update after restoring a database from a previous '
              'Tryton version.'))
        self.check_update.set_active(True)
        table.attach(self.check_update, 1, 3, 5, 6, yoptions=gtk.FILL)
        # Buttons and events
        self.dialog.connect("key-press-event", self.event_show_button_restore)
        self.dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL)
        self.button_restore = gtk.Button(_('Restore'))
        self.button_restore.set_flags(gtk.CAN_DEFAULT)
        self.button_restore.set_flags(gtk.HAS_DEFAULT)
        self.button_restore.set_sensitive(False)
        img_restore = gtk.Image()
        img_restore.set_from_stock('tryton-folder-saved-search',
                                   gtk.ICON_SIZE_BUTTON)
        self.button_restore.set_image(img_restore)
        self.tooltips.set_tip(self.button_restore,
                              _('Restore the database from file.'))
        self.dialog.add_action_widget(self.button_restore, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)

        self.entry_server_password.grab_focus()
示例#51
0
文件: tips.py 项目: solutema/tryton
    def __init__(self):
        self.tips = [
            _('''<b>Welcome to Tryton</b>


'''),
            _(u'''<b>Do you know Triton, one of the namesakes for our project?</b>

Triton (pronounced /ˈtraɪtən/ TRYE-tən, or as in Greek Τρίτων) is the
largest moon of the planet Neptune, discovered on October 10, 1846
by William Lassell. It is the only large moon in the Solar System
with a retrograde orbit, which is an orbit in the opposite direction
to its planet's rotation. At 2,700 km in diameter, it is the seventh-largest
moon in the Solar System. Triton comprises more than 99.5 percent of all
the mass known to orbit Neptune, including the planet's rings and twelve
other known moons. It is also more massive than all the Solar System's
159 known smaller moons combined.
'''),
            _('''<b>Export list records</b>

You can copy records from any list with Ctrl + C
and paste in any application with Ctrl + V
'''),
            _('''<b>Export graphs</b>

You can save any graphs in PNG file with right-click on it.
'''),
        ]

        parent = get_toplevel_window()
        self.win = gtk.Dialog(
            _('Tips'), parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_has_separator(True)
        self.win.set_default_size(500, 400)

        self.win.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        self.win.set_default_response(gtk.RESPONSE_CLOSE)
        vbox = gtk.VBox()
        img = gtk.Image()
        img.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        vbox.pack_start(img, False, False)
        self.label = gtk.Label()
        self.label.set_alignment(0, 0)
        vbox.pack_start(self.label, True, True)
        separator = gtk.HSeparator()
        vbox.pack_start(separator, False, False)

        hbox = gtk.HBox()
        self.check = gtk.CheckButton(_('_Display a new tip next time'), True)
        self.check.set_active(True)
        hbox.pack_start(self.check)
        but_previous = gtk.Button()
        hbox_previous = gtk.HBox()
        img_previous = gtk.Image()
        img_previous.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_BUTTON)
        hbox_previous.pack_start(img_previous)
        label_previous = gtk.Label(_('Previous'))
        hbox_previous.pack_start(label_previous)
        but_previous.add(hbox_previous)
        but_previous.set_relief(gtk.RELIEF_NONE)
        but_previous.connect('clicked', self.tip_previous)
        hbox.pack_start(but_previous)
        hbox_next = gtk.HBox()
        label_next = gtk.Label(_('Next'))
        hbox_next.pack_start(label_next)
        but_next = gtk.Button()
        img_next = gtk.Image()
        img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_BUTTON)
        hbox_next.pack_start(img_next)
        but_next.add(hbox_next)
        but_next.set_relief(gtk.RELIEF_NONE)
        but_next.connect('clicked', self.tip_next)
        hbox.pack_start(but_next)
        vbox.pack_start(hbox, False, False)
        self.win.vbox.pack_start(vbox)
        self.win.show_all()

        try:
            self.number = int(CONFIG['tip.position'])
        except ValueError:
            self.number = 0

        self.tip_set()

        self.win.run()
        CONFIG['tip.autostart'] = self.check.get_active()
        CONFIG['tip.position'] = self.number + 1
        CONFIG.save()
        parent.present()
        self.win.destroy()
    def __init__(self, model, ids, context=None):
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_("Export to CSV"), parent=self.parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT |
            gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)

        vbox = gtk.VBox()
        frame_predef_exports = gtk.Frame()
        frame_predef_exports.set_border_width(2)
        frame_predef_exports.set_shadow_type(gtk.SHADOW_NONE)
        vbox.pack_start(frame_predef_exports, True, True, 0)
        viewport_exports = gtk.Viewport()
        scrolledwindow_exports = gtk.ScrolledWindow()
        scrolledwindow_exports.set_policy(gtk.POLICY_AUTOMATIC,
                gtk.POLICY_AUTOMATIC)
        label_predef_exports = gtk.Label(_("<b>Predefined exports</b>"))
        label_predef_exports.set_use_markup(True)
        frame_predef_exports.set_label_widget(label_predef_exports)
        viewport_exports.add(scrolledwindow_exports)
        frame_predef_exports.add(viewport_exports)

        hbox = gtk.HBox(True)
        vbox.pack_start(hbox, True, True, 0)

        frame_all_fields = gtk.Frame()
        frame_all_fields.set_shadow_type(gtk.SHADOW_NONE)
        hbox.pack_start(frame_all_fields, True, True, 0)
        label_all_fields = gtk.Label(_("<b>All fields</b>"))
        label_all_fields.set_use_markup(True)
        frame_all_fields.set_label_widget(label_all_fields)
        viewport_all_fields = gtk.Viewport()
        scrolledwindow_all_fields = gtk.ScrolledWindow()
        scrolledwindow_all_fields.set_policy(gtk.POLICY_AUTOMATIC,
                gtk.POLICY_AUTOMATIC)
        viewport_all_fields.add(scrolledwindow_all_fields)
        frame_all_fields.add(viewport_all_fields)

        vbox_buttons = gtk.VBox(False, 10)
        vbox_buttons.set_border_width(5)
        hbox.pack_start(vbox_buttons, False, True, 0)

        button_select = gtk.Button(_("_Add"), stock=None, use_underline=True)
        button_select.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-list-add', gtk.ICON_SIZE_BUTTON)
        button_select.set_image(img_button)
        button_select.connect_after('clicked',  self.sig_sel)
        vbox_buttons.pack_start(button_select, False, False, 0)

        button_unselect = gtk.Button(_("_Remove"), stock=None,
                use_underline=True)
        button_unselect.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_BUTTON)
        button_unselect.set_image(img_button)
        button_unselect.connect_after('clicked',  self.sig_unsel)
        vbox_buttons.pack_start(button_unselect, False, False, 0)

        button_unselect_all = gtk.Button(_("Clear"), stock=None,
                use_underline=True)
        button_unselect_all.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-clear', gtk.ICON_SIZE_BUTTON)
        button_unselect_all.set_image(img_button)
        button_unselect_all.connect_after('clicked',  self.sig_unsel_all)
        vbox_buttons.pack_start(button_unselect_all, False, False, 0)

        hseparator_buttons = gtk.HSeparator()
        vbox_buttons.pack_start(hseparator_buttons, False, True, 0)

        button_save_export = gtk.Button(_("Save Export"), stock=None,
                use_underline=True)
        button_save_export.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-save', gtk.ICON_SIZE_BUTTON)
        button_save_export.set_image(img_button)
        button_save_export.connect_after('clicked',  self.add_predef)
        vbox_buttons.pack_start(button_save_export, False, False, 0)

        button_del_export = gtk.Button(_("Delete Export"), stock=None,
                use_underline=True)
        button_del_export.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-delete', gtk.ICON_SIZE_BUTTON)
        button_del_export.set_image(img_button)
        button_del_export.connect_after('clicked',  self.remove_predef)
        vbox_buttons.pack_start(button_del_export, False, False, 0)

        frame_export = gtk.Frame()
        frame_export.set_shadow_type(gtk.SHADOW_NONE)
        label_export = gtk.Label(_("<b>Fields to export</b>"))
        label_export.set_use_markup(True)
        frame_export.set_label_widget(label_export)

        alignment_export = gtk.Alignment(0.5, 0.5, 1, 1)
        alignment_export.set_padding(0, 0, 12, 0)
        frame_export.add(alignment_export)
        viewport_fields_to_export = gtk.Viewport()
        scrolledwindow_export = gtk.ScrolledWindow()
        scrolledwindow_export.set_policy(gtk.POLICY_AUTOMATIC,
                gtk.POLICY_AUTOMATIC)
        viewport_fields_to_export.add(scrolledwindow_export)
        alignment_export.add(viewport_fields_to_export)
        hbox.pack_start(frame_export, True, True, 0)

        frame_options = gtk.Frame()
        frame_options.set_border_width(2)
        label_options = gtk.Label(_("<b>Options</b>"))
        label_options.set_use_markup(True)
        frame_options.set_label_widget(label_options)
        vbox.pack_start(frame_options, False, True, 5)
        hbox_options = gtk.HBox(False, 2)
        frame_options.add(hbox_options)
        hbox_options.set_border_width(2)

        combo_saveas = gtk.combo_box_new_text()
        hbox_options.pack_start(combo_saveas, True, True, 0)
        combo_saveas.append_text(_("Open"))
        combo_saveas.append_text(_("Save"))
        vseparator_options = gtk.VSeparator()
        hbox_options.pack_start(vseparator_options, False, False, 10)

        checkbox_add_field_names = gtk.CheckButton(_("Add _field names"))
        checkbox_add_field_names.set_active(True)
        hbox_options.pack_start(checkbox_add_field_names, False, False, 0)

        button_cancel = gtk.Button("gtk-cancel", stock="gtk-cancel")
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        button_ok = gtk.Button("gtk-ok", stock="gtk-ok")
        self.dialog.add_action_widget(button_ok, gtk.RESPONSE_OK)
        button_ok.set_flags(gtk.CAN_DEFAULT)

        self.dialog.vbox.pack_start(vbox)
        self.dialog.show_all()

        self.ids = ids
        self.model = model
        self.fields_data = {}
        self.context = context

        self.view1 = gtk.TreeView()
        self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.view1.connect('row-expanded', self.on_row_expanded)
        scrolledwindow_all_fields.add(self.view1)
        self.view2 = gtk.TreeView()
        self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        scrolledwindow_export.add(self.view2)
        self.view1.set_headers_visible(False)
        self.view2.set_headers_visible(False)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn('Field name', cell, text=0,
                background=2)
        self.view1.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn('Field name', cell, text=0)
        self.view2.append_column(column)

        self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                gobject.TYPE_STRING)
        self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

        self.fields = {}

        self.model_populate(self._get_fields(model))

        self.view1.set_model(self.model1)
        self.view2.set_model(self.model2)
        self.view1.show_all()
        self.view2.show_all()

        self.wid_action = combo_saveas
        self.wid_write_field_names = checkbox_add_field_names
        self.wid_action.set_active(0)

        # Creating the predefined export view
        self.pref_export = gtk.TreeView()
        self.pref_export.append_column(gtk.TreeViewColumn(_('Name'),
            gtk.CellRendererText(), text=2))
        scrolledwindow_exports.add(self.pref_export)

        self.pref_export.connect("row-activated", self.sel_predef)

        # Fill the predefined export tree view and show everything
        self.predef_model = gtk.ListStore(
                gobject.TYPE_INT,
                gobject.TYPE_PYOBJECT,
                gobject.TYPE_STRING)
        self.fill_predefwin()
        self.pref_export.show_all()
示例#53
0
    def __init__(self):
        self.parent = get_toplevel_window()
        self.dialog = gtk.Dialog(
            _('Keyboard Shortcuts'), self.parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
            | gtk.WIN_POS_CENTER_ON_PARENT | gtk.gdk.WINDOW_TYPE_HINT_DIALOG,
            (gtk.STOCK_OK, gtk.RESPONSE_OK))
        self.dialog.set_icon(GNUHEALTH_ICON)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        notebook = gtk.Notebook()
        self.dialog.vbox.pack_start(notebook)

        shortcuts = [
            (_('Text Entries Shortcuts'), ),
            ('<Ctrl> + X', _('Cut selected text')),
            ('<Ctrl> + C', _('Copy selected text')),
            ('<Ctrl> + V', _('Paste copied text')),
            ('<Tab>', _('Next widget')),
            ('<Shift> + <Tab>', _('Previous widget')),
            (_('Relation Entries Shortcuts'), ),
            ('<F3>', _('Create new relation')),
            ('<F2>', _('Open/Search relation')),
            (_('List Entries Shortcuts'), ),
            ('<F3>', _('Create new line')),
            ('<F2>', _('Open relation')),
            ('<Del>', _('Mark line for deletion')),
            ('<Ins>', _('Unmark line for deletion')),
        ]
        notebook.append_page(self._fill_table(shortcuts),
                             gtk.Label(_('Edition Widgets')))

        shortcuts = [
            (_('Move Cursor'), ),
            ('<Right>', _('Move to right')),
            ('<Left>', _('Move to left')),
            ('<Up>', _('Move up')),
            ('<Down>', _('Move down')),
            ('<Page Up>', _('Move up of one page')),
            ('<Page Down>', _('Move down of one page')),
            ('<Home>', _('Move to top')),
            ('<End>', _('Move to bottom')),
            ('<Backspace>', _('Move to parent')),
            (_('Selection'), ),
            ('<Ctrl> + a', _('Select all')),
            ('<Ctrl> + /', _('Select all')),
            ('<Shift> + <Ctrl> + a', _('Unselect all')),
            ('<Shift> + <Ctrl> + /', _('Unselect all')),
            ('<Backspace>', _('Select parent')),
            ('<Space>', _('Select/Activate current row')),
            ('<Shift> + <Space>', _('Select/Activate current row')),
            ('<Return>', _('Select/Activate current row')),
            ('<Enter>', _('Select/Activate current row')),
            ('<Ctrl> + <Space>', _('Toggle selection')),
            (_('Expand/Collapse'), ),
            ('+', _('Expand row')),
            ('-', _('Collapse row')),
            ('<Space>', _('Toggle row')),
            ('<Shift> + <Left>', _('Collapse all rows')),
            ('<Shift> + <Right>', _('Expand all rows')),
        ]
        notebook.append_page(self._fill_table(shortcuts),
                             gtk.Label(_('Tree view')))

        self.dialog.show_all()
示例#54
0
文件: tips.py 项目: coopengo/tryton
    def __init__(self):
        self.tips = [
            _('''<b>Welcome to Tryton</b>


'''),
            _(u'''<b>Do you know Triton, one of the namesakes for our project?</b>

Triton (pronounced /ˈtraɪtən/ TRYE-tən, or as in Greek Τρίτων) is the
largest moon of the planet Neptune, discovered on October 10, 1846
by William Lassell. It is the only large moon in the Solar System
with a retrograde orbit, which is an orbit in the opposite direction
to its planet's rotation. At 2,700 km in diameter, it is the seventh-largest
moon in the Solar System. Triton comprises more than 99.5 percent of all
the mass known to orbit Neptune, including the planet's rings and twelve
other known moons. It is also more massive than all the Solar System's
159 known smaller moons combined.
'''),
            _('''<b>Export list records</b>

You can copy records from any list with Ctrl + C
and paste in any application with Ctrl + V
'''),
            _('''<b>Export graphs</b>

You can save any graphs in PNG file with right-click on it.
'''),
        ]

        parent = get_toplevel_window()
        self.win = gtk.Dialog(_('Tips'), parent,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_has_separator(True)
        self.win.set_default_size(500, 400)

        self.win.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        self.win.set_default_response(gtk.RESPONSE_CLOSE)
        vbox = gtk.VBox()
        img = gtk.Image()
        img.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        vbox.pack_start(img, False, False)
        self.label = gtk.Label()
        self.label.set_alignment(0, 0)
        vbox.pack_start(self.label, True, True)
        separator = gtk.HSeparator()
        vbox.pack_start(separator, False, False)

        hbox = gtk.HBox()
        self.check = gtk.CheckButton(_('_Display a new tip next time'), True)
        self.check.set_active(True)
        hbox.pack_start(self.check)
        but_previous = gtk.Button()
        hbox_previous = gtk.HBox()
        img_previous = gtk.Image()
        img_previous.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_BUTTON)
        hbox_previous.pack_start(img_previous)
        label_previous = gtk.Label(_('Previous'))
        hbox_previous.pack_start(label_previous)
        but_previous.add(hbox_previous)
        but_previous.set_relief(gtk.RELIEF_NONE)
        but_previous.connect('clicked', self.tip_previous)
        hbox.pack_start(but_previous)
        hbox_next = gtk.HBox()
        label_next = gtk.Label(_('Next'))
        hbox_next.pack_start(label_next)
        but_next = gtk.Button()
        img_next = gtk.Image()
        img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_BUTTON)
        hbox_next.pack_start(img_next)
        but_next.add(hbox_next)
        but_next.set_relief(gtk.RELIEF_NONE)
        but_next.connect('clicked', self.tip_next)
        hbox.pack_start(but_next)
        vbox.pack_start(hbox, False, False)
        self.win.vbox.pack_start(vbox)
        self.win.show_all()

        try:
            self.number = int(CONFIG['tip.position'])
        except ValueError:
            self.number = 0

        self.tip_set()

        self.win.run()
        CONFIG['tip.autostart'] = self.check.get_active()
        CONFIG['tip.position'] = self.number + 1
        CONFIG.save()
        parent.present()
        self.win.destroy()
示例#55
0
    def __init__(self, filename=None):
        """
        Database restore widget
        """
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_("Restore Database"),
            parent=self.parent, flags=gtk.DIALOG_MODAL
            | gtk.WIN_POS_CENTER_ON_PARENT)
        vbox = gtk.VBox()
        self.dialog.vbox.pack_start(vbox)
        self.tooltips = common.Tooltips()
        table = gtk.Table(6, 3, False)
        table.set_border_width(9)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        vbox.pack_start(table)
        self.label_server_url = gtk.Label(_("Server Connection:"))
        self.label_server_url.set_size_request(117, -1)
        self.label_server_url.set_alignment(1, 0.5)
        self.label_server_url.set_padding(3, 3)
        table.attach(self.label_server_url, 0, 1, 0, 1, yoptions=gtk.FILL)
        self.entry_server_url = gtk.Entry()
        self.entry_server_url.set_sensitive(False)
        self.entry_server_url.unset_flags(gtk.CAN_FOCUS)
        self.entry_server_url.set_editable(False)
        self.entry_server_url.set_activates_default(True)
        self.entry_server_url.set_width_chars(16)
        self.label_server_url.set_mnemonic_widget(self.entry_server_url)
        self.tooltips.set_tip(self.entry_server_url, _("This is the URL of "
                "the server. Use server 'localhost' and port '8000' if "
                "the server is installed on this computer. Click on "
                "'Change' to change the address."))
        table.attach(self.entry_server_url, 1, 2, 0, 1, yoptions=gtk.FILL)
        self.button_server_change = gtk.Button(_("C_hange"), stock=None,
            use_underline=True)
        img_button_server_change = gtk.Image()
        img_button_server_change.set_from_stock(
            'tryton-preferences-system', gtk.ICON_SIZE_BUTTON)
        self.button_server_change.set_image(img_button_server_change)
        self.tooltips.set_tip(self.button_server_change, _("Setup the "
                "server connection..."))
        table.attach(self.button_server_change, 2, 3, 0, 1, yoptions=gtk.FILL)
        self.label_server_password = gtk.Label(_("Tryton Server Password:"******"This is the "
                "password of the Tryton server. It doesn't belong to a "
                "real user. This password is usually defined in the trytond "
                "configuration."))
        table.attach(self.entry_server_password, 1, 3, 1, 2, yoptions=gtk.FILL)
        self.hseparator = gtk.HSeparator()
        table.attach(self.hseparator, 0, 3, 2, 3, yoptions=gtk.FILL)
        label_filename = gtk.Label()
        label_filename.set_markup(_("File to Restore:"))
        label_filename.set_alignment(1, 0.5)
        table.attach(label_filename, 0, 1, 3, 4, yoptions=gtk.FILL)
        entry_filename = gtk.Label()
        entry_filename.set_markup("<tt>" + filename + "</tt>")
        table.attach(entry_filename, 1, 3, 3, 4, yoptions=gtk.FILL)
        self.entry_db_name = gtk.Entry()
        self.entry_db_name.set_visibility(True)
        self.entry_db_name.set_activates_default(True)
        self.entry_db_name.set_width_chars(16)
        self.entry_db_name.set_max_length(63)
        handlerid = self.entry_db_name.connect("insert-text",
            self.entry_insert_text)
        self.entry_db_name.set_data('handlerid', handlerid)
        self.tooltips.set_tip(self.entry_db_name, _("Choose the name of "
                "the database to be restored.\n"
                "Allowed characters are alphanumerical or _ (underscore)\n"
                "You need to avoid all accents, space or special "
                "characters! \nExample: tryton"))
        table.attach(self.entry_db_name, 1, 3, 4, 5, yoptions=gtk.FILL)
        label_db_name = gtk.Label(_("New Database Name:"))
        label_db_name.set_alignment(1, 0.5)
        label_db_name.set_mnemonic_widget(self.entry_db_name)
        table.attach(label_db_name, 0, 1, 4, 5, yoptions=gtk.FILL)
        label_db_update = gtk.Label(_('Update Database:'))
        label_db_update.set_alignment(1, 0.5)
        table.attach(label_db_update, 0, 1, 5, 6, yoptions=gtk.FILL)
        self.check_update = gtk.CheckButton()
        label_db_update.set_mnemonic_widget(self.check_update)
        self.tooltips.set_tip(self.check_update, _('Check for an automatic '
                'database update after restoring a database from a previous '
                'Tryton version.'))
        self.check_update.set_active(True)
        table.attach(self.check_update, 1, 3, 5, 6, yoptions=gtk.FILL)
        # Buttons and events
        self.dialog.connect("key-press-event",
            self.event_show_button_restore)
        self.dialog.add_button("gtk-cancel",
            gtk.RESPONSE_CANCEL)
        self.button_restore = gtk.Button(_('Restore'))
        self.button_restore.set_flags(gtk.CAN_DEFAULT)
        self.button_restore.set_flags(gtk.HAS_DEFAULT)
        self.button_restore.set_sensitive(False)
        img_restore = gtk.Image()
        img_restore.set_from_stock('tryton-folder-saved-search',
            gtk.ICON_SIZE_BUTTON)
        self.button_restore.set_image(img_restore)
        self.tooltips.set_tip(self.button_restore,
            _('Restore the database from file.'))
        self.dialog.add_action_widget(self.button_restore, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)

        self.entry_server_password.grab_focus()