コード例 #1
0
static GstStateChangeReturn
gst_xvidenc_change_state (GstElement * element, GstStateChange transition)
{
  GstXvidEnc *xvidenc = GST_XVIDENC (element);
  GstStateChangeReturn ret;

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      if (!gst_xvid_init ())
        return GST_STATE_CHANGE_FAILURE;
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      xvidenc->delay = g_queue_new ();
      break;
    default:
      break;
  }


  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
  if (ret == GST_STATE_CHANGE_FAILURE)
    goto done;

  switch (transition) {
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      if (xvidenc->handle) {
        gst_xvidenc_flush_buffers (xvidenc, FALSE);
        xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
        xvidenc->handle = NULL;
      }
      g_queue_free (xvidenc->delay);
      xvidenc->delay = NULL;
      g_free (xvidenc->xframe_cache);
      xvidenc->xframe_cache = NULL;
      break;
    default:
      break;
  }

done:
  return ret;
}
コード例 #2
0
static void
send_receive_menu_service_added_cb (EMailAccountStore *account_store,
                                    CamelService *service,
                                    SendReceiveData *data)
{
	GQueue *services;

	if (!send_receive_can_use_service (account_store, service, NULL))
		return;

	services = g_queue_new ();

	g_queue_push_head (services, service);
	g_hash_table_foreach (data->menu_items, send_receive_gather_services, services);
	g_queue_sort (services, sort_services_cb, account_store);

	send_receive_add_to_menu (data, service, g_queue_index (services, service));

	g_queue_free (services);
}
コード例 #3
0
ファイル: ex-gqueue-5.c プロジェクト: MarkTseng/mySampleCode
int main(int argc, char** argv) {
 GQueue* q = g_queue_new();
 g_queue_push_tail(q, "Alice ");
 g_queue_push_tail(q, "Bob ");
 g_queue_push_tail(q, "Fred ");
 g_queue_push_tail(q, "Jim ");
 printf("Starting out, the queue is: ");
 g_queue_foreach(q, (GFunc)printf, NULL);
 GList* fred_link = g_queue_peek_nth_link(q, 2);
 printf("\nThe link at index 2 contains %s\n", fred_link->data);
 g_queue_unlink(q, fred_link);
 g_list_free(fred_link);
 GList* jim_link = g_queue_peek_nth_link(q, 2);
 printf("Now index 2 contains %s\n", jim_link->data);
 g_queue_delete_link(q, jim_link);
 printf("Now the queue is: ");
 g_queue_foreach(q, (GFunc)printf, NULL);
 g_queue_free(q);
 return 0;
}
コード例 #4
0
ファイル: polygon_edge_points.c プロジェクト: BIANZiyang/3PRE
GeometryTester * 
polygon_edge_points_tester_new ()
{
    PolygonEdgePointsTester * self = 
        (PolygonEdgePointsTester*) calloc (1, 
                sizeof (PolygonEdgePointsTester));

    self->parent.draw = draw;
    self->parent.mouse_press = mouse_press;
    self->parent.destroy = destroy;
    self->parent.name = "polygon edge points";

    self->poly1 = g_queue_new ();
    g_queue_push_tail (self->poly1, point2i_new (100, 100));
    g_queue_push_tail (self->poly1, point2i_new (250, 100));
    g_queue_push_tail (self->poly1, point2i_new (300, 200));
    g_queue_push_tail (self->poly1, point2i_new (100, 220));

    return (GeometryTester*) self;
}
コード例 #5
0
static GumDukDebugSession *
gum_duk_debug_session_new (GumDukDebugChannel * channel,
                           GIOStream * stream)
{
  GumDukDebugSession * session;

  session = g_slice_new (GumDukDebugSession);

  session->stream = g_object_ref (stream);
  session->input = g_io_stream_get_input_stream (stream);
  session->output = g_io_stream_get_output_stream (stream);

  session->outgoing = g_queue_new ();

  session->cancellable = g_cancellable_new ();

  session->channel = g_object_ref (channel);

  return session;
}
コード例 #6
0
ファイル: openslide-cache.c プロジェクト: Markus-PP/openslide
struct _openslide_cache *_openslide_cache_create(int capacity_in_bytes) {
  struct _openslide_cache *cache = g_slice_new0(struct _openslide_cache);

