示例#1
0
static void
trash_backend_item_count_changed (gpointer user_data)
{
  GVfsBackendTrash *backend = user_data;
  GVfsMonitor *file_monitor;
  GVfsMonitor *dir_monitor;

  file_monitor = trash_backend_get_file_monitor (backend, FALSE);
  dir_monitor = trash_backend_get_dir_monitor (backend, FALSE);

  if (file_monitor)
    {
      g_vfs_monitor_emit_event (file_monitor,
                                G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED,
                                "/", NULL);

      g_object_unref (file_monitor);
    }

  if (dir_monitor)
    {
      g_vfs_monitor_emit_event (dir_monitor,
                                G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED,
                                "/", NULL);

      g_object_unref (dir_monitor);
    }
}
示例#2
0
static void
trash_backend_item_deleted (TrashItem *item,
                            gpointer   user_data)
{
  GVfsBackendTrash *backend = user_data;
  GVfsMonitor *monitor;

  monitor = trash_backend_get_dir_monitor (backend, FALSE);

  if (monitor)
    {
      char *slashname;

      slashname = g_strconcat ("/", trash_item_get_escaped_name (item), NULL);
      g_vfs_monitor_emit_event (monitor, G_FILE_MONITOR_EVENT_DELETED,
                                slashname, NULL);
      g_object_unref (monitor);
      g_free (slashname);
    }
}
示例#3
0
static void
reload_recent_items (GVfsBackendRecent *backend)
{
  GVfsMonitor *monitor;
  GList *items;
  GList *node;
  GList *added = NULL;
  GList *changed = NULL;
  GList *not_seen_items = NULL;
  GList *l;

  not_seen_items = g_hash_table_get_values (backend->items);
  items = gtk_recent_manager_get_items (backend->recent_manager);
  for (node = items; node; node = node->next)
    {
      GtkRecentInfo *recent_info = node->data;
      const char *uri;
      const char *guid;

      if (!gtk_recent_info_is_local (recent_info)
          || gtk_recent_info_get_private_hint (recent_info)
          || g_strcmp0 (gtk_recent_info_get_mime_type (recent_info), "inode/directory") == 0)
        continue;

      uri = gtk_recent_info_get_uri (recent_info);
      guid = g_hash_table_lookup (backend->uri_map, uri);
      if (guid)
        {
          if (gtk_recent_info_exists (recent_info))
            {
              RecentItem *item;
              item = g_hash_table_lookup (backend->items, guid);
              if (recent_item_update (item, recent_info))
                changed = g_list_prepend (changed, item->guid);
              not_seen_items = g_list_remove (not_seen_items, item);
            }
        }
      else
        {
          RecentItem *item;
          item = recent_item_new (recent_info);
          added = g_list_prepend (added, item->guid);
          g_hash_table_insert (backend->items, item->guid, item);
          g_hash_table_insert (backend->uri_map, item->uri, item->guid);
        }
      gtk_recent_info_unref (recent_info);
    }

  g_list_free (items);

  monitor = recent_backend_get_dir_monitor (backend, FALSE);

  /* process removals */
  for (l = not_seen_items; l; l = l->next)
    {
      RecentItem *item = l->data;
      g_hash_table_remove (backend->uri_map, item->uri);
      g_hash_table_steal (backend->items, item->guid);
      if (monitor)
        g_vfs_monitor_emit_event (monitor, G_FILE_MONITOR_EVENT_DELETED, item->guid, NULL);
      recent_item_free (item);
    }
  g_list_free (not_seen_items);

  /* process additions */
  if (monitor)
    {
      for (l = added; l; l = l->next)
        g_vfs_monitor_emit_event (monitor, G_FILE_MONITOR_EVENT_CREATED, l->data, NULL);
    }
  g_list_free (added);

  /* process changes */
  for (l = changed; l; l = l->next)
    {
      /* FIXME: signals */
    }
  g_list_free (changed);

  if (monitor)
    g_object_unref (monitor);
}