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.



20
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
# File 'lib/alexandria/ui/smart_library_properties_dialog_base.rb', line 20

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.



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

def dialog
  @dialog
end

#predicate_operator_ruleObject (readonly)

Returns the value of attribute predicate_operator_rule.



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

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



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

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



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

def handle_add_rule_clicked
  insert_new_rule
end

#handle_date_icon_press(widget, primary, _icon) ⇒ Object



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

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

#handle_remove_rule_clicked(box_controller) ⇒ Object



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

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