YaST Commits
Threads by month
- ----- 2024 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
October 2007
- 25 participants
- 535 discussions
[yast-commit] r41272 - in /branches/tmp/sh/mod-ui/core/libyui/src: YWidget.cc YWidget.h
by sh-sh-sh@svn.opensuse.org 05 Oct '07
by sh-sh-sh@svn.opensuse.org 05 Oct '07
05 Oct '07
Author: sh-sh-sh
Date: Fri Oct 5 22:06:27 2007
New Revision: 41272
URL: http://svn.opensuse.org/viewcvs/yast?rev=41272&view=rev
Log:
obsolete cruft
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc Fri Oct 5 22:06:27 2007
@@ -746,14 +746,6 @@
}
-YCPValue YWidget::changeWidgetTerm( const YCPTerm & property, const YCPValue & newvalue )
-{
- y2warning( "Widget %s: Couldn't change unknown widget property %s to %s",
- id()->toString().c_str(), property->toString().c_str(), newvalue->toString().c_str() );
- return YCPVoid();
-}
-
-
YCPValue YWidget::queryWidget( const YCPSymbol & property )
{
string symbol = property->symbol();
@@ -775,14 +767,6 @@
}
-YCPValue YWidget::queryWidgetTerm( const YCPTerm & property )
-{
- y2warning( "Widget %s: Couldn't query unkown widget property %s",
- id()->toString().c_str(), property->toString().c_str() );
- return YCPVoid();
-}
-
-
// FIXME: Obsolete
// FIXME: Obsolete
// FIXME: Obsolete
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h Fri Oct 5 22:06:27 2007
@@ -501,12 +501,7 @@
// FIXME: Obsolete
// FIXME: Obsolete
virtual YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue );
-
- virtual YCPValue changeWidgetTerm( const YCPTerm & property, const YCPValue & newvalue );
-
virtual YCPValue queryWidget( const YCPSymbol & property );
-
- virtual YCPValue queryWidgetTerm( const YCPTerm & property );
// FIXME: Obsolete
// FIXME: Obsolete
// FIXME: Obsolete
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r41271 - in /branches/tmp/sh/mod-ui/core/libyui/src: YCPPropertyHandler.cc YCPPropertyHandler.h YUI_builtins.cc YWidget.cc
by sh-sh-sh@svn.opensuse.org 05 Oct '07
by sh-sh-sh@svn.opensuse.org 05 Oct '07
05 Oct '07
Author: sh-sh-sh
Date: Fri Oct 5 22:02:39 2007
New Revision: 41271
URL: http://svn.opensuse.org/viewcvs/yast?rev=41271&view=rev
Log:
fixed changeWidgetTerm
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc Fri Oct 5 22:02:39 2007
@@ -89,11 +89,6 @@
if ( trySetTableItems ( widget, val ) ) return true;
if ( trySetSelectionWidgetItems ( widget, val ) ) return true;
}
- else if ( propertyName == YUIProperty_Cell ||
- propertyName == YUIProperty_Item )
- {
- if ( trySetTableCell ( widget, val ) ) return true;
- }
else if ( propertyName == YUIProperty_CurrentButton )
{
if ( trySetRadioButtonGroupCurrentButton( widget, val ) ) return true;
@@ -110,6 +105,28 @@
}
+bool
+YCPPropertyHandler::setComplexProperty( YWidget * widget,
+ const YCPTerm & propertyTerm,
+ const YCPValue & val )
+{
+ string propertyName = propertyTerm->name();
+
+ if ( propertyName == YUIProperty_Cell ||
+ propertyName == YUIProperty_Item )
+ {
+ if ( trySetTableCell( widget, propertyTerm, val ) ) return true;
+ }
+
+ y2error( "Can't handle property %s::%s - not changing anything",
+ widget->widgetClass(), propertyName.c_str() );
+
+ return false;
+}
+
+
+
+
YCPValue
YCPPropertyHandler::getComplexProperty( YWidget * widget, const string & propertyName )
{
@@ -404,79 +421,77 @@
bool
-YCPPropertyHandler::trySetTableCell( YWidget * widget, const YCPValue & val )
+YCPPropertyHandler::trySetTableCell( YWidget * widget, const YCPTerm & propTerm, const YCPValue & val )
{
YTable * table = dynamic_cast<YTable *> (widget );
if ( ! table )
return false;
- if ( val->isTerm() )
+ if ( propTerm->size() == 2 &&
+ propTerm->value(1)->isInteger() )
{
- YCPTerm term = val->asTerm();
+ YCPValue itemId = propTerm->value(0);
+ int column = propTerm->value(1)->asInteger()->value();
- if ( term->size() == 2
- && term->value(1)->isInteger() )
- {
- YCPValue itemId = term->value(0);
- int column = term->value(1)->asInteger()->value();
+ YCPTableItem * item = findItem<YCPTableItem>( table, itemId );
- YCPTableItem * item = findItem<YCPTableItem>( table, itemId );
+ if ( item )
+ {
+ YTableCell * cell = item->cell( column );
- if ( item )
+ if ( cell )
{
- YTableCell * cell = item->cell( column );
-
- if ( cell )
+ if ( val->isString() )
{
- YCPValue newContent = term->value(0);
-
- if ( newContent->isString() )
- {
- cell->setLabel( newContent->asString()->value() );
- table->cellChanged( cell );
- }
- else if ( newContent->isInteger() ) // for backwards compatibility
- {
- cell->setLabel( newContent->toString().c_str() );
- table->cellChanged( cell );
- }
- else if ( newContent->isTerm()
- && newContent->asTerm()->name() == YUISymbol_icon // `icon()
- && newContent->asTerm()->size() == 1
- && newContent->asTerm()->value(0)->isString() )
- {
- YCPString iconName = newContent->asTerm()->value(0)->asString();
- cell->setIconName( iconName->value().c_str() );
- table->cellChanged( cell );
- }
- else // any other type
- {
- string msg = "Expected string, integer, or `icon(\"myicon.png\"), not ";
- msg += newContent->toString().c_str();
- YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Item,
- YOtherProperty ),
- table, msg ) );
- }
+ cell->setLabel( val->asString()->value() );
+ table->cellChanged( cell );
+ }
+ else if ( val->isInteger() ) // for backwards compatibility
+ {
+ cell->setLabel( val->toString().c_str() );
+ table->cellChanged( cell );
+ }
+ else if ( val->isVoid() ) // for backwards compatibility
+ {
+ cell->setLabel( "" );
+ table->cellChanged( cell );
+ }
+ else if ( val->isTerm()
+ && val->asTerm()->name() == YUISymbol_icon // `icon()
+ && val->asTerm()->size() == 1
+ && val->asTerm()->value(0)->isString() )
+ {
+ YCPString iconName = val->asTerm()->value(0)->asString();
+ cell->setIconName( iconName->value().c_str() );
+ table->cellChanged( cell );
}
- else // ! cell
+ else // any other type
{
- y2error( "%s item %s doesn't have a column #%d",
- table->widgetClass(),
- itemId->toString().c_str(),
- column );
+ string msg = "Expected string, integer, or `icon(\"myicon.png\"), not ";
+ msg += val->toString().c_str();
+ YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Item,
+ YOtherProperty ),
+ table, msg ) );
}
}
- else // ! item
+ else // ! cell
{
- y2error( "%s %s has no item with ID %s",
+ y2error( "%s item %s doesn't have a column #%d",
table->widgetClass(),
- table->debugLabel().c_str(),
- itemId->toString().c_str() );
+ itemId->toString().c_str(),
+ column );
}
-
- return true;
}
+ else // ! item
+ {
+ y2error( "%s %s has no item with ID %s",
+ table->widgetClass(),
+ table->debugLabel().c_str(),
+ itemId->toString().c_str() );
+ }
+
+ return true;
}
YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Items,
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h Fri Oct 5 22:02:39 2007
@@ -58,6 +58,14 @@
const string & propertyName,
const YCPValue & val );
+ /**
+ * Set a complex property from a term (like `Item(`someID) )
+ *
+ * Return 'true' on success, 'false' on failure.
+ **/
+ static bool setComplexProperty( YWidget * widget,
+ const YCPTerm & propertyTerm,
+ const YCPValue & val );
/**
* Get a complex property.
@@ -91,7 +99,7 @@
static bool trySetComboBoxValue ( YWidget * widget, const YCPValue & val );
static bool trySetTreeItems ( YWidget * widget, const YCPValue & val );
static bool trySetTableItems ( YWidget * widget, const YCPValue & val );
- static bool trySetTableCell ( YWidget * widget, const YCPValue & val );
+ static bool trySetTableCell ( YWidget * widget, const YCPTerm & propTerm, const YCPValue & val );
static bool trySetSelectionWidgetItems ( YWidget * widget, const YCPValue & val );
static bool trySetRadioButtonGroupCurrentButton ( YWidget * widget, const YCPValue & val );
static bool trySetMultiSelectionBoxSelectedItems ( YWidget * widget, const YCPValue & val );
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc Fri Oct 5 22:02:39 2007
@@ -878,48 +878,58 @@
return YCPNull();
}
- YCPValue id = YCPDialogParser::parseIdTerm( id_value );
- YWidget *widget = YCPDialogParser::findWidgetWithId( id );
+ YCPValue id = YCPDialogParser::parseIdTerm( id_value );
+ YWidget * widget = YCPDialogParser::findWidgetWithId( id );
if ( ! widget )
return YCPBoolean( false );
- if ( property->isSymbol() )
- {
- blockEvents(); // We don't want self-generated events from UI::ChangeWidget().
- string oldShortcutString = widget->shortcutString();
- YCPSymbol sym = property->asSymbol();
- YCPValue ret = YCPVoid();
+ blockEvents(); // We don't want self-generated events from UI::ChangeWidget().
+ YCPValue ret = YCPVoid();
- YPropertySet propSet = widget->propertySet();
+ YPropertySet propSet = widget->propertySet();
+
+ if ( propSet.size() == 5 ) // unchanged from YWidget, no properties supported
+ {
+ // FIXME: Get rid of this
+ // FIXME: Get rid of this
+ // FIXME: Get rid of this
- if ( propSet.size() == 5 ) // unchanged from YWidget, no properties supported
+ if ( property->isSymbol() )
{
- // FIXME: Get rid of this
- // FIXME: Get rid of this
- // FIXME: Get rid of this
+ YCPSymbol sym = property->asSymbol();
y2debug( "Old style UI::ChangeWidget() for %s::%s",
- widget->widgetClass(), sym->symbol().c_str() );
+ widget->widgetClass(), sym->toString().c_str() );
ret = widget->changeWidget( sym, newValue );
- // FIXME: Get rid of this
- // FIXME: Get rid of this
- // FIXME: Get rid of this
}
else
{
- // y2milestone( "New style UI::ChangeWidget() for %s::%s", widget->widgetClass(), sym->symbol().c_str() );
-
- string propertyName = sym->symbol();
- YPropertyValue val;
-
- if ( newValue->isString() ) val = YPropertyValue( newValue->asString()->value() );
- else if ( newValue->isInteger() ) val = YPropertyValue( newValue->asInteger()->value() );
- else if ( newValue->isBoolean() ) val = YPropertyValue( newValue->asBoolean()->value() );
- else
- val = YPropertyValue( false ); // Dummy value, will be rejected anyway
-
- try
+ y2error( "Bad argument for UI::ChangeWidget(): %s",
+ property->toString().c_str() );
+ }
+
+ // FIXME: Get rid of this
+ // FIXME: Get rid of this
+ // FIXME: Get rid of this
+ }
+ else
+ {
+ try
+ {
+ if ( property->isSymbol() )
{
+ string oldShortcutString = widget->shortcutString();
+ string propertyName = property->asSymbol()->symbol();
+ // y2milestone( "New style UI::ChangeWidget() for %s::%s", widget->widgetClass(), propertyName.c_str() );
+
+ YPropertyValue val;
+
+ if ( newValue->isString() ) val = YPropertyValue( newValue->asString()->value() );
+ else if ( newValue->isInteger() ) val = YPropertyValue( newValue->asInteger()->value() );
+ else if ( newValue->isBoolean() ) val = YPropertyValue( newValue->asBoolean()->value() );
+ else
+ val = YPropertyValue( false ); // Dummy value, will be rejected anyway
+
bool success = widget->setProperty( propertyName, val );
if ( ! success )
@@ -929,35 +939,35 @@
}
ret = YCPBoolean( success );
+
+ if ( oldShortcutString != widget->shortcutString() )
+ YDialog::currentDialog()->checkShortcuts();
}
- catch( YUIException & exception )
+ else if ( property->isTerm() )
{
- YUI_CAUGHT( exception );
- ycperror( "UI::ChangeWidget() failed for property %s of %s with ID %s, new value: %s",
- property->toString().c_str(),
- widget->widgetClass(),
- id->toString().c_str(),
- newValue->toString().c_str() );
-
- ret = YCPNull();
+ bool success = YCPPropertyHandler::setComplexProperty( widget, property->asTerm(), newValue );
+ ret = YCPBoolean( success );
+ }
+ else
+ {
+ YUI_THROW( YUIException( string( "Bad UI::ChangeWidget args: " )
+ + property->toString() ) );
}
}
-
-
- if ( oldShortcutString != widget->shortcutString() )
- YDialog::currentDialog()->checkShortcuts();
-
- unblockEvents();
- return ret;
+ catch( YUIException & exception )
+ {
+ YUI_CAUGHT( exception );
+ ycperror( "UI::ChangeWidget() failed for property %s of %s with ID %s, new value: %s",
+ property->toString().c_str(),
+ widget->widgetClass(),
+ id->toString().c_str(),
+ newValue->toString().c_str() );
+ }
}
- else
- {
- blockEvents(); // We don't want self-generated events from UI::ChangeWidget().
- YCPValue result = widget->changeWidgetTerm( property->asTerm(), newValue );
- unblockEvents();
- return result;
- }
+ unblockEvents();
+
+ return ret;
}
@@ -1018,7 +1028,7 @@
if ( property->isSymbol() ) // The normal case: UI::QueryWidget(`myWidget, `SomeProperty)
{
string propertyName = property->asSymbol()->symbol();
- YPropertyValue val = widget->getProperty( propertyName );
+ YPropertyValue val = widget->getProperty( propertyName );
switch ( val.type() )
{
@@ -1038,7 +1048,8 @@
}
else
{
- YUI_THROW( YUIException( "Bad QueryWidget args" ) );
+ YUI_THROW( YUIException( string( "Bad UI::QueryWidget args: " )
+ + property->toString() ) );
}
}
catch( YUIException & exception )
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc Fri Oct 5 22:02:39 2007
@@ -758,8 +758,8 @@
{
string symbol = property->symbol();
- if ( symbol == YUIProperty_Enabled ) return YCPBoolean( isEnabled() );
- if ( symbol == YUIProperty_Notify ) return YCPBoolean( notify() );
+ if ( symbol == YUIProperty_Enabled ) return YCPBoolean( isEnabled() );
+ if ( symbol == YUIProperty_Notify ) return YCPBoolean( notify() );
if ( symbol == YUIProperty_WidgetClass ) return YCPString( widgetClass() );
if ( symbol == YUIProperty_DebugLabel ) return YCPString( debugLabel() );
if ( symbol == YUIProperty_DialogDebugLabel )
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r41270 - /branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp
by sh-sh-sh@svn.opensuse.org 05 Oct '07
by sh-sh-sh@svn.opensuse.org 05 Oct '07
05 Oct '07
Author: sh-sh-sh
Date: Fri Oct 5 22:01:43 2007
New Revision: 41270
URL: http://svn.opensuse.org/viewcvs/yast?rev=41270&view=rev
Log:
fixed example
Modified:
branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp
Modified: branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp (original)
+++ branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp Fri Oct 5 22:01:43 2007
@@ -20,10 +20,11 @@
while ( UI::UserInput() != `cancel)
{
- integer current_item_no = (integer) UI::QueryWidget(`id(`table), `CurrentItem);
- integer amount = tointeger( (string) UI::QueryWidget(`table, `Cell( current_item_no, 1 ) ) );
+ integer current_item_id = (integer) UI::QueryWidget(`id(`table), `CurrentItem);
+ integer amount = tointeger( (string) UI::QueryWidget(`table, `Cell( current_item_id, 1 ) ) );
+ amount = amount+1;
y2debug( "amount: %1", amount );
- UI::ChangeWidget(`id(`table), `Item( current_item_no, 1 ), sformat( "%1", amount+1 ) );
+ UI::ChangeWidget(`id(`table), `Cell( current_item_id, 1 ), amount );
}
UI::CloseDialog();
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r41269 - in /branches/tmp/sh/mod-ui: core/libyui/doc/examples/ core/libyui/src/ qt/src/ qt/src/pkg/
by sh-sh-sh@svn.opensuse.org 05 Oct '07
by sh-sh-sh@svn.opensuse.org 05 Oct '07
05 Oct '07
Author: sh-sh-sh
Date: Fri Oct 5 17:53:40 2007
New Revision: 41269
URL: http://svn.opensuse.org/viewcvs/yast?rev=41269&view=rev
Log:
ported table widget
Added:
branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.h
branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.h
Modified:
branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table1.ycp
branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp
branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPItemParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h
branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItem.h
branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItemParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YDialog.cc
branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc
branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.h
branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc
branches/tmp/sh/mod-ui/core/libyui/src/YTable.h
branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.cc
branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
branches/tmp/sh/mod-ui/qt/src/QY2ListView.cc
branches/tmp/sh/mod-ui/qt/src/QY2ListView.h
branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.h
branches/tmp/sh/mod-ui/qt/src/YQTable.cc
branches/tmp/sh/mod-ui/qt/src/YQTable.h
branches/tmp/sh/mod-ui/qt/src/YQTree.cc
branches/tmp/sh/mod-ui/qt/src/YQUI.h
branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc
branches/tmp/sh/mod-ui/qt/src/YQWizard.cc
branches/tmp/sh/mod-ui/qt/src/YQWizard.h
branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgConflictList.cc
branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgObjList.cc
branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgVersionsView.cc
Modified: branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table1.ycp (original)
+++ branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table1.ycp Fri Oct 5 17:53:40 2007
@@ -8,7 +8,7 @@
[
`item(`id(1), "Chili", 6),
`item(`id(2), "Salami Baguette", nil),
- `item(`id(3), "Spaghetti", 8),
+ `item(`id(3), "Spaghetti", 8),
`item(`id(4), "Steak Sandwich", 12)
]
)
Modified: branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp (original)
+++ branches/tmp/sh/mod-ui/core/libyui/doc/examples/Table5.ycp Fri Oct 5 17:53:40 2007
@@ -21,10 +21,9 @@
while ( UI::UserInput() != `cancel)
{
integer current_item_no = (integer) UI::QueryWidget(`id(`table), `CurrentItem);
- term current_item = (term) UI::QueryWidget(`table, `Item( current_item_no ) );
- y2debug( "current_item: %1", current_item );
- integer amount = tointeger( current_item[2]:nil );
- UI::ChangeWidget(`id(`table), `Item( current_item_no, 1 ), amount+1 );
+ integer amount = tointeger( (string) UI::QueryWidget(`table, `Cell( current_item_no, 1 ) ) );
+ y2debug( "amount: %1", amount );
+ UI::ChangeWidget(`id(`table), `Item( current_item_no, 1 ), sformat( "%1", amount+1 ) );
}
UI::CloseDialog();
Modified: branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog Fri Oct 5 17:53:40 2007
@@ -339,4 +339,13 @@
2007-07-13 19:20 sh(a)suse.de
* Ported MultiProgressMeter
- - now using float values internally to safeguard against huge numbers
\ No newline at end of file
+ - now using float values internally to safeguard against huge numbers
+
+
+2007-10-05 18:00 sh(a)suse.de
+
+* Ported Table
+ - now based on SelectionWidget
+ - much streamlined with the other selection widgets
+ - QueryWidget(table) can now return the complete item term
+ as well as individual cells
Modified: branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am Fri Oct 5 17:53:40 2007
@@ -16,6 +16,8 @@
YCPDialogParser.cc \
YCPItemParser.cc \
YCPTreeItemParser.cc \
+ YCPTableItemParser.cc \
+ YCPTableItemWriter.cc \
YCPPropertyHandler.cc \
YCPValueWidgetID.cc \
YItem.cc \
@@ -95,6 +97,8 @@
YCPItemParser.h \
YCPTreeItem.h \
YCPTreeItemParser.h \
+ YCPTableItemParser.h \
+ YCPTableItemWriter.h \
YCPTableItem.h \
YCPPropertyHandler.h \
YCPValueWidgetID.h \
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc Fri Oct 5 17:53:40 2007
@@ -34,6 +34,7 @@
#include "YCPValueWidgetID.h"
#include "YCPItemParser.h"
#include "YCPTreeItemParser.h"
+#include "YCPTableItemParser.h"
#include "YCP_UI_Exception.h"
#include "YDialog.h"
#include "YUI_util.h"
@@ -80,7 +81,7 @@
const YCPTerm & term )
{
YUI_CHECK_PTR( p );
-
+
// Extract optional widget ID, if present
int n;
YCPValue id = getWidgetId( term, &n );
@@ -323,7 +324,7 @@
y2warning( "Late adding child %s to %s", w->widgetClass(), p->widgetClass() );
p->addChild( w );
}
-
+
// FIXME: Obsolete
// FIXME: Obsolete
// FIXME: Obsolete
@@ -1745,12 +1746,12 @@
term->toString().c_str() );
return 0;
}
-
+
rejectAllOptions( term, optList );
string label = term->value( argnr )->asString()->value();
string initialValue;
-
+
if ( term->size() >= argnr + 2 )
initialValue = term->value( argnr+1 )->asString()->value();
@@ -1809,10 +1810,10 @@
}
string label = term->value( argnr )->asString()->value();
-
+
bool shrinkable = false;
bool immediate = false;
-
+
for ( int o=0; o < optList->size(); o++ )
{
if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_shrinkable ) shrinkable = true;
@@ -1883,7 +1884,7 @@
string label = term->value( argnr )->asString()->value();
bool shrinkable = false;
-
+
for ( int o=0; o < optList->size(); o++ )
{
if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_shrinkable ) shrinkable = true;
@@ -1957,7 +1958,7 @@
string label = term->value( argnr )->asString()->value();
bool editable = false;
-
+
for ( int o=0; o < optList->size(); o++ )
{
if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_editable ) editable = true;
@@ -2052,7 +2053,7 @@
rejectAllOptions( term,optList );
string label = term->value ( argnr )->asString()->value();
-
+
YTree * tree = YUI::widgetFactory()->createTree( parent, label );
if ( numArgs > 1 )
@@ -2084,31 +2085,80 @@
*
* @description
*
- * A Table widget is a generalization of the SelectionBox. Information is
- * displayed in a number of columns. Each column has a header. The number of
- * columns and their titles are described by the first argument, which is a
- * term with the symbol <tt>header</tt>. For each column you add a string
- * specifying its title. For example <tt>`header( "Name", "Price" )</tt> creates
- * the two columns "Name" and "Price".
- *
- * The second argument is an optional list of items (rows) that are inserted in
- * the table. Each item has the form <tt>`item( `id( </tt> id <tt> ), first
- * column, second column, ... )</tt>. For each column one argument has to be
- * specified, which must be of type void, string or integer. Strings are being
- * left justified, integer right and a nil denote an empty cell, just as the
- * empty string.
+ * The Table widget is a selection list with multiple columns. The user can
+ * select exactly one row (with all its columns) from that list.
+ *
+ * Each cell (each column within each row) has a label text and an optional
+ * icon.
*
+ * (Note: Not all UIs (in particular not text-based UIs) support displaying
+ * icons, so an icon should never be an exclusive means to display any kind of
+ * information).
+ *
+ * This widget is similar to SelectionBox, but it has several columns for each
+ * item (each row). If just one column is desired, consider using SelectionBox
+ * instead.
+ *
+ * Note: This is not something like a spread sheet, and it doesn't pretend or
+ * want to be. Actions are performed on rows, not on individual cells (columns
+ * within one row).
+ *
+ * The first argument (after `opt() and `id() which both are optional) is
+ * `header() which specifies the column headers (and implicitly the number of
+ * columns) and optionally the alignment for each column. Default alignment is
+ * left.
+ *
+ * In the list of items, an ID is specified for each item. Each item can have
+ * less cells (columns) than the table has columns (from `header()), in which
+ * case any missing cells are assumed to be empty. If an item has more cells
+ * than the table has columns, any extra cells are ignored.
+ *
+ * Each cell has a text label (which might also be an empty string) and
+ * optionally an icon. If a cell has an icon, it has to be specified with
+ * `cell(`icon("myiconname.png", "Label text")).
+ *
+ * A simple table is specified like this:
+ *
+ * `Table(`id(`players),
+ * `header("Nick", "Age", "Role"),
+ * [
+ * `item(`id("Bluebird"), "Bluebird, 18, "Scout" ),
+ * `item(`id("Ozzz" ), "Ozzz", 23, "Wizard" ),
+ * `item(`id("Wannabe" ), "Wannabe", 17 ),
+ * `item(`id("Coxxan" ), "Coxxan", 26, "Warrior")
+ * ]
+ * )
+ *
+ * This will create a 3-column table. The first column ("Nick") and the third
+ * column ("Role") will be left aligned. The second column ("Age") will be
+ * right aligned. note that "Wannabe" doesn't have a Role. This field will be
+ * empty.
+ *
+ * A table that uses icons is specified like this:
+ *
+ * `Table(`id(`players),
+ * `header("Nick", "Age", "Role"),
+ * [
+ * `item(`id("Bluebird"), "Bluebird, 18, `cell(`icon("scout.png"), "Scout" ) ),
+ * `item(`id("Ozzz" ), "Ozzz", 23, "Wizard" ),
+ * `item(`id("Wannabe" ), "Wannabe", `cell(`icon("underage.png", 17 ) ),
+ * `item(`id("Coxxan" ), "Coxxan", `cell(`icon("oldman.png", 26 ), "Warrior" )
+ * ]
+ * )
+ *
+ * In this example, "Bluebird" has an additional icon in his "Role" column, and
+ * "Wannabe" and "Coxxan" both have additional icons in their "Age" columns.
**/
YWidget *
YCPDialogParser::parseTable( YWidget * parent, YWidgetOpt & opt,
const YCPTerm & term, const YCPList & optList, int argnr )
{
- int numargs = term->size() - argnr;
- if ( numargs < 1 || numargs > 2
+ int numArgs = term->size() - argnr;
+ if ( numArgs < 1 || numArgs > 2
|| !term->value(argnr)->isTerm()
|| term->value(argnr)->asTerm()->name() != YUISymbol_header
- || (numargs == 2 && !term->value(argnr+1)->isList()))
+ || (numArgs == 2 && !term->value(argnr+1)->isList()))
{
y2error( "Invalid arguments for the Table widget: %s",
term->toString().c_str() );
@@ -2117,76 +2167,87 @@
// Parse options
+ bool immediate = false;
+ bool keepSorting = false;
+
for ( int o=0; o < optList->size(); o++ )
{
- if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_immediate ) opt.immediateMode.setValue( true );
- else if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_keepSorting ) opt.keepSorting.setValue( true );
+ if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_immediate ) immediate = true;
+ else if ( optList->value(o)->isSymbol() && optList->value(o)->asSymbol()->symbol() == YUIOpt_keepSorting ) keepSorting = true;
else logUnknownOption( term, optList->value(o) );
}
- // Build header. The header is a vector of strings, each defining
- // one column. The first string is one of the characters L, R or C
- // denoting left, right or center justification, resp.
+ YCPTerm headerTerm = term->value( argnr )->asTerm();
+ YCPList itemList = term->value( argnr+1 )->asList();
+ int columns = headerTerm->size();
- vector<string> header;
- YCPTerm headerterm = term->value( argnr )->asTerm();
- for ( int i=0; i< headerterm->size(); i++ )
- {
- YCPValue v = headerterm->value(i);
- string this_column;
+ YTable * table = YUI::widgetFactory()->createTable( parent, columns );
+
+ if ( keepSorting )
+ table->setKeepSorting( true );
+
+ if ( immediate )
+ table->setImmediateMode( true );
+
+
+ //
+ // Parse header term
+ //
- if ( v->isString() )
- this_column = "L" + v->asString()->value(); // left justified per default
+ for ( int i=0; i < headerTerm->size(); i++ )
+ {
+ YCPValue colHeader = headerTerm->value( i );
- else if ( v->isTerm() )
+ if ( colHeader->isString() )
{
- YCPTerm t=v->asTerm();
- if ( t->size() != 1 ||
- ! t->value(0)->isString() )
- {
- y2error( "Invalid Table column specification %s",
- t->toString().c_str() );
- return 0;
- }
+ table->setHeader( i, colHeader->asString()->value() );
+ }
+ else if ( colHeader->isTerm() )
+ {
+ YCPTerm colHeaderTerm = colHeader->asTerm();
- string s = t->name();
- string just;
- if ( s == "Left" ) just = "L";
- else if ( s == "Right" ) just = "R";
- else if ( s == "Center" ) just = "C";
+ if ( colHeaderTerm->name() == YUISymbol_Left ) table->setAlignment( i, YTable::Left );
+ else if ( colHeaderTerm->name() == YUISymbol_Right ) table->setAlignment( i, YTable::Right );
+ else if ( colHeaderTerm->name() == YUISymbol_Center ) table->setAlignment( i, YTable::Center );
else
{
- y2error( "Invalid Table column specification %s",
- t->toString().c_str() );
- return 0;
+ string msg = string( "Unknown table header alignment: " )
+ + colHeaderTerm->name().c_str();
+ y2error ( "%s", msg.c_str() );
+ ycperror( "%s", msg.c_str() );
}
- this_column = just + t->value(0)->asString()->value();
- }
- else
- {
- y2error( "Invalid header declaration in Table widget: %s",
- headerterm->toString().c_str() );
- return 0;
- }
- header.push_back( this_column );
- }
+ if ( colHeaderTerm->size() > 0 )
+ {
+ if ( colHeaderTerm->value(0)->isString() )
+ table->setHeader( i, colHeaderTerm->value(0)->asString()->value() );
+ else
+ {
+ string msg = string( "Expected string for table header, not " )
+ + colHeaderTerm->value(0)->toString();
- // Empty header not allowed!
- if ( header.size() == 0 )
- {
- y2error( "empty header in Table widget not allowed" );
- return 0;
- }
+ y2error ( "%s", msg.c_str() );
+ ycperror( "%s", msg.c_str() );
+ }
+ if ( colHeaderTerm->size() > 1 )
+ {
+ string msg = string( "Ignoring extra parameters of %s" )
+ + colHeaderTerm->toString();
- YTable *table = dynamic_cast<YTable *> ( YUI::ui()->createTable( parent, opt, header ) );
+ y2error ( "%s", msg.c_str() );
+ ycperror( "%s", msg.c_str() );
+ }
+ }
+ }
+ }
- if ( table && numargs == 2 ) // Fill table with items, if item list is specified
+ if ( numArgs >= 2 ) // Fill table with items, if item list is specified
{
- YCPList itemlist = term->value( argnr+1 )->asList();
- table->addItems( itemlist );
+ YCPList itemList = term->value( argnr+1 )->asList();
+ table->addItems( YCPTableItemParser::parseTableItemList( itemList ) );
}
+
return table;
}
@@ -2228,11 +2289,11 @@
}
rejectAllOptions( term,optList );
-
+
string label = term->value( argnr )->asString()->value();
int maxValue = 100;
int initialValue = 0;
-
+
if ( s >= 2 ) maxValue = term->value( argnr+1 )->asInteger()->value();
if ( s >= 3 ) initialValue = term->value( argnr+2 )->asInteger()->value();
@@ -2273,7 +2334,7 @@
*
* This option implicitly sets `opt( `zeroWidth ) and `opt( zeroHeight ),
* too since there is no useful default size for such an image. Use MinSize()
- * or other layout helpers to explicitly set a size on such a widget.
+ * or other layout helpers to explicitly set a size on such a widget.
*
* Please note that setting both `opt( `tiled ) and `opt( `scaleToFit ) at once
* doesn't make any sense.
@@ -2896,7 +2957,7 @@
}
vector<float> maxValues;
-
+
try
{
maxValues = parseNumList( term->value( argnr )->asList() );
@@ -2905,7 +2966,7 @@
{
YUI_RETHROW( exception );
}
-
+
if ( maxValues.size() < 1 )
{
YUI_THROW( YCPDialogSyntaxErrorException( "Expected list<integer> or list<float>",
@@ -2921,11 +2982,11 @@
YCPDialogParser::parseNumList( const YCPList & yList )
{
vector<float> result;
-
+
for ( int i=0; i < yList->size(); i++ )
{
YCPValue val = yList->value( i );
-
+
if ( val->isInteger() )
{
result.push_back( (float) val->asInteger()->value() );
@@ -3143,7 +3204,7 @@
}
rejectAllOptions( term, optList );
-
+
return YUI::optionalWidgetFactory()->createPatternSelector( parent );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPItemParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPItemParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPItemParser.cc Fri Oct 5 17:53:40 2007
@@ -41,6 +41,8 @@
}
catch ( YUIException & exception )
{
+ // Delete all items created so far
+
YItemIterator it = itemCollection.begin();
while ( it != itemCollection.end() )
@@ -50,8 +52,7 @@
delete item;
}
- itemCollection.clear();
- YUI_RETHROW( exception );
+ throw;
}
return itemCollection;
@@ -97,7 +98,7 @@
YCPString label = YCPNull();
YCPBoolean selected = YCPNull();
- string usage =
+ const char * usage =
"Expected: `item(`id(`myID), `icon(\"MyIcon.png\"), \"MyItemText\", boolean selected )";
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc Fri Oct 5 17:53:40 2007
@@ -38,6 +38,8 @@
#include "YCPTreeItem.h"
#include "YCPItemParser.h"
#include "YCPTreeItemParser.h"
+#include "YCPTableItemParser.h"
+#include "YCPTableItemWriter.h"
#include "YCPValueWidgetID.h"
#include "YCheckBox.h"
@@ -48,6 +50,7 @@
#include "YRadioButtonGroup.h"
#include "YSelectionBox.h"
#include "YTree.h"
+#include "YTable.h"
#include "YUISymbols.h"
using std::list;
@@ -65,6 +68,7 @@
if ( trySetCheckBoxValue ( widget, val ) ) return true;
if ( trySetSelectionBoxValue ( widget, val ) ) return true;
if ( trySetTreeValue ( widget, val ) ) return true;
+ if ( trySetTableValue ( widget, val ) ) return true;
if ( trySetComboBoxValue ( widget, val ) ) return true;
}
if ( propertyName == YUIProperty_Values )
@@ -75,14 +79,21 @@
{
if ( trySetSelectionBoxValue ( widget, val ) ) return true;
if ( trySetTreeValue ( widget, val ) ) return true;
+ if ( trySetTableValue ( widget, val ) ) return true;
}
else if ( propertyName == YUIProperty_Items )
{
- // Make sure to try YTree before YSelectionWidget: YTree inherits YSelectionWidget!
-
+ // Make sure to try YTree and YTable before YSelectionWidget: both inherit YSelectionWidget!
+
if ( trySetTreeItems ( widget, val ) ) return true;
+ if ( trySetTableItems ( widget, val ) ) return true;
if ( trySetSelectionWidgetItems ( widget, val ) ) return true;
}
+ else if ( propertyName == YUIProperty_Cell ||
+ propertyName == YUIProperty_Item )
+ {
+ if ( trySetTableCell ( widget, val ) ) return true;
+ }
else if ( propertyName == YUIProperty_CurrentButton )
{
if ( trySetRadioButtonGroupCurrentButton( widget, val ) ) return true;
@@ -109,12 +120,14 @@
val = tryGetCheckBoxValue ( widget ); if ( ! val.isNull() ) return val;
val = tryGetSelectionBoxValue ( widget ); if ( ! val.isNull() ) return val;
val = tryGetTreeValue ( widget ); if ( ! val.isNull() ) return val;
+ val = tryGetTableValue ( widget ); if ( ! val.isNull() ) return val;
val = tryGetComboBoxValue ( widget ); if ( ! val.isNull() ) return val;
}
else if ( propertyName == YUIProperty_CurrentItem )
{
val = tryGetSelectionBoxValue ( widget ); if ( ! val.isNull() ) return val;
val = tryGetTreeValue ( widget ); if ( ! val.isNull() ) return val;
+ val = tryGetTableValue ( widget ); if ( ! val.isNull() ) return val;
val = tryGetComboBoxValue ( widget ); if ( ! val.isNull() ) return val;
// tryGetMultiSelectionBoxCurrentItem
@@ -135,14 +148,37 @@
{
val = tryGetTreeCurrentBranch ( widget ); if ( ! val.isNull() ) return val;
}
+ else if ( propertyName == YUIProperty_Items )
+ {
+ val = tryGetTableItems ( widget ); if ( ! val.isNull() ) return val;
+
+ // FIXME: TO DO:
+ // FIXME: TO DO:
+ // FIXME: TO DO:
+
+ // tryGetTreeItems
+ // tryGetSelectionWidgetItems
+ }
+
+ y2error( "Can't handle property %s::%s - returning 'nil'",
+ widget->widgetClass(), propertyName.c_str() );
+
+ return YCPVoid();
+}
- // FIXME: TO DO:
- // FIXME: TO DO:
- // FIXME: TO DO:
- // tryGetTreeItems
- // tryGetSelectionWidgetItems
+YCPValue
+YCPPropertyHandler::getComplexProperty( YWidget * widget, const YCPTerm & propertyTerm )
+{
+ YCPValue val = YCPNull();
+ string propertyName = propertyTerm->name();
+
+ if ( propertyName == YUIProperty_Cell ||
+ propertyName == YUIProperty_Item )
+ {
+ val = tryGetTableCell ( widget, propertyTerm ); if ( ! val.isNull() ) return val;
+ }
y2error( "Can't handle property %s::%s - returning 'nil'",
widget->widgetClass(), propertyName.c_str() );
@@ -217,12 +253,11 @@
{
wantedId = val->asTerm()->value(0);
}
-
+
return findItem<Item_t>( wantedId, selWidget->itemsBegin(), selWidget->itemsEnd() );
}
-
template<class Widget_t, class Item_t>
bool trySetSelectionWidgetValue( YWidget * widget, const YCPValue & val )
{
@@ -264,6 +299,13 @@
bool
+YCPPropertyHandler::trySetTableValue( YWidget * widget, const YCPValue & val )
+{
+ return trySetSelectionWidgetValue<YTable, YCPTableItem>( widget, val );
+}
+
+
+bool
YCPPropertyHandler::trySetComboBoxValue( YWidget * widget, const YCPValue & val )
{
YComboBox * comboBox = dynamic_cast<YComboBox *> (widget);
@@ -299,6 +341,27 @@
bool
+YCPPropertyHandler::trySetSelectionWidgetItems( YWidget * widget, const YCPValue & val )
+{
+ YSelectionWidget * selWidget = dynamic_cast<YSelectionWidget *> (widget );
+
+ if ( ! selWidget )
+ return false;
+
+ if ( val->isList() )
+ {
+ selWidget->setItems( YCPItemParser::parseItemList( val->asList() ) );
+ return true;
+ }
+
+ YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Items,
+ YOtherProperty ),
+ widget ) );
+ return false;
+}
+
+
+bool
YCPPropertyHandler::trySetTreeItems( YWidget * widget, const YCPValue & val )
{
YTree * tree = dynamic_cast<YTree *> (widget );
@@ -320,16 +383,16 @@
bool
-YCPPropertyHandler::trySetSelectionWidgetItems( YWidget * widget, const YCPValue & val )
+YCPPropertyHandler::trySetTableItems( YWidget * widget, const YCPValue & val )
{
- YSelectionWidget * selWidget = dynamic_cast<YSelectionWidget *> (widget );
+ YTable * table = dynamic_cast<YTable *> (widget );
- if ( ! selWidget )
+ if ( ! table )
return false;
if ( val->isList() )
{
- selWidget->setItems( YCPItemParser::parseItemList( val->asList() ) );
+ table->setItems( YCPTableItemParser::parseTableItemList( val->asList() ) );
return true;
}
@@ -341,6 +404,89 @@
bool
+YCPPropertyHandler::trySetTableCell( YWidget * widget, const YCPValue & val )
+{
+ YTable * table = dynamic_cast<YTable *> (widget );
+
+ if ( ! table )
+ return false;
+
+ if ( val->isTerm() )
+ {
+ YCPTerm term = val->asTerm();
+
+ if ( term->size() == 2
+ && term->value(1)->isInteger() )
+ {
+ YCPValue itemId = term->value(0);
+ int column = term->value(1)->asInteger()->value();
+
+ YCPTableItem * item = findItem<YCPTableItem>( table, itemId );
+
+ if ( item )
+ {
+ YTableCell * cell = item->cell( column );
+
+ if ( cell )
+ {
+ YCPValue newContent = term->value(0);
+
+ if ( newContent->isString() )
+ {
+ cell->setLabel( newContent->asString()->value() );
+ table->cellChanged( cell );
+ }
+ else if ( newContent->isInteger() ) // for backwards compatibility
+ {
+ cell->setLabel( newContent->toString().c_str() );
+ table->cellChanged( cell );
+ }
+ else if ( newContent->isTerm()
+ && newContent->asTerm()->name() == YUISymbol_icon // `icon()
+ && newContent->asTerm()->size() == 1
+ && newContent->asTerm()->value(0)->isString() )
+ {
+ YCPString iconName = newContent->asTerm()->value(0)->asString();
+ cell->setIconName( iconName->value().c_str() );
+ table->cellChanged( cell );
+ }
+ else // any other type
+ {
+ string msg = "Expected string, integer, or `icon(\"myicon.png\"), not ";
+ msg += newContent->toString().c_str();
+ YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Item,
+ YOtherProperty ),
+ table, msg ) );
+ }
+ }
+ else // ! cell
+ {
+ y2error( "%s item %s doesn't have a column #%d",
+ table->widgetClass(),
+ itemId->toString().c_str(),
+ column );
+ }
+ }
+ else // ! item
+ {
+ y2error( "%s %s has no item with ID %s",
+ table->widgetClass(),
+ table->debugLabel().c_str(),
+ itemId->toString().c_str() );
+ }
+
+ return true;
+ }
+ }
+
+ YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Items,
+ YOtherProperty ),
+ widget ) );
+ return false;
+}
+
+
+bool
YCPPropertyHandler::trySetRadioButtonGroupCurrentButton( YWidget * widget, const YCPValue & val )
{
YRadioButtonGroup * radioButtonGroup = dynamic_cast<YRadioButtonGroup *> (widget);
@@ -384,13 +530,13 @@
YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_SelectedItems,
YOtherProperty ),
widget, msg ) );
-
+
}
YCPList itemIdList = val->asList();
multiSelBox->deselectAllItems();
-
+
for ( int i=0; i < itemIdList.size(); i++ )
{
YCPItem * item = findItem<YCPItem>( multiSelBox, itemIdList->value( i ) );
@@ -426,7 +572,7 @@
YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Values,
YOtherProperty ),
widget, msg ) );
-
+
}
multiProgressMeter->setCurrentValues( YCPDialogParser::parseNumList( val->asList() ) );
@@ -497,6 +643,13 @@
YCPValue
+YCPPropertyHandler::tryGetTableValue( YWidget * widget )
+{
+ return tryGetSelectionWidgetValue<YTable, YCPTableItem>( widget );
+}
+
+
+YCPValue
YCPPropertyHandler::tryGetComboBoxValue( YWidget * widget )
{
YCPValue result = tryGetSelectionWidgetValue<YComboBox, YCPItem>( widget );
@@ -507,7 +660,7 @@
if ( ! comboBox )
return YCPNull();
-
+
result = YCPString( comboBox->value() );
}
@@ -529,7 +682,7 @@
return YCPVoid();
y2debug( "Current radio button: %s", currentButton->debugLabel().c_str() );
-
+
if ( currentButton->hasId() )
{
YCPValueWidgetID * id = dynamic_cast<YCPValueWidgetID *> ( currentButton->id() );
@@ -556,7 +709,7 @@
YCPList selectedItemsList;
YItemCollection selectedItems = multiSelBox->selectedItems();
-
+
for ( YItemIterator it = selectedItems.begin();
it != selectedItems.end();
++it )
@@ -648,7 +801,7 @@
}
YCPList currentBranch;
-
+
for ( list<YTreeItem *>::iterator it = path.begin(); it != path.end(); ++it )
{
YCPTreeItem * ycpTreeItem = dynamic_cast<YCPTreeItem *> (*it);
@@ -661,3 +814,109 @@
return currentBranch;
}
+
+
+YCPValue
+YCPPropertyHandler::tryGetTableCell( YWidget * widget, const YCPTerm & propTerm )
+{
+ YTable * table = dynamic_cast<YTable *> (widget);
+
+ if ( ! table )
+ return YCPNull();
+
+ YCPValue result = YCPVoid();
+ string property = propTerm->name();
+
+ if ( property == YUIProperty_Item && propTerm->size() == 1 ) // `Item("myItemID")
+ {
+ return tryGetTableItem( widget, propTerm );
+ }
+
+ if ( propTerm->size() != 2 || // `Item("myItemID", index)
+ ! propTerm->value(1)->isInteger() )
+ {
+ YUI_THROW( YUIBadPropertyArgException( YProperty( property, YOtherProperty ),
+ table ) );
+ }
+
+ YCPValue itemId = propTerm->value(0);
+ int column = propTerm->value(1)->asInteger()->value();
+
+ const YCPTableItem * item = findItem<YCPTableItem>( table, itemId );
+
+ if ( item )
+ {
+ const YTableCell * cell = item->cell( column );
+
+ if ( cell )
+ {
+ result = YCPTableItemWriter::cellValue( cell );
+ }
+ else // ! cell
+ {
+ y2error( "%s item %s doesn't have a column #%d",
+ table->widgetClass(),
+ itemId->toString().c_str(),
+ column );
+ }
+ }
+ else // ! item
+ {
+ y2error( "%s %s has no item with ID %s",
+ table->widgetClass(),
+ table->debugLabel().c_str(),
+ itemId->toString().c_str() );
+ }
+
+ return result;
+}
+
+
+YCPValue
+YCPPropertyHandler::tryGetTableItem( YWidget * widget, const YCPTerm & propTerm )
+{
+ YTable * table = dynamic_cast<YTable *> (widget);
+
+ if ( ! table )
+ return YCPNull();
+
+ YCPValue result = YCPVoid();
+ string property = propTerm->name();
+
+ if ( propTerm->size() != 1 )
+ {
+ YUI_THROW( YUIBadPropertyArgException( YProperty( property, YOtherProperty ),
+ table ) );
+ }
+
+ YCPValue itemId = propTerm->value(0);
+ const YCPTableItem * item = findItem<YCPTableItem>( table, itemId );
+
+ if ( item )
+ {
+ result = YCPTableItemWriter::itemTerm( item );
+ }
+ else // ! item
+ {
+ y2error( "%s %s has no item with ID %s",
+ table->widgetClass(),
+ table->debugLabel().c_str(),
+ itemId->toString().c_str() );
+ }
+
+ return result;
+}
+
+
+YCPValue
+YCPPropertyHandler::tryGetTableItems( YWidget * widget )
+{
+ YTable * table = dynamic_cast<YTable *> (widget);
+
+ if ( ! table )
+ return YCPNull();
+
+ return YCPTableItemWriter::itemList( table->itemsBegin(), table->itemsEnd() );
+}
+
+
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h Fri Oct 5 17:53:40 2007
@@ -24,6 +24,7 @@
#include <ycp/YCPValue.h>
#include <ycp/YCPMap.h>
+#include <ycp/YCPTerm.h>
#include <string>
#include "YItem.h"
@@ -66,6 +67,14 @@
static YCPValue getComplexProperty( YWidget * widget,
const string & propertyName );
+ /**
+ * Get a complex property from a term (like `Item(`someID) )
+ *
+ * Return YCPNull upon failure, a non-null YCPValue (the result) upon success.
+ **/
+ static YCPValue getComplexProperty( YWidget * widget,
+ const YCPTerm & propertyTerm );
+
protected:
@@ -78,8 +87,11 @@
static bool trySetCheckBoxValue ( YWidget * widget, const YCPValue & val );
static bool trySetSelectionBoxValue ( YWidget * widget, const YCPValue & val );
static bool trySetTreeValue ( YWidget * widget, const YCPValue & val );
+ static bool trySetTableValue ( YWidget * widget, const YCPValue & val );
static bool trySetComboBoxValue ( YWidget * widget, const YCPValue & val );
static bool trySetTreeItems ( YWidget * widget, const YCPValue & val );
+ static bool trySetTableItems ( YWidget * widget, const YCPValue & val );
+ static bool trySetTableCell ( YWidget * widget, const YCPValue & val );
static bool trySetSelectionWidgetItems ( YWidget * widget, const YCPValue & val );
static bool trySetRadioButtonGroupCurrentButton ( YWidget * widget, const YCPValue & val );
static bool trySetMultiSelectionBoxSelectedItems ( YWidget * widget, const YCPValue & val );
@@ -94,11 +106,15 @@
static YCPValue tryGetCheckBoxValue ( YWidget * widget );
static YCPValue tryGetSelectionBoxValue ( YWidget * widget );
static YCPValue tryGetTreeValue ( YWidget * widget );
+ static YCPValue tryGetTableValue ( YWidget * widget );
static YCPValue tryGetComboBoxValue ( YWidget * widget );
static YCPValue tryGetRadioButtonGroupCurrentButton ( YWidget * widget );
static YCPValue tryGetMultiSelectionBoxSelectedItems( YWidget * widget );
static YCPValue tryGetTreeOpenItems ( YWidget * widget );
static YCPValue tryGetTreeCurrentBranch ( YWidget * widget );
+ static YCPValue tryGetTableCell ( YWidget * widget, const YCPTerm & propertyTerm );
+ static YCPValue tryGetTableItem ( YWidget * widget, const YCPTerm & propertyTerm );
+ static YCPValue tryGetTableItems ( YWidget * widget );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItem.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItem.h Fri Oct 5 17:53:40 2007
@@ -21,7 +21,8 @@
#include <ycp/YCPValue.h>
#include <ycp/YCPString.h>
-#include "YItem.h"
+#include <ycp/YCPVoid.h>
+#include "YTableItem.h"
/**
@@ -32,13 +33,18 @@
public:
/**
- * Constructor
+ * Constructors
**/
YCPTableItem( const YCPValue & id )
: YTableItem()
, _id( id )
{}
+ YCPTableItem()
+ : YTableItem()
+ , _id( YCPVoid() )
+ {}
+
/**
* Destructor.
**/
@@ -65,7 +71,11 @@
* 'iconName' are empty).
**/
void addCell( const YCPString & label, const YCPString & iconName )
- YTableItem::addCell( label->value(), iconName->value() );
+ { YTableItem::addCell( label->value(), iconName->value() ); }
+
+ void addCell( const YCPString & label )
+ { YTableItem::addCell( label->value() ); }
+
/**
* Return the label of cell no. 'index' (counting from 0 on) as a YCPString
@@ -77,7 +87,7 @@
* Return the icon of cell no. 'index' (counting from 0 on) as a YCPString
* or an empty YCPString if there is no cell with that index.
**/
- YCPString iconName( int index ) const { return YCPString( YItem::iconName( index ) ); }
+ YCPString iconName( int index ) const { return YCPString( YTableItem::iconName( index ) ); }
private:
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.cc (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.cc Fri Oct 5 17:53:40 2007
@@ -0,0 +1,210 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPTableItemParser.h
+
+ Author: Stefan Hundhammer <sh(a)suse.de>
+
+/-*/
+
+
+#include <ycp/YCPTerm.h>
+#include <ycp/YCPBoolean.h>
+
+#define y2log_component "ui"
+#include <ycp/y2log.h>
+
+#include "YCPTableItemParser.h"
+#include "YCP_UI_Exception.h"
+#include "YUISymbols.h"
+
+#define VERBOSE_PARSER 0
+
+
+YItemCollection
+YCPTableItemParser::parseTableItemList( const YCPList & itemList )
+{
+ YItemCollection itemCollection;
+ itemCollection.reserve( itemList.size() );
+
+ try
+ {
+ for ( int i=0; i < itemList->size(); i++ )
+ {
+ YCPValue itemTerm = itemList->value(i);
+
+ if ( itemTerm->isTerm() &&
+ itemTerm->asTerm()->name() == YUISymbol_item ) // `item(...)
+ {
+ YCPTableItem * item = parseTableItem( itemTerm->asTerm() );
+ itemCollection.push_back( item );
+ }
+ else // not `item(...)
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( "Expected `item(...)", itemTerm ) );
+ }
+ }
+ }
+ catch ( YUIException & exception )
+ {
+ // Delete all items created so far
+
+ YItemIterator it = itemCollection.begin();
+
+ while ( it != itemCollection.end() )
+ {
+ YItem * item = *it;
+ ++it;
+ delete item;
+ }
+
+ throw;
+ }
+
+#if VERBOSE_PARSER
+ y2debug( "%d items", itemCollection.size() );
+#endif
+
+ return itemCollection;
+}
+
+
+YCPTableItem *
+YCPTableItemParser::parseTableItem( const YCPTerm & itemTerm )
+{
+ YCPTableItem * item = new YCPTableItem();
+ YUI_CHECK_NEW( item );
+
+ const char * usage =
+ "Expected: `item(`id(`myID), (\"MyLabelText\"|`cell(...)), ... )";
+
+#if VERBOSE_PARSER
+ y2debug( "Parsing: %s", itemTerm->toString().c_str() );
+#endif
+
+ try
+ {
+ for ( int i=0; i < itemTerm->size(); i++ )
+ {
+ YCPValue arg = itemTerm->value(i);
+
+#if VERBOSE_PARSER
+ y2debug( "Parsing term arg #%d: %s", i, arg->toString().c_str() );
+#endif
+
+ if ( arg->isTerm() ) // `id(), `cell()
+ {
+ YCPTerm term = arg->asTerm();
+
+ if ( term->name() == YUISymbol_id // `id(...)
+ && term->size() == 1
+ && ! item->hasId() ) // and don't have an ID yet
+ {
+ item->setId( term->value(0) );
+ }
+ else if ( term->name() == YUISymbol_cell ) // `cell(...)
+ {
+ parseTableCell( item, term );
+ }
+ else
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, itemTerm ) );
+ }
+ }
+ else if ( arg->isString() ) // label (the user-visible text)
+ {
+ item->addCell( arg->asString() );
+ }
+ else if ( arg->isInteger() ) // integer label (for backwards compatibility)
+ {
+ item->addCell( arg->toString() );
+ }
+ else if ( arg->isVoid() )
+ {
+ item->addCell( YCPString("") );
+ }
+ else
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, itemTerm ) );
+ }
+ }
+
+ if ( ! item->hasId() ) // No ID specified?
+ {
+ // Use the first non-empty cell label as ID for the entire item
+
+ for ( YTableCellConstIterator it = item->cellsBegin();
+ ! item->hasId() && it != item->cellsEnd();
+ ++it )
+ {
+ if ( ! (*it)->label().empty() )
+ item->setId( YCPString( (*it)->label() ) );
+ }
+ }
+ }
+ catch ( YUIException & exception )
+ {
+ delete item;
+ throw;
+ }
+
+ return item;
+}
+
+
+void
+YCPTableItemParser::parseTableCell( YCPTableItem * parent, const YCPTerm & cellTerm )
+{
+ YCPString label = YCPNull();
+ YCPString iconName = YCPNull();
+ const char * usage = "Expected `cell(`icon(\"myicon.png\"), \"mylabel\")";
+
+ if ( cellTerm->size() < 1 || cellTerm->size() > 2 )
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, cellTerm ) );
+
+ for ( int i=0; i < cellTerm->size(); ++i )
+ {
+ YCPValue arg = cellTerm->value(i);
+
+ if ( arg->isString() ) // label
+ {
+ if ( ! label.isNull() ) // already have a label for this cell?
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, cellTerm ) );
+
+ label = arg->asString();
+ }
+ else if ( arg->isTerm() ) // `icon("myicon.png")
+ {
+ YCPTerm iconTerm = arg->asTerm();
+
+ if ( iconTerm->name() == YUISymbol_icon &&
+ iconTerm->size() == 1 &&
+ iconTerm->value(0)->isString() &&
+ iconName.isNull() ) // no icon name yet
+ {
+ iconName = iconTerm->value(0)->asString();
+ }
+ else
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, cellTerm ) );
+ }
+ else // other types
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, cellTerm ) );
+ }
+ }
+
+ // Don't need to check if at least one of label or iconName found:
+ // The cellTerm->size() check above and the other checks in the loop handle that.
+
+ YUI_CHECK_PTR( parent );
+ parent->addCell( label, iconName );
+}
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemParser.h Fri Oct 5 17:53:40 2007
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPTableItemParser.h
+
+ Author: Stefan Hundhammer <sh(a)suse.de>
+
+/-*/
+
+#ifndef YCPTableItemParser_h
+#define YCPTableItemParser_h
+
+#include <ycp/YCPTerm.h>
+#include "YCPTableItem.h"
+
+
+/**
+ * Parser for table item lists
+ **/
+class YCPTableItemParser
+{
+public:
+
+ /**
+ * Parse a table item list:
+ *
+ * [
+ * `item(`id(`myID1 ), "Label1", "Label2", "Label3" ),
+ * `item(`id(`myID1 ), "Label1", `cell("Label2"), "Label3" ),
+ * `item(`id(`myID2 ), "Label1", `cell(`icon( "icon2.png"), "Label2" ), "Label3" ),
+ * `item(`id(`myID2 ), "Label1", `cell( "Label2", `icon( "icon2.png")), "Label3" )
+ * ]
+ *
+ * Return a list of newly created YTableItem-derived objects.
+ *
+ * This function throws exceptions if there are syntax errors.
+ **/
+ static YItemCollection parseTableItemList( const YCPList & ycpItemList );
+
+
+protected:
+
+ /**
+ * Parse an item term:
+ *
+ * `item(`id(`myID1 ), "Label1", "Label2", "Label3" )
+ * `item(`id(`myID1 ), "Label1", `cell( "Label2" ), "Label3" )
+ * `item(`id(`myID2 ), "Label1", `cell(`icon( "icon2.png" ), "Label2" ), "Label3" )
+ * `item(`id(`myID2 ), "Label1", `cell( "Label2", `icon( "icon2.png")), "Label3" )
+ *
+ * `cell() is optional if there is only a label and no icon for that cell.
+ *
+ * This function throws exceptions if there are syntax errors.
+ **/
+ static YCPTableItem * parseTableItem( const YCPTerm & itemTerm );
+
+ /**
+ * Parse a cell term and add a YTableCell to the parent YCPTableItem:
+ *
+ * `cell( "Label" )
+ * `cell( `icon( "icon.png"), "Label" )
+ * `cell( "Label", `icon( "icon.png" ) )
+ **/
+ static void parseTableCell( YCPTableItem * parent, const YCPTerm & cellTerm );
+};
+
+
+#endif // YCPTableItemParser_h
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.cc (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.cc Fri Oct 5 17:53:40 2007
@@ -0,0 +1,88 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPTableItemWriter.cc
+
+ Author: Stefan Hundhammer <sh(a)suse.de>
+
+/-*/
+
+#include "ycp/YCPVoid.h"
+#include "YCPTableItemWriter.h"
+#include "YUISymbols.h"
+
+
+YCPList
+YCPTableItemWriter::itemList( YItemIterator begin, YItemIterator end )
+{
+ YCPList itemList;
+
+ for ( YItemIterator it = begin; it != end; ++it )
+ {
+ YTableItem * item = dynamic_cast<YTableItem *> (*it);
+
+ if ( item )
+ {
+ itemList->add( itemTerm( item ) );
+ }
+ }
+
+ return itemList;
+}
+
+
+YCPValue
+YCPTableItemWriter::itemTerm( const YTableItem * item )
+{
+ if ( ! item )
+ return YCPVoid();
+
+ YCPTerm itemTerm( YUISymbol_item ); // `item()
+
+ const YCPTableItem * ycpItem = dynamic_cast<const YCPTableItem *> (item);
+
+ if ( ycpItem && ycpItem->hasId() )
+ {
+ YCPTerm idTerm( YUISymbol_id ); // `id()
+ idTerm->add( ycpItem->id() );
+ }
+
+ for ( YTableCellConstIterator it = item->cellsBegin(); it != item->cellsEnd(); ++it )
+ itemTerm->add( cellValue( *it ) );
+
+ return itemTerm;
+}
+
+
+YCPValue
+YCPTableItemWriter::cellValue( const YTableCell * cell )
+{
+ if ( ! cell )
+ return YCPVoid();
+
+ if ( cell->hasIconName() )
+ {
+ YCPTerm iconTerm( YUISymbol_icon ); // `icon()
+ iconTerm->add( YCPString( cell->iconName() ) ); // `icon("myicon.png")
+
+ YCPTerm cellTerm( YUISymbol_cell ); // `cell()
+ cellTerm->add( iconTerm ); // `cell(`icon("myicon.png"))
+ cellTerm->add( YCPString( cell->label() ) ); // `cell(`icon("myicon.png"), "mylabel")
+
+ return cellTerm;
+ }
+ else // no icon
+ {
+ return YCPString( cell->label() ); // "mylabel"
+ }
+}
+
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTableItemWriter.h Fri Oct 5 17:53:40 2007
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPTableItemWriter.h
+
+ Author: Stefan Hundhammer <sh(a)suse.de>
+
+/-*/
+
+#ifndef YCPTableItemWriter_h
+#define YCPTableItemWriter_h
+
+#include <ycp/YCPList.h>
+#include <ycp/YCPTerm.h>
+#include <ycp/YCPValue.h>
+
+#include "YCPTableItem.h"
+
+
+/**
+ * Writer for table item lists
+ **/
+class YCPTableItemWriter
+{
+public:
+
+ /**
+ * Create a YCPList from a table item collection:
+ *
+ * [
+ * `item(`id(`myID1 ), "Label1", "Label2", "Label3" ),
+ * `item(`id(`myID1 ), "Label1", `cell("Label2"), "Label3" ),
+ * `item(`id(`myID2 ), "Label1", `cell(`icon( "icon2.png"), "Label2" ), "Label3" )
+ * `item(`id(`myID2 ), "Label1", `cell( "Label2", `icon( "icon2.png")), "Label3" )
+ * ]
+ **/
+ static YCPList itemList( YItemIterator begin, YItemIterator end );
+
+
+ /**
+ * Create a YCPTerm for one table item:
+ *
+ * `item(`id(`myID1 ), "Label1", "Label2", "Label3" )
+ * `item(`id(`myID1 ), "Label1", `cell( "Label2" ), "Label3" )
+ * `item(`id(`myID2 ), "Label1", `cell(`icon( "icon2.png" ), "Label2" ), "Label3" )
+ * `item(`id(`myID2 ), "Label1", `cell( "Label2", `icon( "icon2.png")), "Label3" )
+ *
+ * `cell() will be created only if a cell has an icon.
+ **/
+ static YCPValue itemTerm( const YTableItem * item );
+
+ /**
+ * Create a YCPValue for one table cell: A YCPString if a cell has only a
+ * label and no icon, and a YCPTerm with `cell() otherwise.
+ *
+ * "Label"
+ * `cell( `icon( "icon.png"), "Label" )
+ **/
+ static YCPValue cellValue( const YTableCell * cell );
+};
+
+
+#endif // YCPTableItemWriter_h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItemParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItemParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItemParser.cc Fri Oct 5 17:53:40 2007
@@ -51,12 +51,13 @@
while ( it != itemCollection.end() )
{
+ // Delete all items created so far
+
YItem * item = *it;
++it;
delete item;
}
- itemCollection.clear();
throw;
}
@@ -112,7 +113,7 @@
YCPBoolean isOpen = YCPNull();
YCPList subItemList = YCPNull();
- string usage =
+ const char * usage =
"Expected: `item(`id(`myID), `icon(\"MyIcon.png\"), \"MyItemText\", boolean isOpen, list subItemList )";
#if VERBOSE_PARSER
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YDialog.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YDialog.cc Fri Oct 5 17:53:40 2007
@@ -26,6 +26,9 @@
using std::string;
+#define VERBOSE_DIALOGS 0
+
+
std::stack<YDialog *> YDialog::_dialogStack;
@@ -43,13 +46,17 @@
_dialogStack.push( this );
+#if VERBOSE_DIALOGS
y2debug( "New YDialog at %p", this );
+#endif
}
YDialog::~YDialog()
{
+#if VERBOSE_DIALOGS
y2debug( "Destroying YDialog at %p", this );
+#endif
}
@@ -102,7 +109,10 @@
void YDialog::setInitialSize()
{
+#if VERBOSE_DIALOGS
y2debug( "Setting initial size for YDialog at %p", this );
+#endif
+
// Trigger geometry management
setSize( preferredWidth(), preferredHeight() );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc Fri Oct 5 17:53:40 2007
@@ -114,11 +114,11 @@
}
-string YSelectionWidget::iconFullPath( YItem * item ) const
+string YSelectionWidget::iconFullPath( const string & iconName ) const
{
string fullPath;
- if ( item && ! item->iconName().empty() )
+ if ( ! iconName.empty() )
{
if ( priv->iconBasePath.empty() ||
priv->iconBasePath[0] != '/' )
@@ -126,13 +126,22 @@
fullPath = YUI::yApp()->iconBasePath();
}
- fullPath += priv->iconBasePath + "/" + item->iconName();
+ fullPath += priv->iconBasePath + "/" + iconName;
}
return fullPath;
}
+string YSelectionWidget::iconFullPath( YItem * item ) const
+{
+ if ( item )
+ return iconFullPath( item->iconName() );
+ else
+ return "";
+}
+
+
void YSelectionWidget::addItem( YItem * item )
{
YUI_CHECK_PTR( item );
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.h Fri Oct 5 17:53:40 2007
@@ -214,6 +214,13 @@
string iconBasePath() const;
/**
+ * Return the full path + file name for the specified icon name.
+ *
+ * If 'iconName' is empty, this will return an empty string.
+ **/
+ string iconFullPath( const string & iconName ) const;
+
+ /**
* Return the full path + file name for the icon of the specified item.
*
* If 'item' does not have an iconName specified, this will return an empty
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc Fri Oct 5 17:53:40 2007
@@ -31,254 +31,190 @@
#include "YCPValueWidgetID.h"
-YTable::YTable( const YWidgetOpt & opt, int num_cols )
- : YWidget( opt )
- , num_cols( num_cols )
+struct YTablePrivate
{
+ YTablePrivate( int col )
+ : columns( col )
+ , keepSorting( false )
+ , immediateMode( false )
+ {
+ headers.resize( columns ); // Fill with empty strings (from default constructor)
+ alignments.resize( columns, YTable::Left );
+ }
+
+ int columns;
+ bool keepSorting;
+ bool immediateMode;
+ vector<string> headers;
+ vector<YTable::Alignment> alignments;
+};
+
+
+
+
+YTable::YTable( YWidget * parent, int columns )
+ : YSelectionWidget( parent,
+ "", // label
+ true ) // enforceSingleSelection
+ , priv( new YTablePrivate( columns ) )
+{
+ YUI_CHECK_NEW( priv );
+
setDefaultStretchable( YD_HORIZ, true );
setDefaultStretchable( YD_VERT, true );
}
-YCPValue YTable::changeWidget( const YCPSymbol & property,
- const YCPValue & newValue )
+YTable::~YTable()
{
- string s = property->symbol();
+ // NOP
+}
- /*
- * @property integer CurrentItem the ID of the currently selected item
- * Alias: Value
- */
- if ( s == YUIProperty_CurrentItem ||
- s == YUIProperty_Value ) // Sort for item with that id
- {
- int index = itemWithId( newValue, true ); // true: log error
- if ( index < 0 ) return YCPBoolean( false );
- else
- {
- setCurrentItem( index );
- return YCPBoolean( true );
- }
- }
- /*
- * @property list(item) Items a list of all table items
- */
- else if ( s == YUIProperty_Items ) // Change whole selection box!
- {
- if ( ! newValue->isList() )
- {
- y2warning( "Items property of Table widget must be a list" );
- return YCPBoolean( false );
- }
- OptimizeChanges below( *this ); // delay screen updates until this block is left
-
- itemsCleared();
- rows.clear();
- return YCPBoolean( addItems( newValue->asList() ) );
- }
- else return YWidget::changeWidget( property, newValue );
+int
+YTable::columns() const
+{
+ return priv->columns;
}
-
-YCPValue YTable::changeWidgetTerm( const YCPTerm & property, const YCPValue & newvalue )
+bool
+YTable::hasColumn( int column ) const
{
- string s = property->name();
- /*
- * @property item Item(id) read: a single item (string or term)
- * @property integer|string Item(id,column) write: replacement for one specific cell ( see example )
- */
- if ( s == YUIProperty_Item )
- {
- if ( property->size() != 2 || ! property->value(1)->isInteger() )
- {
- y2error( "Table %s: property `Item() needs two arguments: item id and column number",
- id()->toString().c_str() );
- return YCPBoolean( false );
- }
- YCPValue itemid = property->value(0);
- int item_nr = itemWithId( itemid, true );
- if ( item_nr < 0 ) return YCPBoolean( false );
-
- int colnum = (int)( property->value(1)->asInteger()->value() );
- if ( colnum >= numCols() || colnum < 0 )
- {
- y2error( "Table %s: Invalid column number %d",
- id()->toString().c_str(), colnum );
- return YCPBoolean( false );
- }
-
- string newtext;
- if ( newvalue->isString() ) newtext = newvalue->asString()->value();
- else if ( newvalue->isInteger() ) newtext = newvalue->asInteger()->toString();
- else
- {
- y2error( "Table %s: Invalid value for cell (%s|%d). Must be string or integer",
- id()->toString().c_str(), itemid->toString().c_str(), colnum );
- return YCPBoolean( false );
- }
-
- rows[ item_nr].elements[colnum ] = newtext;
- cellChanged( item_nr, colnum, YCPString( newtext ) );
- return YCPBoolean( true );
- }
- else return YWidget::changeWidgetTerm( property, newvalue );
+ return column >= 0 && column <= priv->columns;
}
-YCPValue YTable::queryWidget( const YCPSymbol & property )
+void
+YTable::setHeader( int column, const string & text )
{
- string s = property->symbol();
- if ( s == YUIProperty_CurrentItem ||
- s == YUIProperty_Value )
- {
- int index = getCurrentItem();
- // y2debug( "current item: %d", index );
- if ( index >= 0 ) return rows[ index ].id;
- else return YCPVoid();
- }
- else if ( s == YUIProperty_Items )
- {
- YCPList result;
- for ( int i = 0 ; i < numItems () ; i ++ )
- {
- result->add ( rows[ i ].makeTerm () );
- }
- return result;
- }
- else return YWidget::queryWidget( property );
+ if ( hasColumn( column ) )
+ priv->headers[ column ] = text;
}
-YCPValue YTable::queryWidgetTerm( const YCPTerm & property )
+string
+YTable::header( int column ) const
{
- string s = property->name();
- if ( s == YUIProperty_Item )
- {
- if ( property->size() != 1 )
- {
- y2error( "Table %s: property `Item() needs one argument",
- id()->toString().c_str() );
- return YCPVoid();
- }
- int item_nr = itemWithId( property->value(0), true );
- if ( item_nr < 0 ) return YCPVoid();
- else return rows[ item_nr ].makeTerm();
- }
- else return YWidget::queryWidgetTerm( property );
+ if ( hasColumn( column ) )
+ return priv->headers[ column ];
+ else
+ return "";
}
-/*
- * Insert a number of items.
- * Reimplemented in YQTable to keep QListView happy.
- */
-bool YTable::addItems( const YCPList & itemlist )
+void
+YTable::setAlignment( int column, YTable::Alignment alignment )
{
- for ( int i = 0; i < itemlist->size(); i++ )
- {
- YCPValue item = itemlist->value(i);
+ if ( hasColumn( column ) )
+ priv->alignments[ column ] = alignment;
+}
- if ( ! addItem( item ) )
- return false; // Error
- }
- return true; // Success
+YTable::Alignment
+YTable::alignment( int column ) const
+{
+ if ( hasColumn( column ) )
+ return priv->alignments[ column ];
+ else
+ return YTable::Left;
}
-bool YTable::addItem( const YCPValue & item )
+bool
+YTable::immediateMode() const
{
- if ( ! item->isTerm() || item->asTerm()->name() != YUISymbol_item )
- {
- y2error( "Invalid item specification %s: Must be `" YUISymbol_item "() term",
- item->toString().c_str() );
- return false;
- }
-
- YCPList collist = item->asTerm()->args();
- if ( collist->size() != numCols() + 1 )
- {
- y2error( "Invalid item specification %s: Wrong number of elements",
- item->toString().c_str() );
- return false;
- }
+ return priv->immediateMode;
+}
- if ( ! collist->value(0)->isTerm()
- || collist->value(0)->asTerm()->name() != YUISymbol_id
- || collist->value(0)->asTerm()->size() != 1)
- {
- y2error( "Invalid item specification %s: Must begin with `" YUISymbol_id "() term",
- item->toString().c_str() );
- return false;
- }
- YCPValue id = collist->value(0)->asTerm()->value(0);
+void
+YTable::setImmediateMode( bool immediateMode )
+{
+ priv->immediateMode = immediateMode;
- // Prepare stl vector of strings of the content
- vector<string> row;
- for ( int r=1; r< collist->size(); r++ )
- {
- YCPValue value = collist->value(r);
- if ( value->isString() ) row.push_back( value->asString()->value() );
- else if ( value->isInteger() ) row.push_back( value->toString() );
- else if ( value->isVoid() ) row.push_back( "" );
- else
- {
- y2error( "Invalid value %s in item. Must be string, integer or void",
- value->toString().c_str() );
- row.push_back( "" );
- }
- }
- addItem( id, row );
- return true;
+ if ( immediateMode )
+ setNotify( true );
}
-
-void YTable::addItem( const YCPValue & id, vector<string> elements )
+bool
+YTable::keepSorting() const
{
- rows.push_back( YTableRow( id, elements ) );
- itemAdded( elements, rows.size() - 1 );
+ return priv->keepSorting;
}
-
-int YTable::numItems() const
+void
+YTable::setKeepSorting( bool keepSorting )
{
- return rows.size();
+ priv->keepSorting = keepSorting;
}
-int YTable::itemWithId( const YCPValue & id, bool report_error )
+
+const YPropertySet &
+YTable::propertySet()
{
- for ( int i=0; i<numItems(); i++ )
+ static YPropertySet propSet;
+
+ if ( propSet.isEmpty() )
{
- if ( rows[i].id->equal( id ) ) return i;
+ /*
+ * @property itemID Value The currently selected item
+ * @property itemID CurrentItem The currently selected item
+ * @property itemList Items All items
+ * @property string Cell One cell (one column of one item)
+ * @property integer Cell (ChangeWidget only) One cell as integer
+ * @property `icon(...) Cell Icon for one one cell
+ * @property string Item Alias for Cell
+ * @property string Item QueryWidget only: Return one complete item
+ */
+ propSet.add( YProperty( YUIProperty_Value, YOtherProperty ) );
+ propSet.add( YProperty( YUIProperty_CurrentItem, YOtherProperty ) );
+ propSet.add( YProperty( YUIProperty_Items, YOtherProperty ) );
+ propSet.add( YProperty( YUIProperty_Cell, YOtherProperty ) );
+ propSet.add( YProperty( YUIProperty_Item, YOtherProperty ) );
+ propSet.add( YWidget::propertySet() );
}
- if ( report_error )
- y2error( "Table: No item %s existing", id->toString().c_str() );
- return -1;
+ return propSet;
}
-int YTable::numCols() const
+
+bool
+YTable::setProperty( const string & propertyName, const YPropertyValue & val )
{
- return num_cols;
+ propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
+
+ if ( propertyName == YUIProperty_Value ) return false; // Needs special handling
+ else if ( propertyName == YUIProperty_CurrentItem ) return false; // Needs special handling
+ else if ( propertyName == YUIProperty_Items ) return false; // Needs special handling
+ else if ( propertyName == YUIProperty_Cell ) return false; // Needs special handling
+ else if ( propertyName == YUIProperty_Item ) return false; // Needs special handling
+ else
+ {
+ return YWidget::setProperty( propertyName, val );
+ }
+
+ return true; // success -- no special processing necessary
}
-YCPTerm YTableRow::makeTerm() const
+YPropertyValue
+YTable::getProperty( const string & propertyName )
{
- // Return the item as term
- YCPTerm itemterm( YUISymbol_item );
- YCPTerm idterm( YUISymbol_id );
- idterm->add( id );
- itemterm->add( idterm );
- for ( unsigned int c=0; c < elements.size(); c++ )
- itemterm->add( YCPString( elements[c] ) );
- return itemterm;
+ propertySet().check( propertyName ); // throws exceptions if not found
+
+ if ( propertyName == YUIProperty_Value ) return YPropertyValue( YOtherProperty );
+ else if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( YOtherProperty );
+ else if ( propertyName == YUIProperty_Items ) return YPropertyValue( YOtherProperty );
+ else if ( propertyName == YUIProperty_Cell ) return YPropertyValue( YOtherProperty );
+ else if ( propertyName == YUIProperty_Item ) return YPropertyValue( YOtherProperty );
+ else
+ {
+ return YWidget::getProperty( propertyName );
+ }
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTable.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTable.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTable.h Fri Oct 5 17:53:40 2007
@@ -19,156 +19,183 @@
#ifndef YTable_h
#define YTable_h
-#include "YWidget.h"
-#include <ycp/YCPString.h>
-#include <ycp/YCPList.h>
+#include "YSelectionWidget.h"
+#include "YTableItem.h"
+
class YMacroRecorder;
+class YTablePrivate;
+
+using std::string;
/**
- * @short helper class for the table widget: one single table row
+ * Table: Selection list with multiple columns. The user can select exactly one
+ * row (with all its columns) from that list. Each cell (each column within
+ * each row) has a label text and an optional icon (*).
+ *
+ * This widget is similar to SelectionBox, but it has several columns for each
+ * item (each row). If just one column is desired, consider using SelectionBox
+ * instead.
+ *
+ * Note: This is not something like a spread sheet, and it doesn't pretend or
+ * want to be. Actions are performed on rows, not on individual cells (columns
+ * within one row).
+ *
+ *
+ * (*) Not all UIs (in particular not text-based UIs) support displaying icons,
+ * so an icon should never be an exclusive means to display any kind of
+ * information.
**/
-class YTableRow
+class YTable : public YSelectionWidget
{
- YCPValue id;
- vector<string> elements;
- YTableRow( YCPValue id, vector<string> elements )
- : id( id ), elements( elements ) {};
- friend class YTable;
-
+protected:
/**
- * Construct a `item( `id( .. ), "asdf", "asdf", ... ) term
+ * Constructor. 'columns' is the number of columns to be created.
**/
- YCPTerm makeTerm() const;
-};
-
+ YTable( YWidget * parent, int columns );
+public:
-/**
- * @short the table widget
- **/
-class YTable : public YWidget
-{
-protected:
/**
- * Creates a new and empty Table
- * @param num_cols The number of columns of the table
+ * Destructor.
**/
- YTable( const YWidgetOpt & opt, int num_cols );
+ virtual ~YTable();
-public:
/**
- * Returns a descriptive name of this widget class for logging,
+ * Return a descriptive name of this widget class for logging,
* debugging etc.
**/
virtual const char * widgetClass() const { return "YTable"; }
/**
- * Adds an item to the table that is given as term
- * yet to be parsed.
+ * Return the number of coluns of this table.
+ * Note that this can only be set in the constructor.
**/
- bool addItem( const YCPValue & item );
+ int columns() const;
/**
- * Adds a list of items to the table. The list
- * contains item specifications yet to be parsed.
+ * Return 'true' if this table has 'column' columns.
**/
- virtual bool addItems( const YCPList & itemlist );
+ bool hasColumn( int column ) const;
/**
- * Adds an item to the table.
+ * Set the header text for the specified column (counting from 0 on).
+ *
+ * Derived classes can overwrite this function, but they should call this
+ * base class function in the new implementation.
**/
- void addItem( const YCPValue & id, vector<string> elements );
+ virtual void setHeader( int column, const string & text );
/**
- * Implements the ui command changeWidget.
+ * Return the header text for the specified column.
**/
- YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue );
+ string header( int column ) const;
- /**
- * Implements the ui command changeWidget with property given as term.
- **/
- YCPValue changeWidgetTerm( const YCPTerm & property, const YCPValue & newvalue );
+ enum Alignment
+ {
+ Left,
+ Center,
+ Right
+ };
/**
- * Implements the ui command queryWidget
+ * Set the alignment for the specified column (counting from 0 on):
+ * YTable::Left, YTable::Center, YTable::Right
+ *
+ * Derived classes can overwrite this function, but they should call this
+ * base class function in the new implementation.
**/
- YCPValue queryWidget( const YCPSymbol & property );
+ virtual void setAlignment( int column, YTable::Alignment alignment );
/**
- * Implements the ui command queryWidget with property given as term.
+ * Return the alignment for the specified column.
**/
- YCPValue queryWidgetTerm( const YCPTerm & property );
+ YTable::Alignment alignment( int column ) const;
/**
- * Returns the number of columns of the table.
- **/
- int numCols() const;
-
- /**
- * The name of the widget property that will return user input.
- * Inherited from YWidget.
- **/
- const char *userInputProperty() { return YUIProperty_CurrentItem; }
-
-
-protected:
- /**
- * Called when an item (a row) has been added. Overload this to
- * fill the ui specific widget with items.
- * @param elements the strings of the elements, one for each column.
- * @param index index of the new item.
+ * Deliver even more events than with notify() set.
+ *
+ * With "notify" alone, a table widget sends an ActivatedEvent when the
+ * user double-clicks an item or presses the "space" key on it. It does not
+ * send an event when the user just sends another item.
+ *
+ * With "immediate", it also sends a SelectionChangedEvent when the user
+ * selects another item. "immediate" implicitly includes "notify".
**/
- virtual void itemAdded( vector<string> elements, int index ) = 0;
+ bool immediateMode() const;
/**
- * Is called, when all items have been cleared. Overload this
- * and clear the ui specific table.
+ * Set immediateMode() on or off.
**/
- virtual void itemsCleared() = 0;
+ void setImmediateMode( bool immediateMode = true );
/**
- * Is called, when the contents of a cell has been changed. Overload
- * this and change the cell text.
+ * Return 'true' if the sort order is to be kept in item insertion order,
+ * i.e. if sorting the table by clicking on a column header should be
+ * disabled.
**/
- virtual void cellChanged( int index, int colnum, const YCPString & newtext ) = 0;
+ bool keepSorting() const;
/**
- * Returns the index of the currently
- * selected item or -1 if no item is selected.
+ * Switch between sorting by item insertion order (keepSorting: true) or
+ * allowing the user to sort by an arbitrary column (by clicking on the
+ * column header).
+ *
+ * Derived classes can overwrite this function, but they should call this
+ * base class function in the new implementation.
**/
- virtual int getCurrentItem() = 0;
+ virtual void setKeepSorting( bool keepSorting );
/**
- * Makes another item the selected one.
+ * Notification that a cell (its text and/or its icon) was changed from the
+ * outside. Applications are required to call this whenever a table cell is
+ * changed after adding the corresponding table item (the row) to the table
+ * widget.
+ *
+ * Derived classes are required to implement this and update the display
+ * accordingly.
+ *
+ * Note that the position of this cell can be retrieved with cell->column()
+ * and cell->itemIndex().
**/
- virtual void setCurrentItem( int index ) = 0;
-
+ virtual void cellChanged( const YTableCell * cell ) = 0;
-protected:
/**
- * The current data in the table
+ * Set a property.
+ * Reimplemented from YWidget.
+ *
+ * This function may throw YUIPropertyExceptions.
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- vector<YTableRow> rows;
+ virtual bool setProperty( const string & propertyName,
+ const YPropertyValue & val );
/**
- * The number of columns of the table
+ * Get a property.
+ * Reimplemented from YWidget.
+ *
+ * This method may throw YUIPropertyExceptions.
**/
- int num_cols;
+ virtual YPropertyValue getProperty( const string & propertyName );
/**
- * Returns the current number of items
+ * Return this class's property set.
+ * This also initializes the property upon the first call.
+ *
+ * Reimplemented from YWidget.
**/
- int numItems() const;
+ virtual const YPropertySet & propertySet();
+
/**
- * Searches for an item with a certain id or a certain label.
- * Returns the index of the found item or -1 if none was found
- * @param report_error set this to true, if you want me to
- * report an error if non item can be found.
+ * The name of the widget property that will return user input.
+ * Inherited from YWidget.
**/
- int itemWithId( const YCPValue & id, bool report_error );
+ const char *userInputProperty() { return YUIProperty_CurrentItem; }
private:
@@ -179,6 +206,9 @@
* handled by the abstract libyui level, not by a specific UI.
**/
virtual void saveUserInput( YMacroRecorder *macroRecorder );
+
+
+ ImplPtr<YTablePrivate> priv;
};
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.cc Fri Oct 5 17:53:40 2007
@@ -102,6 +102,8 @@
{
YUI_CHECK_PTR( cell );
_cells.push_back( cell );
+
+ cell->reparent( this, _cells.size() - 1 );
}
@@ -111,7 +113,14 @@
YTableCell * cell = new YTableCell( label, iconName );
YUI_CHECK_NEW( cell );
- _cells.push_back( cell );
+ addCell( cell );
+}
+
+
+bool
+YTableItem::hasCell( int index ) const
+{
+ return index >= 0 && (unsigned) index < _cells.size();
}
@@ -123,6 +132,14 @@
}
+YTableCell *
+YTableItem::cell( int index )
+{
+ return hasCell( index ) ?
+ _cells[ index ] : 0;
+}
+
+
string
YTableItem::label( int index ) const
{
@@ -142,3 +159,19 @@
{
return hasCell( index ) ? _cells[ index ]->hasIconName() : false;
}
+
+
+
+
+
+void YTableCell::reparent( YTableItem * parent, int column )
+{
+ YUI_CHECK_PTR( parent );
+
+ if ( _parent && _parent != parent && column != column )
+ YUI_THROW( YUIException( string( "Cannot reparent YTableCell \"" )
+ + _label
+ + "to different parent." ) );
+ _parent = parent;
+ _column = column;
+}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTableItem.h Fri Oct 5 17:53:40 2007
@@ -90,7 +90,12 @@
/**
* Add a cell. This item will assume ownership over the cell and delete it
- * when appropriate.
+ * when appropriate (when the table is destroyed or when table items are
+ * replaced), at which time the pointer will become invalid.
+ *
+ * Cells can still be changed after they (and the item they belong to) are
+ * added, but in that case, YTable::cellChanged() needs to be called to
+ * update the table display accordingly.
**/
void addCell( YTableCell * cell );
@@ -122,6 +127,7 @@
* or 0 if there is none.
**/
const YTableCell * cell( int index ) const;
+ YTableCell * cell( int index );
/**
* Return the number of cells this item has.
@@ -132,8 +138,7 @@
* Return 'true' if this item has a cell with the specified index
* (counting from 0 on), 'false' otherwise.
**/
- bool hasCell( int index ) const
- { return index >= 0 && (unsigned) index < _cells.size(); }
+ bool hasCell( int index ) const;
/**
* Return the label of cell no. 'index' (counting from 0 on) or an empty
@@ -168,13 +173,17 @@
**/
void * data() const { return _data; }
+ /**
+ * Just for debugging.
+ **/
+ string label() const { return label(0); }
+
private:
// Disable unwanted base class methods. They don't make sense in this
// context since there is not just one single label or icon name, but one
// for each cell.
- string label() const { return ""; }
string iconName() const { return ""; }
bool hasIconName() const { return false; }
void setLabel ( const string & ) {}
@@ -201,7 +210,7 @@
* these classes make no such assumptions. A YTableItem might have any number
* of cells, including none.
*
- * The YTable widget, is free to ignore any excess cells if there are more than
+ * The YTable widget is free to ignore any excess cells if there are more than
* the YTable widget has columns. If there are less cells than the table has
* columns, the nonexistent cells will be treated as empty.
*
@@ -216,11 +225,29 @@
{
public:
/**
- * Constructor with label and icon name and optionally the selected state.
+ * Constructor with label and optional icon name for cells that don't have
+ * a parent item yet (that will be added to a parent later with
+ * setParent()).
**/
YTableCell( const string & label, const string & iconName = "" )
: _label( label )
, _iconName( iconName )
+ , _parent( 0 )
+ , _column ( -1 )
+ {}
+
+ /**
+ * Constructor with parent, column no., label and optional icon name for
+ * cells that are created with a parent.
+ **/
+ YTableCell( YTableItem * parent,
+ int column,
+ const string & label,
+ const string & iconName = "" )
+ : _label( label )
+ , _iconName( iconName )
+ , _parent( parent )
+ , _column ( column )
{}
// No virtual destructor. This saves a vtable for this class since there
@@ -234,6 +261,10 @@
/**
* Set this cell's label.
+ *
+ * If this is called after the corresponding table item (table row) is
+ * added to the table widget, call YTable::cellChanged() to notify the
+ * table widget about the fact. Only then will the display be updated.
**/
void setLabel( const string & newLabel ) { _label = newLabel; }
@@ -249,16 +280,47 @@
/**
* Set this cell's icon name.
+ *
+ * If this is called after the corresponding table item (table row) is
+ * added to the table widget, call YTable::cellChanged() to notify the
+ * table widget about the fact. Only then will the display be updated.
**/
void setIconName( const string & newIconName ) { _iconName = newIconName; }
+ /**
+ * Return this cell's parent item or 0 if it doesn't have one yet.
+ **/
+ YTableItem * parent() const { return _parent; }
+
+ /**
+ * Return this cell's column no. (counting from 0on) or -1 if it doesn't
+ * have a parent yet.
+ **/
+ int column() const { return _column; }
+
+ /**
+ * Convenience function: Return this cell's parent item's index within its
+ * table widget or -1 if there is no parent item or no parent table.
+ **/
+ int itemIndex() const { return _parent ? _parent->index() : -1; }
+
+ /**
+ * Set this cell's parent item and column no. if it doesn't have a parent
+ * yet.
+ *
+ * This method will throw an exception if the cell already has a parent.
+ **/
+ void reparent( YTableItem * parent, int column );
+
private:
- string _label;
- string _iconName;
+ string _label;
+ string _iconName;
+ YTableItem * _parent;
+ int _column;
};
-#endif // YTableItem_h
+ #endif // YTableItem_h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Fri Oct 5 17:53:40 2007
@@ -455,7 +455,6 @@
virtual YDialog *createDialog( YWidgetOpt & opt ) = 0;
virtual YWidget *createLogView( YWidget *parent, YWidgetOpt & opt, const YCPString & label, int visibleLines, int maxLines ) = 0;
virtual YWidget *createMenuButton( YWidget *parent, YWidgetOpt & opt, const YCPString & label ) = 0;
- virtual YWidget *createTable( YWidget *parent, YWidgetOpt & opt, vector<string> header ) = 0;
virtual YWidget *createIntField( YWidget *parent, YWidgetOpt & opt, const YCPString & label, int minValue, int maxValue, int initialValue ) = 0;
// FIXME: Obsolete
// FIXME: Obsolete
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h Fri Oct 5 17:53:40 2007
@@ -85,20 +85,20 @@
* Drops a log line and throws the YUIException.
**/
#define YUI_THROW( EXCEPTION ) \
- _YUI_THROW( EXCEPTION, YUI_EXCEPTION_CODE_LOCATION )
+ _YUI_THROW( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION )
/**
* Drops a log line telling the YUIException was caught and handled.
**/
#define YUI_CAUGHT( EXCEPTION ) \
- _YUI_CAUGHT( EXCEPTION, YUI_EXCEPTION_CODE_LOCATION )
+ _YUI_CAUGHT( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION )
/**
* Drops a log line and rethrows, updating the YCodeLocation.
**/
#define YUI_RETHROW( EXCEPTION ) \
- _YUI_RETHROW( EXCEPTION, YUI_EXCEPTION_CODE_LOCATION )
+ _YUI_RETHROW( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION )
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h Fri Oct 5 17:53:40 2007
@@ -145,6 +145,7 @@
// Widget properties
+#define YUIProperty_Cell "Cell"
#define YUIProperty_CurrentButton "CurrentButton"
#define YUIProperty_CurrentBranch "CurrentBranch"
#define YUIProperty_CurrentItem "CurrentItem"
@@ -283,6 +284,7 @@
#define YUISymbol_opt "opt"
#define YUISymbol_icon "icon"
#define YUISymbol_item "item"
+#define YUISymbol_cell "cell"
#define YUISymbol_menu "menu"
#define YUISymbol_header "header"
#define YUISymbol_rgb "rgb"
@@ -292,5 +294,9 @@
#define YUISymbol_bottomMargin "bottomMargin"
#define YUISymbol_BackgroundPixmap "BackgroundPixmap"
+#define YUISymbol_Left "Left"
+#define YUISymbol_Right "Right"
+#define YUISymbol_Center "Center"
+
#endif // YUISymbols_h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src…
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc Fri Oct 5 17:53:40 2007
@@ -991,31 +991,33 @@
if ( ! widget )
return YCPVoid();
- if ( property->isSymbol() )
- {
- YPropertySet propSet = widget->propertySet();
- YCPSymbol sym = property->asSymbol();
+ YPropertySet propSet = widget->propertySet();
- if ( propSet.size() == 5 ) // unchanged from YWidget, no properties supported
+ if ( propSet.size() == 5 ) // unchanged from YWidget, no properties supported
+ {
+ if ( property->isSymbol() )
{
// FIXME: Get rid of this
// FIXME: Get rid of this
// FIXME: Get rid of this
+ YCPSymbol sym = property->asSymbol();
y2debug( "Old style UI::QueryWidget() for %s::%s",
widget->widgetClass(), sym->symbol().c_str() );
- return widget->queryWidget( property->asSymbol() );
- // FIXME: Get rid of this
- // FIXME: Get rid of this
- // FIXME: Get rid of this
+ return widget->queryWidget( sym );
+ // FIXME: Get rid of this
+ // FIXME: Get rid of this
+ // FIXME: Get rid of this
}
- else
- {
- // y2debug( "New style UI::QueryWidget() for %s::%s", widget->widgetClass(), sym->symbol().c_str() );
-
- string propertyName = sym->symbol();
+ }
+ else
+ {
+ // y2debug( "New style UI::QueryWidget() for %s::%s", widget->widgetClass(), sym->symbol().c_str() );
- try
+ try
+ {
+ if ( property->isSymbol() ) // The normal case: UI::QueryWidget(`myWidget, `SomeProperty)
{
+ string propertyName = property->asSymbol()->symbol();
YPropertyValue val = widget->getProperty( propertyName );
switch ( val.type() )
@@ -1026,25 +1028,31 @@
case YOtherProperty: return YCPPropertyHandler::getComplexProperty( widget, propertyName );
default:
- y2error( "Unknown result for setProperty( %s )", sym->symbol().c_str() );
+ y2error( "Unknown result for setProperty( %s )", propertyName.c_str() );
return YCPVoid();
}
}
- catch( YUIException & exception )
+ else if ( property->isTerm() ) // Very rare: UI::QueryWidget(`myTable, `Item("abc", 3) )
{
- YUI_CAUGHT( exception );
- ycperror( "UI::QueryWidget() failed for property %s of %s with ID %s",
- property->toString().c_str(),
- widget->widgetClass(),
- id->toString().c_str() );
-
- return YCPVoid();
+ return YCPPropertyHandler::getComplexProperty( widget, property->asTerm() );
+ }
+ else
+ {
+ YUI_THROW( YUIException( "Bad QueryWidget args" ) );
}
}
+ catch( YUIException & exception )
+ {
+ YUI_CAUGHT( exception );
+ ycperror( "UI::QueryWidget() failed for property %s of %s with ID %s",
+ property->toString().c_str(),
+ widget->widgetClass(),
+ id->toString().c_str() );
+ }
}
- else
- return widget->queryWidgetTerm( property->asTerm() );
+
+ return YCPVoid();
}
@@ -1094,7 +1102,7 @@
if ( ! child->hasParent() )
child->setParent( replacePoint );
-
+
replacePoint->showChild();
#if VERBOSE_REPLACE_WIDGET
Modified: branches/tmp/sh/mod-ui/qt/src/QY2ListView.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/QY2ListV…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/QY2ListView.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/QY2ListView.cc Fri Oct 5 17:53:40 2007
@@ -30,6 +30,7 @@
, _mousePressedItem(0)
, _mousePressedCol( -1 )
, _mousePressedButton( NoButton )
+ , _sortByInsertionSequence( false )
, _nextSerial(0)
, _mouseButton1PressedInHeader( false )
, _finalSizeChangeExpected( false )
@@ -233,7 +234,7 @@
if ( item && item->isEnabled() )
{
int col = header()->sectionAt( ev->pos().x() );
- emit( columnDoubleClicked( ev->button(), ( QY2ListViewItem * ) item, col, ev->globalPos() ) );
+ emit( columnDoubleClicked( ev->button(), (QY2ListViewItem *) item, col, ev->globalPos() ) );
}
// invalidate last click data
@@ -310,25 +311,29 @@
}
+bool
+QY2ListView::setSortByInsertionSequence( bool sortByInsertionSequence )
+{
+ _sortByInsertionSequence = sortByInsertionSequence;
+ sort();
+}
+
+
QY2ListViewItem::QY2ListViewItem( QY2ListView * parentListView,
- const QString & text,
- bool sortByInsertionSequence )
+ const QString & text )
: QListViewItem( parentListView, text )
- , _sortByInsertionSequence( sortByInsertionSequence )
{
_serial = parentListView->nextSerial();
}
QY2ListViewItem::QY2ListViewItem( QListViewItem * parentItem,
- const QString & text,
- bool sortByInsertionSequence )
+ const QString & text )
: QListViewItem( parentItem, text )
- , _sortByInsertionSequence( sortByInsertionSequence )
{
_serial = 0;
@@ -357,7 +362,13 @@
int col,
bool ascending ) const
{
- if ( sortByInsertionSequence() )
+ bool sortByInsertionSequence = false;
+ QY2ListView * parentListView = dynamic_cast<QY2ListView *> (listView());
+
+ if ( parentListView )
+ sortByInsertionSequence = parentListView->sortByInsertionSequence();
+
+ if ( sortByInsertionSequence )
{
QY2ListViewItem * other = dynamic_cast<QY2ListViewItem *> (otherListViewItem);
@@ -407,53 +418,36 @@
QY2CheckListItem::QY2CheckListItem( QY2ListView * parentListView,
const QString & text,
- QCheckListItem::Type type,
- bool sortByInsertionSequence )
+ QCheckListItem::Type type )
: QCheckListItem( parentListView, text, type )
- , _sortByInsertionSequence( sortByInsertionSequence )
{
- _serial = 0;
-
- if ( _sortByInsertionSequence )
- _serial = parentListView->nextSerial();
+ _serial = parentListView->nextSerial();
}
QY2CheckListItem::QY2CheckListItem( QListViewItem * parentItem,
const QString & text,
- QCheckListItem::Type type,
- bool sortByInsertionSequence )
+ QCheckListItem::Type type )
: QCheckListItem( parentItem, text, type )
- , _sortByInsertionSequence( sortByInsertionSequence )
{
_serial = 0;
+ QY2ListView * parentListView = dynamic_cast<QY2ListView *> ( listView() );
- if ( _sortByInsertionSequence )
- {
- QY2ListView * parentListView = dynamic_cast<QY2ListView *> ( listView() );
-
- if ( parentListView )
- _serial = parentListView->nextSerial();
- }
+ if ( parentListView )
+ _serial = parentListView->nextSerial();
}
QY2CheckListItem::QY2CheckListItem( QCheckListItem * parentItem,
const QString & text,
- QCheckListItem::Type type,
- bool sortByInsertionSequence )
+ QCheckListItem::Type type )
: QCheckListItem( parentItem, text, type )
- , _sortByInsertionSequence( sortByInsertionSequence )
{
_serial = 0;
+ QY2ListView * parentListView = dynamic_cast<QY2ListView *> ( listView() );
- if ( _sortByInsertionSequence )
- {
- QY2ListView * parentListView = dynamic_cast<QY2ListView *> ( listView() );
-
- if ( parentListView )
- _serial = parentListView->nextSerial();
- }
+ if ( parentListView )
+ _serial = parentListView->nextSerial();
}
@@ -475,7 +469,13 @@
int col,
bool ascending ) const
{
- if ( sortByInsertionSequence() )
+ bool sortByInsertionSequence = false;
+ QY2ListView * parentListView = dynamic_cast<QY2ListView *> (listView());
+
+ if ( parentListView )
+ sortByInsertionSequence = parentListView->sortByInsertionSequence();
+
+ if ( sortByInsertionSequence )
{
QY2CheckListItem * other = dynamic_cast<QY2CheckListItem *> (otherListViewItem);
Modified: branches/tmp/sh/mod-ui/qt/src/QY2ListView.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/QY2ListV…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/QY2ListView.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/QY2ListView.h Fri Oct 5 17:53:40 2007
@@ -128,6 +128,19 @@
virtual QString toolTip( QListViewItem * item, int column );
/**
+ * Returns 'true' if the sort order should always be the item insertion
+ * order, 'false' if the user can change the sort order by clicking on a
+ * column header.
+ **/
+ bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
+
+ /**
+ * Enforce sorting by item insertion order (true) or let user change
+ * sorting by clicking on a column header (false).
+ **/
+ virtual bool setSortByInsertionSequence( bool sortByInsertionSequence );
+
+ /**
* Returns the next free serial number for items that want to be ordered in
* insertion sequence.
**/
@@ -184,6 +197,7 @@
int _mousePressedButton;
std::vector<int> _savedColumnWidth;
+ bool _sortByInsertionSequence;
int _nextSerial;
QY2ListViewToolTip * _toolTip;
@@ -202,26 +216,16 @@
/**
* Constructor for toplevel items.
- *
- * 'sortByInsertionSequence' indicates if this item keeps the insertion
- * order ( true ) or leaves sorting to the user ( false - sort-by-click on
- * column headers ).
- **/
- QY2ListViewItem( QY2ListView * parentListView,
- const QString & text = QString::null,
- bool sortByInsertionSequence = false );
+ **/
+ QY2ListViewItem( QY2ListView * parentListView,
+ const QString & text = QString::null );
/**
* Constructor for deeper level items.
- *
- * 'sortByInsertionSequence' indicates if this item keeps the insertion
- * order ( true ) or leaves sorting to the user ( false - sort-by-click on
- * column headers ).
- **/
- QY2ListViewItem( QListViewItem * parentItem,
- const QString & text = QString::null,
- bool sortByInsertionSequence = false );
+ **/
+ QY2ListViewItem( QListViewItem * parentItem,
+ const QString & text = QString::null );
/**
* Destructor
@@ -264,18 +268,6 @@
int serial() const { return _serial; }
/**
- * Returns true if this item sorts itself by insertion sequence.
- **/
- bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
-
- /**
- * Set sort policy: 'true' to sort by insertion sequence, 'false' for user
- * sort-by-click on column headers.
- **/
- void setSortByInsertionSequence( bool doit )
- { _sortByInsertionSequence = doit; }
-
- /**
* Set the text foreground color for all columns.
* For more specific purposes reimiplement paintCell().
**/
@@ -317,7 +309,6 @@
//
int _serial;
- bool _sortByInsertionSequence;
QColor _textColor;
QColor _backgroundColor;
@@ -334,41 +325,26 @@
/**
* Constructor for toplevel items.
- *
- * 'sortByInsertionSequence' indicates if this item keeps the insertion
- * order ( true ) or leaves sorting to the user ( false - sort-by-click on
- * column headers ).
**/
QY2CheckListItem( QY2ListView * parentListView,
const QString & text,
- QCheckListItem::Type type,
- bool sortByInsertionSequence = false );
+ QCheckListItem::Type type );
/**
* Constructor for deeper level items.
- *
- * 'sortByInsertionSequence' indicates if this item keeps the insertion
- * order ( true ) or leaves sorting to the user ( false - sort-by-click on
- * column headers ).
**/
QY2CheckListItem( QListViewItem * parentItem,
const QString & text,
- QCheckListItem::Type type,
- bool sortByInsertionSequence = false );
+ QCheckListItem::Type type );
/**
* Constructor for deeper level items for QCheckListItem parents.
- *
- * 'sortByInsertionSequence' indicates if this item keeps the insertion
- * order ( true ) or leaves sorting to the user ( false - sort-by-click on
- * column headers ).
**/
QY2CheckListItem( QCheckListItem * parentItem,
const QString & text,
- QCheckListItem::Type type,
- bool sortByInsertionSequence = false );
+ QCheckListItem::Type type );
/**
* Destructor
@@ -411,18 +387,6 @@
int serial() const { return _serial; }
/**
- * Returns true if this item sorts itself by insertion sequence.
- **/
- bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
-
- /**
- * Set sort policy: 'true' to sort by insertion sequence, 'false' for user
- * sort-by-click on column headers.
- **/
- void setSortByInsertionSequence( bool doit )
- { _sortByInsertionSequence = doit; }
-
- /**
* Set the text foreground color for all columns.
* For more specific purposes reimiplement paintCell().
**/
@@ -464,7 +428,6 @@
//
int _serial;
- bool _sortByInsertionSequence;
QColor _textColor;
QColor _backgroundColor;
@@ -501,11 +464,11 @@
**/
virtual void maybeTip( const QPoint & p );
-
+
//
// Data members
//
-
+
QY2ListView * _listView;
};
Modified: branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQSelect…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.h Fri Oct 5 17:53:40 2007
@@ -117,7 +117,9 @@
virtual bool setKeyboardFocus();
/**
- * Event filter - inherited from QWidget
+ * Event filter.
+ *
+ * Reimplemented from QWidget.
**/
bool eventFilter( QObject * obj, QEvent * ev );
Modified: branches/tmp/sh/mod-ui/qt/src/YQTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTable.…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTable.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTable.cc Fri Oct 5 17:53:40 2007
@@ -16,8 +16,6 @@
/-*/
-#include <qstring.h>
-#include <qlistview.h>
#include <qheader.h>
#define y2log_component "qt-ui"
#include <ycp/y2log.h>
@@ -25,264 +23,313 @@
#include "utf8.h"
#include "YQUI.h"
#include "YEvent.h"
-#include "YQTable.h"
#include "YQSignalBlocker.h"
+#include "YUIException.h"
+#include "QY2ListView.h"
+#include "YQTable.h"
-class YQListViewItem : public QListViewItem
+YQTable::YQTable( YWidget * parent,
+ int columns )
+ : QVBox( (QWidget *) parent->widgetRep() )
+ , YTable( parent, columns )
{
-public:
-
- int index;
+ setWidgetRep( this );
+ setMargin( YQWidgetMargin );
- /**
- * Constructor for auto-sorting
- **/
- YQListViewItem( YQTable * table,
- QListView * list_view,
- int index );
+ _qt_listView = new QY2ListView( this );
+ YUI_CHECK_NEW( _qt_listView );
- /**
- * Constructor for maintaining insertion order.
- * 'after' is the item this one is to be inserted after.
- **/
- YQListViewItem( YQTable * table,
- QListView * list_view,
- YQListViewItem * after,
- int index );
+ for ( int i=0; i < columns; i++ )
+ _qt_listView->addColumn( "" ); // Headers are not known yet
-protected:
+ _qt_listView->setAllColumnsShowFocus( true );
- YQTable * table;
-};
+ connect( _qt_listView, SIGNAL( doubleClicked ( QListViewItem * ) ),
+ this, SLOT ( slotActivated ( QListViewItem * ) ) );
+ connect( _qt_listView, SIGNAL( spacePressed ( QListViewItem * ) ),
+ this, SLOT ( slotActivated ( QListViewItem * ) ) );
-YQListViewItem::YQListViewItem( YQTable * table,
- QListView * list_view,
- int index )
- : QListViewItem( list_view )
- , index( index )
- , table( table )
-{
+ connect( _qt_listView, SIGNAL( selectionChanged ( QListViewItem * ) ),
+ this, SLOT ( slotSelected ( QListViewItem * ) ) );
}
-YQListViewItem::YQListViewItem( YQTable * table,
- QListView * list_view,
- YQListViewItem * after,
- int index )
- : QListViewItem( list_view, after )
- , index( index )
- , table( table )
+YQTable::~YQTable()
{
+ // NOP
}
-YQTable::YQTable( QWidget * parent,
- const YWidgetOpt & opt,
- vector<string> header )
- : QVBox( parent )
- , YTable( opt, header.size() )
- , _last_item(0)
+void
+YQTable::setHeader( int column, const string & text )
{
- _sort_by_insertion_order = true;
- _enable_user_sort = ! opt.keepSorting.value();
- setWidgetRep( this );
- setMargin( YQWidgetMargin );
-
- _qt_listview = new QListView( this );
+ YTable::setHeader( column, text );
-
- if ( ! _enable_user_sort )
+ if ( hasColumn( column ) )
{
- y2debug( "User sorting disabled" );
- _qt_listview->setSorting( -1, true ); // disable sorting by click
+ _qt_listView->header()->setLabel( column, fromUTF8( text ) );
+ _qt_listView->adjustColumn( column );
}
- else
- {
- connect( _qt_listview->header(), SIGNAL( clicked (int) ),
- this, SLOT ( userSort(int) ) );
- _qt_listview->setSorting( 65530, true ); // leave initial sorting
- }
-
- // The header is a vector of strings, each defining one
- // column. The first string is one of the characters L, R or C
- // denoting left, right or center justification, resp.
+}
- for ( unsigned c=0; c < header.size(); c++ )
- {
- _qt_listview->addColumn( fromUTF8(header[c].substr(1 ) ) );
- switch ( header[c][0] )
- {
- case 'R':
- _qt_listview->setColumnAlignment( c, AlignRight );
- break;
- case 'C':
- _qt_listview->setColumnAlignment( c, AlignCenter );
- break;
- case 'L':
- default:
- _qt_listview->setColumnAlignment( c, AlignLeft );
- break;
- }
- }
- _qt_listview->setAllColumnsShowFocus( true );
+void
+YQTable::setAlignment( int column, YTable::Alignment alignment )
+{
+ YTable::setAlignment( column, alignment );
- if ( opt.notifyMode.value() )
+ if ( hasColumn( column ) )
{
- connect( _qt_listview, SIGNAL( doubleClicked ( QListViewItem * ) ), this, SLOT( slotActivated( QListViewItem * ) ) );
- connect( _qt_listview, SIGNAL( spacePressed ( QListViewItem * ) ), this, SLOT( slotActivated( QListViewItem * ) ) );
+ int qt_alignment = Qt::Left;
- if ( opt.immediateMode.value() )
+ switch ( alignment )
{
- connect( _qt_listview, SIGNAL( selectionChanged ( QListViewItem * ) ),
- this, SLOT ( slotSelected ( QListViewItem * ) ) );
+ case YTable::Left: qt_alignment = Qt::AlignLeft; break;
+ case YTable::Center: qt_alignment = Qt::AlignCenter; break;
+ case YTable::Right: qt_alignment = Qt::AlignRight; break;
}
+ _qt_listView->setColumnAlignment( column, qt_alignment );
}
}
-void YQTable::userSort( int column ) // column
+void
+YQTable::setKeepSorting( bool keepSorting )
{
- if ( _enable_user_sort )
+ YTable::setKeepSorting( keepSorting );
+ _qt_listView->setSortByInsertionSequence( keepSorting );
+}
+
+
+void
+YQTable::addItem( YItem * yitem )
+{
+ YTableItem * item = dynamic_cast<YTableItem *> (yitem);
+ YUI_CHECK_PTR( item );
+
+ YTable::addItem( item );
+
+ YQTableListViewItem * clone = new YQTableListViewItem( this, _qt_listView, item );
+ YUI_CHECK_NEW( clone );
+
+ if ( item->selected() )
{
- _sort_by_insertion_order = false;
+ YQSignalBlocker sigBlocker( _qt_listView );
+ _qt_listView->setSelected( clone, true );
}
}
-int YQTable::preferredWidth()
+void
+YQTable::selectItem( YItem * yitem, bool selected )
{
- // Arbitrary value.
- // Use a MinSize widget to set a size that is useful for the application.
+ YQSignalBlocker sigBlocker( _qt_listView );
+
+ YTableItem * item = dynamic_cast<YTableItem *> (yitem);
+ YUI_CHECK_PTR( item );
- return 30;
+ YQTableListViewItem * clone = (YQTableListViewItem *) item->data();
+ YUI_CHECK_PTR( clone );
+
+ if ( ! selected && clone == _qt_listView->selectedItem() )
+ {
+ deselectAllItems();
+ }
+ else
+ {
+ _qt_listView->setSelected( clone, true );
+ YTable::selectItem( item, selected );
+ }
}
-int YQTable::preferredHeight()
+void
+YQTable::deselectAllItems()
{
- // Arbitrary value.
- // Use a MinSize widget to set a size that is useful for the application.
+ YQSignalBlocker sigBlocker( _qt_listView );
- return 30;
+ YTable::deselectAllItems();
+ _qt_listView->clearSelection();
}
-void YQTable::setSize( int newWidth, int newHeight )
+void
+YQTable::deleteAllItems()
{
- resize( newWidth, newHeight );
+ _qt_listView->clear();
+ YTable::deleteAllItems();
}
-void YQTable::setEnabled( bool enabled )
+void
+YQTable::cellChanged( const YTableCell * cell )
{
- _qt_listview->setEnabled( enabled );
- _qt_listview->triggerUpdate();
- YWidget::setEnabled( enabled );
+ YTableItem * item = cell->parent();
+ YUI_CHECK_PTR( item );
+
+ YQTableListViewItem * clone = (YQTableListViewItem *) item->data();
+ YUI_CHECK_PTR( clone );
+
+ clone->updateCell( cell );
}
-void YQTable::itemAdded( vector<string> elements, int index )
+void
+YQTable::selectOrigItem( QListViewItem * listViewItem )
{
- YQListViewItem * item;
-
- if ( _sort_by_insertion_order && _last_item )
- item = new YQListViewItem( this, _qt_listview, _last_item, index );
- else
- item = new YQListViewItem( this, _qt_listview, index );
+ if ( listViewItem )
+ {
+ YQTableListViewItem * tableListViewItem = dynamic_cast<YQTableListViewItem *> (listViewItem);
+ YUI_CHECK_PTR( tableListViewItem );
- _last_item = item;
+ YTable::selectItem( tableListViewItem->origItem(), true );
+ }
+}
- for ( unsigned int i=0; i < elements.size(); i++ )
- item->setText( i, fromUTF8( elements[i] ) );
- if ( ! _qt_listview->selectedItem() )
+void
+YQTable::slotSelected( QListViewItem * listViewItem )
+{
+ selectOrigItem( listViewItem );
+
+ if ( immediateMode() )
{
- YQSignalBlocker sigBlocker( _qt_listview );
- item->setSelected( true );
+ if ( ! YQUI::ui()->eventPendingFor( this ) )
+ {
+ // Avoid overwriting a (more important) Activated event with a SelectionChanged event
+
+ YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::SelectionChanged ) );
+ }
}
}
-void YQTable::itemsCleared()
+
+void
+YQTable::slotActivated( QListViewItem * listViewItem )
{
- YQSignalBlocker sigBlocker( _qt_listview );
- _qt_listview->clear();
+ selectOrigItem( listViewItem );
+
+ if ( notify() )
+ YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::Activated ) );
}
-void YQTable::cellChanged( int index, int colnum, const YCPString & newtext )
+void
+YQTable::setEnabled( bool enabled )
{
- QListViewItem * item = findItem( index );
- if ( item ) item->setText( colnum, fromUTF8( newtext->value() ) );
+ _qt_listView->setEnabled( enabled );
+ _qt_listView->triggerUpdate();
+ YWidget::setEnabled( enabled );
}
-int YQTable::getCurrentItem()
+
+int
+YQTable::preferredWidth()
{
- YQListViewItem * ci = ( YQListViewItem * )( _qt_listview->currentItem() );
- if ( ci ) return ci->index;
- else return -1;
+ // Arbitrary value.
+ // Use a MinSize widget to set a size that is useful for the application.
+
+ return 30;
}
-void YQTable::setCurrentItem( int index )
+int
+YQTable::preferredHeight()
{
- QListViewItem * item = findItem( index );
-
- if ( item ) // should be always true
- {
- YQSignalBlocker sigBlocker( _qt_listview );
-
- _qt_listview->setCurrentItem( item );
- _qt_listview->ensureItemVisible( item );
- }
+ // Arbitrary value.
+ // Use a MinSize widget to set a size that is useful for the application.
+
+ return 30;
}
-QListViewItem * YQTable::findItem( int index )
+void
+YQTable::setSize( int newWidth, int newHeight )
{
- // Scan all items and look for the one with the right index.
- QListViewItem * item = _qt_listview->firstChild();
- while ( item )
- {
- if ( ( ( YQListViewItem *)item )->index == index )
- return item;
- item = item->nextSibling();
- }
- return 0;
+ resize( newWidth, newHeight );
}
-bool YQTable::setKeyboardFocus()
+bool
+YQTable::setKeyboardFocus()
{
- _qt_listview->setFocus();
+ _qt_listView->setFocus();
return true;
}
-void YQTable::slotSelected( QListViewItem * )
-{
- if ( notify() )
- {
- if ( ! YQUI::ui()->eventPendingFor( this ) )
- {
- // Avoid overwriting a (more important) Activated event with a SelectionChanged event
- YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::SelectionChanged ) );
- }
+
+
+
+YQTableListViewItem::YQTableListViewItem( YQTable * table,
+ QY2ListView * parent,
+ YTableItem * origItem )
+ : QY2ListViewItem( parent )
+ , _table( table )
+ , _origItem( origItem )
+{
+ YUI_CHECK_PTR( _table );
+ YUI_CHECK_PTR( _origItem );
+
+ _origItem->setData( this );
+
+ for ( YTableCellIterator it = _origItem->cellsBegin();
+ it != _origItem->cellsEnd();
+ ++it )
+ {
+ updateCell( *it );
}
+
+ if ( _origItem->selected() )
+ QY2ListViewItem::setSelected( true );
}
-void YQTable::slotActivated( QListViewItem * )
+void
+YQTableListViewItem::updateCell( const YTableCell * cell )
{
- if ( notify() )
- YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::Activated ) );
+ if ( ! cell )
+ return;
+
+ int column = cell->column();
+
+ //
+ // Set label text
+ //
+
+ setText( column, fromUTF8( cell->label() ) );
+
+
+ //
+ // Set icon (if specified)
+ //
+
+ if ( cell->hasIconName() )
+ {
+ // _table is checked against 0 in the constructor
+
+ string iconName = _table->iconFullPath( cell->iconName() );
+ QPixmap icon = QPixmap( iconName.c_str() );
+
+ if ( icon.isNull() )
+ y2error( "Can't load icon %s", iconName.c_str() );
+ else
+ setPixmap( column, icon );
+ }
+ else // No pixmap name
+ {
+ if ( pixmap( column ) ) // Was there a pixmap before?
+ {
+ setPixmap( column, QPixmap() ); // Set empty pixmap
+ }
+ }
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQTable.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTable.…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTable.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTable.h Fri Oct 5 17:53:40 2007
@@ -25,7 +25,7 @@
#include "YTable.h"
-class QListView;
+class QY2ListView;
class QListViewItem;
class YQListViewItem;
@@ -38,127 +38,176 @@
/**
* Constructor.
**/
- YQTable( QWidget * parent, const YWidgetOpt & opt, vector<string> header );
+ YQTable( YWidget * parent, int columns );
/**
- * Inherited from YWidget: Sets the enabled state of the
- * widget. All new widgets are enabled per definition. Only
- * enabled widgets can take user input.
+ * Destructor.
**/
- void setEnabled( bool enabled );
+ virtual ~YQTable();
/**
- * Preferred width of the widget.
+ * Set the header text for the specified column (counting from 0 on).
*
* Reimplemented from YWidget.
**/
- virtual int preferredWidth();
+ virtual void setHeader( int column, const string & text );
/**
- * Preferred height of the widget.
+ * Set the alignment for the specified column (counting from 0 on):
+ * YTable::Left, YTable::Center, YTable::Right
*
* Reimplemented from YWidget.
**/
- virtual int preferredHeight();
+ virtual void setAlignment( int column, YTable::Alignment alignment );
/**
- * Set the new size of the widget.
+ * Switch between sorting by item insertion order (keepSorting: true) or
+ * allowing the user to sort by an arbitrary column (by clicking on the
+ * column header).
*
- * Reimplemented from YWidget.
+ * Reimplemented from YTable.
**/
- virtual void setSize( int newWidth, int newHeight );
+ virtual void setKeepSorting( bool keepSorting );
/**
- * Notification that new items have been added.
+ * Add an item.
*
- * Reimplemented from YTable.
+ * Reimplemented from YSelectionWidget.
**/
- void itemAdded( vector<string> elements, int index );
+ virtual void addItem( YItem * item );
/**
- * Inherited from YTable. Is called, when alls items are cleared.
+ * Select or deselect an item.
+ *
+ * Reimplemented from YSelectionWidget.
**/
- void itemsCleared();
+ virtual void selectItem( YItem * item, bool selected = true );
/**
- * Inherited from YTable. is called, when the text of a cell has changed.
+ * Deselect all items.
+ *
+ * Reimplemented from YSelectionWidget.
**/
- void cellChanged( int index, int colnum, const YCPString & newtext );
+ virtual void deselectAllItems();
/**
- * Inherited from YTable. Returns the index of the currently
- * selected item or -1 if no item is selected.
+ * Delete all items.
+ *
+ * Reimplemented from YSelectionWidget.
**/
- int getCurrentItem();
+ virtual void deleteAllItems();
/**
- * Inherited from YTable. Makes another item selected.
+ * Notification that a cell (its text and/or its icon) was changed from the
+ * outside. Applications are required to call this whenever a table cell is
+ * changed after adding the corresponding table item (the row) to the table
+ * widget.
+ *
+ * Reimplemented from YTable.
**/
- void setCurrentItem( int index );
+ virtual void cellChanged( const YTableCell * cell );
/**
- * Accept the keyboard focus.
+ * Set enabled/disabled state.
+ *
+ * Reimplemented from YWidget.
**/
- virtual bool setKeyboardFocus();
+ virtual void setEnabled( bool enabled );
/**
- * Returns 'true' if items should be ordered by insertion order
+ * Preferred width of the widget.
+ *
+ * Reimplemented from YWidget.
**/
- bool sortByInsertionOrder() const { return _sort_by_insertion_order; }
+ virtual int preferredWidth();
+ /**
+ * Preferred height of the widget.
+ *
+ * Reimplemented from YWidget.
+ **/
+ virtual int preferredHeight();
+
+ /**
+ * Set the new size of the widget.
+ *
+ * Reimplemented from YWidget.
+ **/
+ virtual void setSize( int newWidth, int newHeight );
+
+ /**
+ * Accept the keyboard focus.
+ *
+ * Reimplemented from YWidget.
+ **/
+ virtual bool setKeyboardFocus();
protected slots:
/**
- * Notification that an item is selected.
- * Only relevant if `opt(`notify, `immediate) is set.
+ * Notification that an item is selected (single click or keyboard).
**/
void slotSelected( QListViewItem * );
/**
- * Notification that an item is activated.
- * Only relevant if `opt(`notify) is set.
+ * Notification that an item is activated (double click or keyboard).
**/
void slotActivated( QListViewItem * );
+protected:
+
/**
- * Notification that the user wishes to change the sort order.
+ * Select the original item (the YTableItem) that corresponds to the
+ * specified listViewItem.
**/
- void userSort( int column );
+ void selectOrigItem( QListViewItem * listViewItem );
+ //
+ // Data members
+ //
-protected:
- /**
- * Helper function. Find item with given id.
- **/
- QListViewItem * findItem( int index );
+ QY2ListView * _qt_listView;
+};
+
+
+
+/**
+ * Visual representation of a YTableItem.
+ **/
+class YQTableListViewItem: public QY2ListViewItem
+{
+public:
/**
- * The Qt widget representing the table
+ * Constructor.
**/
- QListView * _qt_listview;
+ YQTableListViewItem( YQTable * table,
+ QY2ListView * parent,
+ YTableItem * origItem );
-
- //
- // Data members
- //
-
/**
- * Sorting strategy
+ * Return the parent table widget.
**/
- bool _sort_by_insertion_order;
+ YQTable * table() const { return _table; }
/**
- * Flag: User may re-sort the table by clicking on a header?
+ * Return the corresponding YTableItem.
**/
- bool _enable_user_sort;
+ YTableItem * origItem() const { return _origItem; }
/**
- * For maintaining insertion order
+ * Update this item's display with the content of 'cell'.
**/
- YQListViewItem * _last_item;
+ void updateCell( const YTableCell * cell );
+
+protected:
+
+ YQTable * _table;
+ YTableItem * _origItem;
};
+
+
#endif // YQLabel_h
Modified: branches/tmp/sh/mod-ui/qt/src/YQTree.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTree.c…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTree.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTree.cc Fri Oct 5 17:53:40 2007
@@ -131,8 +131,7 @@
if ( ! selected && yqTreeItem == _qt_listView->selectedItem() )
{
- _qt_listView->clearSelection();
- YTree::deselectAllItems();
+ deselectAllItems();
}
else
{
Modified: branches/tmp/sh/mod-ui/qt/src/YQUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI.h?r…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI.h Fri Oct 5 17:53:40 2007
@@ -82,7 +82,7 @@
/**
* Create the widget factory that provides all the createXY() methods for
* optional ("special") widgets and the corresponding hasXYWidget()
- * methods.
+ * methods.
*
* Reimplemented from YUI.
**/
@@ -94,9 +94,9 @@
* Reimplemented from YUI.
**/
virtual YApplication * createApplication();
-
+
public:
-
+
/**
* Returns the UI's default font.
**/
@@ -435,7 +435,6 @@
YWidget * createIntField ( YWidget * parent, YWidgetOpt & opt, const YCPString & label, int minValue, int maxValue, int initialValue);
YWidget * createLogView ( YWidget * parent, YWidgetOpt & opt, const YCPString & label, int visibleLines, int maxLines );
YWidget * createMenuButton ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
- YWidget * createTable ( YWidget * parent, YWidgetOpt & opt, vector<string> header);
/*** Widget creation methods for optional widgets, all reimplemented from YUI ***/
Modified: branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI_wid…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Fri Oct 5 17:53:40 2007
@@ -107,14 +107,6 @@
}
-YWidget * YQUI::createTable ( YWidget * parent,
- YWidgetOpt & opt,
- vector<string> header )
-{
- return new YQTable( (QWidget *) ( parent->widgetRep() ), opt, header);
-}
-
-
YWidget * YQUI::createIntField ( YWidget * parent,
YWidgetOpt & opt,
const YCPString & label,
Modified: branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWidget…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc Fri Oct 5 17:53:40 2007
@@ -174,7 +174,7 @@
{
YQTree * tree = new YQTree( parent, label );
YUI_CHECK_NEW( tree );
-
+
return tree;
}
@@ -183,7 +183,10 @@
YQTable *
YQWidgetFactory::createTable( YWidget * parent, int columns )
{
- return 0; // FIXME: TO DO
+ YQTable * table = new YQTable( parent, columns );
+ YUI_CHECK_NEW( table );
+
+ return table;
}
@@ -193,7 +196,7 @@
{
YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
YUI_CHECK_NEW( progressBar );
-
+
return progressBar;
}
@@ -236,7 +239,7 @@
{
YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
YUI_CHECK_NEW( multiLineEdit );
-
+
return multiLineEdit;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQWizard.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWizard…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWizard.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWizard.cc Fri Oct 5 17:53:40 2007
@@ -824,9 +824,11 @@
_tree = new QY2ListView( vbox );
YUI_CHECK_NEW( _tree );
+
_tree->addColumn( "" );
_tree->header()->hide();
_tree->setRootIsDecorated( true );
+ _tree->setSortByInsertionSequence( true );
connect( _tree, SIGNAL( selectionChanged ( void ) ),
this, SLOT ( treeSelectionChanged ( void ) ) );
Modified: branches/tmp/sh/mod-ui/qt/src/YQWizard.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWizard…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWizard.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWizard.h Fri Oct 5 17:53:40 2007
@@ -695,14 +695,14 @@
TreeItem( QY2ListView * parent,
const QString & text,
const QString & id )
- : QY2ListViewItem( parent, text, true )
+ : QY2ListViewItem( parent, text )
, _id( id )
{}
TreeItem( YQWizard::TreeItem * parent,
const QString & text,
const QString & id )
- : QY2ListViewItem( parent, text, true )
+ : QY2ListViewItem( parent, text )
, _id( id )
{}
Modified: branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgConflictList.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/pkg/YQPk…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgConflictList.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgConflictList.cc Fri Oct 5 17:53:40 2007
@@ -59,6 +59,7 @@
{
addColumn( _( "Dependency Conflict" ) );
setRootIsDecorated( true );
+ setSortByInsertionSequence( true );
}
@@ -251,7 +252,7 @@
if ( ! header.isEmpty() )
{
- parent = new QY2ListViewItem( parent, header, true );
+ parent = new QY2ListViewItem( parent, header );
CHECK_PTR( parent );
parent->setOpen( true );
}
@@ -273,7 +274,7 @@
int more = lines.size() - count + 1;
QString text = ( _( "%1 more..." ) ).arg( more );
- QY2ListViewItem * sublist = new QY2ListViewItem( parent, text, true );
+ QY2ListViewItem * sublist = new QY2ListViewItem( parent, text );
didSplit = true;
if ( sublist )
@@ -283,7 +284,7 @@
}
}
- new QY2ListViewItem( parent, *it, true );
+ new QY2ListViewItem( parent, *it );
++it;
}
}
@@ -329,8 +330,7 @@
// Heading for the choices
// how to resolve this conflict
_( "Conflict Resolution:" ),
- QCheckListItem::Controller,
- true );
+ QCheckListItem::Controller );
CHECK_PTR( _resolutionsHeader );
_resolutionsHeader->setOpen( true );
_resolutionsHeader->setBackgroundColor( LIGHT_GREY );
@@ -392,8 +392,7 @@
zypp::ProblemSolution_Ptr solution )
: QY2CheckListItem( parent,
fromUTF8( solution->description() ),
- QCheckListItem::RadioButton,
- true )
+ QCheckListItem::RadioButton )
, _solution( solution )
{
YQPkgConflictList::dumpList( this, fromUTF8( solution->details() ) );
Modified: branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgObjList.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/pkg/YQPk…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgObjList.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgObjList.cc Fri Oct 5 17:53:40 2007
@@ -102,7 +102,7 @@
const QString & summary,
FSize size )
{
- QY2ListViewItem * item = new QY2ListViewItem( this, QString::null, true );
+ QY2ListViewItem * item = new QY2ListViewItem( this, QString::null );
if ( item )
{
Modified: branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgVersionsView.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/pkg/YQPk…
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgVersionsView.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/pkg/YQPkgVersionsView.cc Fri Oct 5 17:53:40 2007
@@ -61,6 +61,8 @@
_nameCol = _versionCol;
_summaryCol = _repoCol;
+ setSortByInsertionSequence( true );
+
// saveColumnWidths(); // Minimize column widths
// header()->hide();
@@ -117,7 +119,7 @@
return;
QY2CheckListItem * root = new QY2CheckListItem( this, selectable->theObj()->name().c_str(),
- QCheckListItem::Controller, true );
+ QCheckListItem::Controller );
CHECK_PTR( root );
root->setOpen( true );
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r41268 - in /branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src: FingerprintReader.ycp UsersPluginFingerprintReader.pm dialogs.ycp
by jsuchome@svn.opensuse.org 05 Oct '07
by jsuchome@svn.opensuse.org 05 Oct '07
05 Oct '07
Author: jsuchome
Date: Fri Oct 5 15:57:05 2007
New Revision: 41268
URL: http://svn.opensuse.org/viewcvs/yast?rev=41268&view=rev
Log:
do not use Pam API, pam_thinkfinger cares about the PAM configuration
Modified:
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp
Modified: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp (original)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp Fri Oct 5 15:57:05 2007
@@ -37,7 +37,7 @@
import "Arch";
import "FileUtils";
-import "Pam";
+import "Package";
import "Popup";
import "Progress";
import "Report";
@@ -110,7 +110,7 @@
return false;
}
- use_pam = Pam::Enabled ("thinkfinger");
+ use_pam = Package::Installed ("pam_thinkfinger");
modified = false;
return true;
@@ -132,14 +132,14 @@
sleep(sl);
// We do not set help text here, because it was set outside
- Progress::New(caption, " ", 2, [
+ Progress::New(caption, " ", 1, [
// Progress stage
- _("Write the PAM settings"),
+// _("Write the PAM settings"),
// Progress stage
_("Import fingerprint files"),
], [
// Progress step
- _("Writing the PAM settings..."),
+// _("Writing the PAM settings..."),
// Progress step
_("Importing fingerprint files..."),
// Progress finished
@@ -148,6 +148,7 @@
""
);
+ /* no PAM writing on SLE10, everything is done by pam_thinkfinger package
Progress::NextStage();
boolean pam_ret = use_pam ?
@@ -157,6 +158,7 @@
Report::Error (_("Cannot write PAM settings."));
sleep(sl);
+ */
Progress::NextStage();
if (use_pam && import_dir != "")
@@ -213,7 +215,7 @@
global list Summary() {
// summary header
- string summary = Summary::AddHeader(summary, _("PAM Login"));
+ string summary = Summary::AddHeader("", _("PAM Login"));
summary = Summary::AddLine (summary, (use_pam) ?
// summary item
Modified: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm (original)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm Fri Oct 5 15:57:05 2007
@@ -22,7 +22,7 @@
YaST::YCP::Import ("Directory");
YaST::YCP::Import ("FileUtils");
YaST::YCP::Import ("FingerprintReader");
-YaST::YCP::Import ("Pam");
+YaST::YCP::Import ("Package");
YaST::YCP::Import ("SCR");
YaST::YCP::Import ("Users");
@@ -65,7 +65,8 @@
# helper, check if Fingerprint Reader was already configured
sub fingerprint_reader_configured {
- return Pam->Enabled ("thinkfinger");
+ # in SLE10SP1, pam_thinkfinger package handles the PAM stuff itself
+ return Package->Installed ("pam_thinkfinger");
}
# helper function: check if Fingerprint Reader (the device) is available
@@ -206,7 +207,6 @@
# Is it possible to remove this plugin from user?
BEGIN { $TYPEINFO{PluginRemovable} = ["function", "boolean", "any", "any"];}
sub PluginRemovable {
- # doesn't have sense to remove
return YaST::YCP::Boolean (1);
}
Modified: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp (original)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp Fri Oct 5 15:57:05 2007
@@ -104,7 +104,7 @@
`VSpacing (),
`HBox (
// textentry label
- `TextEntry (`id(`import_dir),_("Directory with fingerprint files")),
+ `TextEntry (`id(`import_dir),_("&Directory with fingerprint files")),
`VBox (
`Label (""),
`PushButton (`id (`browse), Label::BrowseButton ())
@@ -170,6 +170,16 @@
UI::ChangeWidget (`id (`browse), `Enabled, use_pam);
continue;
}
+ if (!use_pam &&
+ !Package::RemoveAll (FingerprintReader::UpdatedArchPackages (
+ FingerprintReader::required_packages)))
+ {
+ use_pam = true;
+ UI::ChangeWidget (`id (`rd), `Value, `pamyes);
+ UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam);
+ UI::ChangeWidget (`id (`browse), `Enabled, use_pam);
+ continue;
+ }
if (use_pam != FingerprintReader::use_pam ||
(use_pam && import_dir != ""))
{
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
Author: jsuchome
Date: Fri Oct 5 14:00:23 2007
New Revision: 41267
URL: http://svn.opensuse.org/viewcvs/yast?rev=41267&view=rev
Log:
updated list of architecture specific packages for pam-related modules
Modified:
trunk/extra-packages
Modified: trunk/extra-packages
URL: http://svn.opensuse.org/viewcvs/yast/trunk/extra-packages?rev=41267&r1=4126…
==============================================================================
--- trunk/extra-packages (original)
+++ trunk/extra-packages Fri Oct 5 14:00:23 2007
@@ -116,7 +116,17 @@
yast2-samba-client:
samba-client
+ samba-client-x86 (ia64 only)
+ samba-client-32bit (s390x, x86_64)
+ samba-client-64bit (ppc64 only)
samba-winbind
+ samba-winbind-x86 (ia64 only)
+ samba-winbind-32bit (s390x, x86_64)
+ samba-winbind-64bit (ppc64 only)
+ krb5
+ krb5-x86 (ia64 only)
+ krb5-32bit (s390x, x86_64)
+ krb5-64bit (ppc64 only)
yast2-samba-server:
samba
@@ -135,20 +145,23 @@
autofs4
openldap2-client
pam_ldap-x86 (ia64 only)
- pam_ldap-64bit (ppc32 only
- pam_ldap-32bit (ppc64, s390x, x86_64)
+ pam_ldap-64bit (ppc64 only
+ pam_ldap-32bit (s390x, x86_64)
nss_ldap-x86 (ia64 only)
- nss_ldap-64bit (ppc32 only
- nss_ldap-32bit (ppc64, s390x, x86_64)
+ nss_ldap-64bit (ppc64 only
+ nss_ldap-32bit (s390x, x86_64)
yast2-kerberos-client:
pam_krb5
+ pam_krb5-x86 (ia64 only)
+ pam_krb5-32bit (s390x, x86_64)
+ pam_krb5-64bit (ppc64 only)
krb5
+ krb5-x86 (ia64 only)
+ krb5-32bit (s390x, x86_64)
+ krb5-64bit (ppc64 only)
krb5-client
yast2-ntp-client
- krb5-x86 (ia64 only)
- krb5-32bit (ppc64, s390x, x86_64)
- krb5-64bit (ppc32 only)
yast2-tv:
kdetv (if KDE)
@@ -275,3 +288,10 @@
yast2-ftp-server:
xinetd
vsftpd
+
+yast2-fingerprint-reader:
+ pam_thinkfinger
+ pam_thinkfinger-x86 (ia64 only)
+ pam_thinkfinger-64bit (ppc64 only
+ pam_thinkfinger-32bit (s390x, x86_64)
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r41266 - in /branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader: ./ agent-thinkfinger/ agent-thinkfinger/conf/ agent-thinkfinger/doc/ agent-thinkfinger/doc/autodocs/ agent-thinkfinger/src/ agent-th...
by jsuchome@svn.opensuse.org 05 Oct '07
by jsuchome@svn.opensuse.org 05 Oct '07
05 Oct '07
Author: jsuchome
Date: Fri Oct 5 11:34:11 2007
New Revision: 41266
URL: http://svn.opensuse.org/viewcvs/yast?rev=41266&view=rev
Log:
backporting for SLE10... (fate 302658)
Added:
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/MAINTAINER
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/Makefile.cvs
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/RPMNAME
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/VERSION
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/thinkfinger.scr
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/autodocs/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/autodocs/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.cc
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.h
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Y2CCThinkFingerAgent.cc
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/testsuite/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/testsuite/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/configure.in.in
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/autodocs/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/autodocs/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/package/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/package/yast2-fingerprint-reader.changes
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.desktop
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.ycp (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/helps.ycp (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/wizards.ycp (with props)
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/testsuite/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/testsuite/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/testsuite/tests/
branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/yast2-fingerprint-reader.spec.in
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/MAINTAINER
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/MAINTAINER (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/MAINTAINER Fri Oct 5 11:34:11 2007
@@ -0,0 +1 @@
+Jiri Suchomel <jsuchome(a)suse.cz>
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/Makefile.cvs
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/Makefile.cvs (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/Makefile.cvs Fri Oct 5 11:34:11 2007
@@ -0,0 +1,22 @@
+#
+# Makefile.cvs
+#
+PREFIX = /usr
+
+LIB = $(shell y2tool get-lib)
+
+configure: all
+ ./configure --prefix=$(PREFIX) --libdir=$(PREFIX)/$(LIB)
+
+all:
+ y2tool y2autoconf
+ y2tool y2automake
+ autoreconf --force --install
+
+install: configure
+ make
+ make install
+
+reconf: all
+ ./config.status --recheck
+ ./config.status
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/RPMNAME
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/RPMNAME (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/RPMNAME Fri Oct 5 11:34:11 2007
@@ -0,0 +1 @@
+yast2-fingerprint-reader
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/VERSION (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/VERSION Fri Oct 5 11:34:11 2007
@@ -0,0 +1 @@
+2.13.0
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1 @@
+SUBDIRS = conf doc src testsuite
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,7 @@
+#
+# Makefile.am for .../agent-thinkfinger/conf
+#
+
+scrconf_DATA = thinkfinger.scr
+
+EXTRA_DIST = $(scrconf_DATA)
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/thinkfinger.scr
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/thinkfinger.scr (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/conf/thinkfinger.scr Fri Oct 5 11:34:11 2007
@@ -0,0 +1,16 @@
+/**
+ * File: thinkfinger.scr
+ * Summary: ThinkFinger agent
+ * Author: Jiri Suchomel <jsuchome(a)suse.cz>
+ * Access: read / write / execute
+ *
+ * Example: FIXME
+ *
+ * $Id$
+ *
+ */
+.thinkfinger
+
+`ag_thinkfinger(
+ `ThinkFingerAgent()
+)
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1 @@
+SUBDIRS = autodocs
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/autodocs/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/autodocs/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/doc/autodocs/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,13 @@
+#
+# Makefile.am for .../agent-thinkfinger/doc/autodocs
+#
+
+htmldir = $(docdir)/autodocs
+
+html_DATA = index.html $(wildcard *.html *.png) doxygen.css @RPMNAME@.tag
+CLEANFILES = $(html_DATA) doxygen.log doxygen.conf installdox
+
+doxygen.css @RPMNAME@.tag: index.html
+
+index.html: $(srcdir)/../../src/*.h
+ @ybindir@/ydoxygen PROJECT_NAME=@RPMNAME@
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,24 @@
+
+# Makefile.am for .../agent-thinkfinger/src
+#
+
+AM_CXXFLAGS = -DY2LOG=\"agent-thinkfinger\" -Wall
+
+plugin_LTLIBRARIES = libpy2ag_thinkfinger.la
+noinst_LTLIBRARIES = liby2ag_thinkfinger.la
+
+liby2ag_thinkfinger_la_SOURCES = \
+ ThinkFingerAgent.cc \
+ ThinkFingerAgent.h
+liby2ag_thinkfinger_la_LDFLAGS = -version-info 2:0
+liby2ag_thinkfinger_la_LIBADD = @AGENT_LIBADD@ -lthinkfinger -L$(libdir)
+
+
+libpy2ag_thinkfinger_la_SOURCES = \
+ $(liby2ag_thinkfinger_la_SOURCES) \
+ Y2CCThinkFingerAgent.cc
+libpy2ag_thinkfinger_la_LDFLAGS = -version-info 2:0
+libpy2ag_thinkfinger_la_LIBADD = @AGENT_LIBADD@ -lthinkfinger -L$(libdir)
+
+
+INCLUDES = -I$(includedir)
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.cc (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.cc Fri Oct 5 11:34:11 2007
@@ -0,0 +1,307 @@
+/* ThinkFingerAgent.cc
+ *
+ * An agent for ThinkFinger library (access to fingerprint reader)
+ *
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ */
+
+#include "ThinkFingerAgent.h"
+
+#define PC(n) (path->component_str(n))
+
+#define INIT_FAILED 500
+#define SET_FILE_FAILED 600
+#define SET_CALLBACK_FAILED 700
+
+// structure to be passed to callback
+typedef struct {
+ int write_fd;
+} s_tfdata;
+
+/**
+ * callback function to be called from libthinkfinger_acquire
+ * @param state current device status
+ * @param data void pointer to user data
+ */
+static void callback (libthinkfinger_state state, void *data)
+{
+ s_tfdata *tfdata = (s_tfdata *) data;
+ if (write (tfdata->write_fd, &state, sizeof (libthinkfinger_state)) == -1)
+ y2error("write to pipe failed: %d (%m)", errno);
+}
+
+/**
+ * Constructor
+ */
+ThinkFingerAgent::ThinkFingerAgent() : SCRAgent()
+{
+ child_pid = -1;
+}
+
+/**
+ * Destructor
+ */
+ThinkFingerAgent::~ThinkFingerAgent()
+{
+}
+
+// return the only instance of the class
+ThinkFingerAPI& ThinkFingerAPI::instance()
+{
+ static ThinkFingerAPI _instance; // The singleton
+ return _instance;
+}
+
+// handler for SIGTERM signal (it is necessary to kill the process when
+// user his Cancel)
+void ThinkFingerAPI::catch_sigterm (int sig_num)
+{
+ instance().finalize ();
+ exit (256);
+}
+
+// de-initialize finger print reader (must be called at the end!)
+void ThinkFingerAPI::finalize ()
+{
+ if (instance().tf != NULL)
+ {
+ libthinkfinger_free (instance().tf);
+ instance().tf = NULL;
+ }
+}
+
+ThinkFingerAPI::ThinkFingerAPI()
+{
+ tf = NULL;
+}
+
+ThinkFingerAPI::~ThinkFingerAPI ()
+{
+}
+
+/**
+ * wrapper for libthinkfinger_acquire function;
+ * - we need to take care of the errors and signals
+ * @param file descriptor of the pipe
+ * @param path to the target bir file
+ */
+int ThinkFingerAPI::acquire (int write_fd, string bir_path)
+{
+ signal (15, catch_sigterm);
+
+ int retval = 255;
+ s_tfdata tfdata;
+ tfdata.write_fd = write_fd;
+
+ libthinkfinger_init_status init_status;
+ instance().tf = libthinkfinger_new (&init_status);
+ if (init_status != TF_INIT_SUCCESS) {
+ y2error ("libthinkfinger_new failed");
+ instance().finalize ();
+ retval = INIT_FAILED;
+ write (write_fd, &retval, sizeof(libthinkfinger_state));
+ return retval;
+ }
+
+ if (libthinkfinger_set_file (instance().tf, bir_path.c_str ()) < 0)
+ {
+ y2error ("libthinkfinger_set_file failed");
+ instance().finalize ();
+ retval = SET_FILE_FAILED;
+ write (write_fd, &retval, sizeof(libthinkfinger_state));
+ return retval;
+ }
+ if (libthinkfinger_set_callback (instance().tf, callback, &tfdata) < 0)
+ {
+ y2error ("libthinkfinger_set_callback failed");
+ instance().finalize ();
+ retval = SET_CALLBACK_FAILED;
+ write (write_fd, &retval, sizeof(libthinkfinger_state));
+ return retval;
+ }
+ retval = libthinkfinger_acquire (ThinkFingerAPI::instance().tf);
+ y2milestone ("acquire done with state %d", retval);
+ instance().finalize ();
+ signal (15, SIG_DFL);
+ return retval;
+}
+
+/**
+ * Dir
+ */
+YCPList ThinkFingerAgent::Dir(const YCPPath& path)
+{
+ y2error("Wrong path '%s' in Dir().", path->toString().c_str());
+ return YCPNull();
+}
+
+/**
+ * Read
+ */
+YCPValue ThinkFingerAgent::Read(const YCPPath &path, const YCPValue& arg, const YCPValue& opt) {
+
+ y2debug ("Path in Read(): %s", path->toString().c_str());
+ YCPValue ret = YCPVoid();
+
+ if (path->length() == 0) {
+ ret = YCPString("0");
+ }
+ else if (path->length() == 1) {
+
+ if (PC(0) == "error") {
+ // return the last error message
+ ret = YCPString ("error_message");
+ }
+ else if (PC(0) == "state") {
+ YCPMap retmap;
+ if (!child_pid)
+ {
+ y2error ("ThinkFinger not initialized yet!");
+ return ret;
+ }
+ int state;
+ size_t size = sizeof (libthinkfinger_state);
+ int retval = read (data_pipe[0], &state, size);
+ if (retval == -1)
+ {
+ if (errno != EINTR && errno != EAGAIN)
+ y2error ("error reading from pipe: %d (%m)", errno);
+ }
+ else if (retval == size) {
+ if (state == INIT_FAILED ||
+ state == SET_FILE_FAILED || state == SET_CALLBACK_FAILED)
+ {
+ y2warning ("some initialization failed (%d)...", state);
+ return ret;
+ }
+ retmap->add (YCPString ("state"), YCPInteger (state));
+ }
+ return retmap;
+ }
+ // wait for child exit
+ else if (PC(0) == "exit_status" ) {
+y2internal ("waiting for child exit...");
+ int status;
+ int retval = 255;
+//FIXME in case of
+//Warning: usb_bulk_read expected to read 0x40 (read 0x34 bytes).
+//child doesn't exit...
+ wait (&status);
+ if (WIFSIGNALED (status))
+ y2milestone ("child process was killed");
+ else if (WIFEXITED (status))
+ {
+ retval = WEXITSTATUS (status);
+y2milestone ("retval is %d", retval);
+ }
+ ret = YCPInteger (retval);
+ close (data_pipe[0]); // close FD for reading
+ }
+ else {
+ y2error ("Unknown path in Read(): %s", path->toString().c_str());
+ }
+ }
+ else {
+ y2error ("Unknown path in Read(): %s", path->toString().c_str());
+ }
+ return ret;
+}
+
+
+/**
+ * Write - nothing to do
+ */
+YCPBoolean ThinkFingerAgent::Write(const YCPPath &path, const YCPValue& value,
+ const YCPValue& arg)
+{
+ return YCPBoolean(false);
+}
+
+/**
+ * Execute(.thinkfinger.add-user) is action to acquire fingerprint
+ */
+YCPValue ThinkFingerAgent::Execute(const YCPPath &path, const YCPValue& val, const YCPValue& arg)
+{
+ y2milestone ("Path in Execute(): %s", path->toString().c_str());
+ YCPValue ret = YCPBoolean(false);
+
+ if (path->length() == 1) {
+
+ if (PC(0) == "cancel") {
+y2internal ("killing child process with pid %d", child_pid);
+ if (child_pid)
+ kill (child_pid, 15);
+ child_pid = -1;
+ ret = YCPBoolean (true);
+ }
+ /**
+ * parameter is whole path to target bir file, e.g.
+ * /tmp/YaST-123-456/hh.bir
+ */
+ else if (PC(0) == "add-user") {
+ string path;
+ if (!val.isNull())
+ {
+ path = val->asString()->value();
+ }
+ else
+ {
+ y2error ("path to bir file is missing");
+ return ret;
+ }
+ if (pipe (data_pipe) == -1) {
+ y2error ("pipe creation failed");
+ return ret;
+ }
+
+ long arg;
+ arg = fcntl (data_pipe[0], F_GETFL);
+ if (fcntl (data_pipe[0], F_SETFL, arg | O_NONBLOCK ) < 0)
+ {
+ y2error ("Couldn't set O_NONBLOCK: errno=%d: %m", errno);
+ close (data_pipe[0]);
+ close (data_pipe[1]);
+ return ret;
+ }
+ child_pid = fork ();
+ if (child_pid == -1)
+ {
+ y2error ("fork failed");
+ return ret;
+ }
+ else if (child_pid == 0)
+ {
+ close (data_pipe[0]); // close the read-only FD
+ int state =
+ ThinkFingerAPI::instance().acquire (data_pipe[1], path);
+ y2milestone ("acquire done with state %d", state);
+ close (data_pipe[1]);
+ exit (state);
+ }
+ else // parent -> return
+ {
+ close (data_pipe[1]); // close FD for writing
+ ret = YCPBoolean(true);
+ }
+ }
+ }
+ return ret;
+}
+
+/**
+ * otherCommand
+ */
+YCPValue ThinkFingerAgent::otherCommand(const YCPTerm& term)
+{
+ string sym = term->name();
+
+ if (sym == "ThinkFingerAgent") {
+
+ return YCPVoid();
+ }
+
+ return YCPNull();
+}
+
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.h (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/ThinkFingerAgent.h Fri Oct 5 11:34:11 2007
@@ -0,0 +1,118 @@
+/* ThinkFingerAgent.h
+ *
+ * ThinkFinger agent implementation
+ *
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id: ThinkFingerAgent.h 26456 2005-12-07 16:11:23Z jsuchome $
+ */
+
+#ifndef _ThinkFingerAgent_h
+#define _ThinkFingerAgent_h
+
+#include <Y2.h>
+#include <scr/SCRAgent.h>
+
+using namespace std;
+
+#include <libthinkfinger.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <string>
+
+/**
+ * The real interface to thinkfinger library
+ * - extra (singleton) class is used to contain signal handler function
+ */
+class ThinkFingerAPI
+{
+
+private:
+ ThinkFingerAPI ();
+
+ virtual ~ThinkFingerAPI();
+
+public:
+
+ static ThinkFingerAPI & instance();
+
+ static void catch_sigterm (int);
+
+ int acquire (int, string);
+
+ int test_int;
+
+ libthinkfinger *tf;
+
+ void finalize ();
+
+};
+
+/**
+ * @short An interface class between YaST2 and ThinkFinger Agent
+ */
+class ThinkFingerAgent : public SCRAgent
+{
+
+public:
+
+ /**
+ * Default constructor.
+ */
+ ThinkFingerAgent ();
+
+
+ /**
+ * Destructor.
+ */
+ virtual ~ThinkFingerAgent();
+
+ /**
+ * Provides SCR Read ().
+ * @param path Path that should be read.
+ * @param arg Additional parameter.
+ */
+ virtual YCPValue Read(const YCPPath &path,
+ const YCPValue& arg = YCPNull(),
+ const YCPValue& opt = YCPNull());
+
+ /**
+ * Provides SCR Write ().
+ */
+ virtual YCPBoolean Write(const YCPPath &path,
+ const YCPValue& val,
+ const YCPValue& arg = YCPNull());
+
+ /**
+ * Provides SCR Execute ().
+ */
+ virtual YCPValue Execute(const YCPPath &path,
+ const YCPValue& val = YCPNull(),
+ const YCPValue& arg = YCPNull());
+
+ /**
+ * Provides SCR Dir ().
+ */
+ virtual YCPList Dir(const YCPPath& path);
+
+ /**
+ * Used for mounting the agent.
+ */
+ virtual YCPValue otherCommand(const YCPTerm& term);
+
+
+ /**
+ * array with pipe file descriptors
+ */
+ int data_pipe[2];
+
+ /**
+ * pid of the child process after fork
+ */
+ pid_t child_pid;
+
+};
+
+#endif /* _ThinkFingerAgent_h */
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Y2CCThinkFingerAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Y2CCThinkFingerAgent.cc (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/src/Y2CCThinkFingerAgent.cc Fri Oct 5 11:34:11 2007
@@ -0,0 +1,15 @@
+/* Y2CCThinkFingerAgent.cc
+ *
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ */
+
+#include <scr/Y2AgentComponent.h>
+#include <scr/Y2CCAgentComponent.h>
+
+#include "ThinkFingerAgent.h"
+
+typedef Y2AgentComp <ThinkFingerAgent> Y2ThinkFingerAgentComp;
+
+Y2CCAgentComp <Y2ThinkFingerAgentComp> g_y2ccag_thinkfinger ("ag_thinkfinger");
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/testsuite/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/agent-thinkfinger/testsuite/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,8 @@
+#
+# Makefile.am for .../agent-thinkfinger/testsuite
+#
+
+AUTOMAKE_OPTIONS = dejagnu
+
+clean-local:
+ rm -f tmp.err.* tmp.out.* site.exp site.bak
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/configure.in.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/configure.in.in (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/configure.in.in Fri Oct 5 11:34:11 2007
@@ -0,0 +1,14 @@
+## YCP module configure.in.in
+
+## Initialize
+@YAST2-INIT-COMMON@
+@YAST2-INIT-YCP@
+@YAST2-INIT-PROGRAM@
+
+## some common checks
+@YAST2-CHECKS-COMMON@
+@YAST2-CHECKS-YCP@
+@YAST2-CHECKS-PROGRAM@
+
+## and generate the output...
+@YAST2-OUTPUT@
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,10 @@
+# Makefile.am for fingerprint-reader/doc
+
+SUBDIRS = autodocs
+
+htmldir = $(docdir)
+
+doc_DATA =
+html_DATA =
+
+EXTRA_DIST = $(doc_DATA) $(html_DATA)
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/autodocs/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/autodocs/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/doc/autodocs/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,3 @@
+# Makefile.am for fingerprint-reader/doc/autodocs
+
+include $(top_srcdir)/autodocs-ycp.ami
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/package/yast2-fingerprint-reader.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/package/yast2-fingerprint-reader.changes (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/package/yast2-fingerprint-reader.changes Fri Oct 5 11:34:11 2007
@@ -0,0 +1,6 @@
+-------------------------------------------------------------------
+Tue Oct 2 13:48:59 CEST 2007 - jsuchome(a)suse.cz
+
+- Backport 2.15.2 version for SLE10 (F302658)
+- 2.13.0
+
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/FingerprintReader.ycp Fri Oct 5 11:34:11 2007
@@ -0,0 +1,267 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: modules/FingerprintReader.ycp
+ * Package: Configuration of fingerprint-reader
+ * Summary: FingerprintReader settings, input and output functions
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ *
+ * Representation of the configuration of fingerprint-reader.
+ * Input and output routines.
+ */
+
+{
+
+module "FingerprintReader";
+textdomain "fingerprint-reader";
+
+import "Arch";
+import "FileUtils";
+import "Pam";
+import "Popup";
+import "Progress";
+import "Report";
+import "Summary";
+
+/**
+ * Data was modified?
+ */
+global boolean modified = false;
+
+/**
+ * Required packages for this module to operate
+ */
+global list<string> required_packages = ["pam_thinkfinger"];
+
+// packages to install for specific architectures (see e.g. #224510)
+global map arch_packages = $[
+ "pam_thinkfinger" : $[
+ "ia64" : [ "pam_thinkfinger-x86" ],
+ "ppc64" : [ "pam_thinkfinger-64bit" ],
+ "s390_64" : [ "pam_thinkfinger-32bit" ],
+ "x86_64" : [ "pam_thinkfinger-32bit" ],
+ ],
+];
+
+/**
+ * Write only, used during autoinstallation.
+ * Don't run services and SuSEconfig, it's all done at one place.
+ */
+global boolean write_only = false;
+
+/**
+ * if Fingerprint Reader authentication is enabled
+ */
+global boolean use_pam = false;
+
+/**
+ * Directory with fingerprint files that should be imported
+ */
+global string import_dir = "";
+
+/**
+ * Directory for storing fingerprint files
+ */
+string bir_dir = "/etc/pam_thinkfinger";
+
+/**
+ * Get the list of fingerprint readers
+ */
+global list ReadFingerprintReaderDevices () {
+
+ list devices = (list) SCR::Read (.probe.fingerprint);
+ if (devices == nil)
+ devices = [];
+ return devices;
+}
+
+/**
+ * Read all fingerprint-reader settings
+ * @return true on success
+ */
+global boolean Read() {
+
+ list devices = ReadFingerprintReaderDevices ();
+
+ if (devices == [])
+ {
+ // error popup: no config of non-existent device
+ Report::Error (_("Fingerprint reader device is not available on this system."));
+ return false;
+ }
+
+ use_pam = Pam::Enabled ("thinkfinger");
+
+ modified = false;
+ return true;
+}
+
+/**
+ * Write all fingerprint-reader settings
+ * @return true on success
+ */
+global boolean Write() {
+
+ if (!modified)
+ return true;
+
+ // FingerprintReader read dialog captio
+ string caption = _("Saving Fingerprint Reader Configuration");
+
+ integer sl = 100;
+ sleep(sl);
+
+ // We do not set help text here, because it was set outside
+ Progress::New(caption, " ", 2, [
+ // Progress stage
+ _("Write the PAM settings"),
+ // Progress stage
+ _("Import fingerprint files"),
+ ], [
+ // Progress step
+ _("Writing the PAM settings..."),
+ // Progress step
+ _("Importing fingerprint files..."),
+ // Progress finished
+ _("Finished")
+ ],
+ ""
+ );
+
+ Progress::NextStage();
+
+ boolean pam_ret = use_pam ?
+ Pam::Add ("thinkfinger") : Pam::Remove ("thinkfinger");
+ if (!pam_ret)
+ // Error message
+ Report::Error (_("Cannot write PAM settings."));
+
+ sleep(sl);
+
+ Progress::NextStage();
+ if (use_pam && import_dir != "")
+ {
+ if (!FileUtils::Exists (bir_dir))
+ {
+ SCR::Execute (.target.mkdir, bir_dir);
+ }
+ map out = (map) SCR::Execute (.target.bash_output,
+ sformat ("/bin/cp %1/*.bir %2/", import_dir, bir_dir));
+ if (out["stderr"]:"" != "")
+ {
+ // error popup
+ Popup::ErrorDetails (_("Importing fingerprint files failed."),
+ out["stderr"]:"");
+ }
+ }
+
+ Progress::NextStage();
+ sleep(sl);
+
+ return true;
+}
+
+/**
+ * Get all fingerprint-reader settings from the first parameter
+ * (For use by autoinstallation.)
+ * @param settings The YCP structure to be imported.
+ * @return boolean True on success
+ */
+global boolean Import (map settings) {
+
+ use_pam = settings["use_pam"]:use_pam;
+ import_dir = settings["import_dir"]:import_dir;
+ return true;
+}
+
+/**
+ * Dump the fingerprint-reader settings to a single map
+ * (For use by autoinstallation.)
+ * @return map Dumped settings (later acceptable by Import ())
+ */
+global map Export () {
+ return $[
+ "use_pam" : use_pam,
+ "import_dir" : import_dir
+ ];
+}
+
+/**
+ * Create a textual summary and a list of unconfigured cards
+ * @return summary of the current configuration
+ */
+global list Summary() {
+
+ // summary header
+ string summary = Summary::AddHeader(summary, _("PAM Login"));
+
+ summary = Summary::AddLine (summary, (use_pam) ?
+ // summary item
+ _("Use Fingerprint Authentication") :
+ // summary item
+ _("Do Not Use Fingerprint Authentication"));
+ return [ summary, [] ];
+}
+
+/**
+ * Create a short textual summary
+ * @return summary of the current configuration
+ */
+global define string ShortSummary() {
+
+ return sformat (
+ // summary text (yes/no follows)
+ _("<b>Fingerprint Authentication Enabled</b>: %1<br>"), use_pam ?
+ // summary value
+ _("Yes") :
+ // summary value
+ _("No"));
+}
+
+/**
+ * Return list of architecture specific packages (derived from package list
+ * given as parameter) merged with the packages in parameter
+ */
+global define list<string> UpdatedArchPackages (list<string> packages) {
+
+ list<string> ret = packages;
+ string arch = Arch::architecture ();
+
+ foreach (string package, packages, {
+ ret = (list<string>) union (ret, arch_packages[package,arch]:[]);
+ });
+ return ret;
+}
+
+/**
+ * Return packages needed to be installed and removed during
+ * Autoinstallation to insure module has all needed software
+ * installed.
+ * @return map with 2 lists.
+ */
+global map AutoPackages() {
+ return $[ "install": required_packages, "remove":[] ];
+}
+
+/* EOF */
+}
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,28 @@
+# Makefile.am for fingerprint-reader/src
+
+yncludedir = @yncludedir@/fingerprint-reader
+
+client_DATA = \
+ fingerprint-reader.ycp \
+ users_plugin_fingerprint_reader.ycp
+
+ynclude_DATA = \
+ wizards.ycp \
+ dialogs.ycp \
+ helps.ycp
+
+desktop_DATA = \
+ fingerprint-reader.desktop
+
+module_DATA = \
+ FingerprintReader.ycp \
+ UsersPluginFingerprintReader.pm
+
+# create a symlink for local build, #145327
+fingerprint-reader:
+ ln -sf . $@
+ycpchook = fingerprint-reader
+
+EXTRA_DIST = $(client_DATA) $(ynclude_DATA) $(module_DATA) $(desktop_DATA)
+
+include $(top_srcdir)/Makefile.am.common
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/UsersPluginFingerprintReader.pm Fri Oct 5 11:34:11 2007
@@ -0,0 +1,358 @@
+#! /usr/bin/perl -w
+#
+# This is the API part of UsersPluginFingerprintReader plugin -
+# configuration of user's fingerprints on specific device
+#
+
+package UsersPluginFingerprintReader;
+
+use strict;
+
+use YaST::YCP qw(:LOGGING);
+use YaPI;
+use Data::Dumper;
+
+textdomain("fingerprint-reader");
+
+our %TYPEINFO;
+
+##--------------------------------------
+##--------------------- global imports
+
+YaST::YCP::Import ("Directory");
+YaST::YCP::Import ("FileUtils");
+YaST::YCP::Import ("FingerprintReader");
+YaST::YCP::Import ("Pam");
+YaST::YCP::Import ("SCR");
+YaST::YCP::Import ("Users");
+
+##--------------------------------------
+##--------------------- global variables
+
+# error message, returned when some plugin function fails
+my $error = "";
+
+my $fingerprint_reader_available = undef;
+
+# path to store fingerprints
+my $bir_path = "/etc/pam_thinkfinger";
+
+my $name = "UsersPluginFingerprintReader";
+
+##----------------------------------------
+##--------------------- internal functions
+
+# internal function:
+# check if given key (second parameter) is contained in a list (1st parameter)
+# if 3rd parameter is true (>0), ignore case
+sub contains {
+ my ($list, $key, $ignorecase) = @_;
+ if (!defined $list || ref ($list) ne "ARRAY" || @{$list} == 0) {
+ return 0;
+ }
+ if ($ignorecase) {
+ if ( grep /^\Q$key\E$/i, @{$list} ) {
+ return 1;
+ }
+ } else {
+ if ( grep /^\Q$key\E$/, @{$list} ) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+# helper, check if Fingerprint Reader was already configured
+sub fingerprint_reader_configured {
+
+ return Pam->Enabled ("thinkfinger");
+}
+
+# helper function: check if Fingerprint Reader (the device) is available
+sub is_fingerprint_reader_available {
+
+ if (not defined $fingerprint_reader_available) {
+ my @devices = @{FingerprintReader->ReadFingerprintReaderDevices ()};
+ $fingerprint_reader_available = (@devices > 0);
+ }
+ return $fingerprint_reader_available;
+}
+
+# check if given user has fingerprint authentication configured
+sub fingerprint_present {
+
+ my ($data) = @_;
+ my $username = $data->{"uid"};
+ return 0 if !$username;
+ my $org_username = $data->{"org_user"}{"uid"} || $username;
+ my $org_bir_file = "$bir_path/$org_username.bir";
+ return (FileUtils->Exists ($org_bir_file));
+}
+
+# check if bir file name corresponds with username
+sub adapt_fingerprint_info {
+
+ my ($config, $data) = @_;
+ my $username = $data->{"uid"};
+ my $org_username = $data->{"org_user"}{"uid"} || $username;
+ my $bir_file = $data->{"bir_file"};
+ return $data if !defined $username;
+ if (!defined $bir_file && $username ne $org_username) {
+ # When user was only renamed, but new fingerprint was not generated,
+ # there's no 'bir_file' entry in the map ->
+ # backup his original bir file to tmpdir so it won't get lost and can
+ # be correctly renamed in Write.
+ my $org_bir_file = "$bir_path/$org_username.bir";
+ if (FileUtils->Exists ($org_bir_file)) {
+ my $tmpdir = Directory->tmpdir ();
+ SCR->Execute (".target.bash", "/bin/cp $org_bir_file $tmpdir/$username.bir");
+ $data->{"bir_file"} = $username;
+ }
+ }
+ if ($bir_file && $bir_file ne $username) {
+ $data->{"bir_file"} = $username;
+ }
+ return $data;
+}
+
+# update the object data when removing plugin
+sub remove_plugin_data {
+
+ my ($config, $data) = @_;
+ $data->{"bir_file"} = "";
+ $data->{"plugin_modified"} = 1;
+ return $data;
+}
+
+##------------------------------------------
+##--------------------- global API functions
+
+# All functions have 2 "any" parameters: these mean:
+# 1st: configuration map (hash) - e.g. saying if we work with user or group
+# 2nd: data map (hash) of user/group to work with
+# for details, see UsersPluginLDAPAll.pm
+
+# return names of provided functions
+BEGIN { $TYPEINFO{Interface} = ["function", ["list", "string"], "any", "any"];}
+sub Interface {
+
+ my $self = shift;
+ my @interface = (
+ "GUIClient",
+ "Name",
+ "Summary",
+ "Restriction",
+ "Interface",
+ "PluginPresent",
+ "PluginRemovable",
+ "Error",
+ "AddBefore",
+ "Add",
+ "EditBefore",
+ "Edit",
+ "Delete",
+ "Write"
+ );
+ return \@interface;
+}
+
+# return error message, generated by plugin
+BEGIN { $TYPEINFO{Error} = ["function", "string", "any", "any"];}
+sub Error {
+
+ my $self = shift;
+ return $error;
+}
+
+
+# return plugin name, used for GUI (translated)
+BEGIN { $TYPEINFO{Name} = ["function", "string", "any", "any"];}
+sub Name {
+
+ my $self = shift;
+ # plugin name
+ return __("Fingerprint configuration");
+}
+
+##------------------------------------
+# return plugin summary (to be shown in table with all plugins)
+BEGIN { $TYPEINFO{Summary} = ["function", "string", "any", "any"];}
+sub Summary {
+
+ my $self = shift;
+ # plugin summary (table item)
+ my $ret = __("Set the user's fingerprint");
+ return $ret;
+}
+
+##------------------------------------
+# checks the current data map of user (2nd parameter) and returns
+# true if given user has our plugin
+BEGIN { $TYPEINFO{PluginPresent} = ["function", "boolean", "any", "any"];}
+sub PluginPresent {
+
+ my ($self, $config, $data) = @_;
+ return 0 if not fingerprint_reader_configured ();
+
+ if (contains ($data->{'plugins'}, $name, 1) || fingerprint_present ($data))
+ {
+ y2milestone ("$name plugin present");
+ return 1;
+ }
+ return 0;
+}
+
+##------------------------------------
+# Is it possible to remove this plugin from user?
+BEGIN { $TYPEINFO{PluginRemovable} = ["function", "boolean", "any", "any"];}
+sub PluginRemovable {
+ # doesn't have sense to remove
+ return YaST::YCP::Boolean (1);
+}
+
+
+##------------------------------------
+# return name of YCP client defining YCP GUI
+BEGIN { $TYPEINFO{GUIClient} = ["function", "string", "any", "any"];}
+sub GUIClient {
+
+ return "users_plugin_fingerprint_reader";
+}
+
+##------------------------------------
+# Type of objects this plugin is restricted to.
+# It defines:
+# 1. type of objects which it should be applied to (ldap/nis/local/system)
+# 2. type of objects at all (user)
+# If this function doesn't exist, plugin is applied for all users of all types
+BEGIN { $TYPEINFO{Restriction} = ["function",
+ ["map", "string", "any"], "any", "any"];}
+sub Restriction {
+
+ my $self = shift;
+ # do the check here, so the plugin is not shown when there is no hw for it
+ return {} if not is_fingerprint_reader_available ();
+ return {
+ "local" => 1,
+ "system" => 1,
+ # only for users
+ "user" => 1,
+ };
+}
+
+# this will be called at the beggining of Users::Add
+# Could be called multiple times for one user
+BEGIN { $TYPEINFO{AddBefore} = ["function",
+ ["map", "string", "any"],
+ "any", "any"];
+}
+sub AddBefore {
+
+ my ($self, $config, $data) = @_;
+
+ if (!fingerprint_reader_configured ()) {
+ # error popup
+ $error = __("Fingerprint reader is not configured. Run 'yast2-fingerprint-reader' to configure it");
+ return undef;
+ }
+ return $data;
+}
+
+# This will be called at the end of Users::Add* :
+# modify the object map with fingerprint-reader data
+BEGIN { $TYPEINFO{Add} = ["function", ["map", "string", "any"], "any", "any"];}
+sub Add {
+
+ my ($self, $config, $data) = @_;
+ if (contains ($data->{'plugins_to_remove'}, $name, 1)) {
+ y2milestone ("removing plugin $name...");
+ return remove_plugin_data ($config, $data);
+ }
+ return adapt_fingerprint_info ($config, $data);
+}
+
+# this will be called at the beggining of Users::Edit
+BEGIN { $TYPEINFO{EditBefore} = ["function",
+ ["map", "string", "any"],
+ "any", "any"];
+}
+sub EditBefore {
+
+ my ($self, $config, $data) = @_;
+
+ if (!fingerprint_reader_configured ()) {
+ # error popup
+ $error = __("Fingerprint reader is not configured. Run 'yast2-fingerprint-reader' to configure it");
+ return undef;
+ }
+ return $data;
+}
+
+# This will be called at the end of Users::Edit* :
+# modify the object map with fingerprint-reader data
+BEGIN { $TYPEINFO{Edit} = ["function",
+ ["map", "string", "any"],
+ "any", "any"];
+}
+sub Edit {
+
+ my ($self, $config, $data) = @_;
+ # "plugins_to_remove" is list of plugins which are set for removal
+ if (contains ($data->{'plugins_to_remove'}, $name, 1)) {
+ y2milestone ("removing plugin $name...");
+ return remove_plugin_data ($config, $data);
+ }
+ return adapt_fingerprint_info ($config, $data);
+}
+
+
+# What should be done after user is finally written (this is called only once):
+# - remove org_username.bir file,
+# but only when there is no other (new) user of that name
+# - move temporary bir file to correct location
+BEGIN { $TYPEINFO{Write} = ["function", "boolean", "any", "any"];}
+sub Write {
+
+ my ($self, $config, $data) = @_;
+
+ my $username = $data->{"uid"};
+ my $org_username = $data->{"org_user"}{"uid"} || $username;
+ my $bir_file = $data->{"bir_file"};
+ my $org_bir_file = "$bir_path/$org_username.bir";
+
+ if (($config->{"modified"} || "") eq "deleted") {
+ # check if some new user doesn't have the name of the deleted one
+ my $u = Users->GetUserByName ($org_username, "");
+ if (!defined $u->{"bir_file"}) {
+ $bir_file = "";
+ }
+ }
+ return if (!$username || ! defined $bir_file);
+ if ($username ne $org_username) {
+ # check if there was old bir-file
+ my $u = Users->GetUserByName ($org_username, "");
+ # do not delete birfile when some new user was added with the name
+ # of this one's original name
+ if (!defined $u->{"bir_file"} && FileUtils->Exists ($org_bir_file)) {
+ y2milestone ("removing old file $org_bir_file owned by $username");
+ SCR->Execute (".target.bash", "/bin/rm $org_bir_file");
+ }
+ }
+ elsif ($bir_file eq "" && FileUtils->Exists ($org_bir_file)) {
+ # disable fingerprint authentication for this user
+ # (now $org_username is same as $username)
+ y2milestone ("removing file $org_bir_file for user $username");
+ SCR->Execute (".target.bash", "/bin/rm $org_bir_file");
+ }
+ if ($bir_file) {
+ my $bir_file_path = Directory->tmpdir ();
+ $bir_file_path = "$bir_file_path/$bir_file.bir";
+ y2milestone ("moving $bir_file_path to $bir_path/");
+ SCR->Execute (".target.bash", "/bin/mv $bir_file_path $bir_path/");
+ }
+ return YaST::YCP::Boolean (1);
+}
+
+
+42
+# EOF
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/dialogs.ycp Fri Oct 5 11:34:11 2007
@@ -0,0 +1,188 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/fingerprint-reader/dialogs.ycp
+ * Package: Configuration of fingerprint-reader
+ * Summary: Dialogs definitions
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "fingerprint-reader";
+
+import "Confirm";
+import "FileUtils";
+import "FingerprintReader";
+import "Label";
+import "Package";
+import "Popup";
+import "Stage";
+import "Wizard";
+
+include "fingerprint-reader/helps.ycp";
+
+boolean ReallyAbort() {
+ return !FingerprintReader::modified || Popup::ReallyAbort(true);
+}
+
+/**
+ * Read settings dialog
+ * @return `abort if aborted and `next otherwise
+ */
+symbol ReadDialog() {
+ Wizard::RestoreHelp(HELPS["read"]:"");
+ if (!Confirm::MustBeRoot()) return `abort;
+ boolean ret = FingerprintReader::Read();
+ return ret ? `next : `abort;
+}
+
+/**
+ * Write settings dialog
+ * @return `abort if aborted and `next otherwise
+ */
+symbol WriteDialog() {
+ Wizard::RestoreHelp(HELPS["write"]:"");
+ boolean ret = FingerprintReader::Write();
+ return ret ? `next : `abort;
+}
+
+/**
+ * Main configuration dialog
+ * @return dialog result
+ */
+any FingerprintReaderDialog() {
+
+ // FingerprintReader summary dialog caption
+ string caption = _("Fingerprint Reader Configuration");
+
+ boolean use_pam = FingerprintReader::use_pam;
+ // help text
+ string help_text = _("<p>
+<b><big>Fingerprint Authentication</big></b><br>
+The Fingerprint Reader Configuration updates your PAM settings to enable authentication with fingerprints.</p>") +
+
+ // help text, cont.
+ _("<p>To <b>import fingerprint files</b> from different installations, choose the directory where the files are located.</p>");
+
+ term con = `HBox (`HSpacing (3), `VBox (
+ // frame label
+ `Frame (_("User Authentication"), `HBox(`HSpacing (0.5), `VBox(
+ `VSpacing (0.5),
+ `RadioButtonGroup (`id(`rd),
+ `Left (`HVSquash(`VBox (
+ `Left (`RadioButton (`id(`pamno), `opt (`notify),
+ // radio button label
+ _("Do No&t Use Fingerprint Reader"), !use_pam)),
+ `Left (`RadioButton (`id(`pamyes), `opt (`notify),
+ // radio button label
+ _("&Use Fingerprint Reader"), use_pam))
+ )))
+ ),
+ `VSpacing (0.5)
+ ), `HSpacing (0.5))),
+ `VSpacing (),
+ `HBox (
+ // textentry label
+ `TextEntry (`id(`import_dir),_("Directory with fingerprint files")),
+ `VBox (
+ `Label (""),
+ `PushButton (`id (`browse), Label::BrowseButton ())
+ )
+ )
+ ), `HSpacing(3));
+
+ Wizard::SetContentsButtons (caption, con, help_text,
+ Stage::cont () ? Label::BackButton () : Label::CancelButton (),
+ Stage::cont () ? Label::NextButton () : Label::FinishButton ()
+ );
+ Wizard::SetTitleIcon ("yast-fingerprint");
+ if (!Stage::cont ())
+ Wizard::HideAbortButton ();
+
+ UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam);
+ UI::ChangeWidget (`id (`browse), `Enabled, use_pam);
+
+ any ret = nil;
+ while (true) {
+
+ ret = UI::UserInput();
+ string import_dir = (string)UI::QueryWidget (`id (`import_dir), `Value);
+
+ if (ret == `pamyes || ret == `pamno)
+ {
+ use_pam = (ret == `pamyes);
+ UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam);
+ UI::ChangeWidget (`id (`browse), `Enabled, use_pam);
+ }
+
+ if (ret == `abort || ret == `cancel || ret == `back) {
+ if(ReallyAbort()) break;
+ else continue;
+ }
+ else if (ret == `browse) {
+ string dir = UI::AskForExistingDirectory (import_dir, "");
+ if (dir != nil)
+ {
+ if ((findlastof (dir, "/") + 1) == size(dir))
+ dir = substring (dir, 0, size(dir)-1);
+ UI::ChangeWidget (`id(`home), `Value, dir);
+ }
+ }
+ else if (ret == `next) {
+ if (use_pam && import_dir != "" &&
+ !FileUtils::IsDirectory (import_dir))
+ {
+ // error popup
+ Report::Error (_("The path to fingerprint files
+does not point to the valid directory."));
+ UI::SetFocus (`id (`import_dir));
+ continue;
+ }
+ if (use_pam &&
+ !Package::InstallAll (FingerprintReader::UpdatedArchPackages (
+ FingerprintReader::required_packages))
+ )
+ {
+ use_pam = false;
+ UI::ChangeWidget (`id (`rd), `Value, `pamno);
+ UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam);
+ UI::ChangeWidget (`id (`browse), `Enabled, use_pam);
+ continue;
+ }
+ if (use_pam != FingerprintReader::use_pam ||
+ (use_pam && import_dir != ""))
+ {
+ FingerprintReader::modified = true;
+ FingerprintReader::use_pam = use_pam;
+ FingerprintReader::import_dir = import_dir;
+ }
+ break;
+ }
+ }
+ return ret;
+}
+
+
+/* EOF */
+}
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader Fri Oct 5 11:34:11 2007
@@ -0,0 +1 @@
+link .
\ No newline at end of file
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.desktop
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.desktop (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.desktop Fri Oct 5 11:34:11 2007
@@ -0,0 +1,24 @@
+[Desktop Entry]
+Type=Application
+Categories=Qt;X-SuSE-YaST;X-SuSE-YaST-Misc;
+
+X-KDE-ModuleType=Library
+X-KDE-RootOnly=true
+X-KDE-HasReadOnlyMode=true
+X-KDE-Library=yast2
+X-SuSE-YaST-Call=fingerprint-reader
+
+X-SuSE-YaST-Group=Hardware
+X-SuSE-YaST-Argument=
+X-SuSE-YaST-RootOnly=true
+X-SuSE-YaST-AutoInst=
+X-SuSE-YaST-Geometry=
+X-SuSE-YaST-SortKey=
+X-SuSE-YaST-AutoInstResource=fingerprint-reader
+
+Icon=yast-fingerprint
+Exec=/sbin/yast2 fingerprint-reader
+
+Name=Fingerprint Reader
+GenericName=Set up fingerprint authentication
+X-KDE-SubstituteUID=true
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/fingerprint-reader.ycp Fri Oct 5 11:34:11 2007
@@ -0,0 +1,93 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: clients/fingerprint-reader.ycp
+ * Package: Configuration of fingerprint-reader
+ * Summary: Main file
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ *
+ * Main file for fingerprint-reader configuration. Uses all other files.
+ */
+
+{
+
+/***
+ * <h3>Configuration of fingerprint-reader</h3>
+ */
+
+textdomain "fingerprint-reader";
+
+/* The main () */
+y2milestone ("----------------------------------------");
+y2milestone ("FingerprintReader module started");
+
+import "Progress";
+import "Report";
+import "Summary";
+
+import "CommandLine";
+include "fingerprint-reader/wizards.ycp";
+
+map cmdline_description = $[
+ "id" : "fingerprint-reader",
+ /* Command line help text for the Xfingerprint-reader module */
+ "help" : _("Configuration of fingerprint-reader"),
+ "guihandler" : FingerprintReaderSequence,
+ "initialize" : FingerprintReader::Read,
+ "finish" : FingerprintReader::Write,
+ "actions" : $[
+ // FIXME TODO: fill the functionality description here
+ ],
+ "options" : $[
+ // FIXME TODO: fill the option descriptions here
+ ],
+ "mappings" : $[
+ // FIXME TODO: fill the mappings of actions and options here
+ ]
+];
+
+/* is this proposal or not? */
+boolean propose = false;
+list args = WFM::Args();
+if(size(args) > 0) {
+ if(is(WFM::Args(0), path) && WFM::Args(0) == .propose) {
+ y2milestone("Using PROPOSE mode");
+ propose = true;
+ }
+}
+
+/* main ui function */
+any ret = nil;
+
+if(propose) ret = FingerprintReaderAutoSequence();
+else ret = CommandLine::Run(cmdline_description);
+y2debug("ret=%1", ret);
+
+/* Finish */
+y2milestone("FingerprintReader module finished");
+y2milestone("----------------------------------------");
+
+return ret;
+
+/* EOF */
+}
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/helps.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/helps.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/helps.ycp Fri Oct 5 11:34:11 2007
@@ -0,0 +1,64 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/fingerprint-reader/helps.ycp
+ * Package: Configuration of fingerprint-reader
+ * Summary: Help texts of all the dialogs
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "fingerprint-reader";
+
+/**
+ * All helps are here
+ */
+map HELPS = $[
+
+ /* Read dialog help 1/2 */
+ "read" : _("<p><b><big>Initializing Fingerprint Reader Configuration</big></b><br>
+Please wait...<br></p>
+") +
+
+ /* Read dialog help 2/2 */
+ _("<p><b><big>Aborting Initialization:</big></b><br>
+Safely abort the configuration utility by pressing <b>Abort</b> now.</p>
+"),
+
+ /* Write dialog help 1/2 */
+ "write" : _("<p><b><big>Saving Fingerprint Reader Configuration</big></b><br>
+Please wait...<br></p>
+") +
+
+ /* Write dialog help 2/2 */
+_("<p><b><big>Aborting Saving:</big></b><br>
+Abort the save procedure by pressing <b>Abort</b>.
+An additional dialog informs whether it is safe to do so.
+</p>
+"),
+
+];
+
+/* EOF */
+}
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp Fri Oct 5 11:34:11 2007
@@ -0,0 +1,229 @@
+/**
+ * File:
+ * include/users/users_plugin_fingerprint_reader.ycp
+ *
+ * Package:
+ * Configuration of Fingerprint Reader
+ *
+ * Summary:
+ * GUI part of plugin (UsersPluginFingerprintReader) used to manage
+ * user fingerprints on the appropriate hardware
+ *
+ * Authors:
+ * Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ */
+
+{
+ textdomain "fingerprint-reader";
+
+ import "Directory";
+ import "Label";
+ import "Users";
+ import "UsersPluginFingerprintReader";
+ import "Wizard";
+
+ any ret = nil;
+ string func = "";
+ map<string,any> config = $[];
+ map<string,any> data = $[];
+
+ /* Check arguments */
+ if(size(WFM::Args()) > 0 && is(WFM::Args(0), string)) {
+ func = (string) WFM::Args(0);
+ if(size(WFM::Args()) > 1 && is(WFM::Args(1), map))
+ config = (map<string,any>)WFM::Args(1);
+ if(size(WFM::Args()) > 2 && is(WFM::Args(2), map))
+ data = (map<string,any>)WFM::Args(2);
+ }
+ y2milestone("----------------------------------------");
+ y2milestone("users plugin started: FingerprintReader");
+
+ y2debug ("func=%1, config=%2, data=%3", func,config,data);
+
+ if (func == "Summary") {
+ ret = UsersPluginFingerprintReader::Summary (config, $[]);
+ }
+ else if (func == "Name") {
+ ret = UsersPluginFingerprintReader::Name (config, $[]);
+ }
+ else if (func == "Dialog") {
+
+ string caption = UsersPluginFingerprintReader::Name (config, $[]);
+ // help text for fingerprint reader plugin
+ string help_text = _("<p>Swipe your finger on the fingerprint reader. Three successful attempts
+are needed to save the new fingerprint.</p>");
+ string username = data["uid"]:"";
+ if (username == "")
+ {
+ y2error ("user name is empty!");
+ return `back;
+ }
+ string bir_path = Directory::tmpdir + "/" + username + ".bir";
+
+ term contents = `HBox (`HSpacing (1.5), `VBox(
+ `VSpacing(0.5),
+ `ReplacePoint (`id (`rp),
+ // status label
+ `Label (`id (`label), _("Initializing fingerprint reader..."))
+ ),
+ `ReplacePoint (`id (`rpstatus), `VSpacing ()),
+ `PushButton (`id (`cancel), Label::CancelButton ()),
+ `VSpacing (0.5)
+ ),
+ `HSpacing (1.5)
+ );
+
+ Wizard::CreateDialog ();
+ Wizard::SetTitleIcon ("yast-fingerprint");
+
+ // dialog caption
+ Wizard::SetContentsButtons(caption, contents, help_text,
+ Label::BackButton(), Label::AcceptButton());
+
+ Wizard::HideAbortButton ();
+ Wizard::DisableNextButton ();
+ Wizard::DisableBackButton ();
+
+ boolean exit = false;
+ any ui = nil;
+ integer exit_status = 256;
+ integer swipe_success = 0;
+ integer swipe_failed = 0;
+
+ // helper function, form the string for UI from actuall data
+ void replace_swipe_string () {
+
+ UI::ReplaceWidget (`id (`rpstatus), `Label (
+ // status message (%1, %2 are numbers)
+ sformat (_("Successful swipes: %1, failed swipes: %2"),
+ swipe_success, swipe_failed)
+ ));
+ }
+ if (SCR::Execute (.thinkfinger.add-user, bir_path) != true)
+ {
+ ui = `cancel;
+ // status message
+ UI::ReplaceWidget (`id (`rp),
+ `Label (_("Initialization of fingerprint reader failed.")));
+ }
+ while (ui != `cancel)
+ {
+ map statemap = (map) SCR::Read (.thinkfinger.state);
+ if (statemap != nil && statemap != $[])
+ {
+ integer state = statemap["state"]:0;
+ switch (state) {
+ case 8: { // TF_STATE_ACQUIRE_SUCCESS
+ UI::ReplaceWidget (`id (`rp),
+ // status label
+ `Label (_("Storing data...")));
+ UI::ReplaceWidget (`id (`rpstatus), `VSpacing ());
+ exit = true;
+ break;
+ }
+ case 7: { // TF_STATE_ENROLL_SUCCESS
+ UI::ReplaceWidget (`id (`rp),
+ // status label
+ `Label (_("Storing data...")));
+ UI::ReplaceWidget (`id (`rpstatus), `VSpacing ());
+ exit = true;
+ break;
+ }
+ case 9: { // TF_STATE_ACQUIRE_FAILED
+ UI::ReplaceWidget (`id (`rp),
+ `Label (_("Acquiring fingerprint failed.")));
+ exit = true;
+ break;
+ }
+ case 2: { // TF_STATE_SWIPE_0
+ UI::ReplaceWidget (`id (`rp),
+ `Label (_("Please swipe your finger...")));
+ break;
+ }
+ case 5: { // TF_STATE_SWIPE_SUCCESS
+ swipe_success = swipe_success + 1;
+ replace_swipe_string ();
+ break;
+ }
+ case 6: { // TF_STATE_SWIPE_AFILED
+ swipe_failed = swipe_failed + 1;
+ replace_swipe_string ();
+ break;
+ }
+ }
+ }
+ else if (statemap == nil)
+ {
+y2internal ("statemap is nil - error?");
+ exit_status = (integer) SCR::Read (.thinkfinger.exit_status);
+ break;
+ }
+ if (exit)
+ {
+ exit_status = (integer) SCR::Read (.thinkfinger.exit_status);
+ break;//must be before check for cancel
+ }
+
+ ui = UI::PollInput ();
+
+ if (ui == `cancel || ui == `back)
+ {
+ SCR::Execute (.thinkfinger.cancel);
+ y2internal ("exit status after cancel: %1", SCR::Read (.thinkfinger.exit_status));
+ break;
+ }
+ sleep (100);
+ }
+ y2milestone ("agent exit status: %1", exit_status);
+ // 9 is failed acquire, 253 is USB error, 254 communication error
+ // FIXME what's the meaning of TF_STATE_ENROLL_SUCCESS (7)?
+ if (exit_status == 7 || exit_status == 8)
+ {
+ // status label
+ UI::ReplaceWidget (`id (`rp), `Label (_("Fingerprint acquired successfully.")));
+ UI::ReplaceWidget (`id (`rpstatus), `Label (""));
+ // new id was already saved
+ Wizard::DisableBackButton ();
+ Wizard::EnableNextButton ();
+ }
+ else
+ {
+ // error message, part 1
+ string error = _("Could not acquire fingerprint.");
+ string details = "";
+ if (exit_status == 253)
+ // error message, part 2
+ details = _("USB error occured.");
+ else if (exit_status == 254)
+ // error message, part 2
+ details = _("Communication with fingerprint reader failed.");
+ if (exit_status != 256)
+ {
+ UI::ReplaceWidget (`id (`rp), `Label (error));
+ if (details != "")
+ UI::ReplaceWidget (`id (`rpstatus), `Label (details));
+ }
+ Wizard::EnableBackButton ();
+ }
+ UI::ChangeWidget (`id (`cancel), `Enabled, false);
+ ret = UI::UserInput ();
+ if (ret == `next)
+ {
+ // modified data to add to user
+ map<string, any> tmp_data = $[
+ "bir_file" : username,
+ "plugin_modified" : 1
+ ];
+ if (data["what"]:"" == "edit_user")
+ Users::EditUser (tmp_data);
+ else if (data["what"]:"" == "add_user")
+ Users::AddUser (tmp_data);
+ }
+ Wizard::CloseDialog ();
+ }
+ y2milestone("users plugin finished with %1", ret);
+ y2milestone("----------------------------------------");
+ return ret;
+}
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/wizards.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/wizards.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/src/wizards.ycp Fri Oct 5 11:34:11 2007
@@ -0,0 +1,121 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/fingerprint-reader/wizards.ycp
+ * Package: Configuration of fingerprint-reader
+ * Summary: Wizards definitions
+ * Authors: Jiri Suchomel <jsuchome(a)suse.cz>
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "fingerprint-reader";
+
+import "Sequencer";
+import "Wizard";
+
+include "fingerprint-reader/dialogs.ycp";
+
+/**
+ * Main workflow of the fingerprint-reader configuration
+ * @return sequence result
+ */
+any MainSequence() {
+
+ map aliases = $[
+ "summary" : ``( FingerprintReaderDialog () ),
+ ];
+
+ map sequence = $[
+ "ws_start" : "summary",
+ "summary" : $[
+ `abort : `abort,
+ `next : `next,
+ ],
+ ];
+
+ any ret = Sequencer::Run(aliases, sequence);
+
+ return ret;
+}
+
+/**
+ * Whole configuration of fingerprint-reader
+ * @return sequence result
+ */
+any FingerprintReaderSequence() {
+
+ map aliases = $[
+ "read" : [ ``( ReadDialog() ), true ],
+ "main" : ``( MainSequence() ),
+ "write" : [ ``( WriteDialog() ), true ]
+ ];
+
+ map sequence = $[
+ "ws_start" : "read",
+ "read" : $[
+ `abort : `abort,
+ `next : "main"
+ ],
+ "main" : $[
+ `abort : `abort,
+ `next : "write"
+ ],
+ "write" : $[
+ `abort : `abort,
+ `next : `next
+ ]
+ ];
+
+ Wizard::CreateDialog();
+
+ any ret = Sequencer::Run(aliases, sequence);
+
+ UI::CloseDialog();
+ return ret;
+}
+
+/**
+ * Whole configuration of fingerprint-reader but without reading and writing.
+ * For use with autoinstallation.
+ * @return sequence result
+ */
+any FingerprintReaderAutoSequence() {
+
+ /* Initialization dialog caption */
+ string caption = _("Fingerprint Reader Configuration");
+ /* Initialization dialog contents */
+ term contents = `Label(_("Initializing..."));
+
+ Wizard::CreateDialog();
+ Wizard::SetContentsButtons(caption, contents, "",
+ Label::BackButton(), Label::NextButton());
+
+ any ret = MainSequence();
+
+ UI::CloseDialog();
+ return ret;
+}
+
+/* EOF */
+}
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/testsuite/Makefile.am (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/testsuite/Makefile.am Fri Oct 5 11:34:11 2007
@@ -0,0 +1,21 @@
+#
+# Makefile.am for .../testsuite
+#
+# Do not edit this file (Makefile.am) as it will be overwritten!
+#
+
+AUTOMAKE_OPTIONS = dejagnu
+EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard tests/*.ycp) $(wildcard tests/*.yh)
+
+testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite
+
+all-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir)
+
+clean-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean
+
+check-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check
+
+# EOF
Added: branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/yast2-fingerprint-reader.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/finger…
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/yast2-fingerprint-reader.spec.in (added)
+++ branches/SuSE-SLE-10-SP1-Branch/fingerprint-reader/yast2-fingerprint-reader.spec.in Fri Oct 5 11:34:11 2007
@@ -0,0 +1,34 @@
+@HEADER-COMMENT@
+
+@HEADER@
+Requires: yast2 yast2-pam
+BuildRequires: libthinkfinger libusb-devel
+BuildRequires: doxygen gcc-c++ yast2-core-devel perl-XML-Writer update-desktop-files yast2 yast2-devtools yast2-testsuite yast2-pam
+
+Conflicts: yast2-hardware-detection < 2.15.7
+
+Summary: Configuration of fingerprint reader
+
+%description
+-
+
+@PREP@
+
+@BUILD@
+
+@INSTALL@
+
+@CLEAN@
+
+%files
+%defattr(-,root,root)
+%dir @yncludedir@/fingerprint-reader
+@yncludedir@/fingerprint-reader/*
+@clientdir@/fingerprint-reader.ycp
+@clientdir@/users_plugin_fingerprint_reader.ycp
+@moduledir@/FingerprintReader.*
+@moduledir@/UsersPluginFingerprintReader.pm
+@desktopdir@/fingerprint-reader.desktop
+@scrconfdir@/*.scr
+@plugindir@/libpy2ag_thinkfinger.*
+%doc @docdir@
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
Author: mvidner
Date: Thu Oct 4 17:02:01 2007
New Revision: 41265
URL: http://svn.opensuse.org/viewcvs/yast?rev=41265&view=rev
Log:
Created tag stable-2_16_1 for core
Added:
tags/stable-2_16_1/core/
- copied from r41264, trunk/core/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
Author: jsrain
Date: Thu Oct 4 16:35:11 2007
New Revision: 41264
URL: http://svn.opensuse.org/viewcvs/yast?rev=41264&view=rev
Log:
Created tag stable-2_16_1 for yast2
Added:
tags/stable-2_16_1/yast2/
- copied from r41263, trunk/yast2/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r41263 - in /trunk/yast2: VERSION library/system/src/Kernel.ycp package/yast2.changes
by jsrain@svn.opensuse.org 04 Oct '07
by jsrain@svn.opensuse.org 04 Oct '07
04 Oct '07
Author: jsrain
Date: Thu Oct 4 16:29:37 2007
New Revision: 41263
URL: http://svn.opensuse.org/viewcvs/yast?rev=41263&view=rev
Log:
install bigsmp kernel regardless the memory size (Fate #159006)
Modified:
trunk/yast2/VERSION
trunk/yast2/library/system/src/Kernel.ycp
trunk/yast2/package/yast2.changes
Modified: trunk/yast2/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/VERSION?rev=41263&r1=41262…
==============================================================================
--- trunk/yast2/VERSION (original)
+++ trunk/yast2/VERSION Thu Oct 4 16:29:37 2007
@@ -1 +1 @@
-2.16.0
+2.16.1
Modified: trunk/yast2/library/system/src/Kernel.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/system/src/Kernel.…
==============================================================================
--- trunk/yast2/library/system/src/Kernel.ycp (original)
+++ trunk/yast2/library/system/src/Kernel.ycp Thu Oct 4 16:29:37 2007
@@ -384,15 +384,16 @@
y2error ("Cannot read cpuflags");
y2milestone ("Mounted: %1", SCR::Execute (.target.bash_output, "mount -l"));
}
-
+/*
// check for "roughly" >= 4GB memory (see bug #40729)
list memories = (list) SCR::Read(.probe.memory);
integer memsize = memories[0,"resource","phys_mem",0,"range"]:0;
integer fourGB = 0x0C0000000;
y2milestone ("Physical memory %1", memsize);
-
+*/
// for memory > 4GB and PAE support we install kernel-bigsmp,
- if (memsize >= fourGB && contains (cpuflags, "pae"))
+ // only check PAE CPU
+ if (/*memsize >= fourGB &&*/ contains (cpuflags, "pae"))
{
y2milestone ("Kernel switch: PAE detected");
kernel_packages = ["kernel-bigsmp"];
Modified: trunk/yast2/package/yast2.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=…
==============================================================================
--- trunk/yast2/package/yast2.changes (original)
+++ trunk/yast2/package/yast2.changes Thu Oct 4 16:29:37 2007
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Thu Oct 4 16:29:01 CEST 2007 - jsrain(a)suse.cz
+
+- install bigsmp kernel regardless the memory size (Fate #159006)
+- 2.16.1
+
+-------------------------------------------------------------------
Wed Oct 3 09:39:45 CEST 2007 - mvidner(a)suse.cz
- Do not try to package COPYRIGHT.english, it is gone from
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0