Esempio n. 1
0
GtkStyleContext*
ClaimStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection,
                  GtkStateFlags aStateFlags, StyleFlags aFlags)
{
  MOZ_ASSERT(!sStyleContextNeedsRestore);
  GtkStyleContext* style = GetStyleInternal(aNodeType);
#ifdef DEBUG
  MOZ_ASSERT(!sCurrentStyleContext);
  sCurrentStyleContext = style;
#endif
  GtkStateFlags oldState = gtk_style_context_get_state(style);
  GtkTextDirection oldDirection = gtk_style_context_get_direction(style);
  if (oldState != aStateFlags || oldDirection != aDirection) {
    // From GTK 3.8, set_state() will overwrite the direction, so set
    // direction after state.
    gtk_style_context_set_state(style, aStateFlags);
    gtk_style_context_set_direction(style, aDirection);

    // This invalidate is necessary for unsaved style contexts from GtkWidgets
    // in pre-3.18 GTK, because automatic invalidation of such contexts
    // was delayed until a resize event runs.
    //
    // https://bugzilla.mozilla.org/show_bug.cgi?id=1272194#c7
    //
    // Avoid calling invalidate on saved contexts to avoid performing
    // build_properties() (in 3.16 stylecontext.c) unnecessarily early.
    if (!sStyleContextNeedsRestore) {
      gtk_style_context_invalidate(style);
    }
  }
  return style;
}
void PanelPaletteManager::updatePalette()
{
    GtkStyleContext* context = PanelStyle::instance()->styleContext();
    gtk_style_context_invalidate(context);

    // Without this line, it seems the GtkStyleContext is not correctly
    // initialized and we get some uninitialized pixels in the background
    // brush.
    gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, NULL);

    QPalette pal;
    if (DashClient::instance()->activeInScreen(m_panel->screen()) || HUDClient::instance()->activeInScreen(m_panel->screen())) {
        /* The background color is the same as in the launcher */
        QColor wallpaperColor(unity2dConfiguration().property("averageBgColor").toString());
        QColor backgroundColor(wallpaperColor.red(), wallpaperColor.green(), wallpaperColor.blue(), 168);
        backgroundColor = backgroundColor.darker(800);
        pal.setBrush(QPalette::Window, backgroundColor);
    } else {
        pal.setBrush(QPalette::Window, generateBackgroundBrush());
    }
    m_panel->setPalette(pal);
}
void ScrollbarThemeGtk::themeChanged()
{
    gtk_style_context_invalidate(gtkScrollbarStyleContext());
    updateThemeProperties();
}