Ejemplo n.º 1
0
static void get_color (gint i, gfloat * r, gfloat * g, gfloat * b)
{
    static GdkRGBA c;
    static bool_t valid = FALSE;
    gfloat h, s, v, n;

    if (! valid)
    {
        /* we want a color that matches the current theme
         * selected color of a GtkEntry should be reasonable */
        GtkStyleContext * style = gtk_style_context_new ();
        GtkWidgetPath * path = gtk_widget_path_new ();
        gtk_widget_path_append_type (path, GTK_TYPE_ENTRY);
        gtk_style_context_set_path (style, path);
        gtk_widget_path_free (path);
        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, & c);
        g_object_unref (style);
        valid = TRUE;
    }

    rgb_to_hsv (c.red, c.green, c.blue, & h, & s, & v);

    if (s < 0.1) /* monochrome theme? use blue instead */
    {
        h = 5;
        s = 0.75;
    }

    n = i / (gfloat) (bands - 1);
    s = 1 - 0.9 * n;
    v = 0.75 + 0.25 * n;

    hsv_to_rgb (h, s, v, r, g, b);
}
Ejemplo n.º 2
0
/* FIXME: this doesn't work */
static gboolean
draw_cb_activity (GtkWidget *widget, cairo_t *cr)
{
  GtkStyleContext *context;
  GtkWidgetPath *path;

  context = gtk_widget_get_style_context (widget);
  gtk_style_context_notify_state_change (context,
                                         gtk_widget_get_window (widget),
                                         NULL,
                                         GTK_STATE_FLAG_ACTIVE,
                                         TRUE);

  gtk_style_context_save (context);

  path = gtk_widget_path_new ();
  gtk_widget_path_append_type (path, GTK_TYPE_SPINNER);
  gtk_widget_path_iter_add_class (path, 0, "spinner");
  gtk_style_context_set_path (context, path);
  gtk_widget_path_free (path);

  gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
  gtk_render_activity (context, cr, 12, 12, 12, 12);

  gtk_style_context_restore (context);

  return TRUE;
}
Ejemplo n.º 3
0
static void
workrave_timebar_init_ui(WorkraveTimebar *self)
{
  WorkraveTimebarPrivate *priv = WORKRAVE_TIMEBAR_GET_PRIVATE(self);

  priv->style_context = gtk_style_context_new();

  GtkWidgetPath *path = gtk_widget_path_new();
  gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
  gtk_style_context_set_path(priv->style_context, path);
  gtk_style_context_add_class(priv->style_context, GTK_STYLE_CLASS_TROUGH);
  
  GdkScreen *screen = gdk_screen_get_default();
  priv->pango_context = gdk_pango_context_get_for_screen(screen);

  const PangoFontDescription *font_desc = gtk_style_context_get_font(priv->style_context, GTK_STATE_FLAG_ACTIVE);

  pango_context_set_language(priv->pango_context, gtk_get_default_language());
  pango_context_set_font_description(priv->pango_context, font_desc);

  priv->pango_layout = pango_layout_new(priv->pango_context);
  pango_layout_set_text(priv->pango_layout, "-9:59:59", -1);

  pango_layout_get_pixel_size(priv->pango_layout, &priv->width, &priv->height);

  priv->width = MAX(priv->width + 2 * MARGINX, MIN_HORIZONTAL_BAR_WIDTH);
  priv->height = MAX(priv->height + 2 * MARGINY, MIN_HORIZONTAL_BAR_HEIGHT);

  gtk_widget_path_free(path);
}
Ejemplo n.º 4
0
 ScrollbarStyleContext()
     : m_context(adoptGRef(gtk_style_context_new()))
 {
     GtkWidgetPath* path = gtk_widget_path_new();
     gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR);
     gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCROLLBAR);
     gtk_style_context_set_path(m_context.get(), path);
     gtk_widget_path_free(path);
 }
void getTooltipColors_GtkWidgetPath()
{
#if GTK_CHECK_VERSION(3,20,0)
	if (0 != gtk_check_version(3, 20, 0))
	{
		// 'gtk_widget_path_iter_set_object_name' was introduced in 3.20.0
		printf("With GtkWidgetPath:    Requires 3.20.0\n");
		return;
	}

	// Foreground color is taken from 'tooltip label' css node
	GtkStyleContext* styleContextLabel = gtk_style_context_new();
	{
		GtkWidgetPath* widgetPath = gtk_widget_path_new();
		gtk_widget_path_append_type(widgetPath, 0);
		gtk_widget_path_iter_set_object_name(widgetPath, -1, "tooltip");
		gtk_widget_path_iter_add_class(widgetPath, -1, GTK_STYLE_CLASS_BACKGROUND);
		gtk_widget_path_append_type(widgetPath, GTK_TYPE_LABEL);
		gtk_style_context_set_path(styleContextLabel, widgetPath);
		gtk_widget_path_free(widgetPath);
	}

	// Background color is taken from 'tooltip.background' css node
	GtkStyleContext* styleContextTooltip = gtk_style_context_new();
	{
		GtkWidgetPath* widgetPath = gtk_widget_path_new();
		gtk_widget_path_append_type(widgetPath, 0);
		gtk_widget_path_iter_set_object_name(widgetPath, -1, "tooltip");
		gtk_widget_path_iter_add_class(widgetPath, -1, GTK_STYLE_CLASS_BACKGROUND);
		gtk_style_context_set_path(styleContextTooltip, widgetPath);
		gtk_widget_path_free(widgetPath);
	}

	// Print
	printTooltipColors(styleContextLabel, styleContextTooltip, "GtkWidgetPath");

	// Destroy temporary style contexts
	g_object_unref(styleContextLabel);
	g_object_unref(styleContextTooltip);
#endif // GTK_CHECK_VERSION(3,20,0)
}
Ejemplo n.º 6
0
Archivo: ui.c Proyecto: darkxst/mtest
void
meta_ui_theme_get_frame_borders (MetaUI *ui,
                                 MetaFrameType      type,
                                 MetaFrameFlags     flags,
                                 MetaFrameBorders  *borders)
{
  int text_height;
  GtkStyleContext *style = NULL;
  PangoContext *context;
  const PangoFontDescription *font_desc;
  PangoFontDescription *free_font_desc = NULL;

  if (meta_ui_have_a_theme ())
    {
      context = gtk_widget_get_pango_context (GTK_WIDGET (ui->frames));
      font_desc = meta_prefs_get_titlebar_font ();

      if (!font_desc)
        {
          GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
          GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
          GtkWidgetPath *widget_path;

          style = gtk_style_context_new ();
          gtk_style_context_set_screen (style, screen);
          widget_path = gtk_widget_path_new ();
          gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
          gtk_style_context_set_path (style, widget_path);
          gtk_widget_path_free (widget_path);

          gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
          font_desc = (const PangoFontDescription *) free_font_desc;
        }

      text_height = meta_pango_font_desc_get_text_height (font_desc, context);

      meta_theme_get_frame_borders (meta_theme_get_current (),
                                    type, text_height, flags,
                                    borders);

      if (free_font_desc)
        pango_font_description_free (free_font_desc);
    }
  else
    {
      meta_frame_borders_clear (borders);
    }

  if (style != NULL)
    g_object_unref (style);
}
static void
test_init_of_theme (void)
{
  GtkStyleContext *context;
  GtkCssProvider *provider;
  GtkWidgetPath *path;
  GdkRGBA before, after;
  char *css;

  /* Test that a style context actually uses the theme loaded for the 
   * screen it is using. If no screen is set, it's the default one.
   */
  context = gtk_style_context_new ();
  path = gtk_widget_path_new ();

  /* Set a path that will have a color set.
   * (This could actually fail if style classes change, so if this test
   *  fails, make sure to have this path represent something sane.)
   */
  gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
  gtk_widget_path_iter_add_class (path, -1, GTK_STYLE_CLASS_BACKGROUND);
  gtk_style_context_set_path (context, path);
  gtk_widget_path_free (path);

  /* Get the color. This should be initialized by the theme and not be
   * the default. */
  gtk_style_context_get_color (context, gtk_style_context_get_state (context), &before);

  /* Add a style that sets a different color for this widget.
   * This style has a higher priority than fallback, but a lower 
   * priority than the theme. */
  css = g_strdup_printf (".background { color: %s; }",
                         before.alpha < 0.5 ? "black" : "transparent");
  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (provider, css, -1, NULL);
  gtk_style_context_add_provider (context,
                                  GTK_STYLE_PROVIDER (provider),
                                  GTK_STYLE_PROVIDER_PRIORITY_FALLBACK + 1);
  g_object_unref (provider);

  /* Get the color again. */
  gtk_style_context_get_color (context, gtk_style_context_get_state (context), &after);

  /* Because the style we added does not influence the color,
   * the before and after colors should be identical. */
  g_assert (gdk_rgba_equal (&before, &after));

  g_object_unref (context);
}
Ejemplo n.º 8
0
/*
 * frame_update_titlebar_font
 *
 * Returns: void
 * Description: updates the titlebar font from the pango context, should
 * be called whenever the gtk style or font has changed
 */
