static gboolean
_labels_update_tooltip_idle_cb (PengeInterestingTile *tile)
{
    PengeInterestingTilePrivate *priv = GET_PRIVATE (tile);
    ClutterActor *tmp_text;
    PangoLayout *layout;

    tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->primary_text));
    layout = clutter_text_get_layout (CLUTTER_TEXT (tmp_text));
    if (pango_layout_is_ellipsized (layout))
        mx_widget_set_tooltip_text (MX_WIDGET (priv->primary_text),
                                    mx_label_get_text (MX_LABEL (priv->primary_text)));
    else
        mx_widget_set_tooltip_text (MX_WIDGET (priv->primary_text),
                                    NULL);

    tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->secondary_text));
    layout = clutter_text_get_layout (CLUTTER_TEXT (tmp_text));
    if (pango_layout_is_ellipsized (layout))
        mx_widget_set_tooltip_text (MX_WIDGET (priv->secondary_text),
                                    mx_label_get_text (MX_LABEL (priv->secondary_text)));
    else
        mx_widget_set_tooltip_text (MX_WIDGET (priv->secondary_text),
                                    NULL);

    priv->tooltip_idle_id = 0;


    return FALSE;
}
示例#2
0
static void
test_file (const gchar *filename, GString *string)
{
  gchar *contents;
  gchar *markup;
  gsize  length;
  GError *error = NULL;
  PangoLayout *layout;
  gchar *p;
  gint width = 0;
  gint ellipsize_at = 0;
  PangoEllipsizeMode ellipsize = PANGO_ELLIPSIZE_NONE;
  PangoWrapMode wrap = PANGO_WRAP_WORD;
  PangoFontDescription *desc;

  if (!g_file_get_contents (filename, &contents, &length, &error))
    {
      fprintf (stderr, "%s\n", error->message);
      g_error_free (error);
      return;
    }

  p = strchr (contents, '\n');
  g_assert (p);
  markup = p + 1;
  *p = '\0';

  parse_params (contents, &width, &ellipsize_at, &ellipsize, &wrap);

  layout = pango_layout_new (context);

  desc = pango_font_description_from_string ("Cantarell 11");
  pango_layout_set_font_description (layout, desc);
  pango_font_description_free (desc); 

  pango_layout_set_markup (layout, markup, length);
  g_free (contents);

  if (width != 0)
    pango_layout_set_width (layout, width * PANGO_SCALE);
  pango_layout_set_ellipsize (layout, ellipsize);
  pango_layout_set_wrap (layout, wrap);

  g_string_append (string, pango_layout_get_text (layout));
  g_string_append (string, "\n---\n\n");
  g_string_append_printf (string, "wrapped: %d\n", pango_layout_is_wrapped (layout));
  g_string_append_printf (string, "ellipsized: %d\n", pango_layout_is_ellipsized (layout));
  g_string_append_printf (string, "lines: %d\n", pango_layout_get_line_count (layout));
  if (width != 0)
    g_string_append_printf (string, "width: %d\n", pango_layout_get_width (layout));
  g_string_append (string, "\n---\n\n");
   dump_attrs (pango_layout_get_attributes (layout), string);
  g_string_append (string, "\n---\n\n");
  dump_lines (layout, string);
  g_string_append (string, "\n---\n\n");
  dump_runs (layout, string);

  g_object_unref (layout);
}
示例#3
0
bool ttext::is_truncated() const
{
	recalculate();

#if PANGO_VERSION_CHECK(1,16,0)
	return (pango_layout_is_ellipsized(layout_) != 0);
#else
	return false;
#endif
}
示例#4
0
文件: ui.c 项目: dbrooke/dantracker
int scroll_text_label(void *data)
{
        struct text_update_ctx *ctx = data;
        PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(ctx->e->widget));

        if (pango_layout_is_ellipsized(layout))
                ctx->curptr += 20;
        else
                ctx->curptr = ctx->orig_value;

        if ((ctx->curptr - ctx->orig_value) > strlen(ctx->orig_value))
                ctx->curptr = ctx->orig_value;

        gtk_label_set_markup(GTK_LABEL(ctx->e->widget), ctx->curptr);

        return TRUE;
}
示例#5
0
文件: ui.c 项目: dbrooke/dantracker
int update_text_label(struct named_element *e, const char *value)
{
        struct text_update_ctx *ctx = e->data;
        PangoLayout *layout;

        if (ctx->orig_value && !strcmp(ctx->orig_value, value))
                return 0;

        free(ctx->orig_value);
        ctx->orig_value = strdup(value);
        ctx->curptr = ctx->orig_value;

        gtk_label_set_markup(GTK_LABEL(e->widget), ctx->orig_value);
        layout = gtk_label_get_layout(GTK_LABEL(e->widget));
        if (pango_layout_is_ellipsized(layout) &&
            !ctx->scroll_fn_running) {
                printf("Scheduling scroll function for %s\n", e->name);
                ctx->scroll_fn_running = 1;
                g_timeout_add(3000, scroll_text_label, ctx);
        }

        return 0;
}
示例#6
0
bool ttext::is_truncated() const
{
	recalculate();

	return (pango_layout_is_ellipsized(layout_) != 0);
}
static void
mx_label_allocate (ClutterActor          *actor,
                   const ClutterActorBox *box,
                   ClutterAllocationFlags flags)
{
  MxLabelPrivate *priv = MX_LABEL (actor)->priv;
  gboolean label_did_fade = priv->label_should_fade;

  ClutterActorClass *parent_class;
  ClutterActorBox child_box;
  gboolean x_fill, y_fill;
  gfloat avail_width;

  parent_class = CLUTTER_ACTOR_CLASS (mx_label_parent_class);
  parent_class->allocate (actor, box, flags);

  mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box);
  avail_width = child_box.x2 - child_box.x1;

  /* The default behaviour of ClutterText is to align to the
   * top-left when it gets more space than is needed. Because
   * of this behaviour, if we're aligning to the left, we can
   * assign all our horizontal space to the label without
   * measuring it (i.e. x-fill), and the same applies for
   * aligning to the top and vertical space.
   */
  x_fill = (priv->x_align == MX_ALIGN_START) ? TRUE : FALSE;
  y_fill = (priv->y_align == MX_ALIGN_START) ? TRUE : FALSE;

  mx_allocate_align_fill (priv->label, &child_box, priv->x_align,
                          priv->y_align, x_fill, y_fill);

  priv->label_should_fade = FALSE;

  if (priv->fade_out)
    {
      /* If we're fading out, make sure the label has its full width
       * allocated. This ensures that the offscreen effect has the full
       * label inside its texture.
       */
      gfloat label_width;

      clutter_actor_get_preferred_width (priv->label, -1, NULL, &label_width);

      if (label_width > avail_width)
        {
          priv->label_should_fade = TRUE;
          child_box.x2 = child_box.x1 + label_width;
        }

      mx_fade_effect_set_bounds (MX_FADE_EFFECT (priv->fade_effect),
                                 0, 0, MIN (label_width, avail_width), 0);
    }

  /* Allocate the label */
  clutter_actor_allocate (priv->label, &child_box, flags);

  if (priv->show_tooltip)
    {
      PangoLayout *layout;
      const gchar *text;

      layout = clutter_text_get_layout (CLUTTER_TEXT (priv->label));

      if (pango_layout_is_ellipsized (layout))
        text = clutter_text_get_text (CLUTTER_TEXT (priv->label));
      else
        text = NULL;

      mx_widget_set_tooltip_text (MX_WIDGET (actor), text);
    }

  /* Animate in/out the faded end of the label */
  if (label_did_fade != priv->label_should_fade)
    {
      /* Begin/reverse the fading timeline when necessary */
      if (priv->label_should_fade)
        clutter_timeline_set_direction (priv->fade_timeline,
                                        CLUTTER_TIMELINE_FORWARD);
      else
        clutter_timeline_set_direction (priv->fade_timeline,
                                        CLUTTER_TIMELINE_BACKWARD);

      if (!clutter_timeline_is_playing (priv->fade_timeline))
        clutter_timeline_rewind (priv->fade_timeline);

      clutter_timeline_start (priv->fade_timeline);
    }
}
示例#8
0
static VALUE
rg_is_ellipsized_p(VALUE self)
{
    return CBOOL2RVAL(pango_layout_is_ellipsized(_SELF(self)));
}
示例#9
0
int
draw_is_ellipsized (drawctx_t *ctx) {
    return pango_layout_is_ellipsized (ctx->pangolayout);
}