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

Merge branch 'master' into plugins

Conflicts:
	src/ui/core.c
This commit is contained in:
James Booth 2015-04-30 23:38:14 +01:00
commit 18f25e18d8
9 changed files with 39 additions and 127 deletions

View File

@ -735,9 +735,7 @@ cmd_win(gchar **args, struct cmd_help_t help)
if (!window) {
cons_show("Window %d does not exist.", num);
} else {
if (!wins_is_current(window)) {
ui_ev_focus_win(window);
}
ui_ev_focus_win(window);
}
return TRUE;
@ -1345,9 +1343,7 @@ cmd_msg(gchar **args, struct cmd_help_t help)
if (!chatwin) {
chatwin = ui_ev_new_chat_win(barejid);
}
if (!wins_is_current((ProfWin*)chatwin)) {
ui_ev_focus_win((ProfWin*)chatwin);
}
ui_ev_focus_win((ProfWin*)chatwin);
if (msg) {
cl_ev_send_msg(chatwin, msg);
@ -4204,9 +4200,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
if (!chatwin) {
chatwin = ui_ev_new_chat_win(barejid);
}
if (!wins_is_current((ProfWin*)chatwin)) {
ui_ev_focus_win((ProfWin*)chatwin);
}
ui_ev_focus_win((ProfWin*)chatwin);
if (ui_current_win_is_otr()) {
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");

View File

@ -33,11 +33,14 @@
*/
#include "ui/ui.h"
#include "ui/windows.h"
void
ui_ev_focus_win(ProfWin *win)
{
ui_switch_win(win);
if (!wins_is_current(win)) {
ui_switch_win(win);
}
}
ProfChatWin*

View File

@ -44,6 +44,7 @@
#include "ui/ui.h"
#include "config/theme.h"
#include "command/command.h"
#include "event/ui_events.h"
void
api_cons_alert(void)
@ -182,8 +183,7 @@ void
api_win_focus(const char *tag)
{
ProfPluginWin *pluginwin = wins_get_plugin(tag);
int num = wins_get_num((ProfWin*)pluginwin);
ui_switch_win_num(num);
ui_ev_focus_win((ProfWin*)pluginwin);
}
void
@ -192,12 +192,6 @@ api_win_show(const char *tag, const char *line)
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', NULL, 0, 0, "", line);
// refresh if current
if (wins_is_current(window)) {
int num = wins_get_num(window);
ui_switch_win_num(num);
}
}
void
@ -205,13 +199,7 @@ api_win_show_green(const char *tag, const char *line)
{
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', NULL, 0, theme_attrs(THEME_ONLINE), "", line);
// refresh if current
if (wins_is_current(window)) {
int num = wins_get_num(window);
ui_switch_win_num(num);
}
win_print(window, '!', NULL, 0, THEME_GREEN, "", line);
}
void
@ -219,13 +207,7 @@ api_win_show_red(const char *tag, const char *line)
{
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', NULL, 0, theme_attrs(THEME_OFFLINE), "", line);
// refresh if current
if (wins_is_current(window)) {
int num = wins_get_num(window);
ui_switch_win_num(num);
}
win_print(window, '!', NULL, 0, THEME_RED, "", line);
}
void
@ -233,13 +215,7 @@ api_win_show_cyan(const char *tag, const char *line)
{
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', NULL, 0, theme_attrs(THEME_AWAY), "", line);
// refresh if current
if (wins_is_current(window)) {
int num = wins_get_num(window);
ui_switch_win_num(num);
}
win_print(window, '!', NULL, 0, THEME_CYAN, "", line);
}
void
@ -247,11 +223,5 @@ api_win_show_yellow(const char *tag, const char *line)
{
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', NULL, 0, theme_attrs(THEME_INCOMING), "", line);
// refresh if current
if (wins_is_current(window)) {
int num = wins_get_num(window);
ui_switch_win_num(num);
}
}
win_print(window, '!', NULL, 0, THEME_YELLOW, "", line);
}

View File

