-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GeanyLua] geany.activate not activating document #1229
Comments
Relevant code is in /* Actvate and focus the specified document */
static gint glspi_activate(lua_State* L)
{
gint idx=-1;
if (lua_gettop(L)>0) {
if (lua_isnumber(L,1)) {
idx=(lua_tonumber(L,1));
if (idx<0) { /* Negative number refers to (absolute) GtkNotebook index */
idx=(0-idx)-1;
if (idx>=gtk_notebook_get_n_pages(NOTEBOOK)) { idx=-1;}
} else { /* A positive number refers to the geany->documents_array index */
idx=doc_idx_to_tab_idx(idx-1);
}
} else {
if (lua_isstring(L,1)) {
idx=doc_idx_to_tab_idx(filename_to_doc_idx(lua_tostring(L, 1)));
} else {
if (!lua_isnil(L,1)) { return FAIL_STR_OR_NUM_ARG(1); }
}
}
}
if (idx>=0) {
if (idx!=gtk_notebook_get_current_page(NOTEBOOK)) {
gtk_notebook_set_current_page(NOTEBOOK, idx);
}
}
lua_pushboolean(L, (idx>0));
return 1;
} |
I'm not sure the OPs code should do anything, correct me if I'm wrong, but AFAICT it gets the current document which is the one in the current notebook tab, then sets the notebook tab to that tab, but the code from above: if (idx!=gtk_notebook_get_current_page(NOTEBOOK)) {
gtk_notebook_set_current_page(NOTEBOOK, idx); makes it do nothing if the current tab == the tab requested == the tab of the current document == the document of the current tab so its guaranteed to do nothing. Even if it did set the notebook tab GTK does not say it grabs focus, so the Geanylua doc that says:
is wrong anyway. |
In my Lua test code, what I'm interested in is the return value. Even if the function ultimately doesn't have to switch tabs,
Okay. But the tab isn't changed. Even if focus isn't changed, changing the tab would be an improvement. (eg, if I'm on tab 3, call Presumably, this function did work at some time in GeanyLua's past? |
Ok, thats pretty clearly a bug. The OP seemed to keep using the current document so they would not have changed anything IIUC, so not sure what they meant to describe. For this bug [Edit: maybe there should be two different local variables, |
Even though that code does not change the tab, the return value should still be
I'll poke at |
geany.activate()
is supposed activate a document and return true. If it is unable, it returns false. However, it is not activating the document. Accepted arguments are a tab id (negative numbers), document id (positive numbers), or full document path. Test code attempting to callgeany.activate()
with the document id (test1) and path (test2) follows:Results in status window are:
For reference, an excerpt from the GeanyLua documentation:
The text was updated successfully, but these errors were encountered: