1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
* Copyright (C) 2001, 2002, 2004 Philip Blundell <philb@gnu.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include "errorbox.h"
#include "spacing.h"
gint saved_argc;
gchar **saved_argv;
gboolean
gpe_application_init (int *argc, char **argv[])
{
char *fn;
struct stat buf;
gchar *user_gtkrc_file;
const gchar *default_gtkrc_file = PREFIX "/share/gpe/gtkrc";
const gchar *home_dir = g_get_home_dir ();
gint i;
if (argc && argv)
{
saved_argc = *argc;
saved_argv = g_malloc (*argc * sizeof (gchar *));
for (i = 0; i < saved_argc; i++)
saved_argv[i] = g_strdup ((*argv)[i]);
}
gtk_rc_add_default_file (default_gtkrc_file);
user_gtkrc_file = g_strdup_printf ("%s/.gpe/gtkrc", home_dir);
gtk_rc_add_default_file (user_gtkrc_file);
g_free (user_gtkrc_file);
gtk_init (argc, argv);
gtk_set_locale ();
init_spacing();
if (home_dir[0] && strcmp (home_dir, "/"))
{
/* Maybe this belongs somewhere else */
fn = g_strdup_printf ("%s/.gpe", home_dir);
if (stat (fn, &buf) != 0)
{
if (mkdir (fn, 0700) != 0)
{
gpe_perror_box ("Cannot create ~/.gpe");
g_free (fn);
return FALSE;
}
}
else
{
if (!S_ISDIR (buf.st_mode))
{
gpe_error_box ("ERROR: ~/.gpe is not a directory!");
g_free (fn);
return FALSE;
}
}
g_free (fn);
}
return TRUE;
}
void
gpe_saved_args (gint *argc, gchar **argv[])
{
*argc = saved_argc;
*argv = saved_argv;
}
|