mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
Should really fix #98303
2002-11-19 Havoc Pennington <hp@pobox.com> Should really fix #98303 * src/prefs.c (meta_prefs_change_workspace_name): add bad hack to treat empty string the same as null * src/menu.c (get_workspace_name_with_accel): allocate one more than the length of "name" so we have room for a nul byte (and don't malloc(0) on empty strings). Also some formatting cleanups.
This commit is contained in:
parent
60293ee189
commit
b8788e9c0d
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2002-11-19 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
|
Should really fix #98303
|
||||||
|
|
||||||
|
* src/prefs.c (meta_prefs_change_workspace_name): add
|
||||||
|
bad hack to treat empty string the same as null
|
||||||
|
|
||||||
|
* src/menu.c (get_workspace_name_with_accel): allocate one more
|
||||||
|
than the length of "name" so we have room for a nul byte (and
|
||||||
|
don't malloc(0) on empty strings). Also some formatting cleanups.
|
||||||
|
|
||||||
2002-11-19 Havoc Pennington <hp@pobox.com>
|
2002-11-19 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
* src/window.c (meta_window_client_message): do a
|
* src/window.c (meta_window_client_message): do a
|
||||||
|
15
src/menu.c
15
src/menu.c
@ -131,7 +131,7 @@ activate_cb (GtkWidget *menuitem, gpointer data)
|
|||||||
* The calling code owns the string, and is reponsible to free the
|
* The calling code owns the string, and is reponsible to free the
|
||||||
* memory after use.
|
* memory after use.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char*
|
||||||
get_workspace_name_with_accel (Display *display,
|
get_workspace_name_with_accel (Display *display,
|
||||||
Window xroot,
|
Window xroot,
|
||||||
int index)
|
int index)
|
||||||
@ -148,6 +148,7 @@ get_workspace_name_with_accel (Display *display,
|
|||||||
* integer, insert a '_' before the number if it is less than 10 and
|
* integer, insert a '_' before the number if it is less than 10 and
|
||||||
* return it
|
* return it
|
||||||
*/
|
*/
|
||||||
|
number = 0;
|
||||||
if (sscanf (name, _("Workspace %d"), &number) == 1)
|
if (sscanf (name, _("Workspace %d"), &number) == 1)
|
||||||
{
|
{
|
||||||
char *new_name;
|
char *new_name;
|
||||||
@ -171,24 +172,24 @@ get_workspace_name_with_accel (Display *display,
|
|||||||
char *new_name;
|
char *new_name;
|
||||||
const char *source;
|
const char *source;
|
||||||
char *dest;
|
char *dest;
|
||||||
source = name;
|
|
||||||
/*
|
/*
|
||||||
* Assume the worst case, that every character is a _
|
* Assume the worst case, that every character is a _
|
||||||
*/
|
*/
|
||||||
dest = new_name = g_malloc0 (strlen (name) * 2);
|
new_name = g_malloc0 (strlen (name) * 2 + 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now iterate down the strings, adding '_' to escape as we go
|
* Now iterate down the strings, adding '_' to escape as we go
|
||||||
*/
|
*/
|
||||||
|
dest = new_name;
|
||||||
|
source = name;
|
||||||
while (*source != '\0')
|
while (*source != '\0')
|
||||||
{
|
{
|
||||||
if (*source == '_')
|
if (*source == '_')
|
||||||
*dest++ = '_';
|
*dest++ = '_';
|
||||||
*dest++ = *source++;
|
*dest++ = *source++;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* We don't free *name as we don't own it, and pass ownership of
|
|
||||||
* *new_name to the calling code.
|
|
||||||
*/
|
|
||||||
return new_name;
|
return new_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/prefs.c
17
src/prefs.c
@ -1603,6 +1603,10 @@ meta_prefs_get_workspace_name (int i)
|
|||||||
|
|
||||||
g_assert (workspace_names[i] != NULL);
|
g_assert (workspace_names[i] != NULL);
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_PREFS,
|
||||||
|
"Getting workspace name for %d: \"%s\"\n",
|
||||||
|
i, workspace_names[i]);
|
||||||
|
|
||||||
return workspace_names[i];
|
return workspace_names[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1615,6 +1619,19 @@ meta_prefs_change_workspace_name (int i,
|
|||||||
|
|
||||||
g_return_if_fail (i >= 0 && i < MAX_REASONABLE_WORKSPACES);
|
g_return_if_fail (i >= 0 && i < MAX_REASONABLE_WORKSPACES);
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_PREFS,
|
||||||
|
"Changing name of workspace %d to %s\n",
|
||||||
|
i, name ? name : "none");
|
||||||
|
|
||||||
|
/* This is a bad hack. We have to treat empty string as
|
||||||
|
* "unset" because the root window property can't contain
|
||||||
|
* null. So it gets empty string instead and we don't want
|
||||||
|
* that to result in setting the empty string as a value that
|
||||||
|
* overrides "unset".
|
||||||
|
*/
|
||||||
|
if (name && *name == '\0')
|
||||||
|
name = NULL;
|
||||||
|
|
||||||
if ((name == NULL && workspace_names[i] == NULL) ||
|
if ((name == NULL && workspace_names[i] == NULL) ||
|
||||||
(name && workspace_names[i] && strcmp (name, workspace_names[i]) == 0))
|
(name && workspace_names[i] && strcmp (name, workspace_names[i]) == 0))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user