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