summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui-common.c67
-rw-r--r--src/gui/gui.h1
-rw-r--r--src/irc/irc-recv.c51
3 files changed, 73 insertions, 46 deletions
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 2b396fadb..20b4912a3 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -1022,40 +1022,61 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *mes
void
gui_infobar_printf (int time_displayed, int color, char *message, ...)
{
- static char buffer[1024];
+ static char buf[1024];
va_list argptr;
t_gui_infobar *ptr_infobar;
- char *pos, *buf2, *buf3;
+ char *pos;
va_start (argptr, message);
- vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
+ vsnprintf (buf, sizeof (buf) - 1, message, argptr);
va_end (argptr);
- buf2 = (char *)gui_color_decode ((unsigned char *)buffer, 0);
+ ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar));
+ if (ptr_infobar)
+ {
+ ptr_infobar->color = color;
+ ptr_infobar->text = strdup (buf);
+ pos = strchr (ptr_infobar->text, '\n');
+ if (pos)
+ pos[0] = '\0';
+ ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed;
+ ptr_infobar->next_infobar = gui_infobar;
+ gui_infobar = ptr_infobar;
+ gui_draw_buffer_infobar (gui_current_window->buffer, 1);
+ }
+ else
+ weechat_log_printf (_("Not enough memory for infobar message\n"));
+}
+
+/*
+ * gui_infobar_printf_from_buffer: remove color, convert charset, then
+ * display message in infobar
+ */
+
+void
+gui_infobar_printf_from_buffer (t_gui_buffer *buffer, int time_displayed,
+ int color, char *message1, char *message, ...)
+{
+ static char buf[1024];
+ va_list argptr;
+ char *buf2, *buf3;
+ va_start (argptr, message);
+ vsnprintf (buf, sizeof (buf) - 1, message, argptr);
+ va_end (argptr);
+
+ buf2 = (char *)gui_color_decode ((unsigned char *)buf, 0);
+
+ weechat_log_printf ("avant decodage: %s\n", buf);
if (buf2)
- buf3 = channel_iconv_decode (NULL, NULL, buf2);
+ buf3 = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), buf2);
else
buf3 = NULL;
+ weechat_log_printf ("apres decodage: %s\n", buf3);
- if (buf3)
- {
- ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar));
- if (ptr_infobar)
- {
- ptr_infobar->color = color;
- ptr_infobar->text = strdup (buf3);
- pos = strchr (ptr_infobar->text, '\n');
- if (pos)
- pos[0] = '\0';
- ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed;
- ptr_infobar->next_infobar = gui_infobar;
- gui_infobar = ptr_infobar;
- gui_draw_buffer_infobar (gui_current_window->buffer, 1);
- }
- else
- weechat_log_printf (_("Not enough memory for infobar message\n"));
- }
+ gui_infobar_printf (time_displayed, color,
+ "%s%s", message1,
+ (buf3) ? buf3 : ((buf2) ? buf2 : buf));
if (buf2)
free (buf2);
diff --git a/src/gui/gui.h b/src/gui/gui.h
index eb89671db..d6d05a79f 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -408,6 +408,7 @@ extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
extern void gui_buffer_clear (t_gui_buffer *);
extern void gui_buffer_clear_all ();
extern void gui_infobar_printf (int, int, char *, ...);
+extern void gui_infobar_printf_from_buffer (t_gui_buffer *, int, int, char *, char *, ...);
extern void gui_window_free (t_gui_window *);
extern void gui_infobar_remove ();
extern void gui_buffer_free (t_gui_buffer *, int);
diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c
index de24e19da..b4be5b46a 100644
--- a/src/irc/irc-recv.c
+++ b/src/irc/irc-recv.c
@@ -1249,10 +1249,11 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
nick);
if ( (cfg_look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != gui_current_window->buffer) )
- gui_infobar_printf (cfg_look_infobar_delay_highlight,
- COLOR_WIN_INFOBAR_HIGHLIGHT,
- _("Private %s> %s"),
- nick, pos);
+ gui_infobar_printf_from_buffer (ptr_channel->buffer,
+ cfg_look_infobar_delay_highlight,
+ COLOR_WIN_INFOBAR_HIGHLIGHT,
+ _("Private"), " %s> %s",
+ nick, pos);
}
else
gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK,
@@ -1510,11 +1511,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if ( (cfg_look_infobar)
&& (cfg_look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != gui_current_window->buffer) )
- gui_infobar_printf (cfg_look_infobar_delay_highlight,
- COLOR_WIN_INFOBAR_HIGHLIGHT,
- _("On %s: * %s %s"),
- ptr_channel->name,
- nick, pos);
+ gui_infobar_printf_from_buffer (ptr_channel->buffer,
+ cfg_look_infobar_delay_highlight,
+ COLOR_WIN_INFOBAR_HIGHLIGHT,
+ _("Channel"), " %s: * %s %s",
+ ptr_channel->name,
+ nick, pos);
}
else
gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG,
@@ -1626,11 +1628,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if ( (cfg_look_infobar)
&& (cfg_look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != gui_current_window->buffer) )
- gui_infobar_printf (cfg_look_infobar_delay_highlight,
- COLOR_WIN_INFOBAR_HIGHLIGHT,
- _("On %s: %s> %s"),
- ptr_channel->name,
- nick, pos);
+ gui_infobar_printf_from_buffer (ptr_channel->buffer,
+ cfg_look_infobar_delay_highlight,
+ COLOR_WIN_INFOBAR_HIGHLIGHT,
+ _("Channel"), " %s: %s> %s",
+ ptr_channel->name,
+ nick, pos);
}
else
irc_display_nick (ptr_channel->buffer, ptr_nick,
@@ -2065,11 +2068,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if ( (cfg_look_infobar)
&& (cfg_look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != gui_current_window->buffer) )
- gui_infobar_printf (cfg_look_infobar_delay_highlight,
- COLOR_WIN_INFOBAR_HIGHLIGHT,
- _("On %s: * %s %s"),
- ptr_channel->name,
- nick, pos);
+ gui_infobar_printf_from_buffer (ptr_channel->buffer,
+ cfg_look_infobar_delay_highlight,
+ COLOR_WIN_INFOBAR_HIGHLIGHT,
+ _("Channel"), " %s: * %s %s",
+ ptr_channel->name,
+ nick, pos);
}
else
gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG,
@@ -2153,10 +2157,11 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
nick);
if ( (cfg_look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != gui_current_window->buffer) )
- gui_infobar_printf (cfg_look_infobar_delay_highlight,
- COLOR_WIN_INFOBAR_HIGHLIGHT,
- _("Private %s> %s"),
- nick, pos);
+ gui_infobar_printf_from_buffer (ptr_channel->buffer,
+ cfg_look_infobar_delay_highlight,
+ COLOR_WIN_INFOBAR_HIGHLIGHT,
+ _("Private"), " %s> %s",
+ nick, pos);
}
else
gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK,