2 * geanyprj - Alternative project support for geany light IDE.
4 * Copyright 2007 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
5 * Copyright 2007 Enrico Tröger <enrico.troeger@uvena.de>
6 * Copyright 2007 Nick Treleaven <nick.treleaven@btinternet.com>
7 * Copyright 2007,2008 Yura Siamashka <yurand2@gmail.com>
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "plugindata.h"
30 #include "filetypes.h"
32 #include "pluginmacros.h"
39 PLUGIN_INFO(_("Project"), _("Alternative project support."), VERSION
,
40 _("Yura Siamashka <yurand2@gmail.com>"));
42 PluginFields
*plugin_fields
;
43 GeanyData
*geany_data
;
53 debug("%s\n", __FUNCTION__
);
55 idx
= p_document
->get_cur_idx();
56 if (!DOC_IDX_VALID(idx
) || doc_list
[idx
].file_name
== NULL
)
59 dir
= g_path_get_dirname(doc_list
[idx
].file_name
);
60 proj
= find_file_path(dir
, ".geanyprj");
62 // This is not our project, close it as best as we can
63 if (project
&& project
->type
!= PROJECT_TYPE
)
65 debug("%s Closing unknown project type \n", __FUNCTION__
);
80 else if (strcmp(proj
, g_current_project
->path
) != 0)
90 on_doc_save(GObject
* obj
, gint idx
, gpointer user_data
)
96 debug("%s obj=%p, idx = %d, user_data = %p\n", __FUNCTION__
, obj
, idx
, user_data
);
97 g_return_if_fail(DOC_IDX_VALID(idx
) && doc_list
[idx
].file_name
!= NULL
);
99 name
= g_path_get_basename(doc_list
[idx
].file_name
);
100 if (g_current_project
&& strcmp(name
, ".geanyprj") == 0)
102 xproject_close(FALSE
);
105 xproject_update_tag(doc_list
[idx
].file_name
);
109 on_doc_open(GObject
* obj
, gint idx
, gpointer user_data
)
111 debug("%s obj=%p, idx = %d, user_data = %p\n", __FUNCTION__
, obj
, idx
, user_data
);
116 on_doc_activate(GObject
* obj
, gint idx
, gpointer user_data
)
118 debug("%s obj=%p, idx = %d, user_data = %p\n", __FUNCTION__
, obj
, idx
, user_data
);
122 GeanyCallback geany_callbacks
[] = {
123 {"document-open", (GCallback
) & on_doc_open
, TRUE
, NULL
},
124 {"document-save", (GCallback
) & on_doc_save
, TRUE
, NULL
},
125 {"document-activate", (GCallback
) & on_doc_activate
, TRUE
, NULL
},
126 {NULL
, NULL
, FALSE
, NULL
}
129 /* Called by Geany to initialize the plugin */
131 init(GeanyData
* data
)
133 GtkWidget
*prj
= p_support
->lookup_widget(GTK_WIDGET(app
->window
), "menu_project1");
136 gtk_widget_set_child_visible(prj
, FALSE
);
137 gtk_widget_set_size_request(prj
, 0, 0);
144 /* Called by Geany before unloading the plugin. */
150 GtkWidget
*prj
= p_support
->lookup_widget(GTK_WIDGET(app
->window
), "menu_project1");
151 gtk_widget_set_child_visible(prj
, TRUE
);
152 gtk_widget_set_size_request(prj
, -1, -1);
158 xproject_close(TRUE
);
161 if (g_current_project
)
162 geany_project_free(g_current_project
);
163 g_current_project
= NULL
;