Esempio n. 1
0
static void
xfae_model_init (XfaeModel *model)
{
  XfaeItem *item;
  gchar   **files;
  guint     n;

  model->stamp = g_random_int ();

  files = xfce_resource_match (XFCE_RESOURCE_CONFIG, "autostart/*.desktop", TRUE);
  for (n = 0; files[n] != NULL; ++n)
    {
      item = xfae_item_new (files[n]);
      if (G_LIKELY (item != NULL))
        model->items = g_list_prepend (model->items, item);
    }
  g_strfreev (files);

  model->items = g_list_sort (model->items, xfae_model_sort_items);
}
Esempio n. 2
0
static
GList *zone_scan(char *dir)
{
	GList *buf=NULL;
	int i;

	// search the zones
	fwtime_find(dir);

	// sort them and add a "" item after each (required by libdialog)
	zones = g_list_sort(zones, sort_zones);
	for (i=0; i<g_list_length(zones); i++)
	{
		buf = g_list_append(buf, g_list_nth_data(zones, i));
		buf = g_list_append(buf, "");
	}
	g_list_free(zones);
	zones = buf;
	return(zones);
}
Esempio n. 3
0
EXPORT_C
#endif

GList *
gst_audio_default_registry_mixer_filter (GstAudioMixerFilterFunc filter_func,
    gboolean first, gpointer data)
{
  GList *mixer_list = NULL;
  GList *feature_list;
  GList *walk;

  /* go through all elements of a certain class and check whether
   * they implement a mixer. If so, add it to the list. */
  feature_list = gst_registry_get_feature_list (gst_registry_get_default (),
      GST_TYPE_ELEMENT_FACTORY);

  feature_list = g_list_sort (feature_list, element_factory_rank_compare_func);

  for (walk = feature_list; walk != NULL; walk = walk->next) {
    GstElementFactory *factory;
    const gchar *klass;

    factory = GST_ELEMENT_FACTORY (walk->data);

    /* check category */
    klass = gst_element_factory_get_klass (factory);
    if (strcmp (klass, "Generic/Audio") == 0) {
      gst_audio_mixer_filter_probe_feature (filter_func, factory,
          &mixer_list, first, data);
    }

    if (first && mixer_list != NULL) {
      GST_DEBUG ("Stopping after first found mixer, as requested");
      break;
    }
  }

  gst_plugin_feature_list_free (feature_list);

  return g_list_reverse (mixer_list);
}
/**
 * on_workspace_scrolled:
 * @ebox: the plugin's event box
 * @ev: the event data
 * @data: the workspace plugin
 *
 * Workspace scroll event handler.
 *
 * Returns: TRUE to stop event propogation
 */
static gboolean
on_workspace_scrolled(GtkWidget *ebox, GdkEventScroll *ev, gpointer data)
{
    i3WorkspacesPlugin *i3_workspaces = (i3WorkspacesPlugin *)data;

    GList *wlist = g_hash_table_get_keys(i3_workspaces->workspace_buttons);
    wlist = g_list_sort(wlist, (GCompareFunc) i3wm_workspace_cmp);

    /* Find the focused workspace */
    i3workspace *workspace = NULL;
    GList *witem = NULL;
    for (witem = wlist; witem != NULL; witem = witem->next)
    {
        workspace = (i3workspace *) witem->data;
        if (workspace->focused)
            break;
    }

    if (witem == NULL)
        return FALSE;

    if (ev->direction == GDK_SCROLL_DOWN)
        witem = witem->next;
    else if (ev->direction == GDK_SCROLL_UP)
        witem = witem->prev;
    else
        return FALSE;

    if (witem == NULL)
        return FALSE;

    workspace = (i3workspace *) witem->data;

    GError *err = NULL;
    i3wm_goto_workspace(i3_workspaces->i3wm, workspace, &err);
    if (err != NULL)
    {
        fprintf(stderr, "%s", err->message);
    }
    return TRUE;
}
Esempio n. 5
0
SaErrorT oh_add_domain_conf(const char *host,
                            unsigned short port,
                            SaHpiDomainIdT *did)
{
    g_static_rec_mutex_lock(&ohc_lock);

    // get all known domain ids and sort them
    GList *keys = 0;
    g_hash_table_foreach(ohc_domains, extract_keys, &keys);
    keys = g_list_sort(keys, (GCompareFunc)compare_keys);

    // found prev = a gap in domain ids list or max domain id
    // so that new did will be prev + 1
    SaHpiDomainIdT prev_did = 0;
    GList *item;
    for (item = keys; item != NULL; item = item->next) {
        SaHpiDomainIdT item_did = *(const SaHpiDomainIdT *)(item->data);
        if ((prev_did + 1) < item_did) {
            break;
        }
        prev_did = item_did;
    }

    g_list_free(keys);

    if (prev_did == SAHPI_UNSPECIFIED_DOMAIN_ID) {
        g_static_rec_mutex_unlock(&ohc_lock);
        return SA_ERR_HPI_OUT_OF_SPACE;
    }
    if ((prev_did + 1) == SAHPI_UNSPECIFIED_DOMAIN_ID) {
        g_static_rec_mutex_unlock(&ohc_lock);
        return SA_ERR_HPI_OUT_OF_SPACE;
    }

    *did = prev_did + 1;
    add_domain_conf(*did, host, port);

    g_static_rec_mutex_unlock(&ohc_lock);

    return SA_OK;
}
Esempio n. 6
0
static void
gtk_icon_view_accessible_model_rows_reordered (GtkTreeModel *tree_model,
                                               GtkTreePath  *path,
                                               GtkTreeIter  *iter,
                                               gint         *new_order,
                                               gpointer     user_data)
{
  GtkIconViewAccessible *view;
  GtkIconViewItemAccessibleInfo *info;
  GtkIconView *icon_view;
  GtkIconViewItemAccessible *item;
  GList *items;
  AtkObject *atk_obj;
  gint *order;
  gint length, i;

  atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
  icon_view = GTK_ICON_VIEW (user_data);
  view = (GtkIconViewAccessible*)atk_obj;

  length = gtk_tree_model_iter_n_children (tree_model, NULL);

  order = g_new (gint, length);
  for (i = 0; i < length; i++)
    order [new_order[i]] = i;

  items = view->items;
  while (items)
    {
      info = items->data;
      item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
      info->index = order[info->index];
      item->item = g_list_nth_data (icon_view->priv->items, info->index);
      items = items->next;
    }
  g_free (order);
  view->items = g_list_sort (view->items,
                             (GCompareFunc)gtk_icon_view_accessible_item_compare);

  return;
}
Esempio n. 7
0
File: gtkstock.c Progetto: BYC/gtk
/**
 * gtk_stock_list_ids:
 * 
 * Retrieves a list of all known stock IDs added to a #GtkIconFactory
 * or registered with gtk_stock_add(). The list must be freed with g_slist_free(),
 * and each string in the list must be freed with g_free().
 *
 * Return value: (element-type utf8) (transfer full): a list of known stock IDs
 **/
GSList*
gtk_stock_list_ids (void)
{
  GList *ids;
  GList *icon_ids;
  GSList *retval;
  const gchar *last_id;
  
  init_stock_hash ();

  ids = g_hash_table_get_keys (stock_hash);
  icon_ids = _gtk_icon_factory_list_ids ();
  ids = g_list_concat (ids, icon_ids);

  ids = g_list_sort (ids, (GCompareFunc)strcmp);

  last_id = NULL;
  retval = NULL;
  while (ids != NULL)
    {
      GList *next;

      next = g_list_next (ids);

      if (last_id && strcmp (ids->data, last_id) == 0)
        {
          /* duplicate, ignore */
        }
      else
        {
          retval = g_slist_prepend (retval, g_strdup (ids->data));
          last_id = ids->data;
        }

      g_list_free_1 (ids);
      
      ids = next;
    }

  return retval;
}
Esempio n. 8
0
File: cvar.c Progetto: jdolan/quetoo
/**
 * @brief Enumerates all known variables with the given function.
 */
void Cvar_Enumerate(Cvar_Enumerator func, void *data) {
	GList *sorted = NULL;

	GHashTableIter iter;
	gpointer key, value;
	g_hash_table_iter_init(&iter, cvar_vars);

	while (g_hash_table_iter_next(&iter, &key, &value)) {
		const GQueue *queue = (GQueue *) value;

		for (GList *list = queue->head; list; list = list->next) {
			sorted = g_list_concat(sorted, g_list_copy(list));
		}
	}

	sorted = g_list_sort(sorted, Cvar_Enumerate_comparator);

	g_list_foreach(sorted, (GFunc) func, data);

	g_list_free(sorted);
}
Esempio n. 9
0
static gboolean
do_snapshot (GObject             *instance,
             const gchar         *action_name,
             guint                key_val,
             ClutterModifierType  modifiers,
             gpointer             user_data)
{
  MexDebugPlugin *plugin = MEX_DEBUG_PLUGIN (user_data);
  MexDebugPluginPrivate *priv = plugin->priv;

  if (priv->snapshot)
    {
      priv->gobject_list.free_summary (priv->snapshot);
      priv->snapshot = NULL;
    }

  priv->snapshot = priv->gobject_list.get_summary ();
  priv->snapshot = g_list_sort (priv->snapshot, tuplestrcmp);

  return TRUE;
}
Esempio n. 10
0
int find_x_layout(char *dirname)
{
	struct dirent *ent;
	struct stat statbuf;
	char *fn;

	DIR *dir = opendir(dirname);
	if (!dir) {
		return -1;
	}
	while ((ent = readdir(dir)) != NULL) {
		fn = g_strdup_printf("%s/%s", dirname, ent->d_name);
		if(!stat(fn, &statbuf) && S_ISREG(statbuf.st_mode) && (strlen(ent->d_name) <= 3))
			xkeymap = g_list_append(xkeymap, strdup(ent->d_name));
		free(fn);
	}
	xkeymap = g_list_sort(xkeymap, cmp_str);

	closedir(dir);
	return(0);
}
Esempio n. 11
0
static void
append_account_tree (xmlNodePtr parent,
                     Account *account,
                     gboolean allow_incompat)
{
    GList *children, *node;

    children = gnc_account_get_children(account);
    children = g_list_sort(children, qof_instance_guid_compare);
    for (node = children; node; node = node->next)
    {
        xmlNodePtr accnode;
        Account *account;

        account = node->data;
        accnode = gnc_account_dom_tree_create(account, FALSE, allow_incompat);
        xmlAddChild (parent, accnode);
        append_account_tree(accnode, account);
    }
    g_list_free(children);
}
Esempio n. 12
0
const struct oh_domain_conf * oh_get_next_domain_conf(SaHpiEntryIdT entry_id,
                                                     SaHpiEntryIdT *next_entry_id)
{
    struct oh_domain_conf *dc;
    int did, nextdid = SAHPI_UNSPECIFIED_DOMAIN_ID;

    g_static_rec_mutex_lock(&ohc_lock);

    // get all known domain ids and sort them
    GList *keys = 0;
    g_hash_table_foreach(ohc_domains, extract_keys, &keys);
    keys = g_list_sort(keys, (GCompareFunc)compare_keys);

    // DomainId is used for EntryId
    if (entry_id == SAHPI_FIRST_ENTRY) // get first valid domain id
       did = *(const SaHpiDomainIdT *)(keys->data);
    else // EntryId already must be a valid domain id
       did = (SaHpiDomainIdT) entry_id;

    dc = (struct oh_domain_conf *)g_hash_table_lookup(ohc_domains, &did);

    if (dc != NULL) { 
       // search first domain id > did
       GList *item;
       item = keys;
       while (item != NULL && nextdid <= did) {
          nextdid = *(const SaHpiDomainIdT *)(item->data);
          item = item->next;
       }
       if (nextdid == did) // no next domain id found
          *next_entry_id = SAHPI_LAST_ENTRY;
       else *next_entry_id = (SaHpiEntryIdT) nextdid;
    }
    else *next_entry_id = SAHPI_LAST_ENTRY;

    g_list_free(keys);
    g_static_rec_mutex_unlock(&ohc_lock);

    return dc;
}
Esempio n. 13
0
GList * RecentManager::filterRecent(GList * items, bool xoj) {
	XOJ_CHECK_TYPE(RecentManager);

	GList * filteredItems = NULL;

	// filter
	for (GList * l = items; l != NULL; l = l->next) {
		GtkRecentInfo * info = (GtkRecentInfo *) l->data;
		const char * uri = gtk_recent_info_get_uri(info);

		// Skip remote files anyway, PDF are supported as remote, XOJ not
		if (!g_str_has_prefix(uri, "file://")) {
			continue;
		}

		GFile * file = g_file_new_for_uri(uri);

		// skipt not existing files
		if (!g_file_query_exists(file, NULL)) {
			g_object_unref(file);
			continue;
		}
		g_object_unref(file);

		if (xoj) {
			if (g_str_has_suffix(uri, ".xoj")) {
				filteredItems = g_list_prepend(filteredItems, info);
			}
		} else {
			if (g_str_has_suffix(uri, ".pdf")) {
				filteredItems = g_list_prepend(filteredItems, info);
			}
		}
	}

	// sort
	filteredItems = g_list_sort(filteredItems, (GCompareFunc) sortRecentsEntries);

	return filteredItems;
}
Esempio n. 14
0
static void
add_child (GtkTreeStore   *store,
           GimpHelpDomain *domain,
           GimpHelpLocale *locale,
           GtkTreeIter    *parent,
           GimpHelpItem   *item,
           gint            depth)
{
  GtkTreeIter  iter;
  GList       *list;
  gchar       *uri;

  gtk_tree_store_append (store, &iter, parent);

  gtk_tree_store_set (store, &iter,
                      0, item,
                      1, item->title,
                      -1);

  uri = g_strconcat (domain->help_uri,  "/",
                     locale->locale_id, "/",
                     item->ref,
                     NULL);

  g_hash_table_insert (uri_hash_table,
                       uri,
                       gtk_tree_iter_copy (&iter));

  if (depth + 1 == GIMP_HELP_BROWSER_INDEX_MAX_DEPTH)
    return;

  item->children = g_list_sort (item->children, help_item_compare);

  for (list = item->children; list; list = g_list_next (list))
    {
      GimpHelpItem *item = list->data;

      add_child (store, domain, locale, &iter, item, depth + 1);
    }
}
Esempio n. 15
0
void
load_bookmarks ()
{
  GList *tmp;
  GtkWidget *menu_item;


	/* sort marks so that they are listed alphabetically */
	cfg.bookmarks = g_list_sort(cfg.bookmarks, sort_bookmarks);

  for (tmp = cfg.bookmarks; tmp != NULL; tmp = tmp->next)
    {
			gchar bookmark[((2 * PATH_MAX)+5)];
      Bookmarks *bk = tmp->data;
			if(!strcmp(bk->file, "../"))
			{
				g_snprintf(bookmark, sizeof(bookmark), "%s       %s", bk->mark, 
					bk->dir);
			}
			else
			{
				g_snprintf(bookmark, sizeof(bookmark), "%s       %s/%s", bk->mark,
						bk->dir, bk->file);
			}

      menu_item = gtk_menu_item_new_with_label (bookmark);
      gtk_widget_set_name (GTK_WIDGET (menu_item), bookmark);
      gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
			  GTK_SIGNAL_FUNC (goto_bookmark), bk->mark);
      gtk_signal_connect (GTK_OBJECT (menu_item), "key_press_event",
			  GTK_SIGNAL_FUNC (bookmark_key_cb), NULL);
      gtk_menu_append (GTK_MENU (app.bookmark_menu), menu_item);
      gtk_widget_show (menu_item);

    }
	add_menu_separator(app.bookmark_menu);
	add_menu_item(app.bookmark_menu, "Cancel ", NULL, NULL);

}
GList *
gst_mio_video_device_list_create (GstCoreMediaCtx * ctx)
{
  GList *devices = NULL;
  TundraTargetSpec pspec = { 0, };
  GArray *handles;
  guint handle_idx;

  pspec.name = kTundraSystemPropertyDevices;
  pspec.scope = kTundraScopeGlobal;
  handles = gst_mio_object_get_array (TUNDRA_SYSTEM_OBJECT_ID, &pspec,
      sizeof (TundraObjectID), ctx->mio);
  if (handles == NULL)
    goto beach;

  for (handle_idx = 0; handle_idx != handles->len; handle_idx++) {
    TundraObjectID handle;
    GstMIOVideoDevice *device;

    handle = g_array_index (handles, TundraObjectID, handle_idx);
    device = g_object_new (GST_TYPE_MIO_VIDEO_DEVICE,
        "context", ctx, "handle", handle, NULL);

    /* TODO: Skip screen input devices for now */
    if (gst_mio_video_device_get_transport_type (device) !=
        kTundraDeviceTransportScreen) {
      devices = g_list_prepend (devices, device);
    } else {
      g_object_unref (device);
    }
  }

  devices = g_list_sort (devices, (GCompareFunc) gst_mio_video_device_compare);

  g_array_free (handles, TRUE);

beach:
  return devices;
}
Esempio n. 17
0
gboolean
clone_create_probe(resource_t * rsc, node_t * node, action_t * complete,
                   gboolean force, pe_working_set_t * data_set)
{
    gboolean any_created = FALSE;

    CRM_ASSERT(rsc);

    rsc->children = g_list_sort(rsc->children, sort_rsc_id);
    if (rsc->children == NULL) {
        pe_warn("Clone %s has no children", rsc->id);
        return FALSE;
    }

    if (rsc->exclusive_discover) {
        node_t *allowed = g_hash_table_lookup(rsc->allowed_nodes, node->details->id);
        if (allowed && allowed->rsc_discover_mode != pe_discover_exclusive) {
            /* exclusive discover is enabled and this node is not marked
             * as a node this resource should be discovered on
             *
             * remove the node from allowed_nodes so that the
             * notification contains only nodes that we might ever run
             * on
             */
            g_hash_table_remove(rsc->allowed_nodes, node->details->id);

            /* Bit of a shortcut - might as well take it */
            return FALSE;
        }
    }

    if (is_set(rsc->flags, pe_rsc_unique)) {
        any_created = probe_unique_clone(rsc, node, complete, force, data_set);
    } else {
        any_created = probe_anonymous_clone(rsc, node, complete, force,
                                            data_set);
    }
    return any_created;
}
Esempio n. 18
0
/**
 * set the final_date of the reconcile
 * the value is dupplicate in memory (so parameter can be freed after)
 *
 * \param reconcile_number the number of the reconcile
 * \param date the final_date of the reconcile
 *
 * \return TRUE if ok or FALSE if problem
 * */
gboolean gsb_data_reconcile_set_final_date ( gint reconcile_number,
                        const GDate *date )
{
    struct_reconcile *reconcile;

    reconcile = gsb_data_reconcile_get_structure ( reconcile_number );

    if (!reconcile)
	return FALSE;

    /* we free the last date */
    if ( reconcile -> reconcile_final_date )
        g_date_free (reconcile -> reconcile_final_date);

    /* and copy the new one */
    reconcile -> reconcile_final_date = gsb_date_copy (date);

    /* retrie la liste */
    reconcile_list = g_list_sort ( reconcile_list, (GCompareFunc) gsb_data_reconcile_cmp_int );

    return TRUE;
}
Esempio n. 19
0
void pidgin_syslog_show()
{
	GList *accounts = NULL;
	GList *logs = NULL;

	if (syslog_viewer != NULL) {
		gtk_window_present(GTK_WINDOW(syslog_viewer->window));
		return;
	}

	for(accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) {

		PurpleAccount *account = (PurpleAccount *)accounts->data;
		if(purple_find_prpl(purple_account_get_protocol_id(account)) == NULL)
			continue;

		logs = g_list_concat(purple_log_get_system_logs(account), logs);
	}
	logs = g_list_sort(logs, purple_log_compare);

	syslog_viewer = display_log_viewer(NULL, logs, _("System Log"), NULL, 0);
}
Esempio n. 20
0
static void
add_tests_for_files_in_directory (GFile *dir)
{
  GFileEnumerator *enumerator;
  GFileInfo *info;
  GList *files;
  GError *error = NULL;

  enumerator = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &error);
  g_assert_no_error (error);
  files = NULL;

  while ((info = g_file_enumerator_next_file (enumerator, NULL, &error)))
    {
      const char *filename;

      filename = g_file_info_get_name (info);

      if (!g_str_has_suffix (filename, ".css") ||
          g_str_has_suffix (filename, ".out.css") ||
          g_str_has_suffix (filename, ".ref.css"))
        {
          g_object_unref (info);
          continue;
        }

      files = g_list_prepend (files, g_file_get_child (dir, filename));

      g_object_unref (info);
    }
  
  g_assert_no_error (error);
  g_object_unref (enumerator);

  files = g_list_sort (files, compare_files);
  g_list_foreach (files, (GFunc) add_test_for_file, NULL);
  g_list_free_full (files, g_object_unref);
}
Esempio n. 21
0
gint hashtable_show_keys(GHashTable *table)
{
    GList *list;
    const gchar *type;
    gchar *key;
    gchar *orig_key;
    GValue *val;
    GHashTable *dict;

    list = NULL;

    list = g_hash_table_get_keys(table);
    list = g_list_sort(list, cb_compare_str);

    g_print("*******************************************************\n");
    g_print("%-30s%-20s\n", "key", "value type");
    while (list != NULL) {
        key = list->data;
        if (g_hash_table_lookup_extended(table, key, 
                                         (gpointer *)&orig_key, 
                                         (gpointer *)&val)) {
            g_print("%-30s", key);
            type = G_VALUE_TYPE_NAME(val);
            g_print("%s\n", type);
            if (!g_strcmp0(type, "GHashTable_gchararray+GValue_")) {
                dict = g_value_get_boxed(val);
                hashtable_show_keys(dict);
            }
        } else {
            g_print("%-30s NOT found\n", key);
        }
        
        list = g_list_next(list);
    }
    g_print("*******************************************************\n\n");

    return 0;
}
Esempio n. 22
0
int
get_next_available_win_num(GList *used)
{
    used = g_list_sort(used, cmp_win_num);
    // only console used
    if (g_list_length(used) == 1) {
        return 2;
    } else {
        int result = 0;
        int last_num = 1;
        GList *curr = used;
        // skip console
        curr = g_list_next(curr);
        while (curr != NULL) {
            int curr_num = GPOINTER_TO_INT(curr->data);
            if (((last_num != 9) && ((last_num + 1) != curr_num)) ||
                    ((last_num == 9) && (curr_num != 0))) {
                result = last_num + 1;
                if (result == 10) {
                    result = 0;
                }
                return (result);
            } else {
                last_num = curr_num;
                if (last_num == 0) {
                    last_num = 10;
                }
            }
            curr = g_list_next(curr);
        }
        result = last_num + 1;
        if (result == 10) {
            result = 0;
        }

        return result;
    }
}
/*
 * Fill combobox with an alphabetically sorted list of all users on the system
 */
static void
fill_with_user_list(GtkWidget *combobox)
{
  GList *tmp = NULL, *list;
  TmpUser *tu;
  struct passwd *pw;

  setpwent();

  /* Get all the users info and store it temporary */
  while ((pw = getpwent())) {
    tu = g_new(TmpUser, 1);

    tu->username = g_strdup(pw->pw_name);
    tu->userid = pw->pw_uid;

    tmp = g_list_prepend(tmp, tu);
  }

  /* Sort it! */
  tmp = g_list_sort(tmp, fill_with_user_list_cmp);

  /* Add only the usernames */
  for (list = tmp; list; list = g_list_next(list)) {
    tu = list->data;

    gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), tu->username);

    if (!strcmp (tu->username, "root"))
      gtk_combo_box_set_active (GTK_COMBO_BOX(combobox),
				g_list_position(tmp, list));

    g_free(tu);
  }

  g_list_free(tmp);
  endpwent();
}
Esempio n. 24
0
static void
remove_old_files (TnyFsStreamCache *self, gint64 required_size)
{

	/* 1. we obtain a list of non active files
	 * 2. we sort the list (first uncomplete, then old)
	 * 3. we get items in list and remove them until we have the required size
	 */
	GList *cached_files_list;
	TnyFsStreamCachePriv *priv = TNY_FS_STREAM_CACHE_GET_PRIVATE (self);
	gint64 available_size;

	/* 1. we obtain a list of non active files */
	cached_files_list = NULL;
	g_static_mutex_lock (priv->cache_lock);
	g_hash_table_foreach (priv->cached_files, (GHFunc) get_inactive_files_list, &cached_files_list);
	g_static_mutex_unlock (priv->cache_lock);

	/* 2. we sort the list (first uncomplete, then old) */
	cached_files_list = g_list_sort (cached_files_list, (GCompareFunc) remove_priority);

	/* 3. we get items in list and remove them until we have the required size */
	available_size = get_free_space (self);
	while (available_size < required_size) {
		TnyCachedFile *cached_file = (TnyCachedFile *) cached_files_list->data;
		available_size += tny_cached_file_get_expected_size (cached_file);
		g_static_mutex_lock (priv->cache_lock);
		g_hash_table_remove (priv->cached_files, tny_cached_file_get_id (cached_file));
		g_static_mutex_unlock (priv->cache_lock);
		tny_cached_file_remove (cached_file);
		cached_files_list = g_list_delete_link (cached_files_list, cached_files_list);
		g_object_unref (cached_file);
	}

	g_list_foreach (cached_files_list, (GFunc) g_object_unref, NULL);
	g_list_free (cached_files_list);
	
}
Esempio n. 25
0
static void
ide_workbench_resort_perspectives (IdeWorkbench *self)
{
  GList *children;
  const GList *iter;
  gint i = 0;

  g_assert (IDE_IS_WORKBENCH (self));

  children = gtk_container_get_children (GTK_CONTAINER (self->perspectives_stack));
  children = g_list_sort (children, ide_workbench_compare_perspective);

  for (iter = children; iter; iter = iter->next, i++)
    {
      GtkWidget *child = iter->data;

      gtk_container_child_set (GTK_CONTAINER (self->perspectives_stack), child,
                               "position", i,
                               NULL);
    }

  g_list_free (children);
}
Esempio n. 26
0
static gboolean
do_list (GObject             *instance,
         const gchar         *action_name,
         guint                key_val,
         ClutterModifierType  modifiers,
         gpointer             user_data)
{
  MexDebugPlugin *plugin = MEX_DEBUG_PLUGIN (user_data);
  MexDebugPluginPrivate *priv = plugin->priv;
  GList *tuples, *l;
  gint i;

  tuples = priv->gobject_list.get_summary ();
  tuples = g_list_sort (tuples, tuplecmp);
  for (l = tuples, i = 0; l && i < 20; l = g_list_next (l), i++)
    {
      GObjectListTuple *tuple = l->data;;
      g_print ("%s: %d instances\n", tuple->str, tuple->value);
    }
  priv->gobject_list.free_summary (tuples);

  return TRUE;
}
Esempio n. 27
0
/**
 * games_file_list_new_images:
 * @path1: A NULL-terminated list of strings containing directories to be 
 * searched.
 * 
 * A convenience function which constructs a list of filenames which
 * are images that can be loaded via gdk-pixbuf. Whether a file is an
 * image or not is determined by its extension. The list of possible
 * extensions is determined by querying the gdk-pixbuf library the
 * first time this function is called.
 * 
 * Return value: A new GamesFileList containing the list of image files.
 **/
GamesFileList *
games_file_list_new_images (const gchar * path1, ...)
{
  GamesFileList *filelist;
  gchar *pathentry;
  va_list paths;

  filelist = g_object_new (GAMES_FILE_LIST_TYPE, NULL);

  filelist->priv->list = games_file_list_new_images_single (path1);
  va_start (paths, path1);
  while ((pathentry = va_arg (paths, gchar *)) != NULL) {
    filelist->priv->list = g_list_concat (filelist->priv->list,
			  games_file_list_new_images_single (pathentry));
  }
  va_end (paths);

  filelist->priv->list =
    g_list_sort (filelist->priv->list, (GCompareFunc) g_utf8_collate);
  games_file_list_remove_duplicates (filelist);

  return filelist;
}
Esempio n. 28
0
/* Check if refresh is needed for each package. */
static void trigger_package(gpointer key, gpointer value, gpointer user_data) {
    GList *l_versions = (GList *)value;
    GHashTable *ht_packages = (GHashTable *)user_data;

    if(l_versions == NULL)
	return;

    l_versions = g_list_sort(l_versions, cmp_vers);
    if (value != l_versions)
	g_hash_table_insert(ht_packages, g_strdup(key), l_versions);

    Version *newest = (Version *)(l_versions->data);
    ASSERT_TYPE(newest, T_VERSION);

    GList *l_oldvers = g_list_next(l_versions);

    /* Only one version known => nothing todo. */
    if(l_oldvers == NULL)
	return;

    /* Any host, which has last_upd < version->ts_first needs to be refreshed. */
    g_list_foreach(l_oldvers, add_refresh, &( newest -> ts_first ));
}
Esempio n. 29
0
gboolean
gimv_image_loader_plugin_regist (const gchar *plugin_name,
                                 const gchar *module_name,
                                 gpointer impl,
                                 gint     size)
{
   GimvImageLoaderPlugin *image_loader = impl;

   g_return_val_if_fail (module_name, FALSE);
   g_return_val_if_fail (image_loader, FALSE);
   g_return_val_if_fail (size > 0, FALSE);
   g_return_val_if_fail (image_loader->if_version == GIMV_IMAGE_LOADER_IF_VERSION,
                         FALSE);
   g_return_val_if_fail (image_loader->id, FALSE);

   gimv_image_loader_list = g_list_append (gimv_image_loader_list,
                                           image_loader);

   gimv_image_loader_list = g_list_sort (gimv_image_loader_list,
                                         (GCompareFunc) comp_func_priority);

   return TRUE;
}
Esempio n. 30
0
gint hashtable_show_value_type(GHashTable *table)
{
    GList *list;
    gchar *key;
    GValue *val;

    list = NULL;

    list = g_hash_table_get_keys(table);
    list = g_list_sort(list, cb_compare_str);

    g_print("%-30s%-20s\n", "key", "value type");
    while (list != NULL) {
        key = list->data;
        val = g_hash_table_lookup(table, key);
        g_print("%-30s", key);
        type_print((gpointer)val);
        g_print("\n");
        list = g_list_next(list);
    }

    return 0;
}