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:
@ -66,12 +66,11 @@
|
|||||||
#define GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID "gimp-empty-image-window"
|
#define GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID "gimp-empty-image-window"
|
||||||
#define GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID "gimp-single-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
|
/* The width of the left and right dock areas */
|
||||||
* docks area
|
|
||||||
*/
|
|
||||||
#define GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH "left-docks-width"
|
#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"
|
#define GIMP_IMAGE_WINDOW_RIGHT_DOCKS_POS "right-docks-position"
|
||||||
|
|
||||||
/* Whether the window's maximized or not */
|
/* 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",
|
g_snprintf (widthbuf, sizeof (widthbuf), "%d",
|
||||||
gtk_paned_get_position (GTK_PANED (private->left_hpane)));
|
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);
|
aux_info = g_list_append (aux_info, aux);
|
||||||
|
|
||||||
gtk_widget_get_allocation (private->right_hpane, &allocation);
|
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",
|
g_snprintf (widthbuf, sizeof (widthbuf), "%d",
|
||||||
gtk_paned_get_position (GTK_PANED (private->right_hpane)) -
|
allocation.width -
|
||||||
allocation.width);
|
gtk_paned_get_position (GTK_PANED (private->right_hpane)));
|
||||||
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_RIGHT_DOCKS_POS, widthbuf);
|
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_RIGHT_DOCKS_WIDTH,
|
||||||
|
widthbuf);
|
||||||
aux_info = g_list_append (aux_info, aux);
|
aux_info = g_list_append (aux_info, aux);
|
||||||
|
|
||||||
aux = gimp_session_info_aux_new (GIMP_IMAGE_WINDOW_MAXIMIZED,
|
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
|
static void
|
||||||
gimp_image_window_set_right_hpane_position (GtkPaned *paned,
|
gimp_image_window_set_right_docks_width (GtkPaned *paned,
|
||||||
GtkAllocation *allocation,
|
GtkAllocation *allocation,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
gint position = GPOINTER_TO_INT (data);
|
gint width = GPOINTER_TO_INT (data);
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_PANED (paned));
|
g_return_if_fail (GTK_IS_PANED (paned));
|
||||||
|
|
||||||
if (position > 0)
|
if (width > 0)
|
||||||
gtk_paned_set_position (paned, position);
|
gtk_paned_set_position (paned, allocation->width - width);
|
||||||
else
|
else
|
||||||
gtk_paned_set_position (paned, position + allocation->width);
|
gtk_paned_set_position (paned, - width);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (paned,
|
g_signal_handlers_disconnect_by_func (paned,
|
||||||
gimp_image_window_set_right_hpane_position,
|
gimp_image_window_set_right_docks_width,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,8 +873,8 @@ gimp_image_window_set_aux_info (GimpSessionManaged *session_managed,
|
|||||||
{
|
{
|
||||||
GimpImageWindowPrivate *private;
|
GimpImageWindowPrivate *private;
|
||||||
GList *iter;
|
GList *iter;
|
||||||
gint left_docks_width = -1;
|
gint left_docks_width = G_MININT;
|
||||||
gint right_docks_pos = -1;
|
gint right_docks_width = G_MININT;
|
||||||
gboolean wait_with_right_docks = FALSE;
|
gboolean wait_with_right_docks = FALSE;
|
||||||
gboolean maximized = 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))
|
if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_LEFT_DOCKS_WIDTH))
|
||||||
width = &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))
|
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))
|
else if (! strcmp (aux->name, GIMP_IMAGE_WINDOW_MAXIMIZED))
|
||||||
if (! g_ascii_strcasecmp (aux->value, "yes"))
|
if (! g_ascii_strcasecmp (aux->value, "yes"))
|
||||||
maximized = TRUE;
|
maximized = TRUE;
|
||||||
|
|
||||||
if (width)
|
if (width)
|
||||||
sscanf (aux->value, "%d", 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 &&
|
if (left_docks_width != G_MININT &&
|
||||||
gtk_paned_get_position (GTK_PANED (private->left_hpane)) != left_docks_width)
|
gtk_paned_get_position (GTK_PANED (private->left_hpane)) !=
|
||||||
|
left_docks_width)
|
||||||
{
|
{
|
||||||
gtk_paned_set_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;
|
wait_with_right_docks = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (right_docks_pos > 0 &&
|
if (right_docks_width != G_MININT &&
|
||||||
gtk_paned_get_position (GTK_PANED (private->right_hpane)) != right_docks_pos)
|
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
|
* position
|
||||||
*/
|
*/
|
||||||
g_signal_connect_data (private->right_hpane, "size-allocate",
|
g_signal_connect_data (private->right_hpane, "size-allocate",
|
||||||
G_CALLBACK (gimp_image_window_set_right_hpane_position),
|
G_CALLBACK (gimp_image_window_set_right_docks_width),
|
||||||
GINT_TO_POINTER (right_docks_pos), NULL,
|
GINT_TO_POINTER (right_docks_width), NULL,
|
||||||
G_CONNECT_AFTER);
|
G_CONNECT_AFTER);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* We can set the position directly, because we didn't
|
/* 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),
|
gtk_paned_set_position (GTK_PANED (private->right_hpane),
|
||||||
right_docks_pos);
|
- right_docks_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
(open-on-exit)
|
(open-on-exit)
|
||||||
(aux-info
|
(aux-info
|
||||||
(left-docks-width "80")
|
(left-docks-width "80")
|
||||||
(right-docks-position "200")
|
(right-docks-width "400")
|
||||||
(maximized "no"))
|
(maximized "no"))
|
||||||
(gimp-toolbox
|
(gimp-toolbox
|
||||||
(side left))
|
(side left))
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
(open-on-exit)
|
(open-on-exit)
|
||||||
(aux-info
|
(aux-info
|
||||||
(left-docks-width "80")
|
(left-docks-width "80")
|
||||||
(right-docks-position "-764")
|
(right-docks-width "400")
|
||||||
(maximized "no"))
|
(maximized "no"))
|
||||||
(gimp-toolbox
|
(gimp-toolbox
|
||||||
(side left))
|
(side left))
|
||||||
|
Reference in New Issue
Block a user