~ubuntu-branches/debian/sid/geany-plugins/sid

« back to all changes in this revision

Viewing changes to gproject/src/gproject-main.c

  • Committer: Package Import Robot
  • Author(s): Evgeni Golov, Evgeni Golov
  • Date: 2011-11-17 20:03:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111117200324-8qmu6tuwjtfpv3n7
Tags: 0.21.1-1
[ Evgeni Golov ]
* [f4007f2] Imported Upstream version 0.21.1
* [5ff622d] install plugins from/to /usr/lib/<arch-triplet>/geany
* [75411d7] bump build-dep to geany 0.21
* [db92155] depend on the virtual geany-abi-XX package
* [dd84769] switch to 3.0 (quilt)
* [3ab76d7] drop readme.source
* [233d44c] refresh patch against 0.21.1
* [030bec1] add lintian override for
            documentation-package-not-architecture-independent
* [aba43d7] use debhelper compat level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Jiri Techet <techet@gmail.com>
 
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
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 */
 
18
 
 
19
#ifdef HAVE_CONFIG_H
 
20
# include "config.h"
 
21
#endif
 
22
 
 
23
#include <sys/time.h>
 
24
#include <string.h>
 
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
        #include "config.h"
 
28
#endif
 
29
#include <geanyplugin.h>
 
30
 
 
31
#include "gproject-project.h"
 
32
#include "gproject-sidebar.h"
 
33
#include "gproject-menu.h"
 
34
 
 
35
PLUGIN_VERSION_CHECK(211);
 
36
PLUGIN_SET_INFO(_("GProject"),
 
37
        _("Glob-pattern-based project management plugin for Geany."),
 
38
        VERSION,
 
39
        "Jiri Techet <techet@gmail.com>");
 
40
 
 
41
GeanyPlugin *geany_plugin;
 
42
GeanyData *geany_data;
 
43
GeanyFunctions *geany_functions;
 
44
 
 
45
 
 
46
void plugin_init(G_GNUC_UNUSED GeanyData * data);
 
47
void plugin_cleanup(void);
 
48
 
 
49
 
 
50
static void on_doc_open(G_GNUC_UNUSED GObject * obj, G_GNUC_UNUSED GeanyDocument * doc,
 
51
            G_GNUC_UNUSED gpointer user_data)
 
52
{
 
53
        g_return_if_fail(doc != NULL && doc->file_name != NULL);
 
54
 
 
55
        //tags of open files managed by geany
 
56
        if (gprj_project_is_in_project(doc->file_name))
 
57
                gprj_project_remove_file_tag(doc->file_name);
 
58
 
 
59
        gprj_sidebar_update(FALSE);
 
60
}
 
61
 
 
62
 
 
63
static void on_doc_activate(G_GNUC_UNUSED GObject * obj, G_GNUC_UNUSED GeanyDocument * doc,
 
64
                G_GNUC_UNUSED gpointer user_data)
 
65
{
 
66
        g_return_if_fail(doc != NULL && doc->file_name != NULL);
 
67
 
 
68
        gprj_sidebar_update(FALSE);
 
69
}
 
70
 
 
71
 
 
72
static void on_doc_close(G_GNUC_UNUSED GObject * obj, GeanyDocument * doc,
 
73
                G_GNUC_UNUSED gpointer user_data)
 
74
{
 
75
        g_return_if_fail(doc != NULL && doc->file_name != NULL);
 
76
 
 
77
        //tags of open files managed by geany - when the file gets closed, we should take care of it
 
78
        if (gprj_project_is_in_project(doc->file_name))
 
79
                gprj_project_add_file_tag(doc->file_name);
 
80
 
 
81
        gprj_sidebar_update(FALSE);
 
82
}
 
83
 
 
84
 
 
85
static void on_build_start(GObject *obj, gpointer user_data)
 
86
{
 
87
        gint i;
 
88
 
 
89
        foreach_document(i)
 
90
        {
 
91
                if (gprj_project_is_in_project(documents[i]->file_name))
 
92
                        document_save_file(documents[i], FALSE);
 
93
        }
 
94
}
 
95
 
 
96
 
 
97
static void on_project_dialog_create(G_GNUC_UNUSED GObject * obj, GtkWidget * notebook,
 
98
                G_GNUC_UNUSED gpointer user_data)
 
99
{
 
100
        gprj_project_add_properties_tab(notebook);
 
101
}
 
102
 
 
103
 
 
104
static void on_project_dialog_confirmed(G_GNUC_UNUSED GObject * obj, GtkWidget * notebook,
 
105
                G_GNUC_UNUSED gpointer user_data)
 
106
{
 
107
        gprj_project_read_properties_tab();
 
108
        gprj_sidebar_update(TRUE);
 
109
}
 
110
 
 
111
 
 
112
static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config,
 
113
                G_GNUC_UNUSED gpointer user_data)
 
114
{
 
115
        gprj_project_open(config);
 
116
        gprj_sidebar_update(TRUE);
 
117
        gprj_sidebar_activate(TRUE);
 
118
        gprj_menu_activate_menu_items(TRUE);
 
119
}
 
120
 
 
121
 
 
122
static void on_project_close(G_GNUC_UNUSED GObject * obj, G_GNUC_UNUSED gpointer user_data)
 
123
{
 
124
        gprj_project_close();
 
125
        gprj_sidebar_update(TRUE);
 
126
        gprj_sidebar_activate(FALSE);
 
127
        gprj_menu_activate_menu_items(FALSE);
 
128
}
 
129
 
 
130
 
 
131
static void on_project_save(G_GNUC_UNUSED GObject * obj, GKeyFile * config,
 
132
                G_GNUC_UNUSED gpointer user_data)
 
133
{
 
134
        if (!g_prj)
 
135
        {
 
136
                //happens when the project is created
 
137
                gprj_project_open(config);
 
138
                gprj_sidebar_update(TRUE);
 
139
                gprj_sidebar_activate(TRUE);
 
140
                gprj_menu_activate_menu_items(TRUE);
 
141
        }
 
142
 
 
143
        gprj_project_save(config);
 
144
}
 
145
 
 
146
 
 
147
PluginCallback plugin_callbacks[] = {
 
148
        {"document-open", (GCallback) & on_doc_open, TRUE, NULL},
 
149
        {"document-activate", (GCallback) & on_doc_activate, TRUE, NULL},
 
150
        {"document-close", (GCallback) & on_doc_close, TRUE, NULL},
 
151
        {"build-start", (GCallback) & on_build_start, TRUE, NULL},
 
152
        {"project-dialog-create", (GCallback) & on_project_dialog_create, TRUE, NULL},
 
153
        {"project-dialog-confirmed", (GCallback) & on_project_dialog_confirmed, TRUE, NULL},
 
154
        {"project-open", (GCallback) & on_project_open, TRUE, NULL},
 
155
        {"project-close", (GCallback) & on_project_close, TRUE, NULL},
 
156
        {"project-save", (GCallback) & on_project_save, TRUE, NULL},
 
157
        {NULL, NULL, FALSE, NULL}
 
158
};
 
159
 
 
160
 
 
161
void plugin_init(G_GNUC_UNUSED GeanyData * data)
 
162
{
 
163
        gprj_menu_init();
 
164
        gprj_sidebar_init();
 
165
}
 
166
 
 
167
 
 
168
void plugin_cleanup(void)
 
169
{
 
170
        if (geany_data->app->project)
 
171
        {
 
172
                gprj_project_close();
 
173
                gprj_sidebar_update(TRUE);
 
174
        }
 
175
 
 
176
        gprj_menu_cleanup();
 
177
        gprj_sidebar_cleanup();
 
178
}