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 167603 - gtk.show_about_dialog() not wrapped
gtk.show_about_dialog() not wrapped
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: gtk
Git Master
Other Linux
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2005-02-16 14:38 UTC by Mark McLoughlin
Modified: 2008-06-10 21:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Doesn't quite work (3.20 KB, patch)
2005-11-04 22:29 UTC, Christopher Aillon
none Details | Review
Working patch (3.44 KB, patch)
2005-11-05 00:50 UTC, Christopher Aillon
none Details | Review
Updated patch (2.87 KB, patch)
2006-03-08 05:46 UTC, Christopher Aillon
needs-work Details | Review
updated patch (2.65 KB, patch)
2006-04-12 14:52 UTC, Christopher Aillon
none Details | Review
Updated once again (2.49 KB, patch)
2007-12-27 14:11 UTC, Christopher Aillon
committed Details | Review
testcase (833 bytes, text/plain)
2007-12-27 14:13 UTC, Christopher Aillon
  Details

Description Mark McLoughlin 2005-02-16 14:38:08 UTC
Seems worthwhile to track this one bugzilla:

  Could not write function show_about_dialog: varargs functions not supported

Its just a utility wrapper, but it saves a lot of hassle.
Comment 1 Johan (not receiving bugmail) Dahlin 2005-06-24 15:24:57 UTC
Perhaps we can provide a similar function written in pure python?

What did you end up doing in your application?
Comment 2 Mark McLoughlin 2005-06-26 18:56:42 UTC
I ended up writing a python version of it:

http://cvs.gnome.org/viewcvs/*checkout*/sabayon/admin-tool/aboutdialog.py
Comment 3 Christopher Aillon 2005-11-04 22:29:37 UTC
Created attachment 54324 [details] [review]
Doesn't quite work

Start of an implementation which doesn't really work yet...

Issues still are:
* When dialog appears, it is empty.
* Trying to set a GStrv property results in 

>>> gtk.show_about_dialog (None, name="Foo", version="1.0", comments="Foo is a
program for the GNOME Desktop which does Bar", copyright="2005 caillon",
authors=["caillon"])
Parent is: (nil)
Dialog is: (nil)
No Dialog
Have kwargs
Parsing Property name: 'name'
Setting property: name
Parsing Property name: 'version'
Setting property: version
Parsing Property name: 'comments'
Setting property: comments
Parsing Property name: 'copyright'
Setting property: copyright
Parsing Property name: 'authors'
__main__:1: Warning: gvalue.c:89: cannot initialize GValue with type `GStrv',
the value has already been initialized as `GStrv'
Setting property: authors
Comment 4 Christopher Aillon 2005-11-04 23:24:50 UTC
(Gah, the dialog was empty because I forgot to run gtk.main() from the python
console).
Comment 5 Christopher Aillon 2005-11-05 00:50:01 UTC
Created attachment 54333 [details] [review]
Working patch

Okay, this works.  I needed to remove the g_value_init () in
_pyg_strv_to_gvalue () as other to_gvalue methods don't call it, and callers
don't expect this to happen.
Comment 6 Christopher Aillon 2006-03-08 05:46:28 UTC
Created attachment 60884 [details] [review]
Updated patch

Only a few minor tweaks, and removes the already-committed portion of this patch.
Comment 7 Gustavo Carneiro 2006-04-02 17:33:50 UTC
Comment on attachment 60884 [details] [review]
Updated patch

[...]
>+	if (!dialog) {
>+		dialog = gtk_about_dialog_new ();
>+
>+		g_object_ref (dialog);
>+		gtk_object_sink (GTK_OBJECT (dialog));
>+
>+		g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);

  On gtk+ sources I also found this code at this point:

      /* Close dialog on user response */
      g_signal_connect (dialog, "response", G_CALLBACK (close_cb), NULL);


>+
>+		if (kwargs) {
>+			int pos = 0;
>+			PyObject *py_prop_name;
>+			PyObject *py_prop_value;
>+
>+			while (PyDict_Next (kwargs, &pos, &py_prop_name, &py_prop_value)) {
>+				GParamSpec *pspec;
>+				const gchar *property_name;
>+				GValue property_gvalue = { 0, };
>+
>+				property_name = PyString_AsString (py_prop_name);
>+
>+				klass = G_OBJECT_CLASS (GTK_ABOUT_DIALOG_GET_CLASS(dialog));
>+
>+				pspec = g_object_class_find_property (klass, property_name);
>+				if (!pspec) {
>+					PyErr_Format(PyExc_TypeError,
>+					             "Gtk.AboutDialog doesn't support property `%s'",
>+					             property_name);
>+					break;

  Error handling here is incorrect.  If you break, the function continues to create the about dialog and returns None.  But whenever one raises an exception NULL must be returned, after any necessary cleanup.

>+				}
>+
>+				g_value_init (&property_gvalue, G_PARAM_SPEC_VALUE_TYPE(pspec));
>+				if (pyg_param_gvalue_from_pyobject(&property_gvalue, py_prop_value) < 0) {
>+					PyErr_Format(PyExc_TypeError,
>+					             "could not convert value for property `%s'",
>+					             property_name);
>+					g_value_unset (&property_gvalue);
>+					break;

  Same comment as above.

>+				}
>+
>+				g_object_set_property (G_OBJECT (dialog), property_name, &property_gvalue);
>+				g_value_unset (&property_gvalue);
>+			}
>+		}
[...]
Comment 8 Christopher Aillon 2006-04-03 09:03:03 UTC
Okay, will update this soon with a new patch (currently travelling).
Comment 9 Christopher Aillon 2006-04-12 14:52:09 UTC
Created attachment 63314 [details] [review]
updated patch

So, the missing bit that gcj pointed out is a brand new addition to GTK+ sources, and it relies on the private portion, so we can't easily duplicate its functionality.  So, rather than attempt to do so, I'll just destroy the widget each time its closed instead of keeping a copy in memory.  I don't believe this is a big deal anyway.

(Note that I haven't actually tested with this patch yet.)
Comment 10 Gustavo Carneiro 2006-04-12 17:48:13 UTC
It seems that now you don't have a global variable pointing to the about dialog, so if the user does Help->About twice it gets two dialogs.

BTW, shouldn't this be implemented in python (on gtk/__init__.py) instead?...
Comment 11 Christopher Aillon 2006-04-12 22:03:34 UTC
Correct.  As I said, things moved around in GTK.  So I can leak or be agressive in destruction as I am now.
Comment 12 Christopher Aillon 2007-05-04 13:06:31 UTC
To default owner.  Hopefully someone can find time to merge this.
Comment 13 Johan (not receiving bugmail) Dahlin 2007-05-04 13:33:14 UTC
(In reply to comment #9)
> Created an attachment (id=63314) [edit]
> updated patch
> 
> So, the missing bit that gcj pointed out is a brand new addition to GTK+
> sources, and it relies on the private portion, so we can't easily duplicate its
> functionality.  So, rather than attempt to do so, I'll just destroy the widget
> each time its closed instead of keeping a copy in memory.  I don't believe this
> is a big deal anyway.
> 
> (Note that I haven't actually tested with this patch yet.)
> 

In general this looks good.
It would be even easier to accept the patch if you could submit a test to make sure that it works.
Remember, there's no need to test what the C function does, only the wrapper itself.
Comment 14 Christopher Aillon 2007-12-27 14:11:32 UTC
Created attachment 101674 [details] [review]
Updated once again

Only minor changes since the last one, for API changes.
Comment 15 Christopher Aillon 2007-12-27 14:13:12 UTC
Created attachment 101675 [details]
testcase

Just a quick python testcase
Comment 16 Gian Mario Tagliaretti 2008-06-07 19:08:17 UTC
jdahlin I think we should push this one in trunk now.
Comment 17 Johan (not receiving bugmail) Dahlin 2008-06-08 22:39:41 UTC
Sure, let's commit it
Comment 18 Gian Mario Tagliaretti 2008-06-10 21:33:43 UTC
I've fixed the indentation and 80 columns layout.


Sending        ChangeLog
Sending        gtk/gtk.override
Transmitting file data ..
Committed revision 2993.