Пример #1
0
int
main (int argc, char **argv)
{
        gchar *new_default_files[1] = {NULL};
	GtkSettings *settings;
	gint i;
	gtk_init (&argc, &argv);
        
        /* we get a gtkrc from GTK2_RC_FILES, remove the users theme ... */
        settings = gtk_settings_get_default ();
        g_object_set (settings, "gtk-theme-name", "Raleigh", NULL);
        
	create_testwidgets ();

	window = gtk_window_new (GTK_WINDOW_POPUP);
	box = gtk_vbox_new (FALSE, 0);
	
	gtk_container_add ((GtkContainer*)window, box);
	
	for (i = 0; i < WIDGET_COUNT; i++) {
		if (widgets[i] && !widgets[i]->parent)
			gtk_box_pack_end (GTK_BOX (box), widgets[i], FALSE, FALSE, 0);
	}

	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);
	
	gtk_widget_show_all (window);
	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);
	
	for (i = 0; i < G_N_ELEMENTS (tests); i++)
		run_test (i);
	
	/* remove the rc file again. This should cause an unload of the engine
	 * and destruction of all engine objects. */
        gtk_rc_set_default_files (new_default_files);
	gtk_rc_reparse_all_for_settings (settings, TRUE);

	gtk_widget_hide (window);
	gtk_widget_unmap (window);

	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);

	gtk_widget_destroy (window);

	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);

	/* TODO: It would be really cool to check if there is no
	 * loaded engine at this point. */

	/*
	 * HRM: Calling the follwing causes an assertion failure inside cairo here -- 01.10.2010, Benjamin
	cairo_debug_reset_static_data ();
	*/

	return 0;
}
Пример #2
0
void
gui_gtk_event_process(void)
{

	if (taskmng_isavail() && gdk_events_pending()) {
		gtk_main_iteration_do(FALSE);
	}
}
Пример #3
0
void
SPKDEBridge::TimerHook (void) {
	int cdown = 10;
	gtk_event_loop_called_from_qt = true;
	while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) {
		gtk_main_iteration_do (FALSE);
	}
	gtk_main_iteration_do (FALSE);
	gtk_event_loop_called_from_qt = false;
}
Пример #4
0
static void
__session_periodic_cb(struct ev_loop *loop, struct ev_periodic *w, int revents)
{
  GtkWidget *wgt = w->data;
  printf("%s:%d\n", __FUNCTION__, __LINE__);
  while (gdk_events_pending())
    {
      GdkEvent *ev = gdk_event_get();
      if (ev)
        {
          on_mainwin_frame_event(GTK_WINDOW(wgt), ev, NULL);
          gdk_event_free(ev);
        }
    }
  __invalidate(wgt, NULL, wgt);
}
Пример #5
0
static gboolean
handle_stdin (GIOChannel * channel, GIOCondition condition, gpointer data)
{
  if ((condition & G_IO_IN) != 0)
    {
      GString *string;
      GError *err = NULL;

      string = g_string_new (NULL);
      while (channel->is_readable == FALSE);

      do
        {
          gint status;
          gchar *command = NULL, *value = NULL, **args;

          do
            {
              status = g_io_channel_read_line_string (channel, string, NULL, &err);

              while (gdk_events_pending ())
                gtk_main_iteration ();
            }
          while (status == G_IO_STATUS_AGAIN);

          if (status != G_IO_STATUS_NORMAL)
            {
              if (err)
                {
                  g_printerr ("yad_notification_handle_stdin(): %s\n", err->message);
                  g_error_free (err);
                  err = NULL;
                }
              /* stop handling but not exit */
              g_io_channel_shutdown (channel, TRUE, NULL);
              return FALSE;
            }

          strip_new_line (string->str);
          if (!string->str[0])
            continue;

          args = g_strsplit (string->str, ":", 2);
          command = g_strdup (args[0]);
          if (args[1])
            value = g_strdup (args[1]);
          g_strfreev (args);
          if (value)
            g_strstrip (value);

          if (!g_ascii_strcasecmp (command, "icon") && value)
            {
              g_free (icon);
              icon = g_strdup (value);

              if (gtk_status_icon_get_visible (status_icon) && gtk_status_icon_is_embedded (status_icon))
                set_icon ();
            }
          else if (!g_ascii_strcasecmp (command, "tooltip"))
            {
              if (g_utf8_validate (value, -1, NULL))
                {
                  gchar *message = g_strcompress (value);
                  if (!options.data.no_markup)
                    gtk_status_icon_set_tooltip_markup (status_icon, message);
                  else
                    gtk_status_icon_set_tooltip_text (status_icon, message);
                  g_free (message);
                }
              else
                g_printerr (_("Invalid UTF-8 in tooltip!\n"));
            }
          else if (!g_ascii_strcasecmp (command, "visible"))
            {
#if !GTK_CHECK_VERSION(2,22,0)
              if (!g_ascii_strcasecmp (value, "blink"))
                {
                  gboolean state = gtk_status_icon_get_blinking (status_icon);
                  gtk_status_icon_set_blinking (status_icon, !state);
                }
              else
#endif
              if (!g_ascii_strcasecmp (value, "false"))
                {
                  gtk_status_icon_set_visible (status_icon, FALSE);
#if !GTK_CHECK_VERSION(2,22,0)
                  gtk_status_icon_set_blinking (status_icon, FALSE);
#endif
                }
              else
                {
                  gtk_status_icon_set_visible (status_icon, TRUE);
#if !GTK_CHECK_VERSION(2,22,0)
                  gtk_status_icon_set_blinking (status_icon, FALSE);
#endif
                }
            }
          else if (!g_ascii_strcasecmp (command, "action"))
            {
              g_free (action);
              if (value)
                action = g_strdup (value);
            }
          else if (!g_ascii_strcasecmp (command, "quit"))
            {
              exit_code = YAD_RESPONSE_OK;
              gtk_main_quit ();
            }
          else if (!g_ascii_strcasecmp (command, "menu"))
            {
              if (value)
                parse_menu_str (value);
            }
          else
            g_printerr (_("Unknown command '%s'\n"), command);

          g_free (command);
          g_free (value);
        }
      while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);
      g_string_free (string, TRUE);
    }

  if ((condition & G_IO_HUP) != 0)
    {
      g_io_channel_shutdown (channel, TRUE, NULL);
      gtk_main_quit ();
      return FALSE;
    }

  return TRUE;
}
Пример #6
0
/* GdkEvent Singleton Methods */
static VALUE
gdkevent_s_events_pending(G_GNUC_UNUSED VALUE self)
{
    return CBOOL2RVAL(gdk_events_pending());
}
Пример #7
0
int main(int argc, char **argv)
#endif
{
    char execute[256];
#ifndef GKRELLM_BFM
    int proximity = 0;
    int ch;
#endif
#ifdef FPS
    int f, o;
    time_t y;
#endif
#ifdef PRO
    int cnt = 25000;
#endif

#ifndef GKRELLM_BFM
    GdkEvent *event;
#endif

#ifdef FPS
    o = f = y = 0;
#endif

    /* initialize GDK */
#ifndef GKRELLM_BFM
    if (!gdk_init_check(&argc, &argv)) {
	fprintf(stderr,
		"GDK init failed, bye bye.  Check \"DISPLAY\" variable.\n");
	exit(-1);
    }
#endif
    gdk_rgb_init();

    /* dynamically generate getopt string depending on compile options
     * we are going to borrow 256 char string from exec function, and
     * also build up the "compiled features" string */
    memset(execute, 0, 256);
    strcat(execute, "h");	/* help, always in */
#ifdef ENABLE_DUCK
    strcat(options, "DUCK ");
    strcat(execute, "d");
#ifdef UPSIDE_DOWN_DUCK
    strcat(options, "INVERT ");
    strcat(execute, "u");
#endif				/* UPSIDE_DOWN_DUCK */
#endif				/* ENABLE_DUCK */
#ifdef ENABLE_CPU
    strcat(options, "CPU ");
    strcat(execute, "c");
#endif				/* ENABLE_CPU */
#ifdef ENABLE_MEMSCREEN
    strcat(options, "MEMSCREEN ");
    strcat(execute, "pmk");
#endif				/* ENABLE_MEMSCREEN */
#ifdef ENABLE_FISH
    strcat(options, "FISH ");
    strcat(execute, "f");
    strcat(execute, "n::");
#endif
#ifdef ENABLE_TIME
    strcat(options, "TIME ");
    strcat(execute, "t");
#endif

#ifndef GKRELLM_BFM
    /* command line options */
    while ((ch = getopt(argc, argv, execute)) != -1) {
	switch (ch) {
#ifdef ENABLE_DUCK
	case 'd':
	    duck_enabled = 0;
	    break;
#ifdef UPSIDE_DOWN_DUCK
	case 'u':
	    upside_down_duck_enabled = 0;
	    break;
#endif				/* UPSIDE_DOWN_DUCK */
#endif				/* ENABLE_DUCK */
#ifdef ENABLE_CPU
	case 'c':
	    cpu_enabled = 0;
	    break;
#endif				/* ENABLE_CPU */
#ifdef ENABLE_MEMSCREEN
	case 'm':
	    memscreen_enabled = 0;
	    break;
	case 'p':
	    {
		/* no sense having -p if memscreen isn't compiled in, right?
		 * what we are going to do is to change the colors as follows:
		 * 
		 * (48,140,240) replaced with (158,196,237) - more pale blue
		 * (237,23,23) replaced with (0,255,233) */
		unsigned char *p = mem_screen;

		while (p < mem_screen + sizeof(mem_screen))
		    if (*p == 48) {	/* hopefully no other colors beginning with 48 */
			*p++ = 158;
			*p++ = 196;
			*p++ = 237;
		    } else if (*p == 237) {	/* hopefully no other colors beginning with 237 */
			*p++ = 0;
			*p++ = 255;
			*p++ = 233;
		    } else
			p += 3;

		p = load_screen;

		while (p < load_screen + sizeof(load_screen))
		    if (*p == 48) {	/* hopefully no other colors beginning with 48 */
			*p++ = 158;
			*p++ = 196;
			*p++ = 237;
		    } else
			p += 3;
	    }
	    break;
	case 'k':
	    memscreen_megabytes = 1;
	    break;
#endif				/* ENABLE_MEMSCREEN */

#ifdef ENABLE_FISH
	case 'f':
	    fish_enabled = 0;
	    break;
	case 'n':
	    fish_traffic = 1;
	    if (optarg)
	      network_interface = optarg;
	    break;
#endif
#ifdef ENABLE_TIME
	case 't':
	    time_enabled = 1;
	    break;
#endif
	default:
	    print_usage();
	    exit(-1);
	    break;
	}
    }

    argc -= optind;
    argv += optind;

#endif

    /* zero data structure */
    memset(&bm, 0, sizeof(bm));

#ifdef __FreeBSD__
    if (init_stuff())
	exit(-1);
#endif

    /* set default things, from Xresources or compiled-in defaults */
    bubblemon_session_defaults();

    /* create dockapp window. creates windows, allocates memory, etc */
    make_new_bubblemon_dockapp();

#ifdef ENABLE_FISH
    if(fish_enabled)
    {
	prepare_sprites();
    }
#endif

#ifndef GKRELLM_BFM
#ifdef PRO
    while (cnt--) {
#else
    while (1) {
#endif
	while (gdk_events_pending()) {
	    event = gdk_event_get();
	    if (event) {
		switch (event->type) {
		case GDK_DESTROY:
		    gdk_exit(0);
		    exit(0);
		    break;
		case GDK_BUTTON_PRESS:
		    if (event->button.button == 3) {
			bm.picture_lock = 1;
			break;
		    }
		    if (event->button.button <= argc) {
			snprintf(execute, 250, "%s &",
				 argv[event->button.button - 1]);
			system(execute);
		    }
		    break;
#if defined(ENABLE_CPU) || defined(ENABLE_MEMSCREEN)
		case GDK_ENTER_NOTIFY:
		    /* mouse in: make it darker, and eventually bring up
		     * meminfo */
		    proximity = 1;

		    bm.screen_type = get_screen_selection();
		    bm.picture_lock = 0;
		    break;
		case GDK_LEAVE_NOTIFY:
		    /* mouse out: back to light */
		    proximity = 0;
		    break;
#endif				/* ENABLE_CPU || ENABLE_MEMSCREEN */
		default:
		    break;
		}
	    }
	}
#ifndef PRO
	usleep(15000);
#else
	/* amazingly enough just calling this function takes insane
	 * amount of time.
	 usleep(0); */
#endif
	/* get system statistics */
	get_memory_load_percentage();
	/* update main rgb buffer: bm.rgb_buf */
	bubblemon_update(proximity);

/* *INDENT-OFF* */
#ifdef FPS
	/* render frames per second on bottom-right corner :)
	 * This is GCC-specific (functions inside functions)
	 * and very unoptimized. this is obfuscated 'cause its ugly */
    	f++;{int b;void q(int sx,int sy,int dx,int dy){int i,j;char *from,*to;
	for(j=0;j<8;j++){from=mem_screen+56*3*(sy+j)+sx*3;to=bm.rgb_buf+56*3*
	(dy+j)+dx*3;i=12;while(i--)*to++=*from++;}}b=o;if(b>=100){q((b/100)*4,
	60,43,46);b=b%100;}q((b/10)*4,60,47,46);q((b%10)*4,60,51,46);}if(time(
	NULL)!=y){o=f;f=0;y=time(NULL);}
#endif
/* *INDENT-ON* */

	/* actually draw the screen */
#ifndef BLACKBOX
	gdk_draw_rgb_image(bm.win, bm.gc, 4, 4, 56, 56,
			   GDK_RGB_DITHER_NONE, bm.rgb_buf, 56 * 3);
#endif
	gdk_draw_rgb_image(bm.iconwin, bm.gc, 4, 4, 56, 56,
			   GDK_RGB_DITHER_NONE, bm.rgb_buf, 56 * 3);
#ifdef ENABLE_MEMSCREEN
	/* update graph histories */
	if (memscreen_enabled)
	    roll_history();
#endif				/* ENABLE_MEMSCREEN */
    }
#endif
    return 0;
}				/* main */
Пример #8
0
/* This is a generic rendering function.  It works for all signal styles.
 * The input always looks like one big PCM sample; if the input is really
 * a spectrum, then it will have been transformed by blurk_render_pcm()
 * into 256 PCM samples, with 20000 meaning "no sound" and smaller/negative
 * values representing a lot of sound.  This particular transformation was
 * chosen simply because the normal PCM plotter can then produce a nice-looking
 * spectrum graph.
 *
 * This function supports a variety of ways to plot the [pseudo-]PCM samples.
 * In addition to the usual line graph, it can also mirror the line graph or
 * produce a "bead" graph by passing the data off to render_bead().
 * The decision of how to plot is based on the value of "variation".
 */
static void update_image(gint32 loudness, gint ndata, gint16 *data)
{
	gint	i, y, thick, quiet, center;
	gint	beat;
	guchar	*img;
	gint	width, height, bpl;

#if 0
	/* If events are pending, then skip this frame */
	if (gdk_events_pending())
		return;
#endif

	/* If we completed a resize operation a few seconds ago, then save the
	 * new size now.
	 */
	if (savewhen != 0L && time(NULL) >= savewhen)
	{
		//config_write(FALSE, NULL, NULL);
		savewhen = 0L;
	}

	/* If we're supposed to be in fullscreen mode, and aren't, then
	 * toggle fullscreen mode now.
	 */
#if 0	 
	if (config.fullscreen_desired && !fullscreen_method)
		blursk_fullscreen(FALSE);
#endif

	/* Detect whether this is a beat, and choose a line thickness */
	beat = detect_beat(loudness, &thick, &quiet);

	/* If quiet, then maybe choose a new preset */
	//if (quiet)
		//preset_quiet();

	/* Perform the blurring.  This also affects whether the center of the
	 * signal will be moved lower in the window.
	 */
	center = img_height/2 + blur(beat, quiet);

	/* Perform the fade or solid flash */
	if (beat && !strcmp(config.flash_style, "Full flash"))
		i = 60;
	else
	{
		switch (config.fade_speed[0])
		{
		  case 'S':	i = -1;	break;	/* Slow */
		  case 'M':	i = -3;	break;	/* Medium */
		  case 'F':	i = -9;	break;	/* Fast */
		  default:	i = 0;		/* None */
		}
	}
	if (i != 0)
		loopfade(i);

	/* special processing for "Invert" & bitmap logo flashes */
	if (beat)
	{
		if (!strcmp(config.flash_style, "Invert flash"))
			img_invert();
		else if ((i = bitmap_index(config.flash_style)) >= 0)
			bitmap_flash(i);
	}

	/* Maybe change hue on beats */
	if (beat)
		color_beat();

	/* Add the signal data to the image */
	render(thick, center, ndata, data);

	/* Add floaters */
	drawfloaters(beat);

	/* shift the "ripple effect" from one frame to another */
	img_rippleshift += 3; /* cyclic, since img_rippleshift is a guchar */

	/* Apply the overall effect, if any */
	if (!strcmp(config.overall_effect, "Bump effect"))
	{
		img = img_bump(&width, &height, &bpl);
	}
	else if (!strcmp(config.overall_effect, "Anti-fade effect"))
	{
		img = img_travel(&width, &height, &bpl);
	}
	else if (!strcmp(config.overall_effect, "Ripple effect"))
	{
		img = img_ripple(&width, &height, &bpl);
	}
	else /* "Normal effect" */
	{
		img = img_expand(&width, &height, &bpl);
	}

	/* show info about the track */
	img = show_info(img, height, bpl);

	/* Allow the background color to change */
	color_bg(ndata, data);

	/* Copy the image into the window.  This also converts from
	 * 8-bits to 16/24/32 if necessary.
	 */
#if 0	 
	GDK_THREADS_ENTER();
#if HAVE_XV
	if (!xv_putimg(img, width, height, bpl))
#endif
		gdk_draw_indexed_image(area->window,
			area->style->white_gc,
			0, 0, width, height, GDK_RGB_DITHER_NONE,
			img, bpl, color_map);
	GDK_THREADS_LEAVE();
#endif
	/* Convert colors */
	uint32* pDst = (uint32*)blursk_bitmap->LockRaster();
	uint8* pSrc = img;
	

	for( y = 0; y < height; y++ )
	{
		for( i = 0; i < width; i++ )
		{
			*pDst++ = color_map[*pSrc++];
		}
		pSrc += bpl - width;
	}
	
	blursk_view->DrawBitmap( blursk_bitmap, blursk_bitmap->GetBounds(), blursk_bitmap->GetBounds() );
	blursk_view->Flush();
}
Пример #9
0
/*********************************************
* OpenAsReferenceImage関数                   *
* 参考用画像を開く                           *
* 引数                                       *
* file_path	: ファイルのパス                 *
* reference	: 参考用画像表示ウィンドウの情報 *
*********************************************/
void OpenAsReferenceImage(char* file_path, REFERENCE_WINDOW* reference)
{
	// アプリケーションを管理する構造体のアドレス
	APPLICATION *app = reference->app;
	// ピクセルデータ取得用
	GdkPixbuf *pixbuf;
	// 拡張子判定用
	gchar *str;
	// ファイル名
	gchar *file_name;

	// 拡張子取得
	str = file_path + strlen(file_path) - 1;
	while(*str != '.' && str > file_path)
	{
		str--;
	}

	// ファイル名取得
	file_name = file_path + strlen(file_path) - 1;
	while(*file_name != '/' && *file_name != '\\' && file_name > file_path)
	{
		file_name--;
	}
	if(file_name != file_path)
	{
		file_name++;
	}

	if(StringCompareIgnoreCase(str, ".kab") == 0)
	{
		// システムの文字コードへ変換
		gchar *system_path = g_locale_from_utf8(file_path, -1, NULL, NULL, NULL);
		FILE *fp = fopen(system_path, "rb");
		// ファイルサイズ
		size_t data_size;
		// 読込中メッセージのID
		guint context_id, message_id;
		// 表示イベント処理用
		GdkEvent *queued_event;
		// 合成したレイヤー
		LAYER *mixed;

		g_free(system_path);

		if(fp == NULL)
		{
			return;
		}

		// 読込中のメッセージを表示
		context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(app->status_bar), "Loading");
		message_id = gtk_statusbar_push(GTK_STATUSBAR(app->status_bar),
			context_id, app->labels->window.loading);
		// イベントを回してメッセージを表示
#if GTK_MAJOR_VERSION <= 2
		gdk_window_process_updates(app->status_bar->window, TRUE);
#else
		gdk_window_process_updates(gtk_widget_get_window(app->status_bar), TRUE);
#endif

		while(gdk_events_pending() != FALSE)
		{
			queued_event = gdk_event_get();
			gtk_main_iteration();
			if(queued_event != NULL)
			{
#if GTK_MAJOR_VERSION <= 2
				if(queued_event->any.window == app->status_bar->window
#else
				if(queued_event->any.window == gtk_widget_get_window(app->status_bar)
#endif
					&& queued_event->any.type == GDK_EXPOSE)
				{
					gdk_event_free(queued_event);
					break;
				}
				else
				{
					gdk_event_free(queued_event);
				}
			}
		}

		(void)fseek(fp, 0, SEEK_END);
		data_size = (size_t)ftell(fp);
		rewind(fp);

		mixed = ReadOriginalFormatMixedData(fp, (stream_func_t)fread, data_size, app, file_name);
		if(mixed != NULL)
		{
			uint8 *pixels = (uint8*)MEM_ALLOC_FUNC(mixed->stride * mixed->height);
			(void)memcpy(pixels, mixed->pixels, mixed->stride * mixed->height);
			AddReferenceImage(reference, file_name, pixels,
				mixed->width, mixed->height, mixed->stride, mixed->channel);

			cairo_destroy(mixed->cairo_p);
			cairo_surface_destroy(mixed->surface_p);
			MEM_FREE_FUNC(mixed->name);

			MEM_FREE_FUNC(mixed->pixels);

			MEM_FREE_FUNC(mixed);
		}
	}
Пример #10
0
static visualizer_t * visualizer_create()
  {
  const bg_plugin_info_t * info;
  char * tmp_path;
  int row, col;
  
  GtkWidget * main_table;
  GtkWidget * table;
  GtkWidget * box;
  
  visualizer_t * ret;
  bg_cfg_section_t * cfg_section;
  
  ret = calloc(1, sizeof(*ret));
  
  ret->cb.motion_callback = motion_callback;
  ret->cb.data = ret;
  
  window_init(ret, &ret->normal_window, 0);
  window_init(ret, &ret->fullscreen_window, 1);
  ret->current_window = &ret->normal_window;

  ret->log_window = bg_gtk_log_window_create(log_close_callback, ret,
                                             TR("Gmerlin visualizer"));
  
  ret->config_button =
    create_pixmap_button(ret, "config_16.png", TRS("Configure"));
  ret->plugin_button =
    create_pixmap_button(ret, "plugin_16.png", TRS("Recording and display plugins"));
  ret->restart_button =
    create_pixmap_button(ret, "refresh_16.png", TRS("Restart visualization"));
  ret->quit_button =
    create_pixmap_button(ret, "quit_16.png", TRS("Quit"));
  ret->fullscreen_button =
    create_pixmap_button(ret, "fullscreen_16.png", TRS("Fullscreen mode"));
  ret->nofullscreen_button =
    create_pixmap_button(ret, "windowed_16.png", TRS("Leave fullscreen mode"));

  ret->log_button = create_pixmap_button(ret,
                                         "log_16.png",
                                         TRS("Show log window"));
  ret->about_button = create_pixmap_button(ret,
                                           "about_16.png",
                                           TRS("About Gmerlin visualizer"));
  ret->help_button = create_pixmap_button(ret,
                                          "help_16.png",
                                          TRS("Launch help in a webwroswer"));
  
  ret->fps = gtk_label_new("Fps: --:--");
  gtk_misc_set_alignment(GTK_MISC(ret->fps), 0.0, 0.5);
  gtk_widget_show(ret->fps);
  
  gtk_widget_hide(ret->nofullscreen_button);
  
  //  bg_gtk_box_pack_start_defaults(GTK_BOX(mainbox),
  //                              bg_gtk_vumeter_get_widget(ret->vumeter));
  
  ret->toolbar = gtk_event_box_new();

  gtk_widget_set_events(ret->toolbar,
                        GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
  
  g_signal_connect(G_OBJECT(ret->toolbar), "enter-notify-event",
                   G_CALLBACK(crossing_callback), (gpointer*)ret);
  
  g_signal_connect(G_OBJECT(ret->toolbar), "leave-notify-event",
                   G_CALLBACK(crossing_callback), (gpointer*)ret);

  
  g_object_ref(ret->toolbar); /* Must be done for widgets, which get
                                 reparented after */
  
  ret->vumeter = bg_gtk_vumeter_create(2, 0);
  
  /* Create actual objects */

  /* Create plugin regsitry */
  ret->cfg_reg = bg_cfg_registry_create();
  tmp_path =  bg_search_file_read("visualizer", "config.xml");
  bg_cfg_registry_load(ret->cfg_reg, tmp_path);
  if(tmp_path)
    free(tmp_path);
  
  cfg_section = bg_cfg_registry_find_section(ret->cfg_reg, "plugins");
  ret->plugin_reg = bg_plugin_registry_create(cfg_section);
  ret->visualizer = bg_visualizer_create(ret->plugin_reg);

  bg_visualizer_set_callbacks(ret->visualizer, &ret->cb);
  
  /* Create vis plugin widget */

  ret->vis_plugins =
    bg_gtk_plugin_widget_single_create(TR("Visualization"),
                                       ret->plugin_reg,
                                       BG_PLUGIN_VISUALIZATION,
                                       BG_PLUGIN_VISUALIZE_FRAME |
                                       BG_PLUGIN_VISUALIZE_GL);

  bg_gtk_plugin_widget_single_set_change_callback(ret->vis_plugins,
                                                  set_vis_plugin,
                                                  ret);

  bg_gtk_plugin_widget_single_set_parameter_callback(ret->vis_plugins,
                                                     set_vis_parameter,
                                                     ret);
  
  /* Create audio and video plugin widgets */
  
  plugin_window_init(&ret->plugin_window, ret);

  /* Get ov info */
  
  ret->ov_info =
    bg_gtk_plugin_widget_single_get_plugin(ret->plugin_window.ov_plugins);
  
  /* Load recording plugin */
  ret->ra_info =
    bg_gtk_plugin_widget_single_get_plugin(ret->plugin_window.ra_plugins);
  
  /* Create config stuff */
  
  ret->visualizer_section =
    bg_cfg_registry_find_section(ret->cfg_reg, "visualizer");
  ret->general_section =
    bg_cfg_registry_find_section(ret->cfg_reg, "general");
  ret->log_section =
    bg_cfg_registry_find_section(ret->cfg_reg, "log");
  
  ret->cfg_dialog = create_cfg_dialog(ret);


  
  /* Pack everything */

  main_table = gtk_table_new(2, 2, 0);

  gtk_table_set_row_spacings(GTK_TABLE(main_table), 5);
  gtk_table_set_col_spacings(GTK_TABLE(main_table), 5);
  gtk_container_set_border_width(GTK_CONTAINER(main_table), 5);
  
  table = gtk_table_new(1, 4, 0);

  gtk_table_set_row_spacings(GTK_TABLE(table), 5);
  gtk_table_set_col_spacings(GTK_TABLE(table), 5);
  gtk_container_set_border_width(GTK_CONTAINER(table), 5);
  
  
  row = 0;
  col = 0;
  bg_gtk_plugin_widget_single_attach(ret->vis_plugins,
                                     table,
                                     &row, &col);
  gtk_widget_show(table);
  
  gtk_table_attach(GTK_TABLE(main_table), table, 0, 1, 0, 1,
                   GTK_FILL, GTK_SHRINK, 0, 0);
  
  box = gtk_hbox_new(0, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->plugin_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->config_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->restart_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->fullscreen_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->nofullscreen_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->log_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->about_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->help_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->quit_button,
                     FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box), ret->fps, TRUE, TRUE, 5);
  gtk_widget_show(box);
  
  gtk_table_attach(GTK_TABLE(main_table), box, 0, 1, 1, 2,
                   GTK_FILL, GTK_SHRINK, 0, 0);

  gtk_table_attach(GTK_TABLE(main_table),
                   bg_gtk_vumeter_get_widget(ret->vumeter),
                   1, 2, 0, 2,
                   GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);

  
  gtk_widget_show(main_table);
  
  gtk_container_add(GTK_CONTAINER(ret->toolbar), main_table);
  
  //  gtk_widget_show(ret->toolbar);
  
  /* Start with non-fullscreen mode */
  attach_toolbar(ret, &ret->normal_window);
  
  apply_config(ret);
  
  /* Get visualization plugin */
  info = bg_gtk_plugin_widget_single_get_plugin(ret->vis_plugins);
  bg_visualizer_set_vis_plugin(ret->visualizer, info);
  
  /* Initialize stuff */
  open_audio(ret);
  open_vis(ret);

  
  gtk_widget_show(ret->current_window->window);

  if(ret->width && ret->height)
    gtk_decorated_window_move_resize_window(GTK_WINDOW(ret->current_window->window),
                                            ret->x, ret->y,
                                            ret->width, ret->height);
  else
    gtk_decorated_window_move_resize_window(GTK_WINDOW(ret->current_window->window),
                                            100, 100,
                                            640, 480);
  
  while(gdk_events_pending() || gtk_events_pending())
    gtk_main_iteration();
  
  
  g_idle_add(idle_func, ret);
  
  g_timeout_add(3000, toolbar_timeout, ret);
  g_timeout_add(1000, fps_timeout, ret);
  
  return ret;
  }