Пример #1
0
static void
gd_two_lines_renderer_prepare_layouts (GdTwoLinesRenderer *self,
                                       const GdkRectangle *cell_area,
                                       GtkWidget *widget,
                                       PangoLayout **layout_one,
                                       PangoLayout **layout_two)
{
  PangoLayout *line_one;
  PangoLayout *line_two = NULL;
  gchar *text = NULL;

  g_object_get (self,
                "text", &text,
                NULL);

  line_one = create_layout_with_attrs (widget, cell_area,
                                       self, PANGO_ELLIPSIZE_MIDDLE);

  if (self->priv->line_two == NULL ||
      g_strcmp0 (self->priv->line_two, "") == 0)
    {
      pango_layout_set_height (line_one, - (self->priv->text_lines));

      if (text != NULL)
        pango_layout_set_text (line_one, text, -1);
    }
  else
    {
      GtkStyleContext *context;

      line_two = create_layout_with_attrs (widget, cell_area,
                                           self, PANGO_ELLIPSIZE_END);

      context = gtk_widget_get_style_context (widget);
      gtk_style_context_save (context);
      apply_subtitle_style_to_layout (context, line_two, GTK_STATE_FLAG_NORMAL);
      gtk_style_context_restore (context);

      pango_layout_set_height (line_one, - (self->priv->text_lines - 1));
      pango_layout_set_height (line_two, -1);
      pango_layout_set_text (line_two, self->priv->line_two, -1);

      if (text != NULL)
        pango_layout_set_text (line_one, text, -1);
    }

  if (layout_one)
    *layout_one = line_one;
  if (layout_two)
    *layout_two = line_two;

  g_free (text);
}
static void
gd_two_lines_renderer_prepare_layouts (GdTwoLinesRenderer *self,
                                       GtkWidget *widget,
                                       PangoLayout **layout_one,
                                       PangoLayout **layout_two)
{
  PangoLayout *line_one;
  PangoLayout *line_two = NULL;
  gchar *text = NULL;

  g_object_get (self,
                "text", &text,
                NULL);

  line_one = create_layout_with_attrs (widget, self, PANGO_ELLIPSIZE_MIDDLE);

  if (self->priv->line_two == NULL ||
      g_strcmp0 (self->priv->line_two, "") == 0)
    {
      pango_layout_set_height (line_one, - (self->priv->text_lines));

      if (text != NULL)
        pango_layout_set_text (line_one, text, -1);
    }
  else
    {
      line_two = create_layout_with_attrs (widget, self, PANGO_ELLIPSIZE_END);

      pango_layout_set_height (line_one, - (self->priv->text_lines - 1));
      pango_layout_set_height (line_two, -1);
      pango_layout_set_text (line_two, self->priv->line_two, -1);

      if (text != NULL)
        pango_layout_set_text (line_one, text, -1);
    }

  if (layout_one)
    *layout_one = line_one;
  if (layout_two)
    *layout_two = line_two;

  g_free (text);
}