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;
}
static void
penge_count_tile_update_tooltip (PengeCountTile *self)
{
  PengeCountTilePrivate *priv = self->priv;
  gchar *tooltip_str;
  tooltip_str = g_strdup_printf ("%s\n%s",
                                 mx_label_get_text (MX_LABEL (priv->message_label)),
                                 mx_label_get_text (MX_LABEL (priv->account_label)));
  mx_widget_set_tooltip_text (MX_WIDGET (self), tooltip_str);
  g_free (tooltip_str);
}
static void
penge_count_tile_set_compact (PengeCountTile *self,
                              gboolean        compact)
{
  PengeCountTilePrivate *priv = self->priv;

  if (priv->compact == compact)
    return;

  priv->compact = compact;
  if (compact)
  {
    clutter_actor_set_width (CLUTTER_ACTOR (self), -1);
    
    g_object_ref (priv->count_label);
    clutter_container_remove_actor (CLUTTER_CONTAINER (priv->table),
                                    priv->count_label);
    clutter_actor_unparent (priv->count_label);
    clutter_actor_add_child ((self), priv->count_label);

    penge_count_tile_update_tooltip (self);
  }
  else
  {
    clutter_actor_set_width (CLUTTER_ACTOR (self), 280);
    clutter_actor_reparent (priv->count_label, priv->table);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->table),
                                 priv->count_label,
                                 "column", 0,
                                 "row", 0,
                                 "row-span", 2,
                                 "x-expand", FALSE,
                                 NULL);
    clutter_actor_add_child ((self), priv->table);

    mx_widget_set_tooltip_text (MX_WIDGET (self), NULL);
  }
}
static void
mnb_toolbar_clock_update_time_date (MnbToolbarClock *clock)
{
  MnbToolbarClockPrivate *priv = clock->priv;

  time_t           t;
  struct tm       *tmp;
  char             time_str[64];
  static gboolean  setup_done = FALSE;
  GConfClient     *client;
  char            *time_ptr;

  if (priv->disposed)
    return;

  client = gconf_client_get_default ();

  t = time (NULL);
  tmp = localtime (&t);
  if (tmp)
    {
      gboolean c24h = gconf_client_get_bool (client, MNB_24H_KEY, NULL);

      if (c24h)
        {

          /* translators: translate this to a suitable 24 hourt time format for
           * your locale showing only hours and minutes. For available format
           * specifiers see
           * http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
           */
          strftime (time_str, 64, _("%H:%M"), tmp);
        }
      else
        {
          /* translators: translate this to a suitable default time format for
           * your locale showing only hours and minutes. For available format
           * specifiers see
           * http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
           */
          strftime (time_str, 64, _("%l:%M %P"), tmp);
        }
    }
  else
    snprintf (time_str, 64, "Time");

  /*
   * Strip leading space, if any.
   */
  if (time_str[0] == ' ')
    time_ptr = &time_str[1];
  else
    time_ptr = &time_str[0];

  mx_button_set_label (MX_BUTTON (clock), time_ptr);

  if (tmp)
    /* translators: translate this to a suitable date format for your locale.
     * For availabe format specifiers see
     * http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
     */
    strftime (time_str, 64, _("%B %e, %Y"), tmp);
  else
    snprintf (time_str, 64, "Date");

  mx_widget_set_tooltip_text (MX_WIDGET (clock), time_str);

  if (!setup_done)
    {
      GError *error = NULL;

      setup_done = TRUE;

      gconf_client_add_dir (client, MNB_24H_KEY_DIR,
                            GCONF_CLIENT_PRELOAD_NONE,
                            &error);

      if (error)
        {
          g_warning (G_STRLOC ": Error when adding directory "
                     MNB_24H_KEY_DIR " for notification: %s",
                     error->message);
          g_clear_error (&error);
        }

      gconf_client_notify_add (client,
                               MNB_24H_KEY,
                               mnb_toolbar_clock_format_changed_cb,
                               clock,
                               NULL,
                               &error);

      if (error)
        {
          g_warning (G_STRLOC ": Error when adding key "
                     MNB_24H_KEY " for notification: %s",
                     error->message);
          g_clear_error (&error);
        }
    }

  g_object_unref (client);
}
Beispiel #5
0
void
scroll_grid_main (ClutterContainer *stage)
{
  ClutterActor *scroll, *grid, *table, *label, *visible_entry, *stride_entry;
  int i;

  scroll = mx_scroll_view_new ();
  clutter_container_add_actor (stage, scroll);
  clutter_actor_set_position (scroll, 10, 10);

  clutter_actor_set_size (scroll, 400, 400);

  grid = mx_grid_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll), grid);

  for (i = 1; i <= 200; i++)
    {
      ClutterActor *button;
      gchar *text;

      text = g_strdup_printf ("Button %d", i);

      button = mx_button_new_with_label (text);
      clutter_container_add_actor (CLUTTER_CONTAINER (grid), button);
      mx_widget_set_tooltip_text (MX_WIDGET (button), "test");
      if (i == 1)
        g_signal_connect (button,
                          "clicked",
                          G_CALLBACK (swap_orientation),
                          grid);

      g_free (text);
    }

  table = mx_table_new ();

  label = mx_label_new_with_text ("Make button visible:");
  visible_entry = mx_entry_new ();
  mx_table_insert_actor_with_properties (MX_TABLE (table),
                                         label,
                                         0, 0,
                                         "x-expand", FALSE,
                                         NULL);
  mx_table_insert_actor (MX_TABLE (table), visible_entry, 0, 1);

  label = mx_label_new_with_text ("Set max-stride:");
  stride_entry = mx_entry_new ();
  mx_table_insert_actor_with_properties (MX_TABLE (table),
                                         label,
                                         1, 0,
                                         "x-expand", FALSE,
                                         NULL);
  mx_table_insert_actor (MX_TABLE (table), stride_entry, 1, 1);

  clutter_actor_set_position (table, 10, 420);
  clutter_actor_set_width (table, 400);
  clutter_container_add_actor (stage, table);

  g_signal_connect (mx_entry_get_clutter_text (MX_ENTRY (visible_entry)),
                    "activate",
                    G_CALLBACK (ensure_visible),
                    grid);

  g_signal_connect (mx_entry_get_clutter_text (MX_ENTRY (stride_entry)),
                    "activate",
                    G_CALLBACK (set_max_stride), grid);
}
Beispiel #6
0
static void
penge_app_tile_constructed (GObject *object)
{
  PengeAppTilePrivate *priv = GET_PRIVATE (object);
  GKeyFile *kf;
  gchar *path;
  GError *error = NULL;
  gchar *name = NULL;

  g_return_if_fail (priv->bookmark);

  if (!priv->bookmark)
    return;

  priv->icon_theme = gtk_icon_theme_get_default ();
  g_signal_connect (priv->icon_theme,
                    "changed",
                    (GCallback)_icon_theme_changed_cb,
                    object);

  path = g_filename_from_uri (priv->bookmark, NULL, &error);

  if (path)
  {
    priv->app_info = G_APP_INFO (g_desktop_app_info_new_from_filename (path));
    kf = g_key_file_new ();
    if (!g_key_file_load_from_file (kf,
                                    path,
                                    G_KEY_FILE_NONE,
                                    &error))
    {
      g_warning (G_STRLOC ": Error getting a key file for path: %s",
                 error->message);
      g_clear_error (&error);
    } else {
      name = g_key_file_get_locale_string (kf,
                                           G_KEY_FILE_DESKTOP_GROUP,
                                           "X-GNOME-FullName",
                                           NULL,
                                           NULL);

      if (!name)
      {
        name = g_key_file_get_locale_string (kf,
                                             G_KEY_FILE_DESKTOP_GROUP,
                                             G_KEY_FILE_DESKTOP_KEY_NAME,
                                             NULL,
                                             NULL);
      }

      mx_widget_set_tooltip_text (MX_WIDGET (object),
                                  name);
      g_free (name);
    }
    g_key_file_free (kf);

    g_free (path);
  }

  if (error)
  {
    g_warning (G_STRLOC ": Error getting info from bookmark: %s",
               error->message);
    g_clear_error (&error);
  }

  _update_icon_from_icon_theme ((PengeAppTile *)object);
}
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);
    }
}