1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge pull request #1800 from profanity-im/switch

Improve some UI functions
This commit is contained in:
Michael Vetter 2023-03-23 18:47:09 +01:00 committed by GitHub
commit 2093fe417f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 33 deletions

View File

@ -514,10 +514,7 @@ chatwin_get_string(ProfChatWin* chatwin)
g_string_append_printf(res, ", %d unread", chatwin->unread); g_string_append_printf(res, ", %d unread", chatwin->unread);
} }
char* resstr = res->str; return g_string_free(res, FALSE);
g_string_free(res, FALSE);
return resstr;
} }
void void

View File

@ -943,17 +943,11 @@ mucwin_get_string(ProfMucWin* mucwin)
{ {
assert(mucwin != NULL); assert(mucwin != NULL);
GString* res = g_string_new("Room ");
g_string_append(res, mucwin->roomjid);
if (mucwin->unread > 0) { if (mucwin->unread > 0) {
g_string_append_printf(res, ", %d unread", mucwin->unread); return g_strdup_printf("Room %s, %d unread", mucwin->roomjid, mucwin->unread);
} else {
return g_strdup_printf("Room %s", mucwin->roomjid);
} }
char* resstr = res->str;
g_string_free(res, FALSE);
return resstr;
} }
void void

View File

@ -302,10 +302,14 @@ win_get_title(ProfWin* window)
if (window == NULL) { if (window == NULL) {
return strdup(CONS_WIN_TITLE); return strdup(CONS_WIN_TITLE);
} }
if (window->type == WIN_CONSOLE) {
switch (window->type) {
case WIN_CONSOLE:
{
return strdup(CONS_WIN_TITLE); return strdup(CONS_WIN_TITLE);
} }
if (window->type == WIN_CHAT) { case WIN_CHAT:
{
ProfChatWin* chatwin = (ProfChatWin*)window; ProfChatWin* chatwin = (ProfChatWin*)window;
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
jabber_conn_status_t conn_status = connection_get_status(); jabber_conn_status_t conn_status = connection_get_status();
@ -321,7 +325,8 @@ win_get_title(ProfWin* window)
return strdup(chatwin->barejid); return strdup(chatwin->barejid);
} }
} }
if (window->type == WIN_MUC) { case WIN_MUC:
{
ProfMucWin* mucwin = (ProfMucWin*)window; ProfMucWin* mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
@ -339,30 +344,37 @@ win_get_title(ProfWin* window)
return g_string_free(title, FALSE); return g_string_free(title, FALSE);
} }
if (window->type == WIN_CONFIG) { case WIN_CONFIG:
ProfConfWin* confwin = (ProfConfWin*)window; {
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); if (window->type == WIN_CONFIG) {
GString* title = g_string_new(confwin->roomjid); ProfConfWin* confwin = (ProfConfWin*)window;
g_string_append(title, " config"); assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
if (confwin->form->modified) { GString* title = g_string_new(confwin->roomjid);
g_string_append(title, " *"); g_string_append(title, " config");
if (confwin->form->modified) {
g_string_append(title, " *");
}
return g_string_free(title, FALSE);
} }
return g_string_free(title, FALSE);
} }
if (window->type == WIN_PRIVATE) { case WIN_PRIVATE:
{
ProfPrivateWin* privatewin = (ProfPrivateWin*)window; ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
return strdup(privatewin->fulljid); return strdup(privatewin->fulljid);
} }
if (window->type == WIN_XML) { case WIN_XML:
{
return strdup(XML_WIN_TITLE); return strdup(XML_WIN_TITLE);
} }
if (window->type == WIN_PLUGIN) { case WIN_PLUGIN:
{
ProfPluginWin* pluginwin = (ProfPluginWin*)window; ProfPluginWin* pluginwin = (ProfPluginWin*)window;
assert(pluginwin->memcheck == PROFPLUGINWIN_MEMCHECK); assert(pluginwin->memcheck == PROFPLUGINWIN_MEMCHECK);
return strdup(pluginwin->tag); return strdup(pluginwin->tag);
} }
if (window->type == WIN_VCARD) { case WIN_VCARD:
{
ProfVcardWin* vcardwin = (ProfVcardWin*)window; ProfVcardWin* vcardwin = (ProfVcardWin*)window;
assert(vcardwin->memcheck == PROFVCARDWIN_MEMCHECK); assert(vcardwin->memcheck == PROFVCARDWIN_MEMCHECK);
@ -378,7 +390,8 @@ win_get_title(ProfWin* window)
free(jid); free(jid);
return g_string_free(title, FALSE); return g_string_free(title, FALSE);
} }
return NULL; }
assert(FALSE);
} }
char* char*
@ -420,9 +433,12 @@ win_get_tab_identifier(ProfWin* window)
{ {
return strdup("xmlconsole"); return strdup("xmlconsole");
} }
default: case WIN_VCARD:
return strdup("UNKNOWN"); {
return strdup("vcard");
} }
}
assert(FALSE);
} }
char* char*
@ -503,9 +519,8 @@ win_to_string(ProfWin* window)
ProfVcardWin* vcardwin = (ProfVcardWin*)window; ProfVcardWin* vcardwin = (ProfVcardWin*)window;
return vcardwin_get_string(vcardwin); return vcardwin_get_string(vcardwin);
} }
default:
return NULL;
} }
assert(FALSE);
} }
void void