File: environment.c

package info (click to toggle)
gummi 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,940 kB
  • sloc: ansic: 8,894; sh: 145; makefile: 77; python: 38
file content (126 lines) | stat: -rw-r--r-- 3,254 bytes parent folder | download | duplicates (3)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
 * @file    environment.c
 * @brief
 *
 * Copyright (C) 2009 Gummi Developers
 * All Rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#include "configfile.h"
#include "environment.h"
#include "gui/gui-main.h"
#include "utils.h"

Gummi* gummi = 0;
GummiGui* gui = 0;

Gummi* gummi_init (GuMotion* mo, GuIOFunc* io, GuLatex* latex, GuBiblio* bib,
                   GuTemplate* tpl, GuSnippets* snip, GuTabmanager* tabm,
                   GuProject* proj) {

    Gummi* g = g_new0 (Gummi, 1);
    g->io = io;
    g->motion = mo;
    g->latex = latex;
    g->biblio = bib;
    g->templ = tpl;
    g->snippets = snip;
    g->tabmanager = tabm;
    g->project = proj;

    return g;
}

gboolean gummi_project_active (void) {
    if (gummi->project->projfile) return TRUE;
    return FALSE;
}

gchar* gummi_get_projectfile (void) {
    return gummi->project->projfile;
}

GuEditor* gummi_new_environment (const gchar* filename) {
    GuEditor* ec = editor_new (gummi->motion);
    editor_fileinfo_update (ec, filename);

    slog (L_INFO, "\n");
    slog (L_INFO, "Environment created for:\n");
    slog (L_INFO, "TEX: %s\n", ec->filename);
    slog (L_INFO, "TMP: %s\n", ec->workfile);
    slog (L_INFO, "PDF: %s\n", ec->pdffile);
    return ec;
}

GummiGui* gummi_get_gui (void) {
    return gui;
}

GuEditor* gummi_get_active_editor (void) {
    return g_active_editor;
}

GList* gummi_get_all_tabs (void) {
    return gummi->tabmanager->tabs;
}

GList* gummi_get_all_editors (void) {
    int tabtotal, i;
    GuEditor* ec;
    GList* editors = NULL;

    GList *tabs = gummi_get_all_tabs();
    tabtotal = g_list_length(tabs);

    for (i = 0; i < tabtotal; ++i) {
        ec = GU_TAB_CONTEXT (g_list_nth_data (tabs, i))->editor;
        editors = g_list_append (editors, ec);
    }
    return editors;
}

GuIOFunc* gummi_get_io (void) {
    return gummi->io;
}

GuMotion* gummi_get_motion (void) {
    return gummi->motion;
}

GuLatex* gummi_get_latex (void) {
    return gummi->latex;
}

GuBiblio* gummi_get_biblio (void) {
    return gummi->biblio;
}

GuTemplate* gummi_get_template (void) {
    return gummi->templ;
}

GuSnippets* gummi_get_snippets (void) {
    return gummi->snippets;
}