コード例 #1
0
static void
na_tray_manager_handle_begin_message (NaTrayManager       *manager,
				      XClientMessageEvent *xevent)
{
  GtkSocket      *socket;
  GList          *p;
  PendingMessage *msg;
  long            timeout;
  long            len;
  long            id;

  socket = g_hash_table_lookup (manager->socket_table,
                                GINT_TO_POINTER (xevent->window));
  /* we don't know about this tray icon, so ignore the message */
  if (!socket)
    return;

  /* Check if the same message is already in the queue and remove it if so */
  for (p = manager->messages; p; p = p->next)
    {
      PendingMessage *pmsg = p->data;

      if (xevent->window == pmsg->window &&
	  xevent->data.l[4] == pmsg->id)
	{
	  /* Hmm, we found it, now remove it */
	  pending_message_free (pmsg);
	  manager->messages = g_list_remove_link (manager->messages, p);
          g_list_free_1 (p);
	  break;
	}
    }

  timeout = xevent->data.l[2];
  len     = xevent->data.l[3];
  id      = xevent->data.l[4];

  if (len == 0)
    {
      g_signal_emit (manager, manager_signals[MESSAGE_SENT], 0,
                     socket, "", id, timeout);
    }
  else
    {
      /* Now add the new message to the queue */
      msg = g_new0 (PendingMessage, 1);
      msg->window = xevent->window;
      msg->timeout = timeout;
      msg->len = len;
      msg->id = id;
      msg->remaining_len = msg->len;
      msg->str = g_malloc (msg->len + 1);
      msg->str[msg->len] = '\0';
      manager->messages = g_list_prepend (manager->messages, msg);
    }
}
コード例 #2
0
t_launcher*
quicklauncher_remove_element(t_quicklauncher *quicklauncher, gint num)
{
	t_launcher *result;
	GList *elem = g_list_nth(quicklauncher->launchers, num);
	quicklauncher->launchers = g_list_remove_link(quicklauncher->launchers, elem);
	quicklauncher->nb_launcher--;
	result = (t_launcher*)(elem->data);
	g_list_free_1(elem);
	return result;
}
コード例 #3
0
void
gtk_plot_array_list_remove(GtkPlotArrayList *array_list, GtkPlotArray *array)
{
  GList *list;
  list = g_list_find(array_list->arrays, array);
  if(list){
    g_object_unref(G_OBJECT(array));
    array_list->arrays = g_list_remove_link(array_list->arrays, list);
    g_list_free_1(list); 
  }
}
コード例 #4
0
static void
qof_event_generate_internal (QofInstance *entity, QofEventId event_id,
                             void * event_data)
{
    GList *node;
    GList *next_node = NULL;

    g_return_if_fail(entity);

    switch (event_id)
    {
    case QOF_EVENT_NONE:
    {
        /* if none, don't log, just return. */
        return;
    }
    }

    handler_run_level++;
    for (node = handlers; node; node = next_node)
    {
        HandlerInfo *hi = node->data;

        next_node = node->next;
        if (hi->handler)
        {
            PINFO("id=%d hi=%p han=%p data=%p", hi->handler_id, hi,
                  hi->handler, event_data);
            hi->handler (entity, event_id, hi->user_data, event_data);
        }
    }
    handler_run_level--;

    /* If we're the outermost event runner and we have pending deletes
     * then go delete the handlers now.
     */
    if (handler_run_level == 0 && pending_deletes)
    {
        for (node = handlers; node; node = next_node)
        {
            HandlerInfo *hi = node->data;
            next_node = node->next;
            if (hi->handler == NULL)
            {
                /* remove this node from the list, then free this node */
                handlers = g_list_remove_link (handlers, node);
                g_list_free_1 (node);
//                g_free (hi);
                delete hi;
            }
        }
        pending_deletes = 0;
    }
}
コード例 #5
0
ファイル: modules.c プロジェクト: LastRitter/pango
/**
 * pango_find_map:
 * @language: the language tag for which to find the map
 * @engine_type_id: the engine type for the map to find
 * @render_type_id: the render type for the map to find
 *
 * Locate a #PangoMap for a particular engine type and render
 * type. The resulting map can be used to determine the engine
 * for each character.
 *
 * Return value: the suitable #PangoMap.
 **/