@ -75,6 +75,7 @@
#include "ui/windows.h"
#include "xmpp/xmpp.h"
#include "plugins/plugins.h"
#include "event/ui_events.h"
static char *win_title;
@ -898,64 +899,6 @@ ui_switch_win(ProfWin *window)
status_bar_active(i);
}
void
ui_previous_win(void)
{
ProfWin *old_current = wins_get_current();
if (old_current->type == WIN_MUC_CONFIG) {
ProfMucConfWin *confwin = (ProfMucConfWin*)old_current;
cmd_autocomplete_remove_form_fields(confwin->form);
}
ProfWin *new_current = wins_get_previous();
if (new_current->type == WIN_MUC_CONFIG) {
ProfMucConfWin *confwin = (ProfMucConfWin*)new_current;
cmd_autocomplete_add_form_fields(confwin->form);
}
int i = wins_get_num(new_current);
wins_set_current_by_num(i);
if (i == 1) {
title_bar_console();
status_bar_current(1);
status_bar_active(1);
} else {
title_bar_switch();
status_bar_current(i);
status_bar_active(i);
}
}
void
ui_next_win(void)
{
ProfWin *old_current = wins_get_current();
if (old_current->type == WIN_MUC_CONFIG) {
ProfMucConfWin *confwin = (ProfMucConfWin*)old_current;
cmd_autocomplete_remove_form_fields(confwin->form);
}
ProfWin *new_current = wins_get_next();
if (new_current->type == WIN_MUC_CONFIG) {
ProfMucConfWin *confwin = (ProfMucConfWin*)new_current;
cmd_autocomplete_add_form_fields(confwin->form);
}
int i = wins_get_num(new_current);
wins_set_current_by_num(i);
if (i == 1) {
title_bar_console();
status_bar_current(1);
status_bar_active(1);
} else {
title_bar_switch();
status_bar_current(i);
status_bar_active(i);
}
}
void
ui_gone_secure(const char * const barejid, gboolean trusted)
{
@ -1353,14 +1296,14 @@ ui_new_private_win(const char * const fulljid)
if (!window) {
window = wins_new_private(fulljid);
}
ui_switch_win(window);
ui_ev_focus_win(window);
}
void
ui_create_xmlconsole_win(void)
{
ProfWin *window = wins_new_xmlconsole();
ui_switch_win(window);
ui_ev_focus_win(window);
}
void
@ -1368,7 +1311,7 @@ ui_open_xmlconsole_win(void)
{
ProfXMLWin *xmlwin = wins_get_xmlconsole();
if (xmlwin) {
ui_switch_win((ProfWin*)xmlwin);
ui_ev_focus_win((ProfWin*)xmlwin);
}
}
@ -1440,7 +1383,7 @@ ui_outgoing_private_msg(const char * const fulljid, const char * const message)
}
win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
ui_switch_win(window);
ui_ev_focus_win(window);
}
void
@ -1467,7 +1410,7 @@ ui_room_join(const char * const roomjid, gboolean focus)
if (focus) {
ui_switch_win(window);
ui_ev_focus_win(window);
} else {
int num = wins_get_num(window);
status_bar_active(num);
@ -1481,7 +1424,7 @@ void
ui_switch_to_room(const char * const roomjid)
{
ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
ui_switch_win(window);
ui_ev_focus_win(window);
}
void
@ -2653,7 +2596,7 @@ ui_handle_room_configuration(const char * const roomjid, DataForm *form)
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
ui_switch_win(window);
ui_ev_focus_win(window);
ui_show_form(confwin);
win_print(window, '-', NULL, 0, 0, "", "");
@ -2708,11 +2651,11 @@ ui_handle_room_config_submit_result(const char * const roomjid)
}
if (muc_window) {
ui_switch_win((ProfWin*)muc_window);
ui_ev_focus_win((ProfWin*)muc_window);
win_print(muc_window, '!', NULL, 0, THEME_ROOMINFO, "", "Room configuration successful");
} else {
ProfWin *console = wins_get_console();
ui_switch_win(console);
ui_ev_focus_win(console);
cons_show("Room configuration successful: %s", roomjid);
}
} else {

View File

@ -455,9 +455,7 @@ _go_to_win(int i)
{
ProfWin *window = wins_get_by_num(i);
if (window) {
if (!wins_is_current(window)) {
ui_ev_focus_win(window);
}
ui_ev_focus_win(window);
}
}
@ -534,14 +532,20 @@ _inp_rl_win0_handler(int count, int key)
static int
_inp_rl_altleft_handler(int count, int key)
{
ui_previous_win();
ProfWin *window = wins_get_previous();
if (window) {
ui_ev_focus_win(window);
}
return 0;
}
static int
_inp_rl_altright_handler(int count, int key)
{
ui_next_win();
ProfWin *window = wins_get_next();
if (window) {
ui_ev_focus_win(window);
}
return 0;
}

View File

@ -60,8 +60,6 @@ void ui_redraw(void);
void ui_resize(void);
GSList* ui_get_chat_recipients(void);
void ui_switch_win(ProfWin *window);
void ui_next_win(void);
void ui_previous_win(void);
void ui_sigwinch_handler(int sig);
void ui_gone_secure(const char * const barejid, gboolean trusted);

View File

@ -239,6 +239,8 @@ win_create_plugin(const char * const tag)
new_win->tag = strdup(tag);
new_win->memcheck = PROFPLUGINWIN_MEMCHECK;
return &new_win->super;
}

View File

@ -53,6 +53,7 @@
#include "ui/statusbar.h"
#include "ui/window.h"
#include "ui/windows.h"
#include "event/ui_events.h"
static GHashTable *windows;
static int current;
@ -693,7 +694,7 @@ wins_swap(int source_win, int target_win)
}
if (wins_get_current_num() == source_win) {
wins_set_current_by_num(target_win);
ui_switch_win(console);
ui_ev_focus_win(console);
}
return TRUE;
@ -714,7 +715,7 @@ wins_swap(int source_win, int target_win)
status_bar_active(source_win);
}
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
ui_switch_win(console);
ui_ev_focus_win(console);
}
return TRUE;
}
@ -774,7 +775,7 @@ wins_tidy(void)
windows = new_windows;
current = 1;
ProfWin *console = wins_get_console();
ui_switch_win(console);
ui_ev_focus_win(console);
g_list_free(keys);
return TRUE;
} else {

View File

@ -66,9 +66,6 @@ GSList* ui_get_chat_recipients(void)
void ui_switch_win(ProfWin *win) {}
void ui_next_win(void) {}
void ui_previous_win(void) {}
void ui_gone_secure(const char * const barejid, gboolean trusted) {}
void ui_gone_insecure(const char * const barejid) {}
void ui_trust(const char * const barejid) {}