Ejemplo n.º 1
0
def open_import_csv_dialog(path=None):
    """Opens a filechooser dialog to import a csv file"""
    title = _("Import contacts from...")
    chooser_dialog = gtk.FileChooserDialog(title,
                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))

    chooser_dialog.set_default_response(gtk.RESPONSE_OK)

    filter_ = gtk.FileFilter()
    filter_.set_name(_("Csv files"))
    filter_.add_mime_type("text/xml")
    filter_.add_pattern("*csv")
    chooser_dialog.add_filter(filter_)
    filter_ = gtk.FileFilter()
    filter_.set_name(_("All files"))
    filter_.add_pattern("*")
    chooser_dialog.add_filter(filter_)

    if path:
        chooser_dialog.set_filename(os.path.abspath(path))
    if chooser_dialog.run() == gtk.RESPONSE_OK:
        resp = chooser_dialog.get_filename()
    else:
        resp = None

    chooser_dialog.destroy()
    return resp
    def on_search_find_button_clicked(self, widget):
        pattern = self.view['search_entry'].get_text()

        treeview = self.parent_ctrl.view['contacts_treeview']
        model = treeview.get_model()

        contacts = model.find_contacts(pattern)
        if not contacts:
            dialogs.show_warning_dialog(
                _('No contact found'),
                _('No contact with the name %s found') % pattern)
            return

        # get the path
        path = [
            str(i) for i, row in enumerate(model)
            if row[TV_CNT_OBJ] in contacts
        ]
        # unselect
        sel = treeview.get_selection()
        sel.unselect_all()
        for elem in path:
            # and set the new selection
            sel.select_path(elem)

        self.view.hide()
Ejemplo n.º 3
0
    def _setup_support_tabs(self):
        # populate Help tab
        tbuf = gtk.TextBuffer()
        tbuf.set_text(
            _("In most cases you can find the answer to your"
              " questions about the program in the help menu. This menu can be"
              " accessed if you click on the \"Help\" label on the menu bar"
              " located in the top side of the window, and selecting the"
              " \"Help topics\" option."
              "\n\nYou can also find help, updates and tips in %(name)s's web:"
              "\n\n%(url)s."
              "\n\nIf you use the mail and browser buttons to access other"
              " programs in your system, you might need to ask your Systems"
              " Administrator any doubt that you might have.") % {
                  'name': APP_LONG_NAME,
                  'url': APP_URL
              })
        self['support_notebook_help_text'].set_buffer(tbuf)

        # populate Support center tab
        tbuf = gtk.TextBuffer()
        tbuf.set_text(
            _("If you are using this program in a corporate"
              " environment, your company probably has a support center to"
              " solve the questions that you might have about the program."
              "\n\nIf your company does not have a support center, you will have"
              " to contact your company's System Administrator."))
        self['support_notebook_support_text'].set_buffer(tbuf)
Ejemplo n.º 4
0
def open_import_csv_dialog(path=None):
    """Opens a filechooser dialog to import a csv file"""
    title = _("Import contacts from...")
    chooser_dialog = gtk.FileChooserDialog(
        title, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
    )

    chooser_dialog.set_default_response(gtk.RESPONSE_OK)

    filter_ = gtk.FileFilter()
    filter_.set_name(_("Csv files"))
    filter_.add_mime_type("text/xml")
    filter_.add_pattern("*csv")
    chooser_dialog.add_filter(filter_)
    filter_ = gtk.FileFilter()
    filter_.set_name(_("All files"))
    filter_.add_pattern("*")
    chooser_dialog.add_filter(filter_)

    if path:
        chooser_dialog.set_filename(os.path.abspath(path))
    if chooser_dialog.run() == gtk.RESPONSE_OK:
        resp = chooser_dialog.get_filename()
    else:
        resp = None

    chooser_dialog.destroy()
    return resp
Ejemplo n.º 5
0
    def setup_view(self, view):
        if self.model.name:
            self.view['profile_name_entry'].set_text(self.model.name)
        if self.model.username:
            self.view['username_entry'].set_text(self.model.username)
        if self.model.apn:
            self.view['apn_entry'].set_text(self.model.apn)
        if self.model.primary_dns:
            dns1 = convert_int_to_ip(self.model.primary_dns)
            self.view['primary_dns_entry'].set_text(dns1)
        if self.model.secondary_dns:
            dns2 = convert_int_to_ip(self.model.secondary_dns)
            self.view['secondary_dns_entry'].set_text(dns2)

        if self.model.static_dns:
            self.view['static_dns_check'].set_active(self.model.static_dns)
            self.view.enable_static_dns()
        else:
            self.view['static_dns_check'].set_active(False)

        if not self.model.password:

            def load_secrets(secrets):
                self.model.password = secrets['gsm'].get('passwd', '')
                self.view['password_entry'].set_text(self.model.password)

            try:
                self.model.load_password(load_secrets)
            except KeyringNoMatchError, e:
                logger.error("Error while loading connection password: %s" % e)
                title = _("Error while getting connection password")
                details = _("NoMatchError: No password was retrieved "
                            "from connection, please set one again")
                show_error_dialog(title, details)
                return