PangoMap *
pango_find_map (PangoLanguage *language,
		guint          engine_type_id,
		guint          render_type_id)
{
  GList *tmp_list;
  PangoMapInfo *map_info = NULL;
  gboolean found_earlier = FALSE;

  G_LOCK (maps);

  tmp_list = maps;
  while (tmp_list)
    {
      map_info = tmp_list->data;
      if (map_info->engine_type_id == engine_type_id &&
	  map_info->render_type_id == render_type_id)
	{
	  if (map_info->language == language)
	    break;
	  else
	    found_earlier = TRUE;
	}

      tmp_list = tmp_list->next;
    }

  if (!tmp_list)
    {
      map_info = g_slice_new (PangoMapInfo);
      map_info->language = language;
      map_info->engine_type_id = engine_type_id;
      map_info->render_type_id = render_type_id;

      build_map (map_info);

      maps = g_list_prepend (maps, map_info);
    }
  else if (found_earlier)
    {
      /* Move the found map to the beginning of the list
       * for speed next time around if we had to do
       * any failing comparison. (No longer so important,
       * since we don't strcmp.)
       */
      maps = g_list_remove_link(maps, tmp_list);
      maps = g_list_prepend(maps, tmp_list->data);
      g_list_free_1(tmp_list);
    }

  G_UNLOCK (maps);

  return map_info->map;
}
コード例 #6
0
static void
queue_delete_link (GQueue *queue,
		   GList  *link)
{
  if (queue->tail == link)
    queue->tail = link->prev;
  
  queue->head = g_list_remove_link (queue->head, link);
  g_list_free_1 (link);
  queue->length--;
}
コード例 #7
0
ファイル: dummy_graphics.c プロジェクト: UnNetHack/UnNetHack
/*
int nh_poskey(int *x, int *y, int *mod)
                -- Returns a single character input from the user or a
                   a positioning event (perhaps from a mouse).  If the
                   return value is non-zero, a character was typed, else,
                   a position in the MAP window is returned in x, y and mod.
                   mod may be one of

                        CLICK_1         -- mouse click type 1 
                        CLICK_2         -- mouse click type 2 

                   The different click types can map to whatever the
                   hardware supports.  If no mouse is supported, this
                   routine always returns a non-zero character.
*/
int dummy_nh_poskey(int *x, int *y, int *mod)
{
#if 0
    gtk_signal_emit (GTK_OBJECT (dummy_windowlist[WIN_STATUS].win),
		       ghack_signals[GHSIG_FADE_HIGHLIGHT]);
    
    g_askingQuestion = 0;
    /* Process events until a key or map-click arrives. */
    while ( g_numKeys == 0 && g_numClicks == 0 )
	gtk_main_iteration();
    
    if (g_numKeys > 0) {
	int key;
	GList *theFirst;
	
	theFirst = g_list_first( g_keyBuffer);
	g_keyBuffer = g_list_remove_link(g_keyBuffer, theFirst);
	key = GPOINTER_TO_INT( theFirst->data);
	g_list_free_1( theFirst);
	g_numKeys--;
	return ( key);
    }
    else {
	GHClick *click;
	GList *theFirst;
	
	theFirst = g_list_first( g_clickBuffer);
	g_clickBuffer = g_list_remove_link(g_clickBuffer, theFirst);
	click = (GHClick*) theFirst->data;
	*x=click->x;
        *y=click->y;
        *mod=click->mod;
	g_free( click);
	g_list_free_1( theFirst);
	g_numClicks--;
	return ( 0);
    }
#endif
	printf("dummy_nh_poskey\n");
	return dummy_getchar();
}
コード例 #8
0
/* Scans the list of missing subscriptions checking if they
 * are available yet.
 */