  // init mutex
  cache->mutex = g_mutex_new();

  // init queue
  cache->list = g_queue_new();

  // init hashtable
  cache->hashtable = g_hash_table_new_full(hash_func,
					   key_equal_func,
					   hash_destroy_key,
					   hash_destroy_value);

  // init byte_capacity
  cache->capacity = capacity_in_bytes;

  return cache;
}
コード例 #7
0
ファイル: gvfsafpconnection.c プロジェクト: Alustriel/gvfs
static void
g_vfs_afp_connection_init (GVfsAfpConnection *afp_connection)
{
  GVfsAfpConnectionPrivate *priv;
  
  afp_connection->priv = priv =  G_TYPE_INSTANCE_GET_PRIVATE (afp_connection,
                                                              G_VFS_TYPE_AFP_CONNECTION,
                                                              GVfsAfpConnectionPrivate);
  priv->kRequestQuanta = -1;
  priv->kServerReplayCacheSize = -1;

  g_mutex_init (&priv->mutex);

  priv->request_queue = g_queue_new ();
  priv->request_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                              NULL, (GDestroyNotify)free_request_data);
  priv->read_cancellable = g_cancellable_new ();

  priv->send_loop_running = FALSE;
}
コード例 #8
0
GnomeVFSResult
_gnome_vfs_monitor_do_add (GnomeVFSMethod *method,
			  GnomeVFSMonitorHandle **handle,
			  GnomeVFSURI *uri,
                          GnomeVFSMonitorType monitor_type,
			  GnomeVFSMonitorCallback callback,
			  gpointer user_data)
{
	GnomeVFSResult result;
	GnomeVFSMonitorHandle *monitor_handle = 
		g_new0(GnomeVFSMonitorHandle, 1);

	init_hash_table ();
	gnome_vfs_uri_ref (uri);
	monitor_handle->uri = uri;

	monitor_handle->type = monitor_type;
	monitor_handle->callback = callback;
	monitor_handle->user_data = user_data;
	monitor_handle->pending_callbacks = g_queue_new ();
	monitor_handle->min_send_at = 0;

	result = uri->method->monitor_add (uri->method, 
			&monitor_handle->method_handle, uri, monitor_type);

	if (result != GNOME_VFS_OK) {
		gnome_vfs_uri_unref (uri);
		g_free (monitor_handle);
		monitor_handle = NULL;
	} else {
		G_LOCK (handle_hash);
		g_hash_table_insert (handle_hash, 
				     monitor_handle->method_handle,
				     monitor_handle);
		G_UNLOCK (handle_hash);
	}

	*handle = monitor_handle;

	return result;
}
コード例 #9
0
ファイル: deinterlace.c プロジェクト: ted-n/gst-plugins-good
/*
 * Utility function that sets up a pipeline with deinterlace for
 * validanting that it operates in passthrough mode when receiving
 * data with 'infiltercaps' as the input caps and operating in 'mode' mode
 */
