Class: Alexandria::UI::SmartLibraryPropertiesDialogBase

Inherits:
Object
  • Object
show all
Includes:
Logging, CalendarPopup, GetText
Defined in:
lib/alexandria/ui/smart_library_properties_dialog_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CalendarPopup

#assign_selected_date, #clear_date_entry, #display_calendar_popup, #setup_calendar_widgets

Methods included from Logging

included, #log

Constructor Details

#initialize(parent) ⇒ SmartLibraryPropertiesDialogBase

Returns a new instance of SmartLibraryPropertiesDialogBase.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 21

def initialize(parent)
  @dialog = Gtk::Dialog.new(title: "",
                            parent: parent,
                            flags: :modal,
                            buttons: [[Gtk::Stock::HELP, :help]])

  @dialog.window_position = :center
  @dialog.resizable = true
  @dialog.border_width = 4
  @dialog.child.border_width = 12

  main_box = Gtk::Box.new :vertical
  main_box.border_width = 4
  main_box.spacing = 8

  @dialog.child << main_box

  @smart_library_rules = []

  @rules_header_box = Gtk::Box.new :horizontal
  @rules_header_box.spacing = 2

  @rules_box = Gtk::Box.new :vertical
  @rules_box.spacing = 8
  @rules_box.border_width = 8

  scrollview = Gtk::ScrolledWindow.new
  scrollview.hscrollbar_policy = :never
  scrollview.vscrollbar_policy = :automatic
  scrollview.set_size_request(-1, 125)
  scrollview.add_with_viewport(@rules_box)

  main_box.pack_start(@rules_header_box, expand: false, fill: false)
  main_box << scrollview
end

Instance Attribute Details

#dialogObject (readonly)

Returns the value of attribute dialog.



19
20
21
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 19

def dialog
  @dialog
end

#predicate_operator_ruleObject (readonly)

Returns the value of attribute predicate_operator_rule.



19
20
21
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 19

def predicate_operator_rule
  @predicate_operator_rule
end

Instance Method Details

#apply_smart_rule_for_rule_box(rule_box, operand, operation) ⇒ Object

TODO: Move logic to SmartLibraryRuleBox



70
71
72
73
74
75
76
77
78
79
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 70

def apply_smart_rule_for_rule_box(rule_box, operand, operation)
  idx = @rules_box.children.index(rule_box)
  smart_library_rules[idx] ||= SmartLibrary::Rule.new(operand,
                                                      operation.first,
                                                      nil)
  new_rule = smart_library_rules[idx]
  new_rule.operand = operand
  new_rule.operation = operation.first
  new_rule.value = nil
end

#handle_add_rule_clickedObject



61
62
63
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 61

def handle_add_rule_clicked
  insert_new_rule
end

#handle_date_icon_press(widget, primary, _icon) ⇒ Object



57
58
59
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 57

def handle_date_icon_press(widget, primary, _icon)
  display_calendar_popup(widget) if primary.nick == "primary"
end

#handle_remove_rule_clicked(box_controller) ⇒ Object



65
66
67
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 65

def handle_remove_rule_clicked(box_controller)
  remove_rule_box(box_controller.rule_box)
end