Revision: 97 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=97&view=rev Author: ntrel Date: 2008-07-01 05:06:25 -0700 (Tue, 01 Jul 2008)
Log Message: ----------- Begin updating for Geany 0.15 API changes. Use main_widgets instead of old app. Include some Geany headers due to moved definitions. Add glspi_geany_functions. Use new _prefs structs.
Modified Paths: -------------- trunk/geanylua/ChangeLog trunk/geanylua/geanylua.c trunk/geanylua/glspi.h trunk/geanylua/glspi_app.c trunk/geanylua/glspi_dlg.c trunk/geanylua/glspi_doc.c trunk/geanylua/glspi_init.c trunk/geanylua/glspi_run.c trunk/geanylua/glspi_sci.c
Modified: trunk/geanylua/ChangeLog =================================================================== --- trunk/geanylua/ChangeLog 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/ChangeLog 2008-07-01 12:06:25 UTC (rev 97) @@ -1,3 +1,10 @@ +July 1, 2008 (ntrel) + Begin updating for Geany 0.15 API changes. + Use main_widgets instead of old app. + Include some Geany headers due to moved definitions. + Add glspi_geany_functions. + Use new _prefs structs. + Mar 24, 2008 Released version 0.7.0
@@ -16,7 +23,7 @@ no longer requires the --with-geany-src option.
Mar 13, 2008 - Added support for Geany's new built-in keybinding API. + Added support for Geany's new built-in keybinding API. This means that scripts can now take advantage of Geany's preferences system to configure keybindings. See ./docs/geanylua-keys.html for more info. @@ -100,8 +107,8 @@ The timeout measurement now pauses the timer while dialogs are displayed, rather than setting the timer back to zero for each dialog. Actually it considers the time spent as 1/10 of a second, to keep timeouts working - even if you create an endless loop with a dialog inside. But even still, - you might need to click a lot of buttons before the timer expires! + even if you create an endless loop with a dialog inside. But even still, + you might need to click a lot of buttons before the timer expires!
Jan 10, 2008 Revamped the ugly and broken goto_error() function. Trying to parse the @@ -114,7 +121,7 @@ But for now it's the only way I know how, and at least now it's working.
Jan 8, 2008 - The "geanylua.c" file was getting a bit too large to navigate easily, + The "geanylua.c" file was getting a bit too large to navigate easily, so I moved most of the lua-related code into a new file, "glspi_run.c" Added some new features to the filename-to-menu-label generator, a trailing underscore in the filename will create an ellipsis after for the menu label, @@ -149,7 +156,7 @@ ways which can't currently be detected. ) Also added a timeout() function to allow script authors to increase or even completely disable the timeout if needed. - + Jan 2, 2008 Released version 0.5.1 Fix to compile against Geany-SVN-r2145 (API Ver 37) @@ -161,7 +168,7 @@
Jan 1, 2008 Added files "win32-install.vbs" and "win32-uninstall.vbs" to hopefully - simplify windows installation. Likewise, added the file "install.sh" + simplify windows installation. Likewise, added the file "install.sh" to the pre-compiled Linux-x86 archive.
Dec. 28, 2007 @@ -209,7 +216,7 @@ a new Lua "keyfile" module to manipulate this type of object.
Nov 20, 2007 - Added PLUGIN_AUTHOR define for API compatibility. + Added PLUGIN_AUTHOR define for API compatibility. Added a function to display a customized configure dialog for Geany's new plugin manager.
@@ -258,7 +265,7 @@
Oct 13, 2007 - Bumped versions: plugin=0.3, API=20 to correspond with "official" + Bumped versions: plugin=0.3, API=20 to correspond with "official" Geany 0.12 release.
Modified: trunk/geanylua/geanylua.c =================================================================== --- trunk/geanylua/geanylua.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/geanylua.c 2008-07-01 12:06:25 UTC (rev 97) @@ -54,12 +54,15 @@ PLUGIN_INFO(PLUGIN_NAME, PLUGIN_DESC, PLUGIN_VER, PLUGIN_AUTHOR)
PLUGIN_EXPORT +GeanyFunctions *geany_functions; + +PLUGIN_EXPORT KeyBindingGroup plugin_key_group[1];
-typedef void (*InitFunc) (GeanyData *data, KeyBindingGroup *kg); +typedef void (*InitFunc) (GeanyData *data, GeanyFunctions *functions, KeyBindingGroup *kg); typedef void (*ConfigFunc) (GtkWidget *parent); typedef void (*CleanupFunc) (void);
@@ -167,7 +170,7 @@ } copy_callbacks();
- glspi_init(data, plugin_key_group); + glspi_init(data, geany_functions, plugin_key_group); }
@@ -177,7 +180,7 @@ if (glspi_configure) { glspi_configure(parent); } else { - geany_data->dialogs->show_msgbox(GTK_MESSAGE_ERROR, + geany_functions->p_dialogs->show_msgbox(GTK_MESSAGE_ERROR, _("The "PLUGIN_NAME" plugin failed to load properly.\n" "Please check your installation.") ); }
Modified: trunk/geanylua/glspi.h =================================================================== --- trunk/geanylua/glspi.h 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi.h 2008-07-01 12:06:25 UTC (rev 97) @@ -21,6 +21,7 @@ #include "plugindata.h" #include "sciwrappers.h" #include "keybindings.h" +#include "ui_utils.h"
#include "pluginmacros.h"
@@ -86,7 +87,11 @@
#define geany_data glspi_geany_data
+extern GeanyFunctions *glspi_geany_functions;
+#define geany_functions glspi_geany_functions + + #ifdef NEED_FAIL_ARG_TYPE /* Pushes an error message onto Lua stack if script passes a wrong arg type */ static gint glspi_fail_arg_type(lua_State *L, const gchar *func, gint argnum, gchar *type)
Modified: trunk/geanylua/glspi_app.c =================================================================== --- trunk/geanylua/glspi_app.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi_app.c 2008-07-01 12:06:25 UTC (rev 97) @@ -12,6 +12,7 @@ #define NEED_FAIL_ARG_TYPE #include "glspi.h"
+#include "templates.h"
@@ -31,11 +32,11 @@ static gint glspi_tools(lua_State* L) { lua_newtable(L); - SetTableStr("browser", prefs->tools_browser_cmd); - SetTableStr("make", prefs->tools_make_cmd); - SetTableStr("term", prefs->tools_term_cmd); - SetTableStr("grep", prefs->tools_grep_cmd); - SetTableStr("action", prefs->context_action_cmd); + SetTableStr("browser", geany_data->tool_prefs->browser_cmd); + SetTableStr("make", geany_data->tool_prefs->make_cmd); + SetTableStr("term", geany_data->tool_prefs->term_cmd); + SetTableStr("grep", geany_data->tool_prefs->grep_cmd); + SetTableStr("action", geany_data->tool_prefs->context_action_cmd); return 1; }
@@ -43,11 +44,11 @@ static gint glspi_template(lua_State* L) { lua_newtable(L); - SetTableStr("developer", prefs->template_developer); - SetTableStr("company", prefs->template_company); - SetTableStr("mail", prefs->template_mail); - SetTableStr("initial", prefs->template_initial); - SetTableStr("version", prefs->template_version); + SetTableStr("developer", geany_data->template_prefs->developer); + SetTableStr("company", geany_data->template_prefs->company); + SetTableStr("mail", geany_data->template_prefs->mail); + SetTableStr("initial", geany_data->template_prefs->initials); + SetTableStr("version", geany_data->template_prefs->version); return 1; }
@@ -144,7 +145,7 @@ if (!lua_isstring(L,1) ) { return FAIL_STRING_ARG(1); } widname=lua_tostring(L,1); signame=lua_tostring(L,2); - w=p_support->lookup_widget(app->window, widname); + w=p_support->lookup_widget(main_widgets->window, widname); if (!w) { lua_pushfstring(L, _("Error in module "%s" at function %s():\n" "widget "%s" not found for argument #1.\n "), @@ -581,7 +582,7 @@ gint pos=p_sci->get_position_from_line(doc->sci, fvl+1); sci_send_message(doc->sci,SCI_CALLTIPSHOW,pos+3, (gint)prompt); } - gdk_window_add_filter(app->window->window, keygrab_cb, &km); + gdk_window_add_filter(main_widgets->window->window, keygrab_cb, &km); do { while (gtk_events_pending()) { if (km.group==2) { break; } @@ -591,7 +592,7 @@ dosleep(); } while (km.group!=2);
- gdk_window_remove_filter(app->window->window, keygrab_cb, &km); + gdk_window_remove_filter(main_widgets->window->window, keygrab_cb, &km); if (prompt && doc && doc->is_valid) { p_sci->send_command(doc->sci, SCI_CALLTIPCANCEL); }
Modified: trunk/geanylua/glspi_dlg.c =================================================================== --- trunk/geanylua/glspi_dlg.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi_dlg.c 2008-07-01 12:06:25 UTC (rev 97) @@ -47,7 +47,7 @@ banner=DEFAULT_BANNER; lua_getglobal(L, LUA_MODULE_NAME); lua_pushstring(L,tokenBanner); - lua_pushstring(L,banner); + lua_pushstring(L,banner); lua_settable(L, -3); } } @@ -55,8 +55,8 @@ }
-/* - The GtkMessageDialog wants format strings, but we want literals. +/* + The GtkMessageDialog wants format strings, but we want literals. So we need to replace all '%' with "%%" */ static gchar*pct_esc(const gchar*s) @@ -73,7 +73,7 @@ static GtkWidget*new_dlg(gint msg_type, gint buttons, const gchar*msg1, const gchar*msg2) { gchar *tmp=pct_esc(msg1); - GtkWidget*rv=gtk_message_dialog_new(GTK_WINDOW(app->window), + GtkWidget*rv=gtk_message_dialog_new(GTK_WINDOW(main_widgets->window), DIALOG_FLAGS, msg_type, buttons, "%s", tmp?tmp:msg1);
if (tmp) { @@ -401,7 +401,7 @@ static gchar *file_dlg(lua_State* L, gboolean save, const gchar *path, const gchar *mask, const gchar *name) { gchar *rv=NULL; - gchar *fullname = NULL; + gchar *fullname = NULL; GtkWidget*dlg=NULL; #if NEED_OVERWRITE_PROMPT gboolean accepted=FALSE; @@ -409,7 +409,7 @@ gint resp=GTK_RESPONSE_CANCEL; if (save) { dlg=gtk_file_chooser_dialog_new(_("Save file"), - GTK_WINDOW(app->window), GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_WINDOW(main_widgets->window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); #if NEED_OVERWRITE_PROMPT @@ -419,7 +419,7 @@ #endif } else { dlg=gtk_file_chooser_dialog_new(_("Open file"), - GTK_WINDOW(app->window), GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_WINDOW(main_widgets->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); } @@ -453,7 +453,7 @@ #endif if (resp == GTK_RESPONSE_ACCEPT) { rv=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlg)); - } + } gtk_widget_destroy(dlg); if (fullname) {g_free(fullname);} return rv; @@ -482,7 +482,7 @@ const gchar*tmp=lua_tostring(L,1); if (strcasecmp(tmp,"save")==0) { save=TRUE; - } else + } else if ( (*tmp != '\0') && (strcasecmp(tmp,"open")!=0) ) { lua_pushfstring(L, _("Error in module "%s" at function %s():\n" "expected string "open" or "save" for argument #1.\n "),
Modified: trunk/geanylua/glspi_doc.c =================================================================== --- trunk/geanylua/glspi_doc.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi_doc.c 2008-07-01 12:06:25 UTC (rev 97) @@ -10,7 +10,7 @@
#define DOCS ((document*)(doc_array->data)) -#define NOTEBOOK GTK_NOTEBOOK(app->notebook) +#define NOTEBOOK GTK_NOTEBOOK(main_widgets->notebook)
#ifdef G_OS_WIN32
Modified: trunk/geanylua/glspi_init.c =================================================================== --- trunk/geanylua/glspi_init.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi_init.c 2008-07-01 12:06:25 UTC (rev 97) @@ -32,6 +32,7 @@ const gchar* glspi_version = VERSION;
GeanyData *glspi_geany_data=NULL; +GeanyFunctions *glspi_geany_functions=NULL;
static struct { GtkWidget *menu_item; @@ -39,8 +40,8 @@ gchar *on_saved_script; gchar *on_created_script; gchar *on_opened_script; - gchar *on_activated_script; - gchar *on_init_script; + gchar *on_activated_script; + gchar *on_init_script; gchar *on_cleanup_script; gchar *on_configure_script; gchar *on_proj_opened_script; @@ -356,7 +357,7 @@ if (g_file_test(data,G_FILE_TEST_IS_DIR)) { gchar*label=strrchr(data,DIR_SEP[0]); if (label) { label++; } else { label=data; } - if ((strcasecmp(label,"events")!=0)&&(strcasecmp(label,"support")!=0)) { + if ((strcasecmp(label,"events")!=0)&&(strcasecmp(label,"support")!=0)) { label=g_strdup(label); fixup_label(label); new_menu(user_data, data, label); /* Recursive */ @@ -369,7 +370,7 @@
/* - * Borrowed from Geany's utils_get_file_list() but modified because I want the + * Borrowed from Geany's utils_get_file_list() but modified because I want the * list to store the full path to each file... * * Gets a sorted list of files in the specified directory. @@ -383,7 +384,7 @@ GError *err = NULL; g_return_val_if_fail(path && *path, NULL); dir = g_dir_open(path, 0, &err); - if (dir) { + if (dir) { while (1) { const gchar *filename = g_dir_read_name(dir); if (!filename) { break; } @@ -420,9 +421,10 @@ { local_data.script_list = NULL; local_data.acc_grp=NULL; - local_data.menu_item=new_menu(geany_data->tools_menu, local_data.script_dir, _("_Lua Scripts")); + local_data.menu_item=new_menu(main_widgets->tools_menu, + local_data.script_dir, _("_Lua Scripts")); if (local_data.acc_grp) { - gtk_window_add_accel_group(GTK_WINDOW(app->window), local_data.acc_grp); + gtk_window_add_accel_group(GTK_WINDOW(main_widgets->window), local_data.acc_grp); } }
@@ -430,9 +432,10 @@
/* Called by Geany to initialize the plugin */ PLUGIN_EXPORT -void glspi_init (GeanyData *data, KeyBindingGroup *kg) +void glspi_init (GeanyData *data, GeanyFunctions *functions, KeyBindingGroup *kg) { glspi_geany_data = data; + glspi_geany_functions = functions;
local_data.script_dir = g_strconcat(app->configdir, SCRIPT_FOLDER, NULL); @@ -443,7 +446,7 @@ g_strconcat(app->datadir, SCRIPT_FOLDER, NULL); } if (app->debug_mode) { - g_printerr(_(" ==>> %s: Building menu from '%s'\n"), + g_printerr(_(" ==>> %s: Building menu from '%s'\n"), PLUGIN_NAME, local_data.script_dir); } local_data.on_saved_script = @@ -509,14 +512,14 @@ done(on_saved_script); done(on_created_script); done(on_opened_script); - done(on_activated_script); - done(on_init_script); + done(on_activated_script); + done(on_init_script); done(on_cleanup_script); done(on_configure_script); done(on_proj_opened_script); done(on_proj_saved_script); done(on_proj_closed_script); - + if (local_data.script_list) { g_slist_foreach(local_data.script_list, free_script_names, NULL); g_slist_free(local_data.script_list); @@ -533,7 +536,7 @@ /* Called by geany when user clicks preferences button in plugin manager dialog. -*/ +*/ PLUGIN_EXPORT void glspi_configure(GtkWidget *parent) {
Modified: trunk/geanylua/glspi_run.c =================================================================== --- trunk/geanylua/glspi_run.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi_run.c 2008-07-01 12:06:25 UTC (rev 97) @@ -7,6 +7,7 @@ #define NEED_FAIL_ARG_TYPE #include "glspi.h"
+#include "editor.h"
@@ -48,7 +49,7 @@ document* doc=p_document->get_current(); if ( doc && doc->is_valid ) { gdk_window_invalidate_rect(GTK_WIDGET(doc->sci)->window, NULL, TRUE); - gdk_window_process_updates(GTK_WIDGET(doc->sci)->window, TRUE); + gdk_window_process_updates(GTK_WIDGET(doc->sci)->window, TRUE); } }
@@ -60,7 +61,7 @@ GtkWidget *dialog, *yes_btn, *no_btn; GtkResponseType dv, rv; dv=default_result?GTK_RESPONSE_YES:GTK_RESPONSE_NO; - dialog=gtk_message_dialog_new(GTK_WINDOW(app->window), + dialog=gtk_message_dialog_new(GTK_WINDOW(main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", title); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", question); @@ -99,25 +100,25 @@
/* Display a message box showing any script error... - Depending on the type of error, Lua will sometimes prepend the filename + Depending on the type of error, Lua will sometimes prepend the filename to the message. If need_name is TRUE then we assume that Lua didn't add the filename, so we prepend it ourself. If need_name is FALSE, then the - error message likely contains a filename *and* a line number, so we - give the user an option to automatically open the file and scroll to + error message likely contains a filename *and* a line number, so we + give the user an option to automatically open the file and scroll to the offending line. */ static void glspi_script_error(gchar *script_file, const gchar *msg, gboolean need_name, gint line) { GtkWidget *dialog; if (need_name) { - dialog=gtk_message_dialog_new(GTK_WINDOW(app->window), + dialog=gtk_message_dialog_new(GTK_WINDOW(main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Lua script error:")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s:\n%s", script_file, msg); } else { GtkWidget *open_btn, *cancel_btn; - dialog=gtk_message_dialog_new(GTK_WINDOW(app->window), + dialog=gtk_message_dialog_new(GTK_WINDOW(main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, _("Lua script error:")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", msg); @@ -176,7 +177,7 @@
static gint glspi_timeout(lua_State* L) { - if (( lua_gettop(L) > 0 ) && lua_isnumber(L,1)) { + if (( lua_gettop(L) > 0 ) && lua_isnumber(L,1)) { gint n=lua_tonumber(L,1); if (n>=0) { StateInfo*si=find_state(L); @@ -234,8 +235,8 @@ } } if (si->counter > 100000) { - gdk_window_invalidate_rect(app->window->window, NULL, TRUE); - gdk_window_process_updates(app->window->window, TRUE); + gdk_window_invalidate_rect(main_widgets->window->window, NULL, TRUE); + gdk_window_process_updates(main_widgets->window->window, TRUE); si->counter=0; } else si->counter++; } @@ -340,11 +341,11 @@ */
static void set_string_token(lua_State *L, gchar*name, gchar*value) -{ +{ lua_getglobal(L, LUA_MODULE_NAME); if (lua_istable(L, -1)) { lua_pushstring(L,name); - lua_pushstring(L,value); + lua_pushstring(L,value); lua_settable(L, -3); } else { g_printerr("*** %s: Failed to set value for %s\n", PLUGIN_NAME, name); @@ -354,11 +355,11 @@
static void set_numeric_token(lua_State *L, gchar*name, gint value) -{ +{ lua_getglobal(L, LUA_MODULE_NAME); if (lua_istable(L, -1)) { lua_pushstring(L,name); - push_number(L,value); + push_number(L,value); lua_settable(L, -3); } else { g_printerr("*** %s: Failed to set value for %s\n", PLUGIN_NAME, name); @@ -368,11 +369,11 @@
static void set_boolean_token(lua_State *L, gchar*name, gboolean value) -{ +{ lua_getglobal(L, LUA_MODULE_NAME); if (lua_istable(L, -1)) { lua_pushstring(L,name); - lua_pushboolean(L,value); + lua_pushboolean(L,value); lua_settable(L, -3); } else { g_printerr("*** %s: Failed to set value for %s\n", PLUGIN_NAME, name); @@ -382,7 +383,7 @@
static void set_keyfile_token(lua_State *L, gchar*name, GKeyFile* value) -{ +{ if (!value) {return;} lua_getglobal(L, LUA_MODULE_NAME); if (lua_istable(L, -1)) { @@ -429,7 +430,7 @@ set_string_token(L,tokenDirSep, G_DIR_SEPARATOR_S); set_boolean_token(L,tokenRectSel,FALSE); set_numeric_token(L,tokenCaller, caller); - glspi_init_gsdlg_module(L,glspi_pause_timer, geany_data?GTK_WINDOW(app->window):NULL); + glspi_init_gsdlg_module(L,glspi_pause_timer, geany_data?GTK_WINDOW(main_widgets->window):NULL); glspi_init_kfile_module(L,&glspi_kfile_assign); set_keyfile_token(L,tokenProject, proj); set_string_token(L,tokenScript,script_file); @@ -470,7 +471,7 @@ status = lua_pcall(L, 0, 0, base); lua_remove(L, base); /* remove traceback function */ if (0 == status) { - status = lua_pcall(L, 0, 0, 0); + status = lua_pcall(L, 0, 0, 0); } else { lua_gc(L, LUA_GCCOLLECT, 0); /* force garbage collection if error */ show_error(L, script_file);
Modified: trunk/geanylua/glspi_sci.c =================================================================== --- trunk/geanylua/glspi_sci.c 2008-06-30 14:49:43 UTC (rev 96) +++ trunk/geanylua/glspi_sci.c 2008-07-01 12:06:25 UTC (rev 97) @@ -10,9 +10,11 @@ #include "glspi.h" #include "glspi_sci.h"
+#include "editor.h"
+ /* Get or Set the entire text of the currently active Geany document */ static gint glspi_text(lua_State* L) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.