mirror of
https://github.com/MidnightCommander/mc
synced 2025-04-02 13:12:53 +03:00
Ticket #2608: widget enhancements.
New method of widget ID assignment: now widget ID is a value of unsigned long type. Dlg_head structure now has new filed widget_id that contains a ID of the next added widget. When new widget is added into dialog, widget_id is set as ID of it and then incremented. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
8fe49bb599
commit
c3f359c82b
@ -849,7 +849,7 @@ add_widget_autopos (Dlg_head * h, void *w, widget_pos_flags_t pos_flags)
|
||||
widget->y += h->y;
|
||||
widget->owner = h;
|
||||
widget->pos_flags = pos_flags;
|
||||
widget->id = g_list_length (h->widgets);
|
||||
widget->id = h->widget_id++;
|
||||
|
||||
if ((h->flags & DLG_REVERSE) != 0)
|
||||
h->widgets = g_list_prepend (h->widgets, widget);
|
||||
@ -954,7 +954,7 @@ find_widget_type (const Dlg_head * h, callback_fn callback)
|
||||
/** Find the widget with the given id */
|
||||
|
||||
Widget *
|
||||
dlg_find_by_id (const Dlg_head * h, unsigned int id)
|
||||
dlg_find_by_id (const Dlg_head * h, unsigned long id)
|
||||
{
|
||||
GList *w;
|
||||
|
||||
@ -966,7 +966,7 @@ dlg_find_by_id (const Dlg_head * h, unsigned int id)
|
||||
/** Find the widget with the given id in the dialog h and select it */
|
||||
|
||||
void
|
||||
dlg_select_by_id (const Dlg_head * h, unsigned int id)
|
||||
dlg_select_by_id (const Dlg_head * h, unsigned long id)
|
||||
{
|
||||
Widget *w;
|
||||
|
||||
|
@ -122,6 +122,7 @@ struct Dlg_head
|
||||
/* Internal variables */
|
||||
GList *widgets; /* widgets list */
|
||||
GList *current; /* Curently active widget */
|
||||
unsigned long widget_id; /* maximum id of all widgets */
|
||||
void *data; /* Data can be passed to dialog */
|
||||
char *event_group; /* Name of event group for this dialog */
|
||||
|
||||
@ -201,8 +202,8 @@ void dlg_one_up (Dlg_head * h);
|
||||
void dlg_one_down (Dlg_head * h);
|
||||
int dlg_focus (Dlg_head * h);
|
||||
Widget *find_widget_type (const Dlg_head * h, callback_fn callback);
|
||||
Widget *dlg_find_by_id (const Dlg_head * h, unsigned int id);
|
||||
void dlg_select_by_id (const Dlg_head * h, unsigned int id);
|
||||
Widget *dlg_find_by_id (const Dlg_head * h, unsigned long id);
|
||||
void dlg_select_by_id (const Dlg_head * h, unsigned long id);
|
||||
|
||||
/* Redraw all dialogs */
|
||||
void do_refresh (void);
|
||||
@ -220,8 +221,9 @@ dlg_widget_active (void *w)
|
||||
return ((Widget *) w1->owner->current->data == w1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline unsigned int
|
||||
static inline unsigned long
|
||||
dlg_get_current_widget_id (const struct Dlg_head *h)
|
||||
{
|
||||
return ((Widget *) h->current->data)->id;
|
||||
|
@ -46,7 +46,7 @@ typedef struct WMenuBar
|
||||
gboolean is_dropped; /* If the menubar has dropped */
|
||||
GList *menu; /* The actual menus */
|
||||
size_t selected; /* Selected menu on the top bar */
|
||||
int previous_widget; /* Selected widget ID before activating menu */
|
||||
unsigned long previous_widget; /* Selected widget ID before activating menu */
|
||||
} WMenuBar;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user