Ejemplo n.º 1
0
void init_separator_panel(void *p)
{
	Panel *panel = (Panel *)p;

	// Make sure this is only done once if there are multiple items
	if (panel->separator_list)
		return;

	// panel->separator_list is now a copy of the pointer panel_config.separator_list
	// We make it a deep copy
	panel->separator_list = g_list_copy_deep(panel_config.separator_list, NULL, NULL);

	for (GList *l = panel->separator_list; l; l = l->next) {
		Separator *separator = (Separator *)l->data;
		if (!separator->area.bg)
			separator->area.bg = &g_array_index(backgrounds, Background, 0);
		separator->area.parent = p;
		separator->area.panel = p;
		snprintf(separator->area.name, sizeof(separator->area.name), "separator");
		separator->area.size_mode = LAYOUT_FIXED;
		separator->area.resize_needed = 1;
		separator->area.on_screen = TRUE;
		separator->area._resize = resize_separator;
		separator->area._compute_desired_size = separator_compute_desired_size;
		separator->area._draw_foreground = draw_separator;
		instantiate_area_gradients(&separator->area);
	}
}
Ejemplo n.º 2
0
GList *
ges_layer_get_clips (GESLayer * layer)
{
  GESLayerClass *klass;

  g_return_val_if_fail (GES_IS_LAYER (layer), NULL);

  klass = GES_LAYER_GET_CLASS (layer);

  if (klass->get_objects) {
    return klass->get_objects (layer);
  }

  return g_list_sort (g_list_copy_deep (layer->priv->clips_start,
          (GCopyFunc) gst_object_ref, NULL),
      (GCompareFunc) element_start_compare);
}
Ejemplo n.º 3
0
void init_execp_panel(void *p)
{
	Panel *panel = (Panel *)p;

	// Make sure this is only done once if there are multiple items
	if (panel->execp_list && ((Execp *)panel->execp_list->data)->frontend)
		return;

	// panel->execp_list is now a copy of the pointer panel_config.execp_list
	// We make it a deep copy
	panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, NULL);

	for (GList *l = panel->execp_list; l; l = l->next) {
		Execp *execp = l->data;
		execp->area.bg = execp->backend->bg;
		execp->area.paddingx = execp->backend->paddingx;
		execp->area.paddingy = execp->backend->paddingy;
		execp->area.paddingxlr = execp->backend->paddingxlr;
		execp->area.parent = panel;
		execp->area.panel = panel;
		execp->area._dump_geometry = execp_dump_geometry;
		execp->area._compute_desired_size = execp_compute_desired_size;
		snprintf(execp->area.name,
		         sizeof(execp->area.name),
		         "Execp %s",
		         execp->backend->command ? execp->backend->command : "null");
		execp->area._draw_foreground = draw_execp;
		execp->area.size_mode = LAYOUT_FIXED;
		execp->area._resize = resize_execp;
		execp->area._get_tooltip_text = execp_get_tooltip;
		execp->area._is_under_mouse = full_width_area_is_under_mouse;
		execp->area.has_mouse_press_effect =
		    panel_config.mouse_effects &&
		    (execp->area.has_mouse_over_effect = execp->backend->lclick_command || execp->backend->mclick_command ||
		                                         execp->backend->rclick_command || execp->backend->uwheel_command ||
		                                         execp->backend->dwheel_command);

		execp->area.resize_needed = TRUE;
		execp->area.on_screen = TRUE;
		instantiate_area_gradients(&execp->area);

		if (!execp->backend->timer)
			execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer);
	}
}
static void
photos_delete_notification_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
  PhotosDeleteNotification *self = PHOTOS_DELETE_NOTIFICATION (object);

  switch (prop_id)
    {
    case PROP_ITEMS:
      {
        GList *items;

        items = (GList *) g_value_get_pointer (value);
        self->items = g_list_copy_deep (items, (GCopyFunc) g_object_ref, NULL);
        break;
      }

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Ejemplo n.º 5
0
static ClosedTab *
closed_tab_new (GQueue *closed_tabs,
		const char *address,
		GList *bflist,
		int position,
		EphyNotebook *parent_notebook)
{
	ClosedTab *tab = g_slice_new0 (ClosedTab);
	ClosedTab *sibling_tab;

	tab->url = g_strdup (address);
#ifndef HAVE_WEBKIT2
	tab->bflist = g_list_copy_deep (bflist, (GCopyFunc)webkit_web_history_item_copy, NULL);
#endif
	tab->position = position;

	sibling_tab = find_tab_with_notebook (closed_tabs, parent_notebook);
	if (sibling_tab)
		tab->parent_location = sibling_tab->parent_location;
	else
		tab->parent_location = parent_location_new (parent_notebook);

	return tab;
}
Ejemplo n.º 6
0
void
ags_midi_get_property(GObject *gobject,
		      guint prop_id,
		      GValue *value,
		      GParamSpec *param_spec)
{
  AgsMidi *midi;

  pthread_mutex_t *midi_mutex;

  midi = AGS_MIDI(gobject);

  /* get midi mutex */
  pthread_mutex_lock(ags_midi_get_class_mutex());
  
  midi_mutex = midi->obj_mutex;
  
  pthread_mutex_unlock(ags_midi_get_class_mutex());

  switch(prop_id){
  case PROP_AUDIO:
    {
      pthread_mutex_lock(midi_mutex);

      g_value_set_object(value, midi->audio);

      pthread_mutex_unlock(midi_mutex);
    }
    break;
  case PROP_AUDIO_CHANNEL:
    {
      pthread_mutex_lock(midi_mutex);

      g_value_set_uint(value, midi->audio_channel);

      pthread_mutex_unlock(midi_mutex);
    }
    break;
  case PROP_TIMESTAMP:
    {
      pthread_mutex_lock(midi_mutex);

      g_value_set_object(value, midi->timestamp);

      pthread_mutex_unlock(midi_mutex);
    }
    break;
  case PROP_TRACK:
    {
      pthread_mutex_lock(midi_mutex);

      g_value_set_pointer(value, g_list_copy_deep(midi->track,
						  (GCopyFunc) g_object_ref,
						  NULL));

      pthread_mutex_unlock(midi_mutex);
    }
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
    break;
  }
}
Ejemplo n.º 7
0
void
ags_pulse_client_get_property(GObject *gobject,
			      guint prop_id,
			      GValue *value,
			      GParamSpec *param_spec)
{
  AgsPulseClient *pulse_client;

  pthread_mutex_t *pulse_client_mutex;

  pulse_client = AGS_PULSE_CLIENT(gobject);

  /* get pulse client mutex */
  pthread_mutex_lock(ags_pulse_client_get_class_mutex());
  
  pulse_client_mutex = pulse_client->obj_mutex;
  
  pthread_mutex_unlock(ags_pulse_client_get_class_mutex());
  
  switch(prop_id){
  case PROP_PULSE_SERVER:
    {
      pthread_mutex_lock(pulse_client_mutex);

      g_value_set_object(value, pulse_client->pulse_server);

      pthread_mutex_unlock(pulse_client_mutex);
    }
    break;
  case PROP_CLIENT_NAME:
    {
      pthread_mutex_lock(pulse_client_mutex);

      g_value_set_string(value, pulse_client->client_name);

      pthread_mutex_unlock(pulse_client_mutex);
    }
    break;
  case PROP_DEVICE:
    {
      pthread_mutex_lock(pulse_client_mutex);

      g_value_set_pointer(value,
			  g_list_copy_deep(pulse_client->device,
					   (GCopyFunc) g_object_ref,
					   NULL));

      pthread_mutex_unlock(pulse_client_mutex);
    }
    break;
  case PROP_PORT:
    {
      pthread_mutex_lock(pulse_client_mutex);

      g_value_set_pointer(value,
			  g_list_copy_deep(pulse_client->port,
					   (GCopyFunc) g_object_ref,
					   NULL));

      pthread_mutex_unlock(pulse_client_mutex);
    }
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
    break;
  }
}
Ejemplo n.º 8
0
/**
 * g_list_copy:
 * @list: a #GList, this must point to the top of the list
 *
 * Copies a #GList.
 *
 * Note that this is a "shallow" copy. If the list elements
 * consist of pointers to data, the pointers are copied but
 * the actual data is not. See g_list_copy_deep() if you need
 * to copy the data as well.
 *
 * Returns: the start of the new list that holds the same data as @list
 */
GList *
g_list_copy (GList *list)
{
  return g_list_copy_deep (list, NULL, NULL);
}
Ejemplo n.º 9
0
/**
 * Process the file that is not already in our local cache
 * @param main_struct : main structure of the program
 * @param meta is the meta data of the file to be processed (it does
 *             not contain any hashs at that point).
 */
static void process_big_file_not_in_cache(main_struct_t *main_struct, meta_data_t *meta)
{
    GFile *a_file = NULL;
    gchar *answer = NULL;
    GFileInputStream *stream = NULL;
    GError *error = NULL;
    GList *hash_data_list = NULL;
    GList *hdl_copy = NULL;
    GList *saved_list = NULL;
    hash_data_t *hash_data = NULL;
    gssize read = 0;
    guchar *buffer = NULL;
    GChecksum *checksum = NULL;
    guint8 *a_hash = NULL;
    gsize digest_len = HASH_LEN;
    gsize read_bytes = 0;
    a_clock_t *elapsed = NULL;

    if (main_struct != NULL && main_struct->opt != NULL && meta != NULL)
    {
        a_file = g_file_new_for_path(meta->name);
        print_debug(_("Processing file: %s\n"), meta->name);

        if (a_file != NULL)
        {
            stream = g_file_read(a_file, NULL, &error);

            if (stream != NULL && error == NULL)
            {

                checksum = g_checksum_new(G_CHECKSUM_SHA256);
                buffer = (guchar *) g_malloc(meta->blocksize);
                a_hash = (guint8 *) g_malloc(digest_len);

                read = g_input_stream_read((GInputStream *) stream, buffer, meta->blocksize, NULL, &error);
                read_bytes = read_bytes + read;


                while (read != 0 && error == NULL)
                {
                    g_checksum_update(checksum, buffer, read);
                    g_checksum_get_digest(checksum, a_hash, &digest_len);

                    /* Need to save 'data', 'read' and digest hash in an hash_data_t structure */
                    hash_data = new_hash_data_t(buffer, read, a_hash);
                    hash_data_list = g_list_prepend(hash_data_list, hash_data);

                    g_checksum_reset(checksum);
                    digest_len = HASH_LEN;

                    if (read_bytes >= main_struct->opt->buffersize)
                    {
                        elapsed = new_clock_t();
                        print_debug(_("Sending data: %d bytes\n"), read_bytes);
                        /* 0. Save the list in order to keep hashs for meta-data */
                        hdl_copy = g_list_copy_deep(hash_data_list, copy_only_hash, NULL);
                        saved_list = g_list_concat(hdl_copy, saved_list);

                        /* 1. Send an array of hashs to Hash_Array.json server url */
                        answer = send_hash_array_to_server(main_struct->comm, hash_data_list);

                        /* 2. Keep only hashs that are needed (answer from the server) */
                        hash_data_list = send_all_data_to_server(main_struct, hash_data_list, answer);

                        /* 3. free memory of this list if any is left */
                        g_list_free_full(hash_data_list, free_hdt_struct);
                        hash_data_list = NULL;
                        read_bytes = 0;

                        end_clock(elapsed, "process_big_file_not_in_cache");
                    }

                    buffer = (guchar *) g_malloc(meta->blocksize);
                    a_hash = (guint8 *) g_malloc(digest_len);
                    read = g_input_stream_read((GInputStream *) stream, buffer, meta->blocksize, NULL, &error);
                    read_bytes = read_bytes + read;
                }

                if (error != NULL)
                {
                    print_error(__FILE__, __LINE__, _("Error while reading file: %s\n"), error->message);
                    error = free_error(error);
                    g_list_free_full(hash_data_list, free_hdt_struct);
                    hash_data_list =  NULL;
                }
                else
                {
                    if (read_bytes > 0)
                    {
                        elapsed = new_clock_t();
                        print_debug(_("Sending data: %d bytes\n"), read_bytes);
                        /* 0. Save the list in order to keep hashs for meta-data */
                        hdl_copy = g_list_copy_deep(hash_data_list, copy_only_hash, NULL);
                        saved_list = g_list_concat(hdl_copy, saved_list);

                        /* 1. Send an array of hashs to Hash_Array.json server url */
                        answer = send_hash_array_to_server(main_struct->comm, hash_data_list);

                        /* 2. Keep only hashs that are needed (answer from the server) */
                        hash_data_list = send_all_data_to_server(main_struct, hash_data_list, answer);

                        /* 3. free memory of this list if any is left */
                        g_list_free_full(hash_data_list, free_hdt_struct);
                        hash_data_list = NULL;
                        read_bytes = 0;

                        end_clock(elapsed, "process_big_file_not_in_cache");
                    }

                    /* get the list in correct order (because we prepended the hashs to get speed when inserting hashs in the list) */
                    saved_list = g_list_reverse(saved_list);
                }

                free_variable(buffer);
                free_variable(a_hash);
                g_checksum_free(checksum);
                g_input_stream_close((GInputStream *) stream, NULL, NULL);
                free_object(stream);
            }
            else
            {
                print_error(__FILE__, __LINE__, _("Unable to open file for reading: %s\n"), error->message);
                error = free_error(error);
            }

            meta->hash_data_list = saved_list;
            answer = send_meta_data_to_server(main_struct, meta, TRUE);

            if (answer != NULL)
            {   /** @todo may be we should check that answer is something that tells that everything went Ok. */
                /* Everything has been transmitted so we can save meta data into the local db cache */
                /* This is usefull for file carving to avoid sending too much things to the server  */
                elapsed = new_clock_t();
                db_save_meta_data(main_struct->database, meta, TRUE);
                end_clock(elapsed, "db_save_meta_data");
            }

            a_file = free_object(a_file);
        }
    }
}
Ejemplo n.º 10
0
void
ags_recycling_context_get_property(GObject *gobject,
				   guint prop_id,
				   GValue *value,
				   GParamSpec *param_spec)
{
  AgsRecyclingContext *recycling_context;

  pthread_mutex_t *recycling_context_mutex;

  recycling_context = AGS_RECYCLING_CONTEXT(gobject);

  /* get recycling context mutex */
  pthread_mutex_lock(ags_recycling_context_get_class_mutex());
  
  recycling_context_mutex = recycling_context->obj_mutex;
  
  pthread_mutex_unlock(ags_recycling_context_get_class_mutex());

  switch(prop_id){
  case PROP_RECALL_ID:
    {
      pthread_mutex_lock(recycling_context_mutex);
      
      g_value_set_object(value, recycling_context->recall_id);

      pthread_mutex_unlock(recycling_context_mutex);
    }
    break;
  case PROP_PARENT:
    {
      pthread_mutex_lock(recycling_context_mutex);
      
      g_value_set_object(value, recycling_context->parent);

      pthread_mutex_unlock(recycling_context_mutex);
    }
    break;
  case PROP_CHILD:
    {
      pthread_mutex_lock(recycling_context_mutex);
      
      g_value_set_pointer(value, g_list_copy_deep(recycling_context->children,
						  (GCopyFunc) g_object_ref,
						  NULL));

      pthread_mutex_unlock(recycling_context_mutex);
    }
    break;
  case PROP_LENGTH:
    {
      pthread_mutex_lock(recycling_context_mutex);
      
      g_value_set_uint64(value, recycling_context->length);

      pthread_mutex_unlock(recycling_context_mutex);
    }
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
    break;
  }
}
Ejemplo n.º 11
0
static GList *
facebook_image_list_copy (GList *source)
{
    return g_list_copy_deep (source, (GCopyFunc) facebook_image_copy, NULL);
}
Ejemplo n.º 12
-1
void
gtk_source_completion_model_set_visible_providers (GtkSourceCompletionModel *model,
                                                   GList                    *providers)
{
	GList *l;

	g_return_if_fail (GTK_SOURCE_IS_COMPLETION_MODEL (model));

	for (l = providers; l != NULL; l = l->next)
	{
		g_return_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (l->data));
	}

	g_list_free_full (model->priv->visible_providers, g_object_unref);

	model->priv->visible_providers = g_list_copy_deep (providers,
							   provider_copy_func,
							   NULL);

	for (l = model->priv->providers; l != NULL; l = l->next)
	{
		ProviderInfo *provider_info = l->data;
		provider_info->visible = is_provider_visible (model, provider_info->completion_provider);
	}
}
Ejemplo n.º 13
-1
static void callback_merger(GList *list, CallbackMergeContext *context)
{
    g_mutex_lock(&context->mutex);
    context->list = g_list_concat(context->list,
        g_list_copy_deep (list, context->item_copy, context));
    g_mutex_unlock(&context->mutex);
}
Ejemplo n.º 14
-1
void
http_dd_set_headers(LogDriver *d, GList *headers)
{
  HTTPDestinationDriver *self = (HTTPDestinationDriver *) d;

  g_list_free_full(self->headers, g_free);
  self->headers = g_list_copy_deep(headers, ((GCopyFunc)g_strdup), NULL);
}
Ejemplo n.º 15
-1
static GList *
get_volumes (GVolumeMonitor *volume_monitor)
{
  GUnixVolumeMonitor *monitor;
  
  monitor = G_UNIX_VOLUME_MONITOR (volume_monitor);

  return g_list_copy_deep (monitor->volumes, (GCopyFunc) g_object_ref, NULL);
}
Ejemplo n.º 16
-1
GList *
gst_validate_runner_get_reports (GstValidateRunner * runner)
{
  GList *ret;

  GST_VALIDATE_RUNNER_LOCK (runner);
  ret =
      g_list_copy_deep (runner->priv->reports,
      (GCopyFunc) gst_validate_report_ref, NULL);
  GST_VALIDATE_RUNNER_UNLOCK (runner);

  return ret;
}
Ejemplo n.º 17
-1
GList *
kms_sdp_group_manager_get_groups (KmsSdpGroupManager * obj)
{
  GList *groups, *ret = NULL;

  g_return_val_if_fail (KMS_IS_SDP_GROUP_MANAGER (obj), NULL);

  groups = g_hash_table_get_values (obj->priv->groups);
  ret = g_list_copy_deep (groups, (GCopyFunc) g_object_ref, NULL);
  g_list_free (groups);

  return ret;
}
Ejemplo n.º 18
-1
/**
 * gssdp_resource_group_add_resource:
 * @resource_group: A #GSSDPResourceGroup
 * @target: The resource's target
 * @usn: The resource's USN
 * @locations: (element-type utf8): A #GList of the resource's locations
 *
 * Adds a resource with target @target, USN @usn, and locations @locations
 * to @resource_group.
 *
 * Return value: The ID of the added resource.
 **/
