After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 667158 - Constructor for GdlDockBar loses 'dock' argument with gobject introspection
Constructor for GdlDockBar loses 'dock' argument with gobject introspection
Status: RESOLVED FIXED
Product: gdl
Classification: Other
Component: general
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: Anjuta maintainers
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2012-01-03 00:53 UTC by Micah Carrick
Modified: 2012-10-13 13:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Micah Carrick 2012-01-03 00:53:37 UTC
I don't have a solid enough understanding of introspection internals to know *why* this is happening. Perhaps it's something that could be fixed with annotations or perhaps it needs an override. In any case, I figured it should be noted in a bug report.

When using gdl from Python with introspection, the 'dock' argument does not get passed to the normal constructor for Gdl.DockBar and thus, the constructor cannot pull the "master" property from the dock. As a result, dock items that are minimized are effectively lost. 

It probably makes more sense with some code:

from gi.repository import Gdl
...
dock = Gdl.Dock
dockbar = Gdl.DockBar(dock) # will not work

# workaround #1
dockbar = Gdl.DockBar.new(dock)

# workaround #2
dockbar = Gdl.DockBar()
dockbar.set_property("master", dock.get_property("master")

I'm not sure if introspection usually "maps" constructors to the *_new() function automatically or if that's done with annotations or overrides or some other mechanism. But, Python folks are going to want the constructor to work like gdl_dock_bar_new().
Comment 1 Johannes Schmid 2012-01-03 08:02:24 UTC
This is bad style in the C code which makes it impossible for introspection to work. Thanks for reporting, I will have a look at it.

    /* get the master of the given dock */
    if (dock)
        master = GDL_DOCK_OBJECT_GET_MASTER (dock);

    return g_object_new (GDL_TYPE_DOCK_BAR,
                         "master", master, NULL);


Instead of the "master" property there should be a "dock" property, probably CONSTRUCT_ONLY and READ_ONLY.
Comment 2 Sébastien Granjoux 2012-05-17 19:20:58 UTC
I have looked at that bug, I don't think it's really bad style. The workaround #1 is rather the common way to build most objects. There is the same issue with most other objects, by example GdlDockItem.

Anyway, it's possible to add a dock property as proposed by Johannes to make it more Python's like. You will need to use named parameters though, so:
   dock = Gdl.Dock
   dockbar = Gdl.DockBar(dock = dock)

But I think we should keep the master property as it is still useful.


By the way the GdlDockBar object has a dock public member which is useless. I think it would be better to rename it as unused or do you think it's better to keep the name and just add a comment?
Comment 3 Sébastien Granjoux 2012-08-03 20:04:56 UTC
I have changed the master property of the GdlDockBar to accept a GdlDockObject instead of a GdlDockMaster only.

It means that now you can use the master property in python like this:
    dock = Gdl.Dock
    dockbar = Gdl.DockBar(master = dock)

I think it's fine.

I have done the same thing for the dock parameter of the new function, so you can do too
    dock = Gdl.Dock
    dockbar = Gdk.DockBar.new (dock)
Comment 4 Dominique Leuenberger 2012-10-13 12:23:55 UTC
This changed the prototype of gdl_dock_bar_new to no longer require a GdlDock parameter, but now requiring a GObject parameter...

Was this intentional? (Other apps relying on gdl_dock_bar_new fail to build; gtkpod is a prominent example)
Comment 5 Sébastien Granjoux 2012-10-13 12:42:51 UTC
(In reply to comment #4)
> This changed the prototype of gdl_dock_bar_new to no longer require a GdlDock
> parameter, but now requiring a GObject parameter...
> 
> Was this intentional? (Other apps relying on gdl_dock_bar_new fail to build;
> gtkpod is a prominent example)

Sure.

In fact, GdlDockBar requires a GdlDockMaster. Previously, it was possible to set it by setting the master property to the GdlDockMaster or to pass a GdlDock object to the new function. In this last case, the GdlDockBar use the GdlDockMaster of the GdlDock object.

I have changed this to accept a GdlDockMaster or a GdlDock object in both cases. That's why the argument of the new function is a GObject* instead. So in C, you should get only a warning that you can remove with a cast.


I have done quite a lots of changes in GDL to fix bugs and clean up the interface in the previous cycle. I have sent emails on the anjuta-devel mailing list and try to find other users of GDL. Then, I have still tried to minimize the API breaks but I'm using it mostly in C.

I have tried to increment the version number of library correctly too.

Now, if something can be done better, I'm ready to do it.
Comment 6 Dominique Leuenberger 2012-10-13 12:49:31 UTC
Fair enough. Thanks for the explanation.
I'll try to work with GTKPod upstream to fix the current issues.

(They currently use code like
  app->dock = gdl_dock_new();
  dockbar = gdl_dock_bar_new(GDL_DOCK(app->dock));
)

Which *looks* like it should do the right thing...
Comment 7 Sébastien Granjoux 2012-10-13 12:57:50 UTC
(In reply to comment #6)
> (They currently use code like
>   app->dock = gdl_dock_new();
>   dockbar = gdl_dock_bar_new(GDL_DOCK(app->dock));
> )
> 
> Which *looks* like it should do the right thing...

To avoid the warning you should just need to write
   dockbar = gdl_dock_bar_new(G_OBJECT(app->dock));

The code in GDL will check that the object is a GdlDock or a GdlDockMaster.
Comment 8 Dominique Leuenberger 2012-10-13 13:05:38 UTC
Yes, that's also what I did... now running after Anjuta API changes for gtkpod :)

Thanks for your help!