summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-04-24 16:26:13 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-04-24 16:26:13 +0200
commit163c5d6dfb3df598b3204b7a68041fb093649e9c (patch)
treeb807eb22d811241d8d9384b5330b05db25af6fc7 /src/gui
parent671087e26a2f4c48189c25b73b8fab96a9bd15e8 (diff)
downloadweechat-163c5d6dfb3df598b3204b7a68041fb093649e9c.zip
Remove notify plugin (moved to core)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-color.c1
-rw-r--r--src/gui/gui-buffer.c103
-rw-r--r--src/gui/gui-buffer.h1
-rw-r--r--src/gui/gui-color.h1
4 files changed, 106 insertions, 0 deletions
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index cd1aac5be..1403e5e69 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -381,6 +381,7 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, CONFIG_COLOR(config_color_chat_highlight), CONFIG_COLOR(config_color_chat_highlight_bg));
gui_color_build (GUI_COLOR_CHAT_READ_MARKER, CONFIG_COLOR(config_color_chat_read_marker), CONFIG_COLOR(config_color_chat_read_marker_bg));
gui_color_build (GUI_COLOR_CHAT_TEXT_FOUND, CONFIG_COLOR(config_color_chat_text_found), CONFIG_COLOR(config_color_chat_text_found_bg));
+ gui_color_build (GUI_COLOR_CHAT_VALUE, CONFIG_COLOR(config_color_chat_value), CONFIG_COLOR(config_color_chat_bg));
}
/*
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 68cd3bac5..135a5919e 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -209,6 +209,106 @@ gui_buffer_local_var_remove_all (struct t_gui_buffer *buffer)
}
/*
+ * gui_buffer_notify_get: read a notify level in config file
+ * we first try with all arguments, then remove one by one
+ * to find notify level (from specific to general notify)
+ */
+
+int
+gui_buffer_notify_get (struct t_gui_buffer *buffer)
+{
+ const char *plugin_name;
+ char *option_name, *ptr_end;
+ int length;
+ struct t_config_option *ptr_option;
+
+ plugin_name = plugin_get_name (buffer->plugin);
+ length = strlen (plugin_name) + 1 + strlen (buffer->name) + 1;
+ option_name = malloc (length);
+ if (option_name)
+ {
+ snprintf (option_name, length, "%s.%s", plugin_name, buffer->name);
+
+ ptr_end = option_name + strlen (option_name);
+ while (ptr_end >= option_name)
+ {
+ ptr_option = config_file_search_option (weechat_config_file,
+ weechat_config_section_notify,
+ option_name);
+ if (ptr_option)
+ {
+ free (option_name);
+ return CONFIG_INTEGER(ptr_option);
+ }
+ ptr_end--;
+ while ((ptr_end >= option_name) && (ptr_end[0] != '.'))
+ {
+ ptr_end--;
+ }
+ if ((ptr_end >= option_name) && (ptr_end[0] == '.'))
+ ptr_end[0] = '\0';
+ }
+ ptr_option = config_file_search_option (weechat_config_file,
+ weechat_config_section_notify,
+ option_name);
+
+ free (option_name);
+
+ if (ptr_option)
+ return CONFIG_INTEGER(ptr_option);
+ }
+
+ /* notify level not found */
+ return CONFIG_INTEGER(config_look_buffer_notify_default);
+}
+
+/*
+ * gui_buffer_notify_set: set notify value on a buffer
+ */
+
+void
+gui_buffer_notify_set (struct t_gui_buffer *buffer)
+{
+ int old_notify, new_notify;
+
+ old_notify = buffer->notify;
+ new_notify = gui_buffer_notify_get (buffer);
+
+ if (new_notify != old_notify)
+ {
+ buffer->notify = new_notify;
+ gui_chat_printf (NULL,
+ _("Notify changed for \"%s%s.%s%s\": \"%s%s%s\" to \"%s%s%s\""),
+ GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
+ plugin_get_name (buffer->plugin),
+ buffer->name,
+ GUI_COLOR(GUI_COLOR_CHAT),
+ GUI_COLOR(GUI_COLOR_CHAT_VALUE),
+ gui_buffer_notify_string[old_notify],
+ GUI_COLOR(GUI_COLOR_CHAT),
+ GUI_COLOR(GUI_COLOR_CHAT_VALUE),
+ gui_buffer_notify_string[buffer->notify],
+ GUI_COLOR(GUI_COLOR_CHAT));
+ }
+}
+
+/*
+ * gui_buffer_notify_set_all: set notify values on all opened buffers
+ */
+
+void
+gui_buffer_notify_set_all ()
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ gui_buffer_notify_set (ptr_buffer);
+ }
+}
+
+/*
* gui_buffer_insert: insert buffer in good position in list of buffers
*/
@@ -378,6 +478,9 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
first_buffer_creation = (gui_buffers == NULL);
gui_buffer_insert (new_buffer);
+ /* set notify level */
+ new_buffer->notify = gui_buffer_notify_get (new_buffer);
+
/* check if this buffer should be assigned to a window,
according to windows layout saved */
gui_layout_window_check_buffer (new_buffer);
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index e39799c01..0f773eefa 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -184,6 +184,7 @@ extern char *gui_buffer_notify_string[];
/* buffer functions */
+extern void gui_buffer_notify_set_all ();
extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
const char *name,
int (*input_callback)(void *data,
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 602dd9f3b..50cee70d0 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -57,6 +57,7 @@ enum t_gui_color_enum
GUI_COLOR_CHAT_HIGHLIGHT,
GUI_COLOR_CHAT_READ_MARKER,
GUI_COLOR_CHAT_TEXT_FOUND,
+ GUI_COLOR_CHAT_VALUE,
/* number of colors */
GUI_COLOR_NUM_COLORS,