Revision: 1985 http://geany.svn.sourceforge.net/geany/?rev=1985&view=rev Author: eht16 Date: 2007-10-28 13:54:25 -0700 (Sun, 28 Oct 2007)
Log Message: ----------- Add macro project for app->project. Rename macro tm to tagm to avoid conflicts with tm struct of time.h. Fix a warning about shadowing a global symbol. Use plugin macros in Export and SVNDiff plugins.
Modified Paths: -------------- trunk/plugins/export.c trunk/plugins/filebrowser.c trunk/plugins/pluginmacros.h trunk/plugins/svndiff.c
Modified: trunk/plugins/export.c =================================================================== --- trunk/plugins/export.c 2007-10-28 17:02:36 UTC (rev 1984) +++ trunk/plugins/export.c 2007-10-28 20:54:25 UTC (rev 1985) @@ -24,6 +24,8 @@
/* Export plugin. */
+#include <ctype.h> + #include "geany.h" #include "support.h" #include "plugindata.h" @@ -31,7 +33,7 @@ #include "document.h" #include "prefs.h" #include "utils.h" -#include <ctype.h> +#include "pluginmacros.h"
PluginFields *plugin_fields; @@ -40,13 +42,6 @@ VERSION_CHECK(20) PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."), VERSION)
-#define doc_array geany_data->doc_array -#define scintilla geany_data->sci -#define utils geany_data->utils -#define support geany_data->support -#define dialogs geany_data->dialogs -#define ui geany_data->ui - #define ROTATE_RGB(color) \ (((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16) #define TEMPLATE_HTML "\ @@ -163,15 +158,15 @@ if (extension == NULL) return;
- idx = geany_data->document->get_cur_idx(); - tooltips = GTK_TOOLTIPS(support->lookup_widget(geany_data->app->window, "tooltips")); + idx = documents->get_cur_idx(); + tooltips = GTK_TOOLTIPS(support->lookup_widget(app->window, "tooltips"));
exi = g_new(ExportInfo, 1); exi->idx = idx; exi->export_func = func; exi->have_zoom_level_checkbox = FALSE;
- dialog = gtk_file_chooser_dialog_new(_("Export File"), GTK_WINDOW(geany_data->app->window), + dialog = gtk_file_chooser_dialog_new(_("Export File"), GTK_WINDOW(app->window), GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); @@ -206,7 +201,7 @@ g_signal_connect((gpointer) dialog, "response", G_CALLBACK(on_file_save_dialog_response), exi);
- gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(geany_data->app->window)); + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app->window));
// if the current document has a filename we use it as the default. gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog)); @@ -229,7 +224,7 @@ } else { - const gchar *default_open_path = geany_data->prefs->default_open_path; + const gchar *default_open_path = prefs->default_open_path; gchar *fname = g_strconcat(GEANY_STRING_UNTITLED, extension, NULL);
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog)); @@ -568,7 +563,7 @@ }
// read Geany's font and font size - font_desc = pango_font_description_from_string(geany_data->prefs->editor_font); + font_desc = pango_font_description_from_string(prefs->editor_font); font_name = pango_font_description_get_family(font_desc); //font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE; // take the zoom level also into account
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2007-10-28 17:02:36 UTC (rev 1984) +++ trunk/plugins/filebrowser.c 2007-10-28 20:54:25 UTC (rev 1985) @@ -66,18 +66,18 @@
// Returns: whether name should be hidden. -static gboolean check_hidden(const gchar *basename) +static gboolean check_hidden(const gchar *base_name) { gsize len;
- if (! NZV(basename)) + if (! NZV(base_name)) return FALSE;
- if (basename[0] == '.') + if (base_name[0] == '.') return TRUE;
- len = strlen(basename); - if (basename[len - 1] == '~') + len = strlen(base_name); + if (base_name[len - 1] == '~') return TRUE;
if (hide_object_files) @@ -89,7 +89,7 @@ { const gchar *ext = exts[i];
- if (utils->str_equal(&basename[len - strlen(ext)], ext)) + if (utils->str_equal(&base_name[len - strlen(ext)], ext)) return TRUE; } } @@ -154,7 +154,7 @@ clear();
// TODO: really, we don't want to dereference symlinks - setptr(current_dir, tm->get_real_path(current_dir)); + setptr(current_dir, tagm->get_real_path(current_dir));
utf8_dir = utils->get_utf8_from_locale(current_dir); gtk_entry_set_text(GTK_ENTRY(path_entry), utf8_dir);
Modified: trunk/plugins/pluginmacros.h =================================================================== --- trunk/plugins/pluginmacros.h 2007-10-28 17:02:36 UTC (rev 1984) +++ trunk/plugins/pluginmacros.h 2007-10-28 20:54:25 UTC (rev 1985) @@ -30,6 +30,7 @@ #define app geany_data->app #define doc_array geany_data->doc_array #define prefs geany_data->prefs +#define project app->project
#define dialogs geany_data->dialogs #define documents geany_data->document // avoids conflict with document typedef @@ -39,7 +40,7 @@ #define scintilla geany_data->sci #define support geany_data->support #define templates geany_data->templates -#define tm geany_data->tm +#define tagm geany_data->tm // avoids conflict with "struct tm *t" #define ui geany_data->ui #define utils geany_data->utils
Modified: trunk/plugins/svndiff.c =================================================================== --- trunk/plugins/svndiff.c 2007-10-28 17:02:36 UTC (rev 1984) +++ trunk/plugins/svndiff.c 2007-10-28 20:54:25 UTC (rev 1985) @@ -31,15 +31,12 @@ #include "filetypes.h" #include "utils.h" #include "project.h" +#include "pluginmacros.h"
PluginFields *plugin_fields; GeanyData *geany_data;
-#define utils geany_data->utils -#define ui geany_data->ui -#define doc_array geany_data->doc_array
- VERSION_CHECK(25)
PLUGIN_INFO(_("SVNdiff"), _("Plugin to create a patch of a file against svn"), VERSION) @@ -61,31 +58,29 @@ gchar *text = NULL; gchar *dir_enc = NULL;
- GeanyProject *geany_project = geany_data->app->project; + idx = documents->get_cur_idx();
- idx = geany_data->document->get_cur_idx(); - - if (geany_project != NULL && NZV(geany_project->base_path)) + if (project != NULL && NZV(project->base_path)) { if (doc_list[idx].file_name != NULL) { - geany_data->document->save_file(idx, FALSE); + documents->save_file(idx, FALSE); } - base_name = geany_project->base_path; - project_name = geany_project->name; + base_name = project->base_path; + project_name = project->name; } else if (doc_list[idx].file_name != NULL) { if (doc_list[idx].changed) { - geany_data->document->save_file(idx, FALSE); + documents->save_file(idx, FALSE); } locale_filename = utils->get_locale_from_utf8(doc_list[idx].file_name); base_name = g_path_get_dirname(locale_filename); } else if (doc_list[idx].file_name == NULL) { - if ( geany_data->dialogs->show_save_as() ) + if ( dialogs->show_save_as() ) { locale_filename = utils->get_locale_from_utf8(doc_list[idx].file_name); base_name = g_path_get_dirname(locale_filename); @@ -114,9 +109,9 @@ if (filename != NULL) // Be carefull with mixed up encodings { - text = geany_data->encoding->convert_to_utf8(std_output, -1, &dir_enc); - new_idx = geany_data->document->new_file(filename, NULL, std_output); - geany_data->document->set_encoding(new_idx, dir_enc); + text = encodings->convert_to_utf8(std_output, -1, &dir_enc); + new_idx = documents->new_file(filename, NULL, std_output); + documents->set_encoding(new_idx, dir_enc); g_free(text); g_free(dir_enc); g_free(filename); @@ -158,15 +153,15 @@ gchar *short_name = NULL; gchar *locale_filename = NULL;
- idx = geany_data->document->get_cur_idx(); + idx = documents->get_cur_idx();
if (doc_list[idx].file_name == NULL) { - geany_data->dialogs->show_save_as(); + dialogs->show_save_as(); } else if (doc_list[idx].changed) { - geany_data->document->save_file(idx, FALSE); + documents->save_file(idx, FALSE); }
// Stolen from export.c. Thanks for it, Enrico ;) @@ -196,7 +191,7 @@
// need to convert input text from the encoding of the original file into // UTF-8 because internally Geany always needs UTF-8 - text = geany_data->encoding->convert_to_utf8_from_charset( + text = encodings->convert_to_utf8_from_charset( std_output, -1, doc_list[idx].encoding, TRUE);
if (text == NULL) @@ -205,9 +200,9 @@ } else { - new_idx = geany_data->document->new_file(diff_file_name, + new_idx = documents->new_file(diff_file_name, geany_data->filetypes[GEANY_FILETYPES_DIFF], text); - geany_data->document->set_encoding(new_idx, doc_list[idx].encoding); + documents->set_encoding(new_idx, doc_list[idx].encoding); g_free(text); } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.