Re: [firstboot rhel5-branch] Fixed hiding of a dialog window when user clicked on the main window (#511984)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello, please see the comments below

--

  Martin Gracik

----- "Chris Lumens" <clumens@xxxxxxxxxx> wrote:

> > @@ -43,6 +45,11 @@ class childWindow:
> >      moduleName = (_("Network Setup"))
> >      moduleClass = "reconfig"
> >  
> > +    needsparent = 1
> 
> Please use "True" instead of 1.
> 
> > @@ -166,6 +173,30 @@ class childWindow:
> >          #Run rhn_register so they can register with RHN
> >          pid = start_process("/usr/bin/system-config-network")
> >  
> > +        # get the x window id
> > +        xid = None
> > +        start = time.time()
> > +
> > +        # keep trying for 3 seconds
> > +        while xid is None and (time.time() - start < 3):
> > +            rc, out = commands.getstatusoutput('xwininfo -name' \
> > +                    ' "Network Configuration" -int')
> > +            pattern =
> re.compile("xwininfo:\sWindow\sid:\s(?P<xid>\d+)\s.*")
> > +            for line in out.splitlines():
> > +                m = pattern.match(line)
> > +                if m:
> > +                    xid = long(m.group("xid"))
> 
> I assume you're waiting to make sure that system-config-network has
> started.  Did you encounter problems in testing that required
> waiting?

yes, it seems it takes some miliseconds for the system-config-network to create the window,
if i run xwininfo right after system-config-network, i get "no window" error,
so we have to wait some time, just 1 second worked for me, but it may not work on slower systems.
i hope 3 seconds must be enough, otherwise there's some problem, and we ignore the new code.

> 
> I think a more natural way to format this loop is:
> 
>    xid = None
>    i = 0
> 
>    while not xid and i < 3:
>       rc, out = blah
> 
>       pattern = blah
>       for line in out.splitlines():
>          m = blah
>          if m:
>             xid = blah
> 
>       i += 1
>       time.sleep(1)
> 
> This avoids having to calculate time as well as avoids hammering the
> system by calling xwininfo as fast as possible.  Note you're not
> doing
> any sleeping in your loop so as soon as xwininfo exits
> unsuccessfully,
> you're going to try it again.

yeah, i can do it like this

> 
> Note also that you're not checking the return value of
> commands.getstatusoutput.  I hope that out is "" in the case where
> the
> commands fails.

i think i don't need to check the return value, because later on,
i check if i have a window number in xid, so if the command fails,
i have no xid number, and we will get no traceback, but the dialog window
will work as before, that means, it will be hidden when you click somewhere else,
that's a fallback...

> 
> > +        # if we have the xid, embed the window
> > +        if xid is not None:
> 
> You can more simply say:
> 
>    if not xid:

i think you meant, "if xid:",
well, i don't know if it's possible, probably not,
but what if xwininfo returns a window id = 000000 ?
then this check will fail, and that's not what should happen.
i check explicitly for None, because i set it to None in the beginning
of the loop, so if there is something wrong in the xwininfo output,
it will stay as None.

also, maybe it was a stupid article, but i read somewhere, that it's a good
habit to check for None.
maybe you have some experiences where it's not a good idea, tell me why,
i'm happy to learn from someone more experienced

> 
> > +            network_dlg = gtk.gdk.window_foreign_new(xid)
> > +            self.parent.win.realize()
> > +            network_dlg.set_transient_for(self.parent.win.window)
> > +            network_dlg.set_modal_hint(True)
> > +            # XXX if we keep the main window fullscreen,
> > +            # and use alt+tab, the network window is gone forever
> > +            self.parent.win.unfullscreen()
> > +
> >          flag = None
> >          while not flag:
> >              while gtk.events_pending():
> > @@ -178,5 +209,8 @@ class childWindow:
> >              else:
> >                  time.sleep(0.1)
> >  
> > +        # make the main window fullscreen again
> > +        self.parent.win.fullscreen()
> > +
> >          i.grab_remove ()
> >          self.updateLabels()
> 
> I can't really speak to the window manipulations here, so I'll assume
> if
> it works and avoids the problem of having the gnome panel appear over
> top, it's probably okay.

well the gnome panel still appears, but only when the system-config-network window is opened.
during the rest of the process, the panel is not visible.
i can't figure out what's wrong with it, and how to make it go away,
i tried to talk to guys in #pygtk, but still couldn't figure it out.

> 
> - Chris
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux