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 356011 - gnome.ui.master_client() returns None.
gnome.ui.master_client() returns None.
Status: RESOLVED INVALID
Product: libgnomeui
Classification: Deprecated
Component: general
2.16.x
Other All
: Normal normal
: ---
Assigned To: libgnomeui maintainers
libgnomeui maintainers
Depends on:
Blocks:
 
 
Reported: 2006-09-14 20:22 UTC by Rich Burridge
Modified: 2006-09-15 21:14 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Standalone Python script that reproduces the problem. (9.13 KB, text/x-python)
2006-09-14 20:24 UTC, Rich Burridge
Details

Description Rich Burridge 2006-09-14 20:22:01 UTC
We're working on Orca, a Python based screen reader [1], which
is in GNOME 2.16.

We have a bug [2], where we want to be able to automatically
log the user out, if we've just enabled the "accessibility" Gconf
flag on the desktop.

Gnopernicus (the previous GNOME screen reader written in C)
did this with:

       ...
       if (response_id == GTK_RESPONSE_YES)
       {
           GnomeClient *client = gnome_master_client ();
           if (client)
               gnome_client_request_save (client, GNOME_SAVE_GLOBAL, TRUE,
                                       GNOME_INTERACT_ANY, FALSE, TRUE);
           return TRUE;
       }
       ...

(See about line 572 in .../gnopernicus/gnopi/gnopi.c [3])

We've tried doing what we think is the Python equivalent of this:

import gnome.ui
...
       client = gnome.ui.master_client()
       client.request_save(gnome.ui.SAVE_GLOBAL,  # Save style
                           True,                  # Shutdown
                           gnome.ui.INTERACT_ANY, # Allow user interaction
                           False,                 # Fast
                           True)                  # All apps save state

but could not get the master_client() method to return a
non-null value. See comment #1 in bug #340849.
Comment 1 Rich Burridge 2006-09-14 20:24:09 UTC
Created attachment 72812 [details]
Standalone Python script that reproduces the problem.

bug_340849.py is a small Python script that reproduces the
problem we are seeing.

To run this script, merely type 'python bug_340849.py' in a terminal
window.

To reproduce the problem we are seeing, follow these steps:

0. Make sure you have accessibility turned on:
   If it's not turned on, you will need to do:
     System->Preferences->Assistive Technology Preferences
     Tick the "Enable Assistive Technologies" checkbox
     Then click on Close.
     Then logout and log back in.

1. Run the attached standalone python application in a gnome-terminal
   window.

2. Press F11.
   This will call the getMasterClient() routine, that in turn will call:

    import gnome.ui

    client = gnome.ui.master_client()

   Notice that this returns None.

3. Press the F12 function key to terminate this script.
Comment 2 Gustavo Carneiro 2006-09-15 10:17:22 UTC
The Python wrapper is:

static PyObject *
_wrap_gnome_master_client(PyObject *self)
{
    GnomeClient *ret;
    
    ret = gnome_master_client();
    
    /* pygobject_new handles NULL checking */
    return pygobject_new((GObject *)ret);
}

It has no apparent bug.  Reassigning to libgnomeui.

[ Possibly you are just mis-using the API.  Could it be that you need to create a normal client and call client.connect_to_session_manager() first? ]
Comment 3 Christian Persch 2006-09-15 16:46:24 UTC
Do you (or the libgnome python wrapper) call gnome_program_init with a module list including GNOME_CLIENT_MODULE or LIBGNOMEUI_MODULE ?
Comment 4 Gustavo Carneiro 2006-09-15 16:57:51 UTC
In python, calling gnome.program_init() after importing gnome.ui at least once does that.
Comment 5 Christian Persch 2006-09-15 17:03:32 UTC
The testcase doesn't call this function, so there's no gnome client.

-> INVALID
Comment 6 Rich Burridge 2006-09-15 17:14:37 UTC
Okay, thanks for the pointers. I'm not doing the
gnome.program.init() call, so you are right, this is NOTABUG or
INVALID.

Before you go away, I'd like to know what I should be doing exactly though.

What change to I have to make to the small attached script
to get this working? It'll be in the getMasterClient()
routine, and will be something like:

def getMasterClient():
    print "getMasterClient called:"
    import gnome
    import gnome.ui

    gnome.program_init('orca', '1.0', LIBGNOMEUI_MODULE)
    client = gnome.ui.master_client()
    print "getMasterClient: client: ", client

I tried that and got:

Traceback (most recent call last):
  • File "bug_340849.py", line 176 in notifyEvent
    return self.callback(event)
  • File "bug_340849.py", line 266 in notifyKeystroke
    getMasterClient()
  • File "bug_340849.py", line 244 in getMasterClient
    gnome.program_init('orca', '1.0', LIBGNOMEUI_MODULE)
NameError: global name 'LIBGNOMEUI_MODULE' is not defined


so what should 'LIBGNOMEUI_MODULE' really be?

A secondary question, is where is the documentation for all these 
gnome python bindings? I'm really stumbling in the dark here.

Thanks.
Comment 7 Rich Burridge 2006-09-15 17:22:39 UTC
Never mind. I goggled and found an example:

def getMasterClient():
    print "getMasterClient called:"
    import gnome
    import gnome.ui

    program = gnome.init('orca', '1.0', gnome.libgnome_module_info_get(),
                                 sys.argv, [])
    print "program: ", program
    client = gnome.ui.master_client()
    print "getMasterClient: client: ", client
Comment 8 Gustavo Carneiro 2006-09-15 17:34:12 UTC
(In reply to comment #7)
>     program = gnome.init('orca', '1.0', gnome.libgnome_module_info_get(),
>                                  sys.argv, [])

  You could simplify this to

>     program = gnome.init('orca', '1.0')

with the same effect.
Comment 9 Rich Burridge 2006-09-15 17:38:52 UTC
Cool. Thanks!