Kaydet (Commit) dd67516a authored tarafından Enrico Tröger's avatar Enrico Tröger

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.	    


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1985 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 2d77d301
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
/* Export plugin. */ /* Export plugin. */
#include <ctype.h>
#include "geany.h" #include "geany.h"
#include "support.h" #include "support.h"
#include "plugindata.h" #include "plugindata.h"
...@@ -31,7 +33,7 @@ ...@@ -31,7 +33,7 @@
#include "document.h" #include "document.h"
#include "prefs.h" #include "prefs.h"
#include "utils.h" #include "utils.h"
#include <ctype.h> #include "pluginmacros.h"
PluginFields *plugin_fields; PluginFields *plugin_fields;
...@@ -40,13 +42,6 @@ GeanyData *geany_data; ...@@ -40,13 +42,6 @@ GeanyData *geany_data;
VERSION_CHECK(20) VERSION_CHECK(20)
PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."), VERSION) 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) \ #define ROTATE_RGB(color) \
(((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16) (((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16)
#define TEMPLATE_HTML "\ #define TEMPLATE_HTML "\
...@@ -163,15 +158,15 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func, ...@@ -163,15 +158,15 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
if (extension == NULL) if (extension == NULL)
return; return;
idx = geany_data->document->get_cur_idx(); idx = documents->get_cur_idx();
tooltips = GTK_TOOLTIPS(support->lookup_widget(geany_data->app->window, "tooltips")); tooltips = GTK_TOOLTIPS(support->lookup_widget(app->window, "tooltips"));
exi = g_new(ExportInfo, 1); exi = g_new(ExportInfo, 1);
exi->idx = idx; exi->idx = idx;
exi->export_func = func; exi->export_func = func;
exi->have_zoom_level_checkbox = FALSE; 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_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
...@@ -206,7 +201,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func, ...@@ -206,7 +201,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
g_signal_connect((gpointer) dialog, "response", g_signal_connect((gpointer) dialog, "response",
G_CALLBACK(on_file_save_dialog_response), exi); 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. // if the current document has a filename we use it as the default.
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog)); gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
...@@ -229,7 +224,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func, ...@@ -229,7 +224,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
} }
else 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); gchar *fname = g_strconcat(GEANY_STRING_UNTITLED, extension, NULL);
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog)); gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
...@@ -568,7 +563,7 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom) ...@@ -568,7 +563,7 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
} }
// read Geany's font and font size // 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_name = pango_font_description_get_family(font_desc);
//font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE; //font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;
// take the zoom level also into account // take the zoom level also into account
......
...@@ -66,18 +66,18 @@ static gchar *current_dir = NULL; // in locale-encoding ...@@ -66,18 +66,18 @@ static gchar *current_dir = NULL; // in locale-encoding
// Returns: whether name should be hidden. // Returns: whether name should be hidden.
static gboolean check_hidden(const gchar *basename) static gboolean check_hidden(const gchar *base_name)
{ {
gsize len; gsize len;
if (! NZV(basename)) if (! NZV(base_name))
return FALSE; return FALSE;
if (basename[0] == '.') if (base_name[0] == '.')
return TRUE; return TRUE;
len = strlen(basename); len = strlen(base_name);
if (basename[len - 1] == '~') if (base_name[len - 1] == '~')
return TRUE; return TRUE;
if (hide_object_files) if (hide_object_files)
...@@ -89,7 +89,7 @@ static gboolean check_hidden(const gchar *basename) ...@@ -89,7 +89,7 @@ static gboolean check_hidden(const gchar *basename)
{ {
const gchar *ext = exts[i]; 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; return TRUE;
} }
} }
...@@ -154,7 +154,7 @@ static void refresh() ...@@ -154,7 +154,7 @@ static void refresh()
clear(); clear();
// TODO: really, we don't want to dereference symlinks // 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); utf8_dir = utils->get_utf8_from_locale(current_dir);
gtk_entry_set_text(GTK_ENTRY(path_entry), utf8_dir); gtk_entry_set_text(GTK_ENTRY(path_entry), utf8_dir);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define app geany_data->app #define app geany_data->app
#define doc_array geany_data->doc_array #define doc_array geany_data->doc_array
#define prefs geany_data->prefs #define prefs geany_data->prefs
#define project app->project
#define dialogs geany_data->dialogs #define dialogs geany_data->dialogs
#define documents geany_data->document // avoids conflict with document typedef #define documents geany_data->document // avoids conflict with document typedef
...@@ -39,7 +40,7 @@ ...@@ -39,7 +40,7 @@
#define scintilla geany_data->sci #define scintilla geany_data->sci
#define support geany_data->support #define support geany_data->support
#define templates geany_data->templates #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 ui geany_data->ui
#define utils geany_data->utils #define utils geany_data->utils
......
...@@ -31,14 +31,11 @@ ...@@ -31,14 +31,11 @@
#include "filetypes.h" #include "filetypes.h"
#include "utils.h" #include "utils.h"
#include "project.h" #include "project.h"
#include "pluginmacros.h"
PluginFields *plugin_fields; PluginFields *plugin_fields;
GeanyData *geany_data; GeanyData *geany_data;
#define utils geany_data->utils
#define ui geany_data->ui
#define doc_array geany_data->doc_array
VERSION_CHECK(25) VERSION_CHECK(25)
...@@ -61,31 +58,29 @@ static void svndirectory_activated(GtkMenuItem *menuitem, gpointer gdata) ...@@ -61,31 +58,29 @@ static void svndirectory_activated(GtkMenuItem *menuitem, gpointer gdata)
gchar *text = NULL; gchar *text = NULL;
gchar *dir_enc = 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) 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; base_name = project->base_path;
project_name = geany_project->name; project_name = project->name;
} }
else if (doc_list[idx].file_name != NULL) else if (doc_list[idx].file_name != NULL)
{ {
if (doc_list[idx].changed) 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); locale_filename = utils->get_locale_from_utf8(doc_list[idx].file_name);
base_name = g_path_get_dirname(locale_filename); base_name = g_path_get_dirname(locale_filename);
} }
else if (doc_list[idx].file_name == NULL) 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); locale_filename = utils->get_locale_from_utf8(doc_list[idx].file_name);
base_name = g_path_get_dirname(locale_filename); base_name = g_path_get_dirname(locale_filename);
...@@ -114,9 +109,9 @@ static void svndirectory_activated(GtkMenuItem *menuitem, gpointer gdata) ...@@ -114,9 +109,9 @@ static void svndirectory_activated(GtkMenuItem *menuitem, gpointer gdata)
if (filename != NULL) if (filename != NULL)
// Be carefull with mixed up encodings // Be carefull with mixed up encodings
{ {
text = geany_data->encoding->convert_to_utf8(std_output, -1, &dir_enc); text = encodings->convert_to_utf8(std_output, -1, &dir_enc);
new_idx = geany_data->document->new_file(filename, NULL, std_output); new_idx = documents->new_file(filename, NULL, std_output);
geany_data->document->set_encoding(new_idx, dir_enc); documents->set_encoding(new_idx, dir_enc);
g_free(text); g_free(text);
g_free(dir_enc); g_free(dir_enc);
g_free(filename); g_free(filename);
...@@ -158,15 +153,15 @@ static void svnfile_activated(GtkMenuItem *menuitem, gpointer gdata) ...@@ -158,15 +153,15 @@ static void svnfile_activated(GtkMenuItem *menuitem, gpointer gdata)
gchar *short_name = NULL; gchar *short_name = NULL;
gchar *locale_filename = NULL; gchar *locale_filename = NULL;
idx = geany_data->document->get_cur_idx(); idx = documents->get_cur_idx();
if (doc_list[idx].file_name == NULL) if (doc_list[idx].file_name == NULL)
{ {
geany_data->dialogs->show_save_as(); dialogs->show_save_as();
} }
else if (doc_list[idx].changed) 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 ;) // Stolen from export.c. Thanks for it, Enrico ;)
...@@ -196,7 +191,7 @@ static void svnfile_activated(GtkMenuItem *menuitem, gpointer gdata) ...@@ -196,7 +191,7 @@ static void svnfile_activated(GtkMenuItem *menuitem, gpointer gdata)
// need to convert input text from the encoding of the original file into // need to convert input text from the encoding of the original file into
// UTF-8 because internally Geany always needs UTF-8 // 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); std_output, -1, doc_list[idx].encoding, TRUE);
if (text == NULL) if (text == NULL)
...@@ -205,9 +200,9 @@ static void svnfile_activated(GtkMenuItem *menuitem, gpointer gdata) ...@@ -205,9 +200,9 @@ static void svnfile_activated(GtkMenuItem *menuitem, gpointer gdata)
} }
else 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->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); g_free(text);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment