~ubuntu-branches/ubuntu/warty/ggz-gtk-client/warty

« back to all changes in this revision

Viewing changes to ggz-gtk/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Zander
  • Date: 2003-12-01 00:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20031201000000-ixnk24pwpgigjxa2
Tags: upstream-0.0.7
ImportĀ upstreamĀ versionĀ 0.0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * File: main.c
 
3
 * Author: Justin Zaun
 
4
 * Project: GGZ GTK Client
 
5
 * $Id: main.c,v 1.42 2003/01/12 12:27:43 dr_maux Exp $
 
6
 *
 
7
 * This is the main program body for the GGZ client
 
8
 *
 
9
 * Copyright (C) 2000-2002 Justin Zaun.
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2 of the License, or
 
14
 * (at your option) any later version.
 
15
 *
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program; if not, write to the Free Software
 
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
 
 
28
#include <ggz.h>   /* libggz */
 
29
 
 
30
#include <gtk/gtk.h>
 
31
#include <stdlib.h>
 
32
#include <unistd.h>
 
33
#include <string.h>
 
34
#ifdef ENABLE_NLS
 
35
#include <locale.h>
 
36
#include <libintl.h>
 
37
#endif
 
38
 
 
39
#include <ggzcore.h>
 
40
#include <ggz.h>
 
41
 
 
42
#include "about.h"
 
43
#include "chat.h"
 
44
#include "client.h"
 
45
#include "first.h"
 
46
#include "ggzclient.h"
 
47
#include "license.h"
 
48
#include "login.h"
 
49
#include "server.h"
 
50
#include "support.h"
 
51
 
 
52
 
 
53
static void init_debug(void)
 
54
{
 
55
        char *default_file, *debug_file, **debug_types;
 
56
        int num_types, i;
 
57
 
 
58
        /* Inititialze debugging */
 
59
        default_file = g_strjoin("/", getenv("HOME"), ".ggz/ggz-gtk.debug", NULL);
 
60
        debug_file = ggzcore_conf_read_string("Debug", "FILE", default_file);
 
61
        g_free(default_file);
 
62
 
 
63
        ggzcore_conf_read_list("Debug", "Types", &num_types, (char***)&debug_types);
 
64
        ggz_debug_init((const char**)debug_types, debug_file);
 
65
 
 
66
        /* Free up memory */
 
67
        for (i = 0; i < num_types; i++)
 
68
                ggz_free(debug_types[i]);
 
69
        ggz_free(debug_types);
 
70
        ggz_free(debug_file);
 
71
}
 
72
 
 
73
 
 
74
int main (int argc, char *argv[])
 
75
{
 
76
        GGZOptions opt;
 
77
        char *global_conf, *user_conf, *init_version;
 
78
        
 
79
#ifdef ENABLE_NLS
 
80
        bindtextdomain("ggz-gtk", PACKAGE_LOCALE_DIR);
 
81
        textdomain("ggz-gtk");
 
82
        setlocale(LC_ALL, "");
 
83
#endif
 
84
        
 
85
        /*global_conf = "/etc/ggz/ggz.conf";*/
 
86
        /* We don't support this quite yet */
 
87
        global_conf = NULL;
 
88
        user_conf = g_strdup_printf("%s/.ggz/ggz-gtk.rc", getenv("HOME"));
 
89
        ggzcore_conf_initialize(global_conf, user_conf);
 
90
        g_free(user_conf);
 
91
 
 
92
        opt.flags = GGZ_OPT_PARSER | GGZ_OPT_MODULES;
 
93
        
 
94
        ggzcore_init(opt);
 
95
 
 
96
#ifdef DEBUG
 
97
        init_debug();
 
98
#endif
 
99
 
 
100
        server_profiles_load();
 
101
        
 
102
        gtk_init(&argc, &argv);
 
103
        chat_init();
 
104
 
 
105
        init_version = ggzcore_conf_read_string("INIT", "VERSION", VERSION);
 
106
        if (ggzcore_conf_read_int("INIT", "FIRST", 0) == 0 ||
 
107
            strcmp(init_version, VERSION) !=0 )
 
108
        {
 
109
                first_create_or_raise();
 
110
        } else {
 
111
                win_main = create_win_main();
 
112
                ggz_sensitivity_init();
 
113
                gtk_widget_show(win_main);
 
114
                login_create_or_raise();
 
115
        }
 
116
        ggz_free(init_version);
 
117
 
 
118
        gtk_main();
 
119
 
 
120
        chat_save_lists();
 
121
        server_profiles_cleanup();
 
122
        chat_lists_cleanup();
 
123
 
 
124
        ggzcore_destroy();
 
125
#ifdef DEBUG
 
126
        ggz_debug_cleanup(GGZ_CHECK_MEM);
 
127
#endif  
 
128
 
 
129
        return 0;
 
130
}