Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /modeline.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (hide annotations) (download)
Thu Apr 19 18:05:04 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 3942 byte(s)
(Gtk) Change font of modeline according to the /UI/Gtk/Font configuration value.

1 bluedwarf 13 # modeline.rb: the module definition of Edmaru::ModeLine
2 bluedwarf 10 #
3     # Copyright (C) 2007 Takashi Nakamoto
4     #
5     # This program is free software; you can redistribute it and/or modify
6     # it under the terms of the GNU General Public License version 2 as
7     # published by the Free Software Foundation.
8     #
9     # This program is distributed in the hope that it will be useful, but
10     # WITHOUT ANY WARRANTY; without even the implied warranty of
11     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     # General Public License for more details.
13     #
14     # You should have received a copy of the GNU General Public License
15     # along with this program; if not, write to the Free Software
16     # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17     # 02110-1301 USA.
18     #
19 bluedwarf 4
20     require "modeline_element.rb"
21    
22     module Edmaru
23 bluedwarf 5
24     module ModeLine
25    
26     #Construct the modeline instance.
27     #
28 bluedwarf 6 #=== Arguments
29 bluedwarf 41 #_view_ :: The parent window.
30     #_config_ :: An instance of Edmaru::ConfigurationManager.
31 bluedwarf 6 #
32 bluedwarf 5 #=== Warning
33     #This method *MUST* *NOT* be overrided in derived classes.
34     #
35     #=== Return
36     #An initialized instance of ModeLine.
37 bluedwarf 41 def initialize(window, config)
38 bluedwarf 6 @window = window
39 bluedwarf 5 @elements = Hash.new
40 bluedwarf 6 @elements_order = Array.new
41 bluedwarf 41 @config = config
42 bluedwarf 6
43 bluedwarf 15 init_ui
44 bluedwarf 4 end
45    
46 bluedwarf 5 #The system specific initialization for ModeLine.
47     #
48     #=== Warning
49     #This method *SHOULD* be overrided in derived classes.
50 bluedwarf 15 def init_ui
51 bluedwarf 4 end
52    
53 bluedwarf 5 #Add the specified _element_, an instance of ModeLineElement, to
54     #this ModeLine.
55     #
56     #=== Argument
57     #_element_ :: an instance of ModeLineElement to be added.
58     #
59     #=== Warning
60     #This method *MUST* *NOT* be overrided in derived classes.
61     #
62     #=== Return
63     #_true_ if the addition is succeeded.
64     #_false_ if the _element_'s name has already reserved.
65     def add_element(element)
66     if @elements.include?(element.name)
67     return false
68     end
69    
70     @elements[element.name] = element
71 bluedwarf 6 @elements_order.push(element.name)
72 bluedwarf 4 end
73    
74 bluedwarf 5 #Show the specified element.
75     #
76     #=== Argument
77     #_name_ :: the name of the element.
78     #
79     #=== Warning
80     #This method *MUST* *NOT* be overrided in derived classes.
81     def show_element(name)
82 bluedwarf 6 if !@elements.include?(name) || @elements[name].visible?
83 bluedwarf 5 return
84     end
85    
86     @elements[name].visible = true
87 bluedwarf 6 refresh
88 bluedwarf 4 end
89    
90 bluedwarf 5 #Hide the specified element.
91     #
92     #=== Argument
93     #_name_ :: the name of the element.
94     #
95     #=== Warning
96     #This method *MUST* *NOT* be overrided in derived classes.
97     def hide_element(name)
98 bluedwarf 6 if !@elements.include?(name) || !@elements[name].visible?
99 bluedwarf 5 return
100     end
101    
102     @elements[name].visible = false
103 bluedwarf 15 refresh
104     end
105 bluedwarf 5
106 bluedwarf 15 #Set the text of the specified element.
107     #
108     #=== Warning
109     #This method *MUST* *NOT* be overrided in derived classes.
110     #
111     #=== Argument
112     #_name_ :: the name of this element
113     #_text_ :: a new text to be set as the text of the specified element.
114     def set_element_text(name, text)
115     if !@elements.include?(name) || @elements[name].text == text
116     return
117     end
118    
119     @elements[name].text = text
120 bluedwarf 6 refresh
121 bluedwarf 5 end
122    
123 bluedwarf 15
124 bluedwarf 5 #Get the specified element.
125     #
126     #=== Warning
127     #This method *MUST* *NOT* be overrided in derived classes.
128     #
129     #=== Argument
130     #_name_ :: the name of the element.
131     #
132     #=== Return
133     #An instance of ModeLineElement whose name is the specified name
134     #or _nil_ if the specified name is not registered.
135     def get_element(name)
136     if !@elements.include?(name)
137     return nil
138     end
139    
140     @elements[name]
141     end
142    
143 bluedwarf 6 #Redraws this modeline.
144     #
145     #=== Warning
146     #This method *SHOULD* be overrided in derived classes.
147     def refresh
148     end
149    
150 bluedwarf 5 #Terminate this modeline instance.
151     #
152     #=== Warning
153     #This method *SHOULD* be overrided in derived classes.
154 bluedwarf 4 def terminate
155     end
156     end
157     end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26