def test_constructor(self):
     w = hildon.Window()
     note = hildon.Note("confirmation", w, "xyz")
     self.assertTrue(isinstance(note, hildon.Note))
     note = hildon.Note("information", w, "xyz")
     self.assertTrue(isinstance(note, hildon.Note))
     note = hildon.Note("information", w, "xyz", icon_name="abc")
     self.assertTrue(isinstance(note, hildon.Note))
     note = hildon.Note("cancel", w, "xyz", progressbar=gtk.ProgressBar())
     self.assertTrue(isinstance(note, hildon.Note))
     self.assertRaises(TypeError, hildon.Note, "cancel", w, "xyz")
Example #2
0
 def show_confirmation(self, message, title=None):
     if gpodder.ui.desktop:
         dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL,
                                 gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO)
         if title:
             dlg.set_title(str(title))
             dlg.set_markup(
                 '<span weight="bold" size="larger">%s</span>\n\n%s' %
                 (title, message))
         else:
             dlg.set_markup('<span weight="bold" size="larger">%s</span>' %
                            (message))
         response = dlg.run()
         dlg.destroy()
         return response == gtk.RESPONSE_YES
     elif gpodder.ui.diablo:
         import hildon
         try:
             dlg = hildon.Note('confirmation', (self.main_window, message))
         except TypeError:
             # Kludgy workaround: We're running the Diablo UI on Maemo 5 :)
             dlg = hildon.hildon_note_new_confirmation(self.main_window, \
                     message)
         response = dlg.run()
         dlg.destroy()
         return response == gtk.RESPONSE_OK
     elif gpodder.ui.fremantle:
         import hildon
         dlg = hildon.hildon_note_new_confirmation(self.get_dialog_parent(), \
                 message)
         response = dlg.run()
         dlg.destroy()
         return response == gtk.RESPONSE_OK
     else:
         raise Exception('Unknown interface type')
Example #3
0
 def onCancelWithProgressBar(self, widget):
         prog_bar = gtk.ProgressBar()
         prog_bar.set_fraction (0.35)
         dialog = hildon.Note("cancel_with_progress_bar", (self, "Cancel with Progress Bar", prog_bar))
         dialog.run()
         dialog.destroy()
         prog_bar.destroy()
Example #4
0
def confirmation(window,text,yes,no):
  dialog = hildon.Note ("confirmation", (window, text, gtk.STOCK_DIALOG_WARNING) )
  dialog.set_button_texts (yes, no)
  response = dialog.run()
  dialog.destroy()
  if response == gtk.RESPONSE_OK:
    return True
  return False
Example #5
0
def del_google_acct(widget, data):
    id = get_google_acct_id()
    account = google_accounts.get_account_by_id(id)
    text = "Are you sure that you want to delete account \"%s\"?\n" \
      "Deleting it will remove all links between the data "\
      "stored on your device and data stored in Google.\n"\
      "Please note that no actual data will be deleted, "\
      "only their relationships." % (account[0])
    dialog = hildon.Note("confirmation", data, text)
    dialog.set_button_texts("Yes", "No")
    ans = dialog.run()
    dialog.destroy()

    if ans == gtk.RESPONSE_OK:
        google_accounts.delete_account_by_id(id)
        read_accounts_list()
        update_gaccts_button()
Example #6
0
    def areYouSure(self, text, okCB=None, cancelCB=None):
        """create a confirmation dialog with optional callbacks"""
        import gtk
        import hildon

        note = hildon.Note("confirmation", self.mieru.getWindow(), text)

        returnCode = gtk.Dialog.run(note)
        note.destroy()

        if returnCode == gtk.RESPONSE_OK:
            print("User pressed 'OK' button'")
            if okCB is not None:
                (cb1, args1) = okCB
                cb1(*args1)
            return True
        else:
            print("User pressed 'Cancel' button")
            if cancelCB is not None:
                (cb2, args2) = cancelCB
                cb2(*args2)
            return False
    def test_constructor(self):
        w = hildon.Window()
        note = hildon.Note("confirmation", w, "xyz")
        self.assertTrue(isinstance(note, hildon.Note))
        note = hildon.Note("information", w, "xyz")
        self.assertTrue(isinstance(note, hildon.Note))
        note = hildon.Note("information", w, "xyz", icon_name="abc")
        self.assertTrue(isinstance(note, hildon.Note))
        note = hildon.Note("cancel", w, "xyz", progressbar=gtk.ProgressBar())
        self.assertTrue(isinstance(note, hildon.Note))

        note = hildon.Note(hildon.NOTE_TYPE_PROGRESSBAR, w, "xyz", progressbar=gtk.ProgressBar())
        self.assertTrue(isinstance(note, hildon.Note))
        note = hildon.Note(hildon.NOTE_TYPE_CONFIRMATION, w, "xyz")
        self.assertTrue(isinstance(note, hildon.Note))
        note = hildon.Note(hildon.NOTE_TYPE_INFORMATION, w, "xyz")
        self.assertTrue(isinstance(note, hildon.Note))

        self.assertRaises(ValueError, hildon.Note, "invalid_type", w, "xyz")
        self.assertRaises(ValueError, hildon.Note, ("invalid_type"), w, "xyz")
        self.assertRaises(TypeError, hildon.Note, "cancel")
Example #8
0
    def show_message(self, message, title=None, important=False, widget=None):
        if gpodder.ui.diablo:
            import hildon
            if important:
                try:
                    dlg = hildon.Note('information',
                                      (self.main_window, message))
                except TypeError:
                    if title is None:
                        message = message
                    else:
                        message = '%s\n%s' % (title, message)
                    dlg = hildon.hildon_note_new_information(self.main_window, \
                            message)
                dlg.run()
                dlg.destroy()
            else:
                if title is None:
                    title = 'gPodder'
                pango_markup = '<b>%s</b>\n<small>%s</small>' % (title,
                                                                 message)
                try:
                    hildon.hildon_banner_show_information_with_markup(
                        gtk.Label(''), None, pango_markup)
                except TypeError:
                    # We're probably running the Diablo UI on Maemo 5 :)
                    hildon.hildon_banner_show_information(self.main_window, \
                            '', message)
        elif gpodder.ui.fremantle:
            import hildon
            if important:
                if title is None:
                    message = message
                else:
                    message = '%s\n%s' % (title, message)

                dlg = hildon.hildon_note_new_information( \
                        self.get_dialog_parent(), \
                        message)
                dlg.run()
                dlg.destroy()
            else:
                hildon.hildon_banner_show_information(self.get_dialog_parent(), \
                        '', message)
        else:
            # XXX: Dirty hack to get access to the gPodder-specific config object
            config = getattr(self, '_config', getattr(self, 'config', None))

            if important:
                dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL,
                                        gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
                if title:
                    dlg.set_title(str(title))
                    dlg.set_markup(
                        '<span weight="bold" size="larger">%s</span>\n\n%s' %
                        (title, message))
                else:
                    dlg.set_markup(
                        '<span weight="bold" size="larger">%s</span>' %
                        (message))
                dlg.run()
                dlg.destroy()
            elif config is not None and config.enable_notifications:
                if pynotify is not None:
                    if title is None:
                        title = 'gPodder'
                    notification = pynotify.Notification(title, message,\
                            gpodder.icon_file)
                    try:
                        notification.show()
                    except:
                        # See http://gpodder.org/bug/966
                        pass
                elif widget and isinstance(widget, gtk.Widget):
                    if not widget.window:
                        widget = self.main_window
                    elif not gpodder.win32:
                        widget = self.main_window
                    notification = NotificationWindow(message,
                                                      title,
                                                      important=False,
                                                      widget=widget)
                    notification.show_timeout()
Example #9
0
 def onInformationWithIconName(self, widget):        
         dialog = hildon.Note("information", (self, "Inf. with Icon Name", gtk.STOCK_DIALOG_INFO))
         dialog.run()
         dialog.destroy()
Example #10
0
 def onInformation(self, widget):
         dialog = hildon.Note("information", (self, "Information"))
         dialog.run()
         dialog.destroy()
Example #11
0
 def onConfirmation(self, widget):
         dialog = hildon.Note("confirmation", (self, "Confirmation"))
         dialog.run()
         dialog.destroy()
Example #12
0
def note(window,text,ok):
  dialog = hildon.Note ("information", (window, text, gtk.STOCK_DIALOG_WARNING) )
  dialog.set_button_text(ok)
  dialog.run()
  dialog.destroy()