Add prof.get_current_window to Retrieve Current Window Title (API change) #35
@@ -185,6 +185,17 @@ void prof_send_line(char *line);
|
||||
*/
|
||||
char* prof_get_current_recipient(void);
|
||||
|
||||
/**
|
||||
* Gets the title of the current window as shown in the titlebar.
|
||||
*
|
||||
* Special cases:
|
||||
* - MUC configuration window: Includes "config" and an asterisk if modified (e.g., "room@example.com config *").
|
||||
* - vCard window: Includes the bare JID and an asterisk if modified (e.g., "vCard user@example.com *").
|
||||
*
|
||||
* @return A null-terminated string containing the window title. The caller must free the returned string.
|
||||
*/
|
||||
char* prof_get_current_window(void);
|
||||
|
||||
/**
|
||||
* Gets the Jabber ID of the current chat room.
|
||||
* @return The room Jabber ID (e.g., "metalchat@conference.example.com") or NULL if not in a room.
|
||||
@@ -198,7 +209,7 @@ char* prof_get_current_muc(void);
|
||||
int prof_current_win_is_console(void);
|
||||
|
||||
/**
|
||||
* Gets the user’s nickname in the current chat room.
|
||||
* Gets the user's nickname in the current chat room.
|
||||
* @return The nickname (e.g., "eddie") or NULL if not in a room.
|
||||
*/
|
||||
char* prof_get_current_nick(void);
|
||||
@@ -225,7 +236,7 @@ char** prof_get_current_occupants(void);
|
||||
|
||||
/**
|
||||
* Gets the current nickname in a chat room.
|
||||
* @param barejid The room’s Jabber ID.
|
||||
* @param barejid The room's Jabber ID.
|
||||
* @return The nickname.
|
||||
*/
|
||||
char* prof_get_room_nick(const char* barejid);
|
||||
@@ -511,7 +522,7 @@ void prof_settings_int_set(char *group, char *key, int value);
|
||||
void prof_incoming_message(char* barejid, char* resource, char* message);
|
||||
|
||||
/**
|
||||
* Adds a service discovery feature to CProof’s supported features.
|
||||
* Adds a service discovery feature to CProof's supported features.
|
||||
* Sends a presence update if a session is connected.
|
||||
* @param feature The feature to add.
|
||||
*
|
||||
@@ -547,7 +558,7 @@ void prof_encryption_reset(char *barejid);
|
||||
int prof_chat_set_titlebar_enctext(char* barejid, char* enctext);
|
||||
|
||||
/**
|
||||
* Resets the titlebar encryption indicator for a recipient to CProof’s default.
|
||||
* Resets the titlebar encryption indicator for a recipient to CProof's default.
|
||||
* @param barejid Jabber ID of the recipient.
|
||||
* @return 1 on success, 0 on failure.
|
||||
*
|
||||
@@ -622,7 +633,7 @@ int prof_chat_unset_outgoing_char(char *barejid);
|
||||
int prof_room_set_titlebar_enctext(char* roomjid, char* enctext);
|
||||
|
||||
/**
|
||||
* Resets the titlebar encryption indicator for a room to CProof’s default.
|
||||
* Resets the titlebar encryption indicator for a room to CProof's default.
|
||||
* @param roomjid Jabber ID of the room.
|
||||
* @return 1 on success, 0 on failure.
|
||||
*
|
||||
|
||||
@@ -830,6 +830,22 @@ def get_current_recipient() -> str | None:
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_current_window() -> str:
|
||||
"""Retrieves the title of the current window as shown in the titlebar.
|
||||
|
||||
Returns the title of the currently active window, matching the titlebar display.
|
||||
Special cases:
|
||||
- For MUC configuration windows, includes "config" and an asterisk if modified (e.g., "room@example.com config \*").
|
||||
- For vCard windows, includes the bare JID and an asterisk if modified (e.g., "vCard user@example.com \*").
|
||||
|
||||
:return: The window title as a string.
|
||||
|
||||
Example::
|
||||
|
||||
title = prof.get_current_window()
|
||||
prof.cons_show(f"Current window: {title}")
|
||||
"""
|
||||
|
||||
def get_current_muc() -> str | None:
|
||||
"""Retrieves the Jabber ID of the current chat room.
|
||||
|
||||
|
||||
@@ -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