Patchwork [bitbake-devel] hob: limit the description size when a custom image is saved

login
register
mail settings
Submitter Cristiana Voicu
Date Sept. 4, 2013, 12:55 p.m.
Message ID <BE68E9C8E0850C43B0F0B0B7D57FA5AE2E86170B@IRSMSX105.ger.corp.intel.com>
Download mbox | patch
Permalink /patch/57355/
State New
Headers show

Comments

Cristiana Voicu - Sept. 4, 2013, 12:55 p.m.
Please do not consider this patch. I will send a new version for it.
Thanks,
Cristiana

-----Original Message-----
From: Voicu, Cristiana 
Sent: Wednesday, September 04, 2013 11:25 AM
To: bitbake-devel@lists.openembedded.org
Cc: Voicu, Cristiana
Subject: [PATCH] hob: limit the description size when a custom image is saved

[YOCTO #5003]
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
---
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

 
         self.show_all()
 
+    def limit_description_length(self, textbuffer, iter, text, length):
+        buffer_bounds = textbuffer.get_bounds()
+        entire_text = textbuffer.get_text(*buffer_bounds)
+        entire_text += text
+        if len(entire_text)>150:
+            textbuffer.emit_stop_by_name("insert-text")
+
     def name_entry_changed(self, entry):
         text = entry.get_text()
         if text == '':
--
1.7.9.5

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py b/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
index 56c00bb..42a4f5b 100644
--- a/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
+++ b/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
@@ -70,7 +70,9 @@  class SaveImageDialog (CrumbsDialog):
         sub_label.set_alignment(0, 0)
         sub_label.set_markup("The description should be less than 150 characters long.")
         self.description_entry = gtk.TextView()
-        self.description_entry.get_buffer().set_text(self.description_field)
+        description_buffer = self.description_entry.get_buffer()
+        description_buffer.set_text(self.description_field)
+        description_buffer.connect("insert-text", 
+ self.limit_description_length)
         self.description_entry.set_wrap_mode(gtk.WRAP_WORD)
         self.description_entry.set_size_request(350,150)
         sub_vbox.pack_start(label, expand=False, fill=False) @@ -108,6 +110,13 @@ class SaveImageDialog (CrumbsDialog):