Exemplo n.º 1
0
void init_ui(void) {
	int argc;
	char **argv;
	GtkWidget* dlg;
	
	disp = malloc(WWIDTH*WHEIGHT*3);	
	argc = 1;
	argv = g_new (gchar *, 1);
	argv[0] = g_strdup ("myprog");
	gtk_init (&argc, &argv);	
	gdk_rgb_init ();
	gtk_widget_set_default_visual (gdk_rgb_get_visual());
	gtk_widget_set_default_colormap (gdk_rgb_get_cmap());
	dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
	gtk_signal_connect (GTK_OBJECT (dlg), "destroy",	(GtkSignalFunc) gtk_main_quit, NULL);
	gtk_window_set_title (GTK_WINDOW (dlg), "FLYNN");
	eventbox = gtk_event_box_new();
	gtk_container_border_width (GTK_CONTAINER (eventbox), 0);
	gtk_container_add (GTK_CONTAINER (dlg), GTK_WIDGET (eventbox));
	drawing_area = gtk_drawing_area_new ();
	gtk_widget_set_usize (drawing_area, WWIDTH, WHEIGHT);
	gtk_container_add (GTK_CONTAINER (eventbox),
	GTK_WIDGET (drawing_area));	
	gtk_widget_show (drawing_area);
	gtk_widget_show (eventbox);	
	gtk_widget_add_events (dlg,
	GDK_KEY_PRESS_MASK);
	gtk_signal_connect (GTK_OBJECT (dlg), "key_press_event",	(GtkSignalFunc) key_press, NULL);
	gtk_widget_show (dlg);
	/* gdk_key_repeat_disable (); */
	/* gdk_keyboard_grab (eventbox->window, FALSE, time); */
}
Exemplo n.º 2
0
int
main(int argc,char **argv)
{
  int i;

  for(i=0;i<24;i++)
    hourly[i]=0;
  for(i=0;i<7;i++)
    weekly[i]=0;
  for(i=0;i<256;i++)
    nsrc[i]=i;

  time_cons[0]=0;
  time_cons[1]=0;
  useridx=ispidx=0;

  gtk_init(&argc,&argv);
  gdk_rgb_init();
  load_log();
  create_loglist();
  update_list();

  make_resume();

  gtk_main();

  g_list_free(users);
  g_list_free(isps);
  for(i=0;i<3;i++)
    gdk_pixmap_unref(iconmap[i]);

  free_log();
  return 0;
}
Exemplo n.º 3
0
int
main (int argc,
      char **argv)
{
	CORBA_ORB orb;

	bindtextdomain (PACKAGE, LOCALE_DIRECTORY);
	textdomain (PACKAGE);

	gnome_init_with_popt_table ("Evolution Yank", VERSION,
				    argc, argv, oaf_popt_options, 0, NULL);
	orb = oaf_init (argc, argv);

	gdk_rgb_init ();
	if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
		g_error (_("Yank component could not initialize Bonobo.\n"));
		exit (1);
	}

	glade_gnome_init ();
	gnome_vfs_init ();

	/* Start our component */
	component_factory_init ();

	bonobo_main ();

	return 0;
}
void CFramework::NATIVE_new(void) {
#if !NO_GTK
   gtk_init(0, NULL);
   gdk_rgb_init();
#if OS_Linux
   gtk_timeout_add(20, CFramework__LINUX_timeout, NULL);
#endif
#endif
}/*CFramework::NATIVE_new*/
Exemplo n.º 5
0
/*
** Load the MapPieces Pixbuf 
*/
BOOL MapPicLoad(void)
{
    errormsg(MAPDEBUG1,"MapPicLoad: Entered");

    gdk_rgb_init (); // Required for rendering! Really put here ?
    mMapPieces = gdk_pixbuf_new_from_file ("breakout.png");
    g_assert (mMapPieces != NULL);

    errormsg(MAPDEBUG1,"MapPicLoad: Finished succesfully");
    return TRUE;
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *drawing_area;

  /* --- GTK initialization --- */
  gtk_init( &argc, &argv );
  gdk_rgb_init();

  /* --- Open BMP file and Read headers --- */
  if (argc>1) strcpy(fname1, argv[1]);
  else { printf("入力画像ファイル名: "); gets(fname1); }

  fp1=open_bmpfile(fname1, &bmpf_h, &bmpi_h);

  pict_width=bmpi_h.biWidth; pict_height=bmpi_h.biHeight;

  rgbbuf=(guchar *) malloc(pict_width * pict_height * 3);
  if (rgbbuf==NULL) {
    printf("Can't allocate rgbbuf\n"); exit(1);
  }
  read_bmpfile(fp1);

  pict_width=768;
  pict_height=256;



  /* --- Create the top level window --- */
  g_window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  /* --- Show the label  --- */
  gtk_widget_show(window);
  gtk_signal_connect(GTK_OBJECT(window), "destroy",
		     GTK_SIGNAL_FUNC(destroyapp), NULL);

  drawing_area = gtk_drawing_area_new();
  gtk_drawing_area_size( GTK_DRAWING_AREA(drawing_area), pict_width, pict_height);
  gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
		     (GtkSignalFunc) expose_event, NULL);
  gtk_widget_set_events(drawing_area, GDK_EXPOSURE_MASK
	| GDK_BUTTON_PRESS_MASK);
  gtk_container_add(GTK_CONTAINER(window), drawing_area);

  /* --- Show the label  --- */
  gtk_widget_show(drawing_area);

  /* --- Create GC  --- */
  g_gc = gdk_gc_new(window->window);

  gtk_main();
  return 0;
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
	static struct Camera camera;
	pthread_t draw_thread, grab_thread, tele_thread;

	init_camera(&camera);

	if(argc >= 2 && strcmp(argv[1], "GPS_ON") == 0)  camera.gpson = TRUE;

	//init threads
	g_thread_init(NULL);
	gdk_threads_init();
	//init gtk
	gtk_init(&argc, &argv);
	//Init gdk_rgb
	gdk_rgb_init();
	//Init semaphore
	sem_init(&sem_draw, 0, 0);
	sem_init(&sem_grab, 0, 1);

	open_camera(&camera);
	set_camera_info(&camera);
	get_camera_info(&camera);

//	print_camera_info(&camera);

	create_window(&camera);

	if(camera.gpson) {
		camera_antennaimg_change(&camera, "0");
		pthread_create(&tele_thread, NULL, (void*)&camera_gps_tel, &camera);
	}
	pthread_create(&draw_thread, NULL, (void*)&preview_camera, &camera);
	pthread_create(&grab_thread, NULL, (void*)&grab_image_camera, &camera);

	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();

	camera.quit = 1;
	if(camera.gpson) pthread_join(tele_thread, NULL);
	pthread_join(grab_thread, NULL);
	pthread_join(draw_thread, NULL);
	sem_post(&sem_draw);	
	sem_post(&sem_grab);
	sem_destroy(&sem_draw);
	sem_destroy(&sem_grab);

	close_camera(&camera);

	return 0;
}
Exemplo n.º 8
0
// Initialise the library.
// Pass in the program arguments through argc, argv
int rtk_init(int *argc, char ***argv)
{
  // Initialise the gtk lib
  gtk_init(argc, argv);

  // Allow rgb image handling
  gdk_rgb_init();

  // Use shared mem if we can
  // This speeds things up *a lot*
  gdk_set_use_xshm(1);

  return 0;
}
Exemplo n.º 9
0
int interface_gtk_start(Playlist *playlist, int argc, char **argv)
{
	char path[256];
	char *home;

	the_coreplayer = playlist->GetCorePlayer();

	g_thread_init(NULL);
	if (!g_thread_supported()) {
		alsaplayer_error("Sorry - this interface requires working threads.\n");
		return 1;
	}

	// Scope functions
	scopes = new AlsaSubscriber();
	scopes->Subscribe(the_coreplayer->GetNode(), POS_END);
	scopes->EnterStream(scope_feeder_func, the_coreplayer);

	gtk_set_locale();
	gtk_init(&argc, &argv);
	gdk_rgb_init();

	home = getenv("HOME");
	if (home) {
		snprintf(path, 255, "%s/.gtkrc", home);
		gtk_rc_parse(path);
	}

	if (playlist->Length())
		playlist->UnPause();
	// Scope addons
	gdk_flush();
	GDK_THREADS_ENTER();
	init_main_window(playlist);
	load_scope_addons();
	gdk_flush();
	gtk_main();
	gdk_flush();
	GDK_THREADS_LEAVE();
	unload_scope_addons();
	destroy_scopes_window();
	GDK_THREADS_ENTER();
	gdk_flush();
	GDK_THREADS_LEAVE();

	playlist->Pause();

	dl_close_scopes();
	return 0;
}
Exemplo n.º 10
0
int dodisplay(int argc, char *argv[]) {
    GIOChannel *chan;
    struct imgrect *ir;

    /* have our main loop poll the pipe file descriptor */
    chan = g_io_channel_unix_new(dpychld_fd);
    g_io_add_watch(chan, G_IO_IN | G_IO_ERR | G_IO_HUP, (GIOFunc)pipe_event, NULL);
    fcntl(dpychld_fd, F_SETFL, O_NONBLOCK);

    /* set up list of image rectangles. */
    imgrects = calloc(nimgrects = 16, sizeof *imgrects);
       
    /* do some init thing */
    gtk_init(&argc, &argv);
    gdk_rgb_init();

    gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
    gtk_widget_set_default_visual(gdk_rgb_get_visual());

    /* Make our own window. */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_usize(window, 0, 0);

    darea = gtk_drawing_area_new();
    gtk_container_add(GTK_CONTAINER(window), darea);
    gtk_widget_set_events(darea, GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);

    gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);
    gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy), NULL);

    gtk_signal_connect(GTK_OBJECT(darea), "expose-event", GTK_SIGNAL_FUNC(expose_event), NULL);
    gtk_signal_connect(GTK_OBJECT(darea), "configure_event", GTK_SIGNAL_FUNC(expose_event), NULL);
    
    /* mouse button press/release for saving images */
    gtk_signal_connect(GTK_OBJECT(darea), "button_press_event", GTK_SIGNAL_FUNC(button_press_event), NULL);
    gtk_signal_connect(GTK_OBJECT(darea), "button_press_event", GTK_SIGNAL_FUNC(button_release_event), NULL);

    gtk_widget_show_all(window);

    gtk_main();

    /* Get rid of all remaining images. */
    for (ir = imgrects; ir < imgrects + nimgrects; ++ir)
        if (ir->filename)
            unlink(ir->filename);

    return 0;
}
Exemplo n.º 11
0
// Initialise the library.
// Pass in the program arguments through argc, argv
int rtk_init(int *argc, char ***argv)
{
  // Initialise the gtk lib
  gtk_init(argc, argv);

  // Allow rgb image handling
  gdk_rgb_init();

#ifdef ENABLE_AVCODEC
  // Allow movie capture
  avcodec_init();
  avcodec_register_all();
#endif

  return 0;
}
Exemplo n.º 12
0
int UI_Init(int argc, char **argv)
{
	initTranslator();

  uint32_t w,h;
    if(!g_thread_supported())
        g_thread_init(NULL);
    gdk_threads_init();
    gdk_threads_enter();
    gtk_set_locale();
    global_argc=argc;
    global_argv=argv;
      
    gtk_init(&global_argc, &global_argv);
    gdk_rgb_init();
    
    
}
Exemplo n.º 13
0
Arquivo: ui.c Projeto: barak/gtkboard
int main (int argc, char **argv)
{
#ifdef HAVE_GNOME
	GnomeProgram *app;
#endif
	srandom (get_seed());
	reset_game_params ();
	prefs_read_config_file ();
	parse_opts (argc, argv);
	ui_start_player ();
	
	signal (SIGINT, ui_cleanup);
	signal (SIGTERM, ui_cleanup);
	signal (SIGSEGV, ui_segv_cleanup);
	signal (SIGCHLD, ui_child_cleanup);
	if (!opt_quiet)
	{
		gtk_init(&argc,&argv);    
		gdk_rgb_init();
#ifdef HAVE_GNOME
		app = gnome_program_init (PACKAGE, VERSION, LIBGNOME_MODULE, argc, argv, GNOME_PARAM_NONE);
#endif
		gui_init ();
		g_idle_add ((GSourceFunc) ui_sound_init, NULL);
		gtk_main ();
	}
	else	// background mode
	{
		GMainLoop *loop;
		signal (SIGHUP, ignore);
		set_game_params ();
		ui_stopped = FALSE;
		sound_set_enabled (FALSE);
		g_idle_add (ui_send_make_move_bg, NULL);
#if GLIB_MAJOR_VERSION > 1
		loop = g_main_loop_new (NULL, TRUE);
#else
		loop = g_main_new (TRUE);
#endif
		g_main_run (loop);
		
	}
	return 0;
}
Exemplo n.º 14
0
static void main_frontend(int argc, char *argv[])
{
	GtkWidget *window, *vbox;

	gtk_init(&argc, &argv);
	gdk_rgb_init();

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), "My WebCam");

	gtk_signal_connect(GTK_OBJECT(window), "delete_event",
			   GTK_SIGNAL_FUNC(delete_event), NULL);
	gtk_signal_connect(GTK_OBJECT(window), "destroy",
			   GTK_SIGNAL_FUNC(delete_event), NULL);
	gtk_signal_connect(GTK_OBJECT(window), "key_release_event",
			   GTK_SIGNAL_FUNC(key_event), NULL);

	gtk_container_set_border_width(GTK_CONTAINER(window), 2);

	/* vertical box */
	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	/* image */
	drawing_area = gtk_drawing_area_new();
	gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area),
			      fmt.fmt.pix.width, fmt.fmt.pix.height);
	gtk_box_pack_start(GTK_BOX(vbox), drawing_area, FALSE, FALSE, 0);

	ctrl_create(vbox);

	gtk_widget_show_all(window);

	gdk_input_add(fd,
			GDK_INPUT_READ,
			frame_ready,
			NULL);

	printf("'g' grab an image - 'i' info toggle - 'q' quit\n");

	gtk_main();
}
Exemplo n.º 15
0
void	init_gtk_gui( int argc, char **argv )
{
	// GTK+ を初期化

	gtk_set_locale();

#if	defined( HAVE_G_THREAD_INIT )
	g_thread_init( NULL );
#endif
	gdk_threads_init();

	gtk_init( &argc, &argv );
	gdk_rgb_init();

	gPcgDun.nTileSizeRate = g_graph_scale_rate;

	init_main_win();

	// SDL を初期化

	gMusic.init();
	gSound.init();
	gJoystick.init();

	// タイマーの設定

	ena_timer();

	// タイトル画像を描画

	gPcgDun.initTitle();
	change_scene_gui( SCENE_N_TITLE );
	gPcgDun.drawTitle();

	// グラフィック設定を選択

	gSelConf.init();
	gSelConf.draw();
}
Exemplo n.º 16
0
int main(int argc, char **argv)
{
	GError *error = NULL;
	char *config_file = NULL;
	char *s;
	int l;

	signal(SIGCHLD, sigchld);

	setenv("LC_NUMERIC","C",1);
	setlocale(LC_ALL,"");
	setlocale(LC_NUMERIC,"C");
	setlocale(LC_NUMERIC,"C");

	if (file_exists("navit.c") || file_exists("navit.o")) {
		char buffer[PATH_MAX];
		printf(_("Running from source directory\n"));
		getcwd(buffer, PATH_MAX);
		setenv("NAVIT_PREFIX", buffer, 0);
		setenv("NAVIT_LIBDIR", buffer, 0);
		setenv("NAVIT_SHAREDIR", buffer, 0);
		setenv("NAVIT_LIBPREFIX", "*/.libs/", 0);
		s=g_strdup_printf("%s/../locale", buffer);	
		setenv("NAVIT_LOCALEDIR", s, 0);
		g_free(s);
	} else {
		if (!getenv("NAVIT_PREFIX")) {
			l=strlen(argv[0]);
			if (l > 10 && !strcmp(argv[0]+l-10,"/bin/navit")) {
				s=g_strdup(argv[0]);
				s[l-10]='\0';
				if (strcmp(s, PREFIX)) 
					printf(_("setting '%s' to '%s'\n"), "NAVIT_PREFIX", s);
				setenv("NAVIT_PREFIX", s, 0);
				g_free(s);
			} else 
				setenv("NAVIT_PREFIX", PREFIX, 0);
		}
		s=g_strdup_printf("%s/share/locale", getenv("NAVIT_PREFIX"));
		setenv("NAVIT_LOCALEDIR", s, 0);
		g_free(s);
		s=g_strdup_printf("%s/share/navit", getenv("NAVIT_PREFIX"));
		setenv("NAVIT_SHAREDIR", s, 0);
		g_free(s);
		s=g_strdup_printf("%s/lib/navit", getenv("NAVIT_PREFIX"));
		setenv("NAVIT_LIBDIR", s, 0);
		g_free(s);
	}
        bindtextdomain( "navit", getenv("NAVIT_LOCALEDIR"));
	textdomain( "navit" );

	debug_init();
#if 0
	/* handled in gui/gtk */
	gtk_set_locale();
	gtk_init(&argc, &argv);
	gdk_rgb_init();
#endif
	s = getenv("NAVIT_WID");
	if (s) {
		setenv("SDL_WINDOWID", s, 0);
	}
	config_file=NULL;
	if (argc > 1) 
		config_file=argv[1];
	if (! config_file) {
		config_file=g_strjoin(NULL,get_home_directory(), "/.navit/navit.xml" , NULL);
		if (!file_exists(config_file)) {
			g_free(config_file);
			config_file=NULL;
			}
	}
	if (! config_file) {
		if (file_exists("navit.xml.local"))
			config_file="navit.xml.local";
	}
	if (! config_file) {
		if (file_exists("navit.xml"))
			config_file="navit.xml";
	}
	if (! config_file) {
		config_file=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL);
		if (!file_exists(config_file)) {
			g_free(config_file);
			config_file=NULL;
		}
	}
	if (! config_file) {
		config_file=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL);
		if (!file_exists(config_file)) {
			g_free(config_file);
			config_file=NULL;
		}
	}
	if (!config_file) {
		printf(_("No config file navit.xml, navit.xml.local found\n"));
		exit(1);
	}
	if (!config_load(config_file, &error)) {
		printf(_("Error parsing '%s': %s\n"), config_file, error->message);
		exit(1);
	} else {
		printf(_("Using '%s'\n"), config_file);
	}
	if (! navit) {
		printf(_("No instance has been created, exiting\n"));
		exit(1);
	}
	if (main_loop_gui) {
		gui_run_main_loop(main_loop_gui);
	} else {
#ifdef USE_GTK_MAIN_LOOP
		gtk_main();
#else
		loop = g_main_loop_new (NULL, TRUE);
		if (g_main_loop_is_running (loop))
		{
			g_main_loop_run (loop);
		}
#endif
	}

	return 0;
}
Exemplo n.º 17
0
int main(int argc, char *argv[]) {
    GtkWidget *window;
    GtkWidget *main_vbox;
    GtkWidget *menubar;
    GtkWidget *vbox;


    g_thread_init(NULL);
    gtk_init(&argc, &argv);
    gdk_init (&argc, &argv);
    gdk_rgb_init();


    //  buf= (unsigned char *)malloc (ROWS * COLS * DEPTH * sizeof (unsigned char));
    //if (!buf) {
    //	perror ("malloc buf");
//	exit(0);
    //  }

    open_dev(); /* abre e inicializa video */


    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect(GTK_OBJECT(window), "destroy",
                       GTK_SIGNAL_FUNC(gtk_main_quit), "WM destroy");

    gtk_window_set_title(GTK_WINDOW(window), "NutoScope");
    //gtk_widget_set_usize(GTK_WIDGET(window), COLS, ROWS);

    main_vbox = gtk_vbox_new(FALSE, 1);
    gtk_container_border_width(GTK_CONTAINER(main_vbox), 1);
    gtk_container_add(GTK_CONTAINER(window), main_vbox);
    gtk_widget_show(main_vbox);

    get_main_menu(window, &menubar);
    gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
    gtk_widget_show(menubar);


    darea = gtk_drawing_area_new();
    gtk_box_pack_start (GTK_BOX (main_vbox), darea, FALSE, FALSE, 0);
    gtk_signal_connect (GTK_OBJECT (darea), "expose-event", GTK_SIGNAL_FUNC (on_darea_expose), (gpointer) darea);
    gtk_drawing_area_size (GTK_DRAWING_AREA (darea), COLS, ROWS);
    gtk_widget_show(darea);

    status = gtk_statusbar_new ();
    gtk_box_pack_start (GTK_BOX (main_vbox), status, FALSE, FALSE, 0);
    context_id = gtk_statusbar_get_context_id(
                     GTK_STATUSBAR(status), "Ready");

    gtk_widget_show (status);



    gtk_widget_show(window);


    // load 50x50x3 logo
    logo_image=malloc(50*50*3);
    if (!logo_image) {
        perror("malloc logo ");
        exit;
    }
    load_pnm("logo.pnm", logo_image);
    // Queue frames

    for(frame=0; frame<grab_vm.frames; frame++) {
        grab_buf.frame = frame;
        if(ioctl(grab_fd, VIDIOCMCAPTURE, &grab_buf)<0) {
            perror("VIDIOCMCAPTURE");
            exit(-1);
        }
    }


    gtk_timeout_add(25, send_expose, NULL);

    gdk_threads_enter();
    gtk_main();
    gdk_threads_leave();

    return (0);
}
Exemplo n.º 18
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 */
Exemplo n.º 19
0
int main (int argc, char *argv[]) {
    /* a pointer to a window object - this is what we will draw on.
     */
    GdkWindow *window;

    /* a set of "attributes" for our windows. This struct holds things
     * like width, height etc.
     */
    GdkWindowAttr attributes;

    /* a bitmask of the attributes you actually want to read out of the
     * attributes thing above
     */
    gint attributes_mask;

    /* GDK apps need a main loop to wait for events and so forth. This main
     * loop has a struct which tells you about it called "GMainLoop". We need
     * one of them.
     */
    GMainLoop *mainloop;

    /* initialise gdk. We pass in argc and argv - it uses them for info like
     * display on X and so forth. Die if GDK can't initialize.
     * 
     * Always initialise gdk before working with it. Stuff breaks otherwise.
     */
    if (!gdk_init_check (&argc, &argv)) {
        return FALSE;
    }

    /* gdk_rgb_init() is a function which I can only guess sets up the
     * true colour colour map. It returns void so we can't check its
     * return value.
     */
    gdk_rgb_init();

    /* set the attributes for the window. Lets create a 400x400 top-level
     * window.
     */
    attributes.window_type = GDK_WINDOW_TOPLEVEL;
    attributes.width = 400;
    attributes.height = 400;
    attributes.wclass = GDK_INPUT_OUTPUT;

    /* Get a true-colour colour map. GDK also supports indexed colour maps
     * but they aren't so interesting for us.
     */
    attributes.colormap = gdk_rgb_get_cmap ();

    /* set our mask so that the "colormap" element is used.
     */
    attributes_mask = GDK_WA_COLORMAP;

    /* create the window.
     */
    window = gdk_window_new (NULL, &attributes, attributes_mask);

    /* show the window.
     */
    gdk_window_show (window);

    /* Create a new main loop object. The True is to say that the structure
     * should be initialised to say that it is running.
     */
    mainloop = g_main_new (TRUE);

    /* Run that main loop
     */
    g_main_run (mainloop);
}
Exemplo n.º 20
0
int
main (int argc, char *argv[])
{
	GtkWidget *Universe_Viewer_2;

	int i, pid;
	char mess[32];
	pid=cree_fils(loading,0);
  gtk_set_locale ();
  gtk_init (&argc, &argv);
	//buff = g_strdup_printf ("Waiting ...");
	gdk_rgb_init();
  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");

	AGE_CST=(100.0/9.78)*h;
	read_quasar = read_txt_quasar;
	get_nb_quasar = get_txt_nb_quasar;

	data_filename=(char *) calloc(256,sizeof(char));
	if(argc==2) strcpy(data_filename,argv[1]);
	else strcpy(data_filename,"data/Burbridge.txt");
	init_abacus ();
	data_lenght = get_txt_nb_quasar (data_filename);
	data_lenght_max = data_lenght;
	quasar_pos 	= (Vector *) malloc(data_lenght*sizeof(Vector));
	quasar		= (Quasar *) malloc(data_lenght*sizeof(Quasar));
	graphT		= (Point*) malloc((data_lenght+1)*sizeof(Point));



	read_txt_quasar (data_filename,quasar);

	data_lenght=data_size;
		sprintf(mess,"%d objets lus\n", data_lenght);
	calc_quasar_tau (quasar, graphT);
	calc_quasar_pos(quasar,quasar_pos);
	init_projection_vectors ();
	init_graph();

	for(i=0;i<NBVIEWS;i++)
	{
		quasar_proj[i] =set_quasar_proj (quasar_pos,i);
		the_earth[i]=set_earth_proj(earth,i);
	}

	Universe_Viewer_2 = create_Universe_Viewer_2 (quasar_proj);
	kill(pid,SIGINT);
	gtk_widget_show (Universe_Viewer_2);
	alerte(mess);
	gtk_main();

	// penser à faire le ménage !!!

		free(grapheC0g);
		free(grapheC1g);
		free(grapheC2g);
		free(grapheC31g);
		free(grapheC32g);
		free(grapheC4g);

		//gtk_widget_destroy(Universe_Viewer_2);

	return 0;
}
Exemplo n.º 21
0
int
main (int argc, char *argv[])
{
  DVDResult_t res;
  char *msgq_str;
  program_name = argv[0];
#ifdef ENABLE_NLS
  setlocale(LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);
#endif
  if(argc==1) {
    fprintf(stderr, "Error: Do not start ogle_gui directly. Start ogle\n");
    exit(1);
  }
  if(pipe(dvdpipe)) {
    FATAL("dvdpipe: %s", strerror(errno));
    exit(1);
  }

  msgq_str = argv[2];
  
  init_interpret_config(program_name,
			add_keybinding,
			set_dvd_path);

  interpret_config();
  
  gtk_init(&argc, &argv);

  dvdpipe_handler_id = gtk_input_add_full(dvdpipe[0],
					  GDK_INPUT_READ,
					  dvdpipe_handler,
					  NULL, NULL, NULL);
  // Make Solaris 8+24 displays work
  gdk_rgb_init();
  gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
  gtk_widget_set_default_visual(gdk_rgb_get_visual());
  
  // Initialize glade, and read in the glade file
  my_glade_setup();

  res = DVDOpenNav(&nav, msgq_str);
  if(res != DVD_E_Ok ) {
    DVDPerror("DVDOpen", res);
    exit(1);
  }
  
  xsniff_init(msgq_str);
  
  audio_menu_new();
  subpicture_menu_new();
  
  app = get_glade_widget("app");
  gtk_widget_show(app);

  menu_new(app);  
  
  // If a filename is given on the command line,  start immediately.
  if(argc == 4) {
    res = DVDSetDVDRoot(nav, argv[3]);
    if(res != DVD_E_Ok) {
      DVDPerror("main: DVDSetDVDRoot", res);
    }
    autoload_bookmark();
  }
  
  gtk_main ();
  return 0;
}
Exemplo n.º 22
0
int
main (int argc, char **argv)
{
	int i;
	int found_valid = FALSE;

	GdkPixbuf *pixbuf;
	GdkPixbufLoader *pixbuf_loader;

	gtk_init (&argc, &argv);

	gdk_rgb_set_verbose (TRUE);

	gdk_rgb_init ();

	gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
	gtk_widget_set_default_visual (gdk_rgb_get_visual ());

	{
		char *tbf_readlen = getenv("TBF_READLEN");
		if(tbf_readlen) readlen = atoi(tbf_readlen);
	}

	{
		char *tbf_bps = getenv("TBF_KBPS");
		guint bps;

		if (tbf_bps) {
			bps = atoi(tbf_bps);
			g_print ("Simulating %d kBytes/sec\n", bps);
			readlen = (bps*1024)/10;
		}
	}

	i = 1;
	if (argc == 1) {
                const gchar*** xpmp;
                
		pixbuf = gdk_pixbuf_new_from_data (default_image, GDK_COLORSPACE_RGB, FALSE, 8,
						   DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3,
						   NULL, NULL);
		new_testrgb_window (pixbuf, NULL);

                xpmp = xpms;
                while (*xpmp) {
                        pixbuf = gdk_pixbuf_new_from_xpm_data (*xpmp);
                        new_testrgb_window (pixbuf, NULL);
                        ++xpmp;
                }
                
		found_valid = TRUE;
	} else {
		for (i = 1; i < argc; i++) {

			pixbuf = gdk_pixbuf_new_from_file (argv[i]);
#if 0
			pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
#endif

			if (pixbuf) {
				new_testrgb_window (pixbuf, "File");
				found_valid = TRUE;
			}
		}
#if 1
                {
                        GtkWidget* rgb_window = NULL;
			ProgressFileStatus   status;

                        pixbuf_loader = gdk_pixbuf_loader_new ();
			status.loader = pixbuf_loader;

			status.rgbwin = &rgb_window;

			status.buf = g_malloc (readlen);
                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
                                           "area_prepared",
                                           GTK_SIGNAL_FUNC(progressive_prepared_callback),
                                           &rgb_window);

                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
                                           "area_updated",
                                           GTK_SIGNAL_FUNC(progressive_updated_callback),
                                           &rgb_window);

			
                        status.imagefile = fopen (argv[1], "r");
                        g_assert (status.imagefile != NULL);

			status.readlen = readlen;

                        status.timeout = gtk_timeout_add(100, update_timeout, &status);
                }
#endif
	}

	if (found_valid)
		gtk_main ();

	return 0;
}
Exemplo n.º 23
0
Arquivo: ui.c Projeto: barak/gtkboard
void gui_init ()
{
	GtkWidget *hbox = NULL, *vbox = NULL, *vbox1 = NULL, *frame = NULL;
	GtkWidget *separator;
	GtkAccelGroup *ag;
	GtkItemFactoryEntry game_items [num_games+1];
	GtkItemFactoryEntry items[] = 
	{
#if GTK_MAJOR_VERSION == 1
/*		{ "/_File", NULL, NULL, 0, "<Branch>" },
		{ "/File/_Load game", "<control>L", menu_load_file_dialog, 0, "" },
		{ "/File/_Save game", NULL, NULL, 0, "" },
		{ "/File/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, "" },
*/
		{ "/_Game", NULL, NULL, 0, "<Branch>" },
		{ "/Game/Select _Game", NULL, NULL, 0, "<LastBranch>" },
		{ "/Game/_Levels", NULL, NULL, 0, "<Branch>"},
		{ "/Game/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_New", "<control>N", menu_start_stop_game, MENU_RESET_GAME, "" },
		{ "/Game/_Start", "<control>G", menu_start_stop_game, MENU_START_GAME, "" },
		{ "/Game/_Pause", "<control>P", menu_start_stop_game, MENU_STOP_GAME, "" },
		{ "/Game/Sep2", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_Highscores", NULL, prefs_show_scores, 0, ""},
		{ "/Game/_Zap Highscores", NULL, prefs_zap_highscores, 0, ""},
		{ "/Game/Sep3", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, "" },
		{ "/_Move", NULL, NULL, 0, "<Branch>" },
		{ "/Move/_Back", "<control>B", menu_back_forw, MENU_BACK, "" },
		{ "/Move/_Forward", "<control>F", menu_back_forw, MENU_FORW, "" },
		{ "/Move/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Move/_Move Now", "<control>M", 
			(GtkItemFactoryCallback) ui_move_now_cb, 0, "" },
#else
/*		{ "/_File", NULL, NULL, 0, "<Branch>" },
		{ "/File/_Load game", "<control>L", menu_load_file_dialog, 0, 
				"<StockItem>", GTK_STOCK_OPEN },
		{ "/File/_Save game", NULL, menu_save_file_dialog, 0, 
				"<StockItem>", GTK_STOCK_SAVE },
		{ "/File/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, 
				"<StockItem>", GTK_STOCK_QUIT },
*/
		{ "/_Game", NULL, NULL, 0, "<Branch>" },
		{ "/Game/Select _Game", NULL, NULL, 0, "<LastBranch>" },
		{ "/Game/Levels", NULL, NULL, 0, "<Branch>"},
		{ "/Game/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_New", "<control>N", menu_start_stop_game, MENU_RESET_GAME, 
				"<StockItem>", GTK_STOCK_NEW },
		{ "/Game/_Start", "<control>G", menu_start_stop_game, MENU_START_GAME, 
				"<StockItem>", GTK_STOCK_YES  },
		{ "/Game/_Pause", "<control>P", menu_start_stop_game, MENU_STOP_GAME, 
				"<StockItem>", GTK_STOCK_STOP },
		{ "/Game/Sep2", NULL, NULL, 0, "<Separator>" },
		//FIXME: there's a scores stock item but I can't seem to find it
		{ "/Game/_Highscores", NULL, prefs_show_scores, 0, ""},
		{ "/Game/_Zap Highscores", NULL, prefs_zap_highscores, 0, ""},
		{ "/Game/Sep3", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, 
				"<StockItem>", GTK_STOCK_QUIT },
		{ "/_Move", NULL, NULL, 0, "<Branch>" },
		{ "/Move/_Back", "<control>B", menu_back_forw, 1, 
				"<StockItem>", GTK_STOCK_GO_BACK },
		{ "/Move/_Forward", "<control>F", menu_back_forw, 2, 
				"<StockItem>", GTK_STOCK_GO_FORWARD },
		{ "/Move/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Move/_Move Now", "<control>M", 
			(GtkItemFactoryCallback) ui_move_now_cb, 0, "" },
#endif
		{ "/_Settings", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/_Player", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/Player/File", NULL, NULL, 0, "<RadioItem>" },
		{ "/Settings/Player/Human-Human", NULL, menu_set_player, 1, "/Settings/Player/File" },
		{ "/Settings/Player/Human-Machine", NULL, menu_set_player, 2, 
									"/Settings/Player/File" },
		{ "/Settings/Player/Machine-Human", NULL, menu_set_player, 3, 
									"/Settings/Player/File" },
		{ "/Settings/Player/Machine-Machine", NULL, menu_set_player, 4, 
									"/Settings/Player/File" },
//		{ "/Settings/_Eval function", NULL, NULL, 0, "<Branch>" },
//		{ "/Settings/_Eval function/_White", NULL, NULL, 0, "<Branch>" },
//		{ "/Settings/_Eval function/_Black", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/_Flip Board", "<control>T", menu_board_flip_cb, 0, "" },
		{ "/Settings/_Enable Sound", NULL, menu_enable_sound_cb, 1, ""},
		{ "/Settings/_Disable Sound", NULL, menu_enable_sound_cb, 0, ""},
		{ "/Settings/_Time per move", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/_Time per move/Default", NULL, 
			menu_set_delay_cb, DEF_TIME_PER_MOVE, "<RadioItem>" },
		{ "/Settings/_Time per move/100 milliseconds", NULL, 
			menu_set_delay_cb, 100, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/200 milliseconds", NULL, 
			menu_set_delay_cb, 200, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/500 milliseconds", NULL, 
			menu_set_delay_cb, 500, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/1 second", NULL, 
			menu_set_delay_cb, 1000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/2 seconds", NULL, 
			menu_set_delay_cb, 2000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/5 seconds", NULL, 
			menu_set_delay_cb, 5000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/10 seconds", NULL, 
			menu_set_delay_cb, 10000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/30 seconds", NULL, 
			menu_set_delay_cb, 30000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/1 minute", NULL, 
			menu_set_delay_cb, 600000, "/Settings/Time per move/Default" },
		{ "/_Help", NULL, NULL, 0, "<Branch>" },
		{ "/Help/_About", NULL, menu_show_about_dialog, 0, ""},
#ifdef HAVE_GNOME
		{ "/Help/_Home Page", NULL, menu_help_home_page, 0, "<StockItem>", GTK_STOCK_HOME},
#endif
		// TODO: implement context help
//		{ "/Help/_Context help", NULL, ui_set_context_help, 0, ""},
	};
	int i;
	gdk_rgb_init ();
	main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_policy (GTK_WINDOW (main_window), FALSE, FALSE, TRUE);
	gtk_signal_connect (GTK_OBJECT (main_window), "delete_event",
		GTK_SIGNAL_FUNC(ui_cleanup), NULL);
	gtk_window_set_title (GTK_WINDOW (main_window), "Gtkboard");

	ag = gtk_accel_group_new();
	menu_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", ag);
	gtk_window_add_accel_group (GTK_WINDOW (main_window), ag);
			
	gtk_item_factory_create_items (menu_factory, 
			sizeof (items) / sizeof (items[0]), items, NULL);
	for (i=0; i<=num_games; i++)
	{
		if (i==0) 
			game_items[i].path = "/Game/Select Game/none";
		else 
		{
			if (games[i-1]->group)
			{
				GtkItemFactoryEntry group_item = {NULL, NULL, NULL, 0, "<Branch>"};
				group_item.path = g_strdup_printf ("/Game/Select Game/%s",
						games[i-1]->group);
				// FIXME: this is O(N^2) where N is the number of games
				if (gtk_item_factory_get_widget (menu_factory, group_item.path) == NULL)
					gtk_item_factory_create_item (menu_factory, &group_item, NULL, 1);
				game_items[i].path = g_strdup_printf ("/Game/Select Game/%s/%s",
					games[i-1]->group ? games[i-1]->group : "", games[i-1]->name);
			}
			else
				game_items[i].path = g_strdup_printf ("/Game/Select Game/%s",
						games[i-1]->name);
		}
		game_items[i].accelerator = NULL;
		game_items[i].callback = menu_set_game;
		game_items[i].callback_action = i-1;
		game_items[i].item_type = (i == 0 ? "<RadioItem>": "/Game/Select Game/none");
	}
	gtk_item_factory_create_items (menu_factory, 
			num_games+1, game_items, NULL);
	// ugly hack to create a group of radio button with no button selected by default
	gtk_item_factory_delete_item (menu_factory, "/Game/Select Game/none");

	menu_main = gtk_item_factory_get_widget (menu_factory, "<main>");
	gtk_widget_set_state (gtk_item_factory_get_widget (menu_factory, 
				"/Settings/Player/File"), GTK_STATE_INSENSITIVE);

	for (i=1; i<=NUM_RECENT_GAMES; i++)
	{
		gchar *tmp;
		gchar *gamename;
		gamename = prefs_get_config_val (tmp = g_strdup_printf ("recent_game_%d", i));
		g_free (tmp);
		if (gamename && gamename[0] != '\0')
			menu_insert_game_item (gamename, i);
	}

	menu_set_eval_function ();
	vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX(vbox), menu_main, FALSE, FALSE, 0);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);

	{
	GtkWidget *innerframe;
	board_colbox = gtk_vbox_new (FALSE, 0);
	board_area = gtk_drawing_area_new ();
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), board_colbox, FALSE, FALSE, 0);
	vbox1 = gtk_vbox_new (FALSE, 0);
	board_rowbox = gtk_hbox_new (FALSE, 0);
	innerframe = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (innerframe), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (vbox1), innerframe);
	gtk_container_add (GTK_CONTAINER (innerframe), board_area);
	gtk_container_add (GTK_CONTAINER (vbox1), board_rowbox);
	gtk_box_pack_start (GTK_BOX (hbox), vbox1, TRUE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER (frame), hbox);

	gtk_signal_connect (GTK_OBJECT (board_area), "expose_event",
		GTK_SIGNAL_FUNC (board_redraw), NULL);

   	gtk_widget_set_events(board_area, 
			gtk_widget_get_events (board_area) 
			|   GDK_BUTTON_PRESS_MASK
			|   GDK_BUTTON_RELEASE_MASK
			|   GDK_POINTER_MOTION_MASK
			|   GDK_KEY_PRESS_MASK
			|	GDK_KEY_RELEASE_MASK
			|	GDK_LEAVE_NOTIFY_MASK
			);

	gtk_signal_connect (GTK_OBJECT (board_area), "leave_notify_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (board_area), "motion_notify_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (board_area), "button_release_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (board_area), "button_press_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (main_window), "key_press_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (main_window), "key_release_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	menu_info_bar = hbox = gtk_hbox_new (FALSE, 0);
	sb_game_label = gtk_label_new (opt_game ? opt_game->name : NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_game_label, FALSE, FALSE, 3);
	sb_game_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_game_separator, FALSE, FALSE, 0);
	sb_player_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_player_label, FALSE, FALSE, 3);
	sb_player_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_player_separator, FALSE, FALSE, 0);
	sb_who_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_who_label, FALSE, FALSE, 3);
	sb_who_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_who_separator, FALSE, FALSE, 0);
	sb_score_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_score_label, FALSE, FALSE, 3);
	sb_score_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_score_separator, FALSE, FALSE, 0);
#if GTK_MAJOR_VERSION == 2
	sb_turn_image = gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_MENU);
	gtk_box_pack_end (GTK_BOX (hbox), sb_turn_image, FALSE, FALSE, 0);
	sb_turn_separator = gtk_vseparator_new ();
	gtk_box_pack_end (GTK_BOX (hbox), sb_turn_separator, FALSE, FALSE, 0);
#endif
	sb_time_label = gtk_label_new (NULL);
	gtk_box_pack_end (GTK_BOX (hbox), sb_time_label, FALSE, FALSE, 0);
	sb_time_separator = gtk_vseparator_new ();
	gtk_box_pack_end (GTK_BOX (hbox), sb_time_separator, FALSE, FALSE, 0);
	}
			
	menu_info_separator = separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	menu_warning_bar = gtk_label_new ("Warning: this game has not yet been completely implemented.");
	gtk_box_pack_start (GTK_BOX (vbox), menu_warning_bar, FALSE, FALSE, 0);
	sb_warning_separator = separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
	separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	sb_message_label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (sb_message_label), 0, 0.5);
	hbox = gtk_hbox_new (TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), sb_message_label, TRUE, TRUE, 3);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER (main_window), vbox);
	// FIXME: board_init() needs show() to be called to get a gc, but
	// leads to the whole window not popping up at once
	gtk_widget_show_all (main_window);
	
	if (!opt_game) board_init ();

	gtk_timeout_add (100, sb_update_periodic, NULL);

	// this should be called before setting state_gui_active = TRUE
	if (opt_game) menu_put_game (); 
	state_gui_active = TRUE;

	if (opt_game) menu_start_game ();
	menu_put_player (TRUE);
//	if (!opt_game) sb_message ("Select a game from the Game menu", FALSE);
	sb_update ();
}
Exemplo n.º 24
0
int
fe_args (int argc, char *argv[])
{
#ifdef USE_GNOME
    struct poptOption options[] = {
        {"cfgdir", 'd', POPT_ARG_STRING, 0, 0, _("Config dir"), 0},
        {"noauto", 'a', POPT_ARG_NONE, 0, 0, _("Don't Auto connect"), 0},
#ifdef USE_PANEL
        {"no-panel", 'n', POPT_ARG_NONE, 0, 0, _("Don't use GNOME Panel"), 0},
#endif
        POPT_AUTOHELP {0, '\0', 0, 0}
    };
#endif

    if (argc > 1)
    {
        if (!strcasecmp (argv[1], "-a") || !strcasecmp (argv[1], "--noauto"))
        {
            auto_connect = 0;
        }
#ifdef USE_PANEL
        if (!strcasecmp (argv[1], "-n") || !strcasecmp (argv[1], "--no-panel"))
        {
            nopanel = TRUE;
        }
#endif
        if (!strcasecmp (argv[1], "-v") || !strcasecmp (argv[1], "--version"))
        {
            printf (PACKAGE" "VERSION"\n");
            return 0;
        }
#ifndef USE_GNOME
#ifdef ENABLE_NLS
        bindtextdomain (PACKAGE, PREFIX"/share/locale");
        textdomain (PACKAGE);
#endif
        if (!strcasecmp (argv[1], "-h") || !strcasecmp (argv[1], "--help"))
        {
            printf(_("%s %s Options:\n\n"
                     "   --cfgdir <dir> -d\t : use a different config dir\n"
                     "   --noauto       -a\t : don't auto connect\n"
                     "   --version      -v\t : show version information\n"
                    ), PACKAGE, VERSION);
            return 0;
        }
#endif
    }
#ifdef ENABLE_NLS
#ifdef USE_GNOME
    bindtextdomain (PACKAGE, PREFIX"/share/locale");
    textdomain (PACKAGE);
#endif
#endif

    if (argc > 2)
    {
        if (!strcasecmp (argv[1], "-d") || !strcasecmp (argv[1], "--cfgdir"))
        {
            xdir = strdup (argv[2]);
            if (xdir[strlen (xdir) - 1] == '/')
                xdir[strlen (xdir) - 1] = 0;
        }
    }

#ifndef USE_GNOME
    gtk_set_locale ();
#endif

#ifdef USE_PANEL
    if (nopanel)
        gnome_init_with_popt_table (argv[0], VERSION, argc, argv, options, 0, 0);
    else {
        CORBA_Environment ev;
        CORBA_exception_init (&ev);

        gnome_CORBA_init_with_popt_table (argv[0], VERSION,
                                          &argc, argv, options, 0, 0,
                                          GNORBA_INIT_SERVER_FUNC, &ev);
        CORBA_exception_free (&ev);
    }
#else
#ifdef USE_GNOME
    gnome_init_with_popt_table (argv[0], VERSION, argc, argv, options, 0, 0);
#else
    gtk_init (&argc, &argv);
#endif
#endif

#ifndef USE_GNOME
#ifdef USE_GDK_PIXBUF
    gdk_rgb_init();
#endif
#endif

#ifdef USE_XLIB
    proxy_invisible = gtk_invisible_new ();
    gtk_widget_show (proxy_invisible);

    /* Make the root window send events to the invisible proxy widget */
    gdk_window_set_user_data (GDK_ROOT_PARENT (), proxy_invisible);

    /* Select for PropertyNotify events from the root window */
    XSelectInput (GDK_DISPLAY (), GDK_ROOT_WINDOW (), PropertyChangeMask);

    gtk_signal_connect (GTK_OBJECT (proxy_invisible), "property-notify-event",
                        GTK_SIGNAL_FUNC (handle_property_notify), NULL);
#endif

    return 1;
}
Exemplo n.º 25
0
int main( int   argc, 
          char *argv[] )
{
  GtkWidget *window;
  GtkWidget *vbox;
  char buf[G_ASCII_DTOSTR_BUF_SIZE];

  GtkWidget *button;
  GtkWidget *entry;

  gtk_init (&argc, &argv);

  gdk_rgb_init();

  pos_x[0] = 100;
  pos_y[0] = 100;
  pos_x[1] = 300;
  pos_y[1] = 300;
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (window, "Test Input");

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  gtk_signal_connect (GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC (quit), NULL);

  /* Create the drawing area */

  drawing_area = gtk_drawing_area_new ();
  gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 512, 512);
  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /* Signals used to handle backing pixmap */

  gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
		      (GtkSignalFunc) expose_event, NULL);
  gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event",
		      (GtkSignalFunc) configure_event, NULL);

  /* Event signals */

  gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event",
		      (GtkSignalFunc) motion_notify_event, NULL);
  gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event",
		      (GtkSignalFunc) button_press_event, NULL);

  gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
			 | GDK_LEAVE_NOTIFY_MASK
			 | GDK_BUTTON_PRESS_MASK
			 | GDK_POINTER_MOTION_MASK
			 | GDK_POINTER_MOTION_HINT_MASK);

  
  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_gradient),
		      &a);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE,
				       1.0/a));
  gtk_widget_show (entry);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_gradient),
		      &b);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE,
				       1.0/b));
  gtk_widget_show (entry);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_gradient),
		      &c);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE,
				       1.0/c));
  gtk_widget_show (entry);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_spread),
		      &spread);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_strdup_printf ("%d", spread));
  gtk_widget_show (entry);

  
  /* .. And a quit button */
  button = gtk_button_new_with_label ("Quit");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (window));
  gtk_widget_show (button);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
