-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 2 Sep 2008 07:44:00 +0200 "Sandro Tosi" <[EMAIL PROTECTED]> wrote:
> Merged (at r643): thanks for this contribution! > > There is a little problem you might want to fix (as I didn't managed > yet to debug): > > $ reportbug --ui gtk2 -O --debug reportbug > Traceback (most recent call last): > File "/usr/bin/reportbug", line 1832, in <module> > main() > File "/usr/bin/reportbug", line 855, in main > return iface.user_interface() > File "/usr/bin/reportbug", line 1570, in user_interface > listcc += ui.get_multiline('Enter any additional addresses this > report should be sent to; press ENTER after each address.') > AttributeError: 'module' object has no attribute 'get_multiline' > > right after the subject insertion and click on "Forward". > Fixed in patch 0001. 0002 patch: Uses a list instead of an editor for CC addresses, which is less error prone. We can yet specify the mode to get_multiline and use the list for < ADVANCED users and the editor for >= ADVANCED users, or if you don't like it just drop the patch. 0003 patch: small but important bug fixes - -- http://syx.googlecode.com - Smalltalk YX http://lethalman.blogspot.com - Thoughts about computer technologies http://www.ammazzatecitutti.org - Ammazzateci tutti -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAki+fpAACgkQw9Qj+8Kak3GYYQCfaj1bl+VzSlTrY4vA8GfCZ0Y7 NJAAn3gUdH/rWtilefePj+28gJy61FSV =/2QJ -----END PGP SIGNATURE-----
From 4b29f5e57853235fefb8127c0cbecb175ca031b2 Mon Sep 17 00:00:00 2001 From: Luca Bruno <[EMAIL PROTECTED]> Date: Wed, 3 Sep 2008 13:02:30 +0200 Subject: [PATCH] fixed GetMultilinePage implementation and added to the forwarded list --- debian/changelog | 1 + reportbug/ui/gtk2_ui.py | 69 +++++++++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/debian/changelog b/debian/changelog index 19bde53..d37ea1f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,7 @@ reportbug (3.99.0) UNRELEASED; urgency=low [ Luca Bruno ] - reportbug/ui/gtk2_ui.py + GTK+ interface + + fixed GetMultilinePage implementation and added to the forwarded list [ Sandro Tosi ] - debian/control diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py index 0f307f1..3d412b2 100644 --- a/reportbug/ui/gtk2_ui.py +++ b/reportbug/ui/gtk2_ui.py @@ -469,7 +469,7 @@ class Page (ReportbugConnector): def validate (self, *args, **kwargs): value = self.get_value () if self.is_valid (value): - self.assistant.application.set_next_value (value) + self.application.set_next_value (value) self.set_page_complete (True) else: self.set_page_complete (False) @@ -503,6 +503,42 @@ class GetStringPage (Page): self.label.set_text (prompt) self.entry.grab_focus () +class GetMultilinePage (Page): + def create_widget (self): + vbox = gtk.VBox (spacing=12) + self.label = gtk.Label () + vbox.pack_start (self.label, expand=False) + + view = gtk.TextView () + self.buffer = view.get_buffer () + scrolled = create_scrollable (view) + vbox.pack_start (scrolled) + return vbox + + def connect_signals (self): + self.buffer.connect ('changed', self.validate) + + def is_valid (self, value): + if self.empty_ok: + return True + else: + return bool (value) + + def get_value (self): + text = self.buffer.get_text (self.buffer.get_start_iter (), self.buffer.get_end_iter ()) + lines = text.split ('\n') + # Remove the trailing empty line at the end + if len (lines) > 0 and not lines[-1].strip (): + del lines[-1] + return text.split ('\n') + + def execute (self, prompt, empty_ok=True): + # The result must be iterable for reportbug even if it's empty and not modified + self.empty_ok = empty_ok + self.label.set_text (prompt) + self.buffer.set_text ("") + self.buffer.emit ('changed') + class TreePage (Page): value_column = None @@ -738,32 +774,6 @@ class FinalMessagePage (LongMessagePage): LongMessagePage.execute (self, *args, **kwargs) self.set_page_title ("Thanks for your report") -class GetMultilinePage (Page): - default_complete = True - - def create_widget (self): - vbox = gtk.VBox (spacing=12) - self.label = gtk.Label () - vbox.pack_start (self.label, expand=False) - - view = gtk.TextView () - self.buffer = view.get_buffer () - scrolled = create_scrollable (view) - vbox.pack_start (scrolled) - return vbox - - def is_valid (self, value): - return True - - def connect_signals (self): - self.buffer.connect ('changed', self.validate) - - def get_value (self): - return self.buffer.get_text (self.buffer.get_start_iter (), self.buffer.get_end_iter ()) - - def execute (self, prompt): - self.label.set_text (prompt) - class EditorPage (Page): def create_widget (self): vbox = gtk.VBox (spacing=6) @@ -1028,7 +1038,8 @@ pages = { 'get_string': GetStringPage, 'display_report': DisplayReportPage, 'final_message': FinalMessagePage, 'spawn_editor': EditorPage, - 'select_options': SelectOptionsPage } + 'select_options': SelectOptionsPage, + 'get_multiline': GetMultilinePage } dialogs = { 'yes_no': YesNoDialog, 'get_filename': GetFilenameDialog, 'display_failure': DisplayFailureDialog, } @@ -1057,7 +1068,7 @@ forward_operations (application, dialogs) def test (): # Write some tests here - asd () + print get_multiline ("Prompt") if __name__ == '__main__': test () -- 1.5.6.5
From 6eac33106fbb970e31c5b7662b3e5023077736e1 Mon Sep 17 00:00:00 2001 From: Luca Bruno <[EMAIL PROTECTED]> Date: Wed, 3 Sep 2008 13:50:07 +0200 Subject: [PATCH] GTK+: added list capability to get_multiline --- debian/changelog | 2 + reportbug/ui/gtk2_ui.py | 155 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 130 insertions(+), 27 deletions(-) diff --git a/debian/changelog b/debian/changelog index d37ea1f..1706b92 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,8 @@ reportbug (3.99.0) UNRELEASED; urgency=low - reportbug/ui/gtk2_ui.py + GTK+ interface + fixed GetMultilinePage implementation and added to the forwarded list + + added CustomDialog and InputStringDialog + + added GetListPage to improve the get_multiline wrapper [ Sandro Tosi ] - debian/control diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py index 3d412b2..6cf97d7 100644 --- a/reportbug/ui/gtk2_ui.py +++ b/reportbug/ui/gtk2_ui.py @@ -78,30 +78,13 @@ def error_dialog (message): dialog.set_title ('Reportbug') dialog.show_all () -class ExceptionDialog (gtk.Dialog): - # Register an exception hook to display an error when the GUI breaks - @classmethod - def create_excepthook (cls, oldhook): - def excepthook (exctype, value, tb): - if oldhook: - oldhook (exctype, value, tb) - application.run_once_in_main_thread (cls.start_dialog, - ''.join (traceback.format_exception (exctype, value, tb))) - return excepthook - - @classmethod - def start_dialog (cls, tb): - try: - dialog = cls (tb) - dialog.show_all () - except: - sys.exit (1) - - def __init__ (self, tb): - gtk.Dialog.__init__ (self, "Reportbug: exception", assistant, +class CustomDialog (gtk.Dialog): + def __init__ (self, stock_image, message, buttons, *args, **kwargs): + gtk.Dialog.__init__ (self, "Reportbug", assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + buttons) # Try following the HIG + self.set_default_response (buttons[-1]) # this is the response of the last button self.set_border_width (5) vbox = gtk.VBox (spacing=10) @@ -115,14 +98,52 @@ class ExceptionDialog (gtk.Dialog): align = gtk.Alignment (0.5, 0.5, 1.0, 1.0) hbox.pack_start (align, expand=False) - image = gtk.image_new_from_stock (gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG) + image = gtk.image_new_from_stock (stock_image, gtk.ICON_SIZE_DIALOG) hbox.pack_start (image) - label = gtk.Label ("An error has occurred while doing an operation in Reportbug.\nPlease report the bug.") + label = gtk.Label (message) label.set_line_wrap (True) label.set_justify (gtk.JUSTIFY_FILL) hbox.pack_start (label, expand=False) + self.setup_dialog (vbox, *args, **kwargs) + +class InputStringDialog (CustomDialog): + def __init__ (self, message): + CustomDialog.__init__ (self, gtk.STOCK_DIALOG_INFO, message, + (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) + + def setup_dialog (self, vbox): + self.entry = gtk.Entry () + vbox.pack_start (self.entry, expand=False) + + def get_value (self): + return self.entry.get_text () + +class ExceptionDialog (CustomDialog): + # Register an exception hook to display an error when the GUI breaks + @classmethod + def create_excepthook (cls, oldhook): + def excepthook (exctype, value, tb): + if oldhook: + oldhook (exctype, value, tb) + application.run_once_in_main_thread (cls.start_dialog, + ''.join (traceback.format_exception (exctype, value, tb))) + return excepthook + + @classmethod + def start_dialog (cls, tb): + try: + dialog = cls (tb) + dialog.show_all () + except: + sys.exit (1) + + def __init__ (self, tb): + CustomDialog.__init__ (self, gtk.STOCK_DIALOG_ERROR, "An error has occurred while doing an operation in Reportbug.\nPlease report the bug.", (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE), tb) + + def setup_dialog (self, vbox, tb): # The traceback expander = gtk.Expander ("More details") vbox.pack_start (expander) @@ -501,7 +522,7 @@ class GetStringPage (Page): def execute (self, prompt, options=None, force_prompt=False, default=''): self.label.set_text (prompt) - self.entry.grab_focus () + self.entry.set_text (default) class GetMultilinePage (Page): def create_widget (self): @@ -561,6 +582,79 @@ class TreePage (Page): return result[0] return result +class GetListPage (TreePage): + value_column = 0 + + def create_widget (self): + vbox = gtk.VBox (spacing=12) + self.label = gtk.Label () + vbox.pack_start (self.label, expand=False) + + hbox = gtk.HBox (spacing=6) + + self.view = gtk.TreeView () + self.view.set_rules_hint (True) + self.view.get_selection().set_mode (gtk.SELECTION_MULTIPLE) + scrolled = create_scrollable (self.view) + hbox.pack_start (scrolled) + + bbox = gtk.VButtonBox () + bbox.set_spacing (6) + bbox.set_layout (gtk.BUTTONBOX_START) + button = gtk.Button (stock=gtk.STOCK_ADD) + button.connect ('clicked', self.on_add) + bbox.pack_start (button, expand=False) + button = gtk.Button (stock=gtk.STOCK_REMOVE) + button.connect ('clicked', self.on_remove) + bbox.pack_start (button, expand=False) + hbox.pack_start (bbox, expand=False) + + vbox.pack_start (hbox) + return vbox + + def get_value (self): + values = [] + for row in self.model: + values.append (row[self.value_column]) + return values + + def is_valid (self, value): + if self.empty_ok: + return True + else: + return bool (value) + + def on_add (self, button): + dialog = InputStringDialog ("Add a new item to the list") + dialog.show_all () + dialog.connect ('response', self.on_add_dialog_response) + + def on_add_dialog_response (self, dialog, res): + if res == gtk.RESPONSE_ACCEPT: + self.model.append ([dialog.get_value ()]) + dialog.destroy () + + def on_remove (self, button): + model, paths = self.selection.get_selected_rows () + # We need to transform them to iters, since paths change when removing rows + iters = [] + for path in paths: + iters.append (self.model.get_iter (path)) + for iter in iters: + self.model.remove (iter) + + def execute (self, prompt, empty_ok=True): + self.empty_ok = empty_ok + self.label.set_text (prompt) + + self.model = gtk.ListStore (str) + self.model.connect ('row-changed', self.validate) + self.view.set_model (self.model) + + self.selection.set_mode (gtk.SELECTION_MULTIPLE) + + self.view.append_column (gtk.TreeViewColumn ('Item', gtk.CellRendererText (), text=0)) + class MenuPage (TreePage): value_column = 0 @@ -1031,6 +1125,13 @@ def select_multiple (*args, **kwargs): kwargs['empty_ok'] = True return menu (*args, **kwargs) +def get_multiline (prompt, *args, **kwargs): + if 'ENTER' in prompt: + # This is a list, let's handle it the best way + return get_list (prompt, *args, **kwargs) + else: + return get_multiline (prompt, *args, **kwargs) + pages = { 'get_string': GetStringPage, 'menu': MenuPage, 'handle_bts_query': HandleBTSQueryPage, @@ -1039,7 +1140,7 @@ pages = { 'get_string': GetStringPage, 'final_message': FinalMessagePage, 'spawn_editor': EditorPage, 'select_options': SelectOptionsPage, - 'get_multiline': GetMultilinePage } + 'get_list': GetListPage } dialogs = { 'yes_no': YesNoDialog, 'get_filename': GetFilenameDialog, 'display_failure': DisplayFailureDialog, } @@ -1068,7 +1169,7 @@ forward_operations (application, dialogs) def test (): # Write some tests here - print get_multiline ("Prompt") + print get_multiline ("ENTER") if __name__ == '__main__': test () -- 1.5.6.5
From 287bafaf5870b3bde5664d76f8f0cc561fa7f35e Mon Sep 17 00:00:00 2001 From: Luca Bruno <[EMAIL PROTECTED]> Date: Wed, 3 Sep 2008 14:04:30 +0200 Subject: [PATCH] Fixed return value for default entries in select_options wrapper. Fixed long_message layout --- debian/changelog | 2 ++ reportbug/ui/gtk2_ui.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1706b92..475ca37 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,8 @@ reportbug (3.99.0) UNRELEASED; urgency=low + fixed GetMultilinePage implementation and added to the forwarded list + added CustomDialog and InputStringDialog + added GetListPage to improve the get_multiline wrapper + + fixed return value for default entries in select_options wrapper + + fixed long_message layout [ Sandro Tosi ] - debian/control diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py index 6cf97d7..6eaee17 100644 --- a/reportbug/ui/gtk2_ui.py +++ b/reportbug/ui/gtk2_ui.py @@ -848,6 +848,8 @@ class LongMessagePage (Page): def create_widget (self): self.label = gtk.Label () + self.label.set_line_wrap (True) + self.label.set_justify (gtk.JUSTIFY_FILL) eb = gtk.EventBox () eb.add (self.label) return eb @@ -937,7 +939,7 @@ class EditorPage (Page): self.info_buffer.set_text (info) class SelectOptionsPage (Page): - default_complete = True + default_complete = False def create_widget (self): self.label = gtk.Label () @@ -960,7 +962,7 @@ class SelectOptionsPage (Page): if 'Change editor' in desc: continue button = gtk.Button (options[menuopt.lower ()]) - button.connect ('clicked', self.on_clicked, menuopt) + button.connect ('clicked', self.on_clicked, menuopt.lower ()) if menuopt.isupper (): default = button buttons.insert (0, gtk.HSeparator ()) -- 1.5.6.5
_______________________________________________ Reportbug-maint mailing list Reportbug-maint@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/reportbug-maint