3 #**************************************************************************
6 # Copyright (C) 2009 Euan Freeman <euan04@gmail.com>
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License version 3
10 # as published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #*************************************************************************/
20 # Last modified: 27th September 2009
34 AUTHORS
= ["Euan Freeman <euan04@gmail.com>"]
36 COMMENTS
= "tintwizard generates config files for the lightweight panel replacement tint2"
37 WEBSITE
= "http://code.google.com/p/tintwizard/"
39 # Default values for text entry fields
49 TASKBAR_PADDING_X
= "0"
50 TASKBAR_PADDING_Y
= "0"
52 TASK_MAXIMUM_SIZE_X
= "200"
53 TASK_MAXIMUM_SIZE_Y
= "32"
63 ACTIVE_ICON_ALPHA
= "0"
67 CLOCK_FMT_2
= "%a %d %b"
72 TOOLTIP_PADDING_X
= "0"
73 TOOLTIP_PADDING_Y
= "0"
74 TOOLTIP_SHOW_TIMEOUT
= "0"
75 TOOLTIP_HIDE_TIMEOUT
= "0"
77 BATTERY_ACTION
= 'notify-send "battery low"'
78 BATTERY_PADDING_X
= "0"
79 BATTERY_PADDING_Y
= "0"
81 class TintWizardPrefGUI(gtk
.Window
):
82 """The dialog window which lets the user change the default preferences."""
83 def __init__(self
, tw
):
84 """Create and shows the window."""
87 # Create top-level window
88 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
90 self
.set_title("Preferences")
91 self
.connect("delete_event", self
.quit
)
93 self
.layout
= gtk
.Table(2, 2, False)
95 self
.table
= gtk
.Table(5, 2, False)
96 self
.table
.set_row_spacings(5)
97 self
.table
.set_col_spacings(5)
99 temp
= gtk
.Label("Default Font")
100 temp
.set_alignment(0, 0.5)
101 self
.table
.attach(temp
, 0, 1, 0, 1)
102 self
.font
= gtk
.FontButton(self
.tw
.defaults
["font"])
103 self
.font
.set_alignment(0, 0.5)
104 self
.table
.attach(self
.font
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
106 temp
= gtk
.Label("Default Background Color")
107 temp
.set_alignment(0, 0.5)
108 self
.table
.attach(temp
, 0, 1, 1, 2)
109 self
.bgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["bgColor"]))
110 self
.bgColor
.set_alignment(0, 0.5)
111 self
.table
.attach(self
.bgColor
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
113 temp
= gtk
.Label("Default Foreground Color")
114 temp
.set_alignment(0, 0.5)
115 self
.table
.attach(temp
, 0, 1, 2, 3)
116 self
.fgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["fgColor"]))
117 self
.fgColor
.set_alignment(0, 0.5)
118 self
.table
.attach(self
.fgColor
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
120 temp
= gtk
.Label("Default Border Color")
121 temp
.set_alignment(0, 0.5)
122 self
.table
.attach(temp
, 0, 1, 3, 4)
123 self
.borderColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["borderColor"]))
124 self
.borderColor
.set_alignment(0, 0.5)
125 self
.table
.attach(self
.borderColor
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
127 temp
= gtk
.Label("Number of Background Styles")
128 temp
.set_alignment(0, 0.5)
129 self
.table
.attach(temp
, 0, 1, 4, 5)
130 self
.bgCount
= gtk
.Entry(6)
131 self
.bgCount
.set_width_chars(8)
132 self
.bgCount
.set_text(str(self
.tw
.defaults
["bgCount"]))
133 self
.table
.attach(self
.bgCount
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
135 temp
= gtk
.Label("Default directory")
136 temp
.set_alignment(0, 0.5)
137 self
.table
.attach(temp
, 0, 1, 5, 6)
138 self
.dir = gtk
.Button(self
.tw
.defaults
["dir"])
139 self
.dir.connect("clicked", self
.chooseFolder
)
140 self
.table
.attach(self
.dir, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
142 self
.layout
.attach(self
.table
, 0, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, xpadding
=20, ypadding
=5)
144 temp
= gtk
.Button("Save", gtk
.STOCK_SAVE
)
145 temp
.set_name("save")
146 temp
.connect("clicked", self
.save
)
147 self
.layout
.attach(temp
, 0, 1, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, ypadding
=20)
148 temp
= gtk
.Button("Cancel", gtk
.STOCK_CANCEL
)
149 temp
.set_name("cancel")
150 temp
.connect("clicked", self
.quit
)
151 self
.layout
.attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, ypadding
=20)
153 self
.add(self
.layout
)
157 def chooseFolder(self
, widget
=None, direction
=None):
158 """Called every time the folder button is clicked. Shows a file chooser."""
159 chooser
= gtk
.FileChooserDialog("Choose Default Folder", self
, gtk
.FILE_CHOOSER_ACTION_SELECT_FOLDER
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
160 chooser
.set_default_response(gtk
.RESPONSE_OK
)
162 if self
.tw
.curDir
!= None:
163 chooser
.set_current_folder(self
.tw
.curDir
)
167 response
= chooser
.run()
169 if response
== gtk
.RESPONSE_OK
:
170 self
.dir.set_label(chooser
.get_filename())
177 def quit(self
, widget
=None, event
=None):
178 """Destroys the window."""
181 def save(self
, action
=None):
182 """Called when the Save button is clicked."""
183 if confirmDialog(self
, "Overwrite configuration file?") == gtk
.RESPONSE_YES
:
184 self
.tw
.defaults
["font"] = self
.font
.get_font_name()
185 self
.tw
.defaults
["bgColor"] = rgbToHex(self
.bgColor
.get_color().red
, self
.bgColor
.get_color().green
, self
.bgColor
.get_color().blue
)
186 self
.tw
.defaults
["fgColor"] = rgbToHex(self
.fgColor
.get_color().red
, self
.fgColor
.get_color().green
, self
.fgColor
.get_color().blue
)
187 self
.tw
.defaults
["borderColor"] = rgbToHex(self
.borderColor
.get_color().red
, self
.borderColor
.get_color().green
, self
.borderColor
.get_color().blue
)
190 self
.tw
.defaults
["bgCount"] = int(self
.bgCount
.get_text())
192 errorDialog(self
, "Invalid value for background count")
195 self
.tw
.defaults
["dir"] = self
.dir.get_label()
196 self
.curDir
= self
.tw
.defaults
["dir"]
202 class TintWizardGUI(gtk
.Window
):
203 """The main window for the application."""
205 """Create and show the window."""
210 if len(sys
.argv
) > 1:
211 self
.filename
= sys
.argv
[1]
212 self
.oneConfigFile
= True
214 self
.oneConfigFile
= False
216 # Read conf file and set default values
219 if self
.defaults
["bgColor"] in [None, "None"]:
220 self
.defaults
["bgColor"] = "#000000"
222 if self
.defaults
["fgColor"] in [None, "None"]:
223 self
.defaults
["fgColor"] = "#ffffff"
225 if self
.defaults
["borderColor"] in [None, "None"]:
226 self
.defaults
["borderColor"] = "#ffffff"
228 if self
.defaults
["dir"] in [None, "None"]:
229 if os
.path
.exists(os
.path
.expandvars("${HOME}") + "/.config/tint2"):
230 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
234 self
.curDir
= os
.path
.expandvars(self
.defaults
["dir"])
236 if not os
.path
.exists(os
.path
.expandvars(self
.curDir
)):
237 if os
.path
.exists(os
.path
.expandvars("${HOME}") + "/.config/tint2"):
238 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
243 self
.defaults
["bgCount"] = int(self
.defaults
["bgCount"])
245 self
.defaults
["bgCount"] = 2
247 # Get the full location of the tint2 binary
248 which
= os
.popen('which tint2')
250 self
.tint2Bin
= which
.readline().strip()
254 if len(self
.tint2Bin
) == 0:
255 errorDialog(self
, "tint2 could not be found. Are you sure it is installed?")
258 # Create top-level window
259 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
261 self
.set_title("tintwizard")
263 self
.connect("delete_event", self
.quit
)
265 # self.table is our main layout manager
266 self
.table
= gtk
.Table(4, 1, False)
268 # Create menus and toolbar items
271 <menubar name="MenuBar">
273 <menuitem action="New" />
274 <menuitem action="Open" />
276 <menuitem action="Save" />
277 <menuitem action="Save As..." />
279 <menuitem action="Quit" />
281 <menu action="Tint2">
282 <menuitem action="OpenDefault" />
283 <menuitem action="SaveDefault" />
285 <menuitem action="Apply" />
287 <menu action="Tools">
288 <menuitem action="FontChange" />
290 <menuitem action="Defaults" />
292 <menu action="HelpMenu">
293 <menuitem action="Help" />
294 <menuitem action="Report Bug" />
296 <menuitem action="About" />
299 <toolbar name="ToolBar">
300 <toolitem action="New" />
301 <toolitem action="Open" />
302 <toolitem action="Save" />
304 <toolitem action="Apply" />
310 self
.uiManager
= gtk
.UIManager()
312 accelGroup
= self
.uiManager
.get_accel_group()
313 self
.add_accel_group(accelGroup
)
315 self
.ag
= gtk
.ActionGroup("File")
316 self
.ag
.add_actions([("File", None, "_File"),
317 ("New",gtk
.STOCK_NEW
, "_New", None, "Create a new config", self
.new
),
318 ("Open", gtk
.STOCK_OPEN
, "_Open", None, "Open an existing config", self
.openFile
),
319 ("Save", gtk
.STOCK_SAVE
, "_Save", None, "Save the current config", self
.save
),
320 ("Save As...", gtk
.STOCK_SAVE_AS
, "Save As", None, "Save the current config as...", self
.saveAs
),
321 ("SaveDefault", None, "Save As tint2 Default", None, "Save the current config as the tint2 default", self
.saveAsDef
),
322 ("OpenDefault", None, "Open tint2 Default", None, "Open the current tint2 default config", self
.openDef
),
323 ("Apply", gtk
.STOCK_APPLY
, "Apply Config", None, "Apply the current config to tint2", self
.apply),
324 ("Quit", gtk
.STOCK_QUIT
, "_Quit", None, "Quit the program", self
.quit
),
325 ("Tools", None, "_Tools"),
326 ("Tint2", None, "Tint_2"),
327 ("HelpMenu", None, "_Help"),
328 ("FontChange",gtk
.STOCK_SELECT_FONT
, "Change All Fonts", None, "Change all fonts at once.", self
.changeAllFonts
),
329 ("Defaults",gtk
.STOCK_PREFERENCES
, "Change Defaults", None, "Change tintwizard defaults.", self
.changeDefaults
),
330 ("Help",gtk
.STOCK_HELP
, "_Help", None, "Get help with tintwizard", self
.help),
331 ("Report Bug",None, "Report Bug", None, "Report a problem with tintwizard", self
.reportBug
),
332 ("About",gtk
.STOCK_ABOUT
, "_About Tint Wizard", None, "Find out more about Tint Wizard", self
.about
)])
336 self
.uiManager
.insert_action_group(self
.ag
)
337 self
.uiManager
.add_ui_from_string(ui
)
339 if not self
.oneConfigFile
:
340 # Attach menubar and toolbar to main window
341 self
.table
.attach(self
.uiManager
.get_widget("/MenuBar"), 0, 4, 0, 1)
342 self
.table
.attach(self
.uiManager
.get_widget("/ToolBar"), 0, 4, 1, 2)
345 self
.notebook
= gtk
.Notebook()
346 self
.notebook
.set_tab_pos(gtk
.POS_TOP
)
348 # Create notebook pages
350 self
.tableBgs
= gtk
.Table(rows
=1, columns
=1, homogeneous
=False)
351 self
.tableBgs
.set_row_spacings(5)
352 self
.tableBgs
.set_col_spacings(5)
354 self
.bgNotebook
= gtk
.Notebook()
355 self
.bgNotebook
.set_scrollable(True)
357 self
.tableBgs
.attach(self
.bgNotebook
, 0, 2, 0, 1)
361 # Add buttons for adding/deleting background styles
362 temp
= gtk
.Button("New Background", gtk
.STOCK_NEW
)
363 temp
.set_name("addBg")
364 temp
.connect("clicked", self
.addBgClick
)
365 self
.tableBgs
.attach(temp
, 0, 1, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
366 temp
= gtk
.Button("Delete Background", gtk
.STOCK_DELETE
)
367 temp
.set_name("delBg")
368 temp
.connect("clicked", self
.delBgClick
)
369 self
.tableBgs
.attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
372 self
.tablePanel
= gtk
.Table(rows
=9, columns
=3, homogeneous
=False)
373 self
.tablePanel
.set_row_spacings(5)
374 self
.tablePanel
.set_col_spacings(5)
376 temp
= gtk
.Label("Position")
377 temp
.set_alignment(0, 0.5)
378 self
.tablePanel
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
379 self
.panelPosY
= gtk
.combo_box_new_text()
380 self
.panelPosY
.append_text("bottom")
381 self
.panelPosY
.append_text("top")
382 self
.panelPosY
.append_text("center")
383 self
.panelPosY
.set_active(0)
384 self
.panelPosY
.connect("changed", self
.changeOccurred
)
385 self
.tablePanel
.attach(self
.panelPosY
, 2, 3, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
386 self
.panelPosX
= gtk
.combo_box_new_text()
387 self
.panelPosX
.append_text("left")
388 self
.panelPosX
.append_text("right")
389 self
.panelPosX
.append_text("center")
390 self
.panelPosX
.set_active(0)
391 self
.panelPosX
.connect("changed", self
.changeOccurred
)
392 self
.tablePanel
.attach(self
.panelPosX
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
394 temp
= gtk
.Label("Panel Orientation")
395 temp
.set_alignment(0, 0.5)
396 self
.tablePanel
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
397 self
.panelOrientation
= gtk
.combo_box_new_text()
398 self
.panelOrientation
.append_text("horizontal")
399 self
.panelOrientation
.append_text("vertical")
400 self
.panelOrientation
.set_active(0)
401 self
.panelOrientation
.connect("changed", self
.changeOccurred
)
402 self
.tablePanel
.attach(self
.panelOrientation
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
404 self
.panelSizeLabel
= gtk
.Label("Size (width, height)")
405 self
.panelSizeLabel
.set_alignment(0, 0.5)
406 self
.tablePanel
.attach(self
.panelSizeLabel
, 0, 1, 2, 3, xpadding
=10)
407 self
.panelSizeX
= gtk
.Entry(6)
408 self
.panelSizeX
.set_width_chars(8)
409 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
410 self
.panelSizeX
.connect("changed", self
.changeOccurred
)
411 self
.tablePanel
.attach(self
.panelSizeX
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
412 self
.panelSizeY
= gtk
.Entry(6)
413 self
.panelSizeY
.set_width_chars(8)
414 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
415 self
.panelSizeY
.connect("changed", self
.changeOccurred
)
416 self
.tablePanel
.attach(self
.panelSizeY
, 2, 3, 2, 3, xoptions
=gtk
.EXPAND
)
418 temp
= gtk
.Label("Margin (x, y)")
419 temp
.set_alignment(0, 0.5)
420 self
.tablePanel
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
421 self
.panelMarginX
= gtk
.Entry(6)
422 self
.panelMarginX
.set_width_chars(8)
423 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
424 self
.panelMarginX
.connect("changed", self
.changeOccurred
)
425 self
.tablePanel
.attach(self
.panelMarginX
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
426 self
.panelMarginY
= gtk
.Entry(6)
427 self
.panelMarginY
.set_width_chars(8)
428 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
429 self
.panelMarginY
.connect("changed", self
.changeOccurred
)
430 self
.tablePanel
.attach(self
.panelMarginY
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
)
432 temp
= gtk
.Label("Padding (x, y)")
433 temp
.set_alignment(0, 0.5)
434 self
.tablePanel
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
435 self
.panelPadX
= gtk
.Entry(6)
436 self
.panelPadX
.set_width_chars(8)
437 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
438 self
.panelPadX
.connect("changed", self
.changeOccurred
)
439 self
.tablePanel
.attach(self
.panelPadX
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
440 self
.panelPadY
= gtk
.Entry(6)
441 self
.panelPadY
.set_width_chars(8)
442 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
443 self
.panelPadY
.connect("changed", self
.changeOccurred
)
444 self
.tablePanel
.attach(self
.panelPadY
, 2, 3, 4, 5, xoptions
=gtk
.EXPAND
)
446 temp
= gtk
.Label("Panel Background ID")
447 temp
.set_alignment(0, 0.5)
448 self
.tablePanel
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
449 self
.panelBg
= gtk
.combo_box_new_text()
450 self
.panelBg
.append_text("0 (fully transparent)")
451 for i
in range(len(self
.bgs
)):
452 self
.panelBg
.append_text(str(i
+1))
453 self
.panelBg
.set_active(0)
454 self
.panelBg
.connect("changed", self
.changeOccurred
)
455 self
.tablePanel
.attach(self
.panelBg
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
457 temp
= gtk
.Label("Window Manager Menu")
458 temp
.set_alignment(0, 0.5)
459 self
.tablePanel
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
460 self
.panelMenu
= gtk
.CheckButton()
461 self
.panelMenu
.set_active(False)
462 self
.panelMenu
.connect("toggled", self
.changeOccurred
)
463 self
.tablePanel
.attach(self
.panelMenu
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
465 temp
= gtk
.Label("Place In Window Manager Dock")
466 temp
.set_alignment(0, 0.5)
467 self
.tablePanel
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
468 self
.panelDock
= gtk
.CheckButton()
469 self
.panelDock
.set_active(False)
470 self
.panelDock
.connect("toggled", self
.changeOccurred
)
471 self
.tablePanel
.attach(self
.panelDock
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
)
473 temp
= gtk
.Label("Panel Monitor (all, 1, 2...)")
474 temp
.set_alignment(0, 0.5)
475 self
.tablePanel
.attach(temp
, 0, 1, 8, 9, xpadding
=10)
476 self
.panelMonitor
= gtk
.Entry(6)
477 self
.panelMonitor
.set_width_chars(8)
478 self
.panelMonitor
.set_text(PANEL_MONITOR
)
479 self
.panelMonitor
.connect("changed", self
.changeOccurred
)
480 self
.tablePanel
.attach(self
.panelMonitor
, 1, 2, 8, 9, xoptions
=gtk
.EXPAND
)
483 self
.tableTaskbar
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
484 self
.tableTaskbar
.set_row_spacings(5)
485 self
.tableTaskbar
.set_col_spacings(5)
487 temp
= gtk
.Label("Taskbar Mode")
488 temp
.set_alignment(0, 0.5)
489 self
.tableTaskbar
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
490 self
.taskbarMode
= gtk
.combo_box_new_text()
491 self
.taskbarMode
.append_text("single_desktop")
492 self
.taskbarMode
.append_text("multi_desktop")
493 self
.taskbarMode
.set_active(0)
494 self
.taskbarMode
.connect("changed", self
.changeOccurred
)
495 self
.tableTaskbar
.attach(self
.taskbarMode
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
497 temp
= gtk
.Label("Padding (x, y)")
498 temp
.set_alignment(0, 0.5)
499 self
.tableTaskbar
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
500 self
.taskbarPadX
= gtk
.Entry(6)
501 self
.taskbarPadX
.set_width_chars(8)
502 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
503 self
.taskbarPadX
.connect("changed", self
.changeOccurred
)
504 self
.tableTaskbar
.attach(self
.taskbarPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
505 self
.taskbarPadY
= gtk
.Entry(6)
506 self
.taskbarPadY
.set_width_chars(8)
507 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
508 self
.taskbarPadY
.connect("changed", self
.changeOccurred
)
509 self
.tableTaskbar
.attach(self
.taskbarPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
511 temp
= gtk
.Label("Taskbar Background ID")
512 temp
.set_alignment(0, 0.5)
513 self
.tableTaskbar
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
514 self
.taskbarBg
= gtk
.combo_box_new_text()
515 self
.taskbarBg
.append_text("0 (fully transparent)")
516 for i
in range(len(self
.bgs
)):
517 self
.taskbarBg
.append_text(str(i
+1))
518 self
.taskbarBg
.set_active(0)
519 self
.taskbarBg
.connect("changed", self
.changeOccurred
)
520 self
.tableTaskbar
.attach(self
.taskbarBg
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
522 temp
= gtk
.Label("Active Taskbar Background ID")
523 temp
.set_alignment(0, 0.5)
524 self
.tableTaskbar
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
525 self
.taskbarActiveBg
= gtk
.combo_box_new_text()
526 self
.taskbarActiveBg
.append_text("0 (fully transparent)")
527 for i
in range(len(self
.bgs
)):
528 self
.taskbarActiveBg
.append_text(str(i
+1))
529 self
.taskbarActiveBg
.set_active(0)
530 self
.taskbarActiveBg
.connect("changed", self
.changeOccurred
)
531 self
.tableTaskbar
.attach(self
.taskbarActiveBg
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
532 self
.taskbarActiveBgEnable
= gtk
.CheckButton("Enable")
533 self
.taskbarActiveBgEnable
.set_active(False)
534 self
.taskbarActiveBgEnable
.connect("toggled", self
.changeOccurred
)
535 self
.tableTaskbar
.attach(self
.taskbarActiveBgEnable
, 2, 3, 4, 5, xoptions
=gtk
.EXPAND
)
538 self
.tableTask
= gtk
.Table(rows
=12, columns
=3, homogeneous
=False)
539 self
.tableTask
.set_row_spacings(5)
540 self
.tableTask
.set_col_spacings(5)
542 temp
= gtk
.Label("Number of 'Blinks' on Urgent Event")
543 temp
.set_alignment(0, 0.5)
544 self
.tableTask
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
545 self
.taskBlinks
= gtk
.Entry(6)
546 self
.taskBlinks
.set_width_chars(8)
547 self
.taskBlinks
.set_text(TASK_BLINKS
)
548 self
.taskBlinks
.connect("changed", self
.changeOccurred
)
549 self
.tableTask
.attach(self
.taskBlinks
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
551 temp
= gtk
.Label("Show Text")
552 temp
.set_alignment(0, 0.5)
553 self
.tableTask
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
554 self
.taskTextCheckButton
= gtk
.CheckButton()
555 self
.taskTextCheckButton
.set_active(True)
556 self
.taskTextCheckButton
.connect("toggled", self
.changeOccurred
)
557 self
.tableTask
.attach(self
.taskTextCheckButton
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
559 temp
= gtk
.Label("Centre Text")
560 temp
.set_alignment(0, 0.5)
561 self
.tableTask
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
562 self
.taskCentreCheckButton
= gtk
.CheckButton()
563 self
.taskCentreCheckButton
.set_active(True)
564 self
.taskCentreCheckButton
.connect("toggled", self
.changeOccurred
)
565 self
.tableTask
.attach(self
.taskCentreCheckButton
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
567 temp
= gtk
.Label("Maximum Size (x, y)")
568 temp
.set_alignment(0, 0.5)
569 self
.tableTask
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
570 self
.taskMaxSizeX
= gtk
.Entry(6)
571 self
.taskMaxSizeX
.set_width_chars(8)
572 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
573 self
.taskMaxSizeX
.connect("changed", self
.changeOccurred
)
574 self
.tableTask
.attach(self
.taskMaxSizeX
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
575 self
.taskMaxSizeY
= gtk
.Entry(6)
576 self
.taskMaxSizeY
.set_width_chars(8)
577 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
578 self
.taskMaxSizeY
.connect("changed", self
.changeOccurred
)
579 self
.tableTask
.attach(self
.taskMaxSizeY
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
)
581 temp
= gtk
.Label("Padding (x, y)")
582 temp
.set_alignment(0, 0.5)
583 self
.tableTask
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
584 self
.taskPadX
= gtk
.Entry(6)
585 self
.taskPadX
.set_width_chars(8)
586 self
.taskPadX
.set_text(TASK_PADDING_X
)
587 self
.taskPadX
.connect("changed", self
.changeOccurred
)
588 self
.tableTask
.attach(self
.taskPadX
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
589 self
.taskPadY
= gtk
.Entry(6)
590 self
.taskPadY
.set_width_chars(8)
591 self
.taskPadY
.set_text(TASK_PADDING_Y
)
592 self
.taskPadY
.connect("changed", self
.changeOccurred
)
593 self
.tableTask
.attach(self
.taskPadY
, 2, 3, 4, 5, xoptions
=gtk
.EXPAND
)
595 temp
= gtk
.Label("Horizontal Spacing")
596 temp
.set_alignment(0, 0.5)
597 self
.tableTask
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
598 self
.taskbarSpacing
= gtk
.Entry(6)
599 self
.taskbarSpacing
.set_width_chars(8)
600 self
.taskbarSpacing
.set_text(TASK_SPACING
)
601 self
.taskbarSpacing
.connect("changed", self
.changeOccurred
)
602 self
.tableTask
.attach(self
.taskbarSpacing
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
)
604 temp
= gtk
.Label("Task Background ID")
605 temp
.set_alignment(0, 0.5)
606 self
.tableTask
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
607 self
.taskBg
= gtk
.combo_box_new_text()
608 self
.taskBg
.append_text("0 (fully transparent)")
609 for i
in range(len(self
.bgs
)):
610 self
.taskBg
.append_text(str(i
+1))
611 self
.taskBg
.set_active(0)
612 self
.taskBg
.connect("changed", self
.changeOccurred
)
613 self
.tableTask
.attach(self
.taskBg
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
615 temp
= gtk
.Label("Task Active Background ID")
616 temp
.set_alignment(0, 0.5)
617 self
.tableTask
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
618 self
.taskActiveBg
= gtk
.combo_box_new_text()
619 self
.taskActiveBg
.append_text("0 (fully transparent)")
620 for i
in range(len(self
.bgs
)):
621 self
.taskActiveBg
.append_text(str(i
+1))
622 self
.taskActiveBg
.set_active(0)
623 self
.taskActiveBg
.connect("changed", self
.changeOccurred
)
624 self
.tableTask
.attach(self
.taskActiveBg
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
627 self
.tableIcon
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
628 self
.tableIcon
.set_row_spacings(5)
629 self
.tableIcon
.set_col_spacings(5)
631 temp
= gtk
.Label("Show Icons")
632 temp
.set_alignment(0, 0.5)
633 self
.tableIcon
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
634 self
.taskIconCheckButton
= gtk
.CheckButton()
635 self
.taskIconCheckButton
.set_active(True)
636 self
.taskIconCheckButton
.connect("toggled", self
.changeOccurred
)
637 self
.tableIcon
.attach(self
.taskIconCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
639 temp
= gtk
.Label("Note: Default values of 0 for each of these settings leaves icons unchanged!")
640 temp
.set_alignment(0, 0.5)
641 self
.tableIcon
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
643 temp
= gtk
.Label("Icon Alpha (0 to 100)")
644 temp
.set_alignment(0, 0.5)
645 self
.tableIcon
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
646 self
.iconHue
= gtk
.Entry(6)
647 self
.iconHue
.set_width_chars(8)
648 self
.iconHue
.set_text(ICON_ALPHA
)
649 self
.iconHue
.connect("changed", self
.changeOccurred
)
650 self
.tableIcon
.attach(self
.iconHue
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
652 temp
= gtk
.Label("Icon Saturation (-100 to 100)")
653 temp
.set_alignment(0, 0.5)
654 self
.tableIcon
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
655 self
.iconSat
= gtk
.Entry(6)
656 self
.iconSat
.set_width_chars(8)
657 self
.iconSat
.set_text(ICON_SAT
)
658 self
.iconSat
.connect("changed", self
.changeOccurred
)
659 self
.tableIcon
.attach(self
.iconSat
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
661 temp
= gtk
.Label("Icon Brightness (-100 to 100)")
662 temp
.set_alignment(0, 0.5)
663 self
.tableIcon
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
664 self
.iconBri
= gtk
.Entry(6)
665 self
.iconBri
.set_width_chars(8)
666 self
.iconBri
.set_text(ICON_BRI
)
667 self
.iconBri
.connect("changed", self
.changeOccurred
)
668 self
.tableIcon
.attach(self
.iconBri
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
670 temp
= gtk
.Label("Active Icon Alpha (0 to 100)")
671 temp
.set_alignment(0, 0.5)
672 self
.tableIcon
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
673 self
.activeIconHue
= gtk
.Entry(6)
674 self
.activeIconHue
.set_width_chars(8)
675 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
676 self
.activeIconHue
.connect("changed", self
.changeOccurred
)
677 self
.tableIcon
.attach(self
.activeIconHue
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
)
679 temp
= gtk
.Label("Active Icon Saturation (-100 to 100)")
680 temp
.set_alignment(0, 0.5)
681 self
.tableIcon
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
682 self
.activeIconSat
= gtk
.Entry(6)
683 self
.activeIconSat
.set_width_chars(8)
684 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
685 self
.activeIconSat
.connect("changed", self
.changeOccurred
)
686 self
.tableIcon
.attach(self
.activeIconSat
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
688 temp
= gtk
.Label("Active Icon Brightness (-100 to 100)")
689 temp
.set_alignment(0, 0.5)
690 self
.tableIcon
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
691 self
.activeIconBri
= gtk
.Entry(6)
692 self
.activeIconBri
.set_width_chars(8)
693 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
694 self
.activeIconBri
.connect("changed", self
.changeOccurred
)
695 self
.tableIcon
.attach(self
.activeIconBri
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
)
698 self
.tableFont
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
699 self
.tableFont
.set_row_spacings(5)
700 self
.tableFont
.set_col_spacings(5)
702 temp
= gtk
.Label("Font")
703 temp
.set_alignment(0, 0.5)
704 self
.tableFont
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
705 self
.fontButton
= gtk
.FontButton()
707 if self
.defaults
["font"] in [None, "None"]: # If there was no font specified in the config file
708 self
.defaults
["font"] = self
.fontButton
.get_font_name() # Use the gtk default
710 self
.fontButton
.set_font_name(self
.defaults
["font"])
711 self
.fontButton
.connect("font-set", self
.changeOccurred
)
712 self
.tableFont
.attach(self
.fontButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
714 temp
= gtk
.Label("Font Color")
715 temp
.set_alignment(0, 0.5)
716 self
.tableFont
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
717 self
.fontCol
= gtk
.Entry(7)
718 self
.fontCol
.set_width_chars(9)
719 self
.fontCol
.set_name("fontCol")
720 self
.fontCol
.connect("activate", self
.colorTyped
)
721 self
.tableFont
.attach(self
.fontCol
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
722 self
.fontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
723 self
.fontColButton
.set_use_alpha(True)
724 self
.fontColButton
.set_name("fontCol")
725 self
.fontColButton
.connect("color-set", self
.colorChange
)
726 self
.tableFont
.attach(self
.fontColButton
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
727 self
.fontCol
.set_text(self
.defaults
["fgColor"])
728 # Add this AFTER we set color to avoid "changed" event
729 self
.fontCol
.connect("changed", self
.changeOccurred
)
731 temp
= gtk
.Label("Active Font Color")
732 temp
.set_alignment(0, 0.5)
733 self
.tableFont
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
734 self
.fontActiveCol
= gtk
.Entry(7)
735 self
.fontActiveCol
.set_width_chars(9)
736 self
.fontActiveCol
.set_name("fontActiveCol")
737 self
.fontActiveCol
.connect("activate", self
.colorTyped
)
738 self
.tableFont
.attach(self
.fontActiveCol
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
739 self
.fontActiveColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
740 self
.fontActiveColButton
.set_use_alpha(True)
741 self
.fontActiveColButton
.set_name("fontActiveCol")
742 self
.fontActiveColButton
.connect("color-set", self
.colorChange
)
743 self
.tableFont
.attach(self
.fontActiveColButton
, 2, 3, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
744 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
745 # Add this AFTER we set color to avoid "changed" event
746 self
.fontActiveCol
.connect("changed", self
.changeOccurred
)
748 temp
= gtk
.Label("Font Shadow")
749 temp
.set_alignment(0, 0.5)
750 self
.tableFont
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
751 self
.fontShadowCheckButton
= gtk
.CheckButton()
752 self
.fontShadowCheckButton
.set_active(False)
753 self
.fontShadowCheckButton
.connect("toggled", self
.changeOccurred
)
754 self
.tableFont
.attach(self
.fontShadowCheckButton
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
757 self
.tableTray
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
758 self
.tableTray
.set_row_spacings(5)
759 self
.tableTray
.set_col_spacings(5)
761 temp
= gtk
.Label("Show Systray")
762 temp
.set_alignment(0, 0.5)
763 self
.tableTray
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
764 self
.trayCheckButton
= gtk
.CheckButton()
765 self
.trayCheckButton
.set_active(True)
766 self
.trayCheckButton
.connect("toggled", self
.changeOccurred
)
767 self
.tableTray
.attach(self
.trayCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
769 temp
= gtk
.Label("Padding (x, y)")
770 temp
.set_alignment(0, 0.5)
771 self
.tableTray
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
772 self
.trayPadX
= gtk
.Entry(6)
773 self
.trayPadX
.set_width_chars(8)
774 self
.trayPadX
.set_text(TRAY_PADDING_X
)
775 self
.trayPadX
.connect("changed", self
.changeOccurred
)
776 self
.tableTray
.attach(self
.trayPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
777 self
.trayPadY
= gtk
.Entry(6)
778 self
.trayPadY
.set_width_chars(8)
779 self
.trayPadY
.set_text(TRAY_PADDING_Y
)
780 self
.trayPadY
.connect("changed", self
.changeOccurred
)
781 self
.tableTray
.attach(self
.trayPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
783 temp
= gtk
.Label("Horizontal Spacing")
784 temp
.set_alignment(0, 0.5)
785 self
.tableTray
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
786 self
.traySpacing
= gtk
.Entry(6)
787 self
.traySpacing
.set_width_chars(8)
788 self
.traySpacing
.set_text(TRAY_SPACING
)
789 self
.traySpacing
.connect("changed", self
.changeOccurred
)
790 self
.tableTray
.attach(self
.traySpacing
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
792 temp
= gtk
.Label("Icon Ordering")
793 temp
.set_alignment(0, 0.5)
794 self
.tableTray
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
795 self
.trayOrder
= gtk
.combo_box_new_text()
796 self
.trayOrder
.append_text("ascending")
797 self
.trayOrder
.append_text("descending")
798 self
.trayOrder
.append_text("left2right")
799 self
.trayOrder
.append_text("right2left")
800 self
.trayOrder
.set_active(0)
801 self
.trayOrder
.connect("changed", self
.changeOccurred
)
802 self
.tableTray
.attach(self
.trayOrder
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
804 temp
= gtk
.Label("Systray Background ID")
805 temp
.set_alignment(0, 0.5)
806 self
.tableTray
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
807 self
.trayBg
= gtk
.combo_box_new_text()
808 self
.trayBg
.append_text("0 (fully transparent)")
809 for i
in range(len(self
.bgs
)):
810 self
.trayBg
.append_text(str(i
+1))
811 self
.trayBg
.set_active(0)
812 self
.trayBg
.connect("changed", self
.changeOccurred
)
813 self
.tableTray
.attach(self
.trayBg
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
816 self
.tableClockDisplays
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
817 self
.tableClockDisplays
.set_row_spacings(5)
818 self
.tableClockDisplays
.set_col_spacings(5)
820 temp
= gtk
.Label("Show Clock")
821 temp
.set_alignment(0, 0.5)
822 self
.tableClockDisplays
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
823 self
.clockCheckButton
= gtk
.CheckButton()
824 self
.clockCheckButton
.set_active(True)
825 self
.clockCheckButton
.connect("toggled", self
.changeOccurred
)
826 self
.tableClockDisplays
.attach(self
.clockCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
828 temp
= gtk
.Label("Time 1 Format")
829 temp
.set_alignment(0, 0.5)
830 self
.tableClockDisplays
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
831 self
.clock1Format
= gtk
.Entry(50)
832 self
.clock1Format
.set_width_chars(20)
833 self
.clock1Format
.set_text(CLOCK_FMT_1
)
834 self
.clock1Format
.connect("changed", self
.changeOccurred
)
835 self
.tableClockDisplays
.attach(self
.clock1Format
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
836 self
.clock1CheckButton
= gtk
.CheckButton("Show")
837 self
.clock1CheckButton
.set_active(True)
838 self
.clock1CheckButton
.connect("toggled", self
.changeOccurred
)
839 self
.tableClockDisplays
.attach(self
.clock1CheckButton
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
841 temp
= gtk
.Label("Time 1 Font")
842 temp
.set_alignment(0, 0.5)
843 self
.tableClockDisplays
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
844 self
.clock1FontButton
= gtk
.FontButton()
845 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
846 self
.clock1FontButton
.connect("font-set", self
.changeOccurred
)
847 self
.tableClockDisplays
.attach(self
.clock1FontButton
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
849 temp
= gtk
.Label("Time 2 Format")
850 temp
.set_alignment(0, 0.5)
851 self
.tableClockDisplays
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
852 self
.clock2Format
= gtk
.Entry(50)
853 self
.clock2Format
.set_width_chars(20)
854 self
.clock2Format
.set_text(CLOCK_FMT_2
)
855 self
.clock2Format
.connect("changed", self
.changeOccurred
)
856 self
.tableClockDisplays
.attach(self
.clock2Format
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
857 self
.clock2CheckButton
= gtk
.CheckButton("Show")
858 self
.clock2CheckButton
.set_active(True)
859 self
.clock2CheckButton
.connect("toggled", self
.changeOccurred
)
860 self
.tableClockDisplays
.attach(self
.clock2CheckButton
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
)
862 temp
= gtk
.Label("Time 2 Font")
863 temp
.set_alignment(0, 0.5)
864 self
.tableClockDisplays
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
865 self
.clock2FontButton
= gtk
.FontButton()
866 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
867 self
.clock2FontButton
.connect("font-set", self
.changeOccurred
)
868 self
.tableClockDisplays
.attach(self
.clock2FontButton
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
870 self
.clockArea
= gtk
.ScrolledWindow()
871 self
.clockBuf
= gtk
.TextBuffer()
872 self
.clockTextView
= gtk
.TextView(self
.clockBuf
)
873 self
.clockBuf
.insert_at_cursor("%H 00-23 (24-hour) %I 01-12 (12-hour) %l 1-12 (12-hour) %M 00-59 (minutes)\n%S 00-59 (seconds) %P am/pm %b Jan-Dec %B January-December\n%a Sun-Sat %A Sunday-Saturday %d 01-31 (day) %e 1-31 (day)\n%y 2 digit year, e.g. 09 %Y 4 digit year, e.g. 2009")
874 self
.clockTextView
.set_editable(False)
875 self
.clockArea
.add_with_viewport(self
.clockTextView
)
876 self
.tableClockDisplays
.attach(self
.clockArea
, 0, 3, 5, 6, xpadding
=10)
878 self
.tableClockSettings
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
879 self
.tableClockSettings
.set_row_spacings(5)
880 self
.tableClockSettings
.set_col_spacings(5)
882 temp
= gtk
.Label("Clock Font Color")
883 temp
.set_alignment(0, 0.5)
884 self
.tableClockSettings
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
885 self
.clockFontCol
= gtk
.Entry(7)
886 self
.clockFontCol
.set_width_chars(9)
887 self
.clockFontCol
.set_name("clockFontCol")
888 self
.clockFontCol
.connect("activate", self
.colorTyped
)
889 self
.tableClockSettings
.attach(self
.clockFontCol
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
890 self
.clockFontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
891 self
.clockFontColButton
.set_use_alpha(True)
892 self
.clockFontColButton
.set_name("clockFontCol")
893 self
.clockFontColButton
.connect("color-set", self
.colorChange
)
894 self
.tableClockSettings
.attach(self
.clockFontColButton
, 2, 3, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
895 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
896 # Add this AFTER we set color to avoid "changed" event
897 self
.clockFontCol
.connect("changed", self
.changeOccurred
)
899 temp
= gtk
.Label("Padding (x, y)")
900 temp
.set_alignment(0, 0.5)
901 self
.tableClockSettings
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
902 self
.clockPadX
= gtk
.Entry(6)
903 self
.clockPadX
.set_width_chars(8)
904 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
905 self
.clockPadX
.connect("changed", self
.changeOccurred
)
906 self
.tableClockSettings
.attach(self
.clockPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
907 self
.clockPadY
= gtk
.Entry(6)
908 self
.clockPadY
.set_width_chars(8)
909 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
910 self
.clockPadY
.connect("changed", self
.changeOccurred
)
911 self
.tableClockSettings
.attach(self
.clockPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
913 temp
= gtk
.Label("Clock Background ID")
914 temp
.set_alignment(0, 0.5)
915 self
.tableClockSettings
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
916 self
.clockBg
= gtk
.combo_box_new_text()
917 self
.clockBg
.append_text("0 (fully transparent)")
918 for i
in range(len(self
.bgs
)):
919 self
.clockBg
.append_text(str(i
+1))
920 self
.clockBg
.set_active(0)
921 self
.clockBg
.connect("changed", self
.changeOccurred
)
922 self
.tableClockSettings
.attach(self
.clockBg
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
924 temp
= gtk
.Label("Left Click Command")
925 temp
.set_alignment(0, 0.5)
926 self
.tableClockSettings
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
927 self
.clockLClick
= gtk
.Entry(50)
928 self
.clockLClick
.set_width_chars(20)
929 self
.clockLClick
.set_text(CLOCK_LCLICK
)
930 self
.clockLClick
.connect("changed", self
.changeOccurred
)
931 self
.tableClockSettings
.attach(self
.clockLClick
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
933 temp
= gtk
.Label("Right Click Command")
934 temp
.set_alignment(0, 0.5)
935 self
.tableClockSettings
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
936 self
.clockRClick
= gtk
.Entry(50)
937 self
.clockRClick
.set_width_chars(20)
938 self
.clockRClick
.set_text(CLOCK_RCLICK
)
939 self
.clockRClick
.connect("changed", self
.changeOccurred
)
940 self
.tableClockSettings
.attach(self
.clockRClick
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
943 self
.tableTooltip
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
944 self
.tableTooltip
.set_row_spacings(5)
945 self
.tableTooltip
.set_col_spacings(5)
947 temp
= gtk
.Label("Show Tooltips")
948 temp
.set_alignment(0, 0.5)
949 self
.tableTooltip
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
950 self
.tooltipShow
= gtk
.CheckButton()
951 self
.tooltipShow
.set_active(False)
952 self
.tooltipShow
.connect("toggled", self
.changeOccurred
)
953 self
.tableTooltip
.attach(self
.tooltipShow
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
955 temp
= gtk
.Label("Padding (x, y)")
956 temp
.set_alignment(0, 0.5)
957 self
.tableTooltip
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
958 self
.tooltipPadX
= gtk
.Entry(6)
959 self
.tooltipPadX
.set_width_chars(8)
960 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
961 self
.tooltipPadX
.connect("changed", self
.changeOccurred
)
962 self
.tableTooltip
.attach(self
.tooltipPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
963 self
.tooltipPadY
= gtk
.Entry(6)
964 self
.tooltipPadY
.set_width_chars(8)
965 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
966 self
.tooltipPadY
.connect("changed", self
.changeOccurred
)
967 self
.tableTooltip
.attach(self
.tooltipPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
969 temp
= gtk
.Label("Tooltip Show Timeout (seconds)")
970 temp
.set_alignment(0, 0.5)
971 self
.tableTooltip
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
972 self
.tooltipShowTime
= gtk
.Entry(6)
973 self
.tooltipShowTime
.set_width_chars(8)
974 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
975 self
.tooltipShowTime
.connect("changed", self
.changeOccurred
)
976 self
.tableTooltip
.attach(self
.tooltipShowTime
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
978 temp
= gtk
.Label("Tooltip Hide Timeout (seconds)")
979 temp
.set_alignment(0, 0.5)
980 self
.tableTooltip
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
981 self
.tooltipHideTime
= gtk
.Entry(6)
982 self
.tooltipHideTime
.set_width_chars(8)
983 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
984 self
.tooltipHideTime
.connect("changed", self
.changeOccurred
)
985 self
.tableTooltip
.attach(self
.tooltipHideTime
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
987 temp
= gtk
.Label("Tooltip Background ID")
988 temp
.set_alignment(0, 0.5)
989 self
.tableTooltip
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
990 self
.tooltipBg
= gtk
.combo_box_new_text()
991 self
.tooltipBg
.append_text("0 (fully transparent)")
992 for i
in range(len(self
.bgs
)):
993 self
.tooltipBg
.append_text(str(i
+1))
994 self
.tooltipBg
.set_active(0)
995 self
.tooltipBg
.connect("changed", self
.changeOccurred
)
996 self
.tableTooltip
.attach(self
.tooltipBg
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
998 temp
= gtk
.Label("Tooltip Font")
999 temp
.set_alignment(0, 0.5)
1000 self
.tableTooltip
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
1001 self
.tooltipFont
= gtk
.FontButton()
1002 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1003 self
.tooltipFont
.connect("font-set", self
.changeOccurred
)
1004 self
.tableTooltip
.attach(self
.tooltipFont
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1006 temp
= gtk
.Label("Tooltip Font Color")
1007 temp
.set_alignment(0, 0.5)
1008 self
.tableTooltip
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
1009 self
.tooltipFontCol
= gtk
.Entry(7)
1010 self
.tooltipFontCol
.set_width_chars(9)
1011 self
.tooltipFontCol
.set_name("tooltipFontCol")
1012 self
.tooltipFontCol
.connect("activate", self
.colorTyped
)
1013 self
.tableTooltip
.attach(self
.tooltipFontCol
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
1014 self
.tooltipFontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1015 self
.tooltipFontColButton
.set_use_alpha(True)
1016 self
.tooltipFontColButton
.set_name("tooltipFontCol")
1017 self
.tooltipFontColButton
.connect("color-set", self
.colorChange
)
1018 self
.tableTooltip
.attach(self
.tooltipFontColButton
, 2, 3, 6, 7, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1019 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1020 # Add this AFTER we set color to avoid "changed" event
1021 self
.clockFontCol
.connect("changed", self
.changeOccurred
)
1024 self
.tableMouse
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
1025 self
.tableMouse
.set_row_spacings(5)
1026 self
.tableMouse
.set_col_spacings(5)
1028 temp
= gtk
.Label("Middle Mouse Click Action")
1029 temp
.set_alignment(0, 0.5)
1030 self
.tableMouse
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
1031 self
.mouseMiddle
= gtk
.combo_box_new_text()
1032 self
.mouseMiddle
.append_text("none")
1033 self
.mouseMiddle
.append_text("close")
1034 self
.mouseMiddle
.append_text("toggle")
1035 self
.mouseMiddle
.append_text("iconify")
1036 self
.mouseMiddle
.append_text("shade")
1037 self
.mouseMiddle
.append_text("toggle_iconify")
1038 self
.mouseMiddle
.append_text("maximize_restore")
1039 self
.mouseMiddle
.append_text("desktop_left")
1040 self
.mouseMiddle
.append_text("desktop_right")
1041 self
.mouseMiddle
.set_active(0)
1042 self
.mouseMiddle
.connect("changed", self
.changeOccurred
)
1043 self
.tableMouse
.attach(self
.mouseMiddle
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1045 temp
= gtk
.Label("Right Mouse Click Action")
1046 temp
.set_alignment(0, 0.5)
1047 self
.tableMouse
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
1048 self
.mouseRight
= gtk
.combo_box_new_text()
1049 self
.mouseRight
.append_text("none")
1050 self
.mouseRight
.append_text("close")
1051 self
.mouseRight
.append_text("toggle")
1052 self
.mouseRight
.append_text("iconify")
1053 self
.mouseRight
.append_text("shade")
1054 self
.mouseRight
.append_text("toggle_iconify")
1055 self
.mouseRight
.append_text("maximize_restore")
1056 self
.mouseRight
.append_text("desktop_left")
1057 self
.mouseRight
.append_text("desktop_right")
1058 self
.mouseRight
.set_active(0)
1059 self
.mouseRight
.connect("changed", self
.changeOccurred
)
1060 self
.tableMouse
.attach(self
.mouseRight
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1062 temp
= gtk
.Label("Mouse Wheel Scroll Up Action")
1063 temp
.set_alignment(0, 0.5)
1064 self
.tableMouse
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
1065 self
.mouseUp
= gtk
.combo_box_new_text()
1066 self
.mouseUp
.append_text("none")
1067 self
.mouseUp
.append_text("close")
1068 self
.mouseUp
.append_text("toggle")
1069 self
.mouseUp
.append_text("iconify")
1070 self
.mouseUp
.append_text("shade")
1071 self
.mouseUp
.append_text("toggle_iconify")
1072 self
.mouseUp
.append_text("maximize_restore")
1073 self
.mouseUp
.append_text("desktop_left")
1074 self
.mouseUp
.append_text("desktop_right")
1075 self
.mouseUp
.set_active(0)
1076 self
.mouseUp
.connect("changed", self
.changeOccurred
)
1077 self
.tableMouse
.attach(self
.mouseUp
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1079 temp
= gtk
.Label("Mouse Wheel Scroll Down Action")
1080 temp
.set_alignment(0, 0.5)
1081 self
.tableMouse
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
1082 self
.mouseDown
= gtk
.combo_box_new_text()
1083 self
.mouseDown
.append_text("none")
1084 self
.mouseDown
.append_text("close")
1085 self
.mouseDown
.append_text("toggle")
1086 self
.mouseDown
.append_text("iconify")
1087 self
.mouseDown
.append_text("shade")
1088 self
.mouseDown
.append_text("toggle_iconify")
1089 self
.mouseDown
.append_text("maximize_restore")
1090 self
.mouseDown
.append_text("desktop_left")
1091 self
.mouseDown
.append_text("desktop_right")
1092 self
.mouseDown
.set_active(0)
1093 self
.mouseDown
.connect("changed", self
.changeOccurred
)
1094 self
.tableMouse
.attach(self
.mouseDown
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1097 self
.tableBattery
= gtk
.Table(rows
=8, columns
=3, homogeneous
=False)
1098 self
.tableBattery
.set_row_spacings(5)
1099 self
.tableBattery
.set_col_spacings(5)
1101 temp
= gtk
.Label("Show Battery Applet")
1102 temp
.set_alignment(0, 0.5)
1103 self
.tableBattery
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
1104 self
.batteryCheckButton
= gtk
.CheckButton()
1105 self
.batteryCheckButton
.set_active(False)
1106 self
.batteryCheckButton
.connect("toggled", self
.changeOccurred
)
1107 self
.tableBattery
.attach(self
.batteryCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
1109 temp
= gtk
.Label("Battery Low Status (%)")
1110 temp
.set_alignment(0, 0.5)
1111 self
.tableBattery
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
1112 self
.batteryLow
= gtk
.Entry(6)
1113 self
.batteryLow
.set_width_chars(8)
1114 self
.batteryLow
.set_text(BATTERY_LOW
)
1115 self
.batteryLow
.connect("changed", self
.changeOccurred
)
1116 self
.tableBattery
.attach(self
.batteryLow
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1118 temp
= gtk
.Label("Battery Low Action")
1119 temp
.set_alignment(0, 0.5)
1120 self
.tableBattery
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
1121 self
.batteryLowAction
= gtk
.Entry(150)
1122 self
.batteryLowAction
.set_width_chars(32)
1123 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1124 self
.batteryLowAction
.connect("changed", self
.changeOccurred
)
1125 self
.tableBattery
.attach(self
.batteryLowAction
, 1, 3, 2, 3, xoptions
=gtk
.EXPAND
)
1127 temp
= gtk
.Label("Battery 1 Font")
1128 temp
.set_alignment(0, 0.5)
1129 self
.tableBattery
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
1130 self
.bat1FontButton
= gtk
.FontButton()
1131 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1132 self
.bat1FontButton
.connect("font-set", self
.changeOccurred
)
1133 self
.tableBattery
.attach(self
.bat1FontButton
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1135 temp
= gtk
.Label("Battery 2 Font")
1136 temp
.set_alignment(0, 0.5)
1137 self
.tableBattery
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
1138 self
.bat2FontButton
= gtk
.FontButton()
1139 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1140 self
.bat2FontButton
.connect("font-set", self
.changeOccurred
)
1141 self
.tableBattery
.attach(self
.bat2FontButton
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1143 temp
= gtk
.Label("Battery Font Color")
1144 temp
.set_alignment(0, 0.5)
1145 self
.tableBattery
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
1146 self
.batteryFontCol
= gtk
.Entry(7)
1147 self
.batteryFontCol
.set_width_chars(9)
1148 self
.batteryFontCol
.set_name("batteryFontCol")
1149 self
.batteryFontCol
.connect("activate", self
.colorTyped
)
1150 self
.tableBattery
.attach(self
.batteryFontCol
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
)
1151 self
.batteryFontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1152 self
.batteryFontColButton
.set_use_alpha(True)
1153 self
.batteryFontColButton
.set_name("batteryFontCol")
1154 self
.batteryFontColButton
.connect("color-set", self
.colorChange
)
1155 self
.tableBattery
.attach(self
.batteryFontColButton
, 2, 3, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1156 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1157 # Add this AFTER we set color to avoid "changed" event
1158 self
.batteryFontCol
.connect("changed", self
.changeOccurred
)
1160 temp
= gtk
.Label("Padding (x, y)")
1161 temp
.set_alignment(0, 0.5)
1162 self
.tableBattery
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
1163 self
.batteryPadX
= gtk
.Entry(6)
1164 self
.batteryPadX
.set_width_chars(8)
1165 self
.batteryPadX
.set_text(BATTERY_PADDING_X
)
1166 self
.batteryPadX
.connect("changed", self
.changeOccurred
)
1167 self
.tableBattery
.attach(self
.batteryPadX
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
1168 self
.batteryPadY
= gtk
.Entry(6)
1169 self
.batteryPadY
.set_width_chars(8)
1170 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1171 self
.batteryPadY
.connect("changed", self
.changeOccurred
)
1172 self
.tableBattery
.attach(self
.batteryPadY
, 2, 3, 6, 7, xoptions
=gtk
.EXPAND
)
1174 temp
= gtk
.Label("Battery Background ID")
1175 temp
.set_alignment(0, 0.5)
1176 self
.tableBattery
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
1177 self
.batteryBg
= gtk
.combo_box_new_text()
1178 self
.batteryBg
.append_text("0 (fully transparent)")
1179 for i
in range(len(self
.bgs
)):
1180 self
.batteryBg
.append_text(str(i
+1))
1181 self
.batteryBg
.set_active(0)
1182 self
.batteryBg
.connect("changed", self
.changeOccurred
)
1183 self
.tableBattery
.attach(self
.batteryBg
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1186 self
.configArea
= gtk
.ScrolledWindow()
1187 self
.configBuf
= gtk
.TextBuffer()
1188 self
.configTextView
= gtk
.TextView(self
.configBuf
)
1189 self
.configArea
.add_with_viewport(self
.configTextView
)
1191 # Add backgrounds to notebooks
1192 for i
in range(self
.defaults
["bgCount"]):
1193 self
.addBgClick(None, init
=True)
1195 self
.bgNotebook
.set_current_page(0)
1197 # Create sub-notebooks
1198 self
.taskNotebook
= gtk
.Notebook()
1199 self
.taskNotebook
.set_tab_pos(gtk
.POS_TOP
)
1200 self
.taskNotebook
.set_current_page(0)
1202 self
.taskNotebook
.append_page(self
.tableTask
, gtk
.Label("Task Settings"))
1203 self
.taskNotebook
.append_page(self
.tableIcon
, gtk
.Label("Task Icons"))
1204 self
.taskNotebook
.append_page(self
.tableFont
, gtk
.Label("Task Fonts"))
1206 self
.clockNotebook
= gtk
.Notebook()
1207 self
.clockNotebook
.set_tab_pos(gtk
.POS_TOP
)
1208 self
.clockNotebook
.set_current_page(0)
1210 self
.clockNotebook
.append_page(self
.tableClockDisplays
, gtk
.Label("Clock Display"))
1211 self
.clockNotebook
.append_page(self
.tableClockSettings
, gtk
.Label("Clock Settings"))
1213 # Add pages to notebook
1214 self
.notebook
.append_page(self
.tableBgs
, gtk
.Label("Backgrounds"))
1215 self
.notebook
.append_page(self
.tablePanel
, gtk
.Label("Panel"))
1216 self
.notebook
.append_page(self
.tableTaskbar
, gtk
.Label("Taskbar"))
1217 self
.notebook
.append_page(self
.taskNotebook
, gtk
.Label("Tasks"))
1218 self
.notebook
.append_page(self
.tableTray
, gtk
.Label("Systray"))
1219 self
.notebook
.append_page(self
.clockNotebook
, gtk
.Label("Clock"))
1220 self
.notebook
.append_page(self
.tableMouse
, gtk
.Label("Mouse"))
1221 self
.notebook
.append_page(self
.tableTooltip
, gtk
.Label("Tooltips"))
1222 self
.notebook
.append_page(self
.tableBattery
, gtk
.Label("Battery"))
1223 self
.notebook
.append_page(self
.configArea
, gtk
.Label("View Config"))
1225 self
.notebook
.connect("switch-page", self
.switchPage
)
1227 # Add notebook to window and show
1228 self
.table
.attach(self
.notebook
, 0, 4, 2, 3, xpadding
=5, ypadding
=5)
1230 # Create and add the status bar to the bottom of the main window
1231 self
.statusBar
= gtk
.Statusbar()
1232 self
.statusBar
.set_has_resize_grip(True)
1233 self
.updateStatusBar("New Config File [*]")
1234 self
.table
.attach(self
.statusBar
, 0, 4, 3, 4)
1236 self
.add(self
.table
)
1240 # Create our property dictionary. This holds the widgets which correspond to each property
1242 "panel_monitor": self
.panelMonitor
,
1243 "panel_position": (self
.panelPosY
, self
.panelPosX
, self
.panelOrientation
),
1244 "panel_size": (self
.panelSizeX
, self
.panelSizeY
),
1245 "panel_margin": (self
.panelMarginX
, self
.panelMarginY
),
1246 "panel_padding": (self
.panelPadX
, self
.panelPadY
),
1247 "wm_menu": self
.panelMenu
,
1248 "panel_dock": self
.panelDock
,
1249 "panel_background_id": self
.panelBg
,
1250 "taskbar_mode": self
.taskbarMode
,
1251 "taskbar_padding": (self
.taskbarPadX
, self
.taskbarPadY
, self
.taskbarSpacing
),
1252 "taskbar_background_id": self
.taskbarBg
,
1253 "taskbar_active_background_id": self
.taskbarActiveBg
,
1254 "task_icon": self
.taskIconCheckButton
,
1255 "task_text": self
.taskTextCheckButton
,
1256 "task_centered": self
.taskCentreCheckButton
,
1257 "task_maximum_size": (self
.taskMaxSizeX
, self
.taskMaxSizeY
),
1258 "task_padding": (self
.taskPadX
, self
.taskPadY
),
1259 "task_background_id": self
.taskBg
,
1260 "task_active_background_id": self
.taskActiveBg
,
1261 "task_font": self
.fontButton
,
1262 "task_font_color": (self
.fontCol
, self
.fontColButton
),
1263 "task_active_font_color": (self
.fontActiveCol
, self
.fontActiveColButton
),
1264 "task_icon_asb": (self
.iconHue
, self
.iconSat
, self
.iconBri
),
1265 "task_active_icon_asb": (self
.activeIconHue
, self
.activeIconSat
, self
.activeIconBri
),
1266 "font_shadow": self
.fontShadowCheckButton
,
1267 "systray_padding": (self
.trayPadX
, self
.trayPadY
, self
.traySpacing
),
1268 "systray_background_id": self
.trayBg
,
1269 "systray_sort": self
.trayOrder
,
1270 "time1_format": self
.clock1Format
,
1271 "time2_format": self
.clock2Format
,
1272 "time1_font": self
.clock1FontButton
,
1273 "time2_font": self
.clock2FontButton
,
1274 "clock_font_color": (self
.clockFontCol
, self
.clockFontColButton
),
1275 "clock_padding": (self
.clockPadX
, self
.clockPadY
),
1276 "clock_background_id": self
.clockBg
,
1277 "clock_lclick_command": self
.clockLClick
,
1278 "clock_rclick_command": self
.clockRClick
,
1279 "mouse_middle": self
.mouseMiddle
,
1280 "mouse_right": self
.mouseRight
,
1281 "mouse_scroll_up": self
.mouseUp
,
1282 "mouse_scroll_down": self
.mouseDown
,
1283 "tooltip": self
.tooltipShow
,
1284 "tooltip_padding": (self
.tooltipPadX
, self
.tooltipPadY
),
1285 "tooltip_show_timeout": self
.tooltipShowTime
,
1286 "tooltip_hide_timeout": self
.tooltipHideTime
,
1287 "tooltip_background_id": self
.tooltipBg
,
1288 "tooltip_font": self
.tooltipFont
,
1289 "tooltip_font_color": (self
.tooltipFontCol
, self
.tooltipFontColButton
),
1290 "battery": self
.batteryCheckButton
,
1291 "battery_low_status": self
.batteryLow
,
1292 "battery_low_cmd": self
.batteryLowAction
,
1293 "bat1_font": self
.bat1FontButton
,
1294 "bat2_font": self
.bat2FontButton
,
1295 "battery_font_color": (self
.batteryFontCol
, self
.batteryFontColButton
),
1296 "battery_padding": (self
.batteryPadX
, self
.batteryPadY
),
1297 "battery_background_id": self
.batteryBg
1300 if self
.oneConfigFile
:
1301 self
.readTint2Config()
1303 self
.generateConfig()
1305 def about(self
, action
=None):
1306 """Displays the About dialog."""
1307 about
= gtk
.AboutDialog()
1308 about
.set_program_name(NAME
)
1309 about
.set_version(VERSION
)
1310 about
.set_authors(AUTHORS
)
1311 about
.set_comments(COMMENTS
)
1312 about
.set_website(WEBSITE
)
1313 gtk
.about_dialog_set_url_hook(self
.aboutLinkCallback
)
1317 def aboutLinkCallback(dialog
, link
, data
=None):
1318 """Callback for when a URL is clicked in an About dialog."""
1320 webbrowser
.open(link
)
1322 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit %s" % link
)
1325 """Adds a new background to the list of backgrounds."""
1326 self
.bgs
+= [gtk
.Table(4, 3, False)]
1328 temp
= gtk
.Label("Corner Rounding (px)")
1329 temp
.set_alignment(0, 0.5)
1330 self
.bgs
[-1].attach(temp
, 0, 1, 0, 1, xpadding
=10)
1332 temp
.set_width_chars(9)
1333 temp
.set_name("rounded")
1334 temp
.set_text(BG_ROUNDING
)
1335 temp
.connect("changed", self
.changeOccurred
)
1336 self
.bgs
[-1].attach(temp
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
1338 temp
= gtk
.Label("Background Color")
1339 temp
.set_alignment(0, 0.5)
1340 self
.bgs
[-1].attach(temp
, 0, 1, 1, 2, xpadding
=10)
1342 temp
.set_width_chars(9)
1343 temp
.set_name("bgColEntry")
1344 temp
.set_text(self
.defaults
["bgColor"])
1345 temp
.connect("changed", self
.changeOccurred
)
1346 temp
.connect("activate", self
.colorTyped
)
1347 self
.bgs
[-1].attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1348 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["bgColor"]))
1349 temp
.set_use_alpha(True)
1350 temp
.set_name("bgCol")
1351 temp
.connect("color-set", self
.colorChange
)
1352 self
.bgs
[-1].attach(temp
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1354 temp
= gtk
.Label("Border Width (px)")
1355 temp
.set_alignment(0, 0.5)
1356 self
.bgs
[-1].attach(temp
, 0, 1, 2, 3, xpadding
=10)
1358 temp
.set_width_chars(9)
1359 temp
.set_name("border")
1360 temp
.set_text(BG_BORDER
)
1361 temp
.connect("changed", self
.changeOccurred
)
1362 self
.bgs
[-1].attach(temp
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
1364 temp
= gtk
.Label("Border Color")
1365 temp
.set_alignment(0, 0.5)
1366 self
.bgs
[-1].attach(temp
, 0, 1, 3, 4, xpadding
=10)
1368 temp
.set_width_chars(9)
1369 temp
.set_name("borderColEntry")
1370 temp
.connect("activate", self
.colorTyped
)
1371 temp
.set_text(self
.defaults
["borderColor"])
1372 temp
.connect("changed", self
.changeOccurred
)
1373 self
.bgs
[-1].attach(temp
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
1374 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["borderColor"]))
1375 temp
.set_use_alpha(True)
1376 temp
.set_name("borderCol")
1377 temp
.connect("color-set", self
.colorChange
)
1378 self
.bgs
[-1].attach(temp
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1380 # Note: Only set init to True when initialising background styles.
1381 # This prevents unwanted calls to changeOccurred()
1382 def addBgClick(self
, widget
=None, init
=False):
1383 """Creates a new background and adds a new tab to the notebook."""
1384 n
= self
.bgNotebook
.get_n_pages()
1386 if n
> (self
.defaults
["bgCount"] + 2):
1387 if confirmDialog(self
, "You already have %d background styles. Are you sure you would like another?" % n
) == gtk
.RESPONSE_NO
:
1392 newId
= len(self
.bgs
)
1394 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1396 self
.bgNotebook
.show_all()
1398 self
.updateComboBoxes(n
, "add")
1400 self
.bgNotebook
.set_current_page(n
)
1403 self
.changeOccurred()
1405 def apply(self
, widget
, event
=None, confirmChange
=True):
1406 """Applies the current config to tint2."""
1407 if confirmDialog(self
, "This will terminate all currently running instances of tint2 before applying config. Continue?") == gtk
.RESPONSE_YES
:
1411 #shutil.copyfile(self.filename, self.filename+".backup") # Create backup
1413 # Check if tint2 is running
1414 procs
= os
.popen('pidof "tint2"') # Check list of active processes for tint2
1415 pids
= [] # List of process ids for tint2
1417 for proc
in procs
.readlines():
1418 pids
+= [int(proc
.strip().split(" ")[0])]
1422 # If it is - kill it
1424 os
.kill(pid
, signal
.SIGTERM
)
1427 os
.spawnv(os
.P_NOWAIT
, self
.tint2Bin
, [self
.tint2Bin
, "-c" + self
.filename
])
1429 if confirmChange
and self
.filename
!= (os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc") and confirmDialog(self
, "Use this as default tint2 config?") == gtk
.RESPONSE_YES
:
1431 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1433 shutil
.copyfile(tmp
, self
.filename
)
1434 except shutil
.Error
:
1437 #if confirmChange and confirmDialog(self, "Keep this config?") == gtk.RESPONSE_NO:
1438 # shutil.copyfile(self.filename+".backup", self.filename) # Create backup
1439 # self.apply(widget, event, False)
1441 def changeAllFonts(self
, widget
):
1442 """Changes all fonts at once."""
1443 dialog
= gtk
.FontSelectionDialog("Select Font")
1445 dialog
.set_font_name(self
.defaults
["font"])
1447 if dialog
.run() == gtk
.RESPONSE_OK
:
1448 newFont
= dialog
.get_font_name()
1450 self
.clock1FontButton
.set_font_name(newFont
)
1451 self
.clock2FontButton
.set_font_name(newFont
)
1452 self
.bat1FontButton
.set_font_name(newFont
)
1453 self
.bat2FontButton
.set_font_name(newFont
)
1454 self
.fontButton
.set_font_name(newFont
)
1458 self
.generateConfig()
1459 self
.changeOccurred()
1461 def changeDefaults(self
, widget
=None):
1462 """Shows the style preferences widget."""
1463 TintWizardPrefGUI(self
)
1465 def changeOccurred(self
, widget
=None):
1466 """Called when the user changes something, i.e. entry value"""
1469 self
.updateStatusBar(change
=True)
1471 if widget
== self
.panelOrientation
:
1472 if self
.panelOrientation
.get_active_text() == "horizontal":
1473 self
.panelSizeLabel
.set_text("Size (width, height)")
1475 self
.panelSizeLabel
.set_text("Size (height, width)")
1477 def colorChange(self
, widget
):
1478 """Update the text entry when a color button is updated."""
1479 r
= widget
.get_color().red
1480 g
= widget
.get_color().green
1481 b
= widget
.get_color().blue
1483 label
= self
.getColorLabel(widget
)
1489 label
.set_text(rgbToHex(r
, g
, b
))
1491 self
.changeOccurred()
1493 def colorTyped(self
, widget
):
1494 """Update the color button when a valid value is typed into the entry."""
1495 s
= widget
.get_text()
1497 # The color button associated with this widget.
1498 colorButton
= self
.getColorButton(widget
)
1500 # Just a precautionary check - this situation should never arise.
1502 #print "Error in colorTyped() -- unrecognised entry widget."
1505 # If the entered value is invalid, set textbox to the current
1506 # hex value of the associated color button.
1507 buttonHex
= self
.getHexFromWidget(colorButton
)
1510 errorDialog(self
, "Invalid color specification!")
1511 #self.colorChange(widget) TODO - remove this when issue 29 is verified
1512 widget
.set_text(buttonHex
)
1515 if not self
.oneConfigFile
:
1517 col
= gtk
.gdk
.Color(s
)
1519 errorDialog(self
, "Invalid color specification!")
1520 #self.colorChange(widget) TODO - remove this when issue 29 is verified
1521 widget
.set_text(buttonHex
)
1524 colorButton
.set_color(col
)
1526 # Note: only set init to True when removing backgrounds for a new config
1527 # This prevents unwanted calls to changeOccurred()
1528 def delBgClick(self
, widget
=None, prompt
=True, init
=False):
1529 """Deletes the selected background after confirming with the user."""
1530 selected
= self
.bgNotebook
.get_current_page()
1532 if selected
== -1: # Nothing to remove
1536 if confirmDialog(self
, "Remove this background?") != gtk
.RESPONSE_YES
:
1539 self
.bgNotebook
.remove_page(selected
)
1540 self
.bgs
.pop(selected
)
1542 for i
in range(self
.bgNotebook
.get_n_pages()):
1543 self
.bgNotebook
.set_tab_label_text(self
.bgNotebook
.get_nth_page(i
), "Background ID %d" % (i
+1))
1545 self
.bgNotebook
.show_all()
1547 self
.updateComboBoxes(len(self
.bgs
) + 1, "remove")
1550 self
.changeOccurred()
1552 def generateConfig(self
):
1553 """Reads values from each widget and generates a config."""
1554 self
.configBuf
.delete(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter())
1555 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Tint2 config file\n")
1556 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Generated by tintwizard (http://code.google.com/p/tintwizard/)\n")
1557 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure\n")
1558 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# To use this as default tint2 config: save as $HOME/.config/tint2/tint2rc\n\n")
1560 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Background definitions\n")
1561 for i
in range(len(self
.bgs
)):
1562 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# ID %d\n" % (i
+ 1))
1564 for child
in self
.bgs
[i
].get_children():
1565 if child
.get_name() == "rounded":
1566 rounded
= child
.get_text() if child
.get_text() else BG_ROUNDING
1567 elif child
.get_name() == "border":
1568 borderW
= child
.get_text() if child
.get_text() else BG_BORDER
1569 elif child
.get_name() == "bgCol":
1570 bgCol
= self
.getHexFromWidget(child
)
1571 bgAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1572 elif child
.get_name() == "borderCol":
1573 borderCol
= self
.getHexFromWidget(child
)
1574 borderAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1576 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "rounded = %s\n" % (rounded
))
1577 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_width = %s\n" % (borderW
))
1578 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "background_color = %s %d\n" % (bgCol
, bgAlpha
))
1579 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_color = %s %d\n\n" % (borderCol
, borderAlpha
))
1581 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Panel\n")
1582 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_monitor = %s\n" % (self
.panelMonitor
.get_text() if self
.panelMonitor
.get_text() else PANEL_MONITOR
))
1583 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_position = %s %s %s\n" % (self
.panelPosY
.get_active_text(), self
.panelPosX
.get_active_text(), self
.panelOrientation
.get_active_text()))
1584 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_size = %s %s\n" % (self
.panelSizeX
.get_text() if self
.panelSizeX
.get_text() else PANEL_SIZE_X
,
1585 self
.panelSizeY
.get_text() if self
.panelSizeY
.get_text() else PANEL_SIZE_Y
))
1586 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_margin = %s %s\n" % (self
.panelMarginX
.get_text() if self
.panelMarginX
.get_text() else PANEL_MARGIN_X
,
1587 self
.panelMarginY
.get_text() if self
.panelMarginY
.get_text() else PANEL_MARGIN_Y
))
1588 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_padding = %s %s\n" % (self
.panelPadX
.get_text() if self
.panelPadX
.get_text() else PANEL_PADDING_X
,
1589 self
.panelPadY
.get_text() if self
.panelPadY
.get_text() else PANEL_PADDING_Y
))
1590 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_dock = %s\n" % int(self
.panelDock
.get_active()))
1591 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "wm_menu = %s\n" % int(self
.panelMenu
.get_active()))
1592 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_background_id = %s\n" % (self
.panelBg
.get_active()))
1594 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Taskbar\n")
1595 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_mode = %s\n" % (self
.taskbarMode
.get_active_text()))
1596 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_padding = %s %s %s\n" % (self
.taskbarPadX
.get_text() if self
.taskbarPadX
.get_text() else TASKBAR_PADDING_X
,
1597 self
.taskbarPadY
.get_text() if self
.taskbarPadY
.get_text() else TASKBAR_PADDING_X
,
1598 self
.taskbarSpacing
.get_text() if self
.taskbarSpacing
.get_text() else TASK_SPACING
))
1599 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_background_id = %s\n" % (self
.taskbarBg
.get_active()))
1600 # Comment out the taskbar_active_background_id if user has "disabled" it
1601 if self
.taskbarActiveBgEnable
.get_active() == 0:
1602 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "#")
1603 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_active_background_id = %s\n" % (self
.taskbarActiveBg
.get_active()))
1605 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tasks\n")
1606 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "urgent_nb_of_blink = %s\n" % (self
.taskBlinks
.get_text() if self
.taskBlinks
.get_text() else TASK_BLINKS
))
1607 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_icon = %s\n" % int(self
.taskIconCheckButton
.get_active()))
1608 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_text = %s\n" % int(self
.taskTextCheckButton
.get_active()))
1609 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_centered = %s\n" % int(self
.taskCentreCheckButton
.get_active()))
1610 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_maximum_size = %s %s\n" % (self
.taskMaxSizeX
.get_text() if self
.taskMaxSizeX
.get_text() else TASK_MAXIMUM_SIZE_X
, self
.taskMaxSizeY
.get_text() if self
.taskMaxSizeY
.get_text() else TASK_MAXIMUM_SIZE_Y
))
1611 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_padding = %s %s\n" % (self
.taskPadX
.get_text() if self
.taskPadX
.get_text() else TASK_PADDING_X
,
1612 self
.taskPadY
.get_text() if self
.taskPadY
.get_text() else TASK_PADDING_Y
))
1613 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_background_id = %s\n" % (self
.taskBg
.get_active()))
1614 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_background_id = %s\n" % (self
.taskActiveBg
.get_active()))
1615 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_icon_asb = %s %s %s\n" % (self
.iconHue
.get_text() if self
.iconHue
.get_text() else ICON_ALPHA
,
1616 self
.iconSat
.get_text() if self
.iconSat
.get_text() else ICON_SAT
,
1617 self
.iconBri
.get_text() if self
.iconBri
.get_text() else ICON_BRI
))
1618 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_icon_asb = %s %s %s\n" % (self
.activeIconHue
.get_text() if self
.activeIconHue
.get_text() else ACTIVE_ICON_ALPHA
,
1619 self
.activeIconSat
.get_text() if self
.activeIconSat
.get_text() else ACTIVE_ICON_SAT
,
1620 self
.activeIconBri
.get_text() if self
.activeIconBri
.get_text() else ACTIVE_ICON_BRI
))
1622 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Fonts\n")
1623 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font = %s\n" % (self
.fontButton
.get_font_name()))
1624 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontColButton
),
1625 int(self
.fontColButton
.get_alpha() / 65535.0 * 100)))
1626 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontActiveColButton
),
1627 int(self
.fontActiveColButton
.get_alpha() / 65535.0 * 100)))
1628 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "font_shadow = %s\n" % int(self
.fontShadowCheckButton
.get_active()))
1630 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Systray")
1631 if not self
.trayCheckButton
.get_active():
1632 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), " - DISABLED\n#")
1634 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n")
1635 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_padding = %s %s %s\n" % (self
.trayPadX
.get_text() if self
.trayPadX
.get_text() else TRAY_PADDING_X
,
1636 self
.trayPadY
.get_text() if self
.trayPadY
.get_text() else TRAY_PADDING_Y
,
1637 self
.traySpacing
.get_text() if self
.traySpacing
.get_text() else TRAY_SPACING
))
1638 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_sort = %s\n" % (self
.trayOrder
.get_active_text()))
1639 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_background_id = %s\n" % (self
.trayBg
.get_active()))
1641 if self
.clockCheckButton
.get_active():
1642 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Clock\n")
1643 if self
.clock1CheckButton
.get_active():
1644 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_format = %s\n" % (self
.clock1Format
.get_text() if self
.clock1Format
.get_text() else CLOCK_FMT_1
))
1645 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_font = %s\n" % (self
.clock1FontButton
.get_font_name()))
1646 if self
.clock2CheckButton
.get_active():
1647 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_format = %s\n" % (self
.clock2Format
.get_text() if self
.clock2Format
.get_text() else CLOCK_FMT_2
))
1648 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_font = %s\n" % (self
.clock2FontButton
.get_font_name()))
1649 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_font_color = %s %s\n" % (self
.getHexFromWidget(self
.clockFontColButton
),
1650 int(self
.clockFontColButton
.get_alpha() / 65535.0 * 100)))
1651 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_padding = %s %s\n" % (self
.clockPadX
.get_text() if self
.clockPadX
.get_text() else CLOCK_PADDING_X
,
1652 self
.clockPadY
.get_text() if self
.clockPadY
.get_text() else CLOCK_PADDING_Y
))
1653 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_background_id = %s\n" % (self
.clockBg
.get_active()))
1654 if self
.clockLClick
.get_text():
1655 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_lclick_command = %s\n" % (self
.clockLClick
.get_text()))
1656 if self
.clockRClick
.get_text():
1657 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_rclick_command = %s\n" % (self
.clockRClick
.get_text()))
1659 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tooltips\n")
1660 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip = %s\n" % int(self
.tooltipShow
.get_active()))
1661 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_padding = %s %s\n" % (self
.tooltipPadX
.get_text() if self
.tooltipPadX
.get_text() else TOOLTIP_PADDING_Y
,
1662 self
.tooltipPadY
.get_text() if self
.tooltipPadY
.get_text() else TOOLTIP_PADDING_Y
))
1663 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_show_timeout = %s\n" % (self
.tooltipShowTime
.get_text() if self
.tooltipShowTime
.get_text() else TOOLTIP_SHOW_TIMEOUT
))
1664 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_hide_timeout = %s\n" % (self
.tooltipHideTime
.get_text() if self
.tooltipHideTime
.get_text() else TOOLTIP_HIDE_TIMEOUT
))
1665 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_background_id = %s\n" % (self
.tooltipBg
.get_active()))
1666 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font = %s\n" % (self
.tooltipFont
.get_font_name()))
1667 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font_color = %s %s\n" % (self
.getHexFromWidget(self
.tooltipFontColButton
),
1668 int(self
.tooltipFontColButton
.get_alpha() / 65535.0 * 100)))
1670 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Mouse\n")
1671 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_middle = %s\n" % (self
.mouseMiddle
.get_active_text()))
1672 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_right = %s\n" % (self
.mouseRight
.get_active_text()))
1673 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_up = %s\n" % (self
.mouseUp
.get_active_text()))
1674 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_down = %s\n" % (self
.mouseDown
.get_active_text()))
1676 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Battery\n")
1677 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery = %s\n" % int(self
.batteryCheckButton
.get_active()))
1678 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_low_status = %s\n" % (self
.batteryLow
.get_text() if self
.batteryLow
.get_text() else BATTERY_LOW
))
1679 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_low_cmd = %s\n" % (self
.batteryLowAction
.get_text() if self
.batteryLowAction
.get_text() else BATTERY_ACTION
))
1680 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat1_font = %s\n" % (self
.bat1FontButton
.get_font_name()))
1681 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat2_font = %s\n" % (self
.bat2FontButton
.get_font_name()))
1682 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_font_color = %s %s\n" % (self
.getHexFromWidget(self
.batteryFontColButton
),
1683 int(self
.batteryFontColButton
.get_alpha() / 65535.0 * 100)))
1684 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_padding = %s %s\n" % (self
.batteryPadX
.get_text() if self
.batteryPadX
.get_text() else BATTERY_PADDING_Y
,
1685 self
.batteryPadY
.get_text() if self
.batteryPadY
.get_text() else BATTERY_PADDING_Y
))
1686 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_background_id = %s\n" % (self
.batteryBg
.get_active()))
1688 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# End of config")
1690 def getColorButton(self
, widget
):
1691 """Returns the color button associated with widget."""
1692 if widget
.get_name() == "fontCol":
1693 return self
.fontColButton
1694 elif widget
.get_name() == "fontActiveCol":
1695 return self
.fontActiveColButton
1696 elif widget
.get_name() == "clockFontCol":
1697 return self
.clockFontColButton
1698 elif widget
.get_name() == "batteryFontCol":
1699 return self
.batteryFontColButton
1700 elif widget
.get_name() == "tooltipFontCol":
1701 return self
.tooltipFontColButton
1702 elif widget
.get_name() == "bgColEntry":
1703 bgID
= self
.bgNotebook
.get_current_page()
1705 for child
in self
.bgs
[bgID
].get_children():
1706 if child
.get_name() == "bgCol":
1709 elif widget
.get_name() == "borderColEntry":
1710 bgID
= self
.bgNotebook
.get_current_page()
1712 for child
in self
.bgs
[bgID
].get_children():
1713 if child
.get_name() == "borderCol":
1717 # No button found which matches label
1720 def getColorLabel(self
, widget
):
1721 """Gets the color label associated with a color button."""
1722 if widget
.get_name() == "fontCol":
1724 elif widget
.get_name() == "fontActiveCol":
1725 return self
.fontActiveCol
1726 elif widget
.get_name() == "clockFontCol":
1727 return self
.clockFontCol
1728 elif widget
.get_name() == "batteryFontCol":
1729 return self
.batteryFontCol
1730 elif widget
.get_name() == "tooltipFontCol":
1731 return self
.tooltipFontCol
1732 elif widget
.get_name() == "bgCol":
1733 bgID
= self
.bgNotebook
.get_current_page()
1735 for child
in self
.bgs
[bgID
].get_children():
1736 if child
.get_name() == "bgColEntry":
1739 elif widget
.get_name() == "borderCol":
1740 bgID
= self
.bgNotebook
.get_current_page()
1742 for child
in self
.bgs
[bgID
].get_children():
1743 if child
.get_name() == "borderColEntry":
1747 # No label found which matches color button
1750 def getHexFromWidget(self
, widget
):
1751 """Returns the #RRGGBB value of a widget."""
1752 r
= widget
.get_color().red
1753 g
= widget
.get_color().green
1754 b
= widget
.get_color().blue
1756 return rgbToHex(r
, g
, b
)
1758 def help(self
, action
=None):
1759 """Opens the Help wiki page in the default web browser."""
1761 webbrowser
.open("http://code.google.com/p/tintwizard/wiki/Help")
1763 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/wiki/Help")
1765 def reportBug(self
, action
=None):
1766 """Opens the bug report page in the default web browser."""
1768 webbrowser
.open("http://code.google.com/p/tintwizard/issues/entry")
1770 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/issues/entry")
1773 """Enters the main loop."""
1776 def resetConfig(self
):
1777 """Resets all the widgets to their default values."""
1779 for i
in range(len(self
.bgs
)):
1780 self
.delBgClick(prompt
=False, init
=True)
1782 for i
in range(self
.defaults
["bgCount"]):
1783 self
.addBgClick(init
=True)
1785 self
.bgNotebook
.set_current_page(0)
1788 self
.panelPosY
.set_active(0)
1789 self
.panelPosX
.set_active(0)
1790 self
.panelOrientation
.set_active(0)
1791 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
1792 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
1793 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
1794 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
1795 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
1796 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
1797 self
.panelBg
.set_active(0)
1798 self
.panelMenu
.set_active(0)
1799 self
.panelDock
.set_active(0)
1800 self
.panelMonitor
.set_text(PANEL_MONITOR
)
1802 self
.taskbarMode
.set_active(0)
1803 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
1804 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
1805 self
.taskbarSpacing
.set_text(TASK_SPACING
)
1806 self
.taskbarBg
.set_active(0)
1807 self
.taskbarActiveBg
.set_active(0)
1808 self
.taskbarActiveBgEnable
.set_active(0)
1810 self
.taskBlinks
.set_text(TASK_BLINKS
)
1811 self
.taskCentreCheckButton
.set_active(True)
1812 self
.taskTextCheckButton
.set_active(True)
1813 self
.taskIconCheckButton
.set_active(True)
1814 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
1815 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
1816 self
.taskPadX
.set_text(TASK_PADDING_X
)
1817 self
.taskPadY
.set_text(TASK_PADDING_Y
)
1818 self
.taskBg
.set_active(0)
1819 self
.taskActiveBg
.set_active(0)
1821 self
.iconHue
.set_text(ICON_ALPHA
)
1822 self
.iconSat
.set_text(ICON_SAT
)
1823 self
.iconBri
.set_text(ICON_BRI
)
1824 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
1825 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
1826 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
1828 self
.fontButton
.set_font_name(self
.defaults
["font"])
1829 self
.fontColButton
.set_alpha(65535)
1830 self
.fontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1831 self
.fontCol
.set_text(self
.defaults
["fgColor"])
1832 self
.fontActiveColButton
.set_alpha(65535)
1833 self
.fontActiveColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1834 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
1835 self
.fontShadowCheckButton
.set_active(False)
1837 self
.trayCheckButton
.set_active(True)
1838 self
.trayPadX
.set_text(TRAY_PADDING_X
)
1839 self
.trayPadY
.set_text(TRAY_PADDING_X
)
1840 self
.traySpacing
.set_text(TRAY_SPACING
)
1841 self
.trayOrder
.set_active(0)
1842 self
.trayBg
.set_active(0)
1844 self
.clockCheckButton
.set_active(True)
1845 self
.clock1Format
.set_text(CLOCK_FMT_1
)
1846 self
.clock1CheckButton
.set_active(True)
1847 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
1848 self
.clock2Format
.set_text(CLOCK_FMT_2
)
1849 self
.clock2CheckButton
.set_active(True)
1850 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
1851 self
.clockFontColButton
.set_alpha(65535)
1852 self
.clockFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1853 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
1854 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
1855 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
1856 self
.clockBg
.set_active(0)
1857 self
.clockLClick
.set_text(CLOCK_LCLICK
)
1858 self
.clockRClick
.set_text(CLOCK_RCLICK
)
1860 self
.tooltipShow
.set_active(False)
1861 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
1862 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
1863 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
1864 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
1865 self
.tooltipBg
.set_active(0)
1866 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1867 self
.tooltipFontColButton
.set_alpha(65535)
1868 self
.tooltipFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1869 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1871 self
.mouseMiddle
.set_active(0)
1872 self
.mouseRight
.set_active(0)
1873 self
.mouseUp
.set_active(0)
1874 self
.mouseDown
.set_active(0)
1876 self
.batteryCheckButton
.set_active(False)
1877 self
.batteryLow
.set_text(BATTERY_LOW
)
1878 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1879 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1880 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1881 self
.batteryFontColButton
.set_alpha(65535)
1882 self
.batteryFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1883 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1884 self
.batteryPadX
.set_text(BATTERY_PADDING_Y
)
1885 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1886 self
.batteryBg
.set_active(0)
1888 def new(self
, action
=None):
1889 """Prepares a new config."""
1894 self
.filename
= None
1898 self
.generateConfig()
1899 self
.updateStatusBar("New Config File [*]")
1901 def openDef(self
, widget
=None):
1902 """Opens the default tint2 config."""
1903 self
.openFile(default
=True)
1905 def openFile(self
, widget
=None, default
=False):
1906 """Reads from a config file. If default=True, open the tint2 default config."""
1910 chooser
= gtk
.FileChooserDialog("Open Config File", self
, gtk
.FILE_CHOOSER_ACTION_OPEN
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
1911 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1913 if self
.curDir
!= None:
1914 chooser
.set_current_folder(self
.curDir
)
1916 chooserFilter
= gtk
.FileFilter()
1917 chooserFilter
.set_name("All files")
1918 chooserFilter
.add_pattern("*")
1919 chooser
.add_filter(chooserFilter
)
1922 response
= chooser
.run()
1924 if response
== gtk
.RESPONSE_OK
:
1925 self
.filename
= chooser
.get_filename()
1926 self
.curDir
= os
.path
.dirname(self
.filename
)
1933 self
.filename
= os
.path
.expandvars("$HOME/.config/tint2/tint2rc")
1934 self
.curDir
= os
.path
.expandvars("$HOME/.config/tint2")
1936 self
.readTint2Config()
1937 self
.generateConfig()
1938 self
.updateStatusBar()
1940 def addBgDefs(self
, bgDefs
):
1941 """Add interface elements for a list of background style definitions. bgDefs
1942 should be a list containing dictionaries with the following keys: rounded,
1943 border_width, background_color, border_color"""
1947 for child
in self
.bgs
[-1].get_children():
1948 if child
.get_name() == "rounded":
1949 child
.set_text(d
["rounded"])
1950 elif child
.get_name() == "border":
1951 child
.set_text(d
["border_width"])
1952 elif child
.get_name() == "bgColEntry":
1953 child
.set_text(d
["background_color"].split(" ")[0].strip())
1955 elif child
.get_name() == "borderColEntry":
1956 child
.set_text(d
["border_color"].split(" ")[0].strip())
1958 elif child
.get_name() == "bgCol":
1959 list = d
["background_color"].split(" ")
1961 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1963 child
.set_alpha(65535)
1964 elif child
.get_name() == "borderCol":
1965 list = d
["border_color"].split(" ")
1967 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1969 child
.set_alpha(65535)
1971 newId
= len(self
.bgs
)
1973 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1975 self
.bgNotebook
.show_all()
1977 self
.updateComboBoxes(newId
-1, "add")
1979 self
.bgNotebook
.set_current_page(newId
)
1981 def parseBgs(self
, string
):
1982 """Parses the background definitions from a string."""
1983 s
= string
.split("\n")
1987 bgKeys
= ["border_width", "background_color", "border_color"]
1991 data
= [token
.strip() for token
in line
.split("=")]
1993 if data
[0] == "rounded": # It may be considered bad practice to
1994 bgDefs
+= [{"rounded": data[1]}
] # find each style definition with an
1995 elif data
[0] in bgKeys
: # arbitrary value, but tint2 does the same.
1996 bgDefs
[cur
][data
[0]] = data
[1] # This means that any existing configs must
1997 else: # start with 'rounded'.
1998 newString
+= "%s\n" % line
2000 self
.addBgDefs(bgDefs
)
2004 def parseConfig(self
, string
):
2005 """Parses the contents of a config file."""
2006 for line
in string
.split("\n"):
2007 s
= line
.split("=") # Create a list with KEY and VALUE
2009 e
= s
[0].strip() # Strip whitespace from KEY
2011 if e
== "time1_format": # Set the VALUE of KEY
2012 self
.parseProp(self
.propUI
[e
], s
[1], True, "time1")
2013 elif e
== "time2_format":
2014 self
.parseProp(self
.propUI
[e
], s
[1], True, "time2")
2015 elif e
== "systray_padding":
2016 self
.parseProp(self
.propUI
[e
], s
[1], True, "tray")
2017 elif e
== "taskbar_active_background_id":
2018 self
.parseProp(self
.propUI
[e
], s
[1], True, "activeBg")
2020 if self
.propUI
.has_key(e
):
2021 self
.parseProp(self
.propUI
[e
], s
[1])
2023 def parseProp(self
, prop
, string
, special
=False, propType
=""):
2024 """Parses a variable definition from the conf file and updates the correct UI widget."""
2025 string
= string
.strip() # Remove whitespace from the VALUE
2026 eType
= type(prop
) # Get widget type
2028 if special
: # 'Special' properties are those which are optional
2029 if propType
== "time1":
2030 self
.clockCheckButton
.set_active(True)
2031 self
.clock1CheckButton
.set_active(True)
2032 elif propType
== "time2":
2033 self
.clockCheckButton
.set_active(True)
2034 self
.clock2CheckButton
.set_active(True)
2035 elif propType
== "tray":
2036 self
.trayCheckButton
.set_active(True)
2037 elif propType
== "activeBg":
2038 self
.taskbarActiveBgEnable
.set_active(True)
2040 if eType
== gtk
.Entry
:
2041 prop
.set_text(string
)
2043 elif eType
== gtk
.ComboBox
:
2044 if string
in ["bottom", "top", "left", "right", "center", "single_desktop", "multi_desktop", "single_monitor",
2045 "none", "close", "shade", "iconify", "toggle", "toggle_iconify", "maximize_restore",
2046 "desktop_left", "desktop_right", "horizontal", "vertical", "ascending", "descending",
2047 "left2right", "right2left"]:
2048 if string
in ["bottom", "left", "single_desktop", "none", "horizontal", "ascending"]:
2050 elif string
in ["top", "right", "multi_desktop", "close", "vertical", "descending"]:
2052 elif string
in ["center", "single_monitor", "toggle", "left2right"]:
2054 elif string
in ["right2left"]:
2057 i
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore",
2058 "desktop_left", "desktop_right"].index(string
)
2062 prop
.set_active(int(string
))
2063 elif eType
== gtk
.CheckButton
:
2064 prop
.set_active(bool(int(string
)))
2065 elif eType
== gtk
.FontButton
:
2066 prop
.set_font_name(string
)
2067 elif eType
== gtk
.ColorButton
:
2068 prop
.set_alpha(int(int(string
) * 65535 / 100.0))
2069 elif eType
== tuple: # If a property has more than 1 value, for example the x and y co-ords
2070 s
= string
.split(" ") # of the padding properties, then just we use recursion to set the
2071 for i
in range(len(prop
)): # value of each associated widget.
2073 self
.parseProp(prop
[i
], "0")
2075 self
.parseProp(prop
[i
], s
[i
])
2077 def quit(self
, widget
, event
=None):
2078 """Asks if user would like to save file before quitting, then quits the program."""
2080 if self
.oneConfigFile
:
2081 response
= gtk
.RESPONSE_YES
2083 dialog
= gtk
.Dialog("Save config?", self
, gtk
.DIALOG_MODAL
, (gtk
.STOCK_YES
, gtk
.RESPONSE_YES
, gtk
.STOCK_NO
, gtk
.RESPONSE_NO
, gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
))
2084 dialog
.get_content_area().add(gtk
.Label("Save config before quitting?"))
2085 dialog
.get_content_area().set_size_request(300, 100)
2087 response
= dialog
.run()
2090 if response
== gtk
.RESPONSE_CANCEL
:
2091 return True # Return True to stop it quitting when we hit "Cancel"
2092 elif response
== gtk
.RESPONSE_NO
:
2094 elif response
== gtk
.RESPONSE_YES
:
2101 """Reads the tintwizard configuration file - NOT tint2 config files."""
2102 self
.defaults
= {"font": None, "bgColor": None, "fgColor": None, "borderColor": None, "bgCount": None, "dir": None}
2104 if self
.oneConfigFile
:
2105 # don't need tintwizard.conf
2108 pathName
= os
.path
.dirname(sys
.argv
[0])
2113 if not os
.path
.exists(pathName
+ "tintwizard.conf"):
2117 f
= open(pathName
+ "tintwizard.conf", "r")
2123 if self
.defaults
.has_key(l
[0].strip()):
2124 self
.defaults
[l
[0].strip()] = l
[1].strip()
2126 def readTint2Config(self
):
2127 """Reads in from a config file."""
2128 f
= open(self
.filename
, "r")
2133 if (line
[0] != "#") and (len(line
) > 2):
2138 # Deselect the optional stuff, and we'll re-check them if the config has them enabled
2139 self
.clockCheckButton
.set_active(False)
2140 self
.clock1CheckButton
.set_active(False)
2141 self
.clock2CheckButton
.set_active(False)
2142 self
.trayCheckButton
.set_active(False)
2143 self
.taskbarActiveBgEnable
.set_active(False)
2145 # Remove all background styles so we can create new ones as we read them
2146 for i
in range(len(self
.bgs
)):
2147 self
.delBgClick(None, False)
2149 # As we parse background definitions, we build a new string
2150 # without the background related stuff. This means we don't
2151 # have to read through background defs AGAIN when parsing
2153 noBgDefs
= self
.parseBgs(string
)
2155 self
.parseConfig(noBgDefs
)
2157 def save(self
, widget
=None, event
=None):
2158 """Saves the generated config file."""
2160 # This function returns the boolean status of whether or not the
2161 # file saved, so that the apply() function knows if it should
2162 # kill the tint2 process and apply the new config.
2164 # If no file has been selected, force the user to "Save As..."
2165 if self
.filename
== None:
2166 return self
.saveAs()
2168 self
.generateConfig()
2173 def saveAs(self
, widget
=None, event
=None):
2174 """Prompts the user to select a file and then saves the generated config file."""
2175 self
.generateConfig()
2177 chooser
= gtk
.FileChooserDialog("Save Config File As...", self
, gtk
.FILE_CHOOSER_ACTION_SAVE
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_SAVE
, gtk
.RESPONSE_OK
))
2178 chooser
.set_default_response(gtk
.RESPONSE_OK
)
2180 if self
.curDir
!= None:
2181 chooser
.set_current_folder(self
.curDir
)
2183 chooserFilter
= gtk
.FileFilter()
2184 chooserFilter
.set_name("All files")
2185 chooserFilter
.add_pattern("*")
2186 chooser
.add_filter(chooserFilter
)
2189 response
= chooser
.run()
2191 if response
== gtk
.RESPONSE_OK
:
2192 self
.filename
= chooser
.get_filename()
2194 if os
.path
.exists(self
.filename
):
2195 overwrite
= confirmDialog(self
, "This file already exists. Overwrite this file?")
2197 if overwrite
== gtk
.RESPONSE_YES
:
2202 self
.filename
= None
2210 self
.filename
= None
2214 def saveAsDef(self
, widget
=None, event
=None):
2215 """Saves the config as the default tint2 config."""
2216 if confirmDialog(self
, "Overwrite current tint2 default config?") == gtk
.RESPONSE_YES
:
2217 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
2218 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
2220 # If, for whatever reason, tint2 has no default config - create one.
2221 if not os
.path
.isfile(self
.filename
):
2222 f
= open(self
.filename
, "w")
2223 f
.write("# tint2rc")
2226 self
.generateConfig()
2231 def savePrompt(self
):
2232 """Prompt the user to save before creating a new file."""
2233 if confirmDialog(self
, "Save current config?") == gtk
.RESPONSE_YES
:
2236 def switchPage(self
, notebook
, page
, page_num
):
2237 """Handles notebook page switch events."""
2239 # If user selects the 'View Config' tab, update the textarea within this tab.
2240 if notebook
.get_tab_label_text(notebook
.get_nth_page(page_num
)) == "View Config":
2241 self
.generateConfig()
2243 def updateComboBoxes(self
, i
, action
="add"):
2244 """Updates the contents of a combo box when a background style has been added/removed."""
2245 cbs
= [self
.batteryBg
, self
.clockBg
, self
.taskbarBg
, self
.taskbarActiveBg
, self
.trayBg
, self
.taskActiveBg
, self
.taskBg
, self
.panelBg
, self
.tooltipBg
]
2249 cb
.append_text(str(i
+1))
2252 if cb
.get_active() == i
: # If background is selected, set to a different value
2257 def updateStatusBar(self
, message
="", change
=False):
2258 """Updates the message on the statusbar. A message can be provided,
2259 and if change is set to True (i.e. something has been modified) then
2260 an appropriate symbol [*] is shown beside filename."""
2261 contextID
= self
.statusBar
.get_context_id("")
2263 self
.statusBar
.pop(contextID
)
2266 message
= "%s %s" % (self
.filename
or "New Config File", "[*]" if change
else "")
2268 self
.statusBar
.push(contextID
, message
)
2270 def writeConf(self
):
2271 """Writes the tintwizard configuration file."""
2272 confStr
= "#Start\n[defaults]\n"
2274 for key
in self
.defaults
:
2275 confStr
+= "%s = %s\n" % (key
, str(self
.defaults
[key
]))
2279 pathName
= os
.path
.dirname(sys
.argv
[0])
2282 f
= open("tintwizard.conf", "w")
2284 f
= open(pathName
+"/tintwizard.conf", "w")
2290 def writeFile(self
):
2291 """Writes the contents of the config text buffer to file."""
2293 f
= open(self
.filename
, "w")
2295 f
.write(self
.configBuf
.get_text(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter()))
2301 self
.curDir
= os
.path
.dirname(self
.filename
)
2303 self
.updateStatusBar()
2305 errorDialog(self
, "Could not save file")
2307 # General use functions
2308 def confirmDialog(parent
, message
):
2309 """Creates a confirmation dialog and returns the response."""
2310 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
, message
)
2312 response
= dialog
.run()
2316 def errorDialog(parent
=None, message
="An error has occured!"):
2317 """Creates an error dialog."""
2318 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
2324 """Convert integer n in range [0, 15] to hex."""
2326 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"][n
]
2330 def rgbToHex(r
, g
, b
):
2331 """Constructs a 6 digit hex representation of color (r, g, b)."""
2332 r2
= trunc(r
/ 65535.0 * 255)
2333 g2
= trunc(g
/ 65535.0 * 255)
2334 b2
= trunc(b
/ 65535.0 * 255)
2336 return "#%s%s%s%s%s%s" % (numToHex(r2
/ 16), numToHex(r2
% 16), numToHex(g2
/ 16), numToHex(g2
% 16), numToHex(b2
/ 16), numToHex(b2
% 16))
2339 """Truncate a floating point number, rounding up or down appropriately."""
2340 c
= math
.fabs(math
.ceil(n
) - n
)
2341 f
= math
.fabs(math
.floor(n
) - n
)
2344 return int(math
.ceil(n
))
2346 return int(math
.floor(n
))
2348 # Direct execution of application
2349 if __name__
== "__main__":
2350 tw
= TintWizardGUI()