app: change serialization of the right docks width in SWM (again)

Use "right-docks-width" and always a positive value instead of
"right-docks-position" (as opponsed to "left-docks-width", that
distinction is a GtkPaned implementation detail and does not belong
into a config file). Parse all old values too. Also fix a glitch in
the deserialization code which might fix bug #700147.
This commit is contained in:
Michael Natterer 2013-05-13 00:00:57 +02:00
parent 8320381885
commit a078ca3f5f
3 changed files with 47 additions and 35 deletions

View File

@ -66,12 +66,11 @@
#define GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID "gimp-empty-image-window"
#define GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID "gimp-single-image-window"
/* GtkPaned position of the image area, i.e. the width of the left
* docks area
*/
#define GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH "left-docks-width"
/* The width of the left and right dock areas */
#define GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH "left-docks-width"
#define GIMP_IMAGE_WINDOW_RIGHT_DOCKS_WIDTH "right-docks-width"
/* GtkPaned position of the right docks area */
/* deprecated property: GtkPaned position of the right docks area */
#define GIMP_IMAGE_WINDOW_RIGHT_DOCKS_POS "right-docks-position"
/* Whether the window's maximized or not */
@ -827,18 +826,17 @@ gimp_image_window_get_aux_info (GimpSessionManaged *session_managed)
g_snprintf (widthbuf, sizeof (widthbuf), "%d",
gtk_paned_get_position (GTK_PANED (private->left_hpane)));
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH, widthbuf);
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH,
widthbuf);
aux_info = g_list_append (aux_info, aux);
gtk_widget_get_allocation (private->right_hpane, &allocation);
/* a negative number will be interpreted as the width of the second
* child of the pane
*/
g_snprintf (widthbuf, sizeof (widthbuf), "%d",
gtk_paned_get_position (GTK_PANED (private->right_hpane)) -
allocation.width);
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_RIGHT_DOCKS_POS, widthbuf);
allocation.width -
gtk_paned_get_position (GTK_PANED (private->right_hpane)));
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_RIGHT_DOCKS_WIDTH,
widthbuf);
aux_info = g_list_append (aux_info, aux);
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_MAXIMIZED,
@ -851,21 +849,21 @@ gimp_image_window_get_aux_info (GimpSessionManaged *session_managed)
}
static void
gimp_image_window_set_right_hpane_position (GtkPaned *paned,
GtkAllocation *allocation,
void *data)
gimp_image_window_set_right_docks_width (GtkPaned *paned,
GtkAllocation *allocation,
void *data)
{
gint position = GPOINTER_TO_INT (data);
gint width = GPOINTER_TO_INT (data);
g_return_if_fail (GTK_IS_PANED (paned));
if (position > 0)
gtk_paned_set_position (paned, position);
if (width > 0)
gtk_paned_set_position (paned, allocation->width - width);
else
gtk_paned_set_position (paned, position + allocation->width);
gtk_paned_set_position (paned, - width);
g_signal_handlers_disconnect_by_func (paned,
gimp_image_window_set_right_hpane_position,
gimp_image_window_set_right_docks_width,
data);
}
@ -875,8 +873,8 @@ gimp_image_window_set_aux_info (GimpSessionManaged *session_managed,
{
GimpImageWindowPrivate *private;
GList *iter;
gint left_docks_width = -1;
gint right_docks_pos = -1;
gint left_docks_width = G_MININT;
gint right_docks_width = G_MININT;
gboolean wait_with_right_docks = FALSE;
gboolean maximized = FALSE;
@ -891,18 +889,30 @@ gimp_image_window_set_aux_info (GimpSessionManaged *session_managed,
if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH))
width = &left_docks_width;
else if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_RIGHT_DOCKS_WIDTH))
width = &right_docks_width;
else if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_RIGHT_DOCKS_POS))
width = &right_docks_pos;
width = &right_docks_width;
else if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_MAXIMIZED))
if (! g_ascii_strcasecmp (aux->value, "yes"))
maximized = TRUE;
if (width)
sscanf (aux->value, "%d", width);
/* compat handling for right docks */
if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_RIGHT_DOCKS_POS))
{
/* negate the value because negative docks pos means docks width,
* also use the negativenes of a real docks pos as condition below.
*/
*width = - *width;
}
}
if (left_docks_width > 0 &&
gtk_paned_get_position (GTK_PANED (private->left_hpane)) != left_docks_width)
if (left_docks_width != G_MININT &&
gtk_paned_get_position (GTK_PANED (private->left_hpane)) !=
left_docks_width)
{
gtk_paned_set_position (GTK_PANED (private->left_hpane), left_docks_width);
@ -913,26 +923,28 @@ gimp_image_window_set_aux_info (GimpSessionManaged *session_managed,
wait_with_right_docks = TRUE;
}
if (right_docks_pos > 0 &&
gtk_paned_get_position (GTK_PANED (private->right_hpane)) != right_docks_pos)
if (right_docks_width != G_MININT &&
gtk_paned_get_position (GTK_PANED (private->right_hpane)) !=
right_docks_width)
{
if (wait_with_right_docks || right_docks_pos < 0)
if (wait_with_right_docks || right_docks_width > 0)
{
/* We must wait on a size allocation before we can set the
/* We must wait for a size allocation before we can set the
* position
*/
g_signal_connect_data (private->right_hpane, "size-allocate",
G_CALLBACK (gimp_image_window_set_right_hpane_position),
GINT_TO_POINTER (right_docks_pos), NULL,
G_CALLBACK (gimp_image_window_set_right_docks_width),
GINT_TO_POINTER (right_docks_width), NULL,
G_CONNECT_AFTER);
}
else
{
/* We can set the position directly, because we didn't
* change the left hpane position
* change the left hpane position, and we got the old compat
* dock pos property.
*/
gtk_paned_set_position (GTK_PANED (private->right_hpane),
right_docks_pos);
- right_docks_width);
}
}

View File

@ -23,7 +23,7 @@
(open-on-exit)
(aux-info
(left-docks-width "80")
(right-docks-position "200")
(right-docks-width "400")
(maximized "no"))
(gimp-toolbox
(side left))

View File

@ -23,7 +23,7 @@
(open-on-exit)
(aux-info
(left-docks-width "80")
(right-docks-position "-764")
(right-docks-width "400")
(maximized "no"))
(gimp-toolbox
(side left))