static GList* playlist_sort_selected(GList *list, GCompareFunc cmpfunc) { GList *list1, *list2; GList *temp_list = NULL; GList *index_list = NULL; /* * We take all the selected entries out of the playlist, * sort them, and then put them back in again. */ list1 = g_list_last(list); while (list1) { list2 = g_list_previous(list1); if (((PlaylistEntry *) list1->data)->selected) { gpointer idx; idx = GINT_TO_POINTER(g_list_position(list, list1)); index_list = g_list_prepend(index_list, idx); list = g_list_remove_link(list, list1); temp_list = g_list_concat(list1, temp_list); } list1 = list2; } if (cmpfunc) temp_list = g_list_sort(temp_list, cmpfunc); else temp_list = playlist_shuffle_list(temp_list); list1 = temp_list; list2 = index_list; while (list2) { if (!list1) { g_log(NULL, G_LOG_LEVEL_CRITICAL, "%s: Error during list sorting. " "Possibly dropped some playlist-entries.", PACKAGE); break; } list = g_list_insert(list, list1->data, GPOINTER_TO_INT(list2->data)); list2 = g_list_next(list2); list1 = g_list_next(list1); } g_list_free(index_list); g_list_free(temp_list); return list; }
static GList * dlg_widget_prev (Dlg_head * h, GList * l) { GList *prev; prev = g_list_previous (l); if (prev == NULL) prev = g_list_last (h->widgets); return prev; }
GList *duplicate_arraylist(GList *arraylist) { GList *tmplist; GList *newlist=NULL; tmplist = g_list_last(arraylist); while (tmplist != NULL) { newlist = g_list_prepend(newlist, g_strdupv((gchar **)tmplist->data)); tmplist = g_list_previous(tmplist); } return newlist; }
/** * Save history to the mc_config, but don't save config to file */ void history_save (struct mc_config_t *cfg, const char *name, GList * h) { GIConv conv = INVALID_CONV; GString *buffer; int i; if (name == NULL || *name == '\0' || h == NULL) return; /* go to end of list */ h = g_list_last (h); /* go back 60 places */ for (i = 0; (i < num_history_items_recorded - 1) && (h->prev != NULL); i++) h = g_list_previous (h); if (name != NULL) mc_config_del_group (cfg, name); /* create charset conversion handler to convert strings from system codepage to UTF-8 */ if (!mc_global.utf8_display) conv = str_crt_conv_to ("UTF-8"); buffer = g_string_sized_new (64); /* dump history into profile */ for (i = 0; h != NULL; h = g_list_next (h)) { char key[BUF_TINY]; char *text = (char *) h->data; /* We shouldn't have null entries, but let's be sure */ if (text == NULL) continue; g_snprintf (key, sizeof (key), "%d", i++); if (conv == INVALID_CONV) mc_config_set_string_raw (cfg, name, key, text); else { g_string_set_size (buffer, 0); if (str_convert (conv, text, buffer) == ESTR_FAILURE) mc_config_set_string_raw (cfg, name, key, text); else mc_config_set_string_raw (cfg, name, key, buffer->str); } } g_string_free (buffer, TRUE); if (conv != INVALID_CONV) str_close_conv (conv); }
static gint rlib_csv_previous(gpointer input_ptr, gpointer result_ptr) { struct rlib_csv_results *result = result_ptr; result->navigator = g_list_previous(result->navigator); if(result->navigator == NULL) { result->isdone = TRUE; return FALSE; } else { result->isdone = FALSE; return TRUE; } }
GeglNode * gimp_filter_stack_get_graph (GimpFilterStack *stack) { GList *list; GeglNode *first = NULL; GeglNode *previous = NULL; GeglNode *input; GeglNode *output; g_return_val_if_fail (GIMP_IS_FILTER_STACK (stack), NULL); if (stack->graph) return stack->graph; stack->graph = gegl_node_new (); for (list = GIMP_LIST (stack)->queue->tail; list; list = g_list_previous (list)) { GimpFilter *filter = list->data; GeglNode *node = gimp_filter_get_node (filter); if (! first) first = node; gegl_node_add_child (stack->graph, node); if (previous) gegl_node_connect_to (previous, "output", node, "input"); previous = node; } input = gegl_node_get_input_proxy (stack->graph, "input"); output = gegl_node_get_output_proxy (stack->graph, "output"); if (first && previous) { gegl_node_connect_to (input, "output", first, "input"); gegl_node_connect_to (previous, "output", output, "input"); } else { gegl_node_connect_to (input, "output", output, "input"); } return stack->graph; }
void fill_qck_launcher_dlg() { GtkTreeModel *treemodel; GList *i; GtkTreeIter iter; GdkPixbuf *pixbuf; GtkTreeViewColumn *column; GtkCellRenderer *render; t_launcher *launcher; _icon_window = create_icon_window(); treemodel = GTK_TREE_MODEL(gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER)); gtk_tree_view_set_model(GTK_TREE_VIEW(_dlg->treeview1), treemodel); gtk_tree_view_set_reorderable (GTK_TREE_VIEW (_dlg->treeview1), FALSE);//==>besoin de gérer le reorder gtk_spin_button_set_value(GTK_SPIN_BUTTON(_dlg->spin1), (gdouble)_quicklauncher->nb_lines); render = gtk_cell_renderer_pixbuf_new(); //render = gtk_cell_renderer_combo_new(); //configure_combo(render); if I one day can use combo with pixbuf... g_object_set (G_OBJECT(render), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,"sensitive", TRUE, NULL); column = gtk_tree_view_column_new_with_attributes(_("icone"), render, "pixbuf", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(_dlg->treeview1), column); render = gtk_cell_renderer_text_new(); g_object_set (G_OBJECT(render),"editable", TRUE, NULL); g_signal_connect(render, "edited", G_CALLBACK (cmd_changed), NULL); column = gtk_tree_view_column_new_with_attributes(_("commande"), render, "text", 1, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(_dlg->treeview1), column); //load current config for( i = g_list_last(_quicklauncher->launchers); i != NULL; i = g_list_previous(i) ) { launcher = i->data; gtk_list_store_insert(GTK_LIST_STORE(treemodel), &iter, 0); pixbuf = _create_pixbuf(launcher->icon_id, launcher->icon_name, 16); gtk_list_store_set(GTK_LIST_STORE(treemodel), &iter, 0, pixbuf, 1, launcher->command, 2, (gpointer)launcher, -1); UNREF(pixbuf); } g_signal_connect(_dlg->treeview1, "row-activated", G_CALLBACK(show_icon_window), NULL); g_signal_connect((gpointer)_dlg->spin1, "value-changed", G_CALLBACK (on_spin_value_changed), NULL); g_signal_connect ((gpointer) _dlg->btn_new, "clicked", G_CALLBACK (on_btn_new_clicked), NULL); g_signal_connect ((gpointer) _dlg->btn_remove, "clicked", G_CALLBACK (on_btn_remove_clicked), NULL); g_signal_connect ((gpointer) _dlg->btn_up, "clicked", G_CALLBACK (on_btn_up_clicked), NULL); g_signal_connect ((gpointer) _dlg->btn_down, "clicked", G_CALLBACK (on_btn_down_clicked), NULL); }
static MxFocusable * mex_column_move_focus (MxFocusable *focusable, MxFocusDirection direction, MxFocusable *from) { MxFocusHint hint; GList *link_ = NULL; MexColumn *self = MEX_COLUMN (focusable); MexColumnPrivate *priv = self->priv; focusable = NULL; link_ = g_list_find (priv->children, from); if (!link_) return NULL; switch (direction) { case MX_FOCUS_DIRECTION_PREVIOUS: case MX_FOCUS_DIRECTION_UP: hint = (direction == MX_FOCUS_DIRECTION_PREVIOUS) ? MX_FOCUS_HINT_LAST : MX_FOCUS_HINT_FROM_BELOW; link_ = g_list_previous (link_); if (link_) focusable = mx_focusable_accept_focus ( MX_FOCUSABLE (link_->data), hint); break; case MX_FOCUS_DIRECTION_NEXT: case MX_FOCUS_DIRECTION_DOWN: hint = (direction == MX_FOCUS_DIRECTION_NEXT) ? MX_FOCUS_HINT_FIRST : MX_FOCUS_HINT_FROM_ABOVE; link_ = g_list_next (link_); if (link_) focusable = mx_focusable_accept_focus ( MX_FOCUSABLE (link_->data), hint); break; case MX_FOCUS_DIRECTION_OUT: if (from && (clutter_actor_get_parent (CLUTTER_ACTOR (from)) == CLUTTER_ACTOR (self))) priv->current_focus = CLUTTER_ACTOR (from); break; default: break; } return focusable; }
void glade_gtk_action_bar_add_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GladeWidget *gbox, *gchild; gint num_children; gchar *special_child_type; gbox = glade_widget_get_from_gobject (object); special_child_type = g_object_get_data (child, "special-child-type"); if (special_child_type && !strcmp (special_child_type, "center")) { gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), GTK_WIDGET (child)); return; } /* Try to remove the last placeholder if any, this way GtkBox`s size will not be changed. */ if (!glade_widget_superuser () && !GLADE_IS_PLACEHOLDER (child)) { GList *l, *children; children = gtk_container_get_children (GTK_CONTAINER (object)); for (l = g_list_last (children); l; l = g_list_previous (l)) { GtkWidget *child_widget = l->data; if (GLADE_IS_PLACEHOLDER (child_widget)) { gtk_container_remove (GTK_CONTAINER (object), child_widget); break; } } g_list_free (children); } gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); num_children = glade_gtk_action_bar_get_num_children (object); glade_widget_property_set (gbox, "size", num_children); if (glade_widget_superuser ()) return; gchild = glade_widget_get_from_gobject (child); /* Packing props arent around when parenting during a glade_widget_dup() */ if (gchild && glade_widget_get_packing_properties (gchild)) glade_widget_pack_property_set (gchild, "position", num_children - 1); }
GList * queue_list_prev (Queue *h) { GList *result = NULL; if (queue_has_prev (h)) { GList *list; for (list = g_list_previous (h->current); list; list = g_list_previous (list)) { Item *item = list->data; result = g_list_prepend (result, item->title ? item->title : item->uri); } } return g_list_reverse (result); }
/* adjust menu and toolbar sensitivity depending on the history entries */ static void adjust_menus(void) { if(history_current) { main_set_for_packet_history( (g_list_previous(history_current) != NULL), (g_list_next(history_current) != NULL)); } else { /* we don't have any history */ main_set_for_packet_history(FALSE, FALSE); } /* history_print(); */ }
int main(int argc, char** argv) { GList* list = g_list_append(NULL, "Austin "); list = g_list_append(list, "Bowie "); list = g_list_append(list, "Charleston "); printf("Here's the list: "); g_list_foreach(list, (GFunc)printf, NULL); GList* last = g_list_last(list); printf("\nThe first item (using g_list_first) is '%s'\n", g_list_first(last)->data); printf("The next-to-last item is '%s'\n", g_list_previous(last)->data); printf("The next-to-last item is '%s'\n", g_list_nth_prev(last, 1)->data); g_list_free(list); return 0; }
static int dlg_mouse_event (WDialog * h, Gpm_Event * event) { Widget *wh = WIDGET (h); GList *p; /* close the dialog by mouse left click out of dialog area */ if (mouse_close_dialog && (wh->pos_flags & WPOS_FULLSCREEN) == 0 && ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) && !mouse_global_in_widget (event, wh)) { h->ret_value = B_CANCEL; dlg_stop (h); return MOU_NORMAL; } if (wh->mouse_callback != NULL) { int mou; mou = dlg_mouse_translator (event, wh); if (mou != MOU_UNHANDLED) return mou; } if (h->widgets == NULL) return MOU_UNHANDLED; /* send the event to widgets in reverse Z-order */ p = g_list_last (h->widgets); do { Widget *w = WIDGET (p->data); if (!widget_get_state (w, WST_DISABLED) && w->mouse_callback != NULL) { /* put global cursor position to the widget */ int ret; ret = dlg_mouse_translator (event, w); if (ret != MOU_UNHANDLED) return ret; } p = g_list_previous (p); } while (p != NULL); return MOU_UNHANDLED; }
static void _lib_modulelist_populate_callback(gpointer instance, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; /* go thru list of iop modules and add tp table */ GList *modules = g_list_last(darktable.develop->iop); int ti = 0, tj = 0; while(modules) { dt_iop_module_t *module = (dt_iop_module_t *)(modules->data); if(!dt_iop_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED)) { module->showhide = dtgtk_tristatebutton_new(NULL,0); char filename[1024], datadir[1024]; dt_loc_get_datadir(datadir, 1024); snprintf(filename, 1024, "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op); if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) snprintf(filename, 1024, "%s/pixmaps/plugins/darkroom/template.png", datadir); GtkWidget *image = gtk_image_new_from_file(filename); gtk_button_set_image(GTK_BUTTON(module->showhide), image); /* set button state */ char option[1024]; snprintf(option, 1024, "plugins/darkroom/%s/visible", module->op); gboolean active = dt_conf_get_bool (option); snprintf(option, 1024, "plugins/darkroom/%s/favorite", module->op); gboolean favorite = dt_conf_get_bool (option); gint state=0; if(active) { state++; if(favorite) state++; } _lib_modulelist_tristate_set_state(module->showhide,state,module); dtgtk_tristatebutton_set_state(DTGTK_TRISTATEBUTTON(module->showhide), state); /* connect tristate button callback*/ g_signal_connect(G_OBJECT(module->showhide), "tristate-changed", G_CALLBACK(_lib_modulelist_tristate_changed_callback), module); gtk_table_attach(GTK_TABLE(self->widget), module->showhide, ti, ti+1, tj, tj+1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_SHRINK, 0, 0); if(ti < 5) ti++; else { ti = 0; tj ++; } } modules = g_list_previous(modules); } }
void dialog_switch_prev (void) { GList *prev; if (mc_global.widget.midnight_shutdown || mc_current == NULL) return; prev = g_list_previous (mc_current); if (prev == NULL) prev = g_list_last (mc_dialogs); dialog_switch_goto (prev); }
dt_dev_pixelpipe_iop_t *dt_dev_distort_get_iop_pipe(dt_develop_t *dev, struct dt_dev_pixelpipe_t *pipe, struct dt_iop_module_t *module) { GList *pieces = g_list_last(pipe->nodes); while (pieces) { dt_dev_pixelpipe_iop_t *piece = (dt_dev_pixelpipe_iop_t *) (pieces->data); if ( piece->module == module) { return piece; } pieces = g_list_previous(pieces); } return NULL; }
/** * @brief * @param ui The GstSwitchUI instance. * @param key * @memberof GstSwitchUI */ static void gst_switch_ui_select_preview (GstSwitchUI * ui, guint key) { GList *view = NULL, *selected = NULL; GtkWidget *previous = NULL; GST_SWITCH_UI_LOCK_SELECT (ui); view = gtk_container_get_children (GTK_CONTAINER (ui->preview_box)); if (ui->selected == NULL) { if (view) switch (key) { case GDK_KEY_Up: selected = g_list_last (view); break; case GDK_KEY_Down: selected = view; break; } } else { for (; view; view = g_list_next (view)) { if (GTK_WIDGET (view->data) == ui->selected) { selected = view; break; } } if (selected) { previous = GTK_WIDGET (selected->data); switch (key) { case GDK_KEY_Up: selected = g_list_previous (selected); break; case GDK_KEY_Down: selected = g_list_next (selected); break; } } } if (selected) { ui->selected = GTK_WIDGET (selected->data); } if (ui->selected) { if (previous) { gtk_widget_unset_state_flags (previous, GTK_STATE_FLAG_SELECTED); } gtk_widget_set_state_flags (ui->selected, GTK_STATE_FLAG_SELECTED, TRUE); //INFO ("select: %p, %p", previous, ui->selected); } GST_SWITCH_UI_UNLOCK_SELECT (ui); }
KeyBindingTree *tree_build(GList *keylist) { GList *it; KeyBindingTree *ret = NULL, *p; if (g_list_length(keylist) <= 0) return NULL; /* nothing in the list.. */ for (it = g_list_last(keylist); it; it = g_list_previous(it)) { GList *kit; p = ret; ret = g_new0(KeyBindingTree, 1); for (kit = it; kit != NULL; kit = g_list_previous(kit)) ret->keylist = g_list_prepend(ret->keylist, g_strdup(kit->data)); /* deep copy */ ret->first_child = p; if (p != NULL) p->parent = ret; translate_key(it->data, &ret->state, &ret->key); } return ret; }
static gboolean update_trace_value (GstTraceValues * self, GstClockTime nts, GstClockTime nval, GstClockTime * dts, GstClockTime * dval) { GstTraceValue *lv; GstClockTimeDiff dt; GstClockTime window = self->window; GQueue *q = &self->values; GList *node = q->tail; gboolean ret = FALSE; /* search from the tail of the queue for a good GstTraceValue */ while (node) { lv = node->data; dt = GST_CLOCK_DIFF (lv->ts, nts); if (dt < window) { break; } else { node = g_list_previous (node); } } if (node) { /* calculate the windowed value */ *dts = dt; *dval = GST_CLOCK_DIFF (lv->val, nval); /* drop all older measurements */ while (q->tail != node) { free_trace_value (g_queue_pop_tail (q)); } ret = TRUE; } else { *dts = nts; *dval = nval; } /* don't push too many data items */ lv = q->head ? q->head->data : NULL; if (!lv || (GST_CLOCK_DIFF (lv->ts, nts) > (window / WINDOW_SUBDIV))) { /* push the new measurement */ lv = g_slice_new0 (GstTraceValue); lv->ts = nts; lv->val = nval; g_queue_push_head (q, lv); } return ret; }
void SCTPGraphDialog::drawTSNGraph() { GList *listTSN = NULL,*tlist; tsn_t *tsn; guint8 type; guint32 tsnumber=0; if (direction == 1) { listTSN = g_list_last(selected_assoc->tsn1); } else { listTSN = g_list_last(selected_assoc->tsn2); } while (listTSN) { tsn = (tsn_t*) (listTSN->data); tlist = g_list_first(tsn->tsns); while (tlist) { type = ((struct chunk_header *)tlist->data)->type; if (type == SCTP_DATA_CHUNK_ID || type == SCTP_I_DATA_CHUNK_ID || type == SCTP_FORWARD_TSN_CHUNK_ID) { tsnumber = g_ntohl(((struct data_chunk_header *)tlist->data)->tsn); yt.append(tsnumber); xt.append(tsn->secs + tsn->usecs/1000000.0); ft.append(tsn->frame_number); } tlist = g_list_next(tlist); } listTSN = g_list_previous(listTSN); } QCPScatterStyle myScatter; myScatter.setShape(QCPScatterStyle::ssCircle); myScatter.setSize(3); int graphcount = ui->sctpPlot->graphCount(); // create graph and assign data to it: // Add TSN graph if (xt.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(); gr->setName(QString("TSN")); myScatter.setPen(QPen(Qt::black)); myScatter.setBrush(Qt::black); ui->sctpPlot->graph(graphcount)->setScatterStyle(myScatter); ui->sctpPlot->graph(graphcount)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(graphcount)->setData(xt, yt); typeStrings.insert(graphcount, QString(tr("TSN"))); } }
void menu_frame_select_last(ObMenuFrame *self) { GList *it = NULL; if (self->entries) { for (it = g_list_last(self->entries); it; it = g_list_previous(it)) { ObMenuEntryFrame *e = it->data; if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) break; if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) break; } } menu_frame_select(self, it ? it->data : NULL, FALSE); }
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--; } }
/** * gtr_po_get_prev_fuzzy_or_untrans: * @po: a #GtrPo * * Return value: (transfer none) (element-type Gtranslator.Msg): * a pointer to the previously fuzzy or * untranslated message or NULL if there is not previously * fuzzy or untranslated message. **/ GList * gtr_po_get_prev_fuzzy_or_untrans (GtrPo * po) { GList *msg; GtrPoPrivate *priv = gtr_po_get_instance_private (po); msg = priv->current; while ((msg = g_list_previous (msg))) { if (gtr_msg_is_fuzzy (msg->data) || !gtr_msg_is_translated (msg->data)) return msg; } return NULL; }
static guint64 get_buffer_level (RTPJitterBuffer * jbuf) { GstBuffer *high_buf = NULL, *low_buf = NULL; guint64 level; GList *find; /* first first buffer with timestamp */ find = g_queue_peek_head_link (jbuf->packets); while (find) { high_buf = find->data; if (GST_BUFFER_TIMESTAMP (high_buf) != -1) break; high_buf = NULL; find = g_list_next (find); } find = g_queue_peek_tail_link (jbuf->packets); while (find) { low_buf = find->data; if (GST_BUFFER_TIMESTAMP (low_buf) != -1) break; low_buf = NULL; find = g_list_previous (find); } if (!high_buf || !low_buf || high_buf == low_buf) { level = 0; } else { guint64 high_ts, low_ts; high_ts = GST_BUFFER_TIMESTAMP (high_buf); low_ts = GST_BUFFER_TIMESTAMP (low_buf); if (high_ts > low_ts) level = high_ts - low_ts; else level = 0; GST_LOG_OBJECT (jbuf, "low %" GST_TIME_FORMAT " high %" GST_TIME_FORMAT " level %" G_GUINT64_FORMAT, GST_TIME_ARGS (low_ts), GST_TIME_ARGS (high_ts), level); } return level; }
/* deletes everything include the GList */ void s_delete_object_glist(TOPLEVEL *toplevel, GList *list) { OBJECT *o_current=NULL; GList *ptr; ptr = g_list_last(list); /* do the delete backwards */ while(ptr != NULL) { o_current = (OBJECT *) ptr->data; s_delete_object(toplevel, o_current); ptr = g_list_previous (ptr); } g_list_free(list); }
static void tny_gtk_folder_list_store_iterator_prev (TnyIterator *self) { TnyGtkFolderListStoreIterator *me = (TnyGtkFolderListStoreIterator*) self; if (G_UNLIKELY (!me || !me->current || !me->model)) return; /* Move the iterator to the previous node */ g_mutex_lock (me->model->iterator_lock); me->current = g_list_previous (me->current); g_mutex_unlock (me->model->iterator_lock); return; }
static void tny_gtk_attach_list_model_iterator_prev (TnyIterator *self) { TnyGtkAttachListModelIterator *me = (TnyGtkAttachListModelIterator*) self; if (G_UNLIKELY (!me || !me->current || !me->model)) return; /* Move the iterator to the previous node */ g_mutex_lock (me->model->iterator_lock); me->current = g_list_previous (me->current); g_mutex_unlock (me->model->iterator_lock); return; }
/** * Moves the iterator to the next element and returns its key. If * there is no next element, NULL is returned. */ void * list_iter_next(list_iter_t *iter) { GList *next; list_iter_check(iter); next = iter->next; if (next) { iter->data = next->data; iter->prev = g_list_previous(next); iter->next = g_list_next(next); return iter->data; } else { return NULL; } }
static GList * log_store_empathy_get_filtered_messages (EmpathyLogStore *self, TpAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data) { GList *dates, *l, *messages = NULL; guint i = 0; dates = log_store_empathy_get_dates (self, account, chat_id, chatroom); for (l = g_list_last (dates); l && i < num_messages; l = g_list_previous (l)) { GList *new_messages, *n, *next; /* FIXME: We should really restrict the message parsing to get only * the newest num_messages. */ new_messages = log_store_empathy_get_messages_for_date (self, account, chat_id, chatroom, l->data); n = new_messages; while (n != NULL) { next = g_list_next (n); if (!filter (n->data, user_data)) { g_object_unref (n->data); new_messages = g_list_delete_link (new_messages, n); } else { i++; } n = next; } messages = g_list_concat (messages, new_messages); } g_list_foreach (dates, (GFunc) g_free, NULL); g_list_free (dates); return messages; }
/** * Moves the iterator to the previous element and returns its key. If * there is no previous element, NULL is returned. */ void * list_iter_previous(list_iter_t *iter) { GList *prev; list_iter_check(iter); prev = iter->prev; if (prev) { iter->data = prev->data; iter->next = g_list_next(prev); iter->prev = g_list_previous(prev); return iter->data; } else { return NULL; } }