static gboolean
im_scan_missing (gpointer user_data)
{
  GList *nolonger_missing = NULL;
  GList *l;
  
  G_LOCK (inotify_lock);
  
  IM_W ("scanning missing list with %d items\n", g_list_length (missing_sub_list));
  for (l = missing_sub_list; l; l = l->next)
    {
      inotify_sub *sub = l->data;
      gboolean not_m = FALSE;
      
      IM_W ("checking %p\n", sub);
      g_assert (sub);
      g_assert (sub->dirname);
      not_m = _ip_start_watching (sub);

      if (not_m)
	{
	  missing_cb (sub);
	  IM_W ("removed %s from missing list\n", sub->dirname);
	  /* We have to build a list of list nodes to remove from the
	   * missing_sub_list. We do the removal outside of this loop.
	   */
	  nolonger_missing = g_list_prepend (nolonger_missing, l);
	} 
    }

  for (l = nolonger_missing; l ; l = l->next)
    {
      GList *llink = l->data;
      missing_sub_list = g_list_remove_link (missing_sub_list, llink);
      g_list_free_1 (llink);
    }

  g_list_free (nolonger_missing);
  
  /* If the missing list is now empty, we disable the timeout */
  if (missing_sub_list == NULL)
    {
      scan_missing_running = FALSE;
      G_UNLOCK (inotify_lock);
      return FALSE;
    }
  else
    {
      G_UNLOCK (inotify_lock);
      return TRUE;
    }
}
コード例 #9
0
ファイル: playlist.c プロジェクト: sedwards/xmms3
void playlist_queue_move(int oldpos, int newpos)
{
    GList *tmp;

    PL_LOCK();
    tmp = g_list_nth(queued_list, oldpos);
    queued_list = g_list_remove_link (queued_list, tmp);
    queued_list = g_list_insert(queued_list, tmp->data, newpos);
    g_list_free_1 (tmp);
    PL_UNLOCK();

    playlistwin_update_list();
}
コード例 #10
0
ファイル: playlist.c プロジェクト: sedwards/xmms3
static void playlist_queue_toggle(void *data)
{
    GList *temp;

    temp = g_list_find(queued_list, data);
    if (temp)
    {
        queued_list = g_list_remove_link(queued_list, temp);
        g_list_free_1(temp);
    }
    else
        queued_list = g_list_append(queued_list, data);
}
コード例 #11
0
ファイル: cogl-pipeline-snippet.c プロジェクト: 3v1n0/cogl
void
_cogl_pipeline_snippet_list_free (CoglPipelineSnippetList *list)
{
  GList *l, *tmp;

  for (l = list->entries; l; l = tmp)
    {
      tmp = l->next;

      cogl_object_unref (l->data);
      g_list_free_1 (l);
    }
}
コード例 #12
0
ファイル: node.c プロジェクト: IFGHou/EtherApe
/* Returns a node from the list of new nodes or NULL if there are no more 
 * new nodes */
node_t *
new_nodes_pop(void)
{
  node_t *node = NULL;
  GList *old_item = NULL;

  if (!new_nodes)
    return NULL;

  node = new_nodes->data;
  old_item = new_nodes;

  /* We make sure now that the node hasn't been deleted since */
  /* TODO Sometimes when I get here I have a node, but a null
   * node->node_id. What gives? */
  while (node && !nodes_catalog_find(&node->node_id))
    {
      g_my_debug
	("Already deleted node in list of new nodes, in new_nodes_pop");

      /* Remove this node from the list of new nodes */
      new_nodes = g_list_remove_link (new_nodes, new_nodes);
      g_list_free_1 (old_item);
      if (new_nodes)
	node = new_nodes->data;
      else
	node = NULL;
      old_item = new_nodes;
    }

  if (!new_nodes)
    return NULL;

  /* Remove this node from the list of new nodes */
  new_nodes = g_list_remove_link (new_nodes, new_nodes);
  g_list_free_1 (old_item);

  return node;
}
コード例 #13
0
ファイル: glist.c プロジェクト: AveProjVstm/MonoVstm
GList*
g_list_remove (GList *list, gconstpointer data)
{
    GList *current = g_list_find (list, data);
    if (!current)
        return list;

    if (current == list)
        list = list->next;
    g_list_free_1 (disconnect_node (current));

    return list;
}
コード例 #14
0
ファイル: geany-git-ui-test.c プロジェクト: b4n/geany-git-ui
static int
ggu_git_wrapper_test_main (int     argc,
                           char  **argv)
{
  int rv = 1;
  
  loop_push ();
  if (argc == 2) {
    gchar *path;
    gchar *dir;
    gchar *file;
    
    path = g_strdup (argv[1]);
    dir = g_path_get_dirname (path);
    file = g_path_get_basename (path);
    loop_push ();
    ggu_git_log (dir, NULL, file, log_result_callback, NULL);
    loop_push ();
    ggu_git_branch_list (dir, branch_list_result_callback, NULL);
    rv = 0;
    
    {
      GList  *l;
      GError *err = NULL;
      
      l = ggu_git_log_sync (dir, NULL, file, &err);
      if (err) {
        g_warning ("%s", err->message);
        g_error_free (err);
      } else {
        printf ("=== Commit(s) ===\n");
        while (l) {
          GguGitCommit *commit = l->data;
          GList *next = l->next;
          
          printf ("%.7s -- %s\n", commit->hash, commit->summary);
          ggu_git_commit_unref (commit);
          g_list_free_1 (l);
          l = next;
        }
      }
    }
    
    g_free (file);
    g_free (dir);
    g_free (path);
  }
  loop_pop ();
  
  return rv;
}
コード例 #15
0
ファイル: explorer-history.c プロジェクト: ain101/Fyre
static void         explorer_prune_history  (Explorer* self, int max_nodes)
{
    while (self->history_queue->length > max_nodes) {
	GList* link = g_queue_pop_head_link(self->history_queue);
	if (!link)
	    break;

	if (link == self->history_current_link)
	    self->history_current_link = NULL;

	history_node_free(link->data);
	g_list_free_1(link);
    }
}
コード例 #16
0
ファイル: e-list.c プロジェクト: nobled/evolution-data-server
/* FIXME: This doesn't work properly if the iterator is the first
   iterator in the list.  Well, the iterator doesn't continue on after
   the next time next is called, at least. */
void
e_list_remove_link (EList *list, GList *link)
{
	GList *iterators = list->iterators;
	for (; iterators; iterators = iterators->next) {
		if (((EListIterator *)iterators->data)->iterator == link) {
			e_iterator_prev (iterators->data);
		}
	}
	if (list->free)
		list->free (link->data, list->closure);
	list->list = g_list_remove_link (list->list, link);
	g_list_free_1 (link);
}
コード例 #17
0
ファイル: quoteinfo.c プロジェクト: Alex-Sjoberg/Pioneers
void quotelist_delete(QuoteList * list, QuoteInfo * quote)
{
	GList *scan;

	for (scan = list->quotes; scan != NULL; scan = g_list_next(scan)) {
		if (scan->data == quote) {
			list->quotes =
			    g_list_remove_link(list->quotes, scan);
			g_list_free_1(scan);
			g_free(quote);
			return;
		}
	}
}
コード例 #18
0
ファイル: run_event.c プロジェクト: scottgfhong/libreport
static void free_rule_list(GList *rule_list)
{
    while (rule_list)
    {
        struct rule *cur_rule = rule_list->data;
        list_free_with_free(cur_rule->conditions);
        free(cur_rule->command);
        free(cur_rule);

        GList *next = rule_list->next;
        g_list_free_1(rule_list);
        rule_list = next;
    }
}
コード例 #19
0
static GdkFilterReturn
na_tray_manager_handle_client_message_message_data (GdkXEvent *xev,
                                                    GdkEvent  *event,
                                                    gpointer   data)
{
  XClientMessageEvent *xevent;
  NaTrayManager       *manager;
  GList               *p;
  int                  len;
  
  xevent  = (XClientMessageEvent *) xev;
  manager = data;

  /* Try to see if we can find the pending message in the list */
  for (p = manager->messages; p; p = p->next)
    {
      PendingMessage *msg = p->data;

      if (xevent->window == msg->window)
	{
	  /* Append the message */
	  len = MIN (msg->remaining_len, 20);

	  memcpy ((msg->str + msg->len - msg->remaining_len),
		  &xevent->data, len);
	  msg->remaining_len -= len;

	  if (msg->remaining_len == 0)
	    {
	      GtkSocket *socket;

	      socket = g_hash_table_lookup (manager->socket_table,
                                            GINT_TO_POINTER (msg->window));

	      if (socket)
		  g_signal_emit (manager, manager_signals[MESSAGE_SENT], 0,
				 socket, msg->str, msg->id, msg->timeout);

	      pending_message_free (msg);
	      manager->messages = g_list_remove_link (manager->messages, p);
              g_list_free_1 (p);
	    }

          break;
	}
    }

  return GDK_FILTER_REMOVE;
}
コード例 #20
0
ファイル: lru_cache.c プロジェクト: theopengroup/destor
void lru_cache_kicks(struct lruCache* c, void* user_data,
                     int (*func)(void* elem, void* user_data)) {
    GList* elem = g_list_last(c->elem_queue);
    while (elem) {
        if (func(elem->data, user_data))
            break;
        elem = g_list_previous(elem);
    }
    if (elem) {
        c->elem_queue = g_list_remove_link(c->elem_queue, elem);
        c->free_elem(elem->data);
        g_list_free_1(elem);
        c->size--;
    }
}
コード例 #21
0
ファイル: lru_cache.c プロジェクト: mavslh/destor
/*
 * We know that the elem does not exist!
 */
void* lru_cache_insert(LRUCache *cache, void* data) {
	void *evictor = 0;
	if (cache->cache_max_size > 0
			&& cache->cache_size == cache->cache_max_size) {
		GList *last = g_list_last(cache->lru_queue);
		cache->lru_queue = g_list_remove_link(cache->lru_queue, last);
		evictor = last->data;
		g_list_free_1(last);
		cache->cache_size--;
	}
	/* Valgrind reports it's possible to lost some memory here */
	cache->lru_queue = g_list_prepend(cache->lru_queue, data);
	cache->cache_size++;
	return evictor;
}
コード例 #22
0
ファイル: gdkevents.c プロジェクト: My-Source/root
GdkEvent *gdk_event_unqueue(void)
{
   GdkEvent *event = NULL;
   GList *tmp_list;

   tmp_list = gdk_event_queue_find_first();

   if (tmp_list) {
      event = tmp_list->data;
      gdk_event_queue_remove_link(tmp_list);
      g_list_free_1(tmp_list);
   }

   return event;
}
コード例 #23
0
ファイル: gui_gtk_f.c プロジェクト: kzlin129/vim
/* Container method
 */
    static void
gtk_form_remove(GtkContainer *container, GtkWidget *widget)
{
    GList *tmp_list;
    GtkForm *form;
    GtkFormChild *child = NULL;	    /* init for gcc */

    g_return_if_fail(GTK_IS_FORM(container));

    form = GTK_FORM(container);

    tmp_list = form->children;
    while (tmp_list)
    {
	child = tmp_list->data;
	if (child->widget == widget)
	    break;
	tmp_list = tmp_list->next;
    }

    if (tmp_list)
    {
#if GTK_CHECK_VERSION(3,0,0)
	const gboolean was_visible = gtk_widget_get_visible(widget);
#endif
	if (child->window)
	{
	    g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
		    FUNC2GENERIC(&gtk_form_child_map), child);
	    g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
		    FUNC2GENERIC(&gtk_form_child_unmap), child);

	    /* FIXME: This will cause problems for reparenting NO_WINDOW
	     * widgets out of a GtkForm
	     */
	    gdk_window_set_user_data(child->window, NULL);
	    gdk_window_destroy(child->window);
	}
	gtk_widget_unparent(widget);
#if GTK_CHECK_VERSION(3,0,0)
	if (was_visible)
	    gtk_widget_queue_resize(GTK_WIDGET(container));
