[yast-commit] r52681 - in /trunk/printer: VERSION package/yast2-printer.changes src/Printerlib.ycp src/autoconfig.ycp
Author: jsmeix Date: Wed Oct 29 16:07:17 2008 New Revision: 52681 URL: http://svn.opensuse.org/viewcvs/yast?rev=52681&view=rev Log: - Added functionality to remove the cups-autoconfig RPM in the Autoconfig Settings dialog. - 2.17.28 Modified: trunk/printer/VERSION trunk/printer/package/yast2-printer.changes trunk/printer/src/Printerlib.ycp trunk/printer/src/autoconfig.ycp Modified: trunk/printer/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=52681&r1=52680&r2=52681&view=diff ============================================================================== --- trunk/printer/VERSION (original) +++ trunk/printer/VERSION Wed Oct 29 16:07:17 2008 @@ -1 +1 @@ -2.17.27 +2.17.28 Modified: trunk/printer/package/yast2-printer.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=52681&r1=52680&r2=52681&view=diff ============================================================================== --- trunk/printer/package/yast2-printer.changes (original) +++ trunk/printer/package/yast2-printer.changes Wed Oct 29 16:07:17 2008 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Wed Oct 29 15:56:32 CET 2008 - jsmeix@suse.de + +- Added a AskForExistingFile popup dialog in the Add Driver + dialog to browse the file system to select a PPD file. +- Added functionality to remove the cups-autoconfig RPM + in the Autoconfig Settings dialog. +- 2.17.28 + +------------------------------------------------------------------- Fri Oct 24 12:03:52 CEST 2008 - jsmeix@suse.de - Fixed some bugs in the Add Driver dialog. Modified: trunk/printer/src/Printerlib.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=52681&r1=52680&r2=52681&view=diff ============================================================================== --- trunk/printer/src/Printerlib.ycp (original) +++ trunk/printer/src/Printerlib.ycp Wed Oct 29 16:07:17 2008 @@ -92,24 +92,24 @@ // but I am only interested in real package names here. if( "installed" == action ) { if( ExecuteBashCommand( "rpm -q '" + package_name + "'" ) ) - { y2milestone( "package '%1' is installed", result["stdout"]:package_name ); + { y2milestone( "TestAndInstallPackage: package '%1' is installed", result["stdout"]:package_name ); return true; } // The "%1" makes the YCP Parser happy, otherwise it shows the warning // "Format string is not constant, no parameter checking possible". - y2milestone( "%1", result["stdout"]:"package is not installed" ); + y2milestone( "TestAndInstallPackage: %1", result["stdout"]:"TestAndInstallPackage: package is not installed" ); return false; } if( "install" == action ) { if( ExecuteBashCommand( "rpm -q '" + package_name + "'" ) ) - { y2milestone( "package '%1' is already installed", result["stdout"]:package_name ); + { y2milestone( "TestAndInstallPackage: package '%1' is already installed", result["stdout"]:package_name ); return true; } // Is the package available to be installed? // Package::Available returns nil if no package source is available. boolean package_available = Package::Available( package_name ); if( nil == package_available ) - { y2milestone( "Required package %1 is not installed and there is no package repository available.", package_name ); + { y2milestone( "TestAndInstallPackage: Required package %1 is not installed and there is no package repository available.", package_name ); Popup::Error( sformat( // Message of a Popup::Error where %1 will be replaced by the package name: _("Required package %1 is not installed and there is no package repository available."), package_name @@ -118,7 +118,7 @@ return false; } if( ! package_available ) - { y2milestone( "Required package %1 is not installed and not available in the repository.", package_name ); + { y2milestone( "TestAndInstallPackage: Required package %1 is not installed and not available in the repository.", package_name ); Popup::Error( sformat( // Message of a Popup::Error where %1 will be replaced by the package name: _("Required package %1 is not installed and not available in the repository."), package_name @@ -127,7 +127,7 @@ return false; } if( ! Package::Install( package_name ) ) - { y2milestone( "Failed to install required package %1.", package_name ); + { y2milestone( "TestAndInstallPackage: Failed to install required package %1.", package_name ); Popup::Error( // Message of a Popup::Error where %1 will be replaced by the package name. // Only a simple message because: // Either the user has explicitely rejected to install the package, @@ -142,11 +142,11 @@ } if( "remove" == action ) { if( ! ExecuteBashCommand( "rpm -q '" + package_name + "'" ) ) - { y2milestone( "skip remove because %1", result["stdout"]:"package is not installed" ); + { y2milestone( "TestAndInstallPackage: skip remove because %1", result["stdout"]:"package is not installed" ); return true; } if( ! Package::Remove( package_name ) ) - { y2milestone( "Failed to remove package %1.", package_name ); + { y2milestone( "TestAndInstallPackage: Failed to remove package %1.", package_name ); Popup::Error( // Message of a Popup::Error where %1 will be replaced by the package name. // Only a simple message because: // Either the user has explicitely rejected to remove the package, Modified: trunk/printer/src/autoconfig.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/autoconfig.ycp?rev=52681&r1=52680&r2=52681&view=diff ============================================================================== --- trunk/printer/src/autoconfig.ycp (original) +++ trunk/printer/src/autoconfig.ycp Wed Oct 29 16:07:17 2008 @@ -36,6 +36,7 @@ include "printer/helps.ycp"; +boolean autoconfig_settings_dialog_is_useless = false; // By default the ConfigureNewPrinters value in /etc/cups-autoconfig.conf is set to "yes": boolean initial_cups_autoconfig_ConfigureNewPrinters = true; // By default the DisablePrintersOnRemoval value in /etc/cups-autoconfig.conf is set to "no": @@ -52,47 +53,77 @@ _("Specify in which way USB printers are configured automatically") ) ), - `Left - ( `CheckBox - ( `id("cups_autoconfig_configure_new_attachend"), - // CheckBox to enable that a print queue is automatically created - // when a USB printer is connected for the first time to the USB: - _("Enable &Automatic Configuration of New Attachend USB Printers") - ) - ), - `Left - ( `CheckBox - ( `id("cups_autoconfig_disable_on_removal"), - // CheckBox to disable the print queue - // when a USB printer is disconnected from the USB: - _("&Disable Printout when Disconnecting an USB Printer") - ) - ), - `Left - ( `ComboBox - ( `id("cups_autoconfig_operation_policy"), - // Header for a ComboBox to specify the CUPS operation policy - // for print queues which are automatically created - // when a USB printer is connected for the first time to the USB: - _("Operation &Policy for Automatically Configured USB Printers"), - [""] + // Have space between the header and the choices: + `VSpacing( 1 ), + `HBox + ( `HSpacing( 3 ), + `VBox + ( `Left + ( `CheckBox + ( // Use a CheckBox to remove the cups-autoconfig RPM package + // instead of a RadioButton because this is the only RadioButton + // because there is no RadioButton to install cups-autoconfig + // because initAutoconfig checks if cups-autoconfig is installed + // and if not it tries to install it. + `id("cups_autoconfig_remove"), + // CheckBox to have no automatic configuration of USB printers at all + // by removing the cups-autoconfig RPM package. + // Do not change or translate "cups-autoconfig", it is a RPM package name. + _("No Automatic Configuration at all: &Remove the cups-autoconfig package.") + ) + ), + // Have space between the choice "No Automatic Configuration at all" + // and the settings when automatic configuration is used: + `VSpacing( 1 ), + `Left + ( `CheckBox + ( `id("cups_autoconfig_configure_new_attachend"), + // CheckBox to enable that a print queue is automatically created + // when a USB printer is connected for the first time to the USB: + _("Enable &Automatic Configuration of New Attachend USB Printers") + ) + ), + `Left + ( `CheckBox + ( `id("cups_autoconfig_disable_on_removal"), + // CheckBox to disable the print queue + // when a USB printer is disconnected from the USB: + _("&Disable Printout when Disconnecting an USB Printer") + ) + ), + `Left + ( `ComboBox + ( `id("cups_autoconfig_operation_policy"), + // Header for a ComboBox to specify the CUPS operation policy + // for print queues which are automatically created + // when a USB printer is connected for the first time to the USB: + _("Operation &Policy for Automatically Configured USB Printers"), + [""] + ) + ) ) ) ); void initAutoconfig( string key ) { y2milestone( "entering initAutoconfig with key '%1'", key ); - // The whole Autoconfig Settings dialog is useless without having cups-autoconfig installed: + // The whole Autoconfig Settings dialog is useless without having cups-autoconfig installed. + // Therefore check if cups-autoconfig is installed and if not try to install it. + // It is perfectly o.k. when the user rejects cups-autoconfig to be installed + // (perhaps he selected it to be removed before in this dialog + // and re-launched this dialog by accident or to check the current setting). + // Therefore there is no additional message shown here when the dialog is useless + // because there was a Popup request that cups-autoconfig must be installed. boolean autoconfig_settings_dialog_is_useless = false; - if( ! Printerlib::TestAndInstallPackage( "cups-autoconfig", "install" ) ) - { autoconfig_settings_dialog_is_useless = true; - Popup::Error( // Popup::Error message - // Do not change or translate "cups-autoconfig", it is a RPM package name. - _("This dialog is useless without having the package cups-autoconfig installed") - ); + if( ! Printerlib::TestAndInstallPackage( "cups-autoconfig", "installed" ) ) + { if( ! Printerlib::TestAndInstallPackage( "cups-autoconfig", "install" ) ) + { autoconfig_settings_dialog_is_useless = true; + } } + UI::ChangeWidget( `id("cups_autoconfig_remove"), `Value, autoconfig_settings_dialog_is_useless ); // Read cups-autoconfig settings. - // Ignore errors when the bash commands fail because the default values are used as fallback values. + // Ignore errors when the bash commands fail because the default values are used as + // fallback values in particular when the cups-autoconfig RPM is not installed. // By default the ConfigureNewPrinters value in /etc/cups-autoconfig.conf is set to "yes": initial_cups_autoconfig_ConfigureNewPrinters = true; Printerlib::ExecuteBashCommand( "grep -i '^ConfigureNewPrinters' /etc/cups-autoconfig.conf | cut -s -d '=' -f2 | tr -d -c '[:alnum:]'" ); @@ -148,7 +179,8 @@ { UI::ChangeWidget( `id("cups_autoconfig_operation_policy"), `Value, "not set" ); } if( autoconfig_settings_dialog_is_useless ) - { UI::ChangeWidget( `id("cups_autoconfig_label"), `Enabled, false ); + { UI::ChangeWidget( `id("cups_autoconfig_remove"), `Enabled, false ); + UI::ChangeWidget( `id("cups_autoconfig_label"), `Enabled, false ); UI::ChangeWidget( `id("cups_autoconfig_configure_new_attachend"), `Enabled, false ); UI::ChangeWidget( `id("cups_autoconfig_disable_on_removal"), `Enabled, false ); UI::ChangeWidget( `id("cups_autoconfig_operation_policy"), `Enabled, false ); @@ -159,6 +191,25 @@ void storeAutoconfig( string key, map event ) { y2milestone( "entering storeAutoconfig with key '%1'\nand event '%2'", key, event ); + // If the cups-autoconfig RPM should be removed and when it is currently installed, + // try to remove it and return because nothing else matters in this case. + // Return even when the user decided to reject the removal because + // it would lead to unexpected results when cups-autoconfig settings + // may change in the system when the user decided to remove cups-autoconfig + // but rejects the removal (i.e. some kind of "cancel/abort" by the user) + // but settings were changed in the system nevertheless. + // It is crucial to test whether cups-autoconfig is currently installed + // because it could have been not installed when the dialog was launched + // and the user may have rejected the installation in initAutoconfig + // so that the vaule of the "cups_autoconfig_remove" CheckBox would + // have been also set to 'true' in initAutoconfig. + if( (boolean)UI::QueryWidget( `id("cups_autoconfig_remove"), `Value ) ) + { if( Printerlib::TestAndInstallPackage( "cups-autoconfig", "installed" ) ) + { Printerlib::TestAndInstallPackage( "cups-autoconfig", "remove" ); + y2milestone( "leaving storeAutoconfig" ); + return nil; + } + } boolean applied_autoconfig_settings = true; // Get the actual settings and values from the dialog: boolean current_cups_autoconfig_ConfigureNewPrinters = (boolean)UI::QueryWidget( `id("cups_autoconfig_configure_new_attachend"), `Value ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jsmeix@svn.opensuse.org