GObject constructor silently accepts and ignores positional arguments

Bug #1248152 reported by Alberto Milone
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pygobject
Fix Released
Medium
pygobject (Ubuntu)
Fix Released
Low
Martin Pitt

Bug Description

Using the python bindings, creating a filechooser widget, there's no way to display the "create folder" icon. This seems to work fine in C.

There are two ways to reproduce this:
1) Gtk.FileChooserWidget(parent, Gtk.FileChooserAction.CREATE_FOLDER)
2) Gtk.FileChooserWidget(parent, Gtk.FileChooserAction.SELECT_FOLDER)
and then call widget.set_create_folders(True)

It all works fine when using a Gtk.FileChooserDialog but I really need to embed a filechooser widget in a Gtk.Assistant dialog.

This affects 12.04 and 13.10.

affects: gtk+3.0 (Ubuntu) → ubuntu
Changed in ubuntu:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Alberto Milone (albertomilone) wrote :

In the attached example, the first two buttons use FileChooserDialogs whereas the last two buttons use FileChooserWidgets.

If you pass any argument to the program (e.g. "python chooser_bug.py hack") my hack will kick in and things will work as expected. It's a hack though and the python bindings should really show the button if the calls request it.

Revision history for this message
Martin Pitt (pitti) wrote :

I don't understand this:

        chooser = Gtk.FileChooserWidget(self,
                  Gtk.FileChooserAction.SELECT_FOLDER)

What is the "self" there? As far as I can see, you should call the proper constructor:

        chooser = Gtk.FileChooserWidget.new(Gtk.FileChooserAction.SELECT_FOLDER)

Gtk.FileChooserWidget() calls the GObject constructor, but it seems GtkFileChooserWidget doesn't actually expose the action as a property (which is odd, most other widgets to). It works fine with that.

In principle, your style of invocation should be invalid and generate an exception. The lack of an exception is what's causing this confusion, I'll have a closer look there.

affects: ubuntu → pygobject (Ubuntu)
Revision history for this message
Alberto Milone (albertomilone) wrote :

Yes, same problem without passing the "self" (I've just noticed that the parent widget is not needed)

Martin Pitt (pitti)
summary: - Gtk.FileChooserWidget won't show the "create folder" button
+ GObject constructor silently accepts and ignores positional arguments
Martin Pitt (pitti)
Changed in pygobject (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
status: Confirmed → Triaged
Revision history for this message
Martin Pitt (pitti) wrote :

This can't be fixed fully as long as we still support the old PyGTK style constructors, but this should at least avoid most pitfalls:

https://git.gnome.org/browse/pygobject/commit/?id=7193f050

Changed in pygobject (Ubuntu):
assignee: Martin Pitt (pitti) → nobody
status: Triaged → Fix Committed
importance: Medium → Low
assignee: nobody → Martin Pitt (pitti)
Changed in pygobject:
importance: Unknown → Medium
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pygobject - 3.11.3-0ubuntu1

---------------
pygobject (3.11.3-0ubuntu1) trusty; urgency=medium

  * New upstream release.
    - Warn about wrong positional GObject constructor arguments (they are
      all deprecated now). (LP: #1248152)
 -- Martin Pitt <email address hidden> Fri, 10 Jan 2014 11:59:03 +0100

Changed in pygobject (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.