Exemple #1
0
void
ghid_cancel_lead_user (void)
{
  render_priv *priv = gport->render_priv;

  if (priv->lead_user_timeout)
    g_source_remove (priv->lead_user_timeout);

  if (priv->lead_user_timer)
    g_timer_destroy (priv->lead_user_timer);

  if (priv->lead_user)
    ghid_invalidate_all ();

  priv->lead_user_timeout = 0;
  priv->lead_user_timer = NULL;
  priv->lead_user = false;
}
Exemple #2
0
void
title_bar_update_virtual(void)
{
    ProfWin *window = wins_get_current();
    if (window->type != WIN_CONSOLE) {
        if (typing_elapsed) {
            gdouble seconds = g_timer_elapsed(typing_elapsed, NULL);

            if (seconds >= 10) {
                typing = FALSE;

                g_timer_destroy(typing_elapsed);
                typing_elapsed = NULL;
            }
        }
    }
    _title_bar_draw();
}
Exemple #3
0
int fpi_img_detect_minutiae(struct fp_img *img)
{
	struct fp_minutiae *minutiae;
	int r;
	int *direction_map, *low_contrast_map, *low_flow_map;
	int *high_curve_map, *quality_map;
	int map_w, map_h;
	unsigned char *bdata;
	int bw, bh, bd;
	GTimer *timer;

	if (img->flags & FP_IMG_STANDARDIZATION_FLAGS) {
		fp_err("cant detect minutiae for non-standardized image");
		return -EINVAL;
	}

	/* Remove perimeter points from partial image */
	g_lfsparms_V2.remove_perimeter_pts = img->flags & FP_IMG_PARTIAL ? TRUE : FALSE;

	/* 25.4 mm per inch */
	timer = g_timer_new();
	r = get_minutiae(&minutiae, &quality_map, &direction_map,
                         &low_contrast_map, &low_flow_map, &high_curve_map,
                         &map_w, &map_h, &bdata, &bw, &bh, &bd,
                         img->data, img->width, img->height, 8,
						 DEFAULT_PPI / (double)25.4, &g_lfsparms_V2);
	g_timer_stop(timer);
	fp_dbg("minutiae scan completed in %f secs", g_timer_elapsed(timer, NULL));
	g_timer_destroy(timer);
	if (r) {
		fp_err("get minutiae failed, code %d", r);
		return r;
	}
	fp_dbg("detected %d minutiae", minutiae->num);
	img->minutiae = minutiae;
	img->binarized = bdata;

	free(quality_map);
	free(direction_map);
	free(low_contrast_map);
	free(low_flow_map);
	free(high_curve_map);
	return minutiae->num;
}
int
main (int argc, char *argv[])
{
	GnomePnpIds *ids;
	guint i;

	g_type_init ();

	ids = gnome_pnp_ids_new ();

	if (argc == 2 &&
	    g_str_equal (argv[1], "--timed")) {
		GTimer *timer;
		gdouble elapsed;

		timer = g_timer_new ();

		for (i = 0; i < NUM_ITERS; i++) {
			char *vendor;
			vendor = gnome_pnp_ids_get_pnp_id (ids, "ZZZ");
			g_free (vendor);
		}

		elapsed = g_timer_elapsed (timer, NULL);
		g_timer_destroy (timer);

		g_message ("%d iterations took %lf seconds", NUM_ITERS, elapsed);
		g_object_unref (ids);

		return 0;
	}


	for (i = 1; i < argc; i++)
		show_vendor (ids, argv[i]);
	if (argc < 2) {
		show_vendor (ids, "ELO");
		show_vendor (ids, "IBM");
	}

	g_object_unref (ids);
	return 0;
}
static double
do_profile_run (const ProfileRunVTable *vtable)
{
  GTimer *timer;
  int i;
  double secs;
  ServerData sd;
  void *server;

  g_printerr ("Profiling %s\n", vtable->name);
  
  sd.handled = 0;
  sd.n_clients = 0;
  sd.loop = g_main_loop_new (NULL, FALSE);
  sd.vtable = vtable;

  server = (* vtable->init_server) (&sd);
  
  for (i = 0; i < N_CLIENT_THREADS; i++)
    {
      g_thread_create (vtable->client_thread_func, (void*) vtable, FALSE, NULL);
    }

  timer = g_timer_new ();
  
  g_printerr ("Server thread %p entering main loop\n",
              g_thread_self());
  (* vtable->main_loop_run_func) (sd.loop);
  g_printerr ("Server thread %p exiting main loop\n",
              g_thread_self());

  secs = g_timer_elapsed (timer, NULL);
  g_timer_destroy (timer);

  g_printerr ("%s: %g seconds, %d round trips, %f seconds per pingpong\n",
              vtable->name, secs, sd.handled, secs/sd.handled);

  (* vtable->stop_server) (&sd, server);
  
  g_main_loop_unref (sd.loop);

  return secs;
}
Exemple #6
0
static void
launch_test (const char *binary)
{
  gboolean success = TRUE;
  GTimer *btimer = g_timer_new();
  gboolean need_restart;

  testcase_count = 0;
  if (!gtester_quiet)
    g_print ("TEST: %s... ", binary);

 retry:
  test_log_printfe ("%s<testbinary path=\"%s\">\n", sindent (log_indent), binary);
  log_indent += 2;
  g_timer_start (btimer);
  subtest_exitstatus = 0;
  success &= launch_test_binary (binary, testcase_count);
  success &= subtest_exitstatus == 0;
  need_restart = testcase_open != 0;
  if (testcase_open)
    testcase_close (0, -256, 0);
  g_timer_stop (btimer);
  test_log_printfe ("%s<duration>%.6f</duration>\n", sindent (log_indent), g_timer_elapsed (btimer, NULL));
  log_indent -= 2;
  test_log_printfe ("%s</testbinary>\n", sindent (log_indent));
  g_free (subtest_last_seed);
  subtest_last_seed = NULL;
  if (need_restart)
    {
      /* restart test binary, skipping processed test cases */
      goto retry;
    }

  /* count the inability to run a test as a failure */
  if (!success && testcase_count == 0)
    testcase_fail_count++;

  if (!gtester_quiet)
    g_print ("%s: %s\n", !success ? "FAIL" : "PASS", binary);
  g_timer_destroy (btimer);
  if (subtest_mode_fatal && !success)
    terminate();
}
Exemple #7
0
static MpdData *__magnatune_get_data_album(const char *album, gboolean exact)
{
    MpdData *list = NULL;
    char *query = NULL;
    sqlite3_stmt *stmt = NULL;
    const char *tail;
    int r = 0;
    GTimer *timer = g_timer_new();
    if(exact)
    {
        query =  sqlite3_mprintf("SELECT songs.albumname,duration,number,desc,mp3 from 'songs' " 
        "WHERE songs.albumname=%Q",album);
    }else{
        query =  sqlite3_mprintf("SELECT songs.albumname,duration,number,desc,mp3 from 'songs' "
        "WHERE songs.albumname LIKE '%%%%%q%%%%'",album);
    }
    r=sqlite3_prepare_v2(magnatune_sqlhandle, query, -1,  &stmt,  &tail);
    if(r ==SQLITE_OK) {
        while((r = sqlite3_step(stmt)) == SQLITE_ROW)
        {
            gchar *temp = gmpc_easy_download_uri_escape(sqlite3_column_text(stmt,4));
            list = mpd_new_data_struct_append(list);
            list->type = MPD_DATA_TYPE_SONG;
            list->song = mpd_newSong();
            list->song->album = g_strdup(sqlite3_column_text(stmt,0));
            list->song->artist = __magnatune_get_artist_name(list->song->album);
            list->song->genre = __magnatune_get_genre_name(list->song->album);
            list->song->title= g_strdup(sqlite3_column_text(stmt,3));
            list->song->track = g_strdup(sqlite3_column_text(stmt,2));
            list->song->time = sqlite3_column_int(stmt,1);
            list->song->file = magnatune_get_url(temp);
            g_free(temp);
        }
    }
    else{
        g_warning("Sqlite error: %s\n", tail);
    }
    sqlite3_finalize(stmt);
    sqlite3_free(query);
    g_debug("%f s elapsed getting album songs\n", g_timer_elapsed(timer,NULL));
    g_timer_destroy(timer);
    return list;
}
Exemple #8
0
G_MODULE_EXPORT
void save_to_flash_btn_clicked_cb ()
{	
	print_status ("Flash write in progress...");
	
	void wait (gulong wait_us)
	{
		gulong timer_us = 0;		
		GTimer *timer = g_timer_new ();
		g_timer_start (timer);
		while (timer_us < wait_us)
		{	
			g_timer_stop (timer);
			timer_us = g_timer_elapsed (timer, NULL);
			g_timer_continue (timer);
			gtk_main_iteration_do (FALSE);
		}
		g_timer_destroy (timer);
	}	
Exemple #9
0
void
title_bar_update_virtual(void)
{
    if (current_recipient != NULL) {

        if (typing_elapsed != NULL) {
            gdouble seconds = g_timer_elapsed(typing_elapsed, NULL);

            if (seconds >= 10) {
                typing = FALSE;

                g_timer_destroy(typing_elapsed);
                typing_elapsed = NULL;

                _title_bar_draw();
            }
        }
    }
}
Exemple #10
0
static void gtkhash_hash_file_finish(struct hash_file_s *data)
{
	if (G_UNLIKELY(g_cancellable_is_cancelled(data->cancellable))) {
		for (int i = 0; i < HASH_FUNCS_N; i++)
			if (data->funcs[i].enabled)
				gtkhash_hash_lib_stop(&data->funcs[i]);
	} else {
		for (int i = 0; i < HASH_FUNCS_N; i++)
			if (data->funcs[i].enabled)
				gtkhash_hash_lib_finish(&data->funcs[i]);
	}

	g_object_unref(data->file);
	g_free(data->buffer);
	g_timer_destroy(data->timer);
	g_thread_pool_free(data->thread_pool, true, false);

	gtkhash_hash_file_set_state(data, HASH_FILE_STATE_CALLBACK);
}
Exemple #11
0
static void
_title_bar_refresh(void)
{
    if (current_recipient != NULL) {

        if (typing_elapsed != NULL) {
            gdouble seconds = g_timer_elapsed(typing_elapsed, NULL);

            if (seconds >= 10) {
                typing = FALSE;

                g_timer_destroy(typing_elapsed);
                typing_elapsed = NULL;

                _title_bar_draw();
            }
        }
    }
}
Exemple #12
0
static void
pgd_text_get_text (GtkWidget   *button,
		   PgdTextDemo *demo)
{
	PopplerPage     *page;
	PopplerRectangle rect;
	gdouble          width, height;
	gchar           *text;
	GTimer          *timer;

	page = poppler_document_get_page (demo->doc, demo->page);
	if (!page)
		return;

	poppler_page_get_size (page, &width, &height);
	rect.x1 = rect.y1 = 0;
	rect.x2 = width;
	rect.y2 = height;

	timer = g_timer_new ();
	text = poppler_page_get_text (page, POPPLER_SELECTION_GLYPH, &rect);
	g_timer_stop (timer);

	if (text) {
		gchar *str;

		str = g_strdup_printf ("<i>got text in %.4f seconds</i>",
				       g_timer_elapsed (timer, NULL));
		gtk_label_set_markup (GTK_LABEL (demo->timer_label), str);
		g_free (str);
	} else {
		gtk_label_set_markup (GTK_LABEL (demo->timer_label), "<i>No text found</i>");
	}

	g_timer_destroy (timer);
	g_object_unref (page);

	if (text) {
		gtk_text_buffer_set_text (demo->buffer, text, strlen (text));
		g_free (text);
	}
}
int
main (int argc, char *argv[])
{
	CORBA_Environment ev;

	free (malloc (8));

	g_thread_init (NULL);

	CORBA_exception_init (&ev);

	timer = g_timer_new ();
	g_timer_start (timer);

	g_timer_reset (timer);
	orb = CORBA_ORB_init (&argc, argv, "matecorba-local-orb", &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);
	fprintf (stderr, "ORB: init took %g(ms)\n",
		 (elapsed_time = g_timer_elapsed (timer, NULL)) * 1000.0);
	bogomark += elapsed_time;

	test_copy ();

	test_activation ();

	g_timer_reset (timer);
	CORBA_ORB_destroy (orb, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);
	fprintf (stderr, "ORB: destroy took %g(ms)\n",
		 (elapsed_time = g_timer_elapsed (timer, NULL)) * 1000.0);
	bogomark += elapsed_time;
	g_timer_reset (timer);

	CORBA_Object_release ((CORBA_Object) orb, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);

	g_timer_destroy (timer);

	fprintf (stderr, "Overall bogomark %g\n", 1000.0 / bogomark);

	return 0;
}
Exemple #14
0
void fm_progress_display_destroy (FmProgressDisplay *data)
{
    if (data->job)
    {
        fm_job_cancel (FM_JOB (data->job));

        g_signal_handlers_disconnect_by_func (data->job, on_ask, data);
        g_signal_handlers_disconnect_by_func (data->job, on_ask_rename, data);
        g_signal_handlers_disconnect_by_func (data->job, on_error, data);
        g_signal_handlers_disconnect_by_func (data->job, on_cur_file, data);
        g_signal_handlers_disconnect_by_func (data->job, on_percent, data);
        g_signal_handlers_disconnect_by_func (data->job, on_finished, data);

        g_object_unref (data->job);

        if (data->timer)
            g_timer_destroy (data->timer);
    }

    if (data->parent)
    {
        g_signal_handlers_disconnect_by_func (data->parent, on_parent_destroy, data);
        g_object_unref (data->parent);
    }

    g_free (data->cur_file);

    if (data->delay_timeout)
        g_source_remove (data->delay_timeout);

    if (data->update_timeout)
        g_source_remove (data->update_timeout);

    if (data->dlg)
    {
        g_object_unref (data->error_buf);
        g_object_unref (data->bold_tag);
        gtk_widget_destroy (data->dlg);
    }

    g_slice_free (FmProgressDisplay, data);
}
Exemple #15
0
static void
touch_mem (guint64 block_size,
           guint64 n_blocks,
           guint64 repeats)
{
  guint64 j, accu, n = n_blocks;
  GTimer *timer;
  guint **memc;
  guint **memb;
  guint **mema = g_new (guint*, n);
  for (j = 0; j < n; j++)
    mema[j] = g_slice_alloc (block_size);
  memb = g_new (guint*, n);
  for (j = 0; j < n; j++)
    memb[j] = g_slice_alloc (block_size);
  memc = g_new (guint*, n);
  for (j = 0; j < n; j++)
    memc[j] = g_slice_alloc (block_size);

  timer = g_timer_new();
  fill_memory (mema, n, 2);
  fill_memory (memb, n, 3);
  fill_memory (memc, n, 4);
  access_memory3 (mema, memb, memc, n, 3);
  g_timer_start (timer);
  accu = access_memory3 (mema, memb, memc, n, repeats);
  g_timer_stop (timer);

  g_print ("Access-time = %fs\n", g_timer_elapsed (timer, NULL));
  g_assert (accu / repeats == (2 + 3) * n / 2 + 4 * n / 2);

  for (j = 0; j < n; j++)
    {
      g_slice_free1 (block_size, mema[j]);
      g_slice_free1 (block_size, memb[j]);
      g_slice_free1 (block_size, memc[j]);
    }
  g_timer_destroy (timer);
  g_free (mema);
  g_free (memb);
  g_free (memc);
}
Exemple #16
0
void test7()
{
    sc_uint32 i, j;
    sc_addr addr, addr1, addr2;
    sc_addr new_addr;
    sc_event *event1, *event2, *event3, *event4;

    printf("Segments count: %d\n", sc_storage_get_segments_count());
    print_storage_statistics();

    timer = g_timer_new();

    g_timer_reset(timer);
    g_timer_start(timer);

    addr = sc_storage_node_new(0);
    addr1 = sc_storage_node_new(0);
    printf("Register events\n");
    event1 = sc_event_new(addr, SC_EVENT_ADD_OUTPUT_ARC, 0, &event_callback, 0);
    event2 = sc_event_new(addr1, SC_EVENT_ADD_INPUT_ARC, 1, &event_callback, 0);
    event3 = sc_event_new(addr, SC_EVENT_REMOVE_OUTPUT_ARC, 2, &event_callback, 0);
    event4 = sc_event_new(addr1, SC_EVENT_REMOVE_INPUT_ARC, 3, &event_callback, 0);

    addr2 = sc_storage_arc_new(0, addr, addr1);
    sc_storage_element_free(addr2);

    printf("Unregister events\n");
    sc_event_destroy(event1);
    sc_event_destroy(event2);
    sc_event_destroy(event3);
    sc_event_destroy(event4);

    addr2 = sc_storage_arc_new(0, addr, addr1);
    sc_storage_element_free(addr2);

    g_timer_stop(timer);

    printf("Segments count: %d\n", sc_storage_get_segments_count());
    print_storage_statistics();

    g_timer_destroy(timer);
}
static void _midgard_connection_finalize(GObject *object)
{
	g_assert(object != NULL);
	MidgardConnection *self = (MidgardConnection *) object;

	if (self->err != NULL)
		g_clear_error(&self->err);

	if (self->errstr != NULL) {
		g_free(self->errstr);
		self->errstr = NULL;
	}

	if (self->priv->authstack) {
		g_slist_free(self->priv->authstack);
		self->priv->authstack = NULL;
	}

	g_free ((gchar *)self->priv->cnc_str);
	self->priv->cnc_str = NULL;

	g_timer_stop(self->priv->timer);
	//gdouble bench = g_timer_elapsed(self->priv->timer, NULL);

	if (self->priv->loghandler) {
		/* uptime message disable for a while */
		/* g_message("MidgardConnection uptime %.04f seconds", bench); */
		g_log_remove_handler(G_LOG_DOMAIN, self->priv->loghandler);
	}

	g_timer_destroy(self->priv->timer);

	if (!self->priv->inherited) {
		if (self->priv->config && G_IS_OBJECT (self->priv->config)) {
			g_object_unref(self->priv->config);
			self->priv->config = NULL;
		}
	}

	g_free(self->priv);
	self->priv = NULL;
}
Exemple #18
0
void
splash_destroy (void)
{
  if (! splash)
    return;

  gtk_widget_destroy (splash->window);

  g_object_unref (splash->upper);
  g_object_unref (splash->lower);

#ifdef STARTUP_TIMER
  g_timer_destroy (splash->timer);
  g_free (splash->text1);
  g_free (splash->text2);
#endif

  g_slice_free (GimpSplash, splash);
  splash = NULL;
}
Exemple #19
0
static void
_gtk_timeline_finalize (GObject *object)
{
  GtkTimelinePriv *priv;
  GtkTimeline *timeline;

  timeline = (GtkTimeline *) object;
  priv = timeline->priv;

  if (priv->source_id)
    {
      g_source_remove (priv->source_id);
      priv->source_id = 0;
    }

  if (priv->timer)
    g_timer_destroy (priv->timer);

  G_OBJECT_CLASS (_gtk_timeline_parent_class)->finalize (object);
}
Exemple #20
0
/**
 * @internal
 *
 * @brief Test memory object destructor callbacks.
 * */
static void destructor_callback_test() {

    /* Test variables. */
    CCLContext * ctx = NULL;
    CCLBuffer * b = NULL;
    CCLErr * err = NULL;
    GTimer * timer = NULL;
    cl_bool test_var = CL_FALSE;

    /* Get the test context with the pre-defined device. */
    ctx = ccl_test_context_new(&err);
    g_assert_no_error(err);

    /* Create a buffer. */
    b = ccl_buffer_new(
        ctx, CL_MEM_READ_WRITE, 128 * sizeof(cl_uint), NULL, &err);

    /* Add destructor callback. */
    ccl_memobj_set_destructor_callback(
        (CCLMemObj *) b, destructor_callback, &test_var, &err);
    g_assert_no_error(err);

    /* Destroy buffer. */
    ccl_buffer_destroy(b);

    /* Destroy context. */
    ccl_context_destroy(ctx);

    /* Confirm that memory allocated by wrappers has been properly
     * freed. */
    g_assert(ccl_wrapper_memcheck());

    /* Wait some more... */
    timer = g_timer_new();
    while (g_timer_elapsed(timer, NULL) < 2.0);
    g_timer_stop(timer);
    g_timer_destroy(timer);

    /* Confirm that test_var is CL_TRUE. */
    g_assert_cmpuint(test_var, ==, CL_TRUE);
}
/**
 * pk_backend_search_names_thread:
 */
static void
pk_backend_search_names_thread (PkBackendJob *job, GVariant *params, gpointer user_data)
{
	GTimer *timer;
	guint percentage;
	PkBitfield filters;
	gchar *filters_text;
	gchar **search;

	g_variant_get (params, "(t^a&s)",
		       &filters,
		       &search);

	filters_text = pk_filter_bitfield_to_string (filters);
	g_debug ("started task (%p) search=%s filters=%s", job, search[0], filters_text);
	g_free (filters_text);
	pk_backend_job_set_status (job, PK_STATUS_ENUM_QUERY);
	timer = g_timer_new ();
	percentage = 0;
	do {
		/* now is a good time to see if we should cancel the thread */
		if (is_cancelled) {
			pk_backend_job_error_code (job, PK_ERROR_ENUM_TRANSACTION_CANCELLED,
					       "The thread was stopped successfully");
			pk_backend_job_finished (job);
			return;
		}
		pk_backend_job_set_percentage (job, percentage);
		percentage += 10;
		g_usleep (1000*100);
	} while (percentage < 100);
	g_timer_destroy (timer);
	pk_backend_job_set_percentage (job, 100);
	g_debug ("exited task (%p)", job);

	pk_backend_job_package (job, PK_INFO_ENUM_INSTALLED,
			    "glib2;2.14.0;i386;fedora", "The GLib library");
	pk_backend_job_package (job, PK_INFO_ENUM_INSTALLED,
			    "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
	pk_backend_job_finished (job);
}
/**
 * backend_search_name_thread:
 */
static gboolean
backend_search_name_thread (PkBackend *backend)
{
	GTimer *timer;
	guint percentage;
	PkBitfield filters;
	gchar *filters_text;
	const gchar *search;

	filters = pk_backend_get_uint (backend, "filters");
	search = pk_backend_get_string (backend, "search");

	filters_text = pk_filter_bitfield_to_text (filters);
	egg_debug ("started task (%p) search=%s filters=%s", backend, search, filters_text);
	g_free (filters_text);
	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
	timer = g_timer_new ();
	percentage = 0;
	do {
		/* now is a good time to see if we should cancel the thread */
		if (is_cancelled) {
			pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED,
					       "The thread was stopped successfully");
			pk_backend_finished (backend);
			return TRUE;
		}
		pk_backend_set_percentage (backend, percentage);
		percentage += 10;
		g_usleep (1000*100);
	} while (percentage < 100);
	g_timer_destroy (timer);
	pk_backend_set_percentage (backend, 100);
	egg_debug ("exited task (%p)", backend);

	pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
			    "glib2;2.14.0;i386;fedora", "The GLib library");
	pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
			    "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
	pk_backend_finished (backend);
	return TRUE;
}
static void
clutter_backend_sdl_dispose (GObject *gobject)
{
  ClutterBackendSDL *backend_sdl = CLUTTER_BACKEND_SDL (gobject);

  _clutter_events_uninit (CLUTTER_BACKEND (backend_sdl));

  if (backend_sdl->stage)
    {
      clutter_actor_destroy (CLUTTER_ACTOR (backend_sdl->stage));
      backend_sdl->stage = NULL;
    }

  if (backend_sdl->timer)
    {
      g_timer_destroy (backend_sdl->timer);
      backend_sdl->timer = NULL;
    }

  G_OBJECT_CLASS (clutter_backend_sdl_parent_class)->dispose (gobject);
}
Exemple #24
0
MpdData * magnatune_db_get_artist_list(char *wanted_genre)
{
    MpdData *list = NULL;
    int r;
    /** check if there is data */
    char *query = sqlite3_mprintf("SELECT albumname from 'genres' WHERE genre=%Q", wanted_genre);
    sqlite3_stmt *stmt = NULL;
    const char *tail;
    GTimer *timer = g_timer_new();
    r = sqlite3_prepare_v2(magnatune_sqlhandle, query, -1,  &stmt,  &tail);
    if(r ==SQLITE_OK) {
        while((r = sqlite3_step(stmt)) == SQLITE_ROW)
        {
            sqlite3_stmt *stmt2 = NULL;
            const char *tail2;
            char *query2 = sqlite3_mprintf("SELECT artist from 'albums' WHERE albumname=%Q", sqlite3_column_text(stmt,0));
            int r2 = sqlite3_prepare_v2(magnatune_sqlhandle, query2, -1,  &stmt2,  &tail2);
            if(r2 ==SQLITE_OK) {
                while((r2 = sqlite3_step(stmt2)) == SQLITE_ROW)
                {
                    list = mpd_new_data_struct_append(list);
                    list->type = MPD_DATA_TYPE_TAG;
                    list->tag_type = MPD_TAG_ITEM_ARTIST;
                    list->tag = g_strdup(sqlite3_column_text(stmt2,0));
                }
            }
            sqlite3_finalize(stmt2);
            sqlite3_free(query2);
        }
    }
    sqlite3_finalize(stmt);
    sqlite3_free(query);
    g_debug("%f s elapsed getting genres\n", g_timer_elapsed(timer,NULL));
    g_timer_reset(timer);
    list = misc_mpddata_remove_duplicate_songs(list);

    g_debug("%f s elapsed unique artist list\n", g_timer_elapsed(timer,NULL));
    g_timer_destroy(timer);
    return list;
}
Exemple #25
0
static void
gimv_image_loader_dispose (GObject *object)
{
   GimvImageLoader *loader = GIMV_IMAGE_LOADER (object);

   if (gimv_image_loader_is_loading (loader))
      gimv_image_loader_load_stop (loader);

   if (loader->info)
      gimv_image_info_unref (loader->info);
   loader->info = NULL;

   if (loader->timer)
      g_timer_destroy (loader->timer);
   loader->timer = NULL;

   if (loader->priv) {
      if (loader->priv->next_info)
         gimv_image_info_unref (loader->priv->next_info);
      loader->priv->next_info = NULL;

      if (loader->priv->gio)
         gimv_io_unref (loader->priv->gio);
      loader->priv->gio = NULL;

      if (loader->priv->image)
         g_object_unref (G_OBJECT (loader->priv->image));
      loader->priv->image = NULL;

      if (loader->priv->temp_file)
         g_free ((gchar *) loader->priv->temp_file);
      loader->priv->temp_file = NULL;

      g_free (loader->priv);
      loader->priv = NULL;
   }

   if (G_OBJECT_CLASS (gimv_image_loader_parent_class)->dispose)
      G_OBJECT_CLASS (gimv_image_loader_parent_class)->dispose (object);
}
static void
gdm_display_finalize (GObject *object)
{
    GdmDisplay *display;

    g_return_if_fail (object != NULL);
    g_return_if_fail (GDM_IS_DISPLAY (object));

    display = GDM_DISPLAY (object);

    g_return_if_fail (display->priv != NULL);

    g_debug ("GdmDisplay: Finalizing display: %s", display->priv->id);
    g_free (display->priv->id);
    g_free (display->priv->seat_id);
    g_free (display->priv->remote_hostname);
    g_free (display->priv->x11_display_name);
    g_free (display->priv->x11_cookie);
    g_free (display->priv->slave_command);
    g_free (display->priv->slave_bus_name);

    g_clear_object (&display->priv->display_skeleton);
    g_clear_object (&display->priv->object_skeleton);
    g_clear_object (&display->priv->connection);

    if (display->priv->access_file != NULL) {
        g_object_unref (display->priv->access_file);
    }

    if (display->priv->user_access_file != NULL) {
        g_object_unref (display->priv->user_access_file);
    }

    if (display->priv->slave_timer != NULL) {
        g_timer_destroy (display->priv->slave_timer);
    }

    G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
}
Exemple #27
0
void 
ipmsg_wait_ms(const int wait_ms){
  GTimer *wait_timer = NULL;
  gulong     elapsed = 0;
  gint    remains_ms = 0;

  wait_timer = g_timer_new();  
  g_assert(wait_timer != NULL);

  for(remains_ms = wait_ms;remains_ms > 0; --remains_ms) {

    g_timer_start(wait_timer);

    for(elapsed = 0; elapsed < 1000UL;g_timer_elapsed(wait_timer, &elapsed)) {
      ipmsg_update_ui(); /* 待ちループ */
    }
  }

  g_timer_destroy(wait_timer);

  return;
}
Exemple #28
0
void
moko_talking_hide_window (MokoTalking *talking)
{
  MokoTalkingPrivate *priv;

  g_return_if_fail (MOKO_IS_TALKING (talking));
  priv = talking->priv;

  if ( HEADSET_STATUS_IN == moko_headset_status_get() )
    moko_sound_profile_set(SOUND_PROFILE_HEADSET);
  else
    moko_sound_profile_set(SOUND_PROFILE_STEREO_OUT);

  if (priv->dtimer)
    g_timer_destroy(priv->dtimer);
  priv->dtimer = NULL;

  if (priv->timeout)
    g_source_remove (priv->timeout);

  gtk_widget_hide (priv->window);
}
Exemple #29
0
static void
switch_to_page (OfficeRunner *run,
		int           page)
{
	gtk_notebook_set_current_page (GTK_NOTEBOOK (run->notebook), page);

	switch (page) {
	case RUN_PAGE:
		set_running_settings (run, TRUE);
		gtk_label_set_text (GTK_LABEL (WID ("run_button_label")), _("Run!"));
		break;
	case RUNNING_PAGE: {
		set_running_settings (run, TRUE);
		disable_block_timeout (run);
		run->timer = g_timer_new ();
		run->timeout = gtk_widget_add_tick_callback (run->time_label, count_tick, run, NULL);
		gtk_label_set_text (GTK_LABEL (WID ("run_button_label")), _("Done!"));
		break;
			   }
	case SCORES_PAGE: {
		run->elapsed = g_timer_elapsed (run->timer, NULL);
		g_timer_destroy (run->timer);
		run->timer = NULL;

		gtk_widget_remove_tick_callback (run->time_label, run->timeout);
		run->timeout = 0;

		gtk_label_set_text (GTK_LABEL (WID ("run_button_label")), _("Try Again"));
		set_records_page (run);

		/* This should be enough time for the machine to go to sleep */
		set_running_settings (run, FALSE);
		run->reenable_block_id = g_timeout_add_seconds (3, reenable_block_timeout_cb, run);

		break;
			  }
	}
}
Exemple #30
0
static void
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
{
  int i;
  int val = 1;
  GTimer *timer = g_timer_new();

  for (i = 0; i < n_iters; i++)
    {
      write_all (out_channel, (char *)&val, sizeof (val));
      read_all (in_channel, (char *)&val, sizeof (val));
    }

  val = 0;
  write_all (out_channel, (char *)&val, sizeof (val));

  val = g_timer_elapsed (timer, NULL) * 1000;
  
  write_all (out_channel, (char *)&val, sizeof (val));
  g_timer_destroy (timer);

  exit (0);
}