static void
deinterlace_check_passthrough (gint mode, const gchar * infiltercaps)
{
  GstMessage *msg;
  GQueue *queue;
  GstCaps *incaps = NULL;

  if (infiltercaps)
    incaps = gst_caps_from_string (infiltercaps);

  setup_test_pipeline (mode, incaps, NULL, 20);

  queue = g_queue_new ();

  /* set up probes for testing */
  gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_BUFFER, sinkpad_enqueue_buffer,
      queue, NULL);
  gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BUFFER,
      srcpad_dequeue_and_compare_buffer, queue, NULL);

  fail_unless (gst_element_set_state (pipeline, GST_STATE_PLAYING) !=
      GST_STATE_CHANGE_FAILURE);

  msg = gst_bus_poll (GST_ELEMENT_BUS (pipeline),
      GST_MESSAGE_ERROR | GST_MESSAGE_EOS, -1);
  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
    GST_ERROR ("ERROR: %" GST_PTR_FORMAT, msg);
    fail ("Unexpected error message");
  }
  gst_message_unref (msg);

  /* queue should be empty */
  fail_unless (g_queue_is_empty (queue));

  fail_unless (gst_element_set_state (pipeline, GST_STATE_NULL) ==
      GST_STATE_CHANGE_SUCCESS);
  gst_object_unref (pipeline);
  gst_object_unref (sinkpad);
  gst_object_unref (srcpad);
  g_queue_free (queue);
}
コード例 #10
0
static void
gst_hls_demux_init (GstHLSDemux * demux, GstHLSDemuxClass * klass)
{
  /* sink pad */
  demux->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
  gst_pad_set_chain_function (demux->sinkpad,
      GST_DEBUG_FUNCPTR (gst_hls_demux_chain));
  gst_pad_set_event_function (demux->sinkpad,
      GST_DEBUG_FUNCPTR (gst_hls_demux_sink_event));
  gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad);

  /* fetcher pad */
  demux->fetcherpad =
      gst_pad_new_from_static_template (&fetchertemplate, "sink");
  gst_pad_set_chain_function (demux->fetcherpad,
      GST_DEBUG_FUNCPTR (gst_hls_demux_fetcher_chain));
  gst_pad_set_event_function (demux->fetcherpad,
      GST_DEBUG_FUNCPTR (gst_hls_demux_fetcher_sink_event));
  gst_pad_set_element_private (demux->fetcherpad, demux);
  gst_pad_activate_push (demux->fetcherpad, TRUE);

  demux->do_typefind = TRUE;

  /* Properties */
  demux->fragments_cache = DEFAULT_FRAGMENTS_CACHE;
  demux->bitrate_switch_tol = DEFAULT_BITRATE_SWITCH_TOLERANCE;

  demux->download = gst_adapter_new ();
  demux->fetcher_bus = gst_bus_new ();
  gst_bus_set_sync_handler (demux->fetcher_bus,
      gst_hls_demux_fetcher_bus_handler, demux);
  demux->thread_cond = g_cond_new ();
  demux->thread_lock = g_mutex_new ();
  demux->fetcher_cond = g_cond_new ();
  demux->fetcher_lock = g_mutex_new ();
  demux->queue = g_queue_new ();
  g_static_rec_mutex_init (&demux->task_lock);
  /* FIXME: This really should be a pad task instead */
  demux->task = gst_task_create ((GstTaskFunction) gst_hls_demux_loop, demux);
  gst_task_set_lock (demux->task, &demux->task_lock);
}
コード例 #11
0
ファイル: vtdec.c プロジェクト: cbetz421/gst-plugins-bad
static GstStateChangeReturn
gst_vtdec_change_state (GstElement * element, GstStateChange transition)
{
  GstVTDec *self = GST_VTDEC_CAST (element);
  GError *error = NULL;
  GstStateChangeReturn ret;

  if (transition == GST_STATE_CHANGE_NULL_TO_READY) {
    self->ctx = gst_core_media_ctx_new (GST_API_VIDEO_TOOLBOX, &error);
    if (error != NULL)
      goto api_error;

    self->cur_outbufs = g_queue_new ();
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  if (transition == GST_STATE_CHANGE_READY_TO_NULL) {
    gst_vtdec_destroy_session (self, &self->session);

    CFRelease (self->fmt_desc);
    self->fmt_desc = NULL;

    gst_video_info_init (&self->vinfo);

    g_queue_free_full (self->cur_outbufs, (GDestroyNotify) gst_buffer_unref);

    g_object_unref (self->ctx);
    self->ctx = NULL;
  }

  return ret;

api_error:
  {
    GST_ELEMENT_ERROR (self, RESOURCE, FAILED, ("API error"),
        ("%s", error->message));
    g_clear_error (&error);
    return GST_STATE_CHANGE_FAILURE;
  }
}
コード例 #12
0
static ParserState *
parser_state_new (GtkSourceLanguage       *language,
		  GtkSourceContextData    *ctx_data,
		  GHashTable              *defined_regexes,
		  GHashTable              *styles_mapping,
		  GQueue                  *replacements,
		  xmlTextReader	          *reader,
		  const char              *filename,
		  GHashTable              *loaded_lang_ids)
{
	ParserState *parser_state;
	parser_state = g_slice_new0 (ParserState);

	parser_state->language = language;
	parser_state->ctx_data = ctx_data;

	g_return_val_if_fail (language->priv->id != NULL, NULL);
	parser_state->language_decoration = g_strdup_printf ("%s:", language->priv->id);

	parser_state->current_lang_id = NULL;

	parser_state->id_cookie = 0;
	parser_state->regex_compile_flags = 0;

	parser_state->reader = reader;
	parser_state->filename = g_filename_display_name (filename);
	parser_state->error = NULL;

	parser_state->defined_regexes = defined_regexes;
	parser_state->styles_mapping = styles_mapping;
	parser_state->replacements = replacements;

	parser_state->loaded_lang_ids = loaded_lang_ids;

	parser_state->curr_parents = g_queue_new ();

	parser_state->opening_delimiter = g_strdup ("\\b");
	parser_state->closing_delimiter = g_strdup ("\\b");

	return parser_state;
}
コード例 #13
0
ファイル: gstappsrc.c プロジェクト: zsx/ossbuild
static void
gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass)
{
  appsrc->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsrc, GST_TYPE_APP_SRC,
      GstAppSrcPrivate);

  appsrc->priv->mutex = g_mutex_new ();
  appsrc->priv->cond = g_cond_new ();
  appsrc->priv->queue = g_queue_new ();

  appsrc->priv->size = DEFAULT_PROP_SIZE;
  appsrc->priv->stream_type = DEFAULT_PROP_STREAM_TYPE;
  appsrc->priv->max_bytes = DEFAULT_PROP_MAX_BYTES;
  appsrc->priv->format = DEFAULT_PROP_FORMAT;
  appsrc->priv->block = DEFAULT_PROP_BLOCK;
  appsrc->priv->min_latency = DEFAULT_PROP_MIN_LATENCY;
  appsrc->priv->max_latency = DEFAULT_PROP_MAX_LATENCY;
  appsrc->priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;

  gst_base_src_set_live (GST_BASE_SRC (appsrc), DEFAULT_PROP_IS_LIVE);
}
コード例 #14
0
static GQueue* _torflowslice_getCandidates(TorFlowSlice* slice, GHashTable* table) {
    g_assert(slice);
    g_assert(table);

    /* first get the minimum number of probes that we have for any relay */
    guint minProbes = 0;
    g_hash_table_foreach(table, (GHFunc)_torflowslice_computeMinProbes, &minProbes);

    /* now collect all relays that have the same minimum value */
    GQueue* candidates = g_queue_new();

    GHashTableIter iter;
    gpointer key, value;
    g_hash_table_iter_init(&iter, table);
    while(g_hash_table_iter_next(&iter, &key, &value)) {
        /* the key is the gchar* relay identity */
        g_queue_push_tail(candidates, key);
    }

    return candidates;
}
コード例 #15
0
ファイル: cl_log.c プロジェクト: sipwise/heartbeat
CircularBuffer_t *
NewCircularBuffer(const char *name, uint size, gboolean empty_after_dump)
{
	CircularBuffer_t *buffer = cl_malloc(sizeof(CircularBuffer_t));
	if (!buffer) {
		return buffer;
	}
	buffer->name = name;
	buffer->size = size;
	buffer->empty_after_dump = empty_after_dump;
	buffer->queue = g_queue_new();

#if 1
	if(empty_after_dump == FALSE) {
		cl_log(LOG_ERR, "This requires glib 2.4");
		empty_after_dump = TRUE;
	}
#endif

	return buffer;
}
コード例 #16
0
static void
skypeweb_login(PurpleAccount *account)
{
	PurpleConnection *pc = purple_account_get_connection(account);
	SkypeWebAccount *sa = g_new0(SkypeWebAccount, 1);
	PurpleConnectionFlags flags;
	
	purple_connection_set_protocol_data(pc, sa);
	
	if (!purple_ssl_is_supported()) {
		purple_connection_error (pc,
								PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
								_("Server requires TLS/SSL for login.  No TLS/SSL support found."));
		return;
	}

	flags = purple_connection_get_flags(pc);
	flags |= PURPLE_CONNECTION_FLAG_HTML | PURPLE_CONNECTION_FLAG_NO_BGCOLOR | PURPLE_CONNECTION_FLAG_NO_FONTSIZE;
	purple_connection_set_flags(pc, flags);
	
	if (!SKYPEWEB_BUDDY_IS_MSN(purple_account_get_username(account))) {
		sa->username = g_ascii_strdown(purple_account_get_username(account), -1);
	}
	sa->account = account;
	sa->pc = pc;
	sa->cookie_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
	sa->hostname_ip_cache = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
	sa->sent_messages_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
	sa->waiting_conns = g_queue_new();
	sa->messages_host = g_strdup(SKYPEWEB_DEFAULT_MESSAGES_HOST);
	
	if(strchr(purple_account_get_username(account), '@')) {
		//Has an email address for a username, probably a microsoft account?
		skypeweb_begin_oauth_login(sa);
	} else {
		skypeweb_begin_web_login(sa);
	}
	
	purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", pc, PURPLE_CALLBACK(skypeweb_mark_conv_seen), NULL);
}
コード例 #17
0
ファイル: client.c プロジェクト: azuwis/mpd
static void client_init(struct client *client, int fd)
{
    static unsigned int next_client_num;

    assert(fd >= 0);

    client->cmd_list_size = 0;
    client->cmd_list_OK = -1;

#ifndef G_OS_WIN32
    client->channel = g_io_channel_unix_new(fd);
#else
    client->channel = g_io_channel_win32_new_socket(fd);
#endif
    /* GLib is responsible for closing the file descriptor */
    g_io_channel_set_close_on_unref(client->channel, true);
    /* NULL encoding means the stream is binary safe; the MPD
       protocol is UTF-8 only, but we are doing this call anyway
       to prevent GLib from messing around with the stream */
    g_io_channel_set_encoding(client->channel, NULL, NULL);
    /* we prefer to do buffering */
    g_io_channel_set_buffered(client->channel, false);

    client->source_id = g_io_add_watch(client->channel,
                                       G_IO_IN|G_IO_ERR|G_IO_HUP,
                                       client_in_event, client);

    client->input = fifo_buffer_new(4096);

    client->lastTime = time(NULL);
    client->cmd_list = NULL;
    client->deferred_send = g_queue_new();
    client->deferred_bytes = 0;
    client->num = next_client_num++;
    client->send_buf_used = 0;

    client->permission = getDefaultPermissions();

    (void)write(fd, GREETING, sizeof(GREETING) - 1);
}
コード例 #18
0
ファイル: cockpitchannel.c プロジェクト: maxamillion/cockpit
static gboolean
on_transport_recv (CockpitTransport *transport,
                   const gchar *channel_id,
                   GBytes *data,
                   gpointer user_data)
{
  CockpitChannel *self = user_data;
  CockpitChannelClass *klass;
  GBytes *decoded = NULL;

  if (g_strcmp0 (channel_id, self->priv->id) != 0)
    return FALSE;

  if (self->priv->received_done)
    {
      g_warning ("%s: channel received message after done", self->priv->id);
      cockpit_channel_close (self, "protocol-error");
      return TRUE;
    }

  if (self->priv->ready)
    {
      if (self->priv->base64_encoding)
        data = decoded = base64_decode (data);
      klass = COCKPIT_CHANNEL_GET_CLASS (self);
      g_assert (klass->recv);
      (klass->recv) (self, data);
    }
  else
    {
      if (!self->priv->received)
        self->priv->received = g_queue_new ();
      g_queue_push_tail (self->priv->received, g_bytes_ref (data));
    }

  if (decoded)
    g_bytes_unref (decoded);

  return TRUE;
}
コード例 #19
0
ファイル: call-common.c プロジェクト: shr-project/shr
int
call_common_active_call_add(struct CallActiveViewData *win)
{
	/* if it's not the first call, update all the windows */
	if (active_calls_list) {
		g_queue_foreach(active_calls_list, _foreach_new_active,
				(void *) -1);
	}
	/*init */
	/* if first, init state */
	else {
		call_common_set_sound_state(CALL_SOUND_STATE_INIT);
		g_debug("Initialized active calls list");
		active_calls_list = g_queue_new();
	}

	g_queue_push_head(active_calls_list, win);
	g_debug("%s:%d adding a call to active list (id=%d)", __FILE__,
		__LINE__, win->parent.id);

	return 0;
}
コード例 #20
0
ファイル: sms.c プロジェクト: AndriusA/ofono
/*
 * Create a SMS driver
 *
 * This creates a SMS driver that is hung off a @modem
 * object. However, for the driver to be used by the system, it has to
 * be registered with the oFono core using ofono_sms_register().
 *
 * This is done once the modem driver determines that SMS is properly
 * supported by the hardware.
 */
struct ofono_sms *ofono_sms_create(struct ofono_modem *modem,
					unsigned int vendor,
					const char *driver,
					void *data)
{
	struct ofono_sms *sms;
	GSList *l;

	if (driver == NULL)
		return NULL;

	sms = g_try_new0(struct ofono_sms, 1);

	if (sms == NULL)
		return NULL;

	sms->sca.type = 129;
	sms->ref = 1;
	sms->txq = g_queue_new();
	sms->messages = g_hash_table_new(uuid_hash, uuid_equal);

	sms->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_SMS,
						sms_remove, sms);

	for (l = g_drivers; l; l = l->next) {
		const struct ofono_sms_driver *drv = l->data;

		if (g_strcmp0(drv->name, driver))
			continue;

		if (drv->probe(sms, vendor, data) < 0)
			continue;

		sms->driver = drv;
		break;
	}

	return sms;
}
コード例 #21
0
ファイル: video-timer.c プロジェクト: BoozzyAmdJin/gtk-
int
main(int argc, char **argv)
{
  GError *error = NULL;
  GdkFrameClock *frame_clock;

  if (!gtk_init_with_args (&argc, &argv, "",
                           options, NULL, &error))
    {
      g_printerr ("Option parsing failed: %s\n", error->message);
      return 1;
    }

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_app_paintable (window, TRUE);
  gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);

  g_signal_connect (window, "draw",
                    G_CALLBACK (on_window_draw), NULL);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show (window);

  frame_queue = g_queue_new ();
  g_mutex_init (&frame_mutex);
  g_cond_init (&frame_cond);

  g_thread_new ("Create Frames", create_frames_thread, NULL);

  frame_clock = gtk_widget_get_frame_clock (window);
  g_signal_connect (frame_clock, "update",
                    G_CALLBACK (on_update), NULL);
  gdk_frame_clock_begin_updating (frame_clock);

  gtk_main ();

  return 0;
}
コード例 #22
0
ファイル: shd-process.c プロジェクト: Javex/shadow
gboolean process_addAtExitCallback(Process* proc, gpointer userCallback, gpointer userArgument,
        gboolean shouldPassArgument) {
    MAGIC_ASSERT(proc);
    if(!process_isRunning(proc)) {
        return FALSE;
    }

    if(userCallback) {
        ProcessExitCallbackData* exitCallback = g_new0(ProcessExitCallbackData, 1);
        exitCallback->callback = userCallback;
        exitCallback->argument = userArgument;
        exitCallback->passArgument = shouldPassArgument;

        if(!proc->atExitFunctions) {
            proc->atExitFunctions = g_queue_new();
        }

        g_queue_push_head(proc->atExitFunctions, exitCallback);
    }

    return TRUE;
}
コード例 #23
0
ファイル: http_put.c プロジェクト: carriercomm/oio-sds
struct http_put_s *
http_put_create(gint64 content_length, gint64 soft_length)
{
	/* sanity checks */
	if (soft_length < 0 && content_length >= 0)
		soft_length = content_length;
	if (soft_length >= 0 && content_length >= 0) {
		if (soft_length != content_length)
			return NULL;
	}

	struct http_put_s *p = g_try_malloc0(sizeof(struct http_put_s));
	p->dests = NULL;
	p->mhandle = curl_multi_init();
	p->buffer_tail = g_queue_new();
	p->timeout_cnx = 60;
	p->timeout_op = 60;
	p->content_length = content_length;
	p->remaining_length = p->soft_length = soft_length;
	p->state = HTTP_WHOLE_BEGIN;
	return p;
}
コード例 #24
0
ファイル: worm.c プロジェクト: gfunkmonk2/mate-games
static void
gnibbles_worm_queue_keypress (GnibblesWorm * worm, guint dir)
{
  key_queue_entry *entry;
  int n = worm->number;

  if (key_queue[n] == NULL)
    key_queue[n] = g_queue_new ();

  /* Ignore duplicates in normal movement mode. This resolves the
   * key repeat issue. We ignore this in relative mode because then
   * you do want two keys that are the same in quick succession. */
  if ((!properties->wormprops[worm->number]->relmove) &&
      (!g_queue_is_empty (key_queue[n])) &&
      (dir == ((key_queue_entry *) g_queue_peek_tail (key_queue[n]))->dir))
    return;

  entry = g_new (key_queue_entry, 1);
  entry->worm = worm;
  entry->dir = dir;
  g_queue_push_tail (key_queue[n], (gpointer) entry);
}
コード例 #25
0
static void
gst_mio_video_src_init (GstMIOVideoSrc * self, GstMIOVideoSrcClass * gclass)
{
  GstBaseSrc *base_src = GST_BASE_SRC_CAST (self);
  guint64 host_freq;

  gst_base_src_set_live (base_src, TRUE);
  gst_base_src_set_format (base_src, GST_FORMAT_TIME);

  host_freq = gst_gdouble_to_guint64 (CVGetHostClockFrequency ());
  if (host_freq <= GST_SECOND) {
    self->cv_ratio_n = GST_SECOND / host_freq;
    self->cv_ratio_d = 1;
  } else {
    self->cv_ratio_n = 1;
    self->cv_ratio_d = host_freq / GST_SECOND;
  }

  self->queue = g_queue_new ();
  self->qlock = g_mutex_new ();
  self->qcond = g_cond_new ();
}
コード例 #26
0
ファイル: size-sched.c プロジェクト: nichtdu/seafile
SizeScheduler *
size_scheduler_new (SeafileSession *session)
{
    SizeScheduler *sched = g_new0 (SizeScheduler, 1);

    if (!sched)
        return NULL;

    sched->priv = g_new0 (SizeSchedulerPriv, 1);
    if (!sched->priv) {
        g_free (sched);
        return NULL;
    }

    sched->seaf = session;

    pthread_mutex_init (&sched->priv->q_lock, NULL);

    sched->priv->repo_size_job_queue = g_queue_new ();

    return sched;
}
コード例 #27
0
ファイル: main.c プロジェクト: jmenashe/diff-ext
G_MODULE_EXPORT void
thunar_extension_initialize(ThunarxProviderPlugin* plugin) {
  const gchar* mismatch;

  /* verify that the thunarx versions are compatible */
  mismatch = thunarx_check_version(THUNARX_MAJOR_VERSION, THUNARX_MINOR_VERSION, THUNARX_MICRO_VERSION);
  
  if(G_LIKELY(mismatch == NULL)) {
    g_message("Initializing xdiff-ext extension; DIFF_EXT_DATA_DIR='%s'", DIFF_EXT_DATA_DIR);
    
    {
      int n;
      char** path;
      int i;
      
      gtk_icon_theme_get_search_path(gtk_icon_theme_get_default(), &path, &n);
      
      for(i = 0; i < n; i++) {
        g_message("icon search path: '%s'", path[i]);
      }
    }
    
#ifdef ENABLE_NLS
    bindtextdomain(GETTEXT_PACKAGE, DIFF_EXT_LOCALE_DIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */

    /* register the types provided by this plugin */
    diff_ext_register_type(plugin);

    /* setup the plugin type list */
    type_list[0] = diff_ext_get_type();
    _saved = g_queue_new();

    thunarx_provider_plugin_set_resident(plugin, TRUE);
  } else {
    g_warning("Version mismatch: %s", mismatch);
  }
}
コード例 #28
0
ファイル: gailbutton.c プロジェクト: BYC/gtk
static gboolean
gail_button_do_action (AtkAction *action,
                       gint      i)
{
  GtkWidget *widget;
  GailButton *button;
  gboolean return_value = TRUE;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
  if (widget == NULL)
    /*
     * State is defunct
     */
    return FALSE;

  if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
    return FALSE;

  button = GAIL_BUTTON (action); 

  switch (i)
    {
    case 0:
    case 1:
    case 2:
      if (!button->action_queue) 
	{
	  button->action_queue = g_queue_new ();
	}
      g_queue_push_head (button->action_queue, GINT_TO_POINTER(i));
      if (!button->action_idle_handler)
	button->action_idle_handler = gdk_threads_add_idle (idle_do_action, button);
      break;
    default:
      return_value = FALSE;
      break;
    }
  return return_value; 
}
コード例 #29
0
ファイル: rut-graphable.c プロジェクト: cee1/rig
static RutTraverseVisitFlags
_rut_graphable_traverse_breadth (RutObject *graphable,
                                 RutTraverseCallback callback,
                                 void *user_data)
{
  GQueue *queue = g_queue_new ();
  int dummy;
  int current_depth = 0;
  RutTraverseVisitFlags flags = 0;

  g_queue_push_tail (queue, graphable);
  g_queue_push_tail (queue, &dummy); /* use to delimit depth changes */

  while ((graphable = g_queue_pop_head (queue)))
    {
      if (graphable == &dummy)
        {
          current_depth++;
          g_queue_push_tail (queue, &dummy);
          continue;
        }

      flags = callback (graphable, current_depth, user_data);
      if (flags & RUT_TRAVERSE_VISIT_BREAK)
        break;
      else if (!(flags & RUT_TRAVERSE_VISIT_SKIP_CHILDREN))
        {
          RutGraphableProps *props =
            rut_object_get_properties (graphable, RUT_INTERFACE_ID_GRAPHABLE);
          GList *l;
          for (l = props->children.head; l; l = l->next)
            g_queue_push_tail (queue, l->data);
        }
    }

  g_queue_free (queue);

  return flags;
}
コード例 #30
0
ファイル: network-soup.c プロジェクト: UIKit0/evolution-rss
void
rss_soup_init(void)
{
	g_print("soup init()\n");
	settings = g_settings_new(RSS_CONF_SCHEMA);

#if LIBSOUP_VERSION > 2026002 && defined(HAVE_LIBSOUP_GNOME)
#if EVOLUTION_VERSION < 30304
	if (gconf_client_get_bool (rss_gconf, GCONF_KEY_ACCEPT_COOKIES, NULL)) {
#else
	if (g_settings_get_boolean (settings, CONF_ACCEPT_COOKIES)) {
#endif
		gchar *feed_dir = rss_component_peek_base_directory();
		gchar *cookie_path = g_build_path(
					G_DIR_SEPARATOR_S,
					feed_dir,
					"rss-cookies.sqlite",
					NULL);
		gchar *moz_cookie_path = g_build_path(
						G_DIR_SEPARATOR_S,
						feed_dir,
						"mozembed-rss",
						"cookies.sqlite",
						NULL);
		g_free(feed_dir);

		rss_soup_jar =
			soup_cookie_jar_db_new (cookie_path, FALSE);

		if (!g_file_test(moz_cookie_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_SYMLINK)) {
			sync_gecko_cookies();
		}
		g_free(cookie_path);
		g_free(moz_cookie_path);
	}
#endif
	if (!rf->stqueue)
		rf->stqueue = g_queue_new();
}