If org.gnome.Panel exists on the bus, replace it rather than using gdb

Avoid depending on gdb for replacing an existing panel, since it
requires debuginfo and gdb installed.

Instead we grab the org.gnome.Panel DBus name, using DBus name
replacement semantics.
This commit is contained in:
Colin Walters 2009-07-21 10:50:18 -04:00
parent e12587619b
commit fdd9b85448
2 changed files with 26 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import tempfile
import termios
import time
import errno
import dbus
def find_cmd (cmd_list):
"""
@ -230,6 +231,15 @@ if options.wide:
metacity_pid = pidof("metacity")
compiz_pid = pidof("compiz.real") or pidof("compiz")
# In Gnome 2.26 the panel grabs a dbus name and allows replacement; use that.
bus = dbus.Interface(dbus.SessionBus().get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'),
'org.freedesktop.DBus')
names = bus.ListNames()
gnome_panel_dbus = 'org.gnome.Panel' in names
if gnome_panel_dbus:
gnome_panel_pid = None
else:
gnome_panel_pid = pidof("gnome-panel")
# Run in Xephyr if gnome-panel is already running and the user didn't
@ -299,7 +309,7 @@ finally:
if options.verbose:
print "Restarting Compiz"
subprocess.Popen(["/usr/bin/compiz"])
if gnome_panel_pid:
if gnome_panel_dbus or gnome_panel_pid:
if options.verbose:
print "Restarting gnome-panel"
subprocess.Popen(["/usr/bin/gnome-panel"])

View File

@ -740,6 +740,18 @@ shell_global_grab_dbus_service (ShellGlobal *global)
exit (0);
}
/* Also grab org.gnome.Panel to replace any existing panel process */
if (!dbus_g_proxy_call (bus, "RequestName", &error,
G_TYPE_STRING, "org.gnome.Panel",
G_TYPE_UINT, DBUS_NAME_FLAG_REPLACE_EXISTING | DBUS_NAME_FLAG_DO_NOT_QUEUE,
G_TYPE_INVALID,
G_TYPE_UINT, &request_name_result,
G_TYPE_INVALID))
{
g_print ("failed to acquire org.gnome.Panel: %s\n", error->message);
exit (1);
}
g_object_unref (bus);
}