summaryrefslogtreecommitdiff
path: root/src/gui/gui-layout.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-03-17 08:28:41 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-03-17 08:28:41 +0100
commit30e6acb00dc42afbeb8993ee766199b830335c04 (patch)
treefe825435d5bbc2a190959d569d304a14bb69e4ef /src/gui/gui-layout.c
parente1e3109da3ecf6b81cb6c725f500c8c6e93192f4 (diff)
downloadweechat-30e6acb00dc42afbeb8993ee766199b830335c04.zip
core: add support of multiple layouts (task #11274)
Diffstat (limited to 'src/gui/gui-layout.c')
-rw-r--r--src/gui/gui-layout.c492
1 files changed, 358 insertions, 134 deletions
diff --git a/src/gui/gui-layout.c b/src/gui/gui-layout.c
index 98807602e..124dd42eb 100644
--- a/src/gui/gui-layout.c
+++ b/src/gui/gui-layout.c
@@ -37,76 +37,168 @@
#include "gui-window.h"
-struct t_gui_layout_buffer *gui_layout_buffers = NULL;
-struct t_gui_layout_buffer *last_gui_layout_buffer = NULL;
+struct t_gui_layout *gui_layouts = NULL;
+struct t_gui_layout *last_gui_layout = NULL;
+struct t_gui_layout *gui_layout_current = NULL;
-struct t_gui_layout_window *gui_layout_windows = NULL;
-/* used to attribute a unique id for each window in tree */
-int gui_layout_internal_id = 0;
+/*
+ * Searches a layout by name.
+ *
+ * Returns pointer to layout found, NULL if not found.
+ */
-/* internal id of current window, when saving windows layout */
-int gui_layout_internal_id_current_window = 0;
+struct t_gui_layout *
+gui_layout_search (const char *name)
+{
+ struct t_gui_layout *ptr_layout;
-/* pointer to current window, found when applying windows layout */
-struct t_gui_window *gui_layout_ptr_current_window = NULL;
+ for (ptr_layout = gui_layouts; ptr_layout;
+ ptr_layout = ptr_layout->next_layout)
+ {
+ if (strcmp (ptr_layout->name, name) == 0)
+ return ptr_layout;
+ }
+ /* layout not found */
+ return NULL;
+}
/*
- * Removes a buffer layout.
+ * Allocates a new layout.
+ *
+ * Note: the layout is not added to the list (a call to gui_layout_add() will do
+ * that).
+ *
+ * Returns pointer to new layout, NULL if error.
+ */
+
+struct t_gui_layout *
+gui_layout_alloc (const char *name)
+{
+ struct t_gui_layout *new_layout;
+
+ if (!name || !name[0])
+ return NULL;
+
+ /* create new layout */
+ new_layout = malloc (sizeof (*new_layout));
+ if (!new_layout)
+ return NULL;
+
+ new_layout->name = strdup (name);
+ new_layout->layout_buffers = NULL;
+ new_layout->last_layout_buffer = NULL;
+ new_layout->layout_windows = NULL;
+ new_layout->internal_id = 0;
+ new_layout->internal_id_current_window = 0;
+ new_layout->prev_layout = NULL;
+ new_layout->next_layout = NULL;
+
+ return new_layout;
+}
+
+/*
+ * Adds a layout in "gui_layouts".
+ *
+ * Returns:
+ * 1: layout added
+ * 0: layout not added (another layout exists with same name)
+ */
+
+int
+gui_layout_add (struct t_gui_layout *layout)
+{
+ struct t_gui_layout *ptr_layout;
+
+ if (!layout)
+ return 0;
+
+ ptr_layout = gui_layout_search (layout->name);
+ if (ptr_layout)
+ return 0;
+
+ layout->prev_layout = last_gui_layout;
+ layout->next_layout = NULL;
+ if (gui_layouts)
+ last_gui_layout->next_layout = layout;
+ else
+ gui_layouts = layout;
+ last_gui_layout = layout;
+
+ return 1;
+}
+
+/*
+ * Renames a layout.
+ */
+
+void
+gui_layout_rename (struct t_gui_layout *layout, const char *new_name)
+{
+ if (!layout || !new_name || !new_name[0])
+ return;
+
+ if (layout->name)
+ free (layout->name);
+ layout->name = strdup (new_name);
+}
+
+/*
+ * Removes a buffer layout from a layout.
*/
void
-gui_layout_buffer_remove (struct t_gui_layout_buffer **layout_buffers,
- struct t_gui_layout_buffer **last_layout_buffer,
+gui_layout_buffer_remove (struct t_gui_layout *layout,
struct t_gui_layout_buffer *layout_buffer)
{
- /* free data */
- if (layout_buffer->plugin_name)
- free (layout_buffer->plugin_name);
- if (layout_buffer->buffer_name)
- free (layout_buffer->buffer_name);
+ if (!layout)
+ return;
/* remove layout from list */
if (layout_buffer->prev_layout)
(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 (*layout_buffers == layout_buffer)
- *layout_buffers = layout_buffer->next_layout;
- if (*last_layout_buffer == layout_buffer)
- *last_layout_buffer = layout_buffer->prev_layout;
+ if (layout->layout_buffers == layout_buffer)
+ layout->layout_buffers = layout_buffer->next_layout;
+ if (layout->last_layout_buffer == layout_buffer)
+ layout->last_layout_buffer = layout_buffer->prev_layout;
+
+ /* free data */
+ if (layout_buffer->plugin_name)
+ free (layout_buffer->plugin_name);
+ if (layout_buffer->buffer_name)
+ free (layout_buffer->buffer_name);
free (layout_buffer);
}
/*
- * Removes all buffer layouts.
+ * Removes all buffer layouts from a layout.
*/
void
-gui_layout_buffer_remove_all (struct t_gui_layout_buffer **layout_buffers,
- struct t_gui_layout_buffer **last_layout_buffer)
+gui_layout_buffer_remove_all (struct t_gui_layout *layout)
{
- while (*layout_buffers)
+ if (!layout)
+ return;
+
+ while (layout->layout_buffers)
{
- gui_layout_buffer_remove (layout_buffers, last_layout_buffer,
- *layout_buffers);
+ gui_layout_buffer_remove (layout, layout->layout_buffers);
}
}
/*
- * Resets layout for buffers.
+ * Resets layout_number in all buffers.
*/
void
-gui_layout_buffer_reset (struct t_gui_layout_buffer **layout_buffers,
- struct t_gui_layout_buffer **last_layout_buffer)
+gui_layout_buffer_reset ()
{
struct t_gui_buffer *ptr_buffer;
- gui_layout_buffer_remove_all (layout_buffers, last_layout_buffer);
-
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -115,19 +207,21 @@ gui_layout_buffer_reset (struct t_gui_layout_buffer **layout_buffers,
}
/*
- * Adds a buffer layout.
+ * Adds a buffer layout in a layout.
*
* Returns pointer to buffer layout, NULL if error.
*/
struct t_gui_layout_buffer *
-gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
- struct t_gui_layout_buffer **last_layout_buffer,
+gui_layout_buffer_add (struct t_gui_layout *layout,
const char *plugin_name, const char *buffer_name,
int number)
{
struct t_gui_layout_buffer *new_layout_buffer;
+ if (!layout || !plugin_name || !buffer_name)
+ return NULL;
+
new_layout_buffer = malloc (sizeof (*new_layout_buffer));
if (new_layout_buffer)
{
@@ -137,12 +231,12 @@ gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
new_layout_buffer->number = number;
/* add layout buffer to list */
- new_layout_buffer->prev_layout = *last_layout_buffer;
- if (*layout_buffers)
- (*last_layout_buffer)->next_layout = new_layout_buffer;
+ new_layout_buffer->prev_layout = layout->last_layout_buffer;
+ if (layout->layout_buffers)
+ (layout->last_layout_buffer)->next_layout = new_layout_buffer;
else
- *layout_buffers = new_layout_buffer;
- *last_layout_buffer = new_layout_buffer;
+ layout->layout_buffers = new_layout_buffer;
+ layout->last_layout_buffer = new_layout_buffer;
new_layout_buffer->next_layout = NULL;
}
@@ -154,7 +248,7 @@ gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
*/
void
-gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
+gui_layout_buffer_get_number (struct t_gui_layout *layout,
const char *plugin_name, const char *buffer_name,
int *layout_number,
int *layout_number_merge_order)
@@ -165,10 +259,13 @@ gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
*layout_number = 0;
*layout_number_merge_order = 0;
+ if (!layout)
+ return;
+
old_number = -1;
merge_order = 0;
- for (ptr_layout_buffer = layout_buffers; ptr_layout_buffer;
+ for (ptr_layout_buffer = layout->layout_buffers; ptr_layout_buffer;
ptr_layout_buffer = ptr_layout_buffer->next_layout)
{
if (ptr_layout_buffer->number != old_number)
@@ -194,17 +291,14 @@ gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
*/
void
-gui_layout_buffer_get_number_all (struct t_gui_layout_buffer *layout_buffers)
+gui_layout_buffer_get_number_all (struct t_gui_layout *layout)
{
struct t_gui_buffer *ptr_buffer;
- if (!layout_buffers)
- return;
-
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- gui_layout_buffer_get_number (layout_buffers,
+ gui_layout_buffer_get_number (layout,
gui_buffer_get_plugin_name (ptr_buffer),
ptr_buffer->name,
&(ptr_buffer->layout_number),
@@ -213,31 +307,30 @@ gui_layout_buffer_get_number_all (struct t_gui_layout_buffer *layout_buffers)
}
/*
- * Saves current layout for buffers.
+ * Saves current layout for buffers in a layout.
*/
void
-gui_layout_buffer_save (struct t_gui_layout_buffer **layout_buffers,
- struct t_gui_layout_buffer **last_layout_buffer)
+gui_layout_buffer_save (struct t_gui_layout *layout)
{
struct t_gui_buffer *ptr_buffer;
- if (!layout_buffers || !last_layout_buffer)
+ if (!layout)
return;
- gui_layout_buffer_remove_all (layout_buffers, last_layout_buffer);
+ gui_layout_buffer_remove_all (layout);
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- gui_layout_buffer_add (layout_buffers, last_layout_buffer,
+ gui_layout_buffer_add (layout,
gui_buffer_get_plugin_name (ptr_buffer),
ptr_buffer->name,
ptr_buffer->number);
}
/* get layout number for all buffers */
- gui_layout_buffer_get_number_all (*layout_buffers);
+ gui_layout_buffer_get_number_all (layout);
}
/*
@@ -245,13 +338,16 @@ gui_layout_buffer_save (struct t_gui_layout_buffer **layout_buffers,
*/
void
-gui_layout_buffer_apply (struct t_gui_layout_buffer *layout_buffers)
+gui_layout_buffer_apply (struct t_gui_layout *layout)
{
struct t_gui_buffer *ptr_buffer, *ptr_next_buffer;
int number, count_merged;
+ if (!layout)
+ return;
+
/* get layout number for all buffers */
- gui_layout_buffer_get_number_all (layout_buffers);
+ gui_layout_buffer_get_number_all (layout);
/* unmerge all buffers */
gui_buffer_unmerge_all ();
@@ -298,6 +394,9 @@ gui_layout_buffer_apply (struct t_gui_layout_buffer *layout_buffers)
void
gui_layout_window_remove (struct t_gui_layout_window *layout_window)
{
+ if (!layout_window)
+ return;
+
/* first free children */
if (layout_window->child1)
gui_layout_window_remove (layout_window->child1);
@@ -314,30 +413,32 @@ gui_layout_window_remove (struct t_gui_layout_window *layout_window)
}
/*
- * Removes all window layouts.
+ * Removes all window layouts from a layout.
*/
void
-gui_layout_window_remove_all (struct t_gui_layout_window **layout_windows)
+gui_layout_window_remove_all (struct t_gui_layout *layout)
{
- if (*layout_windows)
+ if (!layout)
+ return;
+
+ if (layout->layout_windows)
{
- gui_layout_window_remove (*layout_windows);
- *layout_windows = NULL;
+ gui_layout_window_remove (layout->layout_windows);
+ layout->layout_windows = NULL;
}
}
+
/*
* Resets layout for windows.
*/
void
-gui_layout_window_reset (struct t_gui_layout_window **layout_windows)
+gui_layout_window_reset ()
{
struct t_gui_window *ptr_win;
- gui_layout_window_remove_all (layout_windows);
-
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->layout_plugin_name)
@@ -354,33 +455,33 @@ gui_layout_window_reset (struct t_gui_layout_window **layout_windows)
}
/*
- * Searches for a window layout by internal id in a layout.
+ * Searches for a window layout by internal id.
*
* Returns pointer to window layout found, NULL if not found.
*/
struct t_gui_layout_window *
-gui_layout_window_search_by_id (struct t_gui_layout_window *layout_windows,
+gui_layout_window_search_by_id (struct t_gui_layout_window *layout_window,
int id)
{
struct t_gui_layout_window *res;
- if (!layout_windows)
+ if (!layout_window)
return NULL;
- if (layout_windows->internal_id == id)
- return layout_windows;
+ if (layout_window->internal_id == id)
+ return layout_window;
- if (layout_windows->child1)
+ if (layout_window->child1)
{
- res = gui_layout_window_search_by_id (layout_windows->child1, id);
+ res = gui_layout_window_search_by_id (layout_window->child1, id);
if (res)
return res;
}
- if (layout_windows->child2)
+ if (layout_window->child2)
{
- res = gui_layout_window_search_by_id (layout_windows->child2, id);
+ res = gui_layout_window_search_by_id (layout_window->child2, id);
if (res)
return res;
}
@@ -395,7 +496,7 @@ gui_layout_window_search_by_id (struct t_gui_layout_window *layout_windows,
*/
struct t_gui_layout_window *
-gui_layout_window_add (struct t_gui_layout_window **layout_windows,
+gui_layout_window_add (struct t_gui_layout_window **layout_window,
int internal_id,
struct t_gui_layout_window *parent,
int split_pct, int split_horiz,
@@ -403,6 +504,9 @@ gui_layout_window_add (struct t_gui_layout_window **layout_windows,
{
struct t_gui_layout_window *new_layout_window;
+ if (!layout_window)
+ return NULL;
+
new_layout_window = malloc (sizeof (*new_layout_window));
if (new_layout_window)
{
@@ -427,7 +531,7 @@ gui_layout_window_add (struct t_gui_layout_window **layout_windows,
else
{
/* no parent? => it's root! */
- *layout_windows = new_layout_window;
+ *layout_window = new_layout_window;
}
}
@@ -439,7 +543,8 @@ gui_layout_window_add (struct t_gui_layout_window **layout_windows,
*/
void
-gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
+gui_layout_window_save_tree (struct t_gui_layout *layout,
+ struct t_gui_layout_window **layout_windows,
struct t_gui_layout_window *parent_layout,
struct t_gui_window_tree *tree)
{
@@ -448,10 +553,10 @@ gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
if (tree->window)
{
if (tree->window == gui_current_window)
- gui_layout_internal_id_current_window = gui_layout_internal_id;
+ layout->internal_id_current_window = layout->internal_id;
layout_window = gui_layout_window_add (layout_windows,
- gui_layout_internal_id,
+ layout->internal_id,
parent_layout,
0, 0,
gui_buffer_get_plugin_name (tree->window->buffer),
@@ -460,7 +565,7 @@ gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
else
{
layout_window = gui_layout_window_add (layout_windows,
- gui_layout_internal_id,
+ layout->internal_id,
parent_layout,
tree->split_pct,
tree->split_horizontal,
@@ -468,42 +573,48 @@ gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
NULL);
}
- gui_layout_internal_id++;
+ layout->internal_id++;
if (tree->child1)
- gui_layout_window_save_tree (layout_windows,
+ {
+ gui_layout_window_save_tree (layout, layout_windows,
layout_window, tree->child1);
+ }
if (tree->child2)
- gui_layout_window_save_tree (layout_windows,
+ {
+ gui_layout_window_save_tree (layout, layout_windows,
layout_window, tree->child2);
+ }
}
/*
- * Saves current layout for windows.
+ * Saves current layout for windows in a layout.
*
* Returns internal id of current window.
*/
-int
-gui_layout_window_save (struct t_gui_layout_window **layout_windows)
+void
+gui_layout_window_save (struct t_gui_layout *layout)
{
- gui_layout_window_remove_all (layout_windows);
+ if (!layout)
+ return;
- gui_layout_internal_id = 1;
- gui_layout_internal_id_current_window = -1;
+ gui_layout_window_remove (layout->layout_windows);
- gui_layout_window_save_tree (layout_windows, NULL, gui_windows_tree);
+ layout->internal_id = 1;
+ layout->internal_id_current_window = -1;
- return gui_layout_internal_id_current_window;
+ gui_layout_window_save_tree (layout, &layout->layout_windows, NULL,
+ gui_windows_tree);
}
/*
- * Checks if buffer can be assigned to one window.
+ * Assigns a buffer to windows.
*/
void
-gui_layout_window_check_buffer (struct t_gui_buffer *buffer)
+gui_layout_window_assign_buffer (struct t_gui_buffer *buffer)
{
struct t_gui_window *ptr_win;
const char *plugin_name;
@@ -529,7 +640,7 @@ gui_layout_window_check_buffer (struct t_gui_buffer *buffer)
*/
void
-gui_layout_window_check_all_buffers ()
+gui_layout_window_assign_all_buffers ()
{
struct t_gui_window *ptr_win;
struct t_gui_buffer *ptr_buffer;
@@ -559,7 +670,8 @@ gui_layout_window_check_all_buffers ()
void
gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
- int internal_id_current_window)
+ int internal_id_current_window,
+ struct t_gui_window **current_window)
{
struct t_gui_window *old_window;
@@ -580,21 +692,27 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
}
if (layout_window->child2)
+ {
gui_layout_window_apply_tree (layout_window->child2,
- internal_id_current_window);
+ internal_id_current_window,
+ 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,
- internal_id_current_window);
+ internal_id_current_window,
+ current_window);
+ }
}
else
{
/* leaf */
if (layout_window->internal_id == internal_id_current_window)
- gui_layout_ptr_current_window = gui_current_window;
+ *current_window = gui_current_window;
gui_window_set_layout_plugin_name (gui_current_window,
layout_window->plugin_name);
@@ -608,26 +726,26 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
*/
void
-gui_layout_window_apply (struct t_gui_layout_window *layout_windows,
+gui_layout_window_apply (struct t_gui_layout *layout,
int internal_id_current_window)
{
- struct t_gui_window *old_window;
+ struct t_gui_window *old_window, *ptr_current_window;
- if (!layout_windows)
+ if (!layout || !layout->layout_windows)
return;
gui_window_merge_all (gui_current_window);
old_window = gui_current_window;
- gui_layout_ptr_current_window = NULL;
+ ptr_current_window = NULL;
- gui_layout_window_apply_tree (layout_windows,
- internal_id_current_window);
+ gui_layout_window_apply_tree (layout->layout_windows,
+ internal_id_current_window,
+ &ptr_current_window);
- gui_layout_window_check_all_buffers ();
+ gui_layout_window_assign_all_buffers ();
- gui_window_switch ((gui_layout_ptr_current_window) ?
- gui_layout_ptr_current_window : old_window);
+ gui_window_switch ((ptr_current_window) ? ptr_current_window : old_window);
}
/*
@@ -637,25 +755,117 @@ gui_layout_window_apply (struct t_gui_layout_window *layout_windows,
void
gui_layout_save_on_exit ()
{
- /* save layout on exit */
+ struct t_gui_layout *ptr_layout;
+
+ if (CONFIG_BOOLEAN(config_look_save_layout_on_exit) == CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_NONE)
+ return;
+
+ ptr_layout = gui_layout_current;
+ if (!ptr_layout)
+ {
+ /* create a "default" layout if needed */
+ ptr_layout = gui_layout_search (GUI_LAYOUT_DEFAULT_NAME);
+ if (!ptr_layout)
+ {
+ ptr_layout = gui_layout_alloc (GUI_LAYOUT_DEFAULT_NAME);
+ if (!ptr_layout)
+ return;
+ gui_layout_add (ptr_layout);
+ }
+ }
+
+ /* save current layout */
switch (CONFIG_BOOLEAN(config_look_save_layout_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_buffers, &last_gui_layout_buffer);
+ gui_layout_buffer_save (ptr_layout);
break;
case CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_WINDOWS:
- gui_layout_window_save (&gui_layout_windows);
+ gui_layout_window_save (ptr_layout);
break;
case CONFIG_LOOK_SAVE_LAYOUT_ON_EXIT_ALL:
- gui_layout_buffer_save (&gui_layout_buffers, &last_gui_layout_buffer);
- gui_layout_window_save (&gui_layout_windows);
+ gui_layout_buffer_save (ptr_layout);
+ gui_layout_window_save (ptr_layout);
+ break;
+ default:
break;
}
}
/*
+ * Frees a layout.
+ */
+
+void
+gui_layout_free (struct t_gui_layout *layout)
+{
+ if (!layout)
+ return;
+
+ /* remove current layout if this is the layout we are removing */
+ if (gui_layout_current == layout)
+ gui_layout_current = NULL;
+
+ /* remove buffers and windows */
+ gui_layout_buffer_remove_all (layout);
+ gui_layout_window_remove (layout->layout_windows);
+
+ /* free data */
+ if (layout->name)
+ free (layout->name);
+
+ free (layout);
+}
+
+/*
+ * Removes a layout from hashtable "gui_layouts".
+ */
+
+void
+gui_layout_remove (struct t_gui_layout *layout)
+{
+ struct t_gui_layout *new_gui_layouts;
+
+ if (!layout)
+ return;
+
+ /* remove current layout if this is the layout we are removing */
+ if (gui_layout_current == layout)
+ gui_layout_current = NULL;
+
+ /* remove alias from list */
+ if (last_gui_layout == layout)
+ last_gui_layout = layout->prev_layout;
+ if (layout->prev_layout)
+ {
+ (layout->prev_layout)->next_layout = layout->next_layout;
+ new_gui_layouts = gui_layouts;
+ }
+ else
+ new_gui_layouts = layout->next_layout;
+ if (layout->next_layout)
+ (layout->next_layout)->prev_layout = layout->prev_layout;
+
+ /* free data */
+ gui_layout_free (layout);
+
+ gui_layouts = new_gui_layouts;
+}
+
+/*
+ * Removes all layouts from "gui_layouts".
+ */
+
+void
+gui_layout_remove_all ()
+{
+ while (gui_layouts)
+ {
+ gui_layout_remove (gui_layouts);
+ }
+}
+
+/*
* Adds a buffer layout in an infolist.
*
* Returns:
@@ -740,19 +950,19 @@ gui_layout_print_log_window (struct t_gui_layout_window *layout_window,
int level)
{
log_printf ("");
- log_printf ("[layout window (addr:0x%lx) (%s) (level %d)]",
+ log_printf (" [layout window (addr:0x%lx) (%s) (level %d)]",
layout_window,
(layout_window->plugin_name) ? "leaf" : "node",
level);
- log_printf (" internal_id. . . . . . : %d", layout_window->internal_id);
- log_printf (" parent_node. . . . . . : 0x%lx", layout_window->parent_node);
- log_printf (" split_pct. . . . . . . : %d", layout_window->split_pct);
- log_printf (" split_horiz. . . . . . : %d", layout_window->split_horiz);
- log_printf (" child1 . . . . . . . . : 0x%lx", layout_window->child1);
- log_printf (" child2 . . . . . . . . : 0x%lx", layout_window->child2);
- log_printf (" plugin_name. . . . . . : '%s'", layout_window->plugin_name);
- log_printf (" buffer_name. . . . . . : '%s'", layout_window->buffer_name);
+ log_printf (" internal_id. . . . . : %d", layout_window->internal_id);
+ log_printf (" parent_node. . . . . : 0x%lx", layout_window->parent_node);
+ log_printf (" split_pct. . . . . . : %d", layout_window->split_pct);
+ log_printf (" split_horiz. . . . . : %d", layout_window->split_horiz);
+ log_printf (" child1 . . . . . . . : 0x%lx", layout_window->child1);
+ log_printf (" child2 . . . . . . . : 0x%lx", layout_window->child2);
+ log_printf (" plugin_name. . . . . : '%s'", layout_window->plugin_name);
+ log_printf (" buffer_name. . . . . : '%s'", layout_window->buffer_name);
if (layout_window->child1)
gui_layout_print_log_window (layout_window->child1, level + 1);
@@ -762,28 +972,42 @@ gui_layout_print_log_window (struct t_gui_layout_window *layout_window,
}
/*
- * Prints layout infos in WeeChat log file (usually for crash dump).
+ * Prints layouts in WeeChat log file (usually for crash dump).
*/
void
gui_layout_print_log ()
{
+ struct t_gui_layout *ptr_layout;
struct t_gui_layout_buffer *ptr_layout_buffer;
log_printf ("");
+ log_printf ("gui_layouts . . . . . . . . . : 0x%lx", gui_layouts);
+ log_printf ("last_gui_layout . . . . . . . : 0x%lx", last_gui_layout);
+ log_printf ("gui_layout_current. . . . . . : 0x%lx", gui_layout_current);
- for (ptr_layout_buffer = gui_layout_buffers; ptr_layout_buffer;
- ptr_layout_buffer = ptr_layout_buffer->next_layout)
+ for (ptr_layout = gui_layouts; ptr_layout;
+ ptr_layout = ptr_layout->next_layout)
{
log_printf ("");
- log_printf ("[layout buffer (addr:0x%lx)]", ptr_layout_buffer);
- log_printf (" plugin_name. . . . . . : '%s'", ptr_layout_buffer->plugin_name);
- log_printf (" buffer_name. . . . . . : '%s'", ptr_layout_buffer->buffer_name);
- log_printf (" number . . . . . . . . : %d", ptr_layout_buffer->number);
- log_printf (" prev_layout. . . . . . : 0x%lx", ptr_layout_buffer->prev_layout);
- log_printf (" next_layout. . . . . . : 0x%lx", ptr_layout_buffer->next_layout);
+ log_printf ("[layout \"%s\" (addr:0x%lx)]", ptr_layout->name, ptr_layout);
+ log_printf (" layout_buffers . . . . : 0x%lx", ptr_layout->layout_buffers);
+ log_printf (" last_layout_buffer . . : 0x%lx", ptr_layout->last_layout_buffer);
+ log_printf (" layout_windows . . . . : 0x%lx", ptr_layout->layout_windows);
+ log_printf (" internal_id. . . . . . : %d", ptr_layout->internal_id);
+ log_printf (" internal_id_current_win: %d", ptr_layout->internal_id_current_window);
+ for (ptr_layout_buffer = ptr_layout->layout_buffers; ptr_layout_buffer;
+ ptr_layout_buffer = ptr_layout_buffer->next_layout)
+ {
+ log_printf ("");
+ log_printf (" [layout buffer (addr:0x%lx)]", ptr_layout_buffer);
+ log_printf (" plugin_name. . . . . : '%s'", ptr_layout_buffer->plugin_name);
+ log_printf (" buffer_name. . . . . : '%s'", ptr_layout_buffer->buffer_name);
+ log_printf (" number . . . . . . . : %d", ptr_layout_buffer->number);
+ log_printf (" prev_layout. . . . . : 0x%lx", ptr_layout_buffer->prev_layout);
+ log_printf (" next_layout. . . . . : 0x%lx", ptr_layout_buffer->next_layout);
+ }
+ if (ptr_layout->layout_windows)
+ gui_layout_print_log_window (ptr_layout->layout_windows, 0);
}
-
- if (gui_layout_windows)
- gui_layout_print_log_window (gui_layout_windows, 0);
}