1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-08 02:33:12 +02:00

api: allow update of variables "scroll_x" and "scroll_y" in bar_window with function hdata_update

This commit is contained in:
Sébastien Helleu
2017-06-08 06:53:32 +02:00
parent 111962c65a
commit e2589aaaca
8 changed files with 62 additions and 3 deletions
+43 -3
View File
@@ -30,6 +30,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hashtable.h"
#include "../core/wee-hdata.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
@@ -1519,6 +1520,45 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
}
}
/*
* Callback for updating data of a bar window.
*/
int
gui_bar_window_update_cb (void *data, struct t_hdata *hdata, void *pointer,
struct t_hashtable *hashtable)
{
const char *value;
int rc;
/* make C compiler happy */
(void) data;
rc = 0;
if (hashtable_has_key (hashtable, "scroll_x"))
{
value = hashtable_get (hashtable, "scroll_x");
if (value)
{
hdata_set (hdata, pointer, "scroll_x", value);
rc++;
}
}
if (hashtable_has_key (hashtable, "scroll_y"))
{
value = hashtable_get (hashtable, "scroll_y");
if (value)
{
hdata_set (hdata, pointer, "scroll_y", value);
rc++;
}
}
return rc;
}
/*
* Returns hdata for bar window.
*/
@@ -1534,7 +1574,7 @@ gui_bar_window_hdata_bar_window_cb (const void *pointer, void *data,
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_bar_window", "next_bar_window",
0, 0, NULL, NULL);
0, 0, &gui_bar_window_update_cb, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_bar_window, bar, POINTER, 0, NULL, "bar");
@@ -1542,8 +1582,8 @@ gui_bar_window_hdata_bar_window_cb (const void *pointer, void *data,
HDATA_VAR(struct t_gui_bar_window, y, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, width, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, height, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, scroll_x, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, scroll_y, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, scroll_x, INTEGER, 1, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, scroll_y, INTEGER, 1, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, cursor_x, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, cursor_y, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_window, current_size, INTEGER, 0, NULL, NULL);