Commit 30e61a48 authored by Roman Zippel's avatar Roman Zippel Committed by Ben Collins

[PATCH] Change P_ROOTMENU into a MENU_ROOT flag

This changes P_ROOTMENU into a MENU_ROOT flag and also fixes some qconf
usability problems.

Some gconf fixes by Romain Lievin <roms@tilp.info>.
parent a900d0f6
...@@ -97,7 +97,7 @@ struct symbol { ...@@ -97,7 +97,7 @@ struct symbol {
#define SYMBOL_HASHMASK 0xff #define SYMBOL_HASHMASK 0xff
enum prop_type { enum prop_type {
P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_ROOTMENU, P_DEFAULT, P_CHOICE P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE
}; };
struct property { struct property {
...@@ -137,6 +137,7 @@ struct menu { ...@@ -137,6 +137,7 @@ struct menu {
}; };
#define MENU_CHANGED 0x0001 #define MENU_CHANGED 0x0001
#define MENU_ROOT 0x0002
#ifndef SWIG #ifndef SWIG
......
...@@ -164,8 +164,6 @@ const char *dbg_print_ptype(int val) ...@@ -164,8 +164,6 @@ const char *dbg_print_ptype(int val)
strcpy(buf, "comment"); strcpy(buf, "comment");
if (val == P_MENU) if (val == P_MENU)
strcpy(buf, "menu"); strcpy(buf, "menu");
if (val == P_ROOTMENU)
strcpy(buf, "rootmenu");
if (val == P_DEFAULT) if (val == P_DEFAULT)
strcpy(buf, "default"); strcpy(buf, "default");
if (val == P_CHOICE) if (val == P_CHOICE)
...@@ -798,7 +796,7 @@ void on_back_pressed(GtkButton * button, gpointer user_data) ...@@ -798,7 +796,7 @@ void on_back_pressed(GtkButton * button, gpointer user_data)
current = current->parent; current = current->parent;
ptype = current->prompt ? current->prompt->type : P_UNKNOWN; ptype = current->prompt ? current->prompt->type : P_UNKNOWN;
if ((ptype != P_ROOTMENU) && (ptype != P_MENU)) if (ptype != P_MENU)
current = current->parent; current = current->parent;
display_tree_part(); display_tree_part();
...@@ -836,6 +834,8 @@ void on_split_clicked(GtkButton * button, gpointer user_data) ...@@ -836,6 +834,8 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
gtk_widget_show(tree1_w); gtk_widget_show(tree1_w);
gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h); gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
gtk_paned_set_position(GTK_PANED(hpaned), w / 2); gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
if (tree2)
gtk_tree_store_clear(tree2);
display_list(); display_list();
} }
...@@ -922,8 +922,10 @@ static void change_sym_value(struct menu *menu, gint col) ...@@ -922,8 +922,10 @@ static void change_sym_value(struct menu *menu, gint col)
config_changed = TRUE; config_changed = TRUE;
if (view_mode == FULL_VIEW) if (view_mode == FULL_VIEW)
update_tree(&rootmenu, NULL); update_tree(&rootmenu, NULL);
else if (view_mode == SPLIT_VIEW) else if (view_mode == SPLIT_VIEW) {
update_tree(current, NULL); update_tree(current, NULL);
display_list();
}
else if (view_mode == SINGLE_VIEW) else if (view_mode == SINGLE_VIEW)
display_tree_part(); //fixme: keep exp/coll display_tree_part(); //fixme: keep exp/coll
break; break;
...@@ -949,8 +951,10 @@ static void toggle_sym_value(struct menu *menu) ...@@ -949,8 +951,10 @@ static void toggle_sym_value(struct menu *menu)
sym_set_tristate_value(menu->sym, newval); sym_set_tristate_value(menu->sym, newval);
if (view_mode == FULL_VIEW) if (view_mode == FULL_VIEW)
update_tree(&rootmenu, NULL); update_tree(&rootmenu, NULL);
else if (view_mode == SPLIT_VIEW) else if (view_mode == SPLIT_VIEW) {
update_tree(current, NULL); update_tree(current, NULL);
display_list();
}
else if (view_mode == SINGLE_VIEW) else if (view_mode == SINGLE_VIEW)
display_tree_part(); //fixme: keep exp/coll display_tree_part(); //fixme: keep exp/coll
} }
...@@ -1035,8 +1039,7 @@ on_treeview2_button_press_event(GtkWidget * widget, ...@@ -1035,8 +1039,7 @@ on_treeview2_button_press_event(GtkWidget * widget,
enum prop_type ptype; enum prop_type ptype;
ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
if (((ptype == P_MENU) || (ptype == P_ROOTMENU)) && if (ptype == P_MENU && view_mode != FULL_VIEW && col == COL_OPTION) {
(view_mode == SINGLE_VIEW) && (col == COL_OPTION)) {
// goes down into menu // goes down into menu
current = menu; current = menu;
display_tree_part(); display_tree_part();
...@@ -1192,7 +1195,6 @@ static gchar **fill_row(struct menu *menu) ...@@ -1192,7 +1195,6 @@ static gchar **fill_row(struct menu *menu)
ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
switch (ptype) { switch (ptype) {
case P_MENU: case P_MENU:
case P_ROOTMENU:
row[COL_PIXBUF] = (gchar *) xpm_menu; row[COL_PIXBUF] = (gchar *) xpm_menu;
if (view_mode != FULL_VIEW) if (view_mode != FULL_VIEW)
row[COL_PIXVIS] = GINT_TO_POINTER(TRUE); row[COL_PIXVIS] = GINT_TO_POINTER(TRUE);
...@@ -1477,11 +1479,11 @@ static void display_tree(struct menu *menu) ...@@ -1477,11 +1479,11 @@ static void display_tree(struct menu *menu)
if (sym) if (sym)
sym->flags &= ~SYMBOL_CHANGED; sym->flags &= ~SYMBOL_CHANGED;
if ((view_mode == SPLIT_VIEW) && (ptype != P_ROOTMENU) && if ((view_mode == SPLIT_VIEW) && !(child->flags & MENU_ROOT) &&
(tree == tree1)) (tree == tree1))
continue; continue;
if ((view_mode == SPLIT_VIEW) && (ptype == P_ROOTMENU) && if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT) &&
(tree == tree2)) (tree == tree2))
continue; continue;
...@@ -1503,7 +1505,7 @@ static void display_tree(struct menu *menu) ...@@ -1503,7 +1505,7 @@ static void display_tree(struct menu *menu)
&& (tree == tree2)) && (tree == tree2))
continue; continue;
if (((menu != &rootmenu) && (ptype != P_ROOTMENU)) || if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) ||
(view_mode == FULL_VIEW) (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW)) { || (view_mode == SPLIT_VIEW)) {
indent++; indent++;
...@@ -1525,8 +1527,6 @@ static void display_tree_part(void) ...@@ -1525,8 +1527,6 @@ static void display_tree_part(void)
/* Display the list in the left frame (split view) */ /* Display the list in the left frame (split view) */
static void display_list(void) static void display_list(void)
{ {
if (tree2)
gtk_tree_store_clear(tree2);
if (tree1) if (tree1)
gtk_tree_store_clear(tree1); gtk_tree_store_clear(tree1);
...@@ -1542,7 +1542,7 @@ static void fixup_rootmenu(struct menu *menu) ...@@ -1542,7 +1542,7 @@ static void fixup_rootmenu(struct menu *menu)
if (!menu->prompt || menu->prompt->type != P_MENU) if (!menu->prompt || menu->prompt->type != P_MENU)
return; return;
menu->prompt->type = P_ROOTMENU; menu->flags |= MENU_ROOT;
for (child = menu->list; child; child = child->next) for (child = menu->list; child; child = child->next)
fixup_rootmenu(child); fixup_rootmenu(child);
} }
......
...@@ -283,7 +283,7 @@ struct menu *menu_get_parent_menu(struct menu *menu) ...@@ -283,7 +283,7 @@ struct menu *menu_get_parent_menu(struct menu *menu)
for (; menu != &rootmenu; menu = menu->parent) { for (; menu != &rootmenu; menu = menu->parent) {
type = menu->prompt ? menu->prompt->type : 0; type = menu->prompt ? menu->prompt->type : 0;
if (type == P_MENU || type == P_ROOTMENU) if (type == P_MENU)
break; break;
} }
return menu; return menu;
......
...@@ -65,11 +65,11 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) ...@@ -65,11 +65,11 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
switch (mode) { switch (mode) {
case menuMode: case menuMode:
if (type != P_ROOTMENU) if (!(child->flags & MENU_ROOT))
goto hide; goto hide;
break; break;
case symbolMode: case symbolMode:
if (type == P_ROOTMENU) if (child->flags & MENU_ROOT)
goto hide; goto hide;
break; break;
default: default:
...@@ -83,8 +83,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) ...@@ -83,8 +83,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
else else
item->testUpdateMenu(visible); item->testUpdateMenu(visible);
if (mode == fullMode || mode == menuMode || if (mode == fullMode || mode == menuMode || type != P_MENU)
(type != P_MENU && type != P_ROOTMENU))
updateMenuList(item, child); updateMenuList(item, child);
else else
updateMenuList(item, 0); updateMenuList(item, 0);
...@@ -140,7 +139,6 @@ void ConfigItem::updateMenu(void) ...@@ -140,7 +139,6 @@ void ConfigItem::updateMenu(void)
if (prop) switch (prop->type) { if (prop) switch (prop->type) {
case P_MENU: case P_MENU:
case P_ROOTMENU:
if (list->mode == singleMode || list->mode == symbolMode) { if (list->mode == singleMode || list->mode == symbolMode) {
/* a menuconfig entry is displayed differently /* a menuconfig entry is displayed differently
* depending whether it's at the view root or a child. * depending whether it's at the view root or a child.
...@@ -172,6 +170,7 @@ void ConfigItem::updateMenu(void) ...@@ -172,6 +170,7 @@ void ConfigItem::updateMenu(void)
char ch; char ch;
if (!sym_is_changable(sym) && !list->showAll) { if (!sym_is_changable(sym) && !list->showAll) {
setPixmap(promptColIdx, 0);
setText(noColIdx, 0); setText(noColIdx, 0);
setText(modColIdx, 0); setText(modColIdx, 0);
setText(yesColIdx, 0); setText(yesColIdx, 0);
...@@ -288,7 +287,7 @@ void ConfigItem::init(void) ...@@ -288,7 +287,7 @@ void ConfigItem::init(void)
ConfigItem::~ConfigItem(void) ConfigItem::~ConfigItem(void)
{ {
if (menu) { if (menu) {
ConfigItem** ip = &(ConfigItem*)menu->data; ConfigItem** ip = (ConfigItem**)&menu->data;
for (; *ip; ip = &(*ip)->nextItem) { for (; *ip; ip = &(*ip)->nextItem) {
if (*ip == this) { if (*ip == this) {
*ip = nextItem; *ip = nextItem;
...@@ -333,7 +332,7 @@ ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) ...@@ -333,7 +332,7 @@ ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv)
updateAll(false), updateAll(false),
symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
showAll(false), showName(false), showRange(false), showData(false), showAll(false), showName(false), showRange(false), showData(false),
rootEntry(0) rootEntry(0)
{ {
...@@ -392,7 +391,7 @@ void ConfigList::updateSelection(void) ...@@ -392,7 +391,7 @@ void ConfigList::updateSelection(void)
if (!menu) if (!menu)
return; return;
type = menu->prompt ? menu->prompt->type : P_UNKNOWN; type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
if (mode == menuMode && (type == P_MENU || type == P_ROOTMENU)) if (mode == menuMode && type == P_MENU)
emit menuSelected(menu); emit menuSelected(menu);
} }
...@@ -403,7 +402,8 @@ void ConfigList::updateList(ConfigItem* item) ...@@ -403,7 +402,8 @@ void ConfigList::updateList(ConfigItem* item)
if (!rootEntry) if (!rootEntry)
goto update; goto update;
if ((mode == singleMode || mode == symbolMode) && rootEntry != &rootmenu) { if (rootEntry != &rootmenu && (mode == singleMode ||
(mode == symbolMode && rootEntry->parent != &rootmenu))) {
item = firstChild(); item = firstChild();
if (!item) if (!item)
item = new ConfigItem(this, 0, true); item = new ConfigItem(this, 0, true);
...@@ -507,7 +507,7 @@ void ConfigList::setRootMenu(struct menu *menu) ...@@ -507,7 +507,7 @@ void ConfigList::setRootMenu(struct menu *menu)
if (rootEntry == menu) if (rootEntry == menu)
return; return;
type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
if (type != P_MENU && type != P_ROOTMENU) if (type != P_MENU)
return; return;
updateMenuList(this, 0); updateMenuList(this, 0);
rootEntry = menu; rootEntry = menu;
...@@ -518,13 +518,12 @@ void ConfigList::setRootMenu(struct menu *menu) ...@@ -518,13 +518,12 @@ void ConfigList::setRootMenu(struct menu *menu)
void ConfigList::setParentMenu(void) void ConfigList::setParentMenu(void)
{ {
ConfigItem* item; ConfigItem* item;
struct menu *oldroot, *newroot; struct menu *oldroot;
oldroot = rootEntry; oldroot = rootEntry;
newroot = menu_get_parent_menu(oldroot); if (rootEntry == &rootmenu)
if (newroot == oldroot)
return; return;
setRootMenu(newroot); setRootMenu(menu_get_parent_menu(rootEntry->parent));
QListViewItemIterator it(this); QListViewItemIterator it(this);
for (; (item = (ConfigItem*)it.current()); it++) { for (; (item = (ConfigItem*)it.current()); it++) {
...@@ -566,7 +565,8 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) ...@@ -566,7 +565,8 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
if (!menu) if (!menu)
break; break;
type = menu->prompt ? menu->prompt->type : P_UNKNOWN; type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
if ((type == P_MENU || type == P_ROOTMENU) && mode != fullMode) { if (type == P_MENU && rootEntry != menu &&
mode != fullMode && mode != menuMode) {
emit menuSelected(menu); emit menuSelected(menu);
break; break;
} }
...@@ -601,6 +601,7 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) ...@@ -601,6 +601,7 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
QPoint p(contentsToViewport(e->pos())); QPoint p(contentsToViewport(e->pos()));
ConfigItem* item = (ConfigItem*)itemAt(p); ConfigItem* item = (ConfigItem*)itemAt(p);
struct menu *menu; struct menu *menu;
enum prop_type ptype;
const QPixmap* pm; const QPixmap* pm;
int idx, x; int idx, x;
...@@ -617,14 +618,17 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) ...@@ -617,14 +618,17 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
int off = header()->sectionPos(0) + itemMargin() + int off = header()->sectionPos(0) + itemMargin() +
treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));
if (x >= off && x < off + pm->width()) { if (x >= off && x < off + pm->width()) {
if (item->goParent) if (item->goParent) {
emit parentSelected(); emit parentSelected();
else if (!menu)
break; break;
else if (menu->sym) } else if (!menu)
changeValue(item); break;
else ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
if (ptype == P_MENU && rootEntry != menu &&
mode != fullMode && mode != menuMode)
emit menuSelected(menu); emit menuSelected(menu);
else
changeValue(item);
} }
} }
break; break;
...@@ -671,8 +675,7 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) ...@@ -671,8 +675,7 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
if (!menu) if (!menu)
goto skip; goto skip;
ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
if ((ptype == P_ROOTMENU || ptype == P_MENU) && if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))
(mode == singleMode || mode == symbolMode))
emit menuSelected(menu); emit menuSelected(menu);
else if (menu->sym) else if (menu->sym)
changeValue(item); changeValue(item);
...@@ -880,7 +883,6 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -880,7 +883,6 @@ ConfigMainWindow::ConfigMainWindow(void)
connect(menuList, SIGNAL(gotFocus(void)), connect(menuList, SIGNAL(gotFocus(void)),
SLOT(listFocusChanged(void))); SLOT(listFocusChanged(void)));
//showFullView();
showSplitView(); showSplitView();
} }
...@@ -1133,6 +1135,8 @@ void ConfigMainWindow::setShowName(bool b) ...@@ -1133,6 +1135,8 @@ void ConfigMainWindow::setShowName(bool b)
return; return;
configList->showName = b; configList->showName = b;
configList->reinit(); configList->reinit();
menuList->showName = b;
menuList->reinit();
} }
void ConfigMainWindow::setShowRange(bool b) void ConfigMainWindow::setShowRange(bool b)
...@@ -1141,6 +1145,8 @@ void ConfigMainWindow::setShowRange(bool b) ...@@ -1141,6 +1145,8 @@ void ConfigMainWindow::setShowRange(bool b)
return; return;
configList->showRange = b; configList->showRange = b;
configList->reinit(); configList->reinit();
menuList->showRange = b;
menuList->reinit();
} }
void ConfigMainWindow::setShowData(bool b) void ConfigMainWindow::setShowData(bool b)
...@@ -1149,6 +1155,8 @@ void ConfigMainWindow::setShowData(bool b) ...@@ -1149,6 +1155,8 @@ void ConfigMainWindow::setShowData(bool b)
return; return;
configList->showData = b; configList->showData = b;
configList->reinit(); configList->reinit();
menuList->showData = b;
menuList->reinit();
} }
/* /*
...@@ -1206,12 +1214,25 @@ void ConfigMainWindow::showAbout(void) ...@@ -1206,12 +1214,25 @@ void ConfigMainWindow::showAbout(void)
void fixup_rootmenu(struct menu *menu) void fixup_rootmenu(struct menu *menu)
{ {
struct menu *child; struct menu *child;
static int menu_cnt = 0;
if (!menu->prompt || menu->prompt->type != P_MENU) menu->flags |= MENU_ROOT;
return; for (child = menu->list; child; child = child->next) {
menu->prompt->type = P_ROOTMENU; if (child->prompt && child->prompt->type == P_MENU) {
for (child = menu->list; child; child = child->next) menu_cnt++;
fixup_rootmenu(child);
menu_cnt--;
} else if (!menu_cnt)
fixup_rootmenu(child); fixup_rootmenu(child);
}
}
static const char *progname;
static void usage(void)
{
printf("%s <config>\n", progname);
exit(0);
} }
int main(int ac, char** av) int main(int ac, char** av)
...@@ -1223,23 +1244,23 @@ int main(int ac, char** av) ...@@ -1223,23 +1244,23 @@ int main(int ac, char** av)
kconfig_load(); kconfig_load();
#endif #endif
progname = av[0];
configApp = new QApplication(ac, av); configApp = new QApplication(ac, av);
#if QT_VERSION >= 300 #if QT_VERSION >= 300
configSettings = new QSettings; configSettings = new QSettings;
#endif #endif
if (ac > 1 && av[1][0] == '-') { if (ac > 1 && av[1][0] == '-') {
switch (av[1][1]) { switch (av[1][1]) {
case 'a':
//showAll = 1;
break;
case 'h': case 'h':
case '?': case '?':
printf("%s <config>\n", av[0]); usage();
exit(0);
} }
name = av[2]; name = av[2];
} else } else
name = av[1]; name = av[1];
if (!name)
usage();
conf_parse(name); conf_parse(name);
fixup_rootmenu(&rootmenu); fixup_rootmenu(&rootmenu);
conf_read(NULL); conf_read(NULL);
......
...@@ -108,7 +108,7 @@ public slots: ...@@ -108,7 +108,7 @@ public slots:
QPixmap symbolYesPix, symbolModPix, symbolNoPix; QPixmap symbolYesPix, symbolModPix, symbolNoPix;
QPixmap choiceYesPix, choiceNoPix; QPixmap choiceYesPix, choiceNoPix;
QPixmap menuPix, menuInvPix, menuBackPix; QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
bool showAll, showName, showRange, showData; bool showAll, showName, showRange, showData;
enum listMode mode; enum listMode mode;
......
...@@ -616,8 +616,6 @@ const char *prop_get_type_name(enum prop_type type) ...@@ -616,8 +616,6 @@ const char *prop_get_type_name(enum prop_type type)
return "comment"; return "comment";
case P_MENU: case P_MENU:
return "menu"; return "menu";
case P_ROOTMENU:
return "rootmenu";
case P_DEFAULT: case P_DEFAULT:
return "default"; return "default";
case P_CHOICE: case P_CHOICE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment