Class: Roebe::GUI::UniversalWidgets::Ifconfig

Inherits:
Base
  • Object
show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb

Overview

Roebe::GUI::UniversalWidgets::Ifconfig

Constant Summary collapse

TITLE =
#

TITLE

#
'Ifconfig'
STATUS_BAR_DEFAULT_MESSAGE =
#

STATUS_BAR_DEFAULT_MESSAGE

#
' Ready.'
PING_X_TIMES =
#

PING_X_TIMES

#
'5'
STATUS_BAR_DELAY =
#

STATUS_BAR_DELAY

#
10
ARRAY_ETH_INTERFACES =
#

ARRAY_ETH_INTERFACES

#
%w(
  eth0 eth1 eth2 eth3 eth4
)
ARRAY_IP_INTERFACES =
#

ARRAY_IP_INTERFACES

#
%w(
  192.168.1.0  192.168.1.1  192.168.1.2
  192.168.1.3  192.168.1.4  192.168.1.5 
  192.168.1.6  192.168.1.7  192.168.1.8
  192.168.1.9  192.168.1.10 192.168.1.11
  192.168.1.12
)
WIDTH =
#

WIDTH

#
'68% or minimum 1320px'
HEIGHT =
#

HEIGHT

#
'40% or minimum 920px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_18
LARGER_FONT =
#

LARGER_FONT

#
:hack_25
SMALLER_FONT =
#

SMALLER_FONT

#
:hack_20
DHCP_CMD =
#

DHCP_CMD

#
'/sbin/dhclient -1 -q -lf /var/lib/dhcp/dhclient-eth1.leases -pf /var/run/dhclient-eth1.pid eth1'
NETWORK_SCRIPTS =
#

NETWORK_SCRIPTS

#
'/etc/sysconfig/network-scripts/'
DEFAULT_PADDING =
#

DEFAULT_PADDING

#
8
IMG =
#

IMG

#
ENV['IMG'].to_s+'/'
COMPUTER_ICON =
#

COMPUTER_ICON

#
::Gtk.image("#{IMG}STD/COMPUTER.png")
HANGING_MONKEY =
#

HANGING_MONKEY

#
::Gtk.image(monkey)
HANG_MAN =
#

HANG_MAN

#
::Gtk.image(
  IMG+::Cyberweb::WebImages.get_proper_url(:hang_man)
)
LOCATION_NEWTORK_YAML_FILE =
#

LOCATION_NEWTORK_YAML_FILE

#
Roebe.file_network
NETWORK_YAML_FILE =
YAML.load_file(LOCATION_NEWTORK_YAML_FILE)
HASH_NETWORK_IPS =
NETWORK_YAML_FILE['nodes']

Constants inherited from Base

Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow

Methods included from Base::CommandlineArguments

#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ Ifconfig

#

initialize

#


197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 197

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  super(:vertical) if use_gtk3?
  determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  on_delete_event_quit_the_application
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Roebe::GUI::UniversalWidgets::Ifconfig[]

#


1257
1258
1259
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1257

def self.[](i = ARGV)
  new(i)
end

.run(i = ARGV) ⇒ Object

#

Roebe::GUI::Gtk::Ifconfig.run

#


1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1240

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::Roebe::GUI::Gtk::Ifconfig.new(i)
  r = ::Gtk.run
  _.set_parent_widget(r) # Must come before we enable the key-combinations.
  r << _
  r.automatic_size_then_automatic_title
  r.enable_quick_exit
  r.set_background :white
  r.top_left_then_run
end

Instance Method Details

#accel_group?Boolean Also known as: accel_group

#

accel_group?

#

Returns:

  • (Boolean)


1150
1151
1152
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1150

def accel_group?
  @accel_group
end

#add_accel_keysObject

#

add_accel_keys

Shortcut keys. Quite nice.

#


823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 823

def add_accel_keys
  @accel_group = gtk_accel_group # access key
  array = [
    Gdk::Keyval::GDK_1,
    Gdk::Keyval::GDK_2,
    Gdk::Keyval::GDK_3,
    Gdk::Keyval::GDK_4,
    Gdk::Keyval::GDK_5,
    Gdk::Keyval::GDK_6,
    Gdk::Keyval::GDK_7
  ]
  array.each { |keyval|
    @accel_group.connect(keyval, Gdk::Window::CONTROL_MASK, ::Gtk::ACCEL_VISIBLE) {
      @notebook.set_page(array.index(keyval))
    }
    @accel_group.connect(keyval, Gdk::Window::MOD1_MASK, ::Gtk::ACCEL_VISIBLE) {
      @notebook.set_page(array.index(keyval))
    }
  }
end

#add_msg_to_statusbar(this_msg, change_to_default_msg = false) ⇒ Object

#

add_msg_to_statusbar

This adds a message to the statusbar.

#


1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1180

def add_msg_to_statusbar(
    this_msg, change_to_default_msg = false
  )
  this_msg[0,1] = ' ' + this_msg[0,1] unless this_msg.start_with? ' ' 
  @status_bar.push(@status_bar_context_id, this_msg)
  if change_to_default_msg
    Thread.new { 
      sleep STATUS_BAR_DELAY
      add_msg_to_statusbar STATUS_BAR_DEFAULT_MESSAGE
    }
  end
end

#add_routeObject

#

add_route

#


607
608
609
610
611
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 607

def add_route
  _ = 'route add -net default gw 80.108.103.1 eth1'
  e _
  system _
end

#assign_new_compile_object(this_program) ⇒ Object

#

assign_new_compile_object

This method updates the data stored in @installer.

#


812
813
814
815
816
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 812

def assign_new_compile_object(this_program)
  this_program = this_program.to_s.dup
  this_program.delete!('_')
  @installer.initialize_dataset_for(this_program)
end

#assign_recieved_and_transmitted_dataObject

#

assign_recieved_and_transmitted_data

RX bytes:1961905524 (1.8 GiB) TX bytes:1833900853 (1.7 GiB)

#


291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 291

def assign_recieved_and_transmitted_data
  _ = `ifconfig -a`.chomp

  _ =~ /TX bytes (\d{2,100}) /
  _ = ~ /TX packets .+ bytes (\d{2,100}) \((.+ MiB)\)/
  if $1
    @data_sent_tx = $1.dup
    @data_sent_tx = @data_sent_tx[0..-9]
    @data_sent_tx[0,1] = @data_sent_tx[0,1]+','
  end
  _ = ~ /RX packets .+ bytes (\d{2,100}) \((.+ MiB)\)/
  if $1
    @data_recieved_rx = $1.dup
    @data_recieved_rx = @data_recieved_rx[0..-9]
    @data_recieved_rx[0,1] = @data_recieved_rx[0,1]+','
  end 
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


340
341
342
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 340

def border_size?
  2
end

#build_ifconfig_command(arg = :up) ⇒ Object

#

build_ifconfig_command

This builds the ifconfig command. For running the system command, use run_ifconfig_command.

ifconfig eth1 up 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255
#


933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 933

def build_ifconfig_command(arg = :up)
  cmd = 'ifconfig '.dup
  cmd << @entry_eth_interface.text
  cmd << ' '
  case arg
  when :up   then cmd << 'up'
  when :down then cmd << 'down'
  end
  cmd << ' '
  cmd << @entry_ip.text
  cmd << ' '
  cmd << 'netmask '
  cmd << @entry_netmask.text
  cmd << ' '
  cmd << 'broadcast '
  cmd << @entry_broadcast.text
  @cmdline_string = cmd
  e cmd
end

#clear_dmesg_bufferObject

#

clear_dmesg_buffer

This clears the buffer.

#


746
747
748
749
750
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 746

def clear_dmesg_buffer
  @dmesg_string = `dmesg -c`
  @source_buffer_dmesg.text = @dmesg_string
  update_dmesg_buffer
end

#compile(this_program) ⇒ Object

#

compile

Compile this program by passing its name. Compile tag.

#


849
850
851
852
853
854
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 849

def compile(this_program)
  assign_new_compile_object(this_program)
  Thread.new {
    @installer.prepare_program(this_program.to_s)
  }
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


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
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1024

def connect_the_skeleton
  abort_on_exception

  outer_box = create_vbox

  @notebook.append_page_menu(@box_first_tab,  NotebookTabWithIcon.new('s','Ifconfig'))
  @notebook.set_tab_reorderable(@box_first_tab, true) 
  @notebook.append_page_menu(@box_second_tab, NotebookTabWithIcon.new('s','Configure Network'))
  @notebook.set_tab_reorderable(@box_second_tab, true)
  @notebook.append_page_menu(@box_third_tab,  NotebookTabWithIcon.new('s','WLAN'))
  @notebook.set_tab_reorderable(@box_third_tab, true)
  @notebook.append_page_menu(@box_fourth_tab, NotebookTabWithIcon.new('s','DMESG'))
  @notebook.set_tab_reorderable(@box_fourth_tab, true)
  @notebook.append_page_menu(@box_fifth_tab,  NotebookTabWithIcon.new('s','Actions'))
  @notebook.set_tab_reorderable(@box_fifth_tab, true)
  @notebook.append_page_menu(@box_sixth_tab,  NotebookTabWithIcon.new('s','Information'))
  @notebook.set_tab_reorderable(@box_sixth_tab, true)
  outer_box.maximal(@notebook, DEFAULT_PADDING)
  outer_box.minimal(@status_bar,0)

  window = create_window_or_runner(nil, width?, height?, title?)
  window << outer_box

  properly_prepare_this_window(window,
    {
      title:       title?,
      font:        font?,
      width:       width?,
      height:      height?,
      padding:     padding?,
      border_size: border_size?
    }
  )
  window.show_all
  window.top_left
  do_all_startup_related_actions
  run_main
end

#cp_config_file(which_one = :resolv) ⇒ Object

#

cp_config_file

Use this to copy a config file.

#


1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1198

def cp_config_file(which_one = :resolv)
  case which_one
  when :hosts,
       :host
    from = ENV['LINUX_NETWORKING']+'/hosts'
    to = '/etc/hosts'
  when :resolv
    from = ENV['LINUX_NETWORKING']+'/resolv.conf'
    to = '/etc/resolv.conf'
  else
    from = ENV['LINUX_NETWORKING']+'/resolv.conf'
    to = '/etc/resolv.conf'
  end
  msg = ' => Copied '+from+' to '+to
  e msg
  add_msg_to_statusbar(msg)
  File.cp(from, to)
end

#create_all_tabsObject

#

create_all_tabs

Add new tabs here. Tabs tag.

#


884
885
886
887
888
889
890
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 884

def create_all_tabs
  create_second_tab
  create_third_tab
  create_fourth_tab
  create_fifth_tab
  create_sixth_tab
end

#create_boxesObject

#

create_boxes

Here we can change the location of the button.

#


863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 863

def create_boxes
  # @ifconfig_big = create_paned_vbox_last_big(@label_title, @source_view)
  @ifconfig_big = create_paned_vbox_last_big(@label_title, @hbox_ifconfig)
  case @location_of_button#
  when :left
    @box_first_tab = create_paned_hbox(@button_update_listing, @ifconfig_big)
  when :right
    @box_first_tab = create_paned_hbox(@ifconfig_big, @button_update_listing)
  when :top
    @box_first_tab = create_paned_vbox(@button_update_listing, @ifconfig_big)
  else # also :bottom
    @box_first_tab = create_paned_vbox(@ifconfig_big, @button_update_listing)
  end
  @box_first_tab.spacing = 2
end

#create_fifth_tabObject

#

create_fifth_tab

This tab is for doing some transactions. 5 tag

#


483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 483

def create_fifth_tab
  @button_cp_resolv_conf = button('_Copy resolv.conf file')
  @button_cp_resolv_conf.on_clicked {
    cp_config_file(:resolv)
  }

  @button_cp_hosts_conf = button('_Copy /etc/hosts file')
  @button_cp_hosts_conf.on_clicked {
    cp_config_file(:hosts)
  }

  @entry_new_hostname = create_entry
  @button_change_hostname = button('_Change Hostname to:_lightgreen')
  @button_change_hostname.on_clicked {
    cmd = 'hostname ' << @entry_new_hostname.text
    e cmd
    system(cmd)
    add_msg_to_statusbar('Changed hostname to '+@entry_new_hostname.text+'. '+
      'Also, dont forget to restart network.')
  }

  @label_dhcp_command = text(' ')
  @button_dhcp_command = button('_Renew DHCPD_'+DHCP_CMD+'_lightgreen')
  @button_dhcp_command.on_clicked {
    add_msg_to_statusbar('Triggering dhcp command next:')
    @label_dhcp_command.set_text DHCP_CMD
    esystem(DHCP_CMD)
  }

  @button_kill_dhcp = button('_Kill DHCPD via dhcpcd -k_lightgreen')      
  @button_kill_dhcp.on_clicked {
    add_msg_to_statusbar('Killing DHCPD ...')
    esystem('dhcpcd -k')
  }

  @button_ping = button('_Ping_lightgreen')
  @button_ping.on_clicked {
    thread = Thread.new { 
      add_msg_to_statusbar('Pinging '+@combo_box_ping_hosts.active_text+
        ' '+PING_X_TIMES+' times ...', true)
    }
    thread.join
    ping_cmd = 'ping -c '+PING_X_TIMES+' '+@entry_ping_this_host.text
    e ping_cmd
    result_of_ping_cmd = `#{ping_cmd}`
    efancy result_of_ping_cmd
  }

  @entry_ping_this_host = create_entry
  @entry_ping_this_host.on_button_press_event do |widget, event|
    @entry_ping_this_host.select_region(0, -1)
  end 
  
  @combo_box_ping_hosts = create_combo_box
  @combo_box_ping_hosts.on_changed {
    if @combo_box_ping_hosts.active_iter
      @entry_ping_this_host.set_text(@combo_box_ping_hosts.active_text)
    end
  }
  %w(
    www.google.com
    derstandard.at
    www.linuxcompatible.org
  ).each { |val| @combo_box_ping_hosts.append_text(val) }
  @combo_box_ping_hosts.active = 0

  # Now, pack the stuff into our tab:
  @box_fifth_tab = create_vbox
  @box_fifth_tab.pack_start(
    create_paned_hbox(@button_cp_resolv_conf, @button_cp_hosts_conf),
    false,true,0)
  @box_fifth_tab.pack_start(
    create_paned_hbox(@button_change_hostname, @entry_new_hostname),
    false,true,0)
  @box_fifth_tab.pack_start(
    create_paned_hbox(HANG_MAN, @button_kill_dhcp),
    false, true,0)
  @box_fifth_tab.pack_start(
    create_paned_hbox(@button_dhcp_command, @label_dhcp_command),
    false,true,0)
  
  # add a blank line
  @box_fifth_tab.pack_start(
    create_paned_hbox(create_label),false,true,0
  )
  
  # Add the combo box that keeps our route
  
  @combo_box_entry_route = create_combo_box_entry(true)
  @combo_box_entry_route.set_size_request(320, 34)
  hbox_route = create_paned_hbox(
    create_paned_hbox(HANGING_MONKEY, @button_add_route),
    modify_bold_label('Route Adder: '),
    @combo_box_entry_route
    ) { 8 } # padding 8
  # 
  [
    'Add default route: route add -net default gw 80.108.103.1 eth1'
  ].each { |val|
    @combo_box_entry_route.append_text(val)
  }
  @combo_box_entry_route.active = 0

  @box_fifth_tab.maximal(
    create_paned_hbox(hbox_route),0
  )

  @box_fifth_tab.minimal(
    create_paned_hbox(
      modify_bold_label('If that doesnt work try "dhcpd eth0"')
    ),0
  )
  @box_fifth_tab.minimal(
    create_paned_hbox(label), 0
  )
  @box_fifth_tab.pack_start(
    create_paned_hbox(
      @button_ping, @entry_ping_this_host,@combo_box_ping_hosts),
    false,true,0)
end

#create_fourth_tabObject

#

create_fourth_tab

This tab is the dmesg result. 4 tag

#


1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1068

def create_fourth_tab

  # Contains the dmesg result.
  @source_buffer_dmesg = create_source_buffer

  @source_view_dmesg = create_source_view(@source_buffer_dmesg)
  # if @source_view_dmesg.respond_to? :set_smart_home_end
  #   @source_view_dmesg.smart_home_end = true
  # end
  @source_view_dmesg.left_margin = 8
  @source_view_dmesg.border_width = 4
  @source_view_dmesg.set_size_request 400,400
  
  @scrolled_window_for_dmesg = create_scrolled_window(@source_view_dmesg) { :automatic }

  @button_update_dmesg = button('Update DMESG')
  @button_update_dmesg.on_clicked {
    update_dmesg_buffer
  }
  @button_update_dmesg.set_size_request(100, 32)

  @button_clear_dmesg = button('Clear DMESG')
  @button_clear_dmesg.on_clicked { clear_dmesg_buffer }
  @button_clear_dmesg.set_size_request(100, 32)

  @box_fourth_tab = create_vbox
  @box_fourth_tab.pack_start(@scrolled_window_for_dmesg, true,true,6)

  @box_fourth_tab.pack_start(
    create_paned_hbox(
      @button_update_dmesg, @button_clear_dmesg
    ),false,true,0
  )
  update_dmesg_buffer
end

#create_labelsObject

#

create_labels

Dump all labels inside here.

#


1159
1160
1161
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1159

def create_labels
  @label_title = modify_bold_label('Ifconfig')
end

#create_notebookObject

#

create_notebook

This is our main notebook view.

#


324
325
326
327
328
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 324

def create_notebook
  @notebook = create_notebook
  @notebook.set_page(0)
  @notebook.is_scrollable
end

#create_second_tabObject

#

create_second_tab

Stuff that you put into the second tab.

ifconfig eth1 up 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255

#


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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 620

def create_second_tab
  @button_ifconfig_up = button('Ifconfig Up')
  @button_ifconfig_up.on_clicked { run_ifconfig_command(:up) }
  @button_ifconfig_down = button('Ifconfig Down')
  @button_ifconfig_down.on_clicked {
    run_ifconfig_command(:down)
  }
  @button_network_restart = button('_NetworkRestart')
  @button_network_restart.on_clicked {
    system '/etc/rc.d/init.d/network restart'
  }

  @entry_eth_interface = create_entry( @eth_interface_to_use )
  @entry_ip        = create_entry(@ip)
  @entry_netmask   = create_entry( @netmask )
  @entry_broadcast = create_entry(@broadcast)

  @array_entries = [
    @entry_eth_interface,
    @entry_broadcast,
    @entry_ip,
    @entry_netmask
  ]
  # This is the most left entry for the eth0 etc interface
  @entry_eth_interface.signal_connect(:event) { |widget, event|
    case event.event_type.name
    when 'GDK_SCROLL'
      case event.direction
      when Gdk::EventScroll::Direction::DOWN
        # puts 'scrolled down!'
      when Gdk::EventScroll::Direction::UP
        puts @active_eth_interface
      end
    end
  }
  @combo_box_eth = create_combo_box(true)
  ARRAY_ETH_INTERFACES.each { |val| @combo_box_eth.append_text(val) }
  @combo_box_eth.active = 1
  @active_eth_interface = @combo_box_eth.active
  @combo_box_eth.on_changed {
    set_eth_interface_entry if @combo_box_eth.active_iter
  }
  
  @combo_box_eth.modify_background(:normal, :white)
  @combo_box_eth.can_focus = false
  @array_entries.each { |entry|
    entry.on_changed { reassign_ifconfig_command }
  }

  @combo_box_ip = create_combo_box(true)
  ARRAY_IP_INTERFACES.each { |val| @combo_box_ip.append_text(val) }

  @combo_box_ip.active = 1
  @combo_box_ip.on_changed {
    set_ip_interface_entry if @combo_box_ip.active_iter
  }

  @combo_box_ip.modify_background(:normal, :white)
  @combo_box_ip.can_focus = false

  @array_entries.each { |entry|
    entry.on_changed { reassign_ifconfig_command }
  }

  hbox_eth = create_paned_hbox_first_big(@entry_eth_interface, @combo_box_eth)
  hbox_ip  = create_paned_hbox_first_big(@entry_ip, @combo_box_ip)
  hbox_broadcast = create_paned_hbox_first_big(@entry_broadcast, @checkbox_broadcast)

  vbox_with_cmdline_entry = create_paned_hbox(@entry_cmdline = gtk_entry)
  @entry_cmdline.editable = false

  vbox1 = create_paned_vbox modify_bold_label('Eth Interface'),hbox_eth
  vbox2 = create_paned_vbox modify_bold_label('IP'),hbox_ip
  vbox3 = create_paned_vbox modify_bold_label('Netmask'),@entry_netmask
  vbox4 = create_paned_vbox modify_bold_label('Broadcast'),hbox_broadcast

  small_box_hbox = create_paned_hbox(vbox1, vbox2, vbox3, vbox4)
  # @ip='192.168.1.2'
  # @netmask='255.255.255.0'
  # @broadcast='192.168.1.255'
  button_box = create_paned_hbox(@button_ifconfig_up,@button_ifconfig_down)
  @box_second_tab = create_paned_vbox(
    button_box,@button_network_restart,vbox_with_cmdline_entry,small_box_hbox
  )
end

#create_sixth_tabObject

#

create_sixth_tab

This tab is for Information stuff only (displaying stuff). 6 tag Information tag. (Information tab)

#


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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 350

def create_sixth_tab
  assign_recieved_and_transmitted_data

  @label_transmitted_data = modify_bold_label(
    'Transmitted data: '+@data_sent_tx + ' bytes (in GIG)','slateblue')
  @label_recieved_data = modify_bold_label(
    'Recieved data: '+ @data_recieved_rx + ' bytes (in GIG)','slateblue')
  
  @event_box_for_label_transmitted_data = create_event_box
  @event_box_for_label_transmitted_data.add(
    create_paned_vbox(@label_transmitted_data, @label_recieved_data)
  )
  
  @event_box_for_label_transmitted_data.signal_connect(:event) {|widget, event|
    if event.event_type.name == 'GDK_BUTTON_PRESS'
      assign_recieved_and_transmitted_data
      @label_transmitted_data.set_markup(
        %Q[<markup><span weight="bold" foreground="slateblue">Transmitted data: #{@data_sent_tx} bytes (in GIG)</span></markup>], true)
      @label_recieved_data.set_markup(
        %Q[<markup><span weight="bold" foreground="slateblue">Recieved data: #{@data_recieved_rx} bytes (in GIG)</span></markup>], true)  
    end
  }

  @box_sixth_tab = create_vbox
  @box_sixth_tab.minimal(
    create_paned_hbox(
      @event_box_for_label_transmitted_data
    ),0
  )
  @box_sixth_tab.maximal(COMPUTER_ICON)
  
  # Empty Spacer
  @box_sixth_tab.maximal(label(''))
  # Next comes the box with the multiple IPs. This is a simply VBOX.
  @info_box_with_ips = create_vbox
  # Now add the available network stuff as reminder.
  HASH_NETWORK_IPS.sort.each { |key, value|
    @info_box_with_ips.pack_start(
      modify_bold_label(key +  ' -> ' + value, 'black','left','left')
    )
  }
  @box_sixth_tab.pack_start(@info_box_with_ips)
  
  # Empty Spacer
  @box_sixth_tab.pack_start(label(''))
  @text_buffer_general_information = create_text_buffer
  result = ''
  if File.exists? '/etc/HOSTNAME'
    hostname = File.read('/etc/HOSTNAME').chomp
    hostname = hostname.split('.')[0] if hostname.include?('.')
    # assigned_ip is the ip our host should get. Be careful,
    # this code should always work with assigned ips.
    # Can be found in:
    #   bl $LINUX_YAML/ips.yml
    assigned_ip = NETWORK_YAML_FILE['nodes']
    assigned_ip = assigned_ip[hostname]
    # pp hostname+'  '+NETWORK_YAML_FILE['nodes']
    result << 'Hostname: '
    result << hostname
    result << ' (LAN: '
    result << assigned_ip
    result << ')' 
    result << N
  end
  result << `iwconfig 2>&1`
  e result
  # On default startup, this buffer carries the iwconfig info.
  # However... iwconfig seems to misbehave :/
  @text_buffer_general_information.set_text(result)
  
  @text_view_general_information = create_text_view(@text_buffer_general_information)
  @box_sixth_tab.maximal(create_label('iwconfig'), 0)
  @box_sixth_tab.maximal(@text_view_general_information,0)
  
  # Spacer
  @box_sixth_tab.pack_start(create_label(''))
  
  @box_sixth_tab.minimal(
    create_paned_hbox(
      modify_bold_label('Information of dirs and 
      files in /etc/sysconfig/network-scripts/:')), 0)
  
  _box = create_vbox
  _box.modify_background(:normal, :white)
  
  if File.exists?(NETWORK_SCRIPTS) # ~ '/etc/sysconfig/network-scripts/'
    content = FileListing.get_file_listing(NETWORK_SCRIPTS, true)
    content.each { |specific_entry|
      alignment = create_alignment(0,0,0,0)
      alignment.modify_background(:normal, :white)
      _box.pack_start( 
        alignment.add(modify_bold_label(specific_entry,'grey')),false,false,0)
    }
  else # else our File does not exist
    dir_missing = modify_bold_label(NETWORK_SCRIPTS+' does not exist.','red') 
    _box.pack_start(dir_missing,false,false,0)
  end
  
  @scrolled_window = create_scrolled_window(_box)
  @scrolled_window.modify_background(:normal, :white)
  @scrolled_window.modify_foreground(:normal, :black)

  @box_sixth_tab.maximal(@scrolled_window, 0)

  if File.exists?(NETWORK_SCRIPTS)
    entry_network_scripts = gtk_entry('cd '+NETWORK_SCRIPTS)
    @box_sixth_tab.pack_start(
      entry_network_scripts,false,true,0)
  end
end

#create_source_viewer_and_bufferObject

#

create_source_viewer_and_buffer

#


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
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 895

def create_source_viewer_and_buffer
  @source_buffer_ifconfig1 = create_source_buffer
  @source_buffer_ifconfig1 = ::Gtk::TextBufferTags.create_my_tags(
    @source_buffer_ifconfig1
  )

  @source_view_ifconfig1 = gtk_source_view(@source_buffer_ifconfig1)
  # if @source_view_ifconfig1.respond_to? :set_smart_home_end
  #   @source_view_ifconfig1.set_smart_home_end(true)
  # end
  @source_view_ifconfig1.left_margin = 2
  
  @source_buffer_ifconfig2 = gtk_source_buffer
  @source_buffer_ifconfig2 = ::Gtk::TextBufferTags.create_my_tags(@source_buffer_ifconfig2)
  
  @source_view_ifconfig2 = gtk_source_view(@source_buffer_ifconfig2)
  # if @source_view_ifconfig2.respond_to? :set_smart_home_end
  #   @source_view_ifconfig2.set_smart_home_end(true)
  # end
  @source_view_ifconfig2.left_margin = 2

  # ======================================================================= #
  # this hbox carries our ifconfig
  # ======================================================================= #
  @hbox_ifconfig = create_paned_hbox(
    @source_view_ifconfig1, @source_view_ifconfig2
  )
end

#create_statusbarObject

#

create_statusbar

#


1166
1167
1168
1169
1170
1171
1172
1173
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1166

def create_statusbar
  @status_bar = create_statusbar
  @status_bar_context_id = @status_bar.get_context_id('StatusBar_Ifconfig')
  @status_bar.push(@status_bar_context_id, STATUS_BAR_DEFAULT_MESSAGE)
  if @status_bar.respond_to? :set_has_resize_grip
    @status_bar.set_has_resize_grip(true)
  end
end

#create_the_buttonsObject

#

create_the_buttons

Not sure if this is the best approach … buttons tag. Contains all or almost all buttons which are used in the application. Also includes checkbox buttons.

#


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
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 960

def create_the_buttons
  @button_update_listing = button('_UpdateListing')
  @button_update_listing.on_clicked { fetch_sys_information }
  @button_update_listing.set_size_request(80, 32)
  # ============================================================== #
  # === WLAN BUTTON tag
  # ============================================================== #
  assign_new_compile_object('wirelesstools')
  @button_compile_wireless_tools = button("_Compile \nWireless Tools: \n"+
    @installer.name?.to_s)
  @button_compile_wireless_tools.on_clicked { compile(:wireless_tools) }
  @button_compile_wireless_tools.set_size_request(80, 32)
  # ============================================================== #
  # === AircrackNG tag
  # ============================================================== #
  assign_new_compile_object('aircrackng')
  @button_compile_aircrackng = button("_Compile \nAircrack-NG\n"+
    @installer.name?.to_s)
  @button_compile_aircrackng.on_clicked { compile(:aircrackng) }
  @button_compile_aircrackng.set_size_request(80, 32)
  # ============================================================== #
  # wireshark tag
  # ============================================================== #
  assign_new_compile_object('wireshark')
  @button_compile_kwifimanager = button("_Compile \nWireshark:\n"+
    @installer.name?.to_s)
  @button_compile_kwifimanager.on_clicked { compile(:wireshark) }
  @button_compile_kwifimanager.set_size_request(80, 32)
  @button_compile_kwifimanager.sensitive = true # here you could disable it
  
  # ============================================================== #
  # NDiswrapper tag
  # ============================================================== #
  assign_new_compile_object('ndiswrapper')
  @button_compile_ndiswrapper = button("_Compile \nNDiswrapper:\n"+
    @installer.name?.to_s)
  @button_compile_ndiswrapper.on_clicked { compile(:ndiswrapper) }
  @button_compile_ndiswrapper.set_size_request(80, 32)

  # ============================================================== #
  # Button add a route.
  # ============================================================== #
  @button_add_route  = button('_Add Route')
  @button_add_route.on_clicked { add_route }
  @button_add_route.set_size_request(80, 32)   
  
  # ============================================================== #
  # Die checkbox tag
  # ============================================================== #
  @checkbox_broadcast = create_check_button('', false)
  @checkbox_broadcast.set_active( false )
  @checkbox_broadcast.hint = 'Activating this setting enables broadcast.'
  @checkbox_broadcast.on_toggled {|widget|
    if widget.active?
      enable_broadcast
    elsif not widget.active?
      disable_broadcast
    end
  }
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1220

def create_the_skeleton
  create_notebook
  create_statusbar
  create_the_buttons
  create_labels # Must come before create_boxes().
  create_source_viewer_and_buffer # Must come before create_boxes().
  create_boxes
  create_all_tabs
end

#create_third_tabObject

#

create_third_tab

This tab is the wlan stuff. Has a nice picture. :P 3 tag

#


1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1109

def create_third_tab
  @box_third_tab = create_vbox
  @event_box_wlan_image = create_event_box
  image = gtk_image(ENV['IMG']+'/SCIENCE/FUNK/WLAN_SYMBOL.png')
  @event_box_wlan_image.add(image)
  @event_box_wlan_image.on_button_press_event {
    open_in_browser 'wlan' 
  }
  @box_third_tab.pack_start(
    create_hbox(
      @event_box_wlan_image,
      @button_compile_wireless_tools,
      @button_compile_aircrackng, 
      @button_compile_kwifimanager,
      @button_compile_ndiswrapper
    ),true,true,6
  )
  # will also install the ndiswrapper driver
  @button_install_wg111t = button('Install WG111T')
  @button_install_wg111t.on_clicked {
    e 'Installing WG111T next.'
    compile(:ndiswrapper) # hmm lets compile it as well
    install_wg111t # Defined in custom_methods.rb
  }
  @box_third_tab.pack_start(
    create_paned_hbox(
      @button_install_wg111t),true,true,6
  )
end

#disable_broadcastObject



805
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 805

def disable_broadcast; end
#
#


1142
1143
1144
1145
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1142

def do_all_startup_related_actions
  fetch_sys_information
  reassign_ifconfig_command # do it once before starting up
end

#enable_broadcastObject

UNFINISHED?



804
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 804

def enable_broadcast;  end

#favicon?Boolean

#

favicon?

#

Returns:

  • (Boolean)


709
710
711
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 709

def favicon?
  HOME_OF_THE_USER_CALLED_X+'DATA/images/PC/OS/LINUX/GOOGLE_MAPS.jpg'
end

#fetch_sys_informationObject

#

fetch_sys_information

This retrieves the info from our host. We use ifconfig -a to get this information.

#


758
759
760
761
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 758

def fetch_sys_information
  @ifconfig1_string = `ifconfig -a`
  update_ifconfig_buffers
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

#


269
270
271
272
273
274
275
276
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 269

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it '

'

end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


333
334
335
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 333

def padding?
  0
end

#reassign_ifconfig_commandObject

#

reassign_ifconfig_command

Reassigns the string to our Gtk::Entry.

#


718
719
720
721
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 718

def reassign_ifconfig_command
  build_ifconfig_command
  @entry_cmdline.set_text(@cmdline_string)
end

#reassign_ip_commandObject

#

reassign_ip_command

#


726
727
728
729
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 726

def reassign_ip_command
  build_ifconfig_command
  @entry_cmdline.set_text(@cmdline_string)
end

#resetObject

#

reset (reset tag)

#


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
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 214

def reset
  super() if respond_to?(:super)
  reset_the_shared_module # This can come early.
  reset_the_base_module
  reset_the_internal_variables
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  # ======================================================================= #
  # === Set the title, width, height and the font in use.
  # ======================================================================= #
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  if use_gtk3?
    handle_CSS_rules
  end
  infer_the_size_automatically
  @ip = '192.168.1.2'
  @netmask = '255.255.255.0'
  @broadcast = '192.168.1.255'
  # ======================================================================= #
  # === @cmdline_string
  # ======================================================================= #
  @cmdline_string = ''.dup # empty at start
  @active_eth_interface = 0 # keeps track of our active eth interface
  @data_recieved_rx = 0 # keeps track of how much data we recieved
  @data_sent_tx     = 0 # keeps track of how much data we recieved
  # ======================================================================= #
  # === @location_of_button
  # ======================================================================= #
  @location_of_button = :top # can be :top
  add_accel_keys
  if Object.const_defined? :RBT
    @installer = RBT::Installer.new(:do_not_run_yet) # so we have a dummy compile object
  else
    @installer = nil
  end
  @eth_interface_to_use = 'eth1'
  if NETWORK_YAML_FILE.has_key? 'MY_IP'
    @my_ip = NETWORK_YAML_FILE['MY_IP'] # contains my real ip
  end
  assign_recieved_and_transmitted_data
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.

#


284
285
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 284

def reset_the_shared_module
end

#runObject

#

run (run tag)

#


1233
1234
1235
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 1233

def run
  run_super
end

#run_ifconfig_command(i = :up) ⇒ Object

#

build_ifconfig_command

Run ifconfig command.

#


314
315
316
317
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 314

def run_ifconfig_command(i = :up)
  build_ifconfig_command(i)
  system(@cmdline_string)
end

#set_eth_interface_entryObject

#

set_eth_interface_entry

#


472
473
474
475
476
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 472

def set_eth_interface_entry
  @entry_eth_interface.set_text(@combo_box_eth.active_text)
  @active_eth_interface = @combo_box_eth.active
  reassign_ifconfig_command
end

#set_ip_interface_entryObject

#

set_ip_interface_entry

#


464
465
466
467
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 464

def set_ip_interface_entry
  @entry_ip.set_text(@combo_box_ip.active_text)
  reassign_ip_command
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


262
263
264
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 262

def smaller_font?
  SMALLER_FONT
end

#update_dmesg_bufferObject

#

update_dmesg_buffer

Reassign buffer to dmesg.

#


736
737
738
739
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 736

def update_dmesg_buffer
  @dmesg_string = `dmesg`
  @source_buffer_dmesg.text = @dmesg_string
end

#update_ifconfig_buffersObject

#

update_ifconfig_buffers

Reassigns our ifconfig buffers. Here you can colourize stuff @ifconfig1_string is for our left buffer.

#


769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# File 'lib/roebe/gui/universal_widgets/ifconfig/ifconfig.rb', line 769

def update_ifconfig_buffers
  @source_buffer_ifconfig1.text = @ifconfig1_string

  if pos = @ifconfig1_string =~ /lo/
    iter = @source_buffer_ifconfig1.get_iter_at_offset(pos)
    iter2 = @source_buffer_ifconfig1.get_iter_at_offset(pos+'lo'.size)
    @source_buffer_ifconfig1.delete(iter, iter2)
    @source_buffer_ifconfig1.insert(iter, 'lo','bold','darkgreen')
  end

  if pos = @ifconfig1_string =~ /(eth.)\s/
    iter = @source_buffer_ifconfig1.get_iter_at_offset(pos)
    iter2 = @source_buffer_ifconfig1.get_iter_at_offset(pos+'eth1'.size)
    @source_buffer_ifconfig1.delete(iter, iter2)
    @source_buffer_ifconfig1.insert(iter, $1,'bold','darkgreen')
  end

  if pos = @ifconfig1_string =~ /(HWaddr 00:50:04:3C:DD:85)/
    iter = @source_buffer_ifconfig1.get_iter_at_offset(pos)
    iter2 = @source_buffer_ifconfig1.get_iter_at_offset(pos+'HWaddr 00:50:04:3C:DD:85'.size)
    # puts 'Match war :'+$1
    @source_buffer_ifconfig1.delete(iter, iter2)
    @source_buffer_ifconfig1.insert(iter, $1,'red','bold')
  end
  
  if pos = @ifconfig1_string =~ /(HWaddr)/
    iter = @source_buffer_ifconfig1.get_iter_at_offset(pos)
    iter2 = @source_buffer_ifconfig1.get_iter_at_offset(pos+'HWaddr'.size)
    # puts 'Match war :'+$1
    @source_buffer_ifconfig1.delete(iter, iter2)
    @source_buffer_ifconfig1.insert(iter, $1,'red','bold')
  end
end