Ejemplo n.º 6
0
    def submit_voucher(self, voucher):
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False:  # Not a PAYT SIM
            show_warning_dialog(_("PAYT submit voucher"),
                                _("SIM is not on a PAYT plan"))
            return

        def submit_cb(error):
            if not error:
                logger.info("PAYT SIM submit voucher success")
                # ok we established his voucher code is good, let's cause the
                # system to update the UI with his new credit. To do that we
                # need to fire off another request
                self.get_current_sim_credit()
                self.model.payt_submit_busy = False
                self.view.clear_voucher_entry_view()
            else:
                logger.error("PAYT SIM submit voucher failed")
                self.model.payt_submit_busy = False
                show_warning_dialog(
                    _("PAYT submit voucher"),
                    _("PAYT submit voucher failed\n\'%s\'") % error)

        ussd = get_payt_submit_voucher_info(self.model.imsi)
        if ussd:
            self.model.payt_submit_busy = True
            self._submit_voucher_by_ussd(ussd, voucher, submit_cb)
        # elif have payt SMS submit voucher info:
        #    self._submit_voucher_by_sms()
        else:
            show_warning_dialog(_("PAYT submit voucher"),
                                _("No PAYT submit voucher method available"))
Ejemplo n.º 7
0
def get_uptime_string(uptime):
    """Returns a uptime(1)'s like output from a uptime expressed in seconds"""
    time_dict = get_time_dict(uptime)
    try:
        hour = "%d" % time_dict['hour']
    except KeyError:
        hour = "0"

    try:
        minute = "%d" % time_dict['minute']
        if time_dict['minute'] < 10:
            minute = '0' + minute
    except KeyError:
        minute = '00'

    msg = "%s:%s" % (hour, minute)
    try:
        day = time_dict['day']
        if day > 1:
            resp = _("%(day)d days, %(msg)s") % {'day': day, 'msg': msg}
        else:
            resp = _("%(day)d day, %(msg)s") % {'day': day, 'msg': msg}

    except KeyError:
        resp = msg

    return resp
    def submit_voucher(self, voucher):
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False: # Not a PAYT SIM
            show_warning_dialog(_("PAYT submit voucher"),
                                _("SIM is not on a PAYT plan"))
            return

        def submit_cb(error):
            if not error:
                logger.info("PAYT SIM submit voucher success")
                # ok we established his voucher code is good, let's cause the
                # system to update the UI with his new credit. To do that we
                # need to fire off another request
                self.get_current_sim_credit()
                self.model.payt_submit_busy = False
                self.view.clear_voucher_entry_view()
            else:
                logger.error("PAYT SIM submit voucher failed")
                self.model.payt_submit_busy = False
                show_warning_dialog(_("PAYT submit voucher"),
                    _("PAYT submit voucher failed\n\'%s\'") % error)

        ussd = get_payt_submit_voucher_info(self.model.imsi)
        if ussd:
            self.model.payt_submit_busy = True
            self._submit_voucher_by_ussd(ussd, voucher, submit_cb)
        # elif have payt SMS submit voucher info:
        #    self._submit_voucher_by_sms()
        else:
            show_warning_dialog(_("PAYT submit voucher"),
                                _("No PAYT submit voucher method available"))
Ejemplo n.º 9
0
        def set_button():
            if state < GUI_MODEM_STATE_REGISTERED:
                ifile = 'connect.png'
                label = _("Connect")
                enabled = False
            elif state == GUI_MODEM_STATE_REGISTERED:
                ifile = 'connect.png'
                label = _("Connect")
                enabled = True
            elif state == GUI_MODEM_STATE_DISCONNECTING:
                ifile = 'disconnect.png'
                label = _("Disconnecting")
                enabled = False
            elif state == GUI_MODEM_STATE_CONNECTING:
                ifile = 'connect.png'
                label = _("Connecting")
                enabled = False
            elif state == GUI_MODEM_STATE_CONNECTED:
                ifile = 'disconnect.png'
                label = _("Disconnect")
                enabled = True

            obj = self['connect_button']
            if obj:
                image = gtk.Image()
                image.set_from_file(os.path.join(IMAGES_DIR, ifile))
                image.show()
                obj.set_icon_widget(image)
                obj.set_label(label)
                obj.set_sensitive(enabled)
    def set_network_info(self, network=None, country=None):
        if network is None:
            network = _('Unknown')
        self['network_name_label'].set_text(network)

        if country is None:
            country = _('Unknown')
        self['country_name_label'].set_text(country)
    def set_network_info(self, network=None, country=None):
        if network is None:
            network = _('Unknown')
        self['network_name_label'].set_text(network)

        if country is None:
            country = _('Unknown')
        self['country_name_label'].set_text(country)
Ejemplo n.º 12
0
        def smsc_eb(*arg):
            title = _('No SMSC number')
            details = _("In order to send a SMS, %s needs to know the number "
                        "of your provider's SMSC. If you do not know the SMSC "
                        "number, contact your customer "
                        "service.") % APP_LONG_NAME
            dialogs.show_error_dialog(title, details)

            self.state = IDLE
Ejemplo n.º 13
0
 def _init_wader_object(self):
     try:
         self.obj = self.bus.get_object(WADER_SERVICE, WADER_OBJPATH)
     except dbus.DBusException, e:
         title = _("Error while starting wader")
         details = _("Check that your installation is correct and your "
                     " OS/distro is supported: %s" % e)
         show_error_dialog(title, details)
         raise SystemExit()
 def _init_wader_object(self):
     try:
         self.obj = self.bus.get_object(WADER_SERVICE, WADER_OBJPATH)
     except dbus.DBusException, e:
         title = _("Error while starting wader")
         details = _("Check that your installation is correct and your "
                     " OS/distro is supported: %s" % e)
         show_error_dialog(title, details)
         raise SystemExit()
