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/>.
27 #include "plugindata.h"
29 #include "filetypes.h"
32 #include "pluginmacros.h"
38 PLUGIN_VERSION_CHECK(38);
39 PLUGIN_SET_INFO(_("Project"), _("Alternative project support."), VERSION
,
40 _("Yura Siamashka <yurand2@gmail.com>"));
42 PluginFields
*plugin_fields
;
43 GeanyData
*geany_data
;
44 GeanyFunctions
*geany_functions
;
53 debug("%s\n", __FUNCTION__
);
55 idx
= p_document
->get_cur_idx();
56 if (!DOC_IDX_VALID(idx
) || documents
[idx
]->file_name
== NULL
)
59 dir
= g_path_get_dirname(documents
[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(G_GNUC_UNUSED GObject
* obj
, gint idx
, G_GNUC_UNUSED gpointer user_data
)
94 debug("%s obj=%p, idx = %d, user_data = %p\n", __FUNCTION__
, obj
, idx
, user_data
);
95 g_return_if_fail(DOC_IDX_VALID(idx
) && documents
[idx
]->file_name
!= NULL
);
97 name
= g_path_get_basename(documents
[idx
]->file_name
);
98 if (g_current_project
&& strcmp(name
, ".geanyprj") == 0)
100 xproject_close(FALSE
);
103 xproject_update_tag(documents
[idx
]->file_name
);
107 on_doc_open(G_GNUC_UNUSED GObject
* obj
, G_GNUC_UNUSED gint idx
, G_GNUC_UNUSED gpointer user_data
)
109 debug("%s obj=%p, idx = %d, user_data = %p\n", __FUNCTION__
, obj
, idx
, user_data
);
114 on_doc_activate(G_GNUC_UNUSED GObject
* obj
, G_GNUC_UNUSED gint idx
,
115 G_GNUC_UNUSED gpointer user_data
)
117 debug("%s obj=%p, idx = %d, user_data = %p\n", __FUNCTION__
, obj
, idx
, user_data
);
121 GeanyCallback geany_callbacks
[] = {
122 {"document-open", (GCallback
) & on_doc_open
, TRUE
, NULL
},
123 {"document-save", (GCallback
) & on_doc_save
, TRUE
, NULL
},
124 {"document-activate", (GCallback
) & on_doc_activate
, TRUE
, NULL
},
125 {NULL
, NULL
, FALSE
, NULL
}
128 /* Called by Geany to initialize the plugin */
130 plugin_init(G_GNUC_UNUSED GeanyData
* data
)
133 p_support
->lookup_widget(GTK_WIDGET(main_widgets
->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. */
149 p_support
->lookup_widget(GTK_WIDGET(main_widgets
->window
), "menu_project1");
150 gtk_widget_set_child_visible(prj
, TRUE
);
151 gtk_widget_set_size_request(prj
, -1, -1);
157 xproject_close(TRUE
);
160 if (g_current_project
)
161 geany_project_free(g_current_project
);
162 g_current_project
= NULL
;