From b913f3304616dc6e62819b3ac0ef56a8ac2c88e7 Mon Sep 17 00:00:00 2001 From: Daniel Francis Date: Sun, 15 Jul 2012 20:13:57 +0000 Subject: Fixing bufs, conecting size changing --- diff --git a/cover.py b/cover.py index 3fe3ebf..6413aee 100644 --- a/cover.py +++ b/cover.py @@ -1,23 +1,21 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# cover.py +# Copyright 2012 S. Daniel Francis # -# Copyright 2012 S. Daniel Francis +# 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 3 of the License. # -# 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 3 of the License. +# 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. # -# 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. +# 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. # @@ -294,56 +292,6 @@ class CoverSlide(gtk.VPaned): self.pack2(self.images_notebook) self._ready = False self.connect('expose-event', self._expose_event_cb) - """ - images_editing_box = gtk.VBox() - self.images_model = gtk.ListStore(str, bool, int) - self.head_iter = self.images_model.append(["Head Image", False, 1]) - self.head_image_check.connect("toggled", - self.check_display_image, - self.head_iter) - self.background_iter = self.images_model.append(["Background Image", - False, - 2]) - self.background_image_check.connect("toggled", - self.check_display_image, - self.background_iter) - self.cover_iter = self.images_model.append(["Cover Image", False, 3]) - self.cover_image_check.connect("toggled", - self.check_display_image, - self.cover_iter) - self.image_iters = [self.head_iter, - self.background_iter, - self.cover_iter] - self.image_combo = gtk.ComboBox(self.images_model) - cell = gtk.CellRendererText() - self.image_combo.pack_start(cell) - self.image_combo.add_attribute(cell, 'text', 0) - self.image_combo.add_attribute(cell, 'sensitive', 1) - self.image_combo.show() - images_editing_box.pack_start(self.image_combo, False, True, 0) - self.images_editing_notebook = gtk.Notebook() - self.images_editing_notebook.set_show_tabs(False) - self.images_editing_notebook.append_page(gtk.Label(), None) - self.head_image_editor = ImageEditor() - self.head_image_editor.show() - self.images_editing_notebook.append_page(self.head_image_editor, None) - self.background_image_editor = ImageEditor() - self.background_image_editor.show() - self.images_editing_notebook.append_page(self.background_image_editor, - None) - self.cover_image_editor = ImageEditor() - self.cover_image_editor.show() - self.images_editing_notebook.append_page(self.cover_image_editor, None) - self.images_editing_notebook.show_all() - self.images_editing_notebook.set_current_page(0) - self.image_combo.connect("changed", self.change_image) - images_editing_box.pack_start(self.images_editing_notebook, - True, - True, - 0) - images_editing_box.show() - hbox.pack_start(images_editing_box, True, True, 0) - """ self.slide_title = gtk.Entry() self.slide_title.set_text("Cover Slide") self.slide_title.show() @@ -355,6 +303,10 @@ class CoverSlide(gtk.VPaned): self.images_notebook.set_current_page( self.images_check_model.get_value(_iter, 2)) + page_num = self.images_notebook.get_current_page() + child = self.images_notebook.get_nth_page(page_num) + child.setup_toolbar() + return True def _expose_event_cb(self, widget, event): @@ -370,15 +322,26 @@ class CoverSlide(gtk.VPaned): #FIXME, Need to select an active row or unselect all. if not self.images_check_model[path][0]: selection = self.images_check_view.get_selection() - selection.unselect_iter(self.images_check_model.get_iter(path)) - self.images_notebook.set_current_page(0) - _iter = self.images_check_model.get_iter_first() - while _iter != None: - if self.images_check_model[_iter][2]: - selection.select_iter(_iter) - break - else: - _iter = self.images_check_model.iter_next(_iter) + if self.images_notebook.get_current_page() !=\ + self.images_check_model[path][2]: + _iter = self.imamages_check_model.get_iter_first() + while _iter != None: + if self.images_check_model[_iter][2] ==\ + self.images_notebook.get_current_page(): + selection.select_iter(_iter) + break + else: + self.images_check_model.iter_next(_iter) + else: + #selection.unselect_iter(self.images_check_model.get_iter(path)) + self.images_notebook.set_current_page(0) + _iter = self.images_check_model.get_iter_first() + while _iter != None: + if self.images_check_model[_iter][2]: + selection.select_iter(_iter) + break + else: + _iter = self.images_check_model.iter_next(_iter) def change_image(self, widget): active_iter = self.image_combo.get_active_iter() diff --git a/toolbars.py b/toolbars.py index 009ea36..ad38b93 100644 --- a/toolbars.py +++ b/toolbars.py @@ -209,7 +209,7 @@ class ImageToolbar(gtk.Toolbar): self.show_all() def get_picture_size(self): - return self.width_entry.get_value(), self.height_entry.get_value() + return [self.width_entry.get_value(), self.height_entry.get_value()] def emit_size(self, widget): self.emit('size-changed') diff --git a/widgets.py b/widgets.py index e03b297..eccee7f 100644 --- a/widgets.py +++ b/widgets.py @@ -88,18 +88,21 @@ class ImageEditor(gtk.Notebook): targetType, time): self.image = self.emit("get-image-from-galery", selection.data) - self.toolbar = self.emit("load-toolbar") - self.toolbar.connect_temporary('size-changed', self.size_changed_cb) self.main_pixbuf = self.image.render_to_preview() self.pixbuf = self.image.render_to_preview() self.image_widget.set_from_pixbuf(self.pixbuf) - self.set_current_page(1) - self.toolbar.set_sensitive(True) - self.toolbar.width_entry.set_value(self.image.width) - self.toolbar.height_entry.set_value(self.image.height) - self.toolbar.link_values_button.set_active(True) self.width = self.image.width self.height = self.image.height + self.set_current_page(1) + self.setup_toolbar() + + def setup_toolbar(self): + if self.get_current_page() == 1: + self.toolbar = self.emit("load-toolbar") + self.toolbar.connect_temporary('size-changed', self.size_changed_cb) + self.toolbar.width_entry.set_value(self.image.width) + self.toolbar.height_entry.set_value(self.image.height) + self.toolbar.link_values_button.set_active(True) def size_changed_cb(self, widget): width, height = self.toolbar.get_picture_size() -- cgit v0.9.1