Exemplo n.º 1
0
/*** MAIN LOOP ***/
int main(int argc, char *argv[])
{
#if	DEBUG
	bmem = AvailMem( MEMF_PUBLIC );
#endif

	ParseArgs(&args, argc, argv);

	/* Look first if Jano isn't already running */
	if( find_janoed( &args ) ) cleanup(0, RETURN_OK);

	/* Some global initialization */
	init_searchtable();

	/* Optionnal libraries */
	AslBase      = (struct Library *)    OpenLibrary("asl.library",     36);
	LocaleBase   = (struct LocaleBase *) OpenLibrary("locale.library",  38);
	DiskfontBase = (struct Library *)    OpenLibrary("diskfont.library", 0);
	IFFParseBase = (struct Library *)    OpenLibrary("iffparse.library",36);

	if(LocaleBase) InitLocale();    /* Localize the prog */

	/* Open the required ROM libraries */
	if( (IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 36)) &&
	    (GfxBase       = (struct GfxBase *)       OpenLibrary("graphics.library",  36)) &&
	    (GadToolsBase  = (struct Library *)       OpenLibrary("gadtools.library",  36)) &&
	    (KeymapBase    = (struct Library *)       OpenLibrary("keymap.library",    36)) &&
		 (UtilityBase   = (struct UtilityBase *)   OpenLibrary("utility.library",   36)) )
	{
		init_macros();
		set_default_prefs(&prefs, IntuitionBase->ActiveScreen);
		
		load_prefs(&prefs, NULL);     /* See if it exists a config file */
		sigport = create_port();

		/* Create whether an empty project or an existing one */
		if( ( edit = create_projects(NULL, args.sa_ArgLst, args.sa_NbArgs) ) )
		{
			/* Open the main interface */
			if(setup() == 0)
			{
				/* Makes edit project visible */
				reshape_panel(edit);
				active_project(edit,TRUE);
				clear_brcorner();

				dispatch_events();

			} else cleanup(ErrMsg(ERR_NOGUI), RETURN_FAIL);
		}
	} else cleanup(ErrMsg(ERR_BADOS), RETURN_FAIL);

	/* Hope that all were well... */
	cleanup(0, RETURN_OK);
	
	return 0;
}
Exemplo n.º 2
0
/**
 * Program entry point. Initializes gtk+, calls the widget creating
 * functions and starts the main loop. Also connects 'popup-menu',
 * 'activate' and 'button-release-event' to the tray_icon.
 *
 * @param argc count of arguments
 * @param argv string array of arguments
 * @return 0 for success, otherwise error code
 */
int main (int argc, char *argv[]) {
  GError *error = NULL;
  GOptionContext *context;

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  DEBUG_PRINT("[Debugging Mode Build]\n");

  setlocale(LC_ALL, "");
  context = g_option_context_new (_("- A mixer for the system tray."));
  g_option_context_add_main_entries (context, args, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  g_option_context_parse (context, &argc, &argv, &error);
  gtk_init (&argc, &argv);

  g_option_context_free(context);


  if (version) {
    printf(_("%s version: %s\n"),PACKAGE,VERSION);
    exit(0);
  }

  popup_window = NULL;
  status_icons[0] = status_icons[1] = status_icons[2] = status_icons[3] = NULL;

  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
  add_pixmap_directory ("./pixmaps");

  ensure_prefs_dir();
  load_prefs();
  cards = NULL; // so we don't try and free on first run
  alsa_init();
  init_libnotify();
  create_popups();
  add_filter();

  tray_icon = create_tray_icon();
  apply_prefs(0);

  g_signal_connect(G_OBJECT(tray_icon), "popup-menu",G_CALLBACK(popup_callback), popup_menu);
  g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL);
  g_signal_connect(G_OBJECT(tray_icon), "button-release-event", G_CALLBACK(tray_icon_button), NULL);

  gtk_main ();
  uninit_libnotify();
  alsa_close();
  return 0;
}
gboolean
update (TBUnreadCount *tbunreadcount)
{
    int newDelay = tbunreadcount->prefs->delay;
    if(newDelay > 0 && newDelay != tbunreadcount->currentDelay)
    {
        start_update(tbunreadcount);
        return FALSE;
    }

    load_prefs(tbunreadcount->applet, tbunreadcount->prefs);

    update_display(tbunreadcount->hud, tbunreadcount->prefs);

    return TRUE;
}
Exemplo n.º 4
0
GameApp::GameApp()
{	
	load_prefs();
	theSound.SetSoundCallback(this, &GameManager::SoundEnded);
	screen = new AppScreen();
	sample = theSound.LoadSample("Resources/Sounds/click.ogg", false /*no stream*/);
	theWorld.NameLayer("background", 0);
	theWorld.NameLayer("objects", 1);
	theWorld.NameLayer("units", 2);
	theWorld.LoadLevel("level");
	BoundingBox bounds(Vector2(-20, -20), Vector2(20, 20));
	theSpatialGraph.CreateGraph(0.6f, bounds);
	Castle* castle = (Castle*)Actor::GetNamed("Castle");
	castle_health = new TextActor("Console", "Castle health: " + IntToString(castle->getHealth()), TXT_Center);
	castle_health->SetPosition(Vector2(-4.5f, 4.5f));
	theWorld.Add(castle_health);
	castle_cash = new TextActor("Console", "Castle cash: " + IntToString(castle->getCash()), TXT_Center);
	castle_cash->SetPosition(Vector2(-4.5f, 3.5f));
	theWorld.Add(castle_cash);
	std::thread interval(&GameApp::timer, this);
	interval.detach();
	_button = theUI.AddButton("Change tactics", Vec2i(90, 700), ButtonPress, true);
}
gboolean
tbunreadcount_applet_fill (PanelApplet *applet,
   const gchar *iid,
   gpointer data)
{
	if (strcmp (iid, "OAFIID:TBUnreadCountApplet") != 0)
		return FALSE;

    initialize_prefs(applet);
    
    TBUnreadCount *tbunreadcount = g_new0(TBUnreadCount, 1);
    tbunreadcount->applet = applet;

    tbunreadcount->hud = malloc(sizeof(HUD));
    init_display(tbunreadcount->hud, applet);

    tbunreadcount->prefs = malloc(sizeof(Prefs));
    load_prefs(tbunreadcount->applet, tbunreadcount->prefs);

    start_update(tbunreadcount);
	
	return TRUE;
}
Exemplo n.º 6
0
int
main (int argc, char **argv)
{
	int c;
	int ret;
	proz_init (argc, argv);	//init libprozilla
	set_defaults ();	//set some reasonable defaults
	load_prefs ();		//load values from the config file

	while ((c =
		getopt_long (argc, argv, "?hvrfk:1Lt:VgsP:", long_opts,
			     NULL)) != EOF)
	{
		switch (c)
		{
		case 'L':
			license ();
			exit (0);
		case 'h':
			help ();
			exit (0);
		case 'V':
			version ();
			exit (0);
		case 'r':
			rt.resume_mode = RESUME;
			break;
		case 'f':
			rt.force_mode = TRUE;
			break;
		case 'k':
			if (setargval (optarg, &rt.num_connections) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the -k option\n" "Please type proz --help for help\n"));
				exit (0);
			}

			if (rt.num_connections == 0)
			{
				printf (_("Hey! How can I download anything with 0 (Zero)" " connections!?\n" "Please type proz --help for help\n"));
				exit (0);
			}

			break;
		case 't':
			if (setargval (optarg, &rt.max_attempts) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the -t or --tries option(s)\n" "Please type proz --help for help\n"));
				exit (0);
			}
			break;
		case 'n':
			/*
			 * Don't use ~/.netrc" 
			 */
			rt.use_netrc = FALSE;
			break;

		case 'P':
			/*
			 * Save the downloaded file to DIR 
			 */
			rt.output_dir = kstrdup (optarg);
			break;
		case '?':
			help ();
			exit (0);
			break;
		case '1':
			rt.num_connections = 1;
			break;

		case 'g':
			/*
			 * TODO solve this soon 
			 */
			printf ("Error: GTK interface is not supported in "
				"the development version currently\n");
			exit (0);
			break;

		case 129:
			/*
			 * lets use PORT as the default then 
			 */
			rt.ftp_use_pasv = FALSE;
			break;
		case 130:
			/*
			 * retry-delay option 
			 */
			if (setargval (optarg, &rt.retry_delay) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --retry-delay option\n" "Please type proz --help for help\n"));
				exit (0);
			}
			break;
		case 131:
	    /*--timout option */
			if (setargval (optarg, &rt.itimeout) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --timeout option\n" "Please type proz --help for help\n"));
				exit (0);
			}
			break;
		case 132:
			/* --no-getch option */
			rt.dont_prompt = TRUE;
			break;

		case 133:
			/* --debug option */
			rt.debug_mode = TRUE;
			rt.libdebug_mode=TRUE;
			break;

		case 'v':
			/* --verbose option */
			rt.quiet_mode = FALSE;
			break;

		case 's':
			/* --ftpsearch option */
			rt.ftp_search = TRUE;
			break;

		case 135:
			/* --no-search option */
			rt.ftp_search = FALSE;
			break;

		case 136:
			/* --pt option */
			if (setargval (optarg, &rt.max_ping_wait) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --pt option\n" "Please type proz --help for help\n"));
				exit (0);
			}

			if (rt.max_ping_wait == 0)
			{
				printf (_("Hey! Does waiting for a server response for Zero(0)" " seconds make and sense to you!?\n" "Please type proz --help for help\n"));
				exit (0);
			}

			break;
		case 137:
			/* --pao option */
			if (setargval (optarg, &rt.max_simul_pings) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --pao option\n" "Please type proz --help for help\n"));
				exit (0);
			}

			if (rt.max_simul_pings == 0)
			{
				printf (_("Hey you! Will pinging Zero(0) servers at once" " achive anything for me!?\n" "Please type proz --help for help\n"));
				exit (0);
			}

			break;

		case 138:
			/* --max-ftp-servers option */
			if (setargval (optarg, &rt.ftps_mirror_req_n) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --pao option\n" "Please type proz --help for help\n"));
				exit (0);
			}

			if (rt.ftps_mirror_req_n == 0)
			{
				printf (_("Hey! Will requesting Zero(0) servers at once" "from the ftpearch achive anything!?\n" "Please type proz --help for help\n"));
				exit (0);
			}

			break;
		case 139:
			/* --max-bps */
			if (setlongargval (optarg, &rt.max_bps_per_dl) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --max-bps option\n" "Please type proz --help for help\n"));
				exit (0);
			}
			break;
		case 140:
      rt.display_mode = DISP_STDOUT;
      break;
		case 141:
			/* --min-size */
			if (setlongargval (optarg, &rt.min_search_size) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --min-size option\n" "Please type proz --help for help\n"));
				exit (0);
			}
			break;

		case 142:
			/* --ftpsid */
		
			if (setargval (optarg, &rt.ftpsearch_server_id) != 1)
			{
				/*
				 * The call failed  due to a invalid arg
				 */
				printf (_("Error: Invalid arguments for the --ftpsid option\n" "Please type proz --help for help\n"));
				exit (0);
			}

			if (rt.ftpsearch_server_id < 0 || rt.ftpsearch_server_id >1)
			{
				printf (_("The available servers are (0) filesearching.com and (1) ftpsearch.elmundo.es\n" "Please type proz --help for help\n"));
				exit (0);
			}

			break;



		default:
			printf (_("Error: Invalid  option\n"));
			exit (0);
		}
	}

	set_runtime_values ();	//tell libprozilla about any changed settings

	if (optind == argc)
	{
		help ();
	}
	else
	{
		/* Gettext stuff */
		setlocale (LC_ALL, "");
		bindtextdomain (PACKAGE, LOCALEDIR);
		textdomain (PACKAGE);

		/*delete the ~/.prozilla/debug.log file if present at the start of each run */
		proz_debug_delete_log ();

    if (rt.display_mode == DISP_CURSES)
      initCurses();
    
		/* we will now see whether the user has specfied any urls in the command line  and add them */
		for (int i = optind; i < argc; i++)
		{
			uerr_t err;
			urlinfo *url_data;
			url_data = (urlinfo *) malloc (sizeof (urlinfo));
			memset (url_data, 0, sizeof (urlinfo));

			//parses and validates the command-line parm
			err = proz_parse_url (argv[i], url_data, 0);
			if (err != URLOK)
			{
				PrintMessage (_
					("%s does not seem to be a valid URL"),
					argv[optind]);
				proz_debug
					("%s does not seem to be a valid URL",
					 argv[optind]);
				exit (0);
			}

			PrintMessage("Starting.....");
	//In to %s\n",url_data->host);
			// start the download
			ret=open_new_dl_win (url_data, rt.ftp_search);
			/*If the download failed the return -1 */
			if(ret==-1)
			  {
			    free(url_data);
			    delete(dl_win);
			    shutdown();
			    return -1;
			  }
			delete(dl_win);
			free (url_data);
		}
	}

  shutdown();

}
Exemplo n.º 7
0
int main(int argc, char* argv[]) 
{

  char *orpg_build_str; 

  Atom WM_DELETE_WINDOW;

/*   char *charval=NULL; */


int standalone_flag = FALSE;


/*    if((charval = getenv("STANDALONE_CVG")) != NULL)  */
/*        standalone_flag = TRUE; */
/*    else  */
/*        standalone_flag = FALSE; */



#ifdef LITTLE_ENDIAN_MACHINE
    fprintf(stderr, "\nThis CVG binary was compiled for the PC Linux Platform.\n");
#else
    fprintf(stderr, "\nThis CVG binary was compiled for the Solaris Sparc Platform.\n");
#endif



#ifdef LIB_LINK_STATIC
standalone_flag = TRUE;
#endif

#ifdef LIB_LINK_DYNAMIC
standalone_flag = FALSE;
#endif


  /* check presence of required libraries    */
  /* function has some dependency on cvg.mak */
  check_libraries(standalone_flag);

  init_prefs();
                                                  
  fprintf(stderr,"CVG START - FINISHED INITIALIZING PREFERENCES\n");


  if(standalone_flag == TRUE) {
      use_cvg_list_flag = prev_cvg_list_flag = TRUE;                
  } else {
      use_cvg_list_flag = prev_cvg_list_flag = FALSE;
  } 
  write_descript_source(use_cvg_list_flag);




  /*  should be moved to preferences!! */
  if((orpg_build_str = getenv("CV_ORPG_BUILD")) == NULL) {
        orpg_build_i = CVG_DEFAULT_BUILD;
        printf("Variable CV_ORPG_BUILD is not set.  CVG assumes default build %d\n", orpg_build_i);
  } else {
        orpg_build_i = atoi(orpg_build_str);  
        printf("CVG using variable CV_ORPG_BUILD to set ORPG Build to %d\n", orpg_build_i); 
  }
  write_orpg_build(orpg_build_i);



  shell = XtAppInitialize(&app,"CVG.RESOURCE",NULL,0,&argc,argv,fallbacks,
                             NULL,0);

  /* intercept the normal window menu 'Close' function */
  XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
  WM_DELETE_WINDOW = XInternAtom ( XtDisplay(shell), "WM_DELETE_WINDOW", FALSE );
  XmAddWMProtocolCallback ( shell, WM_DELETE_WINDOW, exit_callback, NULL );


/* set attrribute so radio buttons are always round */
/*  REQUIRED ON LINUX */
XtVaSetValues(XmGetXmDisplay(XtDisplay(shell)),
     XmNenableToggleVisual,     TRUE,
     NULL);


  
  XtVaSetValues(shell, 
		XmNtitle,  CVG_VERSION_STRING, 


#ifdef SUNOS
                XmNwidth,  615,
                XmNheight, 560,
#endif
#ifdef LINUX
                XmNwidth,  610,
                XmNheight, 570,
#endif


        XmNmwmDecorations,    MWM_DECOR_BORDER^MWM_DECOR_MINIMIZE^MWM_DECOR_TITLE^MWM_DECOR_MENU,
/*  limit available window functions */
        XmNmwmFunctions,      MWM_FUNC_CLOSE^MWM_FUNC_MINIMIZE^MWM_FUNC_MOVE,

        XmNx,         10,
        XmNy,         5, 

/* LINUX KDE ISSUE -  it wouold be convenient to allow the
   applicaion shell to be sized by the widgets by
       a. not specifying an initial size for the shell
       b. setting XmNallowShellResize to TRUE BEFORE widgets are managed
   however when using a SelectionBox with the application shell
   on Linux, KDE crashes when no ititial size is specified for the shell
*/
/*Also, when specifying an initial size for the application shell
    a warning that DialogStype should be XmDIALOG_MODELESS is provided
*/
/* Note: a combination of
       a. Initial size specified for shell
       b. setting XmNallowShellResize to TRUE AFTER managing all widgets
   results in the initial movement of the window, three row selection
   list, and a problem displaying all wigets
*/

/* XmNallowShellResize, TRUE, */
		NULL);
 

  XtRealizeWidget(shell);


  init_globals();
                                                
  fprintf(stderr,"CVG START - FINISHED INITIALIZING GLOBAL DATA\n");  
  
  load_prefs();


  /* CVG 9.1 - erase existing cvg product list to avoid potential problems */
  sprintf(list_fname, "%s/cvg_db_list.lb", config_dir); 
  if(stat(list_fname, &db_list_stat) == 0) {
    res = remove(list_fname);
    fprintf(stderr,"Removed existing cvg product list\n");
  }


  fprintf(stderr,"CVG START - FINISHED LOADING PREFERENCES\n");


/* /// CODE FOR BACKGROUND TASK /////// */

  new_pid = fork();

  switch(new_pid) {
    
      case  -1:  /* Error */
           perror("fork failed");
           exit(1);    
      case  0:  /* child */
         { /*  begin child block */
        
/*  future exec'd executable */
           execlp("cvg_read_db", "cvg_read_db", (char *)0);
/*             read_db(); */
            
         } /*  end child block */
           break;
      default:  /* parent */ 

      fprintf(stderr,"CVG START - READ_DATABASE PROCESS STARTED, PID=%d\n",
                        (int) new_pid);


                        
      init_db_prod_list();
/* DEBUG */
/* fprintf(stderr,"DEBUG CVG START - finished init_db_prod_list\n"); */
          
      setup_gui_display(); 
/* DEBUG */
/* fprintf(stderr,"DEBUG CVG START - finished setup_gui_display\n"); */

      XtAppAddTimeOut(app, 5000, build_list, NULL);          
          
      XtAppMainLoop(app);
    
  } /*  end switch */



/* ///////////////////////////////////////// */

/*   XtAppMainLoop(app); */

  return 0;
}