This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ICS connection state is now reflected in status bar messages.
- Loading branch information
1 parent
7a22cd7
commit a3aa440
Showing
5 changed files
with
82 additions
and
7 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
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,42 @@ | ||
# Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
|
||
class StatusObserver | ||
MESSAGES = { | ||
:disconnected => { :permanent => '', :temporary => "Disconnected from ICS Server" }, | ||
:established => { :temporary => "Connection established" }, | ||
:connecting => { :permanent => "Connecting..." }, | ||
:logging_in => { :permanent => "Logging in..." }, | ||
:logged_in => { :temporary => "Logged in", :permanent => "Connected to ICS server" } | ||
} | ||
|
||
def initialize(set_temporary, set_permanent) | ||
@set_temporary = set_temporary | ||
@set_permanent = set_permanent | ||
switch_to(:disconnected) | ||
end | ||
|
||
def link_to(connection, protocol) | ||
connection.on(:connecting) { switch_to :connecting } | ||
connection.on(:established) { switch_to :established } | ||
connection.on(:closed) { switch_to :disconnected } | ||
protocol.on(:login_prompt) { switch_to :logging_in } | ||
protocol.observe_limited(:prompt) do | ||
switch_to(:logged_in) | ||
true | ||
end | ||
end | ||
|
||
def switch_to(state) | ||
@state = state | ||
messages = MESSAGES[state] | ||
if messages | ||
@set_permanent[messages[:permanent]] if messages[:permanent] | ||
@set_temporary[messages[:temporary]] if messages[:temporary] | ||
end | ||
end | ||
end |
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,22 @@ | ||
# Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
|
||
require 'toolkit' | ||
|
||
class StatusBar < KDE::StatusBar | ||
def initialize(parent) | ||
super(parent) | ||
|
||
@label = Qt::Label.new(self) | ||
|
||
add_widget(@label) | ||
end | ||
|
||
def show_permanent_message(msg) | ||
@label.text = msg | ||
end | ||
end |