-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe5a2e4
commit 4996188
Showing
11 changed files
with
161 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
require 'date' | ||
|
||
# This class declares an `email_shell` custom shell, aka custom window (by convention) | ||
# Used to view an email message | ||
class EmailShell | ||
include Glimmer::UI::CustomShell | ||
|
||
# multiple options without default values | ||
options :date, :subject, :from, :message | ||
|
||
# single option with default value | ||
option :to, default: '"John Irwin" <[email protected]>' | ||
|
||
before_body { | ||
@swt_style |= swt(:shell_trim, :modeless) | ||
} | ||
|
||
body { | ||
# pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell) | ||
shell(swt_style) { | ||
grid_layout(2, false) | ||
|
||
text subject | ||
|
||
label { | ||
text 'Date:' | ||
} | ||
label { | ||
text date | ||
} | ||
|
||
label { | ||
text 'From:' | ||
} | ||
label { | ||
text from | ||
} | ||
|
||
label { | ||
text 'To:' | ||
} | ||
label { | ||
text to | ||
} | ||
|
||
label { | ||
text 'Subject:' | ||
} | ||
label { | ||
text subject | ||
} | ||
|
||
label { | ||
layout_data(:fill, :fill, true, true) { | ||
horizontal_span 2 | ||
verticalIndent 10 | ||
} | ||
|
||
background :white | ||
text message | ||
} | ||
} | ||
} | ||
|
||
end | ||
|
||
class HelloCustomShell | ||
# including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `email_shell` custom widget | ||
include Glimmer | ||
|
||
Email = Struct.new(:date, :subject, :from, :message, keyword_init: true) | ||
EmailSystem = Struct.new(:emails, keyword_init: true) | ||
|
||
def initialize | ||
@email_system = EmailSystem.new( | ||
emails: [ | ||
Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <[email protected]>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"), | ||
Email.new(date: DateTime.new(2029, 10, 21, 8, 1, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v100.0', from: '"Robert McGabbins" <[email protected]>', message: "Team,\n\nWe are upgrading to Glimmer version 100.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"), | ||
Email.new(date: DateTime.new(2029, 10, 19, 16, 58, 0).strftime('%F %I:%M %p'), subject: 'Christmas Party', from: '"Lisa Ferreira" <[email protected]>', message: "Merry Christmas,\n\nAll office Christmas Party arrangements have been set\n\nMake sure to bring a Secret Santa gift\n\nBest regards,\n\nLisa Ferreira"), | ||
Email.new(date: DateTime.new(2029, 10, 16, 9, 43, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v99.0', from: '"Robert McGabbins" <[email protected]>', message: "Team,\n\nWe are upgrading to Glimmer version 99.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"), | ||
Email.new(date: DateTime.new(2029, 10, 15, 11, 2, 0).strftime('%F %I:%M %p'), subject: '2nd Week Report', from: '"Dianne Tux" <[email protected]>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"), | ||
Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <[email protected]>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"), | ||
] | ||
) | ||
end | ||
|
||
def launch | ||
shell { | ||
grid_layout | ||
|
||
text 'Hello, Custom Shell!' | ||
|
||
label { | ||
font height: 24, style: :bold | ||
text 'Emails:' | ||
} | ||
|
||
label { | ||
font height: 18 | ||
text 'Click an email to view its message' | ||
} | ||
|
||
table { | ||
layout_data :fill, :fill, true, true | ||
|
||
table_column { | ||
text 'Date:' | ||
width 180 | ||
} | ||
table_column { | ||
text 'Subject:' | ||
width 180 | ||
} | ||
table_column { | ||
text 'From:' | ||
width 360 | ||
} | ||
|
||
items bind(@email_system, :emails), column_properties(:date, :subject, :from) | ||
|
||
on_mouse_up { |event| | ||
email = event.table_item.get_data | ||
Thread.new do | ||
async_exec { | ||
email_shell(date: email.date, subject: email.subject, from: email.from, message: email.message).open | ||
} | ||
end | ||
} | ||
} | ||
}.open | ||
end | ||
end | ||
|
||
HelloCustomShell.new.launch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters