class Dictionaries::GUI::Gtk::Dictionary
Constants
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- SMALLER_FONT
#¶ ↑
SMALLER_FONT
¶ ↑This one should be relative to the font used above.
#¶ ↑
- TITLE
#¶ ↑
TITLE
¶ ↑#¶ ↑
- USE_THIS_FONT
#¶ ↑
USE_THIS_FONT
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
Public Class Methods
new( commandline_arguments = ARGV, run_already = true )
click to toggle source
run( i = ARGV )
click to toggle source
#¶ ↑
Dictionaries::GUI::Gtk::Dictionary.run
¶ ↑
Use this method if you wish to start a new gtk-application window.
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 427 def self.run( i = ARGV ) require 'gtk_paradise/app/app.rb' _ = ::Dictionaries::GUI::Gtk::Dictionary.new(i) r = ::Gtk.run r << _ r.automatic_size_then_automatic_title r.enable_quick_exit r.border_width = 12 r.top_left_then_run end
Public Instance Methods
add_the_answer_field()
click to toggle source
add_the_header_bar()
click to toggle source
add_the_statistics_frame()
click to toggle source
add_the_widget_for_remote_query_of_the_dictionary_at_leo()
click to toggle source
#¶ ↑
add_the_widget_for_remote_query_of_the_dictionary_at_leo
(bottom tag)¶ ↑
This is the bottom widget.
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 184 def add_the_widget_for_remote_query_of_the_dictionary_at_leo bottom_vbox = gtk_vbox bold_label = gtk_bold_label( 'Query from a remote website instead (more entries available)' ) bottom_vbox.minimal(bold_label, 15) # This is the user-input entry at the bottom. @entry_for_the_remote_query = gtk_entry @entry_for_the_remote_query.center @entry_for_the_remote_query.on_key_press_event { |widget, event| case Gdk::Keyval.to_name(event.keyval) when 'Return', 'KP_Enter' do_perform_a_remote_query_to_the_leo_dictionary end } bottom_vbox.minimal(@entry_for_the_remote_query) # ======================================================================= # # === button_for_the_remote_query # ======================================================================= # button_for_the_remote_query = button( '_Query from a remote dictionary' ) button_for_the_remote_query.clear_background button_for_the_remote_query.bblack2 button_for_the_remote_query.make_bold button_for_the_remote_query.hint = 'This will <b>query the remote dictionary</b> at leo instead. '\ 'The <b>advantage</b> here is that the dataset at leo will '\ 'contain many more entries than does the knowledgebase '\ 'distributed with the <b>dictionaries gem</b>.' button_for_the_remote_query.on_clicked { do_perform_a_remote_query_to_the_leo_dictionary } bottom_vbox.minimal( @entry_at_the_bottom_showing_the_result_from_online_leo, 2 ) @array_style_these_buttons << button_for_the_remote_query small_hbox = gtk_hbox small_hbox.minimal(button_for_the_remote_query, 1) small_hbox.halign_center bottom_vbox.minimal( small_hbox, 2 ) maximal(bottom_vbox, 2) end
border_size?()
click to toggle source
connect_skeleton()
click to toggle source
create_answer_field()
click to toggle source
#¶ ↑
create_answer_field
¶ ↑
This method builds up the “answer-widget”.
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 154 def create_answer_field # ======================================================================= # # === @answer_field # ======================================================================= # @answer_field = gtk_input_field @answer_field.center @answer_field.hint = 'The translated string may appear here.' @answer_field.very_light_yellow_background end
create_input_field_on_top()
click to toggle source
#¶ ↑
create_input_field_on_top
¶ ↑
This is the main widget for user input. The user types in some words, and then hits the main button on the bottom, in order to translate the (english) word to german.
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 286 def create_input_field_on_top text_for_the_label = 'Input an english word in the field below' text = gtk_label(text_for_the_label) text.slateblue text.set_markup( '<span size="x-large" weight="bold">'+text_for_the_label+'</span>', use_underline: true ) # ======================================================================= # # Add the "input field" next for the english word that is to # be translated. # ======================================================================= # @input_field = gtk_input_field @input_field.hint = 'Input the word that should be translated '\ 'here. Then, press the "enter" key or the button '\ '"Translate into german" below.' @input_field.very_light_yellow_background completion = gtk_entry_completion @input_field.completion = completion # Assign the completion. completion_model = gtk_list_store(String) @dictionaries.array.each { |word| iter = completion_model.append iter[0] = word } completion.model = completion_model # ======================================================================= # # Use model column 0 as the text column # ======================================================================= # completion.text_column = 0 @input_field.center @input_field.on_key_press_event { |widget, event| case Gdk::Keyval.to_name(event.keyval) when 'Return', 'KP_Enter' button_pressed_so_try_to_convert_the_input end } hbox_holding_label_and_input_field = gtk_vbox( text, @input_field ) minimal(hbox_holding_label_and_input_field, 2) end
create_skeleton()
click to toggle source
create_the_entries()
click to toggle source
#¶ ↑
create_the_entries
(entries tag, entry tag)¶ ↑
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 371 def create_the_entries # ======================================================================= # # === @entry_at_the_bottom_showing_the_result_from_online_leo # ======================================================================= # @entry_at_the_bottom_showing_the_result_from_online_leo = gtk_entry @entry_at_the_bottom_showing_the_result_from_online_leo.center end
create_the_header_bar()
click to toggle source
#¶ ↑
create_the_header_bar
¶ ↑
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 348 def create_the_header_bar # ======================================================================= # # === @header_bar # ======================================================================= # @header_bar = default_header_bar @header_bar.title = 'Dictionary' end
create_the_statistics_frame()
click to toggle source
#¶ ↑
create_the_statistics_frame
¶ ↑
# ¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 254 def create_the_statistics_frame # ======================================================================= # # === @frame_statistics # ======================================================================= # @frame_statistics = gtk_frame(' Statistics ') @frame_statistics.make_bold @frame_statistics.use_this_font = smaller_font? vbox = gtk_vbox @label_currently_selected_file = gtk_label(return_currently_selected_file) vbox.minimal( @label_currently_selected_file, 0 ) @frame_statistics.add(vbox) end
do_perform_a_remote_query_to_the_leo_dictionary( i = @entry_for_the_remote_query.text.to_s )
click to toggle source
#¶ ↑
do_perform_a_remote_query_to_the_leo_dictionary
¶ ↑
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 241 def do_perform_a_remote_query_to_the_leo_dictionary( i = @entry_for_the_remote_query.text.to_s ) if i and !i.empty? array = ::Dictionaries.return_array_of_translated_words_from_online_leo(i) result = array.first @entry_at_the_bottom_showing_the_result_from_online_leo.set_text(result) end end
e(i = '')
click to toggle source
handle_CSS()
click to toggle source
padding?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/dictionaries/gui/gtk3/dictionary/dictionary.rb, line 77 def reset reset_the_internal_variables # ======================================================================= # # === @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) infer_the_size_automatically # ======================================================================= # # === @dictionaries # ======================================================================= # @dictionaries = Dictionaries.new(:do_not_run_yet) Dictionaries.set_main_file(:default) @dictionaries.load_the_english_file # ======================================================================= # # === @array_style_these_buttons # ======================================================================= # @array_style_these_buttons = [] handle_CSS end
return_currently_selected_file()
click to toggle source
run()
click to toggle source
smaller_font?()
click to toggle source
update_the_statistics_frame(i = return_currently_selected_file)
click to toggle source