diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-07 14:48:45 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-07 14:48:45 +0200 |
commit | 97a8a30a3df69f682c8229df1159a4fc76b0734d (patch) | |
tree | 6a72387e35d0a6db5845ad766f7930e0ce069659 /src | |
parent | 36736564abf243206cb1cbff109119e7351617e2 (diff) | |
download | weechat-97a8a30a3df69f682c8229df1159a4fc76b0734d.zip |
Rename options "irc.look.open_{channel|pv}_near_server" to "irc.look.new_{channel|pv}_position" with new values (none, next or near_server)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 28 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 32 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 11 |
3 files changed, 50 insertions, 21 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index e1708ef71..caaf51c83 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -150,8 +150,8 @@ irc_channel_new (struct t_irc_server *server, int channel_type, { struct t_irc_channel *new_channel; struct t_gui_buffer *new_buffer; - int buffer_created; - char *buffer_name; + int buffer_created, current_buffer_number, buffer_position; + char *buffer_name, str_number[32];; /* alloc memory for new channel */ if ((new_channel = malloc (sizeof (*new_channel))) == NULL) @@ -170,6 +170,8 @@ irc_channel_new (struct t_irc_server *server, int channel_type, weechat_nicklist_remove_all (new_buffer); else { + current_buffer_number = weechat_buffer_get_integer (weechat_current_buffer (), + "number"); new_buffer = weechat_buffer_new (buffer_name, &irc_input_data_cb, NULL, &irc_buffer_close_cb, NULL); @@ -178,12 +180,24 @@ irc_channel_new (struct t_irc_server *server, int channel_type, free (new_channel); return NULL; } - if (((channel_type == IRC_CHANNEL_TYPE_CHANNEL) - && weechat_config_boolean (irc_config_look_open_channel_near_server)) - || ((channel_type == IRC_CHANNEL_TYPE_PRIVATE) - && weechat_config_boolean (irc_config_look_open_pv_near_server))) + buffer_position = (channel_type == IRC_CHANNEL_TYPE_CHANNEL) ? + weechat_config_integer (irc_config_look_new_channel_position) : + weechat_config_integer (irc_config_look_new_pv_position); + switch (buffer_position) { - irc_channel_move_near_server (server, channel_type, new_buffer); + case IRC_CONFIG_LOOK_BUFFER_POSITION_NONE: + /* do nothing */ + break; + case IRC_CONFIG_LOOK_BUFFER_POSITION_NEXT: + /* move buffer to current number + 1 */ + snprintf (str_number, sizeof (str_number), + "%d", current_buffer_number + 1); + weechat_buffer_set (new_buffer, "number", str_number); + break; + case IRC_CONFIG_LOOK_BUFFER_POSITION_NEAR_SERVER: + /* move buffer after last channel/pv of server */ + irc_channel_move_near_server (server, channel_type, new_buffer); + break; } buffer_created = 1; } diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 61bf79b43..2e4e7577d 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -52,8 +52,8 @@ struct t_config_section *irc_config_section_server = NULL; struct t_config_option *irc_config_look_color_nicks_in_server_messages; struct t_config_option *irc_config_look_color_pv_nick_like_channel; struct t_config_option *irc_config_look_server_buffer; -struct t_config_option *irc_config_look_open_channel_near_server; -struct t_config_option *irc_config_look_open_pv_near_server; +struct t_config_option *irc_config_look_new_channel_position; +struct t_config_option *irc_config_look_new_pv_position; struct t_config_option *irc_config_look_nick_prefix; struct t_config_option *irc_config_look_nick_suffix; struct t_config_option *irc_config_look_nick_completion_smart; @@ -1545,16 +1545,24 @@ irc_config_init () "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core", NULL, 0, NULL, NULL, &irc_config_change_look_server_buffer, NULL, NULL, NULL); - irc_config_look_open_channel_near_server = weechat_config_new_option ( - irc_config_file, ptr_section, - "open_channel_near_server", "boolean", - N_("open new channels near server"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_open_pv_near_server = weechat_config_new_option ( - irc_config_file, ptr_section, - "open_pv_near_server", "boolean", - N_("open new privates near server"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_new_channel_position = weechat_config_new_option ( + irc_config_file, ptr_section, + "new_channel_position", "integer", + N_("force position of new channel in list of buffers " + "(none = default position (should be last buffer)r, " + "next = current buffer + 1, near_server = after last channel/pv " + "of server)"), + "none|next|near_server", 0, 0, "none", + NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_new_pv_position = weechat_config_new_option ( + irc_config_file, ptr_section, + "new_pv_position", "integer", + N_("force position of new private in list of buffers " + "(none = default position (should be last buffer)r, " + "next = current buffer + 1, near_server = after last channel/pv " + "of server)"), + "none|next|near_server", 0, 0, "none", + NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_nick_prefix = weechat_config_new_option ( irc_config_file, ptr_section, "nick_prefix", "string", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 7950c8b3a..71a25aec5 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -29,6 +29,13 @@ enum t_irc_config_look_server_buffer IRC_CONFIG_LOOK_SERVER_BUFFER_INDEPENDENT, }; +enum t_irc_config_look_buffer_position +{ + IRC_CONFIG_LOOK_BUFFER_POSITION_NONE = 0, + IRC_CONFIG_LOOK_BUFFER_POSITION_NEXT, + IRC_CONFIG_LOOK_BUFFER_POSITION_NEAR_SERVER, +}; + enum t_irc_config_look_item_display_server { IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_PLUGIN = 0, @@ -71,8 +78,8 @@ extern struct t_config_section *irc_config_section_server; extern struct t_config_option *irc_config_look_color_nicks_in_server_messages; extern struct t_config_option *irc_config_look_color_pv_nick_like_channel; extern struct t_config_option *irc_config_look_server_buffer; -extern struct t_config_option *irc_config_look_open_channel_near_server; -extern struct t_config_option *irc_config_look_open_pv_near_server; +extern struct t_config_option *irc_config_look_new_channel_position; +extern struct t_config_option *irc_config_look_new_pv_position; extern struct t_config_option *irc_config_look_nick_prefix; extern struct t_config_option *irc_config_look_nick_suffix; extern struct t_config_option *irc_config_look_nick_completion_smart; |