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 "../dlib/dlib.hh"
#include <errno.h> #include <errno.h>
static Dlist *link_actions = NULL; static std::vector< Action * > link_actions;
void void
action_parse(char *line) action_parse(char *line)
@@ -41,7 +41,7 @@ action_parse(char *line)
action->label = dStrdup(label); action->label = dStrdup(label);
action->cmd = dStrdup(cmd); action->cmd = dStrdup(cmd);
dList_append(link_actions, action); link_actions.push_back( action );
} }
void void
@@ -49,8 +49,6 @@ a_Actions_init(void)
{ {
int n = dList_length(prefs.link_actions); int n = dList_length(prefs.link_actions);
link_actions = dList_new(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
char *line = reinterpret_cast< char * >( dList_nth_data(prefs.link_actions, i) ); char *line = reinterpret_cast< char * >( dList_nth_data(prefs.link_actions, i) );
if (line) if (line)
@@ -58,7 +56,7 @@ a_Actions_init(void)
} }
} }
Dlist * const std::vector< Action * > &
a_Actions_link_get(void) a_Actions_link_get(void)
{ {
return link_actions; return link_actions;
+3 -8
View File
@@ -12,11 +12,9 @@
#ifndef ACTIONS_H #ifndef ACTIONS_H
#define ACTIONS_H #define ACTIONS_H
#include "dlib/dlib.hh" #include <vector>
#ifdef __cplusplus #include "dlib/dlib.hh"
extern "C" {
#endif /* __cplusplus */
typedef struct { typedef struct {
char *label; char *label;
@@ -24,9 +22,6 @@ typedef struct {
} Action; } Action;
void a_Actions_init(void); 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*/ #endif /* ACTIONS_H*/
+3 -3
View File
@@ -492,8 +492,8 @@ static Fl_Menu_Item *get_link_menu(void)
if (link_menu != NULL) if (link_menu != NULL)
return link_menu; return link_menu;
Dlist *actions = a_Actions_link_get(); const auto &actions = a_Actions_link_get();
int nactions = dList_length(actions); int nactions = actions.size();
/* Count static menu entries */ /* Count static menu entries */
int nstatic = 0; int nstatic = 0;
@@ -511,7 +511,7 @@ static Fl_Menu_Item *get_link_menu(void)
/* And append the dynamic ones */ /* And append the dynamic ones */
for (int i = 0; i < nactions; i++) { 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]; struct link_menu_item *mitem = &link_menu_item[i];
mitem->url = NULL; /* Not known yet */ mitem->url = NULL; /* Not known yet */
mitem->action = action; mitem->action = action;