void
frame_update_titlebar_font (decor_frame_t *frame)
{
    const PangoFontDescription *font_desc;
    PangoFontDescription *free_font_desc;
    PangoFontMetrics *metrics;
    PangoLanguage *lang;

    free_font_desc = NULL;
    frame = gwd_decor_frame_ref (frame);

    font_desc = get_titlebar_font (frame);
    if (!font_desc)
    {
        GtkCssProvider *provider = gtk_css_provider_get_default ();
        GtkStyleContext *context = gtk_style_context_new ();
        GtkWidgetPath *path = gtk_widget_path_new ();

        gtk_widget_path_prepend_type (path, GTK_TYPE_WIDGET);
        gtk_style_context_set_path (context, path);
        gtk_widget_path_free (path);

        gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);

        gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
        font_desc = (const PangoFontDescription *) free_font_desc;
    }

    pango_context_set_font_description (frame->pango_context, font_desc);

    lang    = pango_context_get_language (frame->pango_context);
    metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang);

    frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
				pango_font_metrics_get_descent (metrics));

    gwd_decor_frame_unref (frame);

    pango_font_metrics_unref (metrics);

    if (free_font_desc)
        pango_font_description_free (free_font_desc);
}
Ejemplo n.º 9
0
GR_Font * GR_UnixCairoGraphics::getGUIFont(void)
{
	if (!m_pPFontGUI)
	{
		// get the font resource
#if GTK_CHECK_VERSION(3,0,0)
		GtkStyleContext *tempCtxt = gtk_style_context_new();
		GtkWidgetPath *path = gtk_widget_path_new();
		gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
		gtk_style_context_set_path(tempCtxt, path);
		gtk_widget_path_free(path);
		const char *guiFontName = pango_font_description_get_family(gtk_style_context_get_font(tempCtxt, GTK_STATE_FLAG_NORMAL));
#else
		GtkStyle *tempStyle = gtk_style_new();
		const char *guiFontName = pango_font_description_get_family(tempStyle->font_desc);
#endif
		if (!guiFontName)
			guiFontName = "'Times New Roman'";

		UT_UTF8String s = XAP_EncodingManager::get_instance()->getLanguageISOName();

		const char * pCountry
			= XAP_EncodingManager::get_instance()->getLanguageISOTerritory();
		
		if(pCountry)
		{
			s += "-";
			s += pCountry;
		}
		
		m_pPFontGUI = new GR_PangoFont(guiFontName, 11.0, this, s.utf8_str(), true);

#if GTK_CHECK_VERSION(3,0,0)
		g_object_unref(G_OBJECT(tempCtxt));
#else
		g_object_unref(G_OBJECT(tempStyle));
#endif
		
		UT_ASSERT(m_pPFontGUI);
	}

	return m_pPFontGUI;
}
Ejemplo n.º 10
0
PanelStyle::PanelStyle()
: d(new PanelStylePrivate)
{
    d->q = this;
    d->m_styleContext.reset(gtk_style_context_new());

    GtkWidgetPath* widgetPath = gtk_widget_path_new ();
    gtk_widget_path_append_type(widgetPath, GTK_TYPE_WINDOW);
    gtk_widget_path_iter_set_name(widgetPath, -1 , "UnityPanelWidget");

    gtk_style_context_set_path(d->m_styleContext.data(), widgetPath);
    gtk_style_context_add_class(d->m_styleContext.data(), "gnome-panel-menu-bar");
    gtk_style_context_add_class(d->m_styleContext.data(), "unity-panel");

    gtk_widget_path_free (widgetPath);

    d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name",
        G_CALLBACK(PanelStylePrivate::onThemeChanged), d);

    d->updateTheme();
}
Ejemplo n.º 11
0
static gboolean
draw_cb_slider (GtkWidget *widget, cairo_t *cr)
{
  GtkStyleContext *context;
  GtkWidgetPath *path;

  context = gtk_widget_get_style_context (widget);
  gtk_style_context_save (context);

  path = gtk_widget_path_new ();
  gtk_widget_path_append_type (path, GTK_TYPE_SCALE);
  gtk_widget_path_iter_add_class (path, 0, "slider");
  gtk_widget_path_iter_add_class (path, 0, "scale");
  gtk_style_context_set_path (context, path);
  gtk_widget_path_free (path);

  gtk_render_slider (context, cr, 12, 22, 30, 10, GTK_ORIENTATION_HORIZONTAL);
  gtk_render_slider (context, cr, 54, 12, 10, 30, GTK_ORIENTATION_VERTICAL);

  gtk_style_context_restore (context);

  return TRUE;
}
Ejemplo n.º 12
0
static void
bacon_video_osd_actor_init (BaconVideoOsdActor *osd)
{
	ClutterActor *self;
	GtkWidgetPath *widget_path;

	self = CLUTTER_ACTOR (osd);
        osd->priv = BACON_VIDEO_OSD_ACTOR_GET_PRIVATE (osd);

	osd->priv->canvas = CLUTTER_CANVAS (clutter_canvas_new ());
	g_object_bind_property (self, "width",
				osd->priv->canvas, "width",
				G_BINDING_DEFAULT);
	g_object_bind_property (self, "height",
				osd->priv->canvas, "height",
				G_BINDING_DEFAULT);
	clutter_actor_set_content (self, CLUTTER_CONTENT (osd->priv->canvas));
	g_object_unref (osd->priv->canvas);

	osd->priv->icon_name = NULL;
	osd->priv->message = NULL;

	osd->priv->ctx = g_new0 (GsdOsdDrawContext, 1);

	widget_path = gtk_widget_path_new ();
	gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
	osd->priv->style = gtk_style_context_new ();
	gtk_style_context_set_path (osd->priv->style, widget_path);
	gtk_widget_path_free (widget_path);

	osd->priv->ctx->direction = clutter_get_default_text_direction ();
	osd->priv->ctx->theme = gtk_icon_theme_get_default ();
	osd->priv->ctx->style = osd->priv->style;

	g_signal_connect (osd->priv->canvas, "draw", G_CALLBACK (bacon_video_osd_actor_draw), osd);
        osd->priv->fade_out_alpha = 1.0;
}
Ejemplo n.º 13
0
MetaTilePreview *
meta_tile_preview_new (int      screen_number,
                       gboolean composited)
{
  MetaTilePreview *preview;
  GdkScreen *screen;

  screen = gdk_display_get_screen (gdk_display_get_default (), screen_number);

  preview = g_new (MetaTilePreview, 1);

  preview->preview_window = gtk_window_new (GTK_WINDOW_POPUP);

  gtk_window_set_screen (GTK_WINDOW (preview->preview_window), screen);
  gtk_widget_set_app_paintable (preview->preview_window, TRUE);

  preview->preview_color = NULL;

  preview->tile_rect.x = preview->tile_rect.y = 0;
  preview->tile_rect.width = preview->tile_rect.height = 0;

  preview->has_alpha = composited &&
                       (gdk_screen_get_rgba_visual (screen) != NULL);

  if (preview->has_alpha)
    {
      GtkStyleContext *context;
      GtkWidgetPath *path;
      guchar selection_alpha = 0xFF;

      gtk_widget_set_visual (preview->preview_window,
                             gdk_screen_get_rgba_visual (screen));

      path = gtk_widget_path_new ();
      gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);

      context = gtk_style_context_new ();
      gtk_style_context_set_path (context, path);
      gtk_style_context_add_class (context,
                                   GTK_STYLE_CLASS_RUBBERBAND);

      gtk_widget_path_free (path);

      gtk_style_context_get (context, GTK_STATE_FLAG_SELECTED,
                             "background-color", &preview->preview_color,
                             NULL);

      /* The background-color for the .rubberband class should probably
       * contain the correct alpha value - unfortunately, at least for now
       * it doesn't. Hopefully the following workaround can be removed
       * when GtkIconView gets ported to GtkStyleContext.
       */
      gtk_style_context_get_style (context,
                                   "selection-box-alpha", &selection_alpha,
                                   NULL);
      preview->preview_color->alpha = (double)selection_alpha / 0xFF;

      g_object_unref (context);
    }

  /* We make an assumption that XCreateWindow will be the first operation
   * when calling gtk_widget_realize() (via gdk_window_new()), or that it
   * is at least "close enough".
   */
  preview->create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
  gtk_widget_realize (preview->preview_window);
  g_signal_connect (preview->preview_window, "draw",
                    G_CALLBACK (meta_tile_preview_draw), preview);

  return preview;
}
void testColors()
{
	for (int testBits = 0; testBits < (1 << 4); testBits++)
	{
		GdkRGBA colorFore;
		{
			GtkWidgetPath* widgetPath = gtk_widget_path_new();
			gint pathPos = gtk_widget_path_append_type(widgetPath, gtk_tooltip_get_type());

			#if GTK_CHECK_VERSION(3,20,0)
			if (testBits & 1)
				gtk_widget_path_iter_set_object_name(widgetPath, pathPos, "tooltip");
			#else
			// Silence the warning
			(void)pathPos;
			#endif

			if (testBits & 2)
				gtk_widget_path_append_type(widgetPath, gtk_label_get_type());

			GtkStyleContext* styleContext = gtk_style_context_new();
			gtk_style_context_set_path(styleContext, widgetPath);
			gtk_widget_path_free(widgetPath);

			if (testBits & 4)
				gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BACKGROUND);

			if (testBits & 8)
				gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TOOLTIP);

			gtk_style_context_get_color(styleContext, GTK_STATE_FLAG_NORMAL, &colorFore);

			g_object_unref(styleContext);
		}

		GdkRGBA colorBack;
		{
			GtkWidgetPath* widgetPath = gtk_widget_path_new();
			gint pathPos = gtk_widget_path_append_type(widgetPath, gtk_tooltip_get_type());

			#if GTK_CHECK_VERSION(3,20,0)
			if (testBits & 1)
				gtk_widget_path_iter_set_object_name(widgetPath, pathPos, "tooltip");
			#else
			// Silence the warning
			(void)pathPos;
			#endif

			if (testBits & 2)
				gtk_widget_path_append_type(widgetPath, gtk_label_get_type());

			GtkStyleContext* styleContext = gtk_style_context_new();
			gtk_style_context_set_path(styleContext, widgetPath);
			gtk_widget_path_free(widgetPath);

			if (testBits & 4)
				gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BACKGROUND);

			if (testBits & 8)
				gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TOOLTIP);

			gtk_style_context_get_background_color(styleContext, GTK_STATE_FLAG_NORMAL, &colorBack);

			g_object_unref(styleContext);
		}

		printf
		(
			"%c%c%c%c fore=%s back=%s\n",
			(testBits & 1) ? '1' : '-',
			(testBits & 2) ? '2' : '-',
			(testBits & 4) ? '3' : '-',
			(testBits & 8) ? '4' : '-',
			format_GdkRGBA(colorFore).c_str(),
			format_GdkRGBA(colorBack).c_str()
		);
	}
}
Ejemplo n.º 15
0
static void
gtk_numerable_icon_update_properties_from_style (GtkNumerableIcon *self)
{
  GtkStyleContext *style = self->priv->style;
  GtkWidgetPath *path, *saved;
  cairo_pattern_t *pattern = NULL;
  GdkRGBA background, foreground;
  PangoFontDescription *font = NULL;

  /* save an unmodified copy of the original widget path, in order
   * to restore it later */
  path = gtk_widget_path_copy (gtk_style_context_get_path (style));
  saved = gtk_widget_path_copy (path);

  if (!gtk_widget_path_is_type (path, GTK_TYPE_NUMERABLE_ICON))
    {
      /* append our GType to the style context to fetch appropriate colors */
      gtk_widget_path_append_type (path, GTK_TYPE_NUMERABLE_ICON);
      gtk_style_context_set_path (style, path);
    }

  gtk_style_context_get_background_color (style, gtk_style_context_get_state (style),
                                          &background);
  gtk_style_context_get_color (style, gtk_style_context_get_state (style),
                               &foreground);

  if (self->priv->background != NULL)
    gdk_rgba_free (self->priv->background);

  self->priv->background = gdk_rgba_copy (&background);

  if (self->priv->foreground != NULL)
    gdk_rgba_free (self->priv->foreground);

  self->priv->foreground = gdk_rgba_copy (&foreground);

  gtk_style_context_get (style, gtk_style_context_get_state (style),
                         GTK_STYLE_PROPERTY_BACKGROUND_IMAGE, &pattern,
                         NULL);

  if (pattern != NULL)
    {
      if (self->priv->background_image != NULL)
        cairo_pattern_destroy (self->priv->background_image);

      self->priv->background_image = pattern;
    }

  gtk_style_context_get (style, gtk_style_context_get_state (style),
                         GTK_STYLE_PROPERTY_FONT, &font,
                         NULL);

  if (font != NULL)
    {
      if (self->priv->font != NULL)
        pango_font_description_free (self->priv->font);

      self->priv->font = font;
    }

  gtk_numerable_icon_ensure_emblem (self);

  /* restore original widget path */
  gtk_style_context_set_path (style, saved);

  gtk_widget_path_free (path);
  gtk_widget_path_free (saved);
}
Ejemplo n.º 16
0
void
meta_ui_theme_get_frame_borders (MetaUI *ui,
                                 MetaFrameType      type,
                                 MetaFrameFlags     flags,
                                 int               *top_height,
                                 int               *bottom_height,
                                 int               *left_width,
                                 int               *right_width)
{
  int text_height;
#if GTK_CHECK_VERSION (3, 0, 0)
  GtkStyleContext *style = NULL;
  PangoFontDescription *free_font_desc = NULL;
#endif
  PangoContext *context;
  const PangoFontDescription *font_desc;

  if (meta_ui_have_a_theme ())
    {
      context = gtk_widget_get_pango_context (GTK_WIDGET (ui->frames));
      font_desc = meta_prefs_get_titlebar_font ();

      if (!font_desc)
        {
#if GTK_CHECK_VERSION (3, 0, 0)
          GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
          GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
          GtkWidgetPath *widget_path;

          style = gtk_style_context_new ();
          gtk_style_context_set_screen (style, screen);
          widget_path = gtk_widget_path_new ();
          gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
          gtk_style_context_set_path (style, widget_path);
          gtk_widget_path_free (widget_path);

          gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
          font_desc = (const PangoFontDescription *) free_font_desc;
#else
          GtkStyle *default_style;

          default_style = gtk_widget_get_default_style ();
          font_desc = default_style->font_desc;
#endif
        }

      text_height = meta_pango_font_desc_get_text_height (font_desc, context);

      meta_theme_get_frame_borders (meta_theme_get_current (),
                                    type, text_height, flags,
                                    top_height, bottom_height,
                                    left_width, right_width);

#if GTK_CHECK_VERSION (3, 0, 0)
      if (free_font_desc)
        pango_font_description_free (free_font_desc);
#endif
    }
  else
    {
      *top_height = *bottom_height = *left_width = *right_width = 0;
    }

#if GTK_CHECK_VERSION (3, 0, 0)
  if (style != NULL)
    g_object_unref (style);
#endif
}