Module: Yast::SysconfigComplexInclude
- Defined in:
- ../../src/include/sysconfig/complex.rb
Instance Method Summary (collapse)
-
- (Array) add_if_missing(l, v)
Generic list function - add value to the list if it isn't already there.
-
- (Object) backslash_add(input)
Escape double quotes and back slash characters by back slash.
-
- (String) backslash_remove(input)
Remove backslashes from string - opposite funtion to the backslash_add function.
-
- (Object) check_set_current_value(force_change)
Set new value for variable, warn user if new value does not match type definition.
-
- (Boolean) combo_editable(description)
Get combo box editable status - depends on Type value.
-
- (Array) combo_list(description, set_default)
Create list of values for combo box widget.
-
- (String) create_description(description, richtext)
Create rich text description string from description values.
-
- (Array) create_table_content(varids)
Create table content list for selected variables.
- - (Object) GenerateTree(_Tree, parent, input)
- - (Object) initialize_sysconfig_complex(include_target)
-
- (Boolean) is_node(id)
Is selected item in the tree widget leaf node?.
-
- (Object) MainDialog
Display main configuration dialog.
-
- (Object) Modified
Return a modification status.
-
- (String) possible_values(description, richtext)
Get string representation of type definition.
-
- (Object) ReadDialog
Read settings dialog.
-
- (Object) update_button_state(description)
Update “Default” button state (enable/disable) in the dialog.
-
- (Object) update_combo(description, set_default)
Update combo box in dialog.
-
- (Object) update_location(description)
Update location text in the dialog.
-
- (Object) WriteDialog
Write settings dialog.
Instance Method Details
- (Array) add_if_missing(l, v)
Generic list function - add value to the list if it isn't already there
458 459 460 461 |
# File '../../src/include/sysconfig/complex.rb', line 458 def add_if_missing(l, v) l = deep_copy(l) !Builtins.contains(l, v) ? Builtins.add(l, v) : l end |
- (Object) backslash_add(input)
Escape double quotes and back slash characters by back slash
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File '../../src/include/sysconfig/complex.rb', line 466 def backslash_add(input) # escape double quotes and back slashes escaped = "" pos = 0 while Ops.less_than(pos, Builtins.size(input)) ch = Builtins.substring(input, pos, 1) ch_1 = Builtins.substring(input, Ops.add(pos, 1), 1) # don't add backslash before \$ (#34809) if ch == "\\" && ch_1 != nil && ch_1 != "$" escaped = Ops.add(escaped, "\\\\") else if ch == "\"" escaped = Ops.add(escaped, "\\\"") elsif ch == "\n" # multi line value escaped = Ops.add(escaped, "\\\n") else escaped = Ops.add(escaped, ch) end end pos = Ops.add(pos, 1) end escaped end |
- (String) backslash_remove(input)
Remove backslashes from string - opposite funtion to the backslash_add function.
498 499 500 501 502 503 504 |
# File '../../src/include/sysconfig/complex.rb', line 498 def backslash_remove(input) return nil if input == nil ret = Builtins.regexpsub(input, "(.*)\\([^$].*)", "\\1\\2") ret == nil ? input : ret end |
- (Object) check_set_current_value(force_change)
Set new value for variable, warn user if new value does not match type definition.
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File '../../src/include/sysconfig/complex.rb', line 686 def check_set_current_value(force_change) # check current value if @selected_variable != "" new_value = Convert.to_string(UI.QueryWidget(Id(:combo), :Value)) d = Sysconfig.get_description(@selected_variable) # check whether single quotes are used in the configuration file if Ops.get_string(d, ["actions", "SingleQt"], "") == "1" new_value = backslash_add(new_value) end if Sysconfig.get_name_from_id(@selected_variable) != "" # variable was selected (not category) result = Sysconfig.set_value( @selected_variable, new_value, false, force_change ) if result == :not_valid t = Ops.get_string(d, "Type", "string") # popup question dialog: variable value does not match defined type - ask user to set value (%1 is value entered by user, %2 is allowed type - e.g. integer if Popup.AnyQuestion( Label.WarningMsg, Builtins.sformat( _( "Value '%1'\n" + "does not match type '%2'.\n" + "\n" + "Really set this value?\n" ), new_value, t ), Label.YesButton, Label.NoButton, :focus_no ) == true # force setting of value Sysconfig.set_value( @selected_variable, new_value, true, force_change ) end end end end nil end |
- (Boolean) combo_editable(description)
Get combo box editable status - depends on Type value
442 443 444 445 446 447 448 449 450 451 452 |
# File '../../src/include/sysconfig/complex.rb', line 442 def combo_editable(description) description = deep_copy(description) type = Ops.get_string(description, "Type", "") type == "" || Builtins.regexpmatch(type, "^integer\\(.*:.*\\)$") || type == "integer" || type == "string" || Builtins.regexpmatch(type, "^string\\(.*\\)$") || type == "ip" || Builtins.regexpmatch(type, "^regexp\\(.*\\)$") end |
- (Array) combo_list(description, set_default)
Create list of values for combo box widget
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File '../../src/include/sysconfig/complex.rb', line 510 def combo_list(description, set_default) description = deep_copy(description) new_value = Ops.get_string(description, "new_value") value = Ops.get_string(description, "value", "") # use default value (or emty string) instead of the curent value in autoyast if Mode.config value = Builtins.haskey(description, "Default") ? Ops.get_string(description, "Default", "") : "" end if Ops.get_string(description, ["actions", "SingleQt"], "") == "1" new_value = backslash_remove(new_value) value = backslash_remove(value) end ret = [] deflt = Ops.get_string(description, "Default") if set_default == true && deflt != nil Builtins.y2debug("Adding default value: %1", deflt) ret = Builtins.add(ret, deflt) if !Builtins.contains(ret, deflt) end if new_value != nil ret = Builtins.add(ret, new_value) if !Builtins.contains(ret, new_value) elsif value != nil ret = Builtins.add(ret, value) if !Builtins.contains(ret, value) end type = Ops.get_string(description, "Type", "") if type == "yesno" ret = Builtins.add(ret, "yes") if !Builtins.contains(ret, "yes") ret = Builtins.add(ret, "no") if !Builtins.contains(ret, "no") elsif type == "boolean" ret = Builtins.add(ret, "true") if !Builtins.contains(ret, "true") ret = Builtins.add(ret, "false") if !Builtins.contains(ret, "false") elsif Builtins.regexpmatch(type, "^list\\(.*\\)") values_string = Builtins.regexpsub(type, "^list\\((.*)\\)", "\\1") parsed = String.ParseOptions(values_string, Sysconfig.parse_param) # add missing items Builtins.foreach(parsed) do |option| ret = Builtins.add(ret, option) if !Builtins.contains(ret, option) end elsif Builtins.regexpmatch(type, "^string\\(.*\\)") values_string = Builtins.regexpsub(type, "^string\\((.*)\\)", "\\1") parsed = String.ParseOptions(values_string, Sysconfig.parse_param) # add missing items Builtins.foreach(parsed) do |option| ret = Builtins.add(ret, option) if !Builtins.contains(ret, option) end end # add default value to the list if deflt != nil && !Builtins.contains(ret, deflt) ret = Builtins.add(ret, deflt) end # add old value to the list if variable was modified if new_value != nil ret = Builtins.add(ret, value) if !Builtins.contains(ret, value) end Builtins.y2debug("combo list: %1", ret) deep_copy(ret) end |
- (String) create_description(description, richtext)
Create rich text description string from description values
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File '../../src/include/sysconfig/complex.rb', line 204 def create_description(description, richtext) description = deep_copy(description) varname = Ops.get_string(description, "name", "") file = Ops.get_string(description, "file", "") default_value = Ops.get_string(description, "Default") comment = Ops.get_string(description, "comment", "") possible_vals = possible_values(description, richtext) result = "" if file != "" && file != nil # rich text item result = Ops.add( Ops.add( Ops.add( Ops.add(Ops.add(result, richtext ? "<P><B>" : ""), _("File: ")), richtext ? "</B> " : "" ), file ), richtext ? "</P>" : "\n" ) end if possible_vals != "" && possible_vals != nil # rich text item result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Possible Values: ") ), richtext ? "</B> " : "" ), possible_vals ), richtext ? "</P>" : "\n" ) end if default_value != nil && Ops.greater_than(Builtins.size(file), 0) # TODO: replace empty value by special text (e.g. "</I>empty</I>") # rich text value result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Default Value: ") ), richtext ? "</B> " : "" ), default_value ), richtext ? "</P>" : "\n" ) end # if value was modified add original value if Builtins.haskey(description, "new_value") original = Ops.get_string(description, "value", "") # quote empty value original = "\"\"" if original == "" # rich text value result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Original Value: ") ), richtext ? "</B> " : "" ), original ), richtext ? "</P>" : "\n" ) end if Builtins.haskey(description, "actions") # display specified action command conf_modules = Ops.get_string(description, ["actions", "Cfg"]) restart = Ops.get_string(description, ["actions", "Rest"]) reload = Ops.get_string(description, ["actions", "Reld"]) command = Ops.get_string(description, ["actions", "Cmd"]) precommand = Ops.get_string(description, ["actions", "Pre"]) # check whether action is defined if precommand != nil && Ops.greater_than(Builtins.size(precommand), 0) # header in the variable description text, bash command is appended result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Prepare Command: ") ), richtext ? "</B> " : "" ), precommand ), richtext ? "</P>" : "\n" ) end if conf_modules != nil && Ops.greater_than(Builtins.size(conf_modules), 0) # parse string with options, then add them to the rich text conf = String.ParseOptions(conf_modules, Sysconfig.parse_param) # header in the variable description text result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Configuration Script: ") ), richtext ? "</B> " : "" ), Builtins.mergestring(conf, ", ") ), richtext ? "</P>" : "\n" ) end if reload != nil && Ops.greater_than(Builtins.size(reload), 0) services = String.ParseOptions(reload, Sysconfig.parse_param) # header in the variable description text, service names (e.g. "apache") are appended result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Service to Reload: ") ), richtext ? "</B> " : "" ), Builtins.mergestring(services, ", ") ), richtext ? "</P>" : "\n" ) end if restart != nil && Ops.greater_than(Builtins.size(restart), 0) services = String.ParseOptions(restart, Sysconfig.parse_param) # header in the variable description text, service names (e.g. "apache") are appended result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Service to Restart: ") ), richtext ? "</B> " : "" ), Builtins.mergestring(services, ", ") ), richtext ? "</P>" : "\n" ) end if command != nil && Ops.greater_than(Builtins.size(command), 0) # header in the variable description text, bash command is appended result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Activation Command: ") ), richtext ? "</B> " : "" ), command ), richtext ? "</P>" : "\n" ) end end if comment != "" && comment != nil if richtext # convert '<' and '>' to '<' '>' comment = Builtins.mergestring( Builtins.splitstring(comment, "<"), "<" ) comment = Builtins.mergestring( Builtins.splitstring(comment, ">"), ">" ) # keep comment formatting: # convert '\n' => '<BR>' comment = Builtins.mergestring( Builtins.splitstring(comment, "\n"), "<BR>" ) # do not change node descriptions if file != "" # convert ' ' => ' ' comment = Builtins.mergestring( Builtins.splitstring(comment, " "), " " ) end Builtins.y2debug("formatted comment: %1", comment) end # rich text value result = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(result, richtext ? "<P><B>" : ""), _("Description: ") ), richtext ? "</B><BR> " : "" ), comment ), richtext ? "</P>" : "" ) end Builtins.y2debug("variable description : %1", result) result end |
- (Array) create_table_content(varids)
Create table content list for selected variables
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
# File '../../src/include/sysconfig/complex.rb', line 744 def create_table_content(varids) varids = deep_copy(varids) table_content = [] Builtins.foreach(varids) do |varid| descr = Sysconfig.get_description(varid) name = Ops.get_string(descr, "name", "") old = Ops.get_string(descr, "value", "") new = Ops.get_string(descr, "new_value", "") file = Ops.get_string(descr, "file", "") # display only beginning of comment (to limit table space used) comm = Ops.get_string(descr, "comment", "") # remove newlines comm = Sysconfig.remove_whitespaces( Builtins.mergestring(Builtins.splitstring(comm, "\n"), " ") ) if Ops.greater_than(Builtins.size(comm), 90) comm = Builtins.substring(comm, 0, 90) # when a comment is too long to display it in the table # it is shortened and mark (three dot characters) is added to the end comm = Ops.add(comm, _("...")) end table_content = Builtins.add( table_content, Item(Id(varid), name, new, old, file, comm) ) end deep_copy(table_content) end |
- (Object) GenerateTree(_Tree, parent, input)
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 |
# File '../../src/include/sysconfig/complex.rb', line 776 def GenerateTree(_Tree, parent, input) _Tree = deep_copy(_Tree) input = deep_copy(input) Builtins.foreach(input) do |i| id = Ops.get_string(i, [0, 0], "") title = Ops.get_string(i, 1, "") enabled = Ops.get_boolean(i, 2, false) children = Ops.get_list(i, 3, []) _Tree = Wizard.AddTreeItem(_Tree, parent, title, id) if Ops.greater_than(Builtins.size(children), 0) _Tree = GenerateTree(_Tree, id, children) end end deep_copy(_Tree) end |
- (Object) initialize_sysconfig_complex(include_target)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File '../../src/include/sysconfig/complex.rb', line 11 def initialize_sysconfig_complex(include_target) Yast.import "UI" textdomain "sysconfig" Yast.import "Wizard" Yast.import "Sysconfig" Yast.import "Mode" Yast.import "String" Yast.import "Popup" Yast.import "Label" Yast.include include_target, "sysconfig/helps.rb" Yast.include include_target, "sysconfig/routines.rb" Yast.include include_target, "sysconfig/dialogs.rb" # current selected variable in the tree widget @selected_variable = "" @empty_string = " " @empty_string = Ops.add(@empty_string, @empty_string) @empty_string = Ops.add(@empty_string, @empty_string) end |
- (Boolean) is_node(id)
Is selected item in the tree widget leaf node?
680 681 682 |
# File '../../src/include/sysconfig/complex.rb', line 680 def is_node(id) Builtins.findfirstof(id, "$") == nil end |
- (Object) MainDialog
Display main configuration dialog
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File '../../src/include/sysconfig/complex.rb', line 796 def MainDialog = HBox( # back pushbutton: the user input is ignored and the last dialog is called PushButton(Id(:abort), Opt(:key_F9), Label.AbortButton), HStretch(), PushButton(Id(:help), Opt(:key_F1), Label.HelpButton), HStretch(), # Translation: push button label PushButton(Id(:search), _("&Search")), HStretch(), PushButton(Id(:next), Opt(:key_F10), Label.FinishButton) ) # tree widget label # term help_space_content = `Tree(`id(`tree), `opt(`notify, `vstretch), _("&Configuration Options"), Sysconfig::tree_content); # Wizard::OpenCustomDialog(help_space_content, button_box); Wizard.CreateTreeDialog _Tree = GenerateTree([], "", Sysconfig.tree_content) Wizard.CreateTree(_Tree, _("&Configuration Options")) helptext = # helptext for popup - part 1/2 _( "<p>After you save your changes, this editor changes the variables in the\n" + "corresponding sysconfig file. Then it starts activation commands, which changes the underlying configuration files, stops and starts daemons,\n" + "and runs low-level configuration tools so your configuration in sysconfig takes effect.</p>\n" ) + # helptext for popup - part 2/2 _( "<p><b>Important:</b> You still can edit each individual configuration file manually. The name of file is displayed in the variable description.</p>" ) Wizard.SetContents( _("/etc/sysconfig Editor"), VBox( # label widget Left( Label( Id(:heading), Opt(:hstretch), Ops.add(_("Current Selection: "), @empty_string) ) ), VSpacing(0.5), HBox( HWeight( 1, ReplacePoint( Id(:replace), # combo box label ComboBox( Id(:combo), Opt(:disabled, :hstretch), _("S&etting of: "), [""] ) ) ), VBox( # dummy widget used to align button Label(""), # push button label PushButton(Id(:def), Opt(:disabled), _("&Default")) ) ), VSpacing(1), # help rich text displayed after module start (1/2) RichText( Id(:rt), _( "<P><B>System Configuration Editor</B></P><P>With the system configuration editor, you can change some system settings. You can also use YaST to configure your hardware and system settings.</P>" ) + # help rich text displayed after module start (2/2) _( "<P><B>Note:</B> Descriptions are not translated because they are read directly from configuration files.</P>" ) ), # push button label - displayed only in autoinstallation config mode Mode.config == true ? HBox( PushButton(Id(:use_current), _("&Use Current Value")), # push button label - displayed only in autoinstallation config mode PushButton(Id(:add_new), Opt(:key_F3), _("&Add New Variable...")) ) : Empty() ), helptext, true, true ) # push button label Wizard.SetBackButton(:back, _("&Search")) Wizard.SetNextButton(:next, Label.OKButton) Wizard.SetAbortButton(:abort, Label.CancelButton) if UI.WidgetExists(Id(:wizardTree)) UI.ReplaceWidget(Id(:rep_button_box), ) end Wizard.SetDesktopTitleAndIcon("sysconfig") ret = nil while ret != :cancel && ret != :abort && ret != :next event = UI.WaitForEvent ret = Ops.get(event, "ID") # "Default" button if ret == :def description = Sysconfig.get_description(@selected_variable) update_combo(description, true) elsif ret == :next # check if current value was modified check_set_current_value(false) modified = Sysconfig.get_modified # show table with modified variables if Ops.greater_than(Builtins.size(modified), 0) Builtins.y2milestone("Modified variables: %1", modified) # popup dialog header - confirm to save the changes result = display_variables_dialog( _("Save Modified Variables"), "", # checkbox label create_table_content(modified), Label.SaveButton, Label.CancelButton, _("Confirm Each Activation Command"), false ) ret = :again if Ops.get_symbol(result, "ui", :dummy) == :cancel # set confirmation flag Sysconfig.ConfirmActions = Ops.get_boolean( result, "checkbox", false ) end elsif ret == :back || ret == :search # This is for Search actually FIXME search_parameters = display_search_dialog if search_parameters != {} found = Sysconfig.Search(search_parameters, true) if Ops.greater_than(Builtins.size(found), 0) # // popup dialog header input = display_variables_dialog( _("Search Result"), # help text in popup dialog _( "The search results are displayed here. If you see the item you want, select it then click \"Go to\". Otherwise, click \"Cancel\" to close this dialog." ), create_table_content(found), # push button label _("&Go to"), Label.CancelButton, "", nil ) if Ops.get_symbol(input, "ui", :dummy) == :cancel ret = :again else sel = Ops.get_string(input, "selected") if sel != nil # select variable in the tree #UI::ChangeWidget(`id(`tree), `CurrentItem, sel); Wizard.SelectTreeItem(sel) # display selected variable if UI.WidgetExists(Id(:wizardTree)) ret = :wizardTree else ret = sel end end end else # popup message - search result message Popup.Message(_("No entries found")) end end elsif ret == :help UI.OpenDialog( Opt(:decorated), HBox( VSpacing(16), VBox( HSpacing(60), # popup window header Heading(_("Help")), VSpacing(0.5), RichText(helptext), VSpacing(1.5), # push button label PushButton(Id(:ok), Opt(:default, :key_F10), Label.OKButton) ) ) ) UI.SetFocus(Id(:ok)) UI.UserInput UI.CloseDialog elsif ret == :abort || ret == :cancel if !ReallyAbort() ret = nil else # `cancel is same as `abort ret = :abort end # autoinstallation config mode only elsif ret == :use_current # force current value as changed check_set_current_value(true) description = Sysconfig.get_description(@selected_variable) # update combo box - add "changed" status update_combo(description, false) # autoinstallation config mode only elsif ret == :add_new # ask user for new variable name, value and location (file name) _in = add_new_variable ui = Ops.get_symbol(_in, "ui", :cancel) name = Ops.get_string(_in, "name", "") file = Ops.get_string(_in, "file", "") value = Ops.get_string(_in, "value", "") if ui == :ok Sysconfig.set_value( Builtins.sformat("%1$%2", name, file), value, false, true ) end end if ret == :wizardTree || Ops.is_string?(ret) check_set_current_value(false) # string selected = (string)UI::QueryWidget(`id(`tree), `CurrentItem); selected = Wizard.QueryTreeItem @selected_variable = selected Builtins.y2milestone("Selected: %1", selected) description = Sysconfig.get_description(selected) Builtins.y2milestone("Descr: %1", description) # update richtext content UI.ChangeWidget( Id(:rt), :Value, create_description(description, true) ) # update combo box update_combo(description, false) # update "Default" button state (enable/disable) (description) # update location in header update_location(description) end end UI.CloseDialog Convert.to_symbol(ret) end |
- (Object) Modified
Return a modification status
37 38 39 |
# File '../../src/include/sysconfig/complex.rb', line 37 def Modified Sysconfig.Modified end |
- (String) possible_values(description, richtext)
Get string representation of type definition. Used at richtext description.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File '../../src/include/sysconfig/complex.rb', line 80 def possible_values(description, richtext) description = deep_copy(description) ret = "" type = Ops.get_string(description, "Type", "") if type == "" return ret elsif type == "yesno" ret = Ops.add(ret, "yes,no") elsif type == "boolean" ret = "true,false" elsif Builtins.regexpmatch(type, "^list\\(.*\\)") spaces = [] values = String.ParseOptions( Builtins.regexpsub(type, "^list\\((.*)\\)", "\\1"), Sysconfig.parse_param ) Builtins.foreach(values) do |value| spaces = Builtins.add( spaces, Builtins.mergestring(Builtins.splitstring(value, " "), " ") ) end ret = Builtins.mergestring(spaces, ", ") elsif Builtins.regexpmatch(type, "^string\\(.*\\)") spaces = [] values = String.ParseOptions( Builtins.regexpsub(type, "^string\\((.*)\\)", "\\1"), Sysconfig.parse_param ) Builtins.foreach(values) do |value| spaces = Builtins.add( spaces, Builtins.mergestring(Builtins.splitstring(value, " "), " ") ) end # suffix added to the allowed (predefined) values ret = Ops.add( Ops.add( Ops.add(Builtins.mergestring(spaces, ", "), richtext ? " <I>" : " "), _("or any value") ), richtext ? "</I>" : "" ) elsif Builtins.regexpmatch(type, "^regexp\\(.*\\)") regex = Builtins.regexpsub(type, "^regexp\\((.*)\\)", "\\1") # Translation: description of possible values, regular expression string is added after the text ret = Ops.add( (richtext ? "<I>" : "") + _("Value Matching Regular Expression:") + (richtext ? "</I>" : ""), regex ) elsif type == "integer" # allowed value description ret = (richtext ? "<I>" : "") + _("Any integer value") + (richtext ? "</I>" : "") elsif Builtins.regexpmatch(type, "^integer\\(.*:.*\\)") min = Builtins.regexpsub(type, "^integer\\((.*):.*\\)", "\\1") max = Builtins.regexpsub(type, "^integer\\(.*:(.*)\\)", "\\1") Builtins.y2milestone("min: %1, max: %2", min, max) if max == "" && min != "" # allowed value description ret = Ops.add( Ops.add( richtext ? "<I>" : "", Builtins.sformat(_("Integer value greater or equal to %1"), min) ), richtext ? "</I>" : "" ) elsif min == "" && max != "" # allowed value description ret = Ops.add( Ops.add( richtext ? "<I>" : "", Builtins.sformat(_("Integer value less or equal to %1"), max) ), richtext ? "</I>" : "" ) else # Translation: allowed value description, %1 is minimum value, %2 is maximum integer value ret = Ops.add( Ops.add( richtext ? "<I>" : "", Builtins.sformat(_("Any integer value from %1 to %2"), min, max) ), richtext ? "</I>" : "" ) end elsif type == "string" # allowed value description - any value is allowed ret = (richtext ? "<I>" : "") + _("Any value") + (richtext ? "</I>" : "") elsif type == "ip" # allowed value description - IP adress ret = (richtext ? "<I>" : "") + _("IPv4 or IPv6 address") + (richtext ? "</I>" : "") elsif type == "ip4" # allowed value description - IPv4 adress ret = (richtext ? "<I>" : "") + _("IPv4 address") + (richtext ? "</I>" : "") elsif type == "ip6" # allowed value description - IPv6 adress ret = (richtext ? "<I>" : "") + _("IPv6 address") + (richtext ? "</I>" : "") else Builtins.y2warning("Unknown type definition: %1", type) end ret end |
- (Object) ReadDialog
Read settings dialog
44 45 46 47 48 49 50 |
# File '../../src/include/sysconfig/complex.rb', line 44 def ReadDialog Wizard.SetHelpText(Ops.get_string(@HELPS, "read", "")) Sysconfig.Read :next end |
- (Object) update_button_state(description)
Update “Default” button state (enable/disable) in the dialog
652 653 654 655 656 657 658 659 |
# File '../../src/include/sysconfig/complex.rb', line 652 def (description) description = deep_copy(description) _def = Ops.get_string(description, "Default") UI.ChangeWidget(Id(:def), :Enabled, _def != nil) nil end |
- (Object) update_combo(description, set_default)
Update combo box in dialog
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File '../../src/include/sysconfig/complex.rb', line 586 def update_combo(description, set_default) description = deep_copy(description) varname = Ops.get_string(description, "name", "") # modification flag added to variable name (if it was changed) modif_flag = Builtins.haskey(description, "new_value") ? " " + _("(changed)") : "" if combo_editable(description) # combo box widget label - variable name is appended to the string UI.ReplaceWidget( Id(:replace), ComboBox( Id(:combo), Opt(:editable, :hstretch), Ops.add(Ops.add(_("S&etting of: "), varname), modif_flag), combo_list(description, set_default) ) ) else # combo box widget label - variable name is appended to the string UI.ReplaceWidget( Id(:replace), ComboBox( Id(:combo), Opt(:hstretch), Ops.add(Ops.add(_("S&etting of: "), varname), modif_flag), combo_list(description, set_default) ) ) end # disable combo for non-leaf nodes UI.ChangeWidget( Id(:combo), :Enabled, Ops.get_string(description, "file", "") != "" ) # display warning if value is not single line # combobox is one line entry, multiline values are merged to one line # (new lines are displayed as spaces, but they are correctly preserved val = Ops.get(description, "new_value") != nil ? Ops.get_string(description, "new_value", "") : Ops.get_string(description, "value", "") if val != nil lines = Builtins.splitstring(val, "\n") if Ops.greater_than(Builtins.size(lines), 1) # current value has more than one line - it is displayed incorrectly # because combobox widget has single line entry (lines are merged) Popup.Warning( _( "The currently selected value has more than one line.\nJoined lines are displayed in the combo box.\n" ) ) end end nil end |
- (Object) update_location(description)
Update location text in the dialog
663 664 665 666 667 668 669 670 671 672 673 674 675 |
# File '../../src/include/sysconfig/complex.rb', line 663 def update_location(description) description = deep_copy(description) l = Ops.get_string(description, "location", "") # header label UI.ChangeWidget( Id(:heading), :Value, Ops.add(Ops.add(_("Current Selection: "), l), @empty_string) ) nil end |
- (Object) WriteDialog
Write settings dialog
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File '../../src/include/sysconfig/complex.rb', line 54 def WriteDialog Wizard.SetHelpText(Ops.get_string(@HELPS, "write", "")) ret = true if Sysconfig.Modified == true Builtins.y2milestone("Changes will be written.") # write and activate changes if Sysconfig.Write == false # error popup message Popup.Error( _("An error occurred while saving and activating the changes.") ) else Builtins.sleep(500) # small delay, user should see 100% progress end #Popup::Message(_("The changes were saved and successfully activated.")); end :next end |