Author: jsmeix Date: Fri Sep 19 13:11:45 2008 New Revision: 51311 URL: http://svn.opensuse.org/viewcvs/yast?rev=51311&view=rev Log: First steps to implement the underlying functionality for the Share Printers dialog. Modified: trunk/printer/src/dialogs.ycp trunk/printer/src/sharing.ycp Modified: trunk/printer/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/dialogs.ycp?rev=51311&r1=51310&r2=51311&view=diff ============================================================================== --- trunk/printer/src/dialogs.ycp (original) +++ trunk/printer/src/dialogs.ycp Fri Sep 19 13:11:45 2008 @@ -270,8 +270,10 @@ "SHARING" : $[ "widget" : `custom, "custom_widget" : widgetSharing, - "help" : HELPS["sharing_dialog"]:"", - "handle": handleSharing + "init" : initSharing, + "handle": handleSharing, + "store" : storeSharing, + "help" : HELPS["sharing_dialog"]:"" ], "OPERATIONPOLICY" : $[ "widget" : `custom, Modified: trunk/printer/src/sharing.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/sharing.ycp?rev=51311&r1=51310&r2=51311&view=diff ============================================================================== --- trunk/printer/src/sharing.ycp (original) +++ trunk/printer/src/sharing.ycp Fri Sep 19 13:11:45 2008 @@ -39,78 +39,158 @@ include "printer/helps.ycp"; -term widgetSharing = - `VBox( `VSpacing( 1 ), - `RadioButtonGroup( `id(`deny_or_allow_remote_access), - `VBox( `Left( `RadioButton( `id(`deny_remote_access_radio_button), - `opt(`notify), - _("&Deny remote access"), - true - ) - ), - `VSpacing( 2 ), - `Left( `RadioButton( `id(`allow_remote_access_radio_button), - `opt(`notify), - _("&Allow remote access"), - false - ) - ) - ) - ), - `VSpacing( 1 ), - `HBox( `HSpacing( 3 ), - `VBox( `Left( `CheckBox( `id(`allow_local_network_access_check_box), - _("For computers within the &local network"), - true - ) - ), - `Left( `HBox( `HSpacing( 2 ), - `CheckBox( `id(`publish_to_local_network_check_box), - _("&Publish printers by default within the local network"), - true - ) - ) - ), - `VSpacing( 1 ), - `Left( `Label( _("Via network interfaces specified below") )), - `Table( `id(`interface_table), `header( _("Interface"), - _("Publish printers by default via this interface") - ), - [ `item( `id(0), "eth0", "no" ), - `item( `id(1), "eth1", "yes" ) - ] - ), - `Left( `HBox( `PushButton( `id(`add_interface), _("&Add") ), - `PushButton( `id(`edit_interface), _("&Edit") ), - `PushButton( `id(`delete_interface), _("&Delete") ) - ) - ), - `VSpacing( 1 ), - `Left( `Label( _("For hosts / networks specified below") ) ), - `Table( `id(`ip_table), `header( _("IP address"), - _("Publish printers by default for this address") - ), - [ `item( `id(0), "192.168.100.1", "yes" ), - `item( `id(1), "192.168.100.2", "no" ), - `item( `id(2), "192.168.200.0/24", "no" ), - `item( `id(3), "192.168.300.0/255.255.255.0", "yes" ) - ] - ), - `Left( `HBox( `PushButton( `id(`add_ip), _("A&dd") ), - `PushButton( `id(`edit_ip), _("Ed&it") ), - `PushButton( `id(`delete_ip), _("De&lete") ) - ) - ) - ) - ), - `VSpacing( 1 ) - ); +term widgetSharing = `VBox + ( `VSpacing( 1 ), + `RadioButtonGroup + ( `id(`deny_or_allow_remote_access), + `VBox + ( `Left + ( `RadioButton + ( `id(`deny_remote_access_radio_button), + `opt(`notify), + // A RadioButton label to deny remote access to local print queues: + _("&Deny remote access"), + true + ) + ), + `VSpacing( 2 ), + `Left + ( `RadioButton + ( `id(`allow_remote_access_radio_button), + `opt(`notify), + // A RadioButton label to allow remote access to local print queues: + _("&Allow remote access"), + false + ) + ) + ) + ), + `VSpacing( 1 ), + `HBox + ( `HSpacing( 3 ), + `VBox + ( `Left + ( `CheckBox + ( `id(`allow_local_network_access_check_box), + // A CheckBox label to allow remote access to local print queues + // for computers within the local network: + _("For computers within the &local network"), + true + ) + ), + `Left + ( `HBox + ( `HSpacing( 2 ), + `CheckBox + ( `id(`publish_to_local_network_check_box), + // A CheckBox label to publish local print queues by default within the local network: + _("&Publish printers by default within the local network"), + true + ) + ) + ), + `VSpacing( 1 ), + `Left + ( `Label + ( // A caption for a table to allow remote access to local print queues + // via network interfaces specified in the table below: + _("Via network interfaces specified below") + ) + ), + `Table + ( `id(`interface_table), + `header + ( // A table column header where the column lists network interfaces: + _("Interface"), + // A table column header where the column shows whether or not + // local print queues are published by default + // via the network interface in the other table column: + _("Publish printers by default via this interface") + ), + [ `item( `id(0), "eth0", "no" ), + `item( `id(1), "eth1", "yes" ) + ] + ), + `Left + ( `HBox + ( `PushButton + ( `id(`add_interface), + // A PushButton label to add a network interface to the table which shows + // the network interfaces to allow remote access to local print queues: + _("&Add") + ), + `PushButton + ( `id(`edit_interface), + // A PushButton label to change a network interface in the table which shows + // the network interfaces to allow remote access to local print queues: + _("&Edit") + ), + `PushButton + ( `id(`delete_interface), + // A PushButton label to delete a network interface from the table which shows + // the network interfaces to allow remote access to local print queues: + _("&Delete") + ) + ) + ), + `VSpacing( 1 ), + `Left + ( `Label + ( // A caption for a table to allow remote access to local print queues + // for hosts and/or networks specified in the table below: + _("For hosts / networks specified below") + ) + ), + `Table + ( `id(`ip_table), + `header + ( // A table column header where the column lists IP addresses: + _("IP address"), + // A table column header where the column shows whether or not + // local print queues are published by default + // via the IP address in the other table column: + _("Publish printers by default for this address") + ), + [ `item( `id(0), "192.168.100.1", "yes" ), + `item( `id(1), "192.168.100.2", "no" ), + `item( `id(2), "192.168.200.0/24", "no" ), + `item( `id(3), "192.168.300.0/255.255.255.0", "yes" ) + ] + ), + `Left + ( `HBox + ( `PushButton + ( `id(`add_ip), + // A PushButton label to add an IP address to the table which shows + // the IP addresses to allow remote access to local print queues: + _("A&dd") + ), + `PushButton + ( `id(`edit_ip), + // A PushButton label to change an IP address in the table which shows + // the IP addresses to allow remote access to local print queues: + _("Ed&it") + ), + `PushButton + ( `id(`delete_ip), + // A PushButton label to delete an IP address from the table which shows + // the IP addresses to allow remote access to local print queues: + _("De&lete") + ) + ) + ) + ) + ), + `VSpacing( 1 ) + ); + +boolean sharing_has_changed = false; map showInterfacePopup(string device, boolean publish){ map result = $[]; list<string> devices = NetworkInterfaces::List(""); UI::OpenDialog( `VBox( - `CheckBox(`id(`publish), _("&Publish printers by default via "), publish), + `CheckBox(`id(`publish), _("&Publish printers by default via "), publish), // translators: combo box label for list of configured IPs `ComboBox( `id(`device), `opt( `editable ), _("Network &Devices:"), devices ), `VSpacing(), @@ -134,14 +214,14 @@ break; } } - UI::CloseDialog(); + UI::CloseDialog(); return result; } map showIPPopup(string device, boolean publish){ map result = $[]; UI::OpenDialog( `VBox( - `CheckBox(`id(`publish), _("&Publish printers by default via "), publish), + `CheckBox(`id(`publish), _("&Publish printers by default via "), publish), // translators: input field label for list of configured IPs `InputField( `id(`device), _("Network &Address:"), device ), `VSpacing(), @@ -165,101 +245,111 @@ break; } } - UI::CloseDialog(); + UI::CloseDialog(); return result; } -symbol handleSharing(string key, map event){ +void initSharing( string key ) +{ y2milestone( "entering initSharing with key '%1'", key ); + // Show a user information because the current implementation provides + // only the dialog but does not read from the system or write to the system: + Popup::AnyMessage( // Header of a Popup::AnyMessage because of a work-in-progress dialog: + _("Under Connstruction"), + // Body of a Popup::AnyMessage because of a work-in-progress dialog: + _("Currently only the dialog shows up but it does\nneither read from the system nor write to the system.\n") + ); + y2milestone( "leaving initSharing" ); +} - if (event["EventReason"]:""=="Activated"){ +symbol handleSharing(string key, map event) +{ if (event["EventReason"]:""=="Activated"){ y2milestone("button pressed %1", event); switch(event["WidgetID"]:`nil){ integer current=-1; map ret = nil; - case `add_interface : - ret = showInterfacePopup("", false); - if (ret!=nil){ - list items = (list)UI::QueryWidget(`interface_table, `Items); - items=add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); - UI::ChangeWidget(`interface_table, `Items, items); - UI::ChangeWidget(`interface_table, `CurrentItem, current); - } - break; - case `edit_interface : - current = (integer)UI::QueryWidget(`interface_table, `CurrentItem); - term this = (term)UI::QueryWidget(`interface_table, `Item(current)); + case `add_interface : + ret = showInterfacePopup("", false); + if (ret!=nil){ + list items = (list)UI::QueryWidget(`interface_table, `Items); + items=add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); + UI::ChangeWidget(`interface_table, `Items, items); + UI::ChangeWidget(`interface_table, `CurrentItem, current); + } + break; + case `edit_interface : + current = (integer)UI::QueryWidget(`interface_table, `CurrentItem); + term this = (term)UI::QueryWidget(`interface_table, `Item(current)); ret = showInterfacePopup((string)this[1]:"", (this[2]:"no"=="yes")); - if (ret!=nil){ - list items = []; - foreach(term oneItem, (list<term>)UI::QueryWidget(`interface_table, `Items), { - if (current != oneItem[0, 0]:-1){ - items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); - } else { - y2milestone("Changing item %1", oneItem); - items = add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); - } - }); - UI::ChangeWidget(`interface_table, `Items, items); - UI::ChangeWidget(`interface_table, `CurrentItem, current); - } - break; + if (ret!=nil){ + list items = []; + foreach(term oneItem, (list<term>)UI::QueryWidget(`interface_table, `Items), { + if (current != oneItem[0, 0]:-1){ + items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); + } else { + y2milestone("Changing item %1", oneItem); + items = add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); + } + }); + UI::ChangeWidget(`interface_table, `Items, items); + UI::ChangeWidget(`interface_table, `CurrentItem, current); + } + break; case `delete_interface : - current = (integer)UI::QueryWidget(`interface_table, `CurrentItem); - if (current!=nil && current>-1){ - list items = []; - foreach(term oneItem, (list<term>)UI::QueryWidget(`interface_table, `Items), { - if (current != oneItem[0, 0]:-1){ - items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); - } else y2milestone("Deleting item %1", oneItem); - - }); - UI::ChangeWidget(`interface_table, `Items, items); - } else y2error("Unproper index for current item: %1", current); - break; - case `add_ip : - ret = showIPPopup("", false); - if (ret!=nil){ - list items = (list)UI::QueryWidget(`ip_table, `Items); - items=add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); - UI::ChangeWidget(`ip_table, `Items, items); - UI::ChangeWidget(`ip_table, `CurrentItem, current); - } - break; - - case `edit_ip : - current = (integer)UI::QueryWidget(`ip_table, `CurrentItem); - term this2 = (term)UI::QueryWidget(`ip_table, `Item(current)); + current = (integer)UI::QueryWidget(`interface_table, `CurrentItem); + if (current!=nil && current>-1){ + list items = []; + foreach(term oneItem, (list<term>)UI::QueryWidget(`interface_table, `Items), { + if (current != oneItem[0, 0]:-1){ + items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); + } else y2milestone("Deleting item %1", oneItem); + + }); + UI::ChangeWidget(`interface_table, `Items, items); + } else y2error("Unproper index for current item: %1", current); + break; + case `add_ip : + ret = showIPPopup("", false); + if (ret!=nil){ + list items = (list)UI::QueryWidget(`ip_table, `Items); + items=add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); + UI::ChangeWidget(`ip_table, `Items, items); + UI::ChangeWidget(`ip_table, `CurrentItem, current); + } + break; + + case `edit_ip : + current = (integer)UI::QueryWidget(`ip_table, `CurrentItem); + term this2 = (term)UI::QueryWidget(`ip_table, `Item(current)); ret = showIPPopup((string)this2[1]:"", (this2[2]:"no"=="yes")); - if (ret!=nil){ - list items = []; - foreach(term oneItem, (list<term>)UI::QueryWidget(`ip_table, `Items), { - if (current != oneItem[0, 0]:-1){ - items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); - } else { - y2milestone("Changing item %1", oneItem); - items = add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); - } - }); - UI::ChangeWidget(`ip_table, `Items, items); - UI::ChangeWidget(`ip_table, `CurrentItem, current); - } - break; + if (ret!=nil){ + list items = []; + foreach(term oneItem, (list<term>)UI::QueryWidget(`ip_table, `Items), { + if (current != oneItem[0, 0]:-1){ + items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); + } else { + y2milestone("Changing item %1", oneItem); + items = add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); + } + }); + UI::ChangeWidget(`ip_table, `Items, items); + UI::ChangeWidget(`ip_table, `CurrentItem, current); + } + break; case `delete_ip : - current = (integer)UI::QueryWidget(`ip_table, `CurrentItem); - if (current!=nil && current>-1){ - list items = []; - foreach(term oneItem, (list<term>)UI::QueryWidget(`ip_table, `Items), { - if (current != oneItem[0, 0]:-1){ - items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); - } else y2milestone("Deleting item %1", oneItem); - - }); - UI::ChangeWidget(`ip_table, `Items, items); - } else y2error("Unproper index for current item: %1", current); - break; + current = (integer)UI::QueryWidget(`ip_table, `CurrentItem); + if (current!=nil && current>-1){ + list items = []; + foreach(term oneItem, (list<term>)UI::QueryWidget(`ip_table, `Items), { + if (current != oneItem[0, 0]:-1){ + items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); + } else y2milestone("Deleting item %1", oneItem); + + }); + UI::ChangeWidget(`ip_table, `Items, items); + } else y2error("Unproper index for current item: %1", current); + break; } } - boolean share = (UI::QueryWidget(`deny_or_allow_remote_access, `CurrentButton)==`allow_remote_access_radio_button); UI::ChangeWidget(`allow_local_network_access_check_box, `Enabled, share); UI::ChangeWidget(`publish_to_local_network_check_box, `Enabled, share); @@ -284,5 +374,21 @@ return nil; } +void storeSharing( string key, map event ) +{ y2milestone( "entering storeSharing with key '%1'\nand event '%2'", key, event ); + if( ! sharing_has_changed ) + { y2milestone( "Nothing changed in 'Share Printers' dialog." ); + Popup::ShowFeedback( // No title for such a simple feedback message: + "", + // Message of a Popup::ShowFeedback when nothing was changed: + _("Nothing changed.") + ); + sleep( 1000 ); + Popup::ClearFeedback(); + } + y2milestone( "leaving storeSharing" ); + return nil; +} + /* EOF */ } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org