Merge in some pending patches from Sun

- correct unregistration of keybindings in a multiheaded environment
- have top level window icons respect icon themes
This commit is contained in:
Jody Goldberg 2004-04-07 14:33:18 +00:00
parent e967f6c23f
commit 2908fb0c57
4 changed files with 107 additions and 17 deletions

3
NEWS
View file

@ -4,6 +4,9 @@ Chris Lahey:
* Fix ordering of themes in theme manager
* Fix sizing of svg backgrounds
Glynn:
* Toplevel window icons should use the icon themes
Jody:
http://bugzilla.gnome.org/show_bug.cgi?id=139190
* Fix uniqueness test for binding special keys with no name

View file

@ -1,3 +1,8 @@
2004-04-07 Jody Goldberg <jody@gnome.org>
http://bugzilla.gnome.org/show_bug.cgi?id=130623
* capplet-util.c (capplet_set_icon) : respect the icon theme
2004-04-01 Jody Goldberg <jody@gnome.org>
* Release 2.6.0.3

View file

@ -353,12 +353,39 @@ void
capplet_set_icon (GtkWidget *window, char const *icon_file_name)
{
char *path;
GdkPixbuf *icon_pixbuf;
char *tmp;
char *p;
GdkPixbuf *icon_pixbuf = NULL;
GnomeIconTheme *icon_theme;
/* First look up from the icon theme */
icon_theme = gnome_icon_theme_new ();
tmp = g_strdup (icon_file_name);
p = strrchr (tmp, '.');
if (p)
p[0] = '\0';
path = gnome_icon_theme_lookup_icon (icon_theme, tmp, 48, NULL, NULL);
if (path != NULL) {
icon_pixbuf = gdk_pixbuf_new_from_file (path, NULL);
g_free (path);
}
g_free (tmp);
g_object_unref (icon_theme);
path = g_strconcat (GNOMECC_DATA_DIR "/icons/", icon_file_name, NULL);
icon_pixbuf = gdk_pixbuf_new_from_file (path, NULL);
g_free (path);
if (icon_pixbuf == NULL) {
/* Then we fallback to the control center icon location */
path = g_strconcat (GNOMECC_DATA_DIR "/icons/", icon_file_name, NULL);
icon_pixbuf = gdk_pixbuf_new_from_file (path, NULL);
g_free (path);
}
if (icon_pixbuf == NULL) {
/* Then we fallback to the gnome program discovery stuff */
path = gnome_pixmap_file (icon_file_name);
if (path != NULL) {
icon_pixbuf = gdk_pixbuf_new_from_file (path, NULL);

View file

@ -61,22 +61,17 @@ get_screens_list (void)
return list;
}
char *
screen_exec_display_string (XEvent *xevent)
extern char **environ;
static char *
screen_exec_display_string (GdkScreen *screen)
{
GString *str;
const char *old_display;
char *retval;
char *p;
GdkScreen *screen = NULL;
GdkWindow *window = gdk_xid_table_lookup (xevent->xkey.root);
if (window)
screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
g_assert (GDK_IS_SCREEN (screen));
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
old_display = gdk_display_get_name (gdk_screen_get_display (screen));
@ -96,6 +91,56 @@ screen_exec_display_string (XEvent *xevent)
return retval;
}
/**
* get_exec_environment:
*
* Description: Modifies the current program environment to
* ensure that $DISPLAY is set such that a launched application
* inheriting this environment would appear on screen.
*
* Returns: a newly-allocated %NULL-terminated array of strings or
* %NULL on error. Use g_strfreev() to free it.
*
* mainly ripped from egg_screen_exec_display_string in
* gnome-panel/egg-screen-exec.c
**/
char **
get_exec_environment (XEvent *xevent)
{
char **retval = NULL;
int i;
int display_index = -1;
GdkScreen *screen = NULL;
GdkWindow *window = gdk_xid_table_lookup (xevent->xkey.root);
if (window)
screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
for (i = 0; environ [i]; i++)
if (!strncmp (environ [i], "DISPLAY", 7))
display_index = i;
if (display_index == -1)
display_index = i++;
retval = g_new (char *, i + 1);
for (i = 0; environ [i]; i++)
if (i == display_index)
retval [i] = screen_exec_display_string (screen);
else
retval [i] = g_strdup (environ [i]);
retval [i] = NULL;
return retval;
}
static gint
compare_bindings (gconstpointer a, gconstpointer b)
{
@ -368,9 +413,8 @@ keybindings_filter (GdkXEvent *gdk_xevent,
&error))
return GDK_FILTER_CONTINUE;
envp = g_new0 (gchar *, 2);
envp [0] = screen_exec_display_string (xevent);
envp [1] = NULL;
envp = get_exec_environment (xevent);
retval = g_spawn_async (NULL,
argv,
@ -405,11 +449,22 @@ keybindings_filter (GdkXEvent *gdk_xevent,
void
gnome_settings_keybindings_init (GConfClient *client)
{
GdkDisplay *dpy = gdk_display_get_default ();
GdkScreen *screen;
int screen_num = gdk_display_get_n_screens (dpy);
int i;
gnome_settings_daemon_register_callback (GCONF_BINDING_DIR, bindings_callback);
gdk_window_add_filter (gdk_get_default_root_window (),
keybindings_filter,
NULL);
for (i = 0; i < screen_num; i++)
{
screen = gdk_display_get_screen (dpy, i);
gdk_window_add_filter (gdk_screen_get_root_window (screen),
keybindings_filter, NULL);
}
}
void