示例#1
0
/* This callback serves to keep the markers ordered by their latitude.
 * Markers that are up north on the map should be lowered in the list so that
 * they are drawn the first. This is to make the illusion of a semi-3d plane
 * where the most north you are, the farther you are.
 */
static void
reorder_marker (ClutterGroup *layer,
    ChamplainBaseMarker *marker)
{
  guint i;
  gdouble y, tmp_y, low_y;
  ChamplainBaseMarker *lowest = NULL;

  g_object_get (G_OBJECT (marker), "latitude", &y, NULL);
  y = 90 - y;
  low_y = G_MAXDOUBLE;

  for (i = 0; i < clutter_group_get_n_children (layer); i++)
    {
      ChamplainBaseMarker *prev_marker = CHAMPLAIN_BASE_MARKER (clutter_group_get_nth_child (layer, i));

      if (prev_marker == (ChamplainBaseMarker*) marker)
        continue;

      g_object_get(G_OBJECT(prev_marker), "latitude", &tmp_y, NULL);
      tmp_y = 90 - tmp_y;

      if (y < tmp_y && tmp_y < low_y)
        {
          lowest = prev_marker;
          low_y = tmp_y;
        }
    }

  if (lowest)
    clutter_container_lower_child (CLUTTER_CONTAINER(layer),
        CLUTTER_ACTOR (marker), CLUTTER_ACTOR (lowest));
}
示例#2
0
static VALUE
rbclt_container_lower_child (int argc, VALUE *argv, VALUE self)
{
  ClutterContainer *container = CLUTTER_CONTAINER (RVAL2GOBJ (self));
  VALUE actor, sibling;

  rb_scan_args (argc, argv, "11", &actor, &sibling);

  clutter_container_lower_child (container,
                                 RVAL2GOBJ (actor),
                                 RVAL2GOBJ (sibling));

  return self;
}
示例#3
0
/**
 * clutter_box_pack_before:
 * @box: a #ClutterBox
 * @actor: a #ClutterActor
 * @sibling: (allow-none): a #ClutterActor or %NULL
 * @first_property: the name of the first property to set, or %NULL
 * @Varargs: a list of property name and value pairs, terminated by %NULL
 *
 * Adds @actor to @box, placing it before @sibling, and sets layout
 * properties at the same time, if the #ClutterLayoutManager used by
 * @box supports them
 *
 * If @sibling is %NULL then @actor is placed at the beginning of the
 * list of children, to be allocated and painted below every other child
 *
 * This function is a wrapper around clutter_container_add_actor(),
 * clutter_container_lower_child() and clutter_layout_manager_child_set()
 *
 * Since: 1.2
 */
void
clutter_box_pack_before (ClutterBox   *box,
                         ClutterActor *actor,
                         ClutterActor *sibling,
                         const gchar  *first_property,
                         ...)
{
  va_list var_args;

  g_return_if_fail (CLUTTER_IS_BOX (box));
  g_return_if_fail (CLUTTER_IS_ACTOR (actor));
  g_return_if_fail (sibling == NULL || CLUTTER_IS_ACTOR (sibling));

  clutter_container_add_actor (CLUTTER_CONTAINER (box), actor);
  clutter_container_lower_child (CLUTTER_CONTAINER (box), actor, sibling);

  if (first_property == NULL || *first_property == '\0')
    return;

  va_start (var_args, first_property);
  clutter_box_set_property_valist (box, actor, first_property, var_args);
  va_end (var_args);
}
static void
_zeitgeist_log_find_received (GObject *source_object,
                              GAsyncResult *res,
                              gpointer user_data)
{
  ZeitgeistLog *log = ZEITGEIST_LOG (source_object);
  PengeEverythingPane *pane = user_data;
  PengeEverythingPanePrivate *priv;
  GList *sw_items, *recent_file_items, *l;
  ZeitgeistResultSet *set = NULL;
  GList *old_actors = NULL;
  ClutterActor *actor;
  gboolean show_welcome_tile = TRUE;
  gint recent_files_count, sw_items_count;
  GError *error = NULL;

  g_return_if_fail (PENGE_IS_EVERYTHING_PANE (user_data));

  priv = GET_PRIVATE (pane);

  set = zeitgeist_log_find_events_finish (log, res, &error);
  if (error != NULL)
    {
      g_warning (G_STRLOC ": Error obtaining recent files: %s",
          error->message);
      g_clear_error (&error);
    }

  /* It actually moves the interesting events into a list */
  recent_file_items = _filter_out_unshowable_recent_items (pane, set);
  recent_file_items = g_list_sort (recent_file_items,
                                   (GCompareFunc)_recent_files_sort_func);

  /* Get Sw items */
  sw_items = g_hash_table_get_values (priv->uuid_to_sw_items);
  sw_items = g_list_sort (sw_items,
                          (GCompareFunc)_sw_item_sort_compare_func);

  recent_files_count = priv->block_count * priv->ratio;

  if (recent_files_count > g_list_length (recent_file_items))
    recent_files_count = g_list_length (recent_file_items);

  sw_items_count = priv->block_count - recent_files_count;

  old_actors = g_hash_table_get_values (priv->pointer_to_actor);

  if (sw_items != NULL || recent_file_items != NULL)
  {
    if (priv->welcome_tile)
    {
      clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                      priv->welcome_tile);
      priv->welcome_tile = NULL;
    }
  }

  while ((sw_items_count && sw_items) ||
         (recent_files_count && recent_file_items))
  {
    SwItem *sw_item = NULL;
    ZeitgeistEvent *recent_file_event = NULL;

    /* If no sw items -> force compare to favour recent file */
    if (sw_items_count && sw_items)
      sw_item = (SwItem *)sw_items->data;
    else
      sw_item = NULL;

    /* If no recent files -> force compare to favour sw stuff */
    if (recent_files_count && recent_file_items)
      recent_file_event = recent_file_items->data;
    else
      recent_file_event = NULL;

    if (_compare_item_and_event (sw_item, recent_file_event) < 1)
    {
      /* Sw item is newer */

      actor = g_hash_table_lookup (priv->pointer_to_actor,
                                   sw_item);
      if (!actor)
      {
        actor = _add_from_sw_item (pane, sw_item);
        g_hash_table_insert (priv->pointer_to_actor,
                             sw_item,
                             actor);

        /* Needed to remove from hash when we kill the actor */
        g_object_set_data (G_OBJECT (actor), "data-pointer", sw_item);
      }

      sw_items_count -= _sw_item_weight (sw_item);

      clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                   actor,
                                   "col-span", _sw_item_weight (sw_item),
                                   NULL);

      sw_items = g_list_remove (sw_items, sw_item);

      show_welcome_tile = FALSE;
    } else {
      /* Recent file item is newer */

      actor = g_hash_table_lookup (priv->pointer_to_actor,
                                   recent_file_event);

      if (!actor)
      {
        const gchar *uri = NULL;
        gchar *thumbnail_path = NULL;
        ZeitgeistSubject *subj;

        /* FIXME we assume there is only one subject */
        subj = zeitgeist_event_get_subject (recent_file_event, 0);
        uri = zeitgeist_subject_get_uri (subj);

        thumbnail_path = mpl_utils_get_thumbnail_path (uri);

        actor = _add_from_recent_file_event (pane,
                                            recent_file_event,
                                            thumbnail_path);
        g_free (thumbnail_path);
        g_hash_table_insert (priv->pointer_to_actor,
                             recent_file_event,
                             actor);

        /* Needed to remove from hash when we kill the actor */
        g_object_set_data (G_OBJECT (actor), "data-pointer", recent_file_event);

        show_welcome_tile = FALSE;
      }

      recent_files_count--;

      g_object_unref (recent_file_event);
      recent_file_items = g_list_remove (recent_file_items,
                                         recent_file_event);
    }

    clutter_container_lower_child (CLUTTER_CONTAINER (pane),
                                   actor,
                                   NULL);

    old_actors = g_list_remove (old_actors, actor);
  }

  for (l = old_actors; l; l = l->next)
  {
    gpointer p;
    p = g_object_get_data (G_OBJECT (l->data), "data-pointer");

    if (p)
    {
      clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                      CLUTTER_ACTOR (l->data));
      g_hash_table_remove (priv->pointer_to_actor, p);
    }
  }

  g_list_free (old_actors);

  if (show_welcome_tile && !priv->welcome_tile)
  {
    priv->welcome_tile = penge_welcome_tile_new ();
    clutter_container_add_actor (CLUTTER_CONTAINER (pane),
                                 priv->welcome_tile);
    clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                 priv->welcome_tile,
                                 "col-span", 3,
                                 NULL);
  }

  g_list_free (sw_items);

  for (l = recent_file_items; l; l = l->next)
  {
    ZeitgeistEvent *recent_file_event = l->data;
    g_object_unref (recent_file_event);
  }
  g_list_free (recent_file_items);

}