guint
gssdp_resource_group_add_resource (GSSDPResourceGroup *resource_group,
                                   const char         *target,
                                   const char         *usn,
                                   GList              *locations)
{
        GSSDPResourceGroupPrivate *priv = NULL;
        Resource *resource = NULL;
        GError *error = NULL;

        g_return_val_if_fail (GSSDP_IS_RESOURCE_GROUP (resource_group), 0);
        g_return_val_if_fail (target != NULL, 0);
        g_return_val_if_fail (usn != NULL, 0);
        g_return_val_if_fail (locations != NULL, 0);

        priv = gssdp_resource_group_get_instance_private (resource_group);

        resource = g_slice_new0 (Resource);

        resource->resource_group = resource_group;

        resource->target = g_strdup (target);
        resource->usn    = g_strdup (usn);

        resource->target_regex = create_target_regex (target,
                                                      &resource->version,
                                                      &error);
        if (error) {
                g_warning ("Error compiling regular expression for '%s': %s",
                           target,
                           error->message);

                g_error_free (error);
                resource_free (resource);

                return 0;
        }

        resource->initial_byebye_sent = FALSE;

        resource->locations = g_list_copy_deep (locations, (GCopyFunc) g_strdup, NULL);

        priv->resources = g_list_prepend (priv->resources, resource);

        resource->id = ++priv->last_resource_id;

        if (priv->available)
                resource_alive (resource);

        return resource->id;
}
static void
photos_fetch_collection_state_job_job_collector (GList *collections_for_item, gpointer user_data)
{
  PhotosFetchCollectionStateJobData *data = user_data;
  PhotosFetchCollectionStateJob *self = data->job;
  const gchar *urn = data->urn;

  g_hash_table_insert (self->collections_for_items,
                       g_strdup (urn),
                       g_list_copy_deep (collections_for_item, (GCopyFunc) g_strdup, NULL));

  self->running_jobs--;
  if (self->running_jobs == 0)
    photos_fetch_collection_state_job_emit_callback (self);

  photos_fetch_collection_state_job_data_free (data);
}
Ejemplo n.º 20
-1
void
ags_recall_dssi_run_get_property(GObject *gobject,
				 guint prop_id,
				 GValue *value,
				 GParamSpec *param_spec)
{
  AgsRecallDssiRun *recall_dssi_run;
  
  pthread_mutex_t *recall_mutex;

  recall_dssi_run = AGS_RECALL_DSSI_RUN(gobject);

  /* get recall mutex */
  pthread_mutex_lock(ags_recall_get_class_mutex());
  
  recall_mutex = AGS_RECALL(gobject)->obj_mutex;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  switch(prop_id){
  case PROP_ROUTE_DSSI_AUDIO_RUN:
    {
      pthread_mutex_lock(recall_mutex);

      g_value_set_object(value, recall_dssi_run->route_dssi_audio_run);

      pthread_mutex_unlock(recall_mutex);
    }
    break;
  case PROP_NOTE:
    {
      pthread_mutex_lock(recall_mutex);

      g_value_set_pointer(value,
			  g_list_copy_deep(recall_dssi_run->note,
					   (GCopyFunc) g_object_ref,
					   NULL));

      pthread_mutex_unlock(recall_mutex);
    }
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
    break;
  };
}