GTK3: Fix caja information panel #573

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Member

lukefromdc commented Jun 18, 2016

The Caja information panel (information option in sidebar) was never fully ported to GTK3, probably still isn't. Set the .view style class on it, and exclude the rest of caja_information_panel_update_appearance as that code segfaults (at least with GTK 3.21) on dragging a background to the info panel.

We now have a demo for background dragging in GTK3: A background can be dragged to the information sidebar and will be displayed. Won't be saved and won't appear in other Cajs navigation windows, something in the code that segfaulted no doubt needs to be fixed for that but that's for later. At least this widget finally works. It will follow any theme I have and no longer fails to update to BlackMATE or my own theme.

lukefromdc added some commits Jun 18, 2016

Merge pull request #2 from mate-desktop/dev-style-context
Merge mate-desktop/dev-style-context
GTK3: Fix caja information panel
The Caja information panel (information option in sidebar) was never fully ported to GTK3, probably still isn't. Set the .view style class on it, and exclude the rest of caja_information_panel_update_appearance as that code segfaults (at least with GTK 3.21) on dragging a background to the info panel.

We now have a demo for background dragging in GTK3: A background can be dragged to the information sidebar and will be displayed. Won't be saved and won't appear in other Cajs navigation windows, something in the code that segfaulted no doubt needs to be fixed for that but that's for later. At least this widget finally works. It will follow any theme I have and no longer fails to update to  BlackMATE or my own theme.
Member

raveit65 commented Jun 18, 2016

Well, should be save to merge to master?

Member

lukefromdc commented Jun 18, 2016

Should be, though I would have to revert mate-desktop to test. Cherrypick
that one changed file, it should work fine. Test master with mate-desktop
from master as well, though I don't know how much longer the GdkColor
code will be used.

On 6/18/2016 at 5:24 PM, "raveit65" notifications@github.com wrote:

Well, should be save to merge to master?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#573 (comment)
226965727

Member

raveit65 commented Jun 18, 2016

At the moment i'm a bit clueless what is wrong with GdkRGBA port, i hope that some of the other guys will help.
But at least this have to be done before we switch to gtk3.

Member

lukefromdc commented Jun 18, 2016

With this last commit I just sent the only thing that is broken as a result of
the GdkRBGA issue is the gradient backgrounds and the m-c-c icon for
a color background. Solid color backgrounds were broken for ages in GTK3,
they now work. I submitted an issue that nobody else ever commented on,
closed it since that is now fixed-and worked when I first started playing with
eel-background.

On 6/18/2016 at 5:33 PM, "raveit65" notifications@github.com wrote:

At the moment i'm a bit clueless what is wrong with GdkRGBA port,
i hope that some of the other guys will help.
But at least this have to be done before we switch to gtk3.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#573 (comment)
226966130

Member

lukefromdc commented Jun 18, 2016

For the gradient background, it looks like eel_gradient_new in gdk_extensions.c
may be the culprit, since it's the only real difference from the single color background in
the function eel_bg_get_desktop_color in eel_background.c

On 6/18/2016 at 5:33 PM, "raveit65" notifications@github.com wrote:

At the moment i'm a bit clueless what is wrong with GdkRGBA port,
i hope that some of the other guys will help.
But at least this have to be done before we switch to gtk3.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#573 (comment)
226966130

Member

lukefromdc commented Jun 18, 2016

Just took a look at eel_gradient_new, the color variables there are const char variables, while in eel_bg_get_desktop_color they are GdkRGBA 's. eel_bg_get_desktop_color loads new "char" variables from the RBGA's, wonder if the format put into these variables in not valid for eventually making the colors?

Member

lukefromdc commented Jun 18, 2016

Now playing with the code below:

#if GTK_CHECK_VERSION (3, 0, 0)
start_color = eel_gdk_rgb_to_color_spec (eel_gdk_rgba_to_rgb (&primary));

if (use_gradient)
{
    end_color  = eel_gdk_rgb_to_color_spec (eel_gdk_rgba_to_rgb (&secondary));

#else
start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary));

if (use_gradient)
{
    end_color  = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary));

#endif
color_spec = eel_gradient_new (start_color, end_color, is_horizontal);
g_free (end_color);
}
else
{
color_spec = g_strdup (start_color);
}
g_free (start_color);

return color_spec;``

The start_color and end_color variables both work, as simply setting color_spec = g_strdup to either color works properly. It's when color_spec = eel_gradient_new () is called that a black background results, thus confirming that eel-gdk-extensions.c needs work on the gradient code.

The special case of a gradient where both colors are identical does work, it's in other cases where eel_gradient_new() breaks down.
return g_strconcat (start_color, "-", end_color, is_horizontal ? ":h" : NULL, NULL);
is not giving a useful result here, as replacing it with
return g_strdup (end_color);
causes the expected result: end color only is used as the background.

https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strconcat

warns that this function often assembles a string other than in the order you want. My guess is that the char variables loaded from the GdkRBGA's when put into this function are returning a value that is formatted differently than GkdColor was giving and is not useful for setting up a gradient.

using this test code:
return g_strconcat (start_color, NULL, is_horizontal ? ":h" : NULL, NULL);
Will force a color background to the start color whether solid or either gradient is selected. This shows that the start_color-end_color concatenated string is what is no longer valid here.

Thus, the returned value "color_spec" back in eel_background.c is coming back as a string that cannot be interpreted by another function due to a format change between GdkColor and GdkRBGA.

Member

raveit65 commented Jun 19, 2016

merged 262492b
Thank you

Member

raveit65 commented Jun 19, 2016

Nice analysis, i will look in gdk_extensions.c again.

@raveit65 raveit65 closed this Jun 19, 2016

Member

lukefromdc commented Jun 19, 2016

More on the GkdRBGA issue for gradients: Back in eel_background.c, the returned "color_spec" value is returned by
eel_bg_get_desktop_color toset_image_properties with this code:
static void
set_image_properties (EelBackground *self)
{
#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA c;
#else
GdkColor c;
#endif

if (self->details->is_desktop && !self->details->color)
    self->details->color = eel_bg_get_desktop_color (self);

if (!self->details->color)
{
    c = self->details->default_color;
    make_color_inactive (self, &c);
    mate_bg_set_color (self->details->bg, MATE_BG_COLOR_SOLID, &c, NULL);
}
else if (!eel_gradient_is_gradient (self->details->color))
{

#if GTK_CHECK_VERSION (3, 0, 0)
eel_gdk_rgba_parse_with_white_default (&c, self->details->color);
#else
eel_gdk_color_parse_with_white_default (self->details->color, &c);
#endif
make_color_inactive (self, &c);
mate_bg_set_color (self->details->bg, MATE_BG_COLOR_SOLID, &c, NULL);
}
else
{
#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA c1, c2;
#else
GdkColor c1, c2;
#endif
char *spec;

    spec = eel_gradient_get_start_color_spec (self->details->color);

#if GTK_CHECK_VERSION (3, 0, 0)
eel_gdk_rgba_parse_with_white_default (&c1, spec);
make_color_inactive (self, &c1);
g_free (spec);

    spec = eel_gradient_get_end_color_spec (self->details->color);
    eel_gdk_rgba_parse_with_white_default (&c2, spec);

#else
eel_gdk_color_parse_with_white_default (spec, &c1);
make_color_inactive (self, &c1);
g_free (spec);

    spec = eel_gradient_get_end_color_spec (self->details->color);
    eel_gdk_color_parse_with_white_default (spec, &c2);

#endif
make_color_inactive (self, &c2);
g_free (spec);

    if (eel_gradient_is_horizontal (self->details->color)) {
        mate_bg_set_color (self->details->bg, MATE_BG_COLOR_H_GRADIENT, &c1, &c2);
    } else {
        mate_bg_set_color (self->details->bg, MATE_BG_COLOR_V_GRADIENT, &c1, &c2);
    }
}

}``

Looks like
self->details->color = eel_bg_get_desktop_color (self);
is loaded with that gradient pair of colors and then parsed later to set up the gradient, not sure how this works with a GdkColor. Possibly that is what is not working when a pair of GdkRBGA values are loaded?
i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment