Beispiel #1
0
PoEntry *
po_entry_copy (PoEntry *ret, PoEntry *po)
{
	if (ret == NULL)
		ret = g_new (PoEntry, 1);

	ret->comments.std = g_slist_copy (po->comments.std);
	po_list_str_dup(ret->comments.std);
	ret->comments.pos = g_slist_copy (po->comments.pos);
	po_list_str_dup(ret->comments.pos);
	ret->comments.res = g_slist_copy (po->comments.res);
	po_list_str_dup(ret->comments.res);
	ret->comments.spec = g_slist_copy (po->comments.spec);
	po_list_str_dup(ret->comments.spec);

	ret->previous.ctx = stringblock_dup (po->previous.ctx);
	ret->previous.id = stringblock_dup (po->previous.id);
	ret->previous.id_plural = stringblock_dup (po->previous.id_plural);

	ret->is_fuzzy = po->is_fuzzy;
	ret->is_c_format = po->is_c_format;

	ret->ctx = stringblock_dup (po->ctx);
	ret->id = stringblock_dup (po->id);
	ret->id_plural = stringblock_dup (po->id_plural);
	ret->str = stringblock_dup (po->str);

	ret->msgstrxs = g_slist_copy (po->msgstrxs);
	po_list_msgstrx_dup(ret->msgstrxs);

	return ret;
}
Beispiel #2
0
void sampler_layer_data_clone(struct sampler_layer_data *dst, const struct sampler_layer_data *src, gboolean copy_hasattr)
{
    SAMPLER_FIXED_FIELDS(PROC_FIELDS_CLONE)
    memcpy(dst->velcurve, src->velcurve, 128 * sizeof(float));
    dst->modulations = g_slist_copy(src->modulations);
    for(GSList *mod = dst->modulations; mod; mod = mod->next)
    {
        struct sampler_modulation *srcm = mod->data;
        struct sampler_modulation *dstm = g_malloc(sizeof(struct sampler_modulation));
        memcpy(dstm, srcm, sizeof(struct sampler_modulation));
        dstm->has_value = copy_hasattr ? srcm->has_value : FALSE;
        mod->data = dstm;
    }
    dst->nifs = g_slist_copy(src->nifs);
    for(GSList *nif = dst->nifs; nif; nif = nif->next)
    {
        struct sampler_noteinitfunc *dstn = g_malloc(sizeof(struct sampler_noteinitfunc));
        struct sampler_noteinitfunc *srcn = nif->data;
        memcpy(dstn, srcn, sizeof(struct sampler_noteinitfunc));
        dstn->has_value = copy_hasattr ? srcn->has_value : FALSE;
        nif->data = dstn;
    }
    dst->eff_waveform = src->eff_waveform;
    if (dst->eff_waveform)
        cbox_waveform_ref(dst->eff_waveform);
}
Beispiel #3
0
static void
part_copy (ItemData *dest, ItemData *src)
{
	Part *dest_part, *src_part;
	GSList *list;
	int i;

	g_return_if_fail (dest != NULL);
	g_return_if_fail (IS_PART (dest));
	g_return_if_fail (src != NULL);
	g_return_if_fail (IS_PART (src));

	if (parent_class->copy != NULL)
		parent_class->copy (dest, src);

	dest_part = PART (dest);
	src_part = PART (src);

	dest_part->priv->rotation = src_part->priv->rotation;
	dest_part->priv->flip = src_part->priv->flip;
	dest_part->priv->num_pins = src_part->priv->num_pins;
	dest_part->priv->library = src_part->priv->library;
	dest_part->priv->name = g_strdup (src_part->priv->name);
	dest_part->priv->symbol_name = g_strdup (src_part->priv->symbol_name);

	memcpy (dest_part->priv->pins, src_part->priv->pins,
		src_part->priv->num_pins * sizeof (Pin));
	for (i = 0; i < dest_part->priv->num_pins; i++)
		dest_part->priv->pins[i].part = dest_part;

	// Copy properties and labels.
	dest_part->priv->properties =
		g_slist_copy (src_part->priv->properties);
	for (list = dest_part->priv->properties; list; list = list->next) {
		PartProperty *prop, *new_prop;

		new_prop = g_new0 (PartProperty, 1);
		prop = list->data;
		new_prop->name = g_strdup (prop->name);
		new_prop->value = g_strdup (prop->value);
		list->data = new_prop;
	}

	dest_part->priv->labels = g_slist_copy (src_part->priv->labels);
	for (list = dest_part->priv->labels; list; list = list->next) {
		PartLabel *label, *new_label;

		new_label = g_new0 (PartLabel, 1);
		label = list->data;
		new_label->name = g_strdup (label->name);
		new_label->text = g_strdup (label->text);
		new_label->pos = label->pos;
		list->data = new_label;
	}
}
Beispiel #4
0
static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
{
	float temperature, humidity;
	struct sr_datafeed_packet packet;
	struct sr_datafeed_analog analog;
	struct sr_analog_encoding encoding;
	struct sr_analog_meaning meaning;
	struct sr_analog_spec spec;
	struct dev_context *devc;
	GSList *l;
	int ret;

	(void)idx;

	devc = sdi->priv;

	ret = packet_parse((const char *)buf, idx, &temperature, &humidity);
	if (ret < 0) {
		sr_err("Failed to parse packet.");
		return SR_ERR;
	}

	sr_analog_init(&analog, &encoding, &meaning, &spec, 3);

	/* Common values for both channels. */
	packet.type = SR_DF_ANALOG;
	packet.payload = &analog;
	analog.num_samples = 1;

	/* Temperature. */
	l = g_slist_copy(sdi->channels);
	l = g_slist_remove_link(l, g_slist_nth(l, 1));
	meaning.channels = l;
	meaning.mq = SR_MQ_TEMPERATURE;
	meaning.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
	analog.data = &temperature;
	sr_session_send(sdi, &packet);
	g_slist_free(l);

	/* Humidity. */
	if (mic_devs[idx].has_humidity) {
		l = g_slist_copy(sdi->channels);
		l = g_slist_remove_link(l, g_slist_nth(l, 0));
		meaning.channels = l;
		meaning.mq = SR_MQ_RELATIVE_HUMIDITY;
		meaning.unit = SR_UNIT_PERCENTAGE;
		analog.data = &humidity;
		sr_session_send(sdi, &packet);
		g_slist_free(l);
	}

	devc->num_samples++;

	return SR_OK;
}
gchar *
concatenate_child_result_chars(GSList *data_from_children)
{
    GSList *lp;
    gchar *name = g_strdup("");

    g_return_val_if_fail(name, NULL);

    /* child data lists are in reverse chron order */
    data_from_children = g_slist_reverse(g_slist_copy(data_from_children));

    for (lp = data_from_children; lp; lp = lp->next)
    {
        sixtp_child_result *cr = (sixtp_child_result *) lp->data;
        if (cr->type != SIXTP_CHILD_RESULT_CHARS)
        {
            PERR ("result type is not chars");
            g_slist_free (data_from_children);
            g_free(name);
            return(NULL);
        }
        else
        {
            char *temp;
            temp = g_strconcat(name, (gchar *) cr->data, NULL);
            g_free (name);
            name = temp;
        }
    }
    g_slist_free (data_from_children);
    return(name);
}
Beispiel #6
0
/**
 * retourne l'index du radiobutton actif.
 *
 * \param radio_button
 *
 * \return index bouton actif
 */
gint utils_radiobutton_get_active_index ( GtkWidget *radiobutton )
{
    GSList *liste;
    GSList *tmp_list;
    gint index = 0;

    liste = g_slist_copy ( gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( radiobutton ) ) );
    tmp_list = g_slist_reverse ( liste );

    while ( tmp_list )
    {
        GtkWidget *button;

        button = tmp_list->data;
        if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button ) ) )
            break;

        index++;
        tmp_list = tmp_list->next;
    }

    g_slist_free ( liste );

    return index;
}
Beispiel #7
0
static GSList *
node_func (GdaTreeManager *manager, GdaTreeNode *node, const GSList *children_nodes,
	   G_GNUC_UNUSED gboolean *out_error, G_GNUC_UNUSED GError **error)
{
	if (children_nodes) {
		/* we don't create or modify already created GdaTreeNode object => simply ref them */
		g_slist_foreach ((GSList*) children_nodes, (GFunc) g_object_ref, NULL);
		return g_slist_copy ((GSList*) children_nodes);
	}
	else {
		GSList *list;
		GdaTreeNode *snode;
		GValue *scale;

		snode = gda_tree_manager_create_node (manager, node, "Scaling...");
		g_value_set_double ((scale = gda_value_new (G_TYPE_DOUBLE)), 1.);
		gda_tree_node_set_node_attribute (snode, "scale", scale, NULL);
		gda_value_free (scale);
		g_timeout_add (50, (GSourceFunc) timout_cb, g_object_ref (snode));

		g_value_set_boolean ((scale = gda_value_new (G_TYPE_BOOLEAN)), TRUE);
		gda_tree_node_set_node_attribute (snode, "scale-set", scale, NULL);
		gda_value_free (scale);

		list = g_slist_append (NULL, snode);
		return list;
	}
}
Beispiel #8
0
static uint8_t register_endpoint(const uint8_t *uuid, uint8_t codec,
							GSList *presets)
{
	struct a2dp_endpoint *endpoint;

	/* FIXME: Add proper check for uuid */

	endpoint = g_new0(struct a2dp_endpoint, 1);
	endpoint->id = g_slist_length(endpoints) + 1;
	endpoint->codec = codec;
	endpoint->sep = avdtp_register_sep(AVDTP_SEP_TYPE_SOURCE,
						AVDTP_MEDIA_TYPE_AUDIO,
						codec, FALSE, &sep_ind,
						&sep_cfm, endpoint);
	endpoint->caps = presets->data;
	endpoint->presets = g_slist_copy(g_slist_nth(presets, 1));

	if (endpoint->codec == A2DP_CODEC_VENDOR) {
		a2dp_vendor_codec_t *vndcodec = (void *) endpoint->caps->data;

		avdtp_sep_set_vendor_codec(endpoint->sep,
						btohl(vndcodec->vendor_id),
						btohs(vndcodec->codec_id));
	}

	endpoints = g_slist_append(endpoints, endpoint);

	return endpoint->id;
}
static gboolean
add_active_posts_no_signal(HippoDataCache  *cache,
                           GSList          *posts)
{                           
    GSList *link;
    GSList *copy;
    gboolean added_anything;

    added_anything = FALSE;

    /* Make a backward copy so we can prepend each post 
     * and end up keeping their order
     */
    copy = g_slist_copy(posts);
    copy = g_slist_reverse(copy);

    /* This is a terrible algorithm but the lists are supposed
     * to be very short so it should be OK
     */
    for (link = copy; link != NULL; link = link->next) {
        HippoPost *post = link->data;
        if (g_slist_find(cache->active_posts, post)) {
            ; /* nothing, already in there */
        } else {
            cache->active_posts = g_slist_prepend(cache->active_posts, post);
            g_object_ref(post);
            added_anything = TRUE;
        }
    }
    
    g_slist_free(copy);

    return added_anything;
}
Beispiel #10
0
static void
invoke_notifies (MenuMonitor      *monitor,
		 MenuMonitorEvent  event,
		 const char       *path)
{
  GSList *copy;
  GSList *tmp;

  copy = g_slist_copy (monitor->notifies);
  g_slist_foreach (copy,
		   (GFunc) menu_monitor_notify_ref,
		   NULL);

  tmp = copy;
  while (tmp != NULL)
    {
      MenuMonitorNotify *notify = tmp->data;
      GSList            *next   = tmp->next;

      if (notify->notify_func)
	{
	  notify->notify_func (monitor, event, path, notify->user_data);
	}

      menu_monitor_notify_unref (notify);

      tmp = next;
    }

  g_slist_free (copy);
}
Beispiel #11
0
void
node_foreach_child_full (nodePtr node, gpointer func, gint params, gpointer user_data)
{
	GSList		*children, *iter;

	g_assert (NULL != node);

	/* We need to copy because func might modify the list */
	iter = children = g_slist_copy (node->children);
	while (iter) {
		nodePtr childNode = (nodePtr)iter->data;

		/* Apply the method to the child */
		if (0 == params)
			((nodeActionFunc)func) (childNode);
		else
			((nodeActionDataFunc)func) (childNode, user_data);

		/* Never descend! */

		iter = g_slist_next (iter);
	}

	g_slist_free (children);
}
GSList *
g_slist_agregate(GSList * list, GCompareFunc comparator)
{
	GSList *resL2 = NULL;	/*a list of lists of chunk_info_t */
	GSList *sorted = NULL;	/*a list of chunk_info_t */
	GSList *cursor1 = NULL;
	GSList *last_agregate = NULL;

	if (!list)
		return NULL;

	sorted = g_slist_copy(list);
	if (!sorted)
		return NULL;
	sorted = g_slist_sort(sorted, comparator);
	if (!sorted)
		return NULL;

	for (cursor1 = sorted; cursor1; cursor1 = cursor1->next) {
		if (!cursor1->data)
			continue;
		if (last_agregate && 0 > comparator(last_agregate->data, cursor1->data)) {
			resL2 = g_slist_prepend(resL2, last_agregate);
			last_agregate = NULL;
		}
		last_agregate = g_slist_prepend(last_agregate, cursor1->data);
	}

	if (last_agregate)
		resL2 = g_slist_prepend(resL2, last_agregate);

	g_slist_free (sorted);
	return g_slist_reverse(resL2);
}
Beispiel #13
0
void
glade_gtk_size_group_set_property (GladeWidgetAdaptor * adaptor,
                                   GObject * object,
                                   const gchar * property_name,
                                   const GValue * value)
{
  if (!strcmp (property_name, "widgets"))
    {
      GSList *sg_widgets, *slist;
      GList *widgets, *list;

      /* remove old widgets */
      if ((sg_widgets =
           gtk_size_group_get_widgets (GTK_SIZE_GROUP (object))) != NULL)
        {
          /* copy since we are modifying an internal list */
          sg_widgets = g_slist_copy (sg_widgets);
          for (slist = sg_widgets; slist; slist = slist->next)
            gtk_size_group_remove_widget (GTK_SIZE_GROUP (object),
                                          GTK_WIDGET (slist->data));
          g_slist_free (sg_widgets);
        }

      /* add new widgets */
      if ((widgets = g_value_get_boxed (value)) != NULL)
        {
          for (list = widgets; list; list = list->next)
            gtk_size_group_add_widget (GTK_SIZE_GROUP (object),
                                       GTK_WIDGET (list->data));
        }
    }
  else
    GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object,
                                                 property_name, value);
}
/**
 * Callback called when toggle the check button to split the neutral method of payments
 *
 * \param cell
 * \param path_str
 * \param tree_view
 *
 * \return FALSE
 */
gboolean gsb_reconcile_sort_config_neutral_toggled ( GtkCellRendererToggle *cell,
						     gchar *path_str,
						     GtkWidget *tree_view )
{
    GtkTreePath * treepath;
    GtkTreeIter iter;
    gboolean toggle;
    gint account_number;
    GSList *sorted_list_copy;
    GSList *tmp_list;
    GtkTreeModel *model;

    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));

    /* invert the toggle */
    treepath = gtk_tree_path_new_from_string ( path_str );
    gtk_tree_model_get_iter ( GTK_TREE_MODEL (model),
			      &iter, treepath );

    gtk_tree_model_get (GTK_TREE_MODEL(model), &iter,
			RECONCILIATION_SORT_SPLIT_NEUTRAL_COLUMN, &toggle,
			RECONCILIATION_SORT_ACCOUNT_COLUMN, &account_number,
			-1);
    toggle ^= 1;
    gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
			RECONCILIATION_SORT_SPLIT_NEUTRAL_COLUMN, toggle,
			-1);

    /* and save it */
    gsb_data_account_set_split_neutral_payment ( account_number,
						 toggle );

    /* need to copy the sorted_list to avoid an infinite loop when add a negative payment neutral later */
    sorted_list_copy = g_slist_copy (gsb_data_account_get_sort_list (account_number));
    tmp_list = sorted_list_copy;

    while (tmp_list)
    {
	gint payment_number;

	payment_number = GPOINTER_TO_INT (tmp_list -> data);

	/* payment_number can be negative, so do for it abs */
	if ( gsb_data_payment_get_sign (abs (payment_number)) == GSB_PAYMENT_NEUTRAL )
	{
	    if (toggle)
		gsb_data_account_sort_list_add ( account_number,
						 -payment_number );
	    else
		if (payment_number < 0 )
		    gsb_data_account_sort_list_remove ( account_number,
							payment_number );
	}
	tmp_list = tmp_list -> next;
    }
    g_slist_free (sorted_list_copy);
    gsb_reconcile_sort_config_fill ();
    gsb_file_set_modified ( TRUE );
    return FALSE;
}
Beispiel #15
0
static void read_settings(void)
{
	LISTEN_REC *rec;
	GSList *remove_listens;
	char **ports, **tmp, *ircnet, *port;
	int portnum;

	remove_listens = g_slist_copy(proxy_listens);

	ports = g_strsplit(settings_get_str("irssiproxy_ports"), " ", -1);
	for (tmp = ports; *tmp != NULL; tmp++) {
		ircnet = *tmp;
		port = strchr(ircnet, '=');
		if (port == NULL)
			continue;

		*port++ = '\0';
		portnum = atoi(port);
		if (portnum <=  0)
			continue;

		rec = find_listen(ircnet, portnum);
		if (rec == NULL)
			add_listen(ircnet, portnum);
		else
			remove_listens = g_slist_remove(remove_listens, rec);
	}
	g_strfreev(ports);

	while (remove_listens != NULL) {
                remove_listen(remove_listens->data);
		remove_listens = g_slist_remove(remove_listens, remove_listens->data);
	}
}
Beispiel #16
0
static void
write_xml_wire (Wire *wire, parseXmlContext *ctxt)
{
	xmlNodePtr node_wire;
	gchar *str;
	Coords start_pos, end_pos;

	g_return_if_fail (wire != NULL);
	g_return_if_fail (IS_WIRE (wire));

	// Create a node for the wire.
	node_wire = xmlNewChild (ctxt->node_wires, ctxt->ns, BAD_CAST "wire", NULL);
	if (!node_wire) {
		g_warning ("Failed during save of wire.\n");
		return;
	}

	wire_get_start_pos (wire, &start_pos);
	wire_get_end_pos (wire, &end_pos);

	Node *node;
	Coords last, current, tmp;
	GSList *iter, *copy;

	copy = g_slist_sort (g_slist_copy (wire_get_nodes (wire)), cmp_nodes);
	current = last = start_pos;

	for (iter = copy; iter; iter = iter->next) {
		node = iter->data;
		if (node==NULL) {
			g_warning ("Node of wire did not exist [%p].", node);
			continue;
		}

		tmp = node->key;
		if (coords_equal(&tmp, &start_pos))
			continue;
		if (coords_equal(&tmp, &end_pos))
			continue;

		last = current;
		current = tmp;

		str = g_strdup_printf ("(%g %g)(%g %g)",
			                   last.x, last.y, current.x, current.y);

		xmlNewChild (node_wire, ctxt->ns, BAD_CAST "points", BAD_CAST str);
		g_free (str);
	}
	last = current;
	current = end_pos;
	str = g_strdup_printf ("(%g %g)(%g %g)",
			                   last.x, last.y, current.x, current.y);

	xmlNewChild (node_wire, ctxt->ns, BAD_CAST "points", BAD_CAST str);
	g_free (str);

	g_slist_free (copy);

}
Beispiel #17
0
/**
 * Standard scan() callback API helper.
 *
 * This function can be used to perform common tasks required by a driver's
 * scan() callback. It will initialize the driver for each device on the list
 * and add the devices on the list to the driver's device instance list.
 * Usually it should be used as the last step in the scan() callback, right
 * before returning.
 *
 * Note: This function can only be used if std_init() has been called
 * previously by the driver.
 *
 * Example:
 * @code{c}
 * static GSList *scan(struct sr_dev_driver *di, GSList *options)
 * {
 *     struct GSList *device;
 *     struct sr_dev_inst *sdi;
 *
 *     sdi = g_new0(sr_dev_inst, 1);
 *     sdi->vendor = ...;
 *     ...
 *     devices = g_slist_append(devices, sdi);
 *     ...
 *     return std_scan_complete(di, devices);
 * }
 * @endcode
 *
 * @param di The driver instance to use. Must not be NULL.
 * @param devices List of newly discovered devices (struct sr_dev_inst).
 *
 * @return The @p devices list.
 */
SR_PRIV GSList *std_scan_complete(struct sr_dev_driver *di, GSList *devices)
{
	struct drv_context *drvc;
	GSList *l;

	if (!di) {
		sr_err("Invalid driver instance (di), cannot complete scan.");
		return NULL;
	}

	drvc = di->context;

	for (l = devices; l; l = l->next) {
		struct sr_dev_inst *sdi = l->data;
		if (!sdi) {
			sr_err("Invalid driver instance, cannot complete scan.");
			return NULL;
		}
		sdi->driver = di;
	}

	drvc->instances = g_slist_concat(drvc->instances, g_slist_copy(devices));

	return devices;
}
Beispiel #18
0
void uri_opener_open(MessageView *msgview, GSList *uris)
{
	cm_return_if_fail(msgview);
	cm_return_if_fail(msgview->mimeview);
	cm_return_if_fail(msgview->mimeview->textview);
	cm_return_if_fail(msgview);
	if (!opener.window)
		uri_opener_create();

	manage_window_set_transient(GTK_WINDOW(opener.window));
	gtk_widget_grab_focus(opener.close_btn);
	
	if (uris == NULL) {
		alertpanel_notice(_("There are no URLs in this email."));
		return;
	}
	
	opener.msgview = msgview;
	opener.uris = g_slist_copy(uris);
	uri_opener_load_uris();

	gtk_widget_show(opener.window);
	gtk_widget_grab_focus(opener.urilist);
	gtk_window_set_modal(GTK_WINDOW(opener.window), TRUE);
}
Beispiel #19
0
static GSList*
string_list_strip_duplicates_from_back (GSList *list)
{
  GHashTable *table;
  GSList *tmp;
  GSList *nodups = NULL;
  GSList *reversed;
  
  table = g_hash_table_new (g_str_hash, g_str_equal);

  reversed = g_slist_reverse (g_slist_copy (list));
  
  tmp = reversed;
  while (tmp != NULL)
    {
      if (g_hash_table_lookup (table, tmp->data) == NULL)
        {
          /* This unreverses the reversed list */
          nodups = g_slist_prepend (nodups, tmp->data);
          g_hash_table_insert (table, tmp->data, tmp->data);
        }
      else
        {
          debug_spew (" removing duplicate (from back) \"%s\"\n", tmp->data);
        }
      
      tmp = g_slist_next (tmp);
    }

  g_slist_free (reversed);
  
  g_hash_table_destroy (table);
  
  return nodups;
}
Beispiel #20
0
/**
 * beagle_hit_get_all_properties:
 * @hit: a #BeagleHit
 *
 * Fetches all properties of the given #BeagleHit
 *
 * Return value: A list of all properties (BeagleProperty *) of @hit.  The values
 * contained within the list should not be freed.
 **/ 
GSList *
beagle_hit_get_all_properties (BeagleHit *hit)
{
	g_return_val_if_fail (hit != NULL, NULL);

	return g_slist_copy (hit->properties);
}
static void
rejilla_search_beagle_hit_added_cb (BeagleQuery *query,
				    BeagleHitsAddedResponse *response,
				    RejillaSearchBeagle *search)
{
	GSList *list;
	GSList *iter;
	RejillaSearchBeaglePrivate *priv;

	priv = REJILLA_SEARCH_BEAGLE_PRIVATE (search);

	/* NOTE : list must not be modified nor freed */
	list = beagle_hits_added_response_get_hits (response);
	list = g_slist_copy (list);

	if (priv->hits)
		priv->hits = g_slist_concat (priv->hits, list);
	else
		priv->hits = list;

	for (iter = list; iter; iter = iter->next) {
		BeagleHit *hit;

		hit = iter->data;
		beagle_hit_ref (hit);

		rejilla_search_engine_hit_added (REJILLA_SEARCH_ENGINE (search), hit);
	}
}
Beispiel #22
0
//FIXME: must work with text selection
void
text_remove_all_kerns()
{
    SPDesktop *desktop = SP_ACTIVE_DESKTOP;

    Inkscape::Selection *selection = sp_desktop_selection(desktop);

    if (selection->isEmpty()) {
        sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>text(s)</b> to remove kerns from."));
        return;
    }

    bool did = false;

    for (GSList *items = g_slist_copy((GSList *) selection->itemList());
         items != NULL;
         items = items->next) {
        SPObject *obj = SP_OBJECT(items->data);

        if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) {
            continue;
        }

        text_remove_all_kerns_recursively(obj);
        obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
        did = true;
    }

    if (!did) {
        sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("Select <b>text(s)</b> to remove kerns from."));
    } else {
        sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, 
                         _("Remove manual kerns"));
    }
}
GSList *
panel_g_slist_make_unique (GSList       *list,
			   GCompareFunc  compare,
			   gboolean      free_data)
{
	GSList *sorted, *l;

	g_assert (compare != NULL);

	if (!list)
		return NULL;

	sorted = g_slist_copy (list);
	sorted = g_slist_sort (sorted, compare);

	for (l = sorted; l; l = l->next) {
		GSList *next;

		next = l->next;
		if (l->data && next && next->data)
			if (!compare (l->data, next->data)) {
				list = g_slist_remove (list, l->data);
				if (free_data)
					g_free (l->data);
			}
	}

	g_slist_free (sorted);

	return list;
}
Beispiel #24
0
static uint8_t chan_get_transaction(struct avctp_channel *chan)
{
	GSList *l, *tmp;
	uint8_t transaction;

	if (!chan->processed)
		goto done;

	tmp = g_slist_copy(chan->processed);

	/* Find first unused transaction id */
	for (l = tmp; l; l = g_slist_next(l)) {
		struct avctp_pending_req *req = l->data;

		if (req->transaction == chan->transaction) {
			chan->transaction++;
			chan->transaction %= 16;
			tmp = g_slist_delete_link(tmp, l);
			l = tmp;
		}
	}

	g_slist_free(tmp);

done:
	transaction = chan->transaction;

	chan->transaction++;
	chan->transaction %= 16;

	return transaction;
}
static void
scrollmethod_clicked_event (GtkWidget *widget,
				GtkBuilder *dialog)
{
	GtkToggleButton *disabled = GTK_TOGGLE_BUTTON (WID ("scroll_disabled_radio"));

	gtk_widget_set_sensitive (WID ("horiz_scroll_toggle"),
				  !gtk_toggle_button_get_active (disabled));

	gtk_widget_set_sensitive (WID ("natural_scroll_toggle"),
				  !gtk_toggle_button_get_active (disabled));

	GSList *radio_group;
	int new_scroll_method;
	int old_scroll_method = g_settings_get_int (touchpad_settings, "scroll-method");

	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)))
		return;

	radio_group = g_slist_copy (gtk_radio_button_get_group
		(GTK_RADIO_BUTTON (WID ("scroll_disabled_radio"))));
	radio_group = g_slist_reverse (radio_group);
	new_scroll_method = g_slist_index (radio_group, widget);
	g_slist_free (radio_group);
	
	if (new_scroll_method != old_scroll_method)
		g_settings_set_int (touchpad_settings, "scroll-method", new_scroll_method);
}
Beispiel #26
0
/**
 * gda_repetitive_statement_get_all_sets:
 * @rstmt: a #GdaRepetitiveStatement object
 *
 * Get all the values sets which will have been added using gda_repetitive_statement_append_set().
 *
 * Returns: (transfer container) (element-type GdaSet): a new #GSList of #GdaSet objects (free with g_slist_free()).
 *
 * Since: 4.2
 */
GSList*
gda_repetitive_statement_get_all_sets (GdaRepetitiveStatement *rstmt)
{
	GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private (rstmt);
	
	return g_slist_copy (g_slist_reverse (priv->values_sets));
}
Beispiel #27
0
static BraseroBurnResult
brasero_normalize_start (BraseroJob *job,
			 GError **error)
{
	BraseroNormalizePrivate *priv;
	BraseroBurnResult result;

	priv = BRASERO_NORMALIZE_PRIVATE (job);

	priv->album_gain = -1.0;
	priv->album_peak = -1.0;

	/* get tracks */
	brasero_job_get_tracks (job, &priv->tracks);
	if (!priv->tracks)
		return BRASERO_BURN_ERR;

	priv->tracks = g_slist_copy (priv->tracks);

	result = brasero_normalize_set_next_track (job, error);
	if (result == BRASERO_BURN_ERR)
		return BRASERO_BURN_ERR;

	if (result == BRASERO_BURN_OK)
		return BRASERO_BURN_NOT_RUNNING;

	/* ready to go */
	brasero_job_set_current_action (job,
					BRASERO_BURN_ACTION_ANALYSING,
					_("Normalizing tracks"),
					FALSE);

	return BRASERO_BURN_OK;
}
Beispiel #28
0
/**
 * g_thread_foreach:
 * @thread_func: function to call for all #GThread structures
 * @user_data: second argument to @thread_func
 *
 * Call @thread_func on all #GThreads that have been
 * created with g_thread_create().
 *
 * Note that threads may decide to exit while @thread_func is
 * running, so without intimate knowledge about the lifetime of
 * foreign threads, @thread_func shouldn't access the GThread*
 * pointer passed in as first argument. However, @thread_func will
 * not be called for threads which are known to have exited already.
 *
 * Due to thread lifetime checks, this function has an execution complexity
 * which is quadratic in the number of existing threads.
 *
 * Since: 2.10
 *
 * Deprecated:2.32: There aren't many things you can do with a #GThread,
 *     except comparing it with one that was returned from g_thread_create().
 *     There are better ways to find out if your thread is still alive.
 */
