Author: jsmeix
Date: Fri Nov 27 14:52:20 2009
New Revision: 59825
URL: http://svn.opensuse.org/viewcvs/yast?rev=59825&view=rev
Log:
connections created by the "Connection Wizard"
can be modified by it, bnc #553871 is now fixed.
Added support for current_queue_name and current_device_uri
in Printer.ycp overview.ycp basicadd.ycp basicmodify.ycp
which means that the currently used queu and/or connection
is preselected in the Overview and/or Add/Modify dialogs
(i.e. there no longer only the default Table widget
prelelection which preselects the first table item).
Needs also to be implemented in connectionwizard.ycp
so that the current URI from the Connection Wizard
gets preselected in the Add/Modify dialogs.
Modified:
trunk/printer/src/Printer.ycp
trunk/printer/src/basicadd.ycp
trunk/printer/src/basicmodify.ycp
trunk/printer/src/connectionwizard.ycp
trunk/printer/src/helps.ycp
trunk/printer/src/overview.ycp
Modified: trunk/printer/src/Printer.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printer.ycp?rev=59825&r1=59824&r2=59825&view=diff
==============================================================================
--- trunk/printer/src/Printer.ycp (original)
+++ trunk/printer/src/Printer.ycp Fri Nov 27 14:52:20 2009
@@ -207,10 +207,10 @@
* where the last list entry is an emtpy map.
* @struct autodetected_printer_map
* $[ "uri":"the full CUPS DeviceURI (required)",
- * "model":"the manufacturer and model, often "Unknown" (may be the empty string)",
+ * "model":"the manufacturer and model, often 'Unknown' (may be the empty string)",
* "deviceID":"what the printer reported as its device ID (often the empty string)",
* "info":"arbitrary info regarding this connection (may be the empty string)",
- * "class":"the kind of connection, e.g. "direct","network","file" (may be the empty string)"
+ * "class":"one of 'direct','network','file','serial' or 'ConnectionWizardDialog' (may be the empty string)"
* ]
*/
global list< map< string, string > > connections = [];
@@ -224,6 +224,20 @@
global integer selected_connections_index = -1;
/**
+ * Current device uri:
+ * The device uri (i.e. the connection) which is currently in use
+ * so that the BasicAddDialog and BasicModifyDialog could preselect it.
+ * Note that selected_connections_index cannot be used for this
+ * because the ConnectionItems function which generates
+ * the list of connections for BasicAddDialog and BasicModifyDialog
+ * invalidates selected_connections_index because it autodetects
+ * the currently available connections in the system anew because
+ * those would change e.g. after a printer was connected or disconnected
+ * Preset to "" which indicates that no device uri is currently in use.
+ */
+global string current_device_uri = "";
+
+/**
* Autodetected queues:
* Determined at runtime via Printer::AutodetectQueues() which calls the bash script
* "/usr/lib/YaST2/bin/autodetect_print_queues"
@@ -262,9 +276,24 @@
global boolean queue_filter_show_remote = true;
/**
+ * Current queue name:
+ * The name of the queue which is currently in use
+ * so that the Overview dialog could preselect it.
+ * Note that selected_queues_index cannot be used for this
+ * because the QueueItems function which generates
+ * the list of queues for the Overview dialog
+ * invalidates selected_queues_index because it autodetects
+ * the current actual queues in the system anew because
+ * the list of queues in the system would have changed
+ * e.g. after a new queue was added or after a queue was removed.
+ * Preset to "" which indicates that no queue is currently in use.
+ */
+global string current_queue_name = "";
+
+/**
* Driver options (options in the PPD for one specific existing queue):
* Determined at runtime via Printer::DetermineDriverOptions( "queue_name")
-* which calls the bash script "/usr/lib/YaST2/bin/determine_printer_driver_options"
+ * which calls the bash script "/usr/lib/YaST2/bin/determine_printer_driver_options"
* which outputs on stdout a YCP list of @ref driver_option_map
* where the last list entry is an emtpy map.
* @struct driver_option_map
@@ -831,7 +860,8 @@
string is_disabled = queue["disabled"]:"yes";
string is_rejecting = queue["rejecting"]:"yes";
if( name != "" && uri != "" )
- { if( (config=="local" && local) || (config=="class" && local) || (config=="remote" && remote) )
+ { // Have local or remote stuff in the list depending on whether or not each is requested:
+ if( (config=="local" && local) || (config=="class" && local) || (config=="remote" && remote) )
{ if( "local" == config )
{ // When the queue configuration exists on the local host:
config = _("Local");
@@ -876,6 +906,14 @@
queue_state
)
);
+ // Set selected_queues_index when the current_queue_name is in the list
+ // so that the OverviewDialog can preselect the currently used queue
+ // via its id in the list which is the selected_queues_index.
+ // This is correct for any kind of queue ("local", "class", "remote") here
+ // because any queue in the list can be selected in the OverviewDialog:
+ if( current_queue_name == name )
+ { selected_queues_index = queues_index;
+ }
}
}
}
@@ -901,20 +939,24 @@
/**
* Create a list of items from the autodetected connections
- * which is used for the SelectionBox in the BasicAddDialog and SelectConnectionDialog
+ * which is used for the SelectionBox in the BasicAddDialog and BasicModifyDialog.
+ * This function is also called in connectionwizard.ycp and in printer_proposal.ycp.
* @param connection_filter_string string of a search string to return only matching connections
* (return all connections if connection_filter_string is the empty string)
* @return list of connections (i.e. DeviceURI, model, and info of the "lpinfo -l -v" output)
*/
global list ConnectionItems( string connection_filter_string )
-{ // Autodetect printers if the connections list is empty:
+{ // Invalidate selected_connections_index and selected_ppds_index to be safe:
+ selected_connections_index = -1;
+ selected_ppds_index = -1;
+ // Autodetect printers if the connections list is empty:
if( size( connections ) < 1 || "MoreConnections" == connection_filter_string )
{ list< map< string, string > > connection_wizard_connections = [];
// Save existing connections which have been manually added by the connection wizard:
foreach( map< string, string > connection,
connections,
{ if( "ConnectionWizardDialog" == connection["class"]:"" )
- { connection_wizard_connections = add( connection_wizard_connections, connection);
+ { connection_wizard_connections = add( connection_wizard_connections, connection );
}
}
);
@@ -925,13 +967,12 @@
// was called and this function would have shown more specific messages.
_("Failed to autodetect printers.")
);
- // Return only the existing connection wizard connections which is usally an empty list:
- return connection_wizard_connections;
}
// The connection wizard prepends its manually added connections to the connections list.
// Therefore the connection_wizard_connections are also prepended to the connections list.
// There is an error in the YaST documentation regarding "merge" for lists:
- // It reads "Interprets two lists as sets" which would remove duplicates.
+ // It reads "Interprets two lists as sets" which would
+ // remove duplicates in each list before the merge.
// Actually merge([1,2,2,3],[2,3,3,4]) results [1,2,2,3,2,3,3,4]
// which is needed here to preserve any entry to be on the safe side:
connections = (list