feat(api): add get_current_window call
Some checks failed
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 27s
CI API Docs / Test Python API Documentation Generation (pull_request) Successful in 29s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Linux (debian) (pull_request) Successful in 13m22s
CI Code / Linux (arch) (pull_request) Successful in 13m27s
CI Code / Linux (ubuntu) (pull_request) Successful in 13m36s
CI API Docs / Test C API Documentation Generation (push) Successful in 1m2s
CI Code / Check spelling (push) Has been cancelled
CI Code / Check coding style (push) Has been cancelled
CI Code / Linux (ubuntu) (push) Has been cancelled
CI Code / Linux (debian) (push) Has been cancelled
CI API Docs / Test Python API Documentation Generation (push) Successful in 1m8s
CI Code / Linux (arch) (push) Successful in 9m24s
Some checks failed
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 27s
CI API Docs / Test Python API Documentation Generation (pull_request) Successful in 29s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Linux (debian) (pull_request) Successful in 13m22s
CI Code / Linux (arch) (pull_request) Successful in 13m27s
CI Code / Linux (ubuntu) (pull_request) Successful in 13m36s
CI API Docs / Test C API Documentation Generation (push) Successful in 1m2s
CI Code / Check spelling (push) Has been cancelled
CI Code / Check coding style (push) Has been cancelled
CI Code / Linux (ubuntu) (push) Has been cancelled
CI Code / Linux (debian) (push) Has been cancelled
CI API Docs / Test Python API Documentation Generation (push) Successful in 1m8s
CI Code / Linux (arch) (push) Successful in 9m24s
Add prof_get_current_window API to retrieve the title of the currently active window, matching the titlebar display. The feature is especially useful to track currently used plugin window.
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
#include "plugins/settings.h"
|
||||
#include "plugins/disco.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
|
||||
@@ -205,6 +206,13 @@ api_get_current_recipient(void)
|
||||
}
|
||||
}
|
||||
|
||||
gchar*
|
||||
api_get_current_window(void)
|
||||
{
|
||||
ProfWin* current = wins_get_current();
|
||||
return win_get_title(current);
|
||||
}
|
||||
|
||||
char*
|
||||
api_get_current_muc(void)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ void api_notify(const char* message, const char* category, int timeout_ms);
|
||||
void api_send_line(char* line);
|
||||
|
||||
char* api_get_current_recipient(void);
|
||||
gchar* api_get_current_window(void);
|
||||
char* api_get_current_muc(void);
|
||||
gboolean api_current_win_is_console(void);
|
||||
char* api_get_current_nick(void);
|
||||
|
||||
@@ -165,6 +165,12 @@ c_api_get_current_recipient(void)
|
||||
return api_get_current_recipient();
|
||||
}
|
||||
|
||||
static char*
|
||||
c_api_get_current_window(void)
|
||||
{
|
||||
return api_get_current_window();
|
||||
}
|
||||
|
||||
static char*
|
||||
c_api_get_current_muc(void)
|
||||
{
|
||||
@@ -477,6 +483,7 @@ c_api_init(void)
|
||||
prof_notify = c_api_notify;
|
||||
prof_send_line = c_api_send_line;
|
||||
prof_get_current_recipient = c_api_get_current_recipient;
|
||||
prof_get_current_window = c_api_get_current_window;
|
||||
prof_get_current_muc = c_api_get_current_muc;
|
||||
prof_current_win_is_console = c_api_current_win_is_console;
|
||||
prof_get_current_nick = c_api_get_current_nick;
|
||||
|
||||
@@ -62,6 +62,7 @@ void (*prof_notify)(const char* message, int timeout_ms, const char* category) =
|
||||
void (*prof_send_line)(char* line) = NULL;
|
||||
|
||||
char* (*prof_get_current_recipient)(void) = NULL;
|
||||
char* (*prof_get_current_window)(void) = NULL;
|
||||
char* (*prof_get_current_muc)(void) = NULL;
|
||||
int (*prof_current_win_is_console)(void) = NULL;
|
||||
char* (*prof_get_current_nick)(void) = NULL;
|
||||
|
||||
@@ -71,6 +71,7 @@ void (*prof_notify)(const char* message, int timeout_ms, const char* category);
|
||||
void (*prof_send_line)(char* line);
|
||||
|
||||
char* (*prof_get_current_recipient)(void);
|
||||
char* (*prof_get_current_window)(void);
|
||||
char* (*prof_get_current_muc)(void);
|
||||
int (*prof_current_win_is_console)(void);
|
||||
char* (*prof_get_current_nick)(void);
|
||||
|
||||
@@ -415,6 +415,15 @@ python_api_get_current_recipient(PyObject* self, PyObject* args)
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
python_api_get_current_window(PyObject* self, PyObject* args)
|
||||
{
|
||||
allow_python_threads();
|
||||
auto_gchar gchar* recipient = api_get_current_window();
|
||||
disable_python_threads();
|
||||
return Py_BuildValue("s", recipient);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
python_api_get_current_muc(PyObject* self, PyObject* args)
|
||||
{
|
||||
@@ -1530,6 +1539,7 @@ static PyMethodDef apiMethods[] = {
|
||||
{ "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
|
||||
{ "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
|
||||
{ "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
|
||||
{ "get_current_window", python_api_get_current_window, METH_VARARGS, "Return title of the current window." },
|
||||
{ "get_current_muc", python_api_get_current_muc, METH_VARARGS, "Return the jid of the room of the current window." },
|
||||
{ "get_current_nick", python_api_get_current_nick, METH_VARARGS, "Return nickname in current room." },
|
||||
{ "get_name_from_roster", python_api_get_name_from_roster, METH_VARARGS, "Return nickname in roster of barejid." },
|
||||
|
||||
Reference in New Issue
Block a user