예제 #1
0
static gboolean
mex_suggest_timeout_cb (MexSearchPlugin *self)
{
  gchar *uri;
  const gchar *text;
  MexDownloadQueue *dq;

  MexSearchPluginPrivate *priv = self->priv;

  priv->suggest_timeout = 0;

  text = mx_entry_get_text (MX_ENTRY (priv->search_entry));

  dq = mex_download_queue_get_default ();

  if (priv->suggest_id)
    mex_download_queue_cancel (dq, priv->suggest_id);

  uri =
    g_strdup_printf ("http://google.com/complete/search?output=toolbar&q=%s",
                     text);
  priv->suggest_id =
    mex_download_queue_enqueue (dq, uri, mex_suggest_complete_cb, self);

  return FALSE;
}
예제 #2
0
static void
mex_content_tile_dispose (GObject *object)
{
  MexContentTilePrivate *priv = MEX_CONTENT_TILE (object)->priv;

  if (priv->content)
    {
      /* remove the reference to the MexContent and also disconnect the signal
       * handlers */
      mex_content_tile_set_content (MEX_CONTENT_VIEW (object), NULL);
    }

  if (priv->model)
    {
      g_object_unref (priv->model);
      priv->model = NULL;
    }

  if (priv->download_id)
    {
      MexDownloadQueue *dl_queue = mex_download_queue_get_default ();
      mex_download_queue_cancel (dl_queue, priv->download_id);
      priv->download_id = NULL;
    }

  G_OBJECT_CLASS (mex_content_tile_parent_class)->dispose (object);
}
예제 #3
0
static void
_update_thumbnail (MexContentTile *tile)
{
  MexContentTilePrivate *priv = tile->priv;
  MexDownloadQueue *queue;
  const gchar *file;

  queue = mex_download_queue_get_default ();

  /* cancel any download already in progress */
  if (priv->download_id)
    {
      mex_download_queue_cancel (queue, priv->download_id);
      priv->download_id = NULL;
    }

  /* update thumbnail */
  file = mex_content_get_metadata (priv->content,
                                   MEX_CONTENT_METADATA_STILL);

  /* TODO: Display a spinner? */
  if (file)
    priv->download_id =
      mex_download_queue_enqueue (queue, file,
                                  download_queue_completed,
                                  tile);
  else
    priv->thumbnail_loaded = TRUE;
}
예제 #4
0
static void
_update_thumbnail (MexContentTile *tile)
{
  MexContentTilePrivate *priv = tile->priv;
  MexDownloadQueue *queue;
  const gchar *uri;
  GFile *file;

  queue = mex_download_queue_get_default ();

  /* cancel any download already in progress */
  if (priv->download_id)
    {
      mex_download_queue_cancel (queue, priv->download_id);
      priv->download_id = NULL;
    }

  /* update thumbnail */
  uri = mex_content_get_metadata (priv->content,
                                  MEX_CONTENT_METADATA_STILL);
  if (uri)
    {
      file = g_file_new_for_uri (uri);

      /* TODO: Display a spinner? */
      if (file)
        {
          gchar *path = g_file_get_path (file);

          if (path)
            {
              mx_image_set_from_file_at_size (MX_IMAGE (priv->image), path,
                                              priv->thumb_width,
                                              priv->thumb_height,
                                              NULL);
              priv->thumbnail_loaded = TRUE;
              priv->image_set = TRUE;
              clutter_actor_set_size (priv->image,
                                      priv->thumb_width, priv->thumb_height);
              g_free (path);
            }
          else
            {
              priv->download_id =
                mex_download_queue_enqueue (queue, uri,
                                            download_queue_completed,
                                            tile);
            }

          g_object_unref (file);
        }
    }
  else
    priv->thumbnail_loaded = TRUE;
}
예제 #5
0
static void
mex_search_plugin_dispose (GObject *object)
{
  MexSearchPlugin *self = MEX_SEARCH_PLUGIN (object);
  MexSearchPluginPrivate *priv = self->priv;

  mex_model_manager_remove_category (mex_model_manager_get_default (),
                                     "search");

  if (priv->history_model)
    {
      g_object_unref (priv->history_model);
      priv->history_model = NULL;
    }

  if (priv->suggest_model)
    {
      g_object_unref (priv->suggest_model);
      priv->suggest_model = NULL;
    }

  if (priv->suggest_timeout)
    {
      g_source_remove (priv->suggest_timeout);
      priv->suggest_timeout = 0;
    }

  if (priv->suggest_id)
    {
      MexDownloadQueue *dq = mex_download_queue_get_default ();
      mex_download_queue_cancel (dq, priv->suggest_id);
      priv->suggest_id = NULL;
    }

  if (priv->search_proxy)
    {
      g_object_unref (priv->search_proxy);
      priv->search_proxy = NULL;
    }

  if (priv->search_page)
    {
      g_object_unref (priv->search_page);
      priv->search_page = NULL;
    }

  if (priv->action_info.action)
    {
      g_object_unref (priv->action_info.action);
      priv->action_info.action = NULL;
    }

  G_OBJECT_CLASS (mex_search_plugin_parent_class)->dispose (object);
}
예제 #6
0
static void
mex_content_tile_dispose (GObject *object)
{
  MexContentTilePrivate *priv = MEX_CONTENT_TILE (object)->priv;

  if (priv->content)
    {
      /* remove the reference to the MexContent and also disconnect the signal
       * handlers */
      mex_content_tile_set_content (MEX_CONTENT_VIEW (object), NULL);
    }

  if (priv->model)
    {
      g_object_unref (priv->model);
      priv->model = NULL;
    }

  if (priv->download_id)
    {
      MexDownloadQueue *dl_queue = mex_download_queue_get_default ();
      mex_download_queue_cancel (dl_queue, priv->download_id);
      priv->download_id = NULL;
    }

  if (priv->start_video_preview > 0)
    g_source_remove (priv->start_video_preview);

  if (priv->stop_video_preview > 0)
    g_source_remove (priv->stop_video_preview);

  /* This may or may not be parented so explicitly mark for destroying */
  if (priv->video_preview)
    {
      clutter_actor_destroy (CLUTTER_ACTOR (priv->video_preview));
      priv->video_preview = NULL;
    }

  G_OBJECT_CLASS (mex_content_tile_parent_class)->dispose (object);
}
예제 #7
0
static void
_reset_thumbnail (MexContentTile *tile)
{
  MexContentTilePrivate *priv = tile->priv;
  MexDownloadQueue *queue = mex_download_queue_get_default ();
  const gchar *mime = NULL;
  gchar *placeholder_filename = NULL;

  queue = mex_download_queue_get_default ();

  /* cancel any download already in progress */
  if (priv->download_id)
    {
      mex_download_queue_cancel (queue, priv->download_id);
      priv->download_id = NULL;
    }

  priv->thumbnail_loaded = FALSE;

  /* Load placeholder image */
  if (priv->content)
    mime = mex_content_get_metadata (priv->content,
                                     MEX_CONTENT_METADATA_MIMETYPE);

  if (mime && g_str_has_prefix (mime, "image/"))
    {
      placeholder_filename = "thumb-image.png";
    }
  else if (mime && g_str_equal (mime, "x-mex/tv"))
    {
      placeholder_filename = "thumb-tv.png";
    }
  else if (mime && g_str_equal (mime, "video/dvd"))
    {
      placeholder_filename = "thumb-disc.png";
    }
  else if (mime && (g_str_has_prefix (mime, "video/") ||
                    g_str_equal (mime, "x-mex/media")))
    {
      placeholder_filename = "thumb-video.png";
    }
  else if (mime && (g_str_has_prefix (mime, "audio/")))
    {
      placeholder_filename = "thumb-music.png";
    }
  else if (mime && g_str_equal (mime, "x-grl/box"))
    {
      placeholder_filename = "folder-tile.png";
    }
  else if (mime && g_str_equal (mime, "x-mex/group"))
    {
      placeholder_filename = "folder-tile.png";
    }
  else if (mime && g_str_equal (mime, "x-mex/app"))
    {
      placeholder_filename = "thumb-app.png";
    }

  if (placeholder_filename)
    {
      gchar *tmp;
      const gchar *dir = mex_get_data_dir ();

      tmp = g_build_filename (dir, "style", placeholder_filename, NULL);
      _update_thumbnail_from_image (tile, tmp);
      g_free (tmp);
    }
  else
    {
      mx_image_clear (MX_IMAGE (priv->image));

      /* Reset the height - really, we ought to reset the width and height,
       * but for all our use-cases, we want to keep the set width.
       */
      clutter_actor_set_height (priv->image, -1);
      priv->image_set = FALSE;

      return;
    }

  clutter_actor_set_size (priv->image,
                          priv->thumb_width, priv->thumb_height);
}