summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2002-11-20 04:54:01 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-11-20 04:54:01 +0000
commitb8788e9c0d944a225ca56f1e45b50e583c5a4a28 (patch)
treeb5acee617e4c45d11e85adba0667ac7e8d020823
parent60293ee1892531e2876a1bddd3f355a976e381b3 (diff)
downloadmetacity-b8788e9c0d944a225ca56f1e45b50e583c5a4a28.tar.gz
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.
-rw-r--r--ChangeLog11
-rw-r--r--src/menu.c15
-rw-r--r--src/prefs.c17
3 files changed, 36 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d7c3e8b..509e04d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
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>
+
* src/window.c (meta_window_client_message): do a
recalc_window_features after setting new wm_state in order
to update skip_pager in addition to wm_state_skip_pager
diff --git a/src/menu.c b/src/menu.c
index ea340b9e..335e965b 100644
--- a/src/menu.c
+++ b/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
* memory after use.
*/
-static char *
+static char*
get_workspace_name_with_accel (Display *display,
Window xroot,
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
* return it
*/
+ number = 0;
if (sscanf (name, _("Workspace %d"), &number) == 1)
{
char *new_name;
@@ -171,24 +172,24 @@ get_workspace_name_with_accel (Display *display,
char *new_name;
const char *source;
char *dest;
- source = name;
+
/*
* 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
*/
+ dest = new_name;
+ source = name;
while (*source != '\0')
{
if (*source == '_')
*dest++ = '_';
*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;
}
}
diff --git a/src/prefs.c b/src/prefs.c
index 3b55ca3a..502506e0 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -1602,6 +1602,10 @@ meta_prefs_get_workspace_name (int i)
g_return_val_if_fail (i >= 0 && i < MAX_REASONABLE_WORKSPACES, 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];
}
@@ -1615,6 +1619,19 @@ meta_prefs_change_workspace_name (int i,
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) ||
(name && workspace_names[i] && strcmp (name, workspace_names[i]) == 0))
{