On Sat, 14 Jan 2017 at 23:36:55 +0000, James Clarke wrote:
> It seems GetMultilinePage's get_value also has a call to get_text without
> the extra parameter, but a grep for GetMultilinePage only shows the class
> definition, with no uses... deletion candidate? From what I can tell, it
> was added in 3739eb89aa, but even then it wasn't being used by anything?
> Anyway, if it needs to stay, the extra True needs to be added to it too.
There's also infinite recursion here, if the prompt doesn't contain ENTER:
def get_multiline(prompt, *args, **kwargs):
_assert_context(reportbug_context)
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)
I suspect that last line was intended to be a GetMultilinePage wrapper.
But I can't actually test this, because the only use of get_multiline()
does have ENTER in its prompt (and it crashes - fix attached).
I also turned on deprecation warnings (python -Wall) and fixed most
of them. Some remain, particularly constructors for dialogs; I don't
know PyGTK well enough to immediately know what it wants there.
S
>From a79911a14a226cd068bdb5d1e8e1bd101e457ea5 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sat, 14 Jan 2017 23:59:01 +0000
Subject: [PATCH 10/14] gtk2_ui: hook up GetMultilinePage the way it was
presumably meant to work
---
reportbug/ui/gtk2_ui.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index f055d23..50bd195 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -1731,7 +1731,7 @@ def get_multiline(prompt, *args, **kwargs):
# This is a list, let's handle it the best way
return get_list(prompt, *args, **kwargs)
else:
- return get_multiline(prompt, *args, **kwargs)
+ return _get_multiline(prompt, *args, **kwargs)
pages = {'get_string': GetStringPage,
'get_password': GetPasswordPage,
@@ -1745,6 +1745,7 @@ pages = {'get_string': GetStringPage,
'select_options': SelectOptionsPage,
'get_list': GetListPage,
'system': SystemPage,
+ '_get_multiline': GetMultilinePage,
}
dialogs = {'yes_no': YesNoDialog,
'get_filename': GetFilenameDialog,
--
2.11.0
>From c94b7604ca402727ea0c01126dab4cfe3464ec05 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sun, 15 Jan 2017 00:21:57 +0000
Subject: [PATCH 11/14] gtk2_ui: Use modern form of constructor for
Gtk.Alignment
The one with positional parameters is no longer supported.
---
reportbug/ui/gtk2_ui.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 50bd195..a6b0e11 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -158,13 +158,16 @@ class CustomDialog(Gtk.Dialog):
hbox = Gtk.HBox(spacing=10)
vbox.pack_start(hbox, False, True, 0)
- align = Gtk.Alignment(0.5, 0.5, 1.0, 1.0)
+ # TODO: deprecated, new code is meant to set the halign/valign/margin
+ # properties on the child widget instead. Also this is probably
+ # useless without having a child widget?
+ align = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0)
hbox.pack_start(align, False, True, 0)
image = Gtk.Image.new_from_stock(stock_image, Gtk.IconSize.DIALOG)
hbox.pack_start(image, True, True, 0)
- label = Gtk.Label(message)
+ label = Gtk.Label(label=message)
label.set_line_wrap(True)
label.set_justify(Gtk.Justification.FILL)
label.set_selectable(True)
@@ -395,7 +398,7 @@ class BugPage(Gtk.EventBox, threading.Thread):
self.bug_status = None
vbox = Gtk.VBox(spacing=12)
- vbox.pack_start(Gtk.Label("Retrieving bug information."), False, True, 0)
+ vbox.pack_start(Gtk.Label(label="Retrieving bug information."), False, True, 0)
self.progress = Gtk.ProgressBar()
self.progress.set_pulse_step(0.01)
@@ -436,7 +439,7 @@ class BugPage(Gtk.EventBox, threading.Thread):
def not_found(self):
_assert_context(ui_context)
self.drop_progressbar()
- self.add(Gtk.Label("The bug can't be fetched or it doesn't exist."))
+ self.add(Gtk.Label(label="The bug can't be fetched or it doesn't exist."))
self.show_all()
def found(self, info):
@@ -446,7 +449,7 @@ class BugPage(Gtk.EventBox, threading.Thread):
bodies = info[1]
vbox = Gtk.VBox(spacing=12)
vbox.set_border_width(12)
- label = Gtk.Label('Description: ' + desc)
+ label = Gtk.Label(label='Description: ' + desc)
label.set_line_wrap(True)
label.set_justify(Gtk.Justification.FILL)
vbox.pack_start(label, False, True, 0)
@@ -465,7 +468,7 @@ class BugPage(Gtk.EventBox, threading.Thread):
vbox.pack_start(scrolled, True, True, 0)
bbox = Gtk.HButtonBox()
- button = Gtk.Button("Open in browser")
+ button = Gtk.Button(label="Open in browser")
button.connect('clicked', self.on_open_browser)
bbox.pack_start(button, True, True, 0)
if not self.queryonly:
--
2.11.0
>From c337a37af96df2c8564f5455bdc41225cd148683 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sun, 15 Jan 2017 00:22:53 +0000
Subject: [PATCH 12/14] gtk2_ui: Reduce deprecation spam by using named
properties
Positional parameters to most GObject constructors are deprecated.
---
reportbug/ui/gtk2_ui.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index a6b0e11..6f7c793 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -472,7 +472,7 @@ class BugPage(Gtk.EventBox, threading.Thread):
button.connect('clicked', self.on_open_browser)
bbox.pack_start(button, True, True, 0)
if not self.queryonly:
- button = Gtk.Button("Reply")
+ button = Gtk.Button(label="Reply")
button.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.BUTTON))
button.connect('clicked', self.on_reply)
bbox.pack_start(button, True, True, 0)
@@ -515,7 +515,7 @@ class BugsDialog(Gtk.Dialog):
def show_bug(self, number, *args):
page = BugPage(self.assistant, self, number, self.queryonly, *args)
- self.notebook.append_page(page, Gtk.Label(number))
+ self.notebook.append_page(page, Gtk.Label(label=number))
page.start()
@@ -705,7 +705,7 @@ class IntroPage(Page):
vbox = Gtk.VBox(spacing=24)
- label = Gtk.Label("""
+ label = Gtk.Label(label="""
<b>Reportbug</b> is a tool designed to make the reporting of bugs in Debian and derived distributions relatively painless.
This wizard will guide you through the bug reporting process step by step.
@@ -1088,11 +1088,11 @@ class HandleBTSQueryPage(TreePage):
def create_widget(self):
_assert_context(ui_context)
vbox = Gtk.VBox(spacing=6)
- self.label = Gtk.Label("List of bugs. Select a bug to retrieve and submit more information.")
+ self.label = Gtk.Label(label="List of bugs. Select a bug to retrieve and submit more information.")
vbox.pack_start(self.label, False, True, 6)
hbox = Gtk.HBox(spacing=6)
- label = Gtk.Label("Filter:")
+ label = Gtk.Label(label="Filter:")
hbox.pack_start(label, False, True, 0)
self.entry = Gtk.Entry()
hbox.pack_start(self.entry, True, True, 0)
@@ -1114,7 +1114,7 @@ class HandleBTSQueryPage(TreePage):
self.view.append_column(column)
vbox.pack_start(scrolled, True, True, 0)
- button = Gtk.Button("Retrieve and submit bug information")
+ button = Gtk.Button(label="Retrieve and submit bug information")
button.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.BUTTON))
button.connect('clicked', self.on_retrieve_info)
vbox.pack_start(button, False, True, 0)
@@ -1300,7 +1300,7 @@ class EditorPage(Page):
_assert_context(ui_context)
vbox = Gtk.VBox(spacing=6)
hbox = Gtk.HBox(spacing=12)
- hbox.pack_start(Gtk.Label("Subject: "), False, True, 0)
+ hbox.pack_start(Gtk.Label(label="Subject: "), False, True, 0)
self.subject = Gtk.Entry()
hbox.pack_start(self.subject, True, True, 0)
vbox.pack_start(hbox, False, True, 0)
@@ -1335,7 +1335,7 @@ class EditorPage(Page):
if gtkspellcheck is NotImplemented:
box = Gtk.EventBox()
- label = Gtk.Label("Please install <b>python-gtkspellcheck</b> to enable spell checking")
+ label = Gtk.Label(label="Please install <b>python-gtkspellcheck</b> to enable spell checking")
label.set_use_markup(True)
label.set_line_wrap(True)
label.set_selectable(True)
@@ -1448,12 +1448,12 @@ class SelectOptionsPage(Page):
continue
# stdout is a textview for us
if 'Print message to stdout' in desc:
- button = Gtk.Button("Display message in a text view")
+ button = Gtk.Button(label="Display message in a text view")
button.connect('clicked', self.on_display_clicked)
buttons.append(button)
else:
button = Gtk.Button()
- label = Gtk.Label(options[menuopt.lower()])
+ label = Gtk.Label(label=options[menuopt.lower()])
button.add(label)
button.connect('clicked', self.on_clicked, menuopt.lower())
if menuopt.isupper():
--
2.11.0
>From f70c4dcc86afdc26f8e60c2a6c9d2829717db81e Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sun, 15 Jan 2017 00:23:11 +0000
Subject: [PATCH 13/14] gtk2_ui: Reduce deprecation spam by using named
constructors
---
reportbug/ui/gtk2_ui.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 6f7c793..5ed0f15 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -716,8 +716,8 @@ This wizard will guide you through the bug reporting process step by step.
label.set_justify(Gtk.Justification.FILL)
vbox.pack_start(label, False, True, 0)
- link = Gtk.LinkButton("http://alioth.debian.org/projects/reportbug",
- "Homepage of reportbug project")
+ link = Gtk.LinkButton.new_with_label("http://alioth.debian.org/projects/reportbug",
+ "Homepage of reportbug project")
vbox.pack_start(link, False, True, 0)
return vbox
@@ -1610,7 +1610,7 @@ class ReportbugAssistant(Gtk.Assistant):
def confirm_exit(self, *args):
_assert_context(ui_context)
- dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ dialog = Gtk.MessageDialog.new(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO,
"Are you sure you want to quit Reportbug?")
response = dialog.run()
@@ -1785,7 +1785,7 @@ def initialize():
except ImportError:
message = """Please install the %s package to use the GTK+(known as 'gtk2' in reportbug) interface.
Falling back to 'text' interface."""
- dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ dialog = Gtk.MessageDialog.new(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, None)
dialog.set_markup(message % "<b>gir1.2-vte-2.91</b>")
dialog.run()
--
2.11.0
>From d171f77237a790d13d6287162fac28231d67c294 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sun, 15 Jan 2017 00:29:24 +0000
Subject: [PATCH 14/14] gtk2_ui: Remove deprecated threading calls that no
longer do anything
---
reportbug/ui/gtk2_ui.py | 5 -----
1 file changed, 5 deletions(-)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 5ed0f15..0388668 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -49,9 +49,6 @@ global Vte
gtkspellcheck = None
-#gtk.set_interactive(0)
-Gdk.threads_init()
-
import sys
import re
import os
@@ -535,9 +532,7 @@ class ReportbugApplication(threading.Thread):
raise AssertionError('Could not acquire UI context')
ui_context.push_thread_default()
- Gdk.threads_enter()
Gtk.main()
- Gdk.threads_leave()
def get_last_value(self):
_assert_context(reportbug_context)
--
2.11.0
_______________________________________________
Reportbug-maint mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reportbug-maint