Exemplo n.º 26
0
int
main (int argc, char **argv)
{
	int i;
	int found_valid = FALSE;

	GdkPixbufAnimation *animation;

	gtk_init (&argc, &argv);

	gdk_rgb_set_verbose (TRUE);

	gdk_rgb_init ();

	gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
	gtk_widget_set_default_visual (gdk_rgb_get_visual ());

	{
		char *tbf_readlen = getenv("TBF_READLEN");
		if(tbf_readlen) readlen = atoi(tbf_readlen);
	}

	{
		char *tbf_bps = getenv("TBF_KBPS");
		guint bps;

		if (tbf_bps) {
			bps = atoi(tbf_bps);
			g_print ("Simulating %d kBytes/sec\n", bps);
			readlen = (bps*1024)/10;
		}
	}

	i = 1;
	if (argc == 1) {
		g_print ("USAGE:  testanimation FILE1 ...\n");
		return 0;
	} else {
		for (i = 1; i < argc; i++) {
			animation = gdk_pixbuf_animation_new_from_file (argv[i]);

			if (animation) {
				gint i = 0;
				GList *listptr;
				for (listptr = gdk_pixbuf_animation_get_frames (animation);
				     listptr;
				     listptr = listptr->next) {
					GdkPixbufFrame *frame;
					GdkPixbuf *pixbuf;
					gchar *title;

					frame = listptr->data;
					pixbuf = gdk_pixbuf_frame_get_pixbuf (frame);

					title = g_strdup_printf ("Frame %d", i);
					g_print ("Frame %d  x:%d y:%d width:%d height:%d\n",
						 i,
						 gdk_pixbuf_frame_get_x_offset (frame),
						 gdk_pixbuf_frame_get_y_offset (frame),
						 gdk_pixbuf_get_width (pixbuf),
						 gdk_pixbuf_get_height (pixbuf));
					new_testrgb_window (pixbuf, title);
					g_free (title);
					i++;
				}
				found_valid = TRUE;
			}
		}
#if 0
                {
                        GtkWidget* rgb_window = NULL;
			ProgressFileStatus   status;
			GdkPixbufLoader *pixbuf_loader;

                        pixbuf_loader = gdk_pixbuf_loader_new ();
			status.loader = pixbuf_loader;

			status.rgbwin = &rgb_window;

			status.buf = g_malloc (readlen);
                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
                                           "area_prepared",
                                           GTK_SIGNAL_FUNC(progressive_prepared_callback),
                                           &rgb_window);

                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
                                           "area_updated",
                                           GTK_SIGNAL_FUNC(progressive_updated_callback),
                                           &rgb_window);

			
                        status.imagefile = fopen (argv[1], "r");
                        g_assert (status.imagefile != NULL);

			status.readlen = readlen;

                        status.timeout = gtk_timeout_add(100, update_timeout, &status);
                }
