real_main & arg_parse patch



Hi all,

Here's a patch that removes real_main() and arg_parse() from gide.c and
moves them main(). I've done some additional cleanups (variables that
were no longer used, such as disablefontstuff).

Let me know if this is ok. I still need to get used to this different
coding style.


Index: src/gide.c
===================================================================
RCS file: /cvs/gnome/gIDE/src/gide.c,v
retrieving revision 1.29
diff -u -c -r1.29 gide.c
*** src/gide.c  2001/06/21 03:01:33     1.29
--- src/gide.c  2001/06/27 15:33:55
***************
*** 29,37 ****
  #include <liboaf/liboaf.h>
  #include <bonobo.h>
  
! /* --- global vars --- */
! 
! /* Widgets: Main-Window & Box */
  GideWindow *main_window;
  
  /* Paths */
--- 29,35 ----
  #include <liboaf/liboaf.h>
  #include <bonobo.h>
  
! /* Main window */
  GideWindow *main_window;
  
  /* Paths */
***************
*** 39,55 ****
  gchar tools_path[MAXLEN];
  gchar prj_path[MAXLEN];
  
- /* Command line args */
- static poptContext ctx;
- static gboolean disablefontstuff = FALSE;
- 
  static const struct poptOption gide_popt_options [] = {
        { NULL, '\0', 0, NULL, 0 }
  };
  
! static void open_history( gchar *filename )
  {
- /*
        FILE* history;
        gchar buf[MAXLEN];
        gchar historywp[MAXLEN];
--- 37,48 ----
  gchar tools_path[MAXLEN];
  gchar prj_path[MAXLEN];
  
  static const struct poptOption gide_popt_options [] = {
        { NULL, '\0', 0, NULL, 0 }
  };
  
! /*static void open_history( gchar *filename )
  {
        FILE* history;
        gchar buf[MAXLEN];
        gchar historywp[MAXLEN];
***************
*** 68,97 ****
                        file_open_by_name( main_window, buf );
                }
                fclose( history );
!               } */
! }
  
  /* doesn't seem to belong here. should be in gI_cfg.c or so */
- 
- 
  
! /* some things here happen also in prefs (since they change when prefs
change).
!    so, should be in common function */
! static void real_main( gint argc, gchar *argv[] )
  {
        gint nofargs = 0;
-       gchar* extra_dir;
-       gchar *filename;
-       GideShell *shell;
        GtkWidget *splash;
  
        splash = e_splash_new ();
        gtk_widget_show (splash);
        gtk_object_ref (GTK_OBJECT (splash));
        while (gtk_events_pending ())
                gtk_main_iteration ();
  
!       main_window = gide_window_new(splash);
        
  #if 0
        /* FIXME: This is a good thing to be doing, but I don't want to
--- 61,109 ----
                        file_open_by_name( main_window, buf );
                }
                fclose( history );
!               }
! }*/
  
  /* doesn't seem to belong here. should be in gI_cfg.c or so */
  
! gint main (gint argc, gchar **argv) 
  {
+       CORBA_ORB orb;
+       poptContext ctx;
        gint nofargs = 0;
        GtkWidget *splash;
+       
+       /* Internationalization */
+       bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+       textdomain (PACKAGE);
+       
+       /* Parse options */
+       gnomelib_register_popt_table (oaf_popt_options, _("Oaf
options"));
+       gnome_init_with_popt_table (PACKAGE, VERSION, argc, argv, 
+                                   gide_popt_options, 0, &ctx);
+                                   
+       gnome_window_icon_set_default_from_file (GNOME_ICONDIR
"/gide.png");
  
+       /* Initialize Bonobo */
+       orb = oaf_init (argc, argv);
+ 
+       if (!bonobo_init (orb, NULL, NULL))
+               g_error ("Failure starting Bonobo");
+ 
+       bonobo_activate ();
+ 
+       /* Initialize glade */  
+       glade_gnome_init ();
+ 
+       /* Display splashscreen */
        splash = e_splash_new ();
        gtk_widget_show (splash);
        gtk_object_ref (GTK_OBJECT (splash));
        while (gtk_events_pending ())
                gtk_main_iteration ();
  
!       /* Create main window */
!       main_window = gide_window_new (E_SPLASH (splash));
        
  #if 0
        /* FIXME: This is a good thing to be doing, but I don't want to
***************
*** 100,109 ****
        /* open the files */
        startup_files = poptGetArgs(ctx);
        nofargs = 0;
!       if (startup_files)
!       {
!               while (startup_files[nofargs])
!               {
  #if DOCNOTEBOOK
                        file_open_by_name( main_window,
                                           g_strdup(startup_files[nofargs]));
--- 112,119 ----
        /* open the files */
        startup_files = poptGetArgs(ctx);
        nofargs = 0;
!       if (startup_files) {
!               while (startup_files[nofargs]) {
  #if DOCNOTEBOOK
                        file_open_by_name( main_window,
                                           g_strdup(startup_files[nofargs]));
***************
*** 111,170 ****
  #endif
                }
        }
!       poptFreeContext(ctx);
  
!       if( nofargs == 0 )
!       {
                /* no files given on the commandline, open files from
last session */
!               open_history( HISTORY );
        }
  #endif
  
        gtk_widget_unref (splash);
        gtk_widget_destroy (splash);
  
!       /* GTK Main Loop */
!       gtk_main();
  
  #if 0
        /* Destroy the main_window */
!       gtk_object_destroy( GTK_OBJECT(main_window) );
  #endif
- }
- 
- static void
- arg_parse (int argc, char *argv [])
- {
-       CORBA_ORB         orb;
- 
-       ctx = NULL;
- 
-       gnomelib_register_popt_table (oaf_popt_options, _("Oaf
options"));
-       gnome_init_with_popt_table(PACKAGE, VERSION,
-                                  argc, argv, gide_popt_options,
-                                  0, &ctx);
-       gnome_window_icon_set_default_from_file (GNOME_ICONDIR
"/gide.png");
- 
-       orb = oaf_init (argc, argv);
- 
-       if (bonobo_init (orb, NULL, NULL) == FALSE)
-               g_error ("Failure starting up Bonobo");
- 
-       bonobo_activate ();
-       
- }
- 
- gint main (gint argc, gchar **argv)
- {
-       /* Internationalization */
-       bindtextdomain(PACKAGE, GNOMELOCALEDIR);
-       textdomain(PACKAGE);
- 
-       arg_parse (argc, argv);
-       glade_gnome_init ();
-       
-       real_main(argc, argv);
  
!       /* allīs great, return EXIT_SUCCESS */
!       return( EXIT_SUCCESS );
  }
--- 121,145 ----
  #endif
                }
        }
!       poptFreeContext (ctx);
  
!       if (nofargs == 0) {
                /* no files given on the commandline, open files from
last session */
!               open_history (HISTORY);
        }
  #endif
  
        gtk_widget_unref (splash);
        gtk_widget_destroy (splash);
  
!       /* GTK main Loop */
!       gtk_main ();
  
  #if 0
        /* Destroy the main_window */
!       gtk_object_destroy (GTK_OBJECT (main_window));
  #endif
  
!       /* Allīs great, return EXIT_SUCCESS */
!       return (EXIT_SUCCESS);
  }








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]