Actions now a vector.

This commit is contained in:
2026-01-10 12:28:16 -05:00
parent a30ae02d09
commit ef0db740c1
3 changed files with 9 additions and 16 deletions
+3 -5
View File
@@ -14,7 +14,7 @@
#include "../dlib/dlib.hh"
#include <errno.h>
static Dlist *link_actions = NULL;
static std::vector< Action * > link_actions;
void
action_parse(char *line)
@@ -41,7 +41,7 @@ action_parse(char *line)
action->label = dStrdup(label);
action->cmd = dStrdup(cmd);
dList_append(link_actions, action);
link_actions.push_back( action );
}
void
@@ -49,8 +49,6 @@ a_Actions_init(void)
{
int n = dList_length(prefs.link_actions);
link_actions = dList_new(n);
for (int i = 0; i < n; i++) {
char *line = reinterpret_cast< char * >( dList_nth_data(prefs.link_actions, i) );
if (line)
@@ -58,7 +56,7 @@ a_Actions_init(void)
}
}
Dlist *
const std::vector< Action * > &
a_Actions_link_get(void)
{
return link_actions;
+3 -8
View File
@@ -12,11 +12,9 @@
#ifndef ACTIONS_H
#define ACTIONS_H
#include "dlib/dlib.hh"
#include <vector>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "dlib/dlib.hh"
typedef struct {
char *label;
@@ -24,9 +22,6 @@ typedef struct {
} Action;
void a_Actions_init(void);
Dlist *a_Actions_link_get(void);
const std::vector< Action * > &a_Actions_link_get();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ACTIONS_H*/
+3 -3
View File
@@ -492,8 +492,8 @@ static Fl_Menu_Item *get_link_menu(void)
if (link_menu != NULL)
return link_menu;
Dlist *actions = a_Actions_link_get();
int nactions = dList_length(actions);
const auto &actions = a_Actions_link_get();
int nactions = actions.size();
/* Count static menu entries */
int nstatic = 0;
@@ -511,7 +511,7 @@ static Fl_Menu_Item *get_link_menu(void)
/* And append the dynamic ones */
for (int i = 0; i < nactions; i++) {
Action *action = (Action *) dList_nth_data(actions, i);
Action *action = actions.at( i );
struct link_menu_item *mitem = &link_menu_item[i];
mitem->url = NULL; /* Not known yet */
mitem->action = action;