#endif
	}

	if (found_valid)
		gtk_main ();

	return 0;
}
Exemplo n.º 27
0
Arquivo: leak.c Projeto: s7ephen/leak
int main (int argc, char **argv)
{
	GtkWidget *window, *table, *portplot_area_container, *countplot_area_container, *buttonbox;				// Containers
	GtkWidget *portplot, *countplot, *zoom, *zoomlabel, *soundonoff, *soundlabel, *about, *quit;	// Actual buttons
	gint x, y;
	guchar *pos;

	// Initialize variables
	packetcount = 0;
	sound_fd = -1;
	sound_onoff = FALSE;
	zoom_onoff = FALSE;
	

	//gnome_init("leak", VERSION, argc, argv);
	gtk_init(&argc, &argv);
	gdk_rgb_init();

	// Initialize the window
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW (window), "The leak");
	gtk_signal_connect(GTK_OBJECT (window), 
			"delete_event", 
			GTK_SIGNAL_FUNC(delete_event_close), 
			NULL);

	// Set up containers
	table = gtk_table_new(4, 1, FALSE);
	gtk_container_add(GTK_CONTAINER (window), table);

	buttonbox = gtk_vbox_new(FALSE, 0);
	gtk_table_attach(GTK_TABLE (table),
			buttonbox,
			3, 4,
			0, 1,
			GTK_FILL,
			GTK_FILL,
			0,
			0);

	// Set up drawing areas
	countplot_area_container = gtk_event_box_new();
	countplot = gtk_drawing_area_new();
	gtk_container_add(GTK_CONTAINER (countplot_area_container), countplot);
	gtk_container_set_border_width(GTK_CONTAINER (countplot_area_container), 2);
	gtk_drawing_area_size(GTK_DRAWING_AREA (countplot), 
				PORT_WIDTH, 
				PORT_HEIGHT);
	gtk_signal_connect(GTK_OBJECT (countplot), 
			"expose-event",
			GTK_SIGNAL_FUNC (on_countplot_expose), 
			NULL);
	gtk_table_attach(GTK_TABLE (table),
			countplot_area_container,
			0, 1,
			0, 1,
			GTK_FILL,
			GTK_FILL,
			0,
			0);

	portplot_area_container = gtk_event_box_new();
	portplot = gtk_drawing_area_new();
	gtk_container_add(GTK_CONTAINER (portplot_area_container), portplot);
	gtk_container_set_border_width(GTK_CONTAINER (portplot_area_container), 2);
	gtk_drawing_area_size(GTK_DRAWING_AREA (portplot), 
				PORT_WIDTH, 
				PORT_HEIGHT);
	gtk_signal_connect(GTK_OBJECT (portplot), 
			"expose-event",
			GTK_SIGNAL_FUNC (on_portplot_expose), 
			NULL);
	gtk_signal_connect(GTK_OBJECT (portplot_area_container),
			"button_press_event",
			GTK_SIGNAL_FUNC (grap_location),
			NULL);
	gtk_table_attach(GTK_TABLE (table),
			portplot_area_container,
			1, 2,
			0, 1,
			GTK_FILL,
			GTK_FILL,
			0,
			0);

	// Zoom button
	zoomlabel = gtk_label_new("Zoom In");
	zoom = gtk_button_new();
	gtk_container_add(GTK_CONTAINER (zoom), zoomlabel);
	gtk_box_pack_start(GTK_BOX (buttonbox),
			zoom,
			FALSE,
			FALSE,
			0);
	gtk_container_set_border_width(GTK_CONTAINER (zoom), 0);
	gtk_signal_connect(GTK_OBJECT (zoom),
			"clicked",
			GTK_SIGNAL_FUNC(change_zoom_state),
			zoomlabel);

	// Sound button
	soundlabel = gtk_label_new("Activate\nAudio");
	soundonoff = gtk_button_new();
	gtk_container_add(GTK_CONTAINER (soundonoff), soundlabel);
	gtk_container_set_border_width(GTK_CONTAINER (soundonoff), 0);
	gtk_box_pack_start(GTK_BOX (buttonbox),
			soundonoff,
			FALSE,
			FALSE,
			0);
	gtk_signal_connect(GTK_OBJECT (soundonoff),
			"clicked",
			GTK_SIGNAL_FUNC(change_sound_state),
			soundlabel);

	// About button
	// Commented out for lack of Gnome support
	/*
	about = gtk_button_new_with_label("About...");
	gtk_container_set_border_width(GTK_CONTAINER (about), 0);
	gtk_box_pack_start(GTK_BOX (buttonbox),
			about,
			FALSE,
			FALSE,
			0);
	gtk_signal_connect(GTK_OBJECT (about),
			"clicked",
			GTK_SIGNAL_FUNC(display_about),
			NULL);
	*/

	// Quit button
	quit = gtk_button_new_with_label("Quit");
	gtk_container_set_border_width(GTK_CONTAINER (quit), 0);
	gtk_box_pack_start(GTK_BOX (buttonbox),
			quit,
			FALSE,
			FALSE,
			0);
	gtk_signal_connect(GTK_OBJECT (quit),
			"clicked",
			GTK_SIGNAL_FUNC(delete_event_close),
			NULL);

	// Scroll bar
	scroll_params = gtk_adjustment_new(1.0,
					1,
					1,
					0,
					0,
					0);
	zoomscroll = gtk_vscrollbar_new(GTK_ADJUSTMENT (scroll_params));
	gtk_table_attach(GTK_TABLE (table),
			zoomscroll,
			2, 3,
			0, 1,
			GTK_FILL,
			GTK_FILL,
			0,
			0);
	gtk_range_set_update_policy(GTK_RANGE (zoomscroll),
				GTK_UPDATE_DISCONTINUOUS);
	gtk_signal_connect(GTK_OBJECT (scroll_params),
			"value_changed",
			GTK_SIGNAL_FUNC(change_scroll_value),
			portplot);
	gtk_widget_show_all (window);

	// The speed issues is due to the parameters passed
	// to open_live.  We have to optimize

	pcap_d = pcap_open_live("eth0",100,0,75,ebuf); 
  
	gtk_idle_add((GtkFunction)packet_received,portplot);
	gtk_timeout_add(200,(GtkFunction)decay_portplot,portplot); 
	gtk_timeout_add(3000, (GtkFunction)decay_countplot, countplot);
	gtk_main();
	return 0;
}
Exemplo n.º 28
0
int main(int argc, char **argv)
{
#if 0
        CORBA_Environment ev;
        CORBA_ORB orb;
	Map map_client = CORBA_OBJECT_NIL;
#endif
	char *gps;

	setenv("LC_NUMERIC","C",1);
	setlocale(LC_ALL,"");
	setlocale(LC_NUMERIC,"C");
	gtk_set_locale();
	setlocale(LC_NUMERIC,"C");
	debug_init();
	gtk_init(&argc, &argv);
	gdk_rgb_init();

// 	i18n basic support

	bindtextdomain( "navit", "./locale" );
	textdomain( "navit" );

	map_data_default=load_maps(NULL);
	plugin_load();
	co=gui_gtk_window(1300000,7000000,32);
	
	co->route=route_new();
	route_mapdata_set(co->route, co->map_data); 
	gps=getenv("GPSDATA");
	if (gps) {
		co->vehicle=vehicle_new(gps);
		if (co->vehicle) {
			co->cursor=cursor_new(co,co->vehicle);
			sdl_gui_new(co->vehicle);
		}
	} else {
		g_warning(gettext("Environment-Variable GPSDATA not set - No gps tracking. Set it to file:filename or gpsd://host[:port]"));
	}
	co->speech=speech_new();
	if (! co->speech) 
		g_warning(gettext("Can't connect to speechd, no speech output available"));
	speech_handle=co->speech;
	if (co->vehicle)
		co->compass=compass_new(co);
	if (co->vehicle)
		co->track=track_new(co->map_data);


#if 0
        CORBA_exception_init(&ev);
        orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);

        map_srv_start_poa(orb, &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);
        map_client = map_srv_start_object(&ev, map);
        retval = CORBA_ORB_object_to_string(orb, map_client, &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);
	ior=fopen("map.ior","w");
	if (ior) {
  		fprintf(ior, "%s\n", retval);
		fclose(ior);
	}
        CORBA_free(retval);
#endif

	initSDL();
	gtk_main();
	return 0;
}
Exemplo n.º 29
0
int main(int argc, char *argv[])
{
// Check for big files

#ifdef     __USE_LARGEFILE
#ifdef   __USE_LARGEFILE64
printf("\n LARGE FILE AVAILABLE : %d offset\n",  __USE_FILE_OFFSET64	);
#endif
#endif

/*
	Initialize Gettext if available
*/
#ifdef HAVE_DCGETTEXT
  setlocale (LC_ALL, "");

//#define ALOCALES "/usr/local/share/locale"
  bindtextdomain ("avidemux", ADMLOCALE);
  textdomain ("avidemux");
  printf("Locales for %s appear to be in %s\n","avidemux", ADMLOCALE);
  printf("\nI18N : %s \n",dgettext("avidemux","_File"));
#endif



// thx smurf uk :)
     signal(11, sig_segfault_handler); // show stacktrace on default

	printf("\n*******************\n");
	printf("  Avidemux 2, v  " VERSION "\n");
	printf("*******************\n");
	printf(" http://fixounet.free.fr/avidemux\n");
	printf(" Code      : Mean & JSC \n");
	printf(" GFX       : Nestor Di , [email protected]\n");
	printf(" Testing   : Jakub Misak\n");
	printf(" FreeBSD   : Anish Mistry, [email protected]\n");


#if (defined( ARCH_X86)  || defined(ARCH_X86_64))
	printf("Arcc X86 X86_64 activated.\n"); 	
#endif
   

#ifdef USE_XX_XVID_CVS
	printf("Probing XvidCVS library....\n");
 	dloadXvidCVS(  );
#endif
   VPInitLibrary();
   register_Encoders( );
    atexit(onexit);

#ifndef CYG_MANGLING    
    g_thread_init(NULL);
    gdk_threads_init();
#endif
    gdk_threads_enter();
    gtk_set_locale();
    gtk_init(&argc, &argv);
    gdk_rgb_init();
#ifdef USE_XVID_4
	xvid4_init();
#endif
        initFileSelector();
	CpuCaps::init();
	ADM_InitMemcpy();
	
// Load .avidemuxrc
    quotaInit();
    prefs->load();

   if(!initGUI())
    	{
		printf("\n Fatal : could not init GUI\n");
		exit(-1);	
	}

    video_body = new ADM_Composer;
#ifdef HAVE_ENCODER
     registerVideoFilters(  );
#endif
     
#ifdef USE_FFMPEG
  
                		avcodec_init();
	                 	avcodec_register_all();
				mpegps_init();
	                  
#endif
#ifdef HAVE_AUDIO
    AVDM_audioInit();
#endif    
    buildDistMatrix();
    initScaleTab();

    loadEncoderConfig();
    COL_init();
    
   
    if (argc >= 2)
    {
			  global_argc=argc;
			  global_argv=argv;
			  gtk_timeout_add( 300, (GtkFunction )automation, NULL );
				//automation();				
		}
   #ifdef USE_SDL
   	printf("Global SDL init...\n");
   	SDL_Init(0); //SDL_INIT_AUDIO+SDL_INIT_VIDEO);
   #endif
    oplug_mpegInit();
	if(SpidermonkeyInit() == true)
		printf("Spidermonkey initialized.\n");
	gtk_main();
	gdk_threads_leave();

    return 0;
}
Exemplo n.º 30
0
/*!
  Initialize the display size, position and title.

  \param w, h : Width and height of the window.
  \param x, y : The window is set at position x,y (column index, row index).
  \param title : Window title.

*/
void
vpDisplayGTK::init(unsigned int w, unsigned int h,
                   int x, int y,
                   const std::string &title)
{
  /* Initialisation of thegdk et gdk_rgb library */
  int *argc=NULL ;
  char **argv ;
  gtk_init(argc,&argv);

  this->width  = w;
  this->height = h;

  /* Create the window*/
  widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  gtk_widget_add_events(widget, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 
			| GDK_POINTER_MOTION_MASK);

  gtk_window_set_default_size(GTK_WINDOW(widget), (gint)width, (gint)height);

  if (x != -1)
    windowXPosition = x ;
  if (y != -1)
    windowYPosition = y ;

  gtk_window_move(GTK_WINDOW(widget), windowXPosition, windowYPosition);

  gtk_widget_show(widget);

  gdk_rgb_init();

  /* Create background pixmap */
  background = gdk_pixmap_new(widget->window, (gint)width, (gint)height, -1);

  /* Create graphic context */
  gc = gdk_gc_new(widget->window);

  /* get the colormap  */
  colormap = gdk_window_get_colormap(widget->window);

  col = new GdkColor *[vpColor::id_unknown] ; // id_unknown = number of predefined colors

  /* Create color */
  gdk_color_parse("light blue",&lightBlue);
  gdk_colormap_alloc_color(colormap,&lightBlue,FALSE,TRUE);
  col[vpColor::id_lightBlue] = &lightBlue ;
  
  gdk_color_parse("blue",&blue);
  gdk_colormap_alloc_color(colormap,&blue,FALSE,TRUE);
  col[vpColor::id_blue] = &blue ;
  
  gdk_color_parse("dark blue",&darkBlue);
  gdk_colormap_alloc_color(colormap,&darkBlue,FALSE,TRUE);
  col[vpColor::id_darkBlue] = &darkBlue ;
  
  gdk_color_parse("#FF8C8C",&lightRed);
  gdk_colormap_alloc_color(colormap,&lightRed,FALSE,TRUE);
  col[vpColor::id_lightRed] = &lightRed ;

  gdk_color_parse("red",&red);
  gdk_colormap_alloc_color(colormap,&red,FALSE,TRUE);
  col[vpColor::id_red] = &red ;
  
  gdk_color_parse("dark red",&darkRed);
  gdk_colormap_alloc_color(colormap,&darkRed,FALSE,TRUE);
  col[vpColor::id_darkRed] = &darkRed ;
  
  gdk_color_parse("light green",&lightGreen);
  gdk_colormap_alloc_color(colormap,&lightGreen,FALSE,TRUE);
  col[vpColor::id_lightGreen] = &lightGreen ;

  gdk_color_parse("green",&green);
  gdk_colormap_alloc_color(colormap,&green,FALSE,TRUE);
  col[vpColor::id_green] = &green ;
  
  gdk_color_parse("dark green",&darkGreen);
  gdk_colormap_alloc_color(colormap,&darkGreen,FALSE,TRUE);
  col[vpColor::id_darkGreen] = &darkGreen ;

  gdk_color_parse("yellow",&yellow);
  gdk_colormap_alloc_color(colormap,&yellow,FALSE,TRUE);
  col[vpColor::id_yellow] = &yellow ;

  gdk_color_parse("cyan",&cyan);
  gdk_colormap_alloc_color(colormap,&cyan,FALSE,TRUE);
  col[vpColor::id_cyan] = &cyan ;

  gdk_color_parse("orange",&orange);
  gdk_colormap_alloc_color(colormap,&orange,FALSE,TRUE);
  col[vpColor::id_orange] = &orange ;
  
  gdk_color_parse("purple",&purple);
  gdk_colormap_alloc_color(colormap,&purple,FALSE,TRUE);
  col[vpColor::id_purple] = &purple ;

  gdk_color_parse("white",&white);
  gdk_colormap_alloc_color(colormap,&white,FALSE,TRUE);
  col[vpColor::id_white] = &white ;

  gdk_color_parse("black",&black);
  gdk_colormap_alloc_color(colormap,&black,FALSE,TRUE);
  col[vpColor::id_black] = &black ;
  
  gdk_color_parse("#C0C0C0",&lightGray);
  gdk_colormap_alloc_color(colormap,&lightGray,FALSE,TRUE);
  col[vpColor::id_lightGray] = &lightGray ;
  
  gdk_color_parse("#808080",&gray);
  gdk_colormap_alloc_color(colormap,&gray,FALSE,TRUE);
  col[vpColor::id_gray] = &gray ;
  
  gdk_color_parse("#404040",&darkGray);
  gdk_colormap_alloc_color(colormap,&darkGray,FALSE,TRUE);
  col[vpColor::id_darkGray] = &darkGray ;

  // Try to load a default font
  font = gdk_font_load("-*-times-medium-r-normal-*-16-*-*-*-*-*-*-*");
  if (font == NULL)
    font = gdk_font_load("-*-courier-bold-r-normal-*-*-140-*-*-*-*-*-*");
  if (font == NULL)
    font = gdk_font_load("-*-courier 10 pitch-medium-r-normal-*-16-*-*-*-*-*-*-*");

  title_ = title;
  if(!title.empty())
    gdk_window_set_title(widget->window, title_.c_str());

  displayHasBeenInitialized = true ;
}