mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
achown: add callback for permission buttons
...to change behaviour of WButton objects. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
4b0edd90cf
commit
48d85a42b4
@ -50,10 +50,16 @@
|
|||||||
|
|
||||||
/*** file scope variables ************************************************************************/
|
/*** file scope variables ************************************************************************/
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static cb_ret_t
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
/*** public functions ****************************************************************************/
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
cb_ret_t
|
||||||
|
button_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||||
{
|
{
|
||||||
WButton *b = BUTTON (w);
|
WButton *b = BUTTON (w);
|
||||||
WDialog *h = w->owner;
|
WDialog *h = w->owner;
|
||||||
@ -173,8 +179,8 @@ button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
void
|
||||||
button_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
button_mouse_default_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||||
{
|
{
|
||||||
(void) event;
|
(void) event;
|
||||||
|
|
||||||
@ -194,8 +200,6 @@ button_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
/*** public functions ****************************************************************************/
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
WButton *
|
WButton *
|
||||||
@ -210,7 +214,8 @@ button_new (int y, int x, int action, button_flags_t flags, const char *text, bc
|
|||||||
b->action = action;
|
b->action = action;
|
||||||
b->flags = flags;
|
b->flags = flags;
|
||||||
b->text = parse_hotkey (text);
|
b->text = parse_hotkey (text);
|
||||||
widget_init (w, y, x, 1, button_get_len (b), button_callback, button_mouse_callback);
|
widget_init (w, y, x, 1, button_get_len (b), button_default_callback,
|
||||||
|
button_mouse_default_callback);
|
||||||
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR | WOP_WANT_HOTKEY;
|
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR | WOP_WANT_HOTKEY;
|
||||||
b->callback = callback;
|
b->callback = callback;
|
||||||
b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;
|
b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;
|
||||||
|
@ -49,6 +49,10 @@ char *button_get_text (const WButton * b);
|
|||||||
void button_set_text (WButton * b, const char *text);
|
void button_set_text (WButton * b, const char *text);
|
||||||
int button_get_len (const WButton * b);
|
int button_get_len (const WButton * b);
|
||||||
|
|
||||||
|
cb_ret_t button_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||||
|
void *data);
|
||||||
|
void button_mouse_default_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
#endif /* MC__WIDGET_BUTTON_H */
|
#endif /* MC__WIDGET_BUTTON_H */
|
||||||
|
@ -340,6 +340,44 @@ b_setpos (int f_pos)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static cb_ret_t
|
||||||
|
perm_button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||||
|
{
|
||||||
|
return button_default_callback (w, sender, msg, parm, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
perm_button_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||||
|
{
|
||||||
|
button_mouse_default_callback (w, msg, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static WButton *
|
||||||
|
perm_button_new (int y, int x, int action, button_flags_t flags, const char *text,
|
||||||
|
bcback_fn callback)
|
||||||
|
{
|
||||||
|
WButton *b;
|
||||||
|
Widget *w;
|
||||||
|
|
||||||
|
/* create base button using native API */
|
||||||
|
b = button_new (y, x, action, flags, text, callback);
|
||||||
|
w = WIDGET (b);
|
||||||
|
|
||||||
|
/* we don't want HOTKEY */
|
||||||
|
widget_want_hotkey (w, FALSE);
|
||||||
|
|
||||||
|
w->callback = perm_button_callback;
|
||||||
|
w->mouse_callback = perm_button_mouse_callback;
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static cb_ret_t
|
static cb_ret_t
|
||||||
chl_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
chl_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||||
{
|
{
|
||||||
@ -709,11 +747,11 @@ advanced_chown_init (void)
|
|||||||
#define XTRACT(i,y,cb) y, BX+advanced_chown_but[i].x, \
|
#define XTRACT(i,y,cb) y, BX+advanced_chown_but[i].x, \
|
||||||
advanced_chown_but[i].ret_cmd, advanced_chown_but[i].flags, \
|
advanced_chown_but[i].ret_cmd, advanced_chown_but[i].flags, \
|
||||||
(advanced_chown_but[i].text), cb
|
(advanced_chown_but[i].text), cb
|
||||||
b_att[0] = button_new (XTRACT (0, BY, NULL));
|
b_att[0] = perm_button_new (XTRACT (0, BY, NULL));
|
||||||
advanced_chown_but[0].id = add_widget (ch_dlg, b_att[0]);
|
advanced_chown_but[0].id = add_widget (ch_dlg, b_att[0]);
|
||||||
b_att[1] = button_new (XTRACT (1, BY, NULL));
|
b_att[1] = perm_button_new (XTRACT (1, BY, NULL));
|
||||||
advanced_chown_but[1].id = add_widget (ch_dlg, b_att[1]);
|
advanced_chown_but[1].id = add_widget (ch_dlg, b_att[1]);
|
||||||
b_att[2] = button_new (XTRACT (2, BY, NULL));
|
b_att[2] = perm_button_new (XTRACT (2, BY, NULL));
|
||||||
advanced_chown_but[2].id = add_widget (ch_dlg, b_att[2]);
|
advanced_chown_but[2].id = add_widget (ch_dlg, b_att[2]);
|
||||||
b_user = button_new (XTRACT (3, BY, user_group_button_cb));
|
b_user = button_new (XTRACT (3, BY, user_group_button_cb));
|
||||||
advanced_chown_but[3].id = add_widget (ch_dlg, b_user);
|
advanced_chown_but[3].id = add_widget (ch_dlg, b_user);
|
||||||
|
Loading…
Reference in New Issue
Block a user