~ubuntu-branches/ubuntu/hoary/jamin/hoary

« back to all changes in this revision

Viewing changes to src/resource.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Jordens
  • Date: 2004-01-17 12:14:37 UTC
  • Revision ID: james.westby@ubuntu.com-20040117121437-3idr2e2m3k5jnm9n
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2003 Jack O'Quin
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  $Id: resource.c,v 1.1 2004/01/10 05:19:18 joq Exp $
 
15
 */
 
16
 
 
17
#include <stdio.h>
 
18
#include <unistd.h>
 
19
#include <sys/types.h>
 
20
#include <sys/stat.h>
 
21
#include <fcntl.h>
 
22
#include <gtk/gtk.h>
 
23
 
 
24
#include "main.h"
 
25
#include "resource.h"
 
26
 
 
27
static const char *resource_file;       /* GTK resource file, -r option */
 
28
 
 
29
/* Name associated with -r option, NULL if none */
 
30
void resource_file_name(const char *name)
 
31
{
 
32
    if (name)
 
33
        resource_file = name;
 
34
    else
 
35
        resource_file = JAMIN_EXAMPLES_DIR JAMIN_UI;
 
36
}
 
37
 
 
38
void resource_file_parse(void)
 
39
{
 
40
    if (resource_file) {
 
41
 
 
42
        /* use resource file specified with -r option */
 
43
        printf("Using GTK resource file %s\n", resource_file);
 
44
        gtk_rc_parse(resource_file);
 
45
 
 
46
    } else if (jamin_dir) {
 
47
 
 
48
        char rcfile[PATH_MAX];
 
49
        int fd;
 
50
 
 
51
        /* look for a user-defined GTK rc file, and parse it */
 
52
        snprintf(rcfile, PATH_MAX, "%s%s", jamin_dir, JAMIN_UI);
 
53
        if ((fd = open(rcfile, O_RDONLY)) >= 0) {
 
54
            close(fd);
 
55
            gtk_rc_parse(rcfile);
 
56
        }
 
57
    }
 
58
}