summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-03-07 11:26:06 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-03-07 11:26:06 +0100
commita44cc9ffde04c0bd0a28e53f5a64afcaa5479c49 (patch)
tree3c3a7e2ccbe358306b4454b611953dac5865dac4 /src
parent3194c641a0e687eef24d8066dab245abc71d7c1b (diff)
downloadweechat-a44cc9ffde04c0bd0a28e53f5a64afcaa5479c49.zip
Add new key to zoom a window (meta-z by default) (task #7470)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c35
-rw-r--r--src/core/wee-config.c14
-rw-r--r--src/core/weechat.c2
-rw-r--r--src/gui/curses/gui-curses-keyboard.c1
-rw-r--r--src/gui/curses/gui-curses-main.c4
-rw-r--r--src/gui/gtk/gui-gtk-main.c4
-rw-r--r--src/gui/gui-buffer.c3
-rw-r--r--src/gui/gui-layout.c192
-rw-r--r--src/gui/gui-layout.h35
-rw-r--r--src/gui/gui-window.c40
-rw-r--r--src/gui/gui-window.h1
11 files changed, 216 insertions, 115 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 45734d590..7c7ac9d60 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1978,13 +1978,13 @@ command_layout (void *data, struct t_gui_buffer *buffer,
{
if (flag_buffers)
{
- gui_layout_buffer_save ();
+ gui_layout_buffer_save (&gui_layout_buffers, &last_gui_layout_buffer);
gui_chat_printf (NULL,
_("Layout saved for buffers (order of buffers)"));
}
if (flag_windows)
{
- gui_layout_window_save ();
+ gui_layout_window_save (&gui_layout_windows);
gui_chat_printf (NULL,
_("Layout saved for windows (buffer displayed by "
"each window)"));
@@ -1997,9 +1997,9 @@ command_layout (void *data, struct t_gui_buffer *buffer,
if (string_strcasecmp (argv[1], "apply") == 0)
{
if (flag_buffers)
- gui_layout_buffer_apply ();
+ gui_layout_buffer_apply (gui_layout_buffers);
if (flag_windows)
- gui_layout_window_apply ();
+ gui_layout_window_apply (gui_layout_windows, -1);
return WEECHAT_RC_OK;
}
@@ -2009,13 +2009,13 @@ command_layout (void *data, struct t_gui_buffer *buffer,
{
if (flag_buffers)
{
- gui_layout_buffer_reset ();
+ gui_layout_buffer_reset (&gui_layout_buffers, &last_gui_layout_buffer);
gui_chat_printf (NULL,
_("Layout reset for buffers"));
}
if (flag_windows)
{
- gui_layout_window_reset ();
+ gui_layout_window_reset (&gui_layout_windows);
gui_chat_printf (NULL,
_("Layout reset for windows"));
}
@@ -3509,6 +3509,13 @@ command_window (void *data, struct t_gui_buffer *buffer,
gui_window_scroll (gui_current_window, argv[2]);
return WEECHAT_RC_OK;
}
+
+ /* zoom window */
+ if (string_strcasecmp (argv[1], "zoom") == 0)
+ {
+ gui_window_zoom (gui_current_window);
+ return WEECHAT_RC_OK;
+ }
gui_chat_printf (NULL,
_("%sError: unknown option for \"%s\" "
@@ -3849,9 +3856,10 @@ command_init ()
N_("manage windows"),
N_("[list | -1 | +1 | b# | up | down | left | right | "
"splith [pct] | splitv [pct] | resize pct | "
- "merge [all] | page_up | page_down | scroll | scroll_up | "
- "scroll_down | scroll_top | scroll_bottom | "
- "scroll_previous_highlight | scroll_next_highlight ]"),
+ "merge [all] | page_up | page_down | refresh | scroll | "
+ "scroll_up | scroll_down | scroll_top | scroll_bottom | "
+ "scroll_previous_highlight | scroll_next_highlight | "
+ "zoom]"),
N_(" list: list opened windows (no parameter implies this "
"list)\n"
" -1: jump to previous window\n"
@@ -3869,6 +3877,7 @@ command_init ()
"window)\n\n"
" page_up: scroll one page up\n"
" page_down: scroll one page down\n"
+ " refresh: refresh screen\n"
" scroll: scroll number of lines (+/-N) or with time: "
"s=seconds, m=minutes, h=hours, d=days, M=months, y=years\n"
" scroll_up: scroll a few lines up\n"
@@ -3877,7 +3886,7 @@ command_init ()
"scroll_bottom: scroll to bottom of buffer\n"
"scroll_previous_highlight: scroll to previous highlight\n"
"scroll_next_highlight: scroll to next highlight\n"
- " refresh: refresh screen\n\n"
+ " zoom: zoom on window\n\n"
"For splith and splitv, pct is a percentage which "
"represents size of new window, computed with current "
"window as size reference. For example 25 means create a "
@@ -3888,9 +3897,9 @@ command_init ()
" scroll 2 days up: /window scroll -2d\n"
" scroll to beginning of current day: /window scroll -d"),
"list|-1|+1|up|down|left|right|splith|splitv|resize|merge|"
- "page_up|page_down|scroll_up|scroll|scroll_down|scroll_top|"
- "scroll_bottom|scroll_previous_highlight|"
- "scroll_next_highlight|refresh all",
+ "page_up|page_down|refresh|scroll_up|scroll|scroll_down|"
+ "scroll_top|scroll_bottom|scroll_previous_highlight|"
+ "scroll_next_highlight|zoom all",
&command_window, NULL);
}
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 43ccfced1..7d6b727bd 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -415,8 +415,8 @@ config_weechat_reload (void *data, struct t_config_file *config_file)
gui_bar_free_all ();
/* remove layout */
- gui_layout_buffer_reset ();
- gui_layout_window_reset ();
+ gui_layout_buffer_reset (&gui_layout_buffers, &last_gui_layout_buffer);
+ gui_layout_window_reset (&gui_layout_windows);
/* remove all filters */
gui_filter_free_all ();
@@ -748,7 +748,9 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
number1 = strtol (argv[2], &error1, 10);
if (error1 && !error1[0])
{
- gui_layout_buffer_add (argv[0], argv[1], number1);
+ gui_layout_buffer_add (&gui_layout_buffers,
+ &last_gui_layout_buffer,
+ argv[0], argv[1], number1);
}
}
string_free_exploded (argv);
@@ -772,8 +774,10 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
if (error1 && !error1[0] && error2 && !error2[0]
&& error3 && !error3[0] && error4 && !error4[0])
{
- parent = gui_layout_window_search_by_id (number2);
- gui_layout_window_add (number1,
+ parent = gui_layout_window_search_by_id (gui_layout_windows,
+ number2);
+ gui_layout_window_add (&gui_layout_windows,
+ number1,
parent,
number3,
number4,
diff --git a/src/core/weechat.c b/src/core/weechat.c
index 017ac95ec..6bb1f1af6 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -411,7 +411,7 @@ main (int argc, char *argv[])
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
argc, argv);
command_startup (1); /* command executed after plugins */
- gui_layout_window_apply (); /* apply saved layout for windows */
+ gui_layout_window_apply (gui_layout_windows, -1); /* apply saved layout */
weechat_upgrading = 0;
gui_main_loop (); /* WeeChat main loop */
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index 28a1d64ac..59a88eb58 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -138,6 +138,7 @@ gui_keyboard_default_bindings ()
gui_keyboard_bind (NULL, /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
gui_keyboard_bind (NULL, /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
gui_keyboard_bind (NULL, /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
+ gui_keyboard_bind (NULL, /* m-z */ "meta-z", "/window zoom");
gui_keyboard_bind (NULL, /* m-= */ "meta-=", "/filter toggle");
gui_keyboard_bind (NULL, /* m-0 */ "meta-0", "/buffer 10");
gui_keyboard_bind (NULL, /* m-1 */ "meta-1", "/buffer 1");
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index f35769b78..ce6571101 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -358,8 +358,8 @@ gui_main_end (int clean_exit)
free (gui_input_clipboard);
/* delete layout saved */
- gui_layout_window_remove_all ();
- gui_layout_buffer_remove_all ();
+ gui_layout_window_remove_all (&gui_layout_windows);
+ gui_layout_buffer_remove_all (&gui_layout_buffers, &last_gui_layout_buffer);
/* delete all windows */
while (gui_windows)
diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c
index 188c9a619..bc5d2d6b7 100644
--- a/src/gui/gtk/gui-gtk-main.c
+++ b/src/gui/gtk/gui-gtk-main.c
@@ -248,8 +248,8 @@ gui_main_end (int clean_exit)
free(gui_input_clipboard);
/* delete layout saved */
- gui_layout_window_remove_all ();
- gui_layout_buffer_remove_all ();
+ gui_layout_window_remove_all (&gui_layout_windows);
+ gui_layout_buffer_remove_all (&gui_layout_buffers, &last_gui_layout_buffer);
/* delete all windows */
while (gui_windows)
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index a511a1905..6144f6071 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -292,7 +292,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->plugin = plugin;
new_buffer->plugin_name_for_upgrade = NULL;
/* number will be set later (when inserting buffer in list) */
- new_buffer->layout_number = gui_layout_buffer_get_number (plugin_get_name (plugin),
+ new_buffer->layout_number = gui_layout_buffer_get_number (gui_layout_buffers,
+ plugin_get_name (plugin),
name);
new_buffer->name = strdup (name);
new_buffer->short_name = strdup (name);
diff --git a/src/gui/gui-layout.c b/src/gui/gui-layout.c
index 8b4fc4f2b..c673b4996 100644
--- a/src/gui/gui-layout.c
+++ b/src/gui/gui-layout.c
@@ -41,7 +41,14 @@ struct t_gui_layout_buffer *last_gui_layout_buffer = NULL;
struct t_gui_layout_window *gui_layout_windows = NULL;
-int internal_id = 0;
+/* used to attribute a unique id for each window in tree */
+int gui_layout_internal_id = 0;
+
+/* internal id of current window, when saving windows layout */
+int gui_layout_internal_id_current_window = 0;
+
+/* pointer to current window, found when applying windows layout */
+struct t_gui_window *gui_layout_ptr_current_window = NULL;
/*
@@ -49,7 +56,9 @@ int internal_id = 0;
*/
void
-gui_layout_buffer_remove (struct t_gui_layout_buffer *layout_buffer)
+gui_layout_buffer_remove (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer,
+ struct t_gui_layout_buffer *layout_buffer)
{
/* free data */
if (layout_buffer->plugin_name)
@@ -62,10 +71,10 @@ gui_layout_buffer_remove (struct t_gui_layout_buffer *layout_buffer)
(layout_buffer->prev_layout)->next_layout = layout_buffer->next_layout;
if (layout_buffer->next_layout)
(layout_buffer->next_layout)->prev_layout = layout_buffer->prev_layout;
- if (gui_layout_buffers == layout_buffer)
- gui_layout_buffers = layout_buffer->next_layout;
- if (last_gui_layout_buffer == layout_buffer)
- last_gui_layout_buffer = layout_buffer->prev_layout;
+ if (*layout_buffers == layout_buffer)
+ *layout_buffers = layout_buffer->next_layout;
+ if (*last_layout_buffer == layout_buffer)
+ *last_layout_buffer = layout_buffer->prev_layout;
free (layout_buffer);
}
@@ -75,11 +84,13 @@ gui_layout_buffer_remove (struct t_gui_layout_buffer *layout_buffer)
*/
void
-gui_layout_buffer_remove_all ()
+gui_layout_buffer_remove_all (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer)
{
- while (gui_layout_buffers)
+ while (*layout_buffers)
{
- gui_layout_buffer_remove (gui_layout_buffers);
+ gui_layout_buffer_remove (layout_buffers, last_layout_buffer,
+ *layout_buffers);
}
}
@@ -88,11 +99,12 @@ gui_layout_buffer_remove_all ()
*/
void
-gui_layout_buffer_reset ()
+gui_layout_buffer_reset (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer)
{
struct t_gui_buffer *ptr_buffer;
- gui_layout_buffer_remove_all ();
+ gui_layout_buffer_remove_all (layout_buffers, last_layout_buffer);
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
@@ -106,7 +118,9 @@ gui_layout_buffer_reset ()
*/
struct t_gui_layout_buffer *
-gui_layout_buffer_add (const char *plugin_name, const char *buffer_name,
+gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer,
+ const char *plugin_name, const char *buffer_name,
int number)
{
struct t_gui_layout_buffer *new_layout_buffer;
@@ -120,12 +134,12 @@ gui_layout_buffer_add (const char *plugin_name, const char *buffer_name,
new_layout_buffer->number = number;
/* add layout buffer to list */
- new_layout_buffer->prev_layout = last_gui_layout_buffer;
- if (gui_layout_buffers)
- last_gui_layout_buffer->next_layout = new_layout_buffer;
+ new_layout_buffer->prev_layout = *last_layout_buffer;
+ if (*layout_buffers)
+ (*last_layout_buffer)->next_layout = new_layout_buffer;
else
- gui_layout_buffers = new_layout_buffer;
- last_gui_layout_buffer = new_layout_buffer;
+ *layout_buffers = new_layout_buffer;
+ *last_layout_buffer = new_layout_buffer;
new_layout_buffer->next_layout = NULL;
}
@@ -137,16 +151,21 @@ gui_layout_buffer_add (const char *plugin_name, const char *buffer_name,
*/
void
-gui_layout_buffer_save ()
+gui_layout_buffer_save (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer)
{
struct t_gui_buffer *ptr_buffer;
- gui_layout_buffer_remove_all ();
+ if (!layout_buffers || !last_layout_buffer)
+ return;
+
+ gui_layout_buffer_remove_all (layout_buffers, last_layout_buffer);
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- gui_layout_buffer_add (plugin_get_name (ptr_buffer->plugin),
+ gui_layout_buffer_add (layout_buffers, last_layout_buffer,
+ plugin_get_name (ptr_buffer->plugin),
ptr_buffer->name,
ptr_buffer->number);
}
@@ -158,11 +177,12 @@ gui_layout_buffer_save ()
*/
int
-gui_layout_buffer_get_number (const char *plugin_name, const char *buffer_name)
+gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
+ const char *plugin_name, const char *buffer_name)
{
struct t_gui_layout_buffer *ptr_layout_buffer;
- for (ptr_layout_buffer = gui_layout_buffers; ptr_layout_buffer;
+ for (ptr_layout_buffer = layout_buffers; ptr_layout_buffer;
ptr_layout_buffer = ptr_layout_buffer->next_layout)
{
if ((string_strcasecmp (ptr_layout_buffer->plugin_name, plugin_name) == 0)
@@ -177,22 +197,23 @@ gui_layout_buffer_get_number (const char *plugin_name, const char *buffer_name)
}
/*
- * gui_layout_buffer_apply: apply current layout for buffers
+ * gui_layout_buffer_apply: apply a layout for buffers
*/
void
-gui_layout_buffer_apply ()
+gui_layout_buffer_apply (struct t_gui_layout_buffer *layout_buffers)
{
struct t_gui_buffer *ptr_buffer;
const char *plugin_name;
- if (gui_layout_buffers)
+ if (layout_buffers)
{
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
plugin_name = plugin_get_name (ptr_buffer->plugin);
- ptr_buffer->layout_number = gui_layout_buffer_get_number (plugin_name,
+ ptr_buffer->layout_number = gui_layout_buffer_get_number (layout_buffers,
+ plugin_name,
ptr_buffer->name);
if ((ptr_buffer->layout_number > 0)
&& (ptr_buffer->layout_number != ptr_buffer->number))
@@ -231,12 +252,12 @@ gui_layout_window_remove (struct t_gui_layout_window *layout_window)
*/
void
-gui_layout_window_remove_all ()
+gui_layout_window_remove_all (struct t_gui_layout_window **layout_windows)
{
- if (gui_layout_windows)
+ if (*layout_windows)
{
- gui_layout_window_remove (gui_layout_windows);
- gui_layout_windows = NULL;
+ gui_layout_window_remove (*layout_windows);
+ *layout_windows = NULL;
}
}
@@ -245,11 +266,11 @@ gui_layout_window_remove_all ()
*/
void
-gui_layout_window_reset ()
+gui_layout_window_reset (struct t_gui_layout_window **layout_windows)
{
struct t_gui_window *ptr_win;
- gui_layout_window_remove_all ();
+ gui_layout_window_remove_all (layout_windows);
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
@@ -267,28 +288,32 @@ gui_layout_window_reset ()
}
/*
- * gui_layout_window_search_by_id_tree: search a layout window by internal id
- * in a tree
+ * gui_layout_window_search_by_id: search a layout window by internal id
+ * in a layout
*/
struct t_gui_layout_window *
-gui_layout_window_search_by_id_tree (struct t_gui_layout_window *tree, int id)
+gui_layout_window_search_by_id (struct t_gui_layout_window *layout_windows,
+ int id)
{
struct t_gui_layout_window *res;
- if (tree->internal_id == id)
- return tree;
+ if (!layout_windows)
+ return NULL;
+
+ if (layout_windows->internal_id == id)
+ return layout_windows;
- if (tree->child1)
+ if (layout_windows->child1)
{
- res = gui_layout_window_search_by_id_tree (tree->child1, id);
+ res = gui_layout_window_search_by_id (layout_windows->child1, id);
if (res)
return res;
}
- if (tree->child2)
+ if (layout_windows->child2)
{
- res = gui_layout_window_search_by_id_tree (tree->child2, id);
+ res = gui_layout_window_search_by_id (layout_windows->child2, id);
if (res)
return res;
}
@@ -297,24 +322,12 @@ gui_layout_window_search_by_id_tree (struct t_gui_layout_window *tree, int id)
}
/*
- * gui_layout_window_search_by_id: search a layout window by internal id
- */
-
-struct t_gui_layout_window *
-gui_layout_window_search_by_id (int id)
-{
- if (!gui_layout_windows)
- return NULL;
-
- return gui_layout_window_search_by_id_tree (gui_layout_windows, id);
-}
-
-/*
* gui_layout_window_add: add a window layout
*/
struct t_gui_layout_window *
-gui_layout_window_add (int internal_id,
+gui_layout_window_add (struct t_gui_layout_window **layout_windows,
+ int internal_id,
struct t_gui_layout_window *parent,
int split_pct, int split_horiz,
const char *plugin_name, const char *buffer_name)
@@ -345,7 +358,7 @@ gui_layout_window_add (int internal_id,
else
{
/* no parent? => it's root! */
- gui_layout_windows = new_layout_window;
+ *layout_windows = new_layout_window;
}
}
@@ -357,14 +370,19 @@ gui_layout_window_add (int internal_id,
*/
void
-gui_layout_window_save_tree (struct t_gui_layout_window *parent_layout,
+gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
+ struct t_gui_layout_window *parent_layout,
struct t_gui_window_tree *tree)
{
struct t_gui_layout_window *layout_window;
if (tree->window)
{
- layout_window = gui_layout_window_add (internal_id++,
+ if (tree->window == gui_current_window)
+ gui_layout_internal_id_current_window = gui_layout_internal_id;
+
+ layout_window = gui_layout_window_add (layout_windows,
+ gui_layout_internal_id,
parent_layout,
0, 0,
plugin_get_name (tree->window->buffer->plugin),
@@ -372,7 +390,8 @@ gui_layout_window_save_tree (struct t_gui_layout_window *parent_layout,
}
else
{
- layout_window = gui_layout_window_add (internal_id++,
+ layout_window = gui_layout_window_add (layout_windows,
+ gui_layout_internal_id,
parent_layout,
tree->split_pct,
tree->split_horizontal,
@@ -380,24 +399,33 @@ gui_layout_window_save_tree (struct t_gui_layout_window *parent_layout,
NULL);
}
+ gui_layout_internal_id++;
+
if (tree->child1)
- gui_layout_window_save_tree (layout_window, tree->child1);
+ gui_layout_window_save_tree (layout_windows,
+ layout_window, tree->child1);
if (tree->child2)
- gui_layout_window_save_tree (layout_window, tree->child2);
+ gui_layout_window_save_tree (layout_windows,
+ layout_window, tree->child2);
}
/*
* gui_layout_window_save: save current layout for windows
+ * return internal id of current window
*/
-void
-gui_layout_window_save ()
+int
+gui_layout_window_save (struct t_gui_layout_window **layout_windows)
{
- gui_layout_window_remove_all ();
+ gui_layout_window_remove_all (layout_windows);
+
+ gui_layout_internal_id = 1;
+ gui_layout_internal_id_current_window = -1;
- internal_id = 1;
- gui_layout_window_save_tree (NULL, gui_windows_tree);
+ gui_layout_window_save_tree (layout_windows, NULL, gui_windows_tree);
+
+ return gui_layout_internal_id_current_window;
}
/*
@@ -464,7 +492,8 @@ gui_layout_window_check_all_buffers ()
*/
void
-gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window)
+gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
+ int internal_id_current_window)
{
struct t_gui_window *new_window, *old_window;
@@ -485,17 +514,22 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window)
}
if (layout_window->child2)
- gui_layout_window_apply_tree (layout_window->child2);
+ gui_layout_window_apply_tree (layout_window->child2,
+ internal_id_current_window);
if (old_window != gui_current_window)
gui_window_switch (old_window);
if (layout_window->child1)
- gui_layout_window_apply_tree (layout_window->child1);
+ gui_layout_window_apply_tree (layout_window->child1,
+ internal_id_current_window);
}
else
{
/* leaf */
+ if (layout_window->internal_id == internal_id_current_window)
+ gui_layout_ptr_current_window = gui_current_window;
+
gui_window_set_layout_plugin_name (gui_current_window,
layout_window->plugin_name);
gui_window_set_layout_buffer_name (gui_current_window,
@@ -508,21 +542,25 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window)
*/
void
-gui_layout_window_apply ()
+gui_layout_window_apply (struct t_gui_layout_window *layout_windows,
+ int internal_id_current_window)
{
struct t_gui_window *old_window;
- if (gui_layout_windows)
+ if (layout_windows)
{
gui_window_merge_all (gui_current_window);
old_window = gui_current_window;
+ gui_layout_ptr_current_window = NULL;
- gui_layout_window_apply_tree (gui_layout_windows);
+ gui_layout_window_apply_tree (layout_windows,
+ internal_id_current_window);
gui_layout_window_check_all_buffers ();
- gui_window_switch (old_window);
+ gui_window_switch ((gui_layout_ptr_current_window) ?
+ gui_layout_ptr_current_window : old_window);
}
}
@@ -540,14 +578,14 @@ gui_layout_save_on_exit ()
case CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_NONE:
break;
case CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_BUFFERS:
- gui_layout_buffer_save ();
+ gui_layout_buffer_save (&gui_layout_buffers, &last_gui_layout_buffer);
break;
case CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_WINDOWS:
- gui_layout_window_save ();
+ gui_layout_window_save (&gui_layout_windows);
break;
case CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_ALL:
- gui_layout_buffer_save ();
- gui_layout_window_save ();
+ gui_layout_buffer_save (&gui_layout_buffers, &last_gui_layout_buffer);
+ gui_layout_window_save (&gui_layout_windows);
break;
}
}
diff --git a/src/gui/gui-layout.h b/src/gui/gui-layout.h
index bc09e6601..fe81fe34f 100644
--- a/src/gui/gui-layout.h
+++ b/src/gui/gui-layout.h
@@ -51,32 +51,41 @@ struct t_gui_layout_window
/* layout variables */
extern struct t_gui_layout_buffer *gui_layout_buffers;
-extern struct t_gui_layout_buffer *gui_layout_last_buffer;
+extern struct t_gui_layout_buffer *last_gui_layout_buffer;
extern struct t_gui_layout_window *gui_layout_windows;
/* layout functions */
-extern void gui_layout_buffer_remove_all ();
-extern void gui_layout_buffer_reset ();
-extern struct t_gui_layout_buffer *gui_layout_buffer_add (const char *plugin_name,
+extern void gui_layout_buffer_remove_all (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer);
+extern void gui_layout_buffer_reset (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer);
+extern struct t_gui_layout_buffer *gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer,
+ const char *plugin_name,
const char *buffer_name,
int number);
-extern void gui_layout_buffer_save ();
-extern int gui_layout_buffer_get_number (const char *plugin_name,
+extern void gui_layout_buffer_save (struct t_gui_layout_buffer **layout_buffers,
+ struct t_gui_layout_buffer **last_layout_buffer);
+extern int gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
+ const char *plugin_name,
const char *buffer_name);
-extern void gui_layout_buffer_apply ();
+extern void gui_layout_buffer_apply (struct t_gui_layout_buffer *layout_buffers);
-extern void gui_layout_window_remove_all ();
-extern void gui_layout_window_reset ();
-extern struct t_gui_layout_window *gui_layout_window_search_by_id (int id);
-extern struct t_gui_layout_window *gui_layout_window_add (int internal_id,
+extern void gui_layout_window_remove_all (struct t_gui_layout_window **layout_windows);
+extern void gui_layout_window_reset (struct t_gui_layout_window **layout_windows);
+extern struct t_gui_layout_window *gui_layout_window_search_by_id (struct t_gui_layout_window *layout_windows,
+ int id);
+extern struct t_gui_layout_window *gui_layout_window_add (struct t_gui_layout_window **layout_windows,
+ int internal_id,
struct t_gui_layout_window *parent,
int split_pct,
int split_horiz,
const char *plugin_name,
const char *buffer_name);
-extern void gui_layout_window_save ();
-extern void gui_layout_window_apply ();
+extern int gui_layout_window_save (struct t_gui_layout_window **layout_windows);
+extern void gui_layout_window_apply (struct t_gui_layout_window *layout_windows,
+ int internal_id_current_window);
extern void gui_layout_window_check_buffer (struct t_gui_buffer *buffer);
extern void gui_layout_save_on_exit ();
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index e0e6acc65..906a1f3f9 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -48,6 +48,7 @@
#include "gui-filter.h"
#include "gui-input.h"
#include "gui-hotlist.h"
+#include "gui-layout.h"
int gui_init_ok = 0; /* = 1 if GUI is initialized*/
@@ -61,6 +62,11 @@ struct t_gui_window *gui_current_window = NULL; /* current window */
struct t_gui_window_tree *gui_windows_tree = NULL; /* windows tree */
+struct t_gui_layout_window *gui_window_layout_before_zoom = NULL;
+ /* layout before zooming on a window */
+int gui_window_layout_id_current_window = -1;
+ /* current window id before zoom */
+
/*
* gui_window_ask_refresh: set "gui_window_refresh_needed" flag
@@ -911,6 +917,34 @@ gui_window_search_stop (struct t_gui_window *window)
}
/*
+ * gui_window_zoom: zoom window (maximize it or restore layout before previous
+ * zoom)
+ */
+
+void
+gui_window_zoom (struct t_gui_window *window)
+{
+ if (!gui_ok)
+ return;
+
+ if (gui_window_layout_before_zoom)
+ {
+ /* restore layout as it was before zooming a window */
+ gui_layout_window_apply (gui_window_layout_before_zoom,
+ gui_window_layout_id_current_window);
+ gui_layout_window_remove_all (&gui_window_layout_before_zoom);
+ gui_window_layout_id_current_window = -1;
+ }
+ else
+ {
+ /* save layout and zoom on current window */
+ gui_window_layout_id_current_window =
+ gui_layout_window_save (&gui_window_layout_before_zoom);
+ gui_window_merge_all (window);
+ }
+}
+
+/*
* gui_window_add_to_infolist: add a window in an infolist
* return 1 if ok, 0 if error
*/
@@ -972,7 +1006,11 @@ gui_window_print_log ()
struct t_gui_bar_window *ptr_bar_win;
log_printf ("");
- log_printf ("current window = 0x%lx", gui_current_window);
+ log_printf ("gui_windows . . . . . . . . . : 0x%lx", gui_windows);
+ log_printf ("last_gui_window . . . . . . . : 0x%lx", last_gui_window);
+ log_printf ("gui_current window. . . . . . : 0x%lx", gui_current_window);
+ log_printf ("gui_windows_tree. . . . . . . : 0x%lx", gui_windows_tree);
+ log_printf ("gui_window_layout_before_zoom : 0x%lx", gui_window_layout_before_zoom);
for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window)
{
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index fce3221fe..ae81801c7 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -135,6 +135,7 @@ extern void gui_window_search_start (struct t_gui_window *window);
extern void gui_window_search_restart (struct t_gui_window *window);
extern void gui_window_search_stop (struct t_gui_window *window);
extern int gui_window_search_text (struct t_gui_window *window);
+extern void gui_window_zoom (struct t_gui_window *window);
extern int gui_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_window *window);
extern void gui_window_print_log ();