+ fb_empty = self.add_linked(indent, use_facebook, self.new_checkbox('Create birthday-only contacts'))
+ fb_empty.set_active(self.get_create_empty())
+
+ use_twitter = self.new_checkbox('Use Twitter', content)
+ use_twitter.set_active(self.get_use_twitter())
+
+ indent = self.new_indent(content)
+ tw_user = self.add_linked(indent, use_twitter, self.new_input('Twitter username'))
+ tw_user.set_text(self.get_twitter_credentials()[0])
+
+ tw_pass = self.add_linked(indent, use_twitter, self.new_input('Twitter password'))
+ tw_pass.set_property('hildon-input-mode', gtk.HILDON_GTK_INPUT_MODE_FULL |
+ gtk.HILDON_GTK_INPUT_MODE_INVISIBLE)
+ tw_pass.set_text(self.get_twitter_credentials()[1])
+
+ dialog.show_all()
+ result = dialog.run()
+ dialog.hide()
+ if result == gtk.RESPONSE_OK:
+ self.set_use_facebook(use_facebook.get_active())
+ self.set_create_empty(fb_empty.get_active())
+ self.set_use_twitter(use_twitter.get_active(), tw_user.get_text(), tw_pass.get_text())
+
+ return result
+
+ # -----------------------------------------------------------------------
+ def new_checkbox(self, label, box = None):
+ checkbox = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
+ checkbox.set_label(label)
+ if box:
+ box.add(checkbox)
+ return checkbox
+
+
+ # -----------------------------------------------------------------------
+ def new_indent(self, box):
+ outer = gtk.HBox()
+ indent = gtk.VBox()
+ outer.pack_start(indent, padding=48)
+ box.add(outer)
+ return indent
+
+
+ # -----------------------------------------------------------------------
+ def new_input(self, text, box = None):
+ input = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
+ input.set_property('hildon-input-mode', gtk.HILDON_GTK_INPUT_MODE_FULL)
+ input.set_placeholder(text)
+ input.set_property('is-focus', False)
+ if box:
+ box.add(input)
+ return input
+
+
+ # -----------------------------------------------------------------------
+ def add_linked(self, box, ctrl, to_add):
+ box.add(to_add)
+ self.sync_edit(ctrl, to_add)
+ ctrl.connect('toggled', self.sync_edit, to_add)
+ return to_add
+
+
+ # -----------------------------------------------------------------------
+ def sync_edit(self, use_twitter, edit):
+ edit.set_property('sensitive', use_twitter.get_active())
+
+