Ejemplo n.º 15
0
        def smsc_eb(*arg):
            title = _('No SMSC number')
            details = _("In order to send a SMS, %s needs to know the number "
                        "of your provider's SMSC. If you do not know the SMSC "
                        "number, contact your customer "
                        "service.") % APP_LONG_NAME
            dialogs.show_error_dialog(title, details)

            self.state = IDLE
Ejemplo n.º 16
0
        def enable_pin_eb(e):
            title = _("Incorrect PIN")
            details = _("""
<small>The PIN you've just entered is
incorrect. Bear in mind that after
three failed PINs you'll be asked
for the PUK code</small>
""")
            show_warning_dialog(title, details)
            self.errback(self.enable)
            self.model.unregister_observer(self)
            self.view.hide()
Ejemplo n.º 17
0
        def enable_pin_eb(e):
            title = _("Incorrect PIN")
            details = _("""
<small>The PIN you've just entered is
incorrect. Bear in mind that after
three failed PINs you'll be asked
for the PUK code</small>
""")
            show_warning_dialog(title, details)
            self.errback(self.enable)
            self.model.unregister_observer(self)
            self.view.hide()
    def __init__(self, parent):
        super(KeyringPasswordDialog, self).__init__(parent,
                _("Unlock keyring"),
                _("The application '%s' wants access to the default "
                  "keyring, but is locked." % APP_NAME))

        pin_panel = get_object(self.tree, 'ask_keyring_password_panel')
        get_object(self.tree, 'ask_keyring_password_window').remove(pin_panel)
        self.vbox.add(pin_panel)

        self.password_entry = get_object(self.tree, 'keyring_password_entry')
        #self.password_entry.get_settings().set_long_property(
        #    "gtk-entry-password-hint-timeout", 600, "")
        add_password_validation(self.password_entry, self.check_ok_conditions)
Ejemplo n.º 19
0
    def __init__(self, parent):
        super(KeyringPasswordDialog, self).__init__(
            parent, _("Unlock keyring"),
            _("The application '%s' wants access to the default "
              "keyring, but is locked." % APP_NAME))

        pin_panel = get_object(self.tree, 'ask_keyring_password_panel')
        get_object(self.tree, 'ask_keyring_password_window').remove(pin_panel)
        self.vbox.add(pin_panel)

        self.password_entry = get_object(self.tree, 'keyring_password_entry')
        #self.password_entry.get_settings().set_long_property(
        #    "gtk-entry-password-hint-timeout", 600, "")
        add_password_validation(self.password_entry, self.check_ok_conditions)
 def submit_cb(error):
     if not error:
         logger.info("PAYT SIM submit voucher success")
         # ok we established his voucher code is good, let's cause the
         # system to update the UI with his new credit. To do that we
         # need to fire off another request
         self.get_current_sim_credit()
         self.model.payt_submit_busy = False
         self.view.clear_voucher_entry_view()
     else:
         logger.error("PAYT SIM submit voucher failed")
         self.model.payt_submit_busy = False
         show_warning_dialog(_("PAYT submit voucher"),
             _("PAYT submit voucher failed\n\'%s\'") % error)
Ejemplo n.º 21
0
 def submit_cb(error):
     if not error:
         logger.info("PAYT SIM submit voucher success")
         # ok we established his voucher code is good, let's cause the
         # system to update the UI with his new credit. To do that we
         # need to fire off another request
         self.get_current_sim_credit()
         self.model.payt_submit_busy = False
         self.view.clear_voucher_entry_view()
     else:
         logger.error("PAYT SIM submit voucher failed")
         self.model.payt_submit_busy = False
         show_warning_dialog(
             _("PAYT submit voucher"),
             _("PAYT submit voucher failed\n\'%s\'") % error)
    def __init__(self,
                 parent_model,
                 main_model,
                 profile=None,
                 imsi=None,
                 network=None):
        super(ProfileModel, self).__init__()

        self.bus = dbus.SystemBus()
        self.manager = manager
        self.profile = profile

        self.parent_model = parent_model
        self.main_model = main_model

        if self.profile and hasattr(self.profile, '__dbus_object_path__'):
            self.profile_path = self.profile.__dbus_object_path__

        if profile:
            self._load_profile(profile=profile)
        elif imsi:
            self._load_profile_from_imsi(imsi)
            self.name = self.make_profilename_unique(self.name)
        elif network:
            self._load_profile_from_network(network)
            self.name = self.make_profilename_unique(self.name)
        else:
            self.uuid = str(uuid1())  # blank profile
            self.name = self.make_profilename_unique(_('Custom'))

        self.sm = []  # signal matches list
Ejemplo n.º 23
0
    def __init__(self, parent_model, main_model,
                    profile=None, imsi=None, network=None):
        super(ProfileModel, self).__init__()

        self.bus = dbus.SystemBus()
        self.manager = manager
        self.profile = profile

        self.parent_model = parent_model
        self.main_model = main_model

        if self.profile and hasattr(self.profile, '__dbus_object_path__'):
            self.profile_path = self.profile.__dbus_object_path__

        if profile:
            self._load_profile(profile=profile)
        elif imsi:
            self._load_profile_from_imsi(imsi)
            self.name = self.make_profilename_unique(self.name)
        elif network:
            self._load_profile_from_network(network)
            self.name = self.make_profilename_unique(self.name)
        else:
            self.uuid = str(uuid1())  # blank profile
            self.name = self.make_profilename_unique(_('Custom'))

        self.sm = []  # signal matches list
Ejemplo n.º 24
0
 def bps_to_human(bps):
     f = float(bps)
     for m in ['b/s ', 'kb/s', 'mb/s', 'gb/s']:
         if f < 1000:
             return "%3.2f %s" % (f, m)
         f /= 1000
     return _("N/A")
Ejemplo n.º 25
0
    def on_ok_button_clicked(self, widget):
        self.model.name = self.view['profile_name_entry'].get_text()
        self.model.username = self.view['username_entry'].get_text()
        self.model.password = self.view['password_entry'].get_text()

        mode = self.view['connection_combobox'].get_active_text()
        band = self.view['band_combobox'].get_active_text()
        auth = self.view['authentication_combobox'].get_active_text()
        if mode:
            self.model.network_pref = MODE_MAP_REV[mode]
        if band:
            self.model.band = BAND_MAP_REV[band]
        if auth:
            self.model.auth = AUTH_MAP_REV[auth]

        self.model.apn = self.view['apn_entry'].get_text()
        self.model.static_dns = self.view['static_dns_check'].get_active()
        if self.view['static_dns_check'].get_active():
            dns1 = self.view['primary_dns_entry'].get_text()
            dns2 = self.view['secondary_dns_entry'].get_text()
            if dns1:
                self.model.primary_dns = convert_ip_to_int(dns1)
            if dns2:
                self.model.secondary_dns = convert_ip_to_int(dns2)

        try:
            self.model.save()
        except RuntimeError, e:
            show_error_dialog(_("Error creating profile"), get_error_msg(e))
Ejemplo n.º 26
0
    def get_current_sim_credit(self):
        # my job is to obtain the current credit value. I take care of setting
        # both value and time as a credit amount is only valid at the time you
        # check. I store the values in Gconf and set a flag indicating whether
        # this SIM is prepay capable
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False:  # Not a PAYT SIM
            show_warning_dialog(_("PAYT credit check"),
                                _("SIM is not on a PAYT plan"))
            return

        def credit_cb(credit):
            if credit:
                utc = time()
                now = datetime.fromtimestamp(utc, self.tz)
                logger.info("PAYT SIM credit: %s on %s" %
                            (credit, now.strftime("%c")))

                self.model.payt_credit_balance = credit
                self.model.set_sim_conf('payt_credit_balance', credit)

                self.model.payt_credit_date = now
                self.model.set_sim_conf('payt_credit_date', utc)
            else:
                self.model.payt_credit_balance = _("Not available")
                self.model.payt_credit_date = None

            # Record SIM as PAYT or not
            if not isinstance(payt_available, bool):
                self.model.payt_available = (credit is not None)
                self.model.set_sim_conf('payt_available',
                                        self.model.payt_available)

            self.model.payt_credit_busy = False

        ussd = get_payt_credit_check_info(self.model.imsi)
        if ussd:
            self.model.payt_credit_busy = True
            self._get_current_sim_credit_by_ussd(ussd, credit_cb)
        # elif have payt SMS credit check info:
        #    self._get_current_sim_credit_by_sms()
        else:
            show_warning_dialog(_("PAYT credit check"),
                                _("No PAYT credit check method available"))
    def get_current_sim_credit(self):
        # my job is to obtain the current credit value. I take care of setting
        # both value and time as a credit amount is only valid at the time you
        # check. I store the values in Gconf and set a flag indicating whether
        # this SIM is prepay capable
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False: # Not a PAYT SIM
            show_warning_dialog(_("PAYT credit check"),
                                _("SIM is not on a PAYT plan"))
            return

        def credit_cb(credit):
            if credit:
                utc = time()
                now = datetime.fromtimestamp(utc, self.tz)
                logger.info("PAYT SIM credit: %s on %s" %
                                (credit, now.strftime("%c")))

                self.model.payt_credit_balance = credit
                self.model.set_sim_conf('payt_credit_balance', credit)

                self.model.payt_credit_date = now
                self.model.set_sim_conf('payt_credit_date', utc)
            else:
                self.model.payt_credit_balance = _("Not available")
                self.model.payt_credit_date = None

            # Record SIM as PAYT or not
            if not isinstance(payt_available, bool):
                self.model.payt_available = (credit is not None)
                self.model.set_sim_conf('payt_available',
                                        self.model.payt_available)

            self.model.payt_credit_busy = False

        ussd = get_payt_credit_check_info(self.model.imsi)
        if ussd:
            self.model.payt_credit_busy = True
            self._get_current_sim_credit_by_ussd(ussd, credit_cb)
        # elif have payt SMS credit check info:
        #    self._get_current_sim_credit_by_sms()
        else:
            show_warning_dialog(_("PAYT credit check"),
                                _("No PAYT credit check method available"))
        def show_icon_cb(checkbutton):
            if checkbutton.get_active():
                if not tray_available():
                    # block the handler so the set_active method doesnt
                    # executes this callback again
                    checkbutton.handler_block(self._hid2)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid2)
                    message = _("Missing dependency")
                    details = _("""
To use this feature you need either pygtk >= 2.10 or the egg.trayicon module
""")
                    show_warning_dialog(message, details)
                    return True
                else:
                    self.view.setup_user_close_window_minimize_enable(True)
            else:
                self.view.setup_user_close_window_minimize_enable(False)
Ejemplo n.º 29
0
 def register_view(self, view):
     super(NewSmsController, self).register_view(view)
     # set initial text
     msg = _('Text message: 0/%d chars') % self.max_length
     self.view.get_top_widget().set_title(msg)
     # signals stuff
     textbuffer = self.view['sms_edit_text_view'].get_buffer()
     textbuffer.connect('changed', self._textbuffer_changed)
     # show up
     self.numbers_entry.grab_focus()
Ejemplo n.º 30
0
 def bytes_to_human(_bytes):
     f = float(_bytes)
     for m in ['B', 'KiB', 'MiB', 'GiB']:
         if f < 1000:
             if _bytes < 1000:  # don't show fraction of bytes
                 return "%3.0f %s" % (f, m)
             else:
                 return "%3.2f %s" % (f, m)
         f /= 1024
     return _("N/A")
        def show_icon_cb(checkbutton):
            if checkbutton.get_active():
                if not tray_available():
                    # block the handler so the set_active method doesnt
                    # executes this callback again
                    checkbutton.handler_block(self._hid2)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid2)
                    message = _("Missing dependency")
                    details = _("""
To use this feature you need either pygtk >= 2.10 or the egg.trayicon module
""")
                    show_warning_dialog(message, details)
                    return True
                else:
                    self.view.setup_user_close_window_minimize_enable(True)
            else:
                self.view.setup_user_close_window_minimize_enable(False)
Ejemplo n.º 32
0
    def on_search_find_button_clicked(self, widget):
        pattern = self.view["search_entry"].get_text()

        treeview = self.parent_ctrl.view["contacts_treeview"]
        model = treeview.get_model()

        contacts = model.find_contacts(pattern)
        if not contacts:
            dialogs.show_warning_dialog(_("No contact found"), _("No contact with the name %s found") % pattern)
            return

        # get the path
        path = [str(i) for i, row in enumerate(model) if row[3] in contacts]
        # unselect
        sel = treeview.get_selection()
        sel.unselect_all()
        for elem in path:
            # and set the new selection
            sel.select_path(elem)
Ejemplo n.º 33
0
 def register_view(self, view):
     super(NewSmsController, self).register_view(view)
     # set initial text
     msg = _('Text message: 0/%d chars') % self.max_length
     self.view.get_top_widget().set_title(msg)
     # signals stuff
     textbuffer = self.view['sms_edit_text_view'].get_buffer()
     textbuffer.connect('changed', self._textbuffer_changed)
     # show up
     self.numbers_entry.grab_focus()
Ejemplo n.º 34
0
    def _setup_view(self):
        treeview = self.view['treeview1']
        col_type, col_name, col_number, col_pyobj, col_editable = range(5)
        treeview.set_model(ContactsStoreModel())

        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        treeview.connect('row-activated', self._row_activated_handler)

        cell = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_("Type"))
        column.pack_start(cell)
        column.set_attributes(cell, pixbuf=col_type)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Name"), cell, text=col_name)
        column.set_resizable(True)
        column.set_sort_column_id(col_name)
        cell.set_property('editable', False)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Number"), cell, text=col_number)
        column.set_resizable(True)
        column.set_sort_column_id(col_number)
        cell.set_property('editable', False)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn("IntId", cell, text=col_pyobj)
        column.set_visible(False)
        column.set_sort_column_id(col_pyobj)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Editable", cell, text=col_editable)
        column.set_visible(False)
        column.set_sort_column_id(col_editable)
        treeview.append_column(column)

        # make add contact insensitive until a row has been selected
        self.view['add_button'].set_sensitive(False)
Ejemplo n.º 35
0
    def _setup_view(self):
        treeview = self.view["treeview1"]
        col_type, col_name, col_number, col_pyobj, col_editable = range(5)
        treeview.set_model(ContactsStoreModel())

        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        treeview.connect("row-activated", self._row_activated_handler)

        cell = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_("Type"))
        column.pack_start(cell)
        column.set_attributes(cell, pixbuf=col_type)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Name"), cell, text=col_name)
        column.set_resizable(True)
        column.set_sort_column_id(col_name)
        cell.set_property("editable", False)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Number"), cell, text=col_number)
        column.set_resizable(True)
        column.set_sort_column_id(col_number)
        cell.set_property("editable", False)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn("IntId", cell, text=col_pyobj)
        column.set_visible(False)
        column.set_sort_column_id(col_pyobj)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Editable", cell, text=col_editable)
        column.set_visible(False)
        column.set_sort_column_id(col_editable)
        treeview.append_column(column)

        # make add contact insensitive until a row has been selected
        self.view["add_button"].set_sensitive(False)
    def setup_view(self):
        self._view = self['apn_list_treeview']
        self['APNimage'].set_from_file(self.IMAGE_FILE)

        # init columns
        render_text = gtk.CellRendererText()
        col0 = gtk.TreeViewColumn(_('Name'))
        col0.pack_start(render_text, expand=True)
        col0.add_attribute(render_text, 'text', 0)
        self._view.append_column(col0)

        col1 = gtk.TreeViewColumn(_('Country'))
        col1.pack_start(render_text, expand=True)
        col1.add_attribute(render_text, 'text', 1)
        self._view.append_column(col1)

        col2 = gtk.TreeViewColumn(_('Type'))
        col2.pack_start(render_text, expand=True)
        col2.add_attribute(render_text, 'text', 2)
        self._view.append_column(col2)
Ejemplo n.º 37
0
    def setup_view(self):
        self._view = self['apn_list_treeview']
        self['APNimage'].set_from_file(self.IMAGE_FILE)

        # init columns
        render_text = gtk.CellRendererText()
        col0 = gtk.TreeViewColumn(_('Name'))
        col0.pack_start(render_text, expand=True)
        col0.add_attribute(render_text, 'text', 0)
        self._view.append_column(col0)

        col1 = gtk.TreeViewColumn(_('Country'))
        col1.pack_start(render_text, expand=True)
        col1.add_attribute(render_text, 'text', 1)
        self._view.append_column(col1)

        col2 = gtk.TreeViewColumn(_('Type'))
        col2.pack_start(render_text, expand=True)
        col2.add_attribute(render_text, 'text', 2)
        self._view.append_column(col2)
Ejemplo n.º 38
0
def save_csv_file(path=None):
    """Opens a filechooser dialog to choose where to save a csv file"""
    title = _("Save as ...")
    chooser_dialog = gtk.FileChooserDialog(
        title,
        action=gtk.FILE_CHOOSER_ACTION_SAVE,
        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK),
    )

    chooser_dialog.set_default_response(gtk.RESPONSE_OK)
    filter_ = gtk.FileFilter()
    filter_.set_name(_("Csv files"))
    filter_.add_mime_type("text/xml")
    filter_.add_pattern("*csv")
    chooser_dialog.add_filter(filter_)

    filter_ = gtk.FileFilter()
    filter_.set_name(_("All files"))
    filter_.add_pattern("*")
    chooser_dialog.add_filter(filter_)

    if path:
        chooser_dialog.set_filename(os.path.abspath(path))
    if chooser_dialog.run() == gtk.RESPONSE_OK:
        resp = chooser_dialog.get_filename()
        if os.path.isfile(resp):
            # requests to confirm overwrite:
            overwrite = show_warning_request_cancel_ok(
                _('Overwrite "%s"?') % os.path.basename(resp),
                _(
                    """A file with this name already exists.
If you choose to overwrite this file, the contents will be lost."""
                ),
            )
            if not overwrite:
                resp = None
    else:
        resp = None

    chooser_dialog.destroy()
    return resp
Ejemplo n.º 39
0
    def _textbuffer_changed(self, textbuffer):
        """Handler for the textbuffer changed signal"""
        text = textbuffer.get_text(textbuffer.get_start_iter(),
                                   textbuffer.get_end_iter())
        if not len(text):
            msg = _('Text message: 0/%d chars') % SEVENBIT_SIZE
        else:
            # get the number of messages
            # we use a default number for encoding purposes
            num_sms = len(SmsSubmit('+342453435', text).to_pdu())
            if num_sms == 1:
                max_length = SEVENBIT_SIZE if is_gsm_text(text) else UCS2_SIZE
                args = dict(num=len(text), total=max_length)
                msg = _('Text message: %(num)d/%(total)d chars') % args
            else:
                max_length = SEVENBIT_MP_SIZE if is_gsm_text(text) else UCS2_MP_SIZE
                used = len(text) - (max_length * (num_sms - 1))
                args = dict(num=used, total=max_length, msgs=num_sms)
                msg = _('Text message: '
                        '%(num)d/%(total)d chars (%(msgs)d SMS)') % args

        self.view.get_top_widget().set_title(msg)
Ejemplo n.º 40
0
    def _setup_view(self):
        treeview = self.view['treeview1']
        treeview.set_model(ContactsStoreModel())

        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        treeview.connect('row-activated', self._row_activated_handler)

        cell = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_("Type"))
        column.pack_start(cell)
        column.set_attributes(cell, pixbuf=TV_CNT_TYPE)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        cell.set_property('editable', False)
        column = gtk.TreeViewColumn(_("Name"), cell, text=TV_CNT_NAME)
        column.set_resizable(True)
        column.set_sort_column_id(TV_CNT_NAME)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        cell.set_property('editable', False)
        column = gtk.TreeViewColumn(_("Number"), cell, text=TV_CNT_NUMBER)
        column.set_resizable(True)
        column.set_sort_column_id(TV_CNT_NUMBER)
        treeview.append_column(column)

        cell = gtk.CellRendererToggle()
        column = gtk.TreeViewColumn("Editable", cell, active=TV_CNT_EDITABLE)
        column.set_visible(False)
        treeview.append_column(column)

        cell = None
        column = gtk.TreeViewColumn("IntId", cell)  # TV_CNT_OBJ
        column.set_visible(False)
        treeview.append_column(column)

        # make add contact insensitive until a row has been selected
        self.view['add_button'].set_sensitive(False)
    def delete(self):
        if self.profile:
            logger.info("Removing profile %s" % self.profile)
            self.manager.remove_profile(self.profile)
            self.profile_path = None
            self.uuid = None
            self.name = ""

            while self.sm:
                sm = self.sm.pop()
                sm.remove()
        else:
            raise RuntimeError(_("Trying to remove an unsaved profile"))
    def _setup_view(self):
        treeview = self.view['treeview1']
        treeview.set_model(ContactsStoreModel())

        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        treeview.connect('row-activated', self._row_activated_handler)

        cell = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_("Type"))
        column.pack_start(cell)
        column.set_attributes(cell, pixbuf=TV_CNT_TYPE)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        cell.set_property('editable', False)
        column = gtk.TreeViewColumn(_("Name"), cell, text=TV_CNT_NAME)
        column.set_resizable(True)
        column.set_sort_column_id(TV_CNT_NAME)
        treeview.append_column(column)

        cell = gtk.CellRendererText()
        cell.set_property('editable', False)
        column = gtk.TreeViewColumn(_("Number"), cell, text=TV_CNT_NUMBER)
        column.set_resizable(True)
        column.set_sort_column_id(TV_CNT_NUMBER)
        treeview.append_column(column)

        cell = gtk.CellRendererToggle()
        column = gtk.TreeViewColumn("Editable", cell, active=TV_CNT_EDITABLE)
        column.set_visible(False)
        treeview.append_column(column)

        cell = None
        column = gtk.TreeViewColumn("IntId", cell)  # TV_CNT_OBJ
        column.set_visible(False)
        treeview.append_column(column)

        # make add contact insensitive until a row has been selected
        self.view['add_button'].set_sensitive(False)