void
g_thread_foreach (GFunc    thread_func,
                  gpointer user_data)
{
  GSList *slist = NULL;
  GRealThread *thread;
  g_return_if_fail (thread_func != NULL);
  /* snapshot the list of threads for iteration */
  G_LOCK (g_thread);
  slist = g_slist_copy (g_thread_all_threads);
  G_UNLOCK (g_thread);
  /* walk the list, skipping non-existent threads */
  while (slist)
    {
      GSList *node = slist;
      slist = node->next;
      /* check whether the current thread still exists */
      G_LOCK (g_thread);
      if (g_slist_find (g_thread_all_threads, node->data))
        thread = node->data;
      else
        thread = NULL;
      G_UNLOCK (g_thread);
      if (thread)
        thread_func (thread, user_data);
      g_slist_free_1 (node);
    }
}
Beispiel #29
0
static int server_reconnect_timeout(void)
{
	SERVER_CONNECT_REC *conn;
	GSList *list, *tmp;
	time_t now;

	/* If server_connect() removes the next reconnection in queue,
	   we're screwed. I don't think this should happen anymore, but just
	   to be sure we don't crash, do this safely. */
	list = g_slist_copy(reconnects);
	now = time(NULL);
	for (tmp = list; tmp != NULL; tmp = tmp->next) {
		RECONNECT_REC *rec = tmp->data;

		if (g_slist_find(reconnects, rec) == NULL)
			continue;

		if (rec->next_connect <= now) {
			conn = rec->conn;
			server_reconnect_destroy(rec, FALSE);
			server_connect(conn);
		}
	}

	g_slist_free(list);
	return 1;
}
bool
HippoChatRoomWrapper::idleRescan()
{
    removeAllMembers(false);

    // have to free list and unref each member
    GSList *members = hippo_chat_room_get_users(delegate_);
    
    for (GSList *link = members; link != NULL; link = link->next) {
        HippoPerson *user = HIPPO_PERSON(link->data);
        addMember(user);
        g_object_unref(G_OBJECT(user));
    }
    g_slist_free(members);

    // this list on the other hand is not a copy, but we copy it for ourselves.
    // right now it should be safe not to copy the members since HippoChatRoom
    // never deletes messages once added... but perhaps not the best long-term plan
    GSList *messages = g_slist_copy(hippo_chat_room_get_messages(delegate_));
    for (GSList *link = messages; link != NULL; link = link->next) {
        HippoChatMessage *m = static_cast<HippoChatMessage*>(link->data);
        notifyMessage(m);
    }
    g_slist_free(messages);

    return false;
}