#endif
	form->children = g_list_remove_link(form->children, tmp_list);
	g_list_free_1(tmp_list);
	g_free(child);
    }
}
コード例 #24
0
ファイル: inotify-missing.c プロジェクト: fatman2021/mate-vfs
/* inotify_lock must be held before calling */
void im_rm (ih_sub_t *sub)
{
	GList *link;

	link = g_list_find (missing_sub_list, sub);

	if (!link) {
		IM_W("asked to remove %s from missing list but it isn't on the list!\n", sub->pathname);
		return;
	}

	IM_W("removing %s from missing list\n", sub->dirname);

	missing_sub_list = g_list_remove_link (missing_sub_list, link);
	g_list_free_1 (link);
}
コード例 #25
0
gpointer
tracker_priority_queue_pop (TrackerPriorityQueue *queue,
                            gint                 *priority_out)
{
	GList *node;
	gpointer data;

	node = tracker_priority_queue_pop_node (queue, priority_out);
	if (node == NULL)
		return NULL;

	data = node->data;
	g_list_free_1 (node);

	return data;
}
コード例 #26
0
ファイル: win.c プロジェクト: andreas-volker/owl-wb
void
win_destroy(void *ptr) {
    Win *w;
    GList *l;

    w = (Win*)ptr;
    gtk_widget_destroy(GTK_WIDGET(w->web));
    gtk_widget_destroy(GTK_WIDGET(w->scroll));
    gtk_widget_destroy(GTK_WIDGET(w->win));
    if((l = g_list_find(data.wins, w))) {
        data.wins = g_list_remove_link(data.wins, l);
        g_list_free_1(l);
    }
    free(w);
    if(!data.wins)
        gtk_main_quit();
}
コード例 #27
0
ファイル: ex-glist-3.c プロジェクト: MarkTseng/mySampleCode
int main(int argc, char** argv) {
 GList* list = g_list_append(NULL, "Austin ");
 list = g_list_append(list, "Bowie ");
 list = g_list_append(list, "Chicago ");
 printf("Here's the list: ");
 g_list_foreach(list, (GFunc)printf, NULL);
 GList* bowie = g_list_nth(list, 1);
 list = g_list_remove_link(list, bowie);
 g_list_free_1(bowie);
 printf("\nHere's the list after the remove_link call: ");
 g_list_foreach(list, (GFunc)printf, NULL);
 list = g_list_delete_link(list, g_list_nth(list, 1));
 printf("\nHere's the list after the delete_link call: ");
 g_list_foreach(list, (GFunc)printf, NULL);
 g_list_free(list);
 return 0;
 }
コード例 #28
0
static void
clear_dup (gpointer key,
           gpointer value,
           gpointer data)
{
        GList *dupes;

        /* don't bother maintaining the ring, we're destroying the
         * entire hash table anyway
         */
        dupes = g_object_get_data (G_OBJECT (value), "dupes");

        if (dupes) {
                g_list_free_1 (dupes);
                g_object_set_data (G_OBJECT (value), "dupes", NULL);
        }
}
コード例 #29
0
void
gtk_plot_array_list_clear(GtkPlotArrayList *array_list)
{
  GList *list;

  list = array_list->arrays;
  while(list){
    if(list->data && G_IS_OBJECT(list->data)) 
      g_object_unref(G_OBJECT(list->data));
    list->data = NULL;
    array_list->arrays = g_list_remove_link(array_list->arrays, list);
    g_list_free_1(list);

    list = array_list->arrays;
  }
  array_list->arrays = NULL;
}
コード例 #30
0
ファイル: stringref.c プロジェクト: CkNoSFeRaTU/pidgin
static gboolean gs_idle_cb(gpointer data)
{
	PurpleStringref *ref;
	GList *del;

	while (gclist != NULL) {
		ref = gclist->data;
		if (REFCOUNT(ref->ref) == 0) {
			stringref_free(ref);
		}
		del = gclist;
		gclist = gclist->next;
		g_list_free_1(del);
	}

	return FALSE;
}