Skip to content
Snippets Groups Projects
Commit b4c5dcad authored by George Joseph's avatar George Joseph
Browse files

menuselect: Various menuselect enhancements

* Add 'external' as a support level.
* Add ability for module directories to add entries to the menu
  by adding members to the <module_prefix>/<module_prefix>.xml file.
* Expand the description field to 3 lines in the ncurses implementation.
* Allow the description field to wrap in the newt implementation.
* Add description field to the gtk implementation.

Change-Id: I7f9600a1984a42ce0696db574c1051bc9ad7c808
parent 616446fe
No related branches found
No related tags found
No related merge requests found
...@@ -164,7 +164,7 @@ dist-clean:: ...@@ -164,7 +164,7 @@ dist-clean::
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $^ >> $@ $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $^ >> $@
echo "</member>" >> $@ echo "</member>" >> $@
.moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(sort $(ALL_C_MODS) $(ALL_CC_MODS)))) .moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(sort $(ALL_C_MODS) $(ALL_CC_MODS)))) $(wildcard $(call tolower,$(MENUSELECT_CATEGORY)).xml)
@echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\" remove_on_change=\"$(SUBDIR)/modules.link\">" > $@ @echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\" remove_on_change=\"$(SUBDIR)/modules.link\">" > $@
@cat $^ >> $@ @cat $^ >> $@
@echo "</category>" >> $@ @echo "</category>" >> $@
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
-include $(ASTTOPDIR)/makeopts -include $(ASTTOPDIR)/makeopts
# Helpful functions
# call with $(call function,...)
tolower = $(shell echo $(1) | tr '[:upper:]' '[:lower:]')
.PHONY: dist-clean .PHONY: dist-clean
# If 'make' decides to create intermediate files to satisfy a build requirement # If 'make' decides to create intermediate files to satisfy a build requirement
......
...@@ -246,6 +246,10 @@ static enum support_level_values string_to_support_level(const char *support_lev ...@@ -246,6 +246,10 @@ static enum support_level_values string_to_support_level(const char *support_lev
return SUPPORT_DEPRECATED; return SUPPORT_DEPRECATED;
} }
if (!strcasecmp(support_level, "external")) {
return SUPPORT_EXTERNAL;
}
return SUPPORT_UNSPECIFIED; return SUPPORT_UNSPECIFIED;
} }
...@@ -259,6 +263,8 @@ static const char *support_level_to_string(enum support_level_values support_lev ...@@ -259,6 +263,8 @@ static const char *support_level_to_string(enum support_level_values support_lev
return "Extended"; return "Extended";
case SUPPORT_DEPRECATED: case SUPPORT_DEPRECATED:
return "Deprecated"; return "Deprecated";
case SUPPORT_EXTERNAL:
return "External";
default: default:
return "Unspecified"; return "Unspecified";
} }
......
...@@ -105,7 +105,8 @@ enum support_level_values { ...@@ -105,7 +105,8 @@ enum support_level_values {
SUPPORT_EXTENDED = 1, SUPPORT_EXTENDED = 1,
SUPPORT_DEPRECATED = 2, SUPPORT_DEPRECATED = 2,
SUPPORT_UNSPECIFIED = 3, SUPPORT_UNSPECIFIED = 3,
SUPPORT_COUNT = 4, /* Keep this item at the end of the list. Tracks total number of support levels. */ SUPPORT_EXTERNAL = 4,
SUPPORT_COUNT = 5, /* Keep this item at the end of the list. Tracks total number of support levels. */
}; };
AST_LIST_HEAD_NOLOCK(support_level_bucket, member); AST_LIST_HEAD_NOLOCK(support_level_bucket, member);
......
...@@ -194,46 +194,49 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int ...@@ -194,46 +194,49 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
int start_x = (max_x / 2 - MEMBER_INFO_LEFT_ADJ); int start_x = (max_x / 2 - MEMBER_INFO_LEFT_ADJ);
int maxlen = (max_x - start_x); int maxlen = (max_x - start_x);
wmove(menu, end - start_y + 1, start_x); wmove(menu, end - start_y + 1, 0);
wclrtoeol(menu); wclrtoeol(menu);
wmove(menu, end - start_y + 2, start_x); wmove(menu, end - start_y + 2, 0);
wclrtoeol(menu); wclrtoeol(menu);
wmove(menu, end - start_y + 3, start_x); wmove(menu, end - start_y + 3, 0);
wclrtoeol(menu); wclrtoeol(menu);
wmove(menu, end - start_y + 4, start_x); wmove(menu, end - start_y + 4, 0);
wclrtoeol(menu); wclrtoeol(menu);
wmove(menu, end - start_y + 5, start_x); wmove(menu, end - start_y + 5, 0);
wclrtoeol(menu); wclrtoeol(menu);
wmove(menu, end - start_y + 6, start_x); wmove(menu, end - start_y + 6, 0);
wclrtoeol(menu);
wmove(menu, end - start_y + 7, 0);
wclrtoeol(menu); wclrtoeol(menu);
if (mem->displayname) { if (mem->displayname) {
int name_len = strlen(mem->displayname); char buf[maxlen + 1];
char *displayname = strdupa(mem->displayname);
char *word;
int current_line = 1;
int new_line = 1;
buf[0] = '\0';
wmove(menu, end - start_y + 1, start_x); wmove(menu, end - start_y + 1, start_x);
if (name_len > maxlen) {
char *last_space; while ((word = strsep(&displayname, " "))) {
char *line_1 = strdup(mem->displayname); if ((strlen(buf) + strlen(word) + 1) > maxlen) {
waddstr(menu, buf);
if (line_1) { current_line++;
line_1[maxlen] = '\0'; wmove(menu, end - start_y + current_line, start_x);
last_space = strrchr(line_1, ' '); buf[0] = '\0';
if (last_space) { new_line = 1;
*last_space = '\0';
}
waddstr(menu, line_1);
wmove(menu, end - start_y + 2, start_x);
waddstr(menu, &mem->displayname[last_space - line_1]);
free(line_1);
} else {
waddstr(menu, (char *) mem->displayname);
} }
} else { sprintf(buf, "%s%*.*s%s", buf, new_line ? 0 : 1, new_line ? 0 : 1, " ", word);
waddstr(menu, (char *) mem->displayname); new_line = 0;
}
if (strlen(buf)) {
waddstr(menu, buf);
} }
} }
if (!AST_LIST_EMPTY(&mem->deps)) { if (!AST_LIST_EMPTY(&mem->deps)) {
wmove(menu, end - start_y + 3, start_x); wmove(menu, end - start_y + 4, start_x);
strcpy(buf, "Depends on: "); strcpy(buf, "Depends on: ");
AST_LIST_TRAVERSE(&mem->deps, dep, list) { AST_LIST_TRAVERSE(&mem->deps, dep, list) {
strncat(buf, dep->displayname, sizeof(buf) - strlen(buf) - 1); strncat(buf, dep->displayname, sizeof(buf) - strlen(buf) - 1);
...@@ -244,7 +247,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int ...@@ -244,7 +247,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
waddstr(menu, buf); waddstr(menu, buf);
} }
if (!AST_LIST_EMPTY(&mem->uses)) { if (!AST_LIST_EMPTY(&mem->uses)) {
wmove(menu, end - start_y + 4, start_x); wmove(menu, end - start_y + 5, start_x);
strcpy(buf, "Can use: "); strcpy(buf, "Can use: ");
AST_LIST_TRAVERSE(&mem->uses, use, list) { AST_LIST_TRAVERSE(&mem->uses, use, list) {
strncat(buf, use->displayname, sizeof(buf) - strlen(buf) - 1); strncat(buf, use->displayname, sizeof(buf) - strlen(buf) - 1);
...@@ -255,7 +258,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int ...@@ -255,7 +258,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
waddstr(menu, buf); waddstr(menu, buf);
} }
if (!AST_LIST_EMPTY(&mem->conflicts)) { if (!AST_LIST_EMPTY(&mem->conflicts)) {
wmove(menu, end - start_y + 5, start_x); wmove(menu, end - start_y + 6, start_x);
strcpy(buf, "Conflicts with: "); strcpy(buf, "Conflicts with: ");
AST_LIST_TRAVERSE(&mem->conflicts, con, list) { AST_LIST_TRAVERSE(&mem->conflicts, con, list) {
strncat(buf, con->displayname, sizeof(buf) - strlen(buf) - 1); strncat(buf, con->displayname, sizeof(buf) - strlen(buf) - 1);
...@@ -268,7 +271,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int ...@@ -268,7 +271,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
if (!mem->is_separator) { /* Separators lack support levels */ if (!mem->is_separator) { /* Separators lack support levels */
{ /* support level */ { /* support level */
wmove(menu, end - start_y + 6, start_x); wmove(menu, end - start_y + 7, start_x);
snprintf(buf, sizeof(buf), "Support Level: %s", mem->support_level); snprintf(buf, sizeof(buf), "Support Level: %s", mem->support_level);
if (mem->replacement && *mem->replacement) { if (mem->replacement && *mem->replacement) {
char buf2[64]; char buf2[64];
......
...@@ -16,6 +16,8 @@ enum { ...@@ -16,6 +16,8 @@ enum {
COLUMN_USES, COLUMN_USES,
/*! Conflicts */ /*! Conflicts */
COLUMN_CNFS, COLUMN_CNFS,
/*! Description */
COLUMN_DESC,
/*! Number of columns, must be the last element in the enum */ /*! Number of columns, must be the last element in the enum */
NUM_COLUMNS, NUM_COLUMNS,
}; };
...@@ -254,7 +256,8 @@ int run_menu(void) ...@@ -254,7 +256,8 @@ int run_menu(void)
G_TYPE_BOOLEAN, /* COLUMN_SELECTED */ G_TYPE_BOOLEAN, /* COLUMN_SELECTED */
G_TYPE_STRING, /* COLUMN_DEPS */ G_TYPE_STRING, /* COLUMN_DEPS */
G_TYPE_STRING, /* COLUMN_USES */ G_TYPE_STRING, /* COLUMN_USES */
G_TYPE_STRING); /* COLUMN_CNFS */ G_TYPE_STRING, /* COLUMN_CNFS */
G_TYPE_STRING); /* COLUMN_DESC */
AST_LIST_TRAVERSE(&categories, cat, list) { AST_LIST_TRAVERSE(&categories, cat, list) {
GtkTreeIter iter, iter2; GtkTreeIter iter, iter2;
...@@ -307,6 +310,7 @@ int run_menu(void) ...@@ -307,6 +310,7 @@ int run_menu(void)
COLUMN_DEPS, dep_buf, COLUMN_DEPS, dep_buf,
COLUMN_USES, use_buf, COLUMN_USES, use_buf,
COLUMN_CNFS, cnf_buf, COLUMN_CNFS, cnf_buf,
COLUMN_DESC, mem->displayname,
-1); -1);
} }
} }
...@@ -344,6 +348,11 @@ int run_menu(void) ...@@ -344,6 +348,11 @@ int run_menu(void)
renderer, "text", COLUMN_CNFS, NULL); renderer, "text", COLUMN_CNFS, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Description",
renderer, "text", COLUMN_DESC, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
g_signal_connect(tree, "row-activated", (GCallback) row_activated_handler, store); g_signal_connect(tree, "row-activated", (GCallback) row_activated_handler, store);
gtk_container_add(GTK_CONTAINER(s_window), GTK_WIDGET(tree)); gtk_container_add(GTK_CONTAINER(s_window), GTK_WIDGET(tree));
......
...@@ -326,7 +326,7 @@ int run_menu(void) ...@@ -326,7 +326,7 @@ int run_menu(void)
newtFormAddComponent(form, subOptions); newtFormAddComponent(form, subOptions);
newtComponentAddCallback(subOptions, category_menu_callback, NULL); newtComponentAddCallback(subOptions, category_menu_callback, NULL);
memberNameTextbox = newtTextbox(2, y - 13, x - 10, 1, 0); memberNameTextbox = newtTextbox(2, y - 13, x - 10, 2, NEWT_FLAG_WRAP);
dependsLabel = newtLabel(2, y - 11, " Depends on:"); dependsLabel = newtLabel(2, y - 11, " Depends on:");
usesLabel = newtLabel(2, y - 10, " Can use:"); usesLabel = newtLabel(2, y - 10, " Can use:");
conflictsLabel = newtLabel(2, y - 9, "Conflicts with:"); conflictsLabel = newtLabel(2, y - 9, "Conflicts with:");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment