From f90c56e934812e59834b23263c485f6bc825daa2 Mon Sep 17 00:00:00 2001 From: Agustin Zubiaga Date: Tue, 11 Jun 2013 21:19:56 +0000 Subject: Starting redesign --- (limited to 'agendacanvas.py') diff --git a/agendacanvas.py b/agendacanvas.py index 1d688da..00542ea 100755 --- a/agendacanvas.py +++ b/agendacanvas.py @@ -45,7 +45,9 @@ if __name__ == "__main__": a.set_property('gtk-theme-name', 'sugar-100') def pixbuf(path): - pix = gtk.gdk.pixbuf_new_from_file_at_size(path, 200, 200) + pix = gtk.gdk.pixbuf_new_from_file_at_size(path, + (gtk.gdk.screen_width() / 10) - 5, + (gtk.gdk.screen_width() / 10) - 5) return pix @@ -93,45 +95,32 @@ class AddTelephoneArea(gtk.VBox): self.bb.props.palette.popdown(True) -class canvas(gtk.HPaned): +class Canvas(gtk.HPaned): + + def __init__(self, remove): + super(Canvas, self).__init__() - def __init__(self): - super(canvas, self).__init__() - #### - self.toolbar = gtk.Toolbar() - self.remove = ToolButton('remove') - self.remove.set_tooltip(_('Remove this contact')) - self.addbtn = ToolButton('add') - self.addbtn.connect('clicked', self._show_palette_add_button) - - self.sep = gtk.SeparatorToolItem() - self.toolarea = AddTelephoneArea(self.addbtn, self) - self.sep.props.draw = False - self.sep.set_expand(True) - self.toolbar.insert(self.sep, -1) - self.toolbar.insert(self.remove, -1) - ### self.ficha = Ficha() - self.set1 = Telefonos(self.remove, self.ficha) + fscroll = gtk.ScrolledWindow() + fscroll.add_with_viewport(self.ficha) + fscroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + self.set1 = Telefonos(remove, self.ficha) self.scroll = gtk.ScrolledWindow() self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scroll.add_with_viewport(self.set1) self.vbx = gtk.VBox() self.vbx.pack_start(self.scroll, True, True, 0) - self.vbx.pack_end(self.toolbar, False, True, 0) self.vbx.set_size_request(gtk.gdk.screen_width() / 3, -1) self.add1(self.vbx) - self.add2(self.ficha) + self.add2(fscroll) self.show_all() - self.addbtn.set_tooltip(_('Add a new contact')) if __name__ == "__main__": self.toolbar.insert(self.addbtn, -1) if os.path.isfile("users"): self.read_file('users') - self._create_palette_add_button(self.addbtn) def read_file(self, file_path): fd = open(file_path, 'r') @@ -145,21 +134,14 @@ class canvas(gtk.HPaned): email = data['emails'][current] direction = data['directions'][current] avatar = data['avatars'][current] - self._add(x, numero, edad, email, direction, avatar) + self.add(x, numero, edad, email, direction, avatar) current += 1 - def _show_palette_add_button(self, button): - button.props.palette.popup(immediate=True, state=1) - - def _create_palette_add_button(self, button): - pallete = button.get_palette() - pallete.set_content(self.toolarea) - txt = _("Unknown") pt = os.path.join(os.getcwd(), 'avatars', 'none.svg') td = _("None") - def _add(self, name, number=txt, age=1, email=td, direct=txt, av=pt): + def add(self, name=_("New Contact"), number=txt, age=1, email=td, direct=txt, av=pt): self.set1._add_telephone(name, number, age, email, direct, av) self.show_all() @@ -207,6 +189,7 @@ class Telefonos(gtk.TreeView): echo = True a += 1 self.ficha.name_entry.set_text(name) + self.ficha.name_entry.grab_focus() self.ficha.age_entry.set_text(str(AGES[utils.current])) self.ficha.telephone_entry.set_text(str(NUMBERS[utils.current])) self.ficha.email_entry.set_text(str(EMAILS[utils.current])) @@ -234,6 +217,7 @@ class Telefonos(gtk.TreeView): AVATARS.append(avatar) IMAGE.set_from_pixbuf(pixbuf(avatar)) IMAGE.show_all() + self.set_cursor(len(NAMES) - 1) self.show_all() @@ -282,13 +266,11 @@ class Ficha(gtk.VBox): Direction -Entry- """ ### - self.namee = gtk.Label(_('Name:')) self.age = gtk.Label(_('Age:')) self.telephone = gtk.Label(_('Telephone:')) self.email = gtk.Label('Email:') self.direction = gtk.Label(_('Adress:')) - self.namee.set_size_request(100, -1) self.age.set_size_request(100, -1) self.telephone.set_size_request(100, -1) self.email.set_size_request(100, -1) @@ -298,7 +280,8 @@ class Ficha(gtk.VBox): self.name_entry = gtk.Entry() self.user = gtk.Button() self.conectado = self.user.connect('clicked', self.open) - IMAGE.set_size_request(200, 200) + #self.user.set_size_request((gtk.gdk.screen_width() / 10) - 5, + # (gtk.gdk.screen_width() / 10) - 5) self.user.add(IMAGE) self.age_entry = gtk.SpinButton() @@ -327,8 +310,7 @@ class Ficha(gtk.VBox): self.emailbox = gtk.HBox() self.directionbox = gtk.HBox() ### - self.namebox.pack_start(self.user, expand=True, fill=True, padding=6) - self.namebox.pack_start(self.namee, False, False, 6) + self.namebox.pack_start(self.user, False, True, padding=6) self.namebox.pack_end(self.name_entry, True, True, 6) self.agebox.pack_start(self.age, False, False, 6) self.agebox.pack_end(self.age_entry, True, True, 6) @@ -391,7 +373,9 @@ class Ficha(gtk.VBox): self.user.disconnect(self.conectado) path = ch.file_path self.conectado = self.user.connect('clicked', self.open, path) - pix = gtk.gdk.pixbuf_new_from_file_at_size(path, 200, 200) + pix = gtk.gdk.pixbuf_new_from_file_at_size(path, + (gtk.gdk.screen_width() / 10) - 5, + (gtk.gdk.screen_width() / 10) - 5) image.set_from_pixbuf(pix) for x in list(self.user): self.user.remove(x) @@ -412,7 +396,9 @@ class Ficha(gtk.VBox): def _set_img_button(self, widget, path, win): win.destroy() image = gtk.Image() - pix = gtk.gdk.pixbuf_new_from_file_at_size(path, 200, 200) + pix = gtk.gdk.pixbuf_new_from_file_at_size(path, + (gtk.gdk.screen_width() / 10) - 5, + (gtk.gdk.screen_width() / 10) - 5) image.set_from_pixbuf(pix) self.user.disconnect(self.conectado) self.conectado = self.user.connect('clicked', self.open, path) @@ -516,7 +502,8 @@ class Avatars(gtk.VBox): button.set_sensitive(sensi) button.set_tooltip_text(path) image = gtk.Image() - pix = gtk.gdk.pixbuf_new_from_file_at_size(path, 100, 100) + pix = gtk.gdk.pixbuf_new_from_file_at_size(path, (gtk.gdk.screen_width() / 10) - 5, + (gtk.gdk.screen_width() / 10) - 5) image.set_from_pixbuf(pix) button.add(image) button.connect('clicked', self._set_path) -- cgit v0.9.1