Ejemplo n.º 43
0
    def delete(self):
        if self.profile:
            logger.info("Removing profile %s" % self.profile)
            self.manager.remove_profile(self.profile)
            self.profile_path = None
            self.uuid = None
            self.name = ""

            while self.sm:
                sm = self.sm.pop()
                sm.remove()
        else:
            raise RuntimeError(_("Trying to remove an unsaved profile"))
Ejemplo n.º 44
0
    def get_cached_sim_credit(self):

        if self.model.get_sim_conf('payt_available'):
            credit = self.model.get_sim_conf('payt_credit_balance')
            utc = self.model.get_sim_conf('payt_credit_date')

            if credit and utc:
                self.model.payt_credit_balance = credit
                self.model.payt_credit_date = datetime.fromtimestamp(utc, self.tz)
                return

        self.model.payt_credit_balance = _("Not available")
        self.model.payt_credit_date = None
def show_about_dialog():
    abt = gtk.AboutDialog()
    abt.set_icon(gtk.gdk.pixbuf_new_from_file(DIALOG_ICON))

    gtk.about_dialog_set_url_hook(lambda abt, url: show_uri(url))
    gtk.about_dialog_set_email_hook(lambda d, e: show_uri("mailto:%s" % e))

    if gtk.pygtk_version >= (2, 11, 0):
        abt.set_program_name(APP_NAME)
    else:
        abt.set_name(APP_NAME)
    abt.set_version(APP_VERSION)
    _copyright = """\
Copyright (C) 2006-2012 Vodafone España S.A.
Copyright (C) 2008-2010 Warp Networks, S.L.
Copyright (C) 2008-2009 Wader contributors"""
    abt.set_copyright(_copyright)
    abt.set_authors(APP_AUTHORS)
    abt.set_documenters(APP_DOCUMENTERS)
    abt.set_artists(APP_ARTISTS)
    abt.set_website(APP_URL)
    abt.set_translator_credits(_('translator-credits'))

    abt.set_website_label(APP_URL)
    _license = """\
V Mobile Broadband

%s

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
    abt.set_license(_license % _copyright)

    def close(dialog, response):
        dialog.destroy()

    abt.connect("response", close)

    return abt
Ejemplo n.º 46
0
def show_about_dialog():
    abt = gtk.AboutDialog()
    abt.set_icon(gtk.gdk.pixbuf_new_from_file(DIALOG_ICON))

    gtk.about_dialog_set_url_hook(lambda abt, url: show_uri(url))
    gtk.about_dialog_set_email_hook(lambda d, e: show_uri("mailto:%s" % e))

    if gtk.pygtk_version >= (2, 11, 0):
        abt.set_program_name(APP_NAME)
    else:
        abt.set_name(APP_NAME)
    abt.set_version(APP_VERSION)
    _copyright = """\
Copyright (C) 2006-2012 Vodafone España S.A.
Copyright (C) 2008-2010 Warp Networks, S.L.
Copyright (C) 2008-2009 Wader contributors"""
    abt.set_copyright(_copyright)
    abt.set_authors(APP_AUTHORS)
    abt.set_documenters(APP_DOCUMENTERS)
    abt.set_artists(APP_ARTISTS)
    abt.set_website(APP_URL)
    abt.set_translator_credits(_("translator-credits"))

    abt.set_website_label(APP_URL)
    _license = """\
V Mobile Broadband

%s

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
    abt.set_license(_license % _copyright)

    def close(dialog, response):
        dialog.destroy()

    abt.connect("response", close)

    return abt
Ejemplo n.º 47
0
    def get_cached_sim_credit(self):

        if self.model.get_sim_conf('payt_available'):
            credit = self.model.get_sim_conf('payt_credit_balance')
            utc = self.model.get_sim_conf('payt_credit_date')

            if credit and utc:
                self.model.payt_credit_balance = credit
                self.model.payt_credit_date = datetime.fromtimestamp(
                    utc, self.tz)
                return

        self.model.payt_credit_balance = _("Not available")
        self.model.payt_credit_date = None
        def get_imsi_cb(imsi):
            if imsi:
                msisdn = self.conf.get("sim/%s" % imsi, 'msisdn')
                if msisdn:
                    logger.info("MSISDN from gconf: %s" % msisdn)
                    self.msisdn = msisdn
                    cb(self.msisdn)
                    return

            ussd = get_msisdn_ussd_info(imsi)
            if ussd:
                self._get_msisdn_by_ussd(ussd, cb)
            else:
                cb(_("Unknown"))
Ejemplo n.º 49
0
    def _textbuffer_changed(self, textbuffer):
        """Handler for the textbuffer changed signal"""
        text = textbuffer.get_text(textbuffer.get_start_iter(),
                                   textbuffer.get_end_iter())
        if not len(text):
            msg = _('Text message: 0/%d chars') % SEVENBIT_SIZE
        else:
            # get the number of messages
            # we use a default number for encoding purposes
            num_sms = len(SmsSubmit('+342453435', text).to_pdu())
            if num_sms == 1:
                max_length = SEVENBIT_SIZE if is_gsm_text(text) else UCS2_SIZE
                args = dict(num=len(text), total=max_length)
                msg = _('Text message: %(num)d/%(total)d chars') % args
            else:
                max_length = SEVENBIT_MP_SIZE if is_gsm_text(
                    text) else UCS2_MP_SIZE
                used = len(text) - (max_length * (num_sms - 1))
                args = dict(num=used, total=max_length, msgs=num_sms)
                msg = _('Text message: '
                        '%(num)d/%(total)d chars (%(msgs)d SMS)') % args

        self.view.get_top_widget().set_title(msg)
Ejemplo n.º 50
0
    def __init__(self, parent):
        super(NewKeyringDialog, self).__init__(
            parent, _("Create default keyring"),
            _("The application '%s' wants to store a password, but "
              "there is no default keyring. To create one, you need "
              "to choose a password you wish to use for it." % APP_NAME))
        self.cancel_button.destroy()

        pin_panel = get_object(self.tree, 'new_keyring_panel')
        get_object(self.tree, 'new_keyring_window').remove(pin_panel)
        self.vbox.add(pin_panel)

        self.password_entry = get_object(self.tree, 'new_keyring_password')
        #self.password_entry.get_settings().set_long_property(
        #    "gtk-entry-password-hint-timeout", 600, "")
        add_password_validation(self.password_entry, self.check_ok_conditions)

        self.confirm_password_entry = get_object(
            self.tree, 'new_keyring_password_confirm')
        #self.confirm_password_entry.get_settings().set_long_property(
        #    "gtk-entry-password-hint-timeout", 600, "")
        add_password_validation(self.confirm_password_entry,
                                self.check_ok_conditions)
    def __init__(self, parent):
        super(NewKeyringDialog, self).__init__(parent,
                _("Create default keyring"),
                _("The application '%s' wants to store a password, but "
                  "there is no default keyring. To create one, you need "
                  "to choose a password you wish to use for it." % APP_NAME))
        self.cancel_button.destroy()

        pin_panel = get_object(self.tree, 'new_keyring_panel')
        get_object(self.tree, 'new_keyring_window').remove(pin_panel)
        self.vbox.add(pin_panel)

        self.password_entry = get_object(self.tree, 'new_keyring_password')
        #self.password_entry.get_settings().set_long_property(
        #    "gtk-entry-password-hint-timeout", 600, "")
        add_password_validation(self.password_entry, self.check_ok_conditions)

        self.confirm_password_entry = get_object(self.tree,
                                                'new_keyring_password_confirm')
        #self.confirm_password_entry.get_settings().set_long_property(
        #    "gtk-entry-password-hint-timeout", 600, "")
        add_password_validation(self.confirm_password_entry,
                                self.check_ok_conditions)
Ejemplo n.º 52
0
        def get_imsi_cb(imsi):
            if imsi:
                msisdn = self.conf.get("sim/%s" % imsi, 'msisdn')
                if msisdn:
                    logger.info("MSISDN from gconf: %s" % msisdn)
                    self.msisdn = msisdn
                    cb(self.msisdn)
                    return

            ussd = get_msisdn_ussd_info(imsi)
            if ussd:
                self._get_msisdn_by_ussd(ussd, cb)
            else:
                cb(_("Unknown"))
        def keyringtoggled_cb(checkbutton):
            """
            Callback for the gnomekeyring_checkbutton::toggled signal

            we are gonna try to import gnomekeyring beforehand, if we
            get an ImportError we will inform the user about what she
            should do
            """
            if checkbutton.get_active():
                try:
                    import gnomekeyring
                except ImportError:
                    # block the handler so the set_active method doesnt execute
                    # this callback again
                    checkbutton.handler_block(self._hid1)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid1)
                    message = _("Missing dependency")
                    details = _(
"""To use this feature you need the gnomekeyring module""")
                    show_warning_dialog(message, details)
                    return True
Ejemplo n.º 54
0
def save_csv_file(path=None):
    """Opens a filechooser dialog to choose where to save a csv file"""
    title = _("Save as ...")
    chooser_dialog = gtk.FileChooserDialog(title,
                    action=gtk.FILE_CHOOSER_ACTION_SAVE,
                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_SAVE, gtk.RESPONSE_OK))

    chooser_dialog.set_default_response(gtk.RESPONSE_OK)
    filter_ = gtk.FileFilter()
    filter_.set_name(_("Csv files"))
    filter_.add_mime_type("text/xml")
    filter_.add_pattern("*csv")
    chooser_dialog.add_filter(filter_)

    filter_ = gtk.FileFilter()
    filter_.set_name(_("All files"))
    filter_.add_pattern("*")
    chooser_dialog.add_filter(filter_)

    if path:
        chooser_dialog.set_filename(os.path.abspath(path))
    if chooser_dialog.run() == gtk.RESPONSE_OK:
        resp = chooser_dialog.get_filename()
        if os.path.isfile(resp):
            # requests to confirm overwrite:
            overwrite = show_warning_request_cancel_ok(
                          _('Overwrite "%s"?') % os.path.basename(resp),
                          _("""A file with this name already exists.
If you choose to overwrite this file, the contents will be lost."""))
            if not overwrite:
                resp = None
    else:
        resp = None

    chooser_dialog.destroy()
    return resp