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: 21st April 2010
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 PANEL_AUTOHIDE_SHOW
= "0.0"
50 PANEL_AUTOHIDE_HIDE
= "0.0"
51 PANEL_AUTOHIDE_HEIGHT
= "0"
52 TASKBAR_PADDING_X
= "0"
53 TASKBAR_PADDING_Y
= "0"
56 TASK_MAXIMUM_SIZE_X
= "200"
57 TASK_MAXIMUM_SIZE_Y
= "32"
64 TRAY_MAX_ICON_SIZE
= "0"
65 TRAY_ICON_ALPHA
= "100"
71 ACTIVE_ICON_ALPHA
= "100"
74 URGENT_ICON_ALPHA
= "100"
77 ICONIFIED_ICON_ALPHA
= "100"
78 ICONIFIED_ICON_SAT
= "0"
79 ICONIFIED_ICON_BRI
= "0"
81 CLOCK_FMT_2
= "%a %d %b"
83 CLOCK_TIME1_TIMEZONE
= ""
84 CLOCK_TIME2_TIMEZONE
= ""
85 CLOCK_TOOLTIP_TIMEZONE
= ""
90 TOOLTIP_PADDING_X
= "0"
91 TOOLTIP_PADDING_Y
= "0"
92 TOOLTIP_SHOW_TIMEOUT
= "0"
93 TOOLTIP_HIDE_TIMEOUT
= "0"
96 BATTERY_ACTION
= 'notify-send "battery low"'
97 BATTERY_PADDING_X
= "0"
98 BATTERY_PADDING_Y
= "0"
100 class TintWizardPrefGUI(gtk
.Window
):
101 """The dialog window which lets the user change the default preferences."""
102 def __init__(self
, tw
):
103 """Create and shows the window."""
106 # Create top-level window
107 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
109 self
.set_title("Preferences")
110 self
.connect("delete_event", self
.quit
)
112 self
.layout
= gtk
.Table(2, 2, False)
114 self
.table
= gtk
.Table(5, 2, False)
115 self
.table
.set_row_spacings(5)
116 self
.table
.set_col_spacings(5)
118 createLabel(self
.table
, text
="Default Font", gridX
=0, gridY
=0)
119 self
.font
= gtk
.FontButton(self
.tw
.defaults
["font"])
120 self
.font
.set_alignment(0, 0.5)
121 self
.table
.attach(self
.font
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
123 createLabel(self
.table
, text
="Default Background Color", gridX
=0, gridY
=1)
124 self
.bgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["bgColor"]))
125 self
.bgColor
.set_alignment(0, 0.5)
126 self
.table
.attach(self
.bgColor
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
128 createLabel(self
.table
, text
="Default Foreground Color", gridX
=0, gridY
=2)
129 self
.fgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["fgColor"]))
130 self
.fgColor
.set_alignment(0, 0.5)
131 self
.table
.attach(self
.fgColor
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
133 createLabel(self
.table
, text
="Default Border Color", gridX
=0, gridY
=3)
134 self
.borderColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["borderColor"]))
135 self
.borderColor
.set_alignment(0, 0.5)
136 self
.table
.attach(self
.borderColor
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
138 createLabel(self
.table
, text
="Number of background styles", gridX
=0, gridY
=4)
139 self
.bgCount
= createEntry(self
.table
, maxSize
=6, width
=8, text
=str(self
.tw
.defaults
["bgCount"]), gridX
=1, gridY
=4, xExpand
=True, yExpand
=True)
141 self
.layout
.attach(self
.table
, 0, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, xpadding
=20, ypadding
=5)
143 createButton(self
.layout
, text
="Save", stock
=gtk
.STOCK_SAVE
, name
="save", gridX
=0, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.save
)
144 createButton(self
.layout
, text
="Cancel", stock
=gtk
.STOCK_CANCEL
, name
="cancel", gridX
=1, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.quit
)
146 self
.add(self
.layout
)
150 def quit(self
, widget
=None, event
=None):
151 """Destroys the window."""
154 def save(self
, action
=None):
155 """Called when the Save button is clicked."""
156 if confirmDialog(self
, "Overwrite configuration file?") == gtk
.RESPONSE_YES
:
157 self
.tw
.defaults
["font"] = self
.font
.get_font_name()
158 self
.tw
.defaults
["bgColor"] = rgbToHex(self
.bgColor
.get_color().red
, self
.bgColor
.get_color().green
, self
.bgColor
.get_color().blue
)
159 self
.tw
.defaults
["fgColor"] = rgbToHex(self
.fgColor
.get_color().red
, self
.fgColor
.get_color().green
, self
.fgColor
.get_color().blue
)
160 self
.tw
.defaults
["borderColor"] = rgbToHex(self
.borderColor
.get_color().red
, self
.borderColor
.get_color().green
, self
.borderColor
.get_color().blue
)
163 self
.tw
.defaults
["bgCount"] = int(self
.bgCount
.get_text())
165 errorDialog(self
, "Invalid value for background count")
172 class TintWizardGUI(gtk
.Window
):
173 """The main window for the application."""
175 """Create and show the window."""
180 if len(sys
.argv
) > 1:
181 self
.filename
= sys
.argv
[1]
182 self
.oneConfigFile
= True
184 self
.oneConfigFile
= False
186 # Read conf file and set default values
189 if self
.defaults
["bgColor"] in [None, "None"]:
190 self
.defaults
["bgColor"] = "#000000"
192 if self
.defaults
["fgColor"] in [None, "None"]:
193 self
.defaults
["fgColor"] = "#ffffff"
195 if self
.defaults
["borderColor"] in [None, "None"]:
196 self
.defaults
["borderColor"] = "#ffffff"
198 if os
.path
.exists(os
.path
.expandvars("${HOME}") + "/.config/tint2"):
199 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
201 errorDialog("$HOME/.config/tint2/ directory not found! Is tint2 installed correctly?")
205 self
.defaults
["bgCount"] = int(self
.defaults
["bgCount"])
207 self
.defaults
["bgCount"] = 2
209 # Get the full location of the tint2 binary
210 which
= os
.popen('which tint2')
212 self
.tint2Bin
= which
.readline().strip()
216 if len(self
.tint2Bin
) == 0:
217 errorDialog(self
, "tint2 could not be found. Are you sure it is installed?")
220 # Create top-level window
221 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
223 self
.set_title("tintwizard")
225 self
.connect("delete_event", self
.quit
)
227 # self.table is our main layout manager
228 self
.table
= gtk
.Table(4, 1, False)
230 # Set up the dictionary to hold all registered widgets
233 # Create menus and toolbar items
236 <menubar name="MenuBar">
238 <menuitem action="New" />
239 <menuitem action="Open" />
241 <menuitem action="Save" />
242 <menuitem action="Save As..." />
244 <menuitem action="Quit" />
246 <menu action="Tint2">
247 <menuitem action="OpenDefault" />
248 <menuitem action="SaveDefault" />
250 <menuitem action="Apply" />
252 <menu action="Tools">
253 <menuitem action="FontChange" />
255 <menuitem action="Defaults" />
257 <menu action="HelpMenu">
258 <menuitem action="Help" />
259 <menuitem action="Report Bug" />
261 <menuitem action="About" />
264 <toolbar name="ToolBar">
265 <toolitem action="New" />
266 <toolitem action="Open" />
267 <toolitem action="Save" />
269 <toolitem action="Apply" />
275 self
.uiManager
= gtk
.UIManager()
277 accelGroup
= self
.uiManager
.get_accel_group()
278 self
.add_accel_group(accelGroup
)
280 self
.ag
= gtk
.ActionGroup("File")
281 self
.ag
.add_actions([("File", None, "_File"),
282 ("New",gtk
.STOCK_NEW
, "_New", None, "Create a new config", self
.new
),
283 ("Open", gtk
.STOCK_OPEN
, "_Open", None, "Open an existing config", self
.openFile
),
284 ("Save", gtk
.STOCK_SAVE
, "_Save", None, "Save the current config", self
.save
),
285 ("Save As...", gtk
.STOCK_SAVE_AS
, "Save As", None, "Save the current config as...", self
.saveAs
),
286 ("SaveDefault", None, "Save As tint2 Default", None, "Save the current config as the tint2 default", self
.saveAsDef
),
287 ("OpenDefault", None, "Open tint2 Default", None, "Open the current tint2 default config", self
.openDef
),
288 ("Apply", gtk
.STOCK_APPLY
, "Apply Config", None, "Apply the current config to tint2", self
.apply),
289 ("Quit", gtk
.STOCK_QUIT
, "_Quit", None, "Quit the program", self
.quit
),
290 ("Tools", None, "_Tools"),
291 ("Tint2", None, "Tint_2"),
292 ("HelpMenu", None, "_Help"),
293 ("FontChange",gtk
.STOCK_SELECT_FONT
, "Change All Fonts", None, "Change all fonts at once.", self
.changeAllFonts
),
294 ("Defaults",gtk
.STOCK_PREFERENCES
, "Change Defaults", None, "Change tintwizard defaults.", self
.changeDefaults
),
295 ("Help",gtk
.STOCK_HELP
, "_Help", None, "Get help with tintwizard", self
.help),
296 ("Report Bug",None, "Report Bug", None, "Report a problem with tintwizard", self
.reportBug
),
297 ("About",gtk
.STOCK_ABOUT
, "_About Tint Wizard", None, "Find out more about Tint Wizard", self
.about
)])
300 self
.uiManager
.insert_action_group(self
.ag
, -1)
301 self
.uiManager
.add_ui_from_string(ui
)
303 if not self
.oneConfigFile
:
304 # Attach menubar and toolbar to main window
305 self
.table
.attach(self
.uiManager
.get_widget("/MenuBar"), 0, 4, 0, 1)
306 self
.table
.attach(self
.uiManager
.get_widget("/ToolBar"), 0, 4, 1, 2)
309 self
.notebook
= gtk
.Notebook()
310 self
.notebook
.set_tab_pos(gtk
.POS_TOP
)
312 # Create notebook pages
314 self
.tableBgs
= gtk
.Table(rows
=1, columns
=1, homogeneous
=False)
315 self
.tableBgs
.set_row_spacings(5)
316 self
.tableBgs
.set_col_spacings(5)
318 self
.bgNotebook
= gtk
.Notebook()
319 self
.bgNotebook
.set_scrollable(True)
321 self
.tableBgs
.attach(self
.bgNotebook
, 0, 2, 0, 1)
325 # Add buttons for adding/deleting background styles
326 createButton(self
.tableBgs
, text
="New Background", stock
=gtk
.STOCK_NEW
, name
="addBg", gridX
=0, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.addBgClick
)
327 createButton(self
.tableBgs
, text
="Delete Background", stock
=gtk
.STOCK_DELETE
, name
="delBg", gridX
=1, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.delBgClick
)
330 self
.createPanelDisplayWidgets()
331 self
.createPanelSettingsWidgets()
332 self
.createPanelAutohideWidgets()
335 self
.createTaskbarWidgets()
338 self
.createTaskSettingsWidgets()
339 self
.createNormalTasksWidgets()
340 self
.createActiveTasksWidgets()
341 self
.createUrgentTasksWidgets()
342 self
.createIconifiedTasksWidgets()
345 self
.createSystemTrayWidgets()
348 self
.createClockDisplayWidgets()
349 self
.createClockSettingsWidgets()
352 self
.createMouseWidgets()
355 self
.createTooltipsWidgets()
358 self
.createBatteryWidgets()
361 self
.configArea
= gtk
.ScrolledWindow()
362 self
.configBuf
= gtk
.TextBuffer()
363 self
.configTextView
= gtk
.TextView(self
.configBuf
)
364 self
.configArea
.add_with_viewport(self
.configTextView
)
366 # Add backgrounds to notebooks
367 for i
in range(self
.defaults
["bgCount"]):
368 self
.addBgClick(None, init
=True)
370 self
.bgNotebook
.set_current_page(0)
372 # Create sub-notebooks
373 self
.panelNotebook
= gtk
.Notebook()
374 self
.panelNotebook
.set_tab_pos(gtk
.POS_TOP
)
375 self
.panelNotebook
.set_current_page(0)
377 self
.panelNotebook
.append_page(self
.tablePanelDisplay
, gtk
.Label("Panel Display"))
378 self
.panelNotebook
.append_page(self
.tablePanelSettings
, gtk
.Label("Panel Settings"))
379 self
.panelNotebook
.append_page(self
.tablePanelAutohide
, gtk
.Label("Panel Autohide"))
381 self
.taskNotebook
= gtk
.Notebook()
382 self
.taskNotebook
.set_tab_pos(gtk
.POS_TOP
)
383 self
.taskNotebook
.set_current_page(0)
385 self
.taskNotebook
.append_page(self
.tableTask
, gtk
.Label("Task Settings"))
386 self
.taskNotebook
.append_page(self
.tableTaskDefault
, gtk
.Label("Normal Tasks"))
387 self
.taskNotebook
.append_page(self
.tableTaskActive
, gtk
.Label("Active Tasks"))
388 self
.taskNotebook
.append_page(self
.tableTaskUrgent
, gtk
.Label("Urgent Tasks"))
389 self
.taskNotebook
.append_page(self
.tableTaskIconified
, gtk
.Label("Iconified Tasks"))
391 self
.clockNotebook
= gtk
.Notebook()
392 self
.clockNotebook
.set_tab_pos(gtk
.POS_TOP
)
393 self
.clockNotebook
.set_current_page(0)
395 self
.clockNotebook
.append_page(self
.tableClockDisplays
, gtk
.Label("Clock Display"))
396 self
.clockNotebook
.append_page(self
.tableClockSettings
, gtk
.Label("Clock Settings"))
398 # Add pages to notebook
399 self
.notebook
.append_page(self
.tableBgs
, gtk
.Label("Backgrounds"))
400 self
.notebook
.append_page(self
.panelNotebook
, gtk
.Label("Panel"))
401 self
.notebook
.append_page(self
.tableTaskbar
, gtk
.Label("Taskbar"))
402 self
.notebook
.append_page(self
.taskNotebook
, gtk
.Label("Tasks"))
403 self
.notebook
.append_page(self
.tableTray
, gtk
.Label("System Tray"))
404 self
.notebook
.append_page(self
.clockNotebook
, gtk
.Label("Clock"))
405 self
.notebook
.append_page(self
.tableMouse
, gtk
.Label("Mouse"))
406 self
.notebook
.append_page(self
.tableTooltip
, gtk
.Label("Tooltips"))
407 self
.notebook
.append_page(self
.tableBattery
, gtk
.Label("Battery"))
408 self
.notebook
.append_page(self
.configArea
, gtk
.Label("View Config"))
410 self
.notebook
.connect("switch-page", self
.switchPage
)
412 # Add notebook to window and show
413 self
.table
.attach(self
.notebook
, 0, 4, 2, 3, xpadding
=5, ypadding
=5)
415 if self
.oneConfigFile
:
416 # Add button Apply and Close
417 self
.box1
= gtk
.HBox(False, 20)
418 self
.table
.attach(self
.box1
, 0, 4, 3, 4, xpadding
=5, ypadding
=5)
419 temp
= gtk
.Button("Apply", gtk
.STOCK_APPLY
)
420 temp
.set_name("applyBg")
421 temp
.connect("clicked", self
.apply)
422 self
.box1
.pack_start(temp
, True, True, 0)
423 temp
= gtk
.Button("Close", gtk
.STOCK_CLOSE
)
424 temp
.set_name("closeBg")
425 temp
.connect("clicked", self
.quit
)
426 self
.box1
.pack_start(temp
, True, True, 0)
428 # Create and add the status bar to the bottom of the main window
429 self
.statusBar
= gtk
.Statusbar()
430 self
.statusBar
.set_has_resize_grip(True)
431 self
.updateStatusBar("New Config File [*]")
432 self
.table
.attach(self
.statusBar
, 0, 4, 4, 5)
438 # If tintwizard was launched with a tint2 config filename
439 # as an argument, load that config.
440 if self
.oneConfigFile
:
441 self
.readTint2Config()
443 self
.generateConfig()
445 def createPanelDisplayWidgets(self
):
446 """Create the Panel Display widgets."""
447 self
.tablePanelDisplay
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
448 self
.tablePanelDisplay
.set_row_spacings(5)
449 self
.tablePanelDisplay
.set_col_spacings(5)
451 createLabel(self
.tablePanelDisplay
, text
="Position", gridX
=0, gridY
=0, xPadding
=10)
452 self
.panelPosY
= createComboBox(self
.tablePanelDisplay
, ["bottom", "top", "center"], gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
453 self
.panelPosX
= createComboBox(self
.tablePanelDisplay
, ["left", "right", "center"], gridX
=2, gridY
=0, handler
=self
.changeOccurred
)
454 # Note: registered below
456 createLabel(self
.tablePanelDisplay
, text
="Panel Orientation", gridX
=0, gridY
=1, xPadding
=10)
457 self
.panelOrientation
= createComboBox(self
.tablePanelDisplay
, ["horizontal", "vertical"], gridX
=1, gridY
=1, handler
=self
.changeOccurred
)
458 self
.registerComponent("panel_position", (self
.panelPosY
, self
.panelPosX
, self
.panelOrientation
))
460 self
.panelSizeLabel
= createLabel(self
.tablePanelDisplay
, text
="Size (width, height)", gridX
=0, gridY
=2, xPadding
=10)
461 self
.panelSizeX
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_SIZE_X
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
462 self
.panelSizeY
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_SIZE_Y
, gridX
=2, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
463 self
.registerComponent("panel_size", (self
.panelSizeX
, self
.panelSizeY
))
465 createLabel(self
.tablePanelDisplay
, text
="Margin (x, y)", gridX
=0, gridY
=3, xPadding
=10)
466 self
.panelMarginX
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_MARGIN_X
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
467 self
.panelMarginY
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_MARGIN_Y
, gridX
=2, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
468 self
.registerComponent("panel_margin", (self
.panelMarginX
, self
.panelMarginY
))
470 createLabel(self
.tablePanelDisplay
, text
="Padding (x, y)", gridX
=0, gridY
=4, xPadding
=10)
471 self
.panelPadX
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_PADDING_X
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
472 self
.panelPadY
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_PADDING_Y
, gridX
=2, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
475 createLabel(self
.tablePanelDisplay
, text
="Horizontal Spacing", gridX
=0, gridY
=5, xPadding
=10)
476 self
.panelSpacing
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=TASKBAR_SPACING
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
477 self
.registerComponent("panel_padding", (self
.panelPadX
, self
.panelPadY
, self
.panelSpacing
))
479 createLabel(self
.tablePanelDisplay
, text
="Panel Background ID", gridX
=0, gridY
=6, xPadding
=10)
480 self
.panelBg
= createComboBox(self
.tablePanelDisplay
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=6, handler
=self
.changeOccurred
)
481 self
.registerComponent("panel_background_id", self
.panelBg
)
483 def createPanelSettingsWidgets(self
):
484 """Create the Panel Settings widgets."""
485 self
.tablePanelSettings
= gtk
.Table(rows
=5, columns
=3, homogeneous
=False)
486 self
.tablePanelSettings
.set_row_spacings(5)
487 self
.tablePanelSettings
.set_col_spacings(5)
489 createLabel(self
.tablePanelSettings
, text
="Window Manager Menu", gridX
=0, gridY
=0, xPadding
=10)
490 self
.panelMenu
= createCheckButton(self
.tablePanelSettings
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
491 self
.registerComponent("wm_menu", self
.panelMenu
)
493 createLabel(self
.tablePanelSettings
, text
="Place In Window Manager Dock", gridX
=0, gridY
=1, xPadding
=10)
494 self
.panelDock
= createCheckButton(self
.tablePanelSettings
, active
=False, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
495 self
.registerComponent("panel_dock", self
.panelDock
)
497 createLabel(self
.tablePanelSettings
, text
="Panel Layer", gridX
=0, gridY
=2, xPadding
=10)
498 self
.panelLayer
= createComboBox(self
.tablePanelSettings
, ["bottom", "top", "normal"], gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
499 self
.registerComponent("panel_layer", self
.panelLayer
)
501 createLabel(self
.tablePanelSettings
, text
="Strut Policy", gridX
=0, gridY
=3, xPadding
=10)
502 self
.panelAutohideStrut
= createComboBox(self
.tablePanelSettings
, ["none", "minimum", "follow_size"], gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
503 self
.registerComponent("strut_policy", self
.panelAutohideStrut
)
505 createLabel(self
.tablePanelSettings
, text
="Panel Monitor (all, 1, 2, ...)", gridX
=0, gridY
=4, xPadding
=10)
506 self
.panelMonitor
= createEntry(self
.tablePanelSettings
, maxSize
=6, width
=8, text
=PANEL_MONITOR
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
507 self
.registerComponent("panel_monitor", self
.panelMonitor
)
509 def createPanelAutohideWidgets(self
):
510 """Create the Panel Autohide widgets."""
511 self
.tablePanelAutohide
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
512 self
.tablePanelAutohide
.set_row_spacings(5)
513 self
.tablePanelAutohide
.set_col_spacings(5)
515 createLabel(self
.tablePanelAutohide
, text
="Autohide Panel", gridX
=0, gridY
=0, xPadding
=10)
516 self
.panelAutohide
= createCheckButton(self
.tablePanelAutohide
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
517 self
.registerComponent("autohide", self
.panelAutohide
)
519 createLabel(self
.tablePanelAutohide
, text
="Autohide Show Timeout (seconds)", gridX
=0, gridY
=1, xPadding
=10)
520 self
.panelAutohideShow
= createEntry(self
.tablePanelAutohide
, maxSize
=6, width
=8, text
=PANEL_AUTOHIDE_SHOW
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
521 self
.registerComponent("autohide_show_timeout", self
.panelAutohideShow
)
523 createLabel(self
.tablePanelAutohide
, text
="Autohide Hide Timeout (seconds)", gridX
=0, gridY
=2, xPadding
=10)
524 self
.panelAutohideHide
= createEntry(self
.tablePanelAutohide
, maxSize
=6, width
=8, text
=PANEL_AUTOHIDE_HIDE
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
525 self
.registerComponent("autohide_hide_timeout", self
.panelAutohideHide
)
527 createLabel(self
.tablePanelAutohide
, text
="Autohide Hidden Height", gridX
=0, gridY
=3, xPadding
=10)
528 self
.panelAutohideHeight
= createEntry(self
.tablePanelAutohide
, maxSize
=6, width
=8, text
=PANEL_AUTOHIDE_HEIGHT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
529 self
.registerComponent("autohide_height", self
.panelAutohideHeight
)
531 def createTaskbarWidgets(self
):
532 """Create the Taskbar widgets."""
533 self
.tableTaskbar
= gtk
.Table(rows
=5, columns
=3, homogeneous
=False)
534 self
.tableTaskbar
.set_row_spacings(5)
535 self
.tableTaskbar
.set_col_spacings(5)
537 createLabel(self
.tableTaskbar
, text
="Taskbar Mode", gridX
=0, gridY
=0, xPadding
=10)
538 self
.taskbarMode
= createComboBox(self
.tableTaskbar
, ["single_desktop", "multi_desktop"], gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
539 self
.registerComponent("taskbar_mode", self
.taskbarMode
)
541 createLabel(self
.tableTaskbar
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
542 self
.taskbarPadX
= createEntry(self
.tableTaskbar
, maxSize
=6, width
=8, text
=TASKBAR_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
543 self
.taskbarPadY
= createEntry(self
.tableTaskbar
, maxSize
=6, width
=8, text
=TASKBAR_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
546 createLabel(self
.tableTaskbar
, text
="Horizontal Spacing", gridX
=0, gridY
=2, xPadding
=10)
547 self
.taskbarSpacing
= createEntry(self
.tableTaskbar
, maxSize
=6, width
=8, text
=TASK_SPACING
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
548 self
.registerComponent("taskbar_padding", (self
.taskbarPadX
, self
.taskbarPadY
, self
.taskbarSpacing
))
550 createLabel(self
.tableTaskbar
, text
="Taskbar Background ID", gridX
=0, gridY
=3, xPadding
=10)
551 self
.taskbarBg
= createComboBox(self
.tableTaskbar
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
552 self
.registerComponent("taskbar_background_id", self
.taskbarBg
)
554 createLabel(self
.tableTaskbar
, text
="Active Taskbar Background ID", gridX
=0, gridY
=4, xPadding
=10)
555 self
.taskbarActiveBg
= createComboBox(self
.tableTaskbar
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
556 self
.taskbarActiveBgEnable
= createCheckButton(self
.tableTaskbar
, text
="Enable", active
=False, gridX
=2, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
557 self
.registerComponent("taskbar_active_background_id", self
.taskbarActiveBg
)
559 def createTaskSettingsWidgets(self
):
560 """Create the Task Settings widgets."""
561 self
.tableTask
= gtk
.Table(rows
=12, columns
=3, homogeneous
=False)
562 self
.tableTask
.set_row_spacings(5)
563 self
.tableTask
.set_col_spacings(5)
565 createLabel(self
.tableTask
, text
="Number of 'Blinks' on Urgent Event", gridX
=0, gridY
=0, xPadding
=10)
566 self
.taskBlinks
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_BLINKS
, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
567 self
.registerComponent("urgent_nb_of_blink", self
.taskBlinks
)
569 createLabel(self
.tableTask
, text
="Show Icons", gridX
=0, gridY
=1, xPadding
=10)
570 self
.taskIconCheckButton
= createCheckButton(self
.tableTask
, active
=True, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
571 self
.registerComponent("task_icon", self
.taskIconCheckButton
)
573 createLabel(self
.tableTask
, text
="Show Text", gridX
=0, gridY
=2, xPadding
=10)
574 self
.taskTextCheckButton
= createCheckButton(self
.tableTask
, active
=True, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
575 self
.registerComponent("task_text", self
.taskTextCheckButton
)
577 createLabel(self
.tableTask
, text
="Centre Text", gridX
=0, gridY
=3, xPadding
=10)
578 self
.taskCentreCheckButton
= createCheckButton(self
.tableTask
, active
=True, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
579 self
.registerComponent("task_centered", self
.taskCentreCheckButton
)
581 createLabel(self
.tableTask
, text
="Font", gridX
=0, gridY
=4, xPadding
=10)
582 self
.fontButton
= gtk
.FontButton()
584 if self
.defaults
["font"] in [None, "None"]: # If there was no font specified in the config file
585 self
.defaults
["font"] = self
.fontButton
.get_font_name() # Use the gtk default
587 self
.fontButton
= createFontButton(self
.tableTask
, font
=self
.defaults
["font"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
588 self
.registerComponent("task_font", self
.fontButton
)
590 createLabel(self
.tableTask
, text
="Show Font Shadow", gridX
=0, gridY
=5, xPadding
=10)
591 self
.fontShadowCheckButton
= createCheckButton(self
.tableTask
, active
=False, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
592 self
.registerComponent("font_shadow", self
.fontShadowCheckButton
)
594 createLabel(self
.tableTask
, text
="Maximum Size (x, y)", gridX
=0, gridY
=6, xPadding
=10)
595 self
.taskMaxSizeX
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_MAXIMUM_SIZE_X
, gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
596 self
.taskMaxSizeY
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_MAXIMUM_SIZE_Y
, gridX
=2, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
597 self
.registerComponent("task_maximum_size", (self
.taskMaxSizeX
, self
.taskMaxSizeY
))
599 createLabel(self
.tableTask
, text
="Padding (x, y)", gridX
=0, gridY
=7, xPadding
=10)
600 self
.taskPadX
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_PADDING_X
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
601 self
.taskPadY
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_PADDING_Y
, gridX
=2, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
602 self
.registerComponent("task_padding", (self
.taskPadX
, self
.taskPadY
))
604 def createNormalTasksWidgets(self
):
605 """Create the Normal Tasks widgets."""
606 self
.tableTaskDefault
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
607 self
.tableTaskDefault
.set_row_spacings(5)
608 self
.tableTaskDefault
.set_col_spacings(5)
610 createLabel(self
.tableTaskDefault
, text
="Normal Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
611 self
.taskBg
= createComboBox(self
.tableTaskDefault
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
612 self
.registerComponent("task_background_id", self
.taskBg
)
614 createLabel(self
.tableTaskDefault
, text
="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX
=0, gridY
=1, sizeX
=3, xPadding
=10)
616 createLabel(self
.tableTaskDefault
, text
="Normal Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
617 self
.iconHue
= createEntry(self
.tableTaskDefault
, maxSize
=6, width
=8, text
=ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
620 createLabel(self
.tableTaskDefault
, text
="Normal Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
621 self
.iconSat
= createEntry(self
.tableTaskDefault
, maxSize
=6, width
=8, text
=ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
624 createLabel(self
.tableTaskDefault
, text
="Normal Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
625 self
.iconBri
= createEntry(self
.tableTaskDefault
, maxSize
=6, width
=8, text
=ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
626 self
.registerComponent("task_icon_asb", (self
.iconHue
, self
.iconSat
, self
.iconBri
))
628 createLabel(self
.tableTaskDefault
, text
="Normal Font Color", gridX
=0, gridY
=5, xPadding
=10)
629 self
.fontCol
= createEntry(self
.tableTaskDefault
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontCol")
630 self
.fontCol
.connect("activate", self
.colorTyped
)
631 self
.fontColButton
= createColorButton(self
.tableTaskDefault
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
632 self
.fontCol
.set_text(self
.defaults
["fgColor"])
633 # Add this AFTER we set color to avoid "changed" event
634 self
.fontCol
.connect("changed", self
.changeOccurred
)
635 self
.registerComponent("task_font_color", (self
.fontCol
, self
.fontColButton
))
637 def createActiveTasksWidgets(self
):
638 """Create the Active Tasks widgets."""
639 self
.tableTaskActive
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
640 self
.tableTaskActive
.set_row_spacings(5)
641 self
.tableTaskActive
.set_col_spacings(5)
643 createLabel(self
.tableTaskActive
, text
="Active Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
644 self
.taskActiveBg
= createComboBox(self
.tableTaskActive
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
645 self
.registerComponent("task_active_background_id", self
.taskActiveBg
)
647 createLabel(self
.tableTaskActive
, text
="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX
=0, gridY
=1, sizeX
=3, xPadding
=10)
649 createLabel(self
.tableTaskActive
, text
="Active Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
650 self
.activeIconHue
= createEntry(self
.tableTaskActive
, maxSize
=6, width
=8, text
=ACTIVE_ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
653 createLabel(self
.tableTaskActive
, text
="Active Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
654 self
.activeIconSat
= createEntry(self
.tableTaskActive
, maxSize
=6, width
=8, text
=ACTIVE_ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
657 createLabel(self
.tableTaskActive
, text
="Active Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
658 self
.activeIconBri
= createEntry(self
.tableTaskActive
, maxSize
=6, width
=8, text
=ACTIVE_ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
659 self
.registerComponent("task_active_icon_asb", (self
.activeIconHue
, self
.activeIconSat
, self
.activeIconBri
))
661 createLabel(self
.tableTaskActive
, text
="Active Font Color", gridX
=0, gridY
=5, xPadding
=10)
662 self
.fontActiveCol
= createEntry(self
.tableTaskActive
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontActiveCol")
663 self
.fontActiveCol
.connect("activate", self
.colorTyped
)
664 self
.fontActiveColButton
= createColorButton(self
.tableTaskActive
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontActiveCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
665 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
666 # Add this AFTER we set color to avoid "changed" event
667 self
.fontActiveCol
.connect("changed", self
.changeOccurred
)
668 self
.registerComponent("task_active_font_color", (self
.fontActiveCol
, self
.fontActiveColButton
))
670 def createUrgentTasksWidgets(self
):
671 """Create the Urgent Tasks widgets."""
672 self
.tableTaskUrgent
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
673 self
.tableTaskUrgent
.set_row_spacings(5)
674 self
.tableTaskUrgent
.set_col_spacings(5)
676 createLabel(self
.tableTaskUrgent
, text
="Urgent Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
677 self
.taskUrgentBg
= createComboBox(self
.tableTaskUrgent
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
678 self
.registerComponent("task_urgent_background_id", self
.taskUrgentBg
)
680 createLabel(self
.tableTaskUrgent
, text
="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX
=0, gridY
=1, sizeX
=3, xPadding
=10)
682 createLabel(self
.tableTaskUrgent
, text
="Urgent Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
683 self
.urgentIconHue
= createEntry(self
.tableTaskUrgent
, maxSize
=6, width
=8, text
=URGENT_ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
686 createLabel(self
.tableTaskUrgent
, text
="Urgent Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
687 self
.urgentIconSat
= createEntry(self
.tableTaskUrgent
, maxSize
=6, width
=8, text
=URGENT_ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
690 createLabel(self
.tableTaskUrgent
, text
="Urgent Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
691 self
.urgentIconBri
= createEntry(self
.tableTaskUrgent
, maxSize
=6, width
=8, text
=URGENT_ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
692 self
.registerComponent("task_urgent_icon_asb", (self
.urgentIconHue
, self
.urgentIconSat
, self
.urgentIconBri
))
694 createLabel(self
.tableTaskUrgent
, text
="Urgent Font Color", gridX
=0, gridY
=5, xPadding
=10)
695 self
.fontUrgentCol
= createEntry(self
.tableTaskUrgent
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontUrgentCol")
696 self
.fontUrgentCol
.connect("activate", self
.colorTyped
)
697 self
.fontUrgentColButton
= createColorButton(self
.tableTaskUrgent
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontUrgentCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
698 self
.fontUrgentCol
.set_text(self
.defaults
["fgColor"])
699 # Add this AFTER we set color to avoid "changed" event
700 self
.fontUrgentCol
.connect("changed", self
.changeOccurred
)
701 self
.registerComponent("task_urgent_font_color", (self
.fontUrgentCol
, self
.fontUrgentColButton
))
703 def createIconifiedTasksWidgets(self
):
704 """Create the Iconified Tasks widgets."""
705 self
.tableTaskIconified
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
706 self
.tableTaskIconified
.set_row_spacings(5)
707 self
.tableTaskIconified
.set_col_spacings(5)
709 createLabel(self
.tableTaskIconified
, text
="Iconified Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
710 self
.taskIconifiedBg
= createComboBox(self
.tableTaskIconified
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
711 self
.registerComponent("task_iconified_background_id", self
.taskIconifiedBg
)
713 createLabel(self
.tableTaskIconified
, text
="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX
=0, gridY
=1, sizeX
=3, xPadding
=10)
715 createLabel(self
.tableTaskIconified
, text
="Iconified Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
716 self
.iconifiedIconHue
= createEntry(self
.tableTaskIconified
, maxSize
=6, width
=8, text
=ICONIFIED_ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
719 createLabel(self
.tableTaskIconified
, text
="Iconified Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
720 self
.iconifiedIconSat
= createEntry(self
.tableTaskIconified
, maxSize
=6, width
=8, text
=ICONIFIED_ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
723 createLabel(self
.tableTaskIconified
, text
="Iconified Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
724 self
.iconifiedIconBri
= createEntry(self
.tableTaskIconified
, maxSize
=6, width
=8, text
=ICONIFIED_ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
725 self
.registerComponent("task_iconified_icon_asb", (self
.iconifiedIconHue
, self
.iconifiedIconSat
, self
.iconifiedIconBri
))
727 createLabel(self
.tableTaskIconified
, text
="Iconified Font Color", gridX
=0, gridY
=5, xPadding
=10)
728 self
.fontIconifiedCol
= createEntry(self
.tableTaskIconified
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontIconifiedCol")
729 self
.fontIconifiedCol
.connect("activate", self
.colorTyped
)
730 self
.fontIconifiedColButton
= createColorButton(self
.tableTaskIconified
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontIconifiedCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
731 self
.fontIconifiedCol
.set_text(self
.defaults
["fgColor"])
732 # Add this AFTER we set color to avoid "changed" event
733 self
.fontIconifiedCol
.connect("changed", self
.changeOccurred
)
734 self
.registerComponent("task_iconified_font_color", (self
.fontIconifiedCol
, self
.fontIconifiedColButton
))
736 def createSystemTrayWidgets(self
):
737 """Create the System Tray widgets."""
738 self
.tableTray
= gtk
.Table(rows
=9, columns
=3, homogeneous
=False)
739 self
.tableTray
.set_row_spacings(5)
740 self
.tableTray
.set_col_spacings(5)
742 createLabel(self
.tableTray
, text
="Show System Tray", gridX
=0, gridY
=0, xPadding
=10)
743 self
.trayShow
= createCheckButton(self
.tableTray
, active
=True, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
744 self
.registerComponent("systray", self
.trayShow
)
746 createLabel(self
.tableTray
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
747 self
.trayPadX
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
748 self
.trayPadY
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
751 createLabel(self
.tableTray
, text
="Horizontal Spacing", gridX
=0, gridY
=2, xPadding
=10)
752 self
.traySpacing
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_SPACING
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
753 self
.registerComponent("systray_padding", (self
.trayPadX
, self
.trayPadY
, self
.traySpacing
))
755 createLabel(self
.tableTray
, text
="System Tray Background ID", gridX
=0, gridY
=3, xPadding
=10)
756 self
.trayBg
= createComboBox(self
.tableTray
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
757 self
.registerComponent("systray_background_id", self
.trayBg
)
759 createLabel(self
.tableTray
, text
="Icon Ordering", gridX
=0, gridY
=4, xPadding
=10)
760 self
.trayOrder
= createComboBox(self
.tableTray
, ["ascending", "descending", "left2right", "right2left"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
761 self
.registerComponent("systray_sort", self
.trayOrder
)
763 createLabel(self
.tableTray
, text
="Maximum Icon Size (0 for automatic size)", gridX
=0, gridY
=5, xPadding
=10)
764 self
.trayMaxIconSize
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_MAX_ICON_SIZE
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
765 self
.registerComponent("systray_icon_size", self
.trayMaxIconSize
)
767 createLabel(self
.tableTray
, text
="System Tray Icon Alpha (0 to 100)", gridX
=0, gridY
=6, xPadding
=10)
768 self
.trayIconHue
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_ICON_ALPHA
, gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
771 createLabel(self
.tableTray
, text
="System Tray Icon Saturation (-100 to 100)", gridX
=0, gridY
=7, xPadding
=10)
772 self
.trayIconSat
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_ICON_SAT
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
775 createLabel(self
.tableTray
, text
="System Tray Icon Brightness (-100 to 100)", gridX
=0, gridY
=8, xPadding
=10)
776 self
.trayIconBri
= createEntry(self
.tableTray
, maxSize
=6, width
=8, text
=TRAY_ICON_BRI
, gridX
=1, gridY
=8, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
777 self
.registerComponent("systray_icon_asb", (self
.trayIconHue
, self
.trayIconSat
, self
.trayIconBri
))
779 def createClockDisplayWidgets(self
):
780 """Create the Clock Display widgets."""
781 self
.tableClockDisplays
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
782 self
.tableClockDisplays
.set_row_spacings(5)
783 self
.tableClockDisplays
.set_col_spacings(5)
785 createLabel(self
.tableClockDisplays
, text
="Show", gridX
=0, gridY
=0, xPadding
=10)
786 self
.clockCheckButton
= createCheckButton(self
.tableClockDisplays
, active
=True, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
788 createLabel(self
.tableClockDisplays
, text
="Time 1 Format", gridX
=0, gridY
=1, xPadding
=10)
789 self
.clock1Format
= createEntry(self
.tableClockDisplays
, maxSize
=50, width
=20, text
=CLOCK_FMT_1
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
790 self
.clock1CheckButton
= createCheckButton(self
.tableClockDisplays
, text
="Show", active
=True, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
791 self
.registerComponent("time1_format", self
.clock1Format
)
793 createLabel(self
.tableClockDisplays
, text
="Time 1 Font", gridX
=0, gridY
=2, xPadding
=10)
794 self
.clock1FontButton
= createFontButton(self
.tableClockDisplays
, font
=self
.defaults
["font"], gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
795 self
.registerComponent("time1_font", self
.clock1FontButton
)
797 createLabel(self
.tableClockDisplays
, text
="Time 2 Format", gridX
=0, gridY
=3, xPadding
=10)
798 self
.clock2Format
= createEntry(self
.tableClockDisplays
, maxSize
=50, width
=20, text
=CLOCK_FMT_2
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
799 self
.clock2CheckButton
= createCheckButton(self
.tableClockDisplays
, text
="Show", active
=True, gridX
=2, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
800 self
.registerComponent("time2_format", self
.clock2Format
)
802 createLabel(self
.tableClockDisplays
, text
="Time 2 Font", gridX
=0, gridY
=4, xPadding
=10)
803 self
.clock2FontButton
= createFontButton(self
.tableClockDisplays
, font
=self
.defaults
["font"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
804 self
.registerComponent("time2_font", self
.clock2FontButton
)
806 createLabel(self
.tableClockDisplays
, text
="Tooltip Format", gridX
=0, gridY
=5, xPadding
=10)
807 self
.clockTooltipFormat
= createEntry(self
.tableClockDisplays
, maxSize
=50, width
=20, text
=CLOCK_TOOLTIP
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
808 self
.clockTooltipCheckButton
= createCheckButton(self
.tableClockDisplays
, text
="Show", active
=True, gridX
=2, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
809 self
.registerComponent("clock_tooltip", self
.clockTooltipFormat
)
811 self
.clockArea
= gtk
.ScrolledWindow()
812 self
.clockBuf
= gtk
.TextBuffer()
813 self
.clockTextView
= gtk
.TextView(self
.clockBuf
)
814 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")
815 self
.clockTextView
.set_editable(False)
816 self
.clockArea
.add_with_viewport(self
.clockTextView
)
817 self
.tableClockDisplays
.attach(self
.clockArea
, 0, 3, 6, 7, xpadding
=10)
819 def createClockSettingsWidgets(self
):
820 """Create the Clock Settings widgets."""
821 self
.tableClockSettings
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
822 self
.tableClockSettings
.set_row_spacings(5)
823 self
.tableClockSettings
.set_col_spacings(5)
825 createLabel(self
.tableClockSettings
, text
="Clock Font Color", gridX
=0, gridY
=0, xPadding
=10)
826 self
.clockFontCol
= createEntry(self
.tableClockSettings
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=None, name
="clockFontCol")
827 self
.clockFontCol
.connect("activate", self
.colorTyped
)
828 self
.clockFontColButton
= createColorButton(self
.tableClockSettings
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="clockFontCol", gridX
=2, gridY
=0, handler
=self
.colorChange
)
829 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
830 # Add this AFTER we set color to avoid "changed" event
831 self
.clockFontCol
.connect("changed", self
.changeOccurred
)
832 self
.registerComponent("clock_font_color", (self
.clockFontCol
, self
.clockFontColButton
))
834 createLabel(self
.tableClockSettings
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
835 self
.clockPadX
= createEntry(self
.tableClockSettings
, maxSize
=6, width
=8, text
=CLOCK_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
836 self
.clockPadY
= createEntry(self
.tableClockSettings
, maxSize
=6, width
=8, text
=CLOCK_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
837 self
.registerComponent("clock_padding", (self
.clockPadX
, self
.clockPadY
))
839 createLabel(self
.tableClockSettings
, text
="Clock Background ID", gridX
=0, gridY
=2, xPadding
=10)
840 self
.clockBg
= createComboBox(self
.tableClockSettings
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
841 self
.registerComponent("clock_background_id", self
.clockBg
)
843 createLabel(self
.tableClockSettings
, text
="Left Click Command", gridX
=0, gridY
=3, xPadding
=10)
844 self
.clockLClick
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_LCLICK
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
845 self
.registerComponent("clock_lclick_command", self
.clockLClick
)
847 createLabel(self
.tableClockSettings
, text
="Right Click Command", gridX
=0, gridY
=4, xPadding
=10)
848 self
.clockRClick
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_RCLICK
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
849 self
.registerComponent("clock_rclick_command", self
.clockRClick
)
851 createLabel(self
.tableClockSettings
, text
="Time 1 Timezone", gridX
=0, gridY
=5, xPadding
=10)
852 self
.clockTime1Timezone
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_TIME1_TIMEZONE
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
853 self
.clockTimezone1CheckButton
= createCheckButton(self
.tableClockSettings
, text
="Enable", active
=False, gridX
=2, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
854 self
.registerComponent("time1_timezone", self
.clockTime1Timezone
)
856 createLabel(self
.tableClockSettings
, text
="Time 2 Timezone", gridX
=0, gridY
=6, xPadding
=10)
857 self
.clockTime2Timezone
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_TIME2_TIMEZONE
, gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
858 self
.clockTimezone2CheckButton
= createCheckButton(self
.tableClockSettings
, text
="Enable", active
=False, gridX
=2, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
859 self
.registerComponent("time2_timezone", self
.clockTime2Timezone
)
861 createLabel(self
.tableClockSettings
, text
="Tooltip Timezone", gridX
=0, gridY
=7, xPadding
=10)
862 self
.clockTooltipTimezone
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_TOOLTIP_TIMEZONE
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
863 self
.clockTimezoneTooltipCheckButton
= createCheckButton(self
.tableClockSettings
, text
="Enable", active
=False, gridX
=2, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
864 self
.registerComponent("clock_tooltip_timezone", self
.clockTooltipTimezone
)
866 def createMouseWidgets(self
):
867 """Creates the Mouse widgets."""
868 self
.tableMouse
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
869 self
.tableMouse
.set_row_spacings(5)
870 self
.tableMouse
.set_col_spacings(5)
872 mouseCmds
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore", "desktop_left", "desktop_right", "next_task", "prev_task"]
874 createLabel(self
.tableMouse
, text
="Middle Mouse Click Action", gridX
=0, gridY
=0, xPadding
=10)
875 self
.mouseMiddle
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
876 self
.registerComponent("mouse_middle", self
.mouseMiddle
)
878 createLabel(self
.tableMouse
, text
="Right Mouse Click Action", gridX
=0, gridY
=1, xPadding
=10)
879 self
.mouseRight
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=1, handler
=self
.changeOccurred
)
880 self
.registerComponent("mouse_right", self
.mouseRight
)
882 createLabel(self
.tableMouse
, text
="Mouse Wheel Scroll Up Action", gridX
=0, gridY
=2, xPadding
=10)
883 self
.mouseUp
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
884 self
.registerComponent("mouse_scroll_up", self
.mouseUp
)
886 createLabel(self
.tableMouse
, text
="Mouse Wheel Scroll Down Action", gridX
=0, gridY
=3, xPadding
=10)
887 self
.mouseDown
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
888 self
.registerComponent("mouse_scroll_down", self
.mouseDown
)
890 def createTooltipsWidgets(self
):
891 """Creates the Tooltips widgets."""
892 self
.tableTooltip
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
893 self
.tableTooltip
.set_row_spacings(5)
894 self
.tableTooltip
.set_col_spacings(5)
896 createLabel(self
.tableTooltip
, text
="Show Tooltips", gridX
=0, gridY
=0, xPadding
=10)
897 self
.tooltipShow
= createCheckButton(self
.tableTooltip
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
898 self
.registerComponent("tooltip", self
.tooltipShow
)
900 createLabel(self
.tableTooltip
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
901 self
.tooltipPadX
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
902 self
.tooltipPadY
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
903 self
.registerComponent("tooltip_padding", (self
.tooltipPadX
, self
.tooltipPadY
))
905 createLabel(self
.tableTooltip
, text
="Tooltip Show Timeout (seconds)", gridX
=0, gridY
=2, xPadding
=10)
906 self
.tooltipShowTime
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_SHOW_TIMEOUT
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
907 self
.registerComponent("tooltip_show_timeout", self
.tooltipShowTime
)
909 createLabel(self
.tableTooltip
, text
="Tooltip Hide Timeout (seconds)", gridX
=0, gridY
=3, xPadding
=10)
910 self
.tooltipHideTime
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_HIDE_TIMEOUT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
911 self
.registerComponent("tooltip_hide_timeout", self
.tooltipHideTime
)
913 createLabel(self
.tableTooltip
, text
="Tooltip Background ID", gridX
=0, gridY
=4, xPadding
=10)
914 self
.tooltipBg
= createComboBox(self
.tableTooltip
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
915 self
.registerComponent("tooltip_background_id", self
.tooltipBg
)
917 createLabel(self
.tableTooltip
, text
="Tooltip Font", gridX
=0, gridY
=5, xPadding
=10)
918 self
.tooltipFont
= createFontButton(self
.tableTooltip
, font
=self
.defaults
["font"], gridX
=1, gridY
=5, handler
=self
.changeOccurred
)
919 self
.registerComponent("tooltip_font", self
.tooltipFont
)
921 createLabel(self
.tableTooltip
, text
="Tooltip Font Color", gridX
=0, gridY
=6, xPadding
=10)
922 self
.tooltipFontCol
= createEntry(self
.tableTooltip
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=None, name
="tooltipFontCol")
923 self
.tooltipFontCol
.connect("activate", self
.colorTyped
)
924 self
.tooltipFontColButton
= createColorButton(self
.tableTooltip
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="tooltipFontCol", gridX
=2, gridY
=6, handler
=self
.colorChange
)
925 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
926 # Add this AFTER we set color to avoid "changed" event
927 self
.tooltipFontCol
.connect("changed", self
.changeOccurred
)
928 self
.registerComponent("tooltip_font_color", (self
.tooltipFontCol
, self
.tooltipFontColButton
))
930 def createBatteryWidgets(self
):
931 """Creates the Battery widgets."""
932 self
.tableBattery
= gtk
.Table(rows
=8, columns
=3, homogeneous
=False)
933 self
.tableBattery
.set_row_spacings(5)
934 self
.tableBattery
.set_col_spacings(5)
936 createLabel(self
.tableBattery
, text
="Show Battery Applet", gridX
=0, gridY
=0, xPadding
=10)
937 self
.batteryCheckButton
= createCheckButton(self
.tableBattery
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
938 self
.registerComponent("battery", self
.batteryCheckButton
)
940 createLabel(self
.tableBattery
, text
="Battery Low Status (%)", gridX
=0, gridY
=1, xPadding
=10)
941 self
.batteryLow
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_LOW
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
942 self
.registerComponent("battery_low_status", self
.batteryLow
)
944 createLabel(self
.tableBattery
, text
="Battery Low Action", gridX
=0, gridY
=2, xPadding
=10)
945 self
.batteryLowAction
= createEntry(self
.tableBattery
, maxSize
=150, width
=32, text
=BATTERY_ACTION
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
946 self
.registerComponent("battery_low_cmd", self
.batteryLowAction
)
948 createLabel(self
.tableBattery
, text
="Battery Hide (0 to 100)", gridX
=0, gridY
=3, xPadding
=10)
949 self
.batteryHide
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_HIDE
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
950 self
.registerComponent("battery_hide", self
.batteryHide
)
952 createLabel(self
.tableBattery
, text
="Battery 1 Font", gridX
=0, gridY
=4, xPadding
=10)
953 self
.bat1FontButton
= createFontButton(self
.tableBattery
, font
=self
.defaults
["font"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
954 self
.registerComponent("bat1_font", self
.bat1FontButton
)
956 createLabel(self
.tableBattery
, text
="Battery 2 Font", gridX
=0, gridY
=5, xPadding
=10)
957 self
.bat2FontButton
= createFontButton(self
.tableBattery
, font
=self
.defaults
["font"], gridX
=1, gridY
=5, handler
=self
.changeOccurred
)
958 self
.registerComponent("bat2_font", self
.bat2FontButton
)
960 createLabel(self
.tableBattery
, text
="Battery Font Color", gridX
=0, gridY
=6, xPadding
=10)
961 self
.batteryFontCol
= createEntry(self
.tableBattery
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=None, name
="batteryFontCol")
962 self
.batteryFontCol
.connect("activate", self
.colorTyped
)
963 self
.batteryFontColButton
= createColorButton(self
.tableBattery
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="batteryFontCol", gridX
=2, gridY
=6, handler
=self
.colorChange
)
964 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
965 # Add this AFTER we set color to avoid "changed" event
966 self
.batteryFontCol
.connect("changed", self
.changeOccurred
)
967 self
.registerComponent("battery_font_color", (self
.batteryFontCol
, self
.batteryFontColButton
))
969 createLabel(self
.tableBattery
, text
="Padding (x, y)", gridX
=0, gridY
=7, xPadding
=10)
970 self
.batteryPadX
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_PADDING_X
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
971 self
.batteryPadY
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_PADDING_Y
, gridX
=2, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
972 self
.registerComponent("battery_padding", (self
.batteryPadX
, self
.batteryPadY
))
974 createLabel(self
.tableBattery
, text
="Battery Background ID", gridX
=0, gridY
=8, xPadding
=10)
975 self
.batteryBg
= createComboBox(self
.tableBattery
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=8, handler
=self
.changeOccurred
)
976 self
.registerComponent("battery_background_id", self
.batteryBg
)
978 def registerComponent(self
, configProperty
, component
):
979 """Registers a component with a particular property from
980 a tint2 config. Note: a component may be a double or
981 triple if that property has more than one value associated
983 self
.propUI
[configProperty
] = component
985 def getComponent(self
, configProperty
):
986 """Fetches the component associated with a tint2 property."""
987 return self
.propUI
[configProperty
] if configProperty
in self
.propUI
else None
989 def about(self
, action
=None):
990 """Displays the About dialog."""
991 about
= gtk
.AboutDialog()
992 about
.set_program_name(NAME
)
993 about
.set_version(VERSION
)
994 about
.set_authors(AUTHORS
)
995 about
.set_comments(COMMENTS
)
996 about
.set_website(WEBSITE
)
997 gtk
.about_dialog_set_url_hook(self
.aboutLinkCallback
)
1001 def aboutLinkCallback(dialog
, link
, data
=None):
1002 """Callback for when a URL is clicked in an About dialog."""
1004 webbrowser
.open(link
)
1006 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit %s" % link
)
1009 """Adds a new background to the list of backgrounds."""
1010 self
.bgs
+= [gtk
.Table(4, 3, False)]
1012 createLabel(self
.bgs
[-1], text
="Corner Rounding (px)", gridX
=0, gridY
=0, xPadding
=10)
1013 createEntry(self
.bgs
[-1], maxSize
=7, width
=9, text
=BG_ROUNDING
, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
, name
="rounded")
1015 createLabel(self
.bgs
[-1], text
="Background Color", gridX
=0, gridY
=1, xPadding
=10)
1017 temp
.set_width_chars(9)
1018 temp
.set_name("bgColEntry")
1019 temp
.set_text(self
.defaults
["bgColor"])
1020 temp
.connect("changed", self
.changeOccurred
)
1021 temp
.connect("activate", self
.colorTyped
)
1022 self
.bgs
[-1].attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1023 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["bgColor"]))
1024 temp
.set_use_alpha(True)
1025 temp
.set_name("bgCol")
1026 temp
.connect("color-set", self
.colorChange
)
1027 self
.bgs
[-1].attach(temp
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1029 createLabel(self
.bgs
[-1], text
="Border Width (px)", gridX
=0, gridY
=2, xPadding
=10)
1030 createEntry(self
.bgs
[-1], maxSize
=7, width
=9, text
=BG_BORDER
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
, name
="border")
1032 createLabel(self
.bgs
[-1], text
="Border Color", gridX
=0, gridY
=3, xPadding
=10)
1034 temp
.set_width_chars(9)
1035 temp
.set_name("borderColEntry")
1036 temp
.connect("activate", self
.colorTyped
)
1037 temp
.set_text(self
.defaults
["borderColor"])
1038 temp
.connect("changed", self
.changeOccurred
)
1039 self
.bgs
[-1].attach(temp
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
1040 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["borderColor"]))
1041 temp
.set_use_alpha(True)
1042 temp
.set_name("borderCol")
1043 temp
.connect("color-set", self
.colorChange
)
1044 self
.bgs
[-1].attach(temp
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1046 # Note: Only set init to True when initialising background styles.
1047 # This prevents unwanted calls to changeOccurred()
1048 def addBgClick(self
, widget
=None, init
=False):
1049 """Creates a new background and adds a new tab to the notebook."""
1050 n
= self
.bgNotebook
.get_n_pages()
1052 if n
> (self
.defaults
["bgCount"] + 2):
1053 if confirmDialog(self
, "You already have %d background styles. Are you sure you would like another?" % n
) == gtk
.RESPONSE_NO
:
1058 newId
= len(self
.bgs
)
1060 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1062 self
.bgNotebook
.show_all()
1064 self
.updateComboBoxes(n
, "add")
1066 self
.bgNotebook
.set_current_page(n
)
1069 self
.changeOccurred()
1071 def addBgDefs(self
, bgDefs
):
1072 """Add interface elements for a list of background style definitions. bgDefs
1073 should be a list containing dictionaries with the following keys: rounded,
1074 border_width, background_color, border_color"""
1078 for child
in self
.bgs
[-1].get_children():
1079 if child
.get_name() == "rounded":
1080 child
.set_text(d
["rounded"])
1081 elif child
.get_name() == "border":
1082 child
.set_text(d
["border_width"])
1083 elif child
.get_name() == "bgColEntry":
1084 child
.set_text(d
["background_color"].split(" ")[0].strip())
1086 elif child
.get_name() == "borderColEntry":
1087 child
.set_text(d
["border_color"].split(" ")[0].strip())
1089 elif child
.get_name() == "bgCol":
1090 list = d
["background_color"].split(" ")
1092 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1094 child
.set_alpha(65535)
1095 elif child
.get_name() == "borderCol":
1096 list = d
["border_color"].split(" ")
1098 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1100 child
.set_alpha(65535)
1102 newId
= len(self
.bgs
)
1104 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1106 self
.bgNotebook
.show_all()
1108 self
.updateComboBoxes(newId
-1, "add")
1110 self
.bgNotebook
.set_current_page(newId
)
1112 def apply(self
, widget
, event
=None, confirmChange
=True):
1113 """Applies the current config to tint2."""
1114 # Check if tint2 is running
1115 procs
= os
.popen('pidof "tint2"') # Check list of active processes for tint2
1116 pids
= [] # List of process ids for tint2
1118 for proc
in procs
.readlines():
1119 pids
+= [int(proc
.strip().split(" ")[0])]
1123 if self
.oneConfigFile
:
1124 # Save and copy as default
1126 tmpSrc
= self
.filename
1127 tmpDest
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1129 shutil
.copyfile(tmpSrc
, tmpDest
)
1130 except shutil
.Error
:
1132 # Ask tint2 to reload config
1134 os
.kill(pid
, signal
.SIGUSR1
)
1136 if confirmDialog(self
, "This will terminate all currently running instances of tint2 before applying config. Continue?") == gtk
.RESPONSE_YES
:
1140 #shutil.copyfile(self.filename, self.filename+".backup") # Create backup
1142 # If it is - kill it
1144 os
.kill(pid
, signal
.SIGTERM
)
1147 os
.spawnv(os
.P_NOWAIT
, self
.tint2Bin
, [self
.tint2Bin
, "-c", self
.filename
])
1149 if confirmChange
and self
.filename
!= (os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc") and confirmDialog(self
, "Use this as default tint2 config?") == gtk
.RESPONSE_YES
:
1151 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1153 shutil
.copyfile(tmp
, self
.filename
)
1154 except shutil
.Error
:
1157 #if confirmChange and confirmDialog(self, "Keep this config?") == gtk.RESPONSE_NO:
1158 # shutil.copyfile(self.filename+".backup", self.filename) # Create backup
1159 # self.apply(widget, event, False)
1161 def changeAllFonts(self
, widget
):
1162 """Changes all fonts at once."""
1163 dialog
= gtk
.FontSelectionDialog("Select Font")
1165 dialog
.set_font_name(self
.defaults
["font"])
1167 if dialog
.run() == gtk
.RESPONSE_OK
:
1168 newFont
= dialog
.get_font_name()
1170 self
.clock1FontButton
.set_font_name(newFont
)
1171 self
.clock2FontButton
.set_font_name(newFont
)
1172 self
.bat1FontButton
.set_font_name(newFont
)
1173 self
.bat2FontButton
.set_font_name(newFont
)
1174 self
.fontButton
.set_font_name(newFont
)
1178 self
.generateConfig()
1179 self
.changeOccurred()
1181 def changeDefaults(self
, widget
=None):
1182 """Shows the style preferences widget."""
1183 TintWizardPrefGUI(self
)
1185 def changeOccurred(self
, widget
=None):
1186 """Called when the user changes something, i.e. entry value"""
1189 self
.updateStatusBar(change
=True)
1191 if widget
== self
.panelOrientation
:
1192 if self
.panelOrientation
.get_active_text() == "horizontal":
1193 self
.panelSizeLabel
.set_text("Size (width, height)")
1195 self
.panelSizeLabel
.set_text("Size (height, width)")
1197 def colorChange(self
, widget
):
1198 """Update the text entry when a color button is updated."""
1199 r
= widget
.get_color().red
1200 g
= widget
.get_color().green
1201 b
= widget
.get_color().blue
1203 label
= self
.getColorLabel(widget
)
1209 label
.set_text(rgbToHex(r
, g
, b
))
1211 self
.changeOccurred()
1213 def colorTyped(self
, widget
):
1214 """Update the color button when a valid value is typed into the entry."""
1215 s
= widget
.get_text()
1217 # The color button associated with this widget.
1218 colorButton
= self
.getColorButton(widget
)
1220 # Just a precautionary check - this situation should never arise.
1222 #print "Error in colorTyped() -- unrecognised entry widget."
1225 # If the entered value is invalid, set textbox to the current
1226 # hex value of the associated color button.
1227 buttonHex
= self
.getHexFromWidget(colorButton
)
1230 errorDialog(self
, "Invalid color specification: [%s]" % s
)
1231 widget
.set_text(buttonHex
)
1235 col
= gtk
.gdk
.Color(s
)
1237 errorDialog(self
, "Invalid color specification: [%s]" % s
)
1238 widget
.set_text(buttonHex
)
1241 colorButton
.set_color(col
)
1243 # Note: only set init to True when removing backgrounds for a new config
1244 # This prevents unwanted calls to changeOccurred()
1245 def delBgClick(self
, widget
=None, prompt
=True, init
=False):
1246 """Deletes the selected background after confirming with the user."""
1247 selected
= self
.bgNotebook
.get_current_page()
1249 if selected
== -1: # Nothing to remove
1253 if confirmDialog(self
, "Remove this background?") != gtk
.RESPONSE_YES
:
1256 self
.bgNotebook
.remove_page(selected
)
1257 self
.bgs
.pop(selected
)
1259 for i
in range(self
.bgNotebook
.get_n_pages()):
1260 self
.bgNotebook
.set_tab_label_text(self
.bgNotebook
.get_nth_page(i
), "Background ID %d" % (i
+1))
1262 self
.bgNotebook
.show_all()
1264 self
.updateComboBoxes(len(self
.bgs
) + 1, "remove")
1267 self
.changeOccurred()
1269 def generateConfig(self
):
1270 """Reads values from each widget and generates a config."""
1271 self
.configBuf
.delete(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter())
1272 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Tint2 config file\n")
1273 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Generated by tintwizard (http://code.google.com/p/tintwizard/)\n")
1274 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure\n\n")
1275 if not self
.oneConfigFile
:
1276 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# To use this as default tint2 config: save as $HOME/.config/tint2/tint2rc\n\n")
1278 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Background definitions\n")
1279 for i
in range(len(self
.bgs
)):
1280 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# ID %d\n" % (i
+ 1))
1282 for child
in self
.bgs
[i
].get_children():
1283 if child
.get_name() == "rounded":
1284 rounded
= child
.get_text() if child
.get_text() else BG_ROUNDING
1285 elif child
.get_name() == "border":
1286 borderW
= child
.get_text() if child
.get_text() else BG_BORDER
1287 elif child
.get_name() == "bgCol":
1288 bgCol
= self
.getHexFromWidget(child
)
1289 bgAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1290 elif child
.get_name() == "borderCol":
1291 borderCol
= self
.getHexFromWidget(child
)
1292 borderAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1294 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "rounded = %s\n" % (rounded
))
1295 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_width = %s\n" % (borderW
))
1296 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "background_color = %s %d\n" % (bgCol
, bgAlpha
))
1297 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_color = %s %d\n\n" % (borderCol
, borderAlpha
))
1299 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Panel\n")
1300 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_monitor = %s\n" % (self
.panelMonitor
.get_text() if self
.panelMonitor
.get_text() else PANEL_MONITOR
))
1301 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()))
1302 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
,
1303 self
.panelSizeY
.get_text() if self
.panelSizeY
.get_text() else PANEL_SIZE_Y
))
1304 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
,
1305 self
.panelMarginY
.get_text() if self
.panelMarginY
.get_text() else PANEL_MARGIN_Y
))
1306 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_padding = %s %s %s\n" % (self
.panelPadX
.get_text() if self
.panelPadX
.get_text() else PANEL_PADDING_X
,
1307 self
.panelPadY
.get_text() if self
.panelPadY
.get_text() else PANEL_PADDING_Y
,
1308 self
.panelSpacing
.get_text() if self
.panelSpacing
.get_text() else TASKBAR_SPACING
))
1309 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_dock = %s\n" % int(self
.panelDock
.get_active()))
1310 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "wm_menu = %s\n" % int(self
.panelMenu
.get_active()))
1311 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_layer = %s\n" % (self
.panelLayer
.get_active_text()))
1312 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_background_id = %s\n" % (self
.panelBg
.get_active()))
1314 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Panel Autohide\n")
1315 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "autohide = %s\n" % int(self
.panelAutohide
.get_active()))
1316 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "autohide_show_timeout = %s\n" % (self
.panelAutohideShow
.get_text() if self
.panelAutohideShow
.get_text() else PANEL_AUTOHIDE_SHOW
))
1317 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "autohide_hide_timeout = %s\n" % (self
.panelAutohideHide
.get_text() if self
.panelAutohideHide
.get_text() else PANEL_AUTOHIDE_HIDE
))
1318 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "autohide_height = %s\n" % (self
.panelAutohideHeight
.get_text() if self
.panelAutohideHeight
.get_text() else PANEL_AUTOHIDE_HEIGHT
))
1319 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "strut_policy = %s\n" % (self
.panelAutohideStrut
.get_active_text() if self
.panelAutohideStrut
.get_active_text() else PANEL_AUTOHIDE_STRUT
))
1321 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Taskbar\n")
1322 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_mode = %s\n" % (self
.taskbarMode
.get_active_text()))
1323 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
,
1324 self
.taskbarPadY
.get_text() if self
.taskbarPadY
.get_text() else TASKBAR_PADDING_X
,
1325 self
.taskbarSpacing
.get_text() if self
.taskbarSpacing
.get_text() else TASK_SPACING
))
1326 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_background_id = %s\n" % (self
.taskbarBg
.get_active()))
1327 # Comment out the taskbar_active_background_id if user has "disabled" it
1328 if self
.taskbarActiveBgEnable
.get_active() == 0:
1329 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "#")
1330 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_active_background_id = %s\n" % (self
.taskbarActiveBg
.get_active()))
1332 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tasks\n")
1333 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
))
1334 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_icon = %s\n" % int(self
.taskIconCheckButton
.get_active()))
1335 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_text = %s\n" % int(self
.taskTextCheckButton
.get_active()))
1336 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_centered = %s\n" % int(self
.taskCentreCheckButton
.get_active()))
1337 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
))
1338 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
,
1339 self
.taskPadY
.get_text() if self
.taskPadY
.get_text() else TASK_PADDING_Y
))
1340 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_background_id = %s\n" % (self
.taskBg
.get_active()))
1341 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_background_id = %s\n" % (self
.taskActiveBg
.get_active()))
1342 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_urgent_background_id = %s\n" % (self
.taskUrgentBg
.get_active()))
1343 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_iconified_background_id = %s\n" % (self
.taskIconifiedBg
.get_active()))
1345 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Task Icons\n")
1346 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
,
1347 self
.iconSat
.get_text() if self
.iconSat
.get_text() else ICON_SAT
,
1348 self
.iconBri
.get_text() if self
.iconBri
.get_text() else ICON_BRI
))
1349 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
,
1350 self
.activeIconSat
.get_text() if self
.activeIconSat
.get_text() else ACTIVE_ICON_SAT
,
1351 self
.activeIconBri
.get_text() if self
.activeIconBri
.get_text() else ACTIVE_ICON_BRI
))
1352 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_urgent_icon_asb = %s %s %s\n" % (self
.urgentIconHue
.get_text() if self
.urgentIconHue
.get_text() else URGENT_ICON_ALPHA
,
1353 self
.urgentIconSat
.get_text() if self
.urgentIconSat
.get_text() else URGENT_ICON_SAT
,
1354 self
.urgentIconBri
.get_text() if self
.urgentIconBri
.get_text() else URGENT_ICON_BRI
))
1355 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_iconified_icon_asb = %s %s %s\n" % (self
.iconifiedIconHue
.get_text() if self
.iconifiedIconHue
.get_text() else ICONIFIED_ICON_ALPHA
,
1356 self
.iconifiedIconSat
.get_text() if self
.iconifiedIconSat
.get_text() else ICONIFIED_ICON_SAT
,
1357 self
.iconifiedIconBri
.get_text() if self
.iconifiedIconBri
.get_text() else ICONIFIED_ICON_BRI
))
1359 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Fonts\n")
1360 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font = %s\n" % (self
.fontButton
.get_font_name()))
1361 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontColButton
),
1362 int(self
.fontColButton
.get_alpha() / 65535.0 * 100)))
1363 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontActiveColButton
),
1364 int(self
.fontActiveColButton
.get_alpha() / 65535.0 * 100)))
1365 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_urgent_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontUrgentColButton
),
1366 int(self
.fontUrgentColButton
.get_alpha() / 65535.0 * 100)))
1367 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_iconified_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontIconifiedColButton
),
1368 int(self
.fontIconifiedColButton
.get_alpha() / 65535.0 * 100)))
1369 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "font_shadow = %s\n" % int(self
.fontShadowCheckButton
.get_active()))
1371 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# System Tray\n")
1372 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray = %s\n" % int(self
.trayShow
.get_active()))
1373 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
,
1374 self
.trayPadY
.get_text() if self
.trayPadY
.get_text() else TRAY_PADDING_Y
,
1375 self
.traySpacing
.get_text() if self
.traySpacing
.get_text() else TRAY_SPACING
))
1376 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_sort = %s\n" % (self
.trayOrder
.get_active_text()))
1377 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_background_id = %s\n" % (self
.trayBg
.get_active()))
1378 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_icon_size = %s\n" % (self
.trayMaxIconSize
.get_text() if self
.trayMaxIconSize
.get_text() else TRAY_MAX_ICON_SIZE
))
1379 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_icon_asb = %s %s %s\n" % (self
.trayIconHue
.get_text() if self
.trayIconHue
.get_text() else TRAY_ICON_ALPHA
,
1380 self
.trayIconSat
.get_text() if self
.trayIconSat
.get_text() else TRAY_ICON_SAT
,
1381 self
.trayIconBri
.get_text() if self
.trayIconBri
.get_text() else TRAY_ICON_BRI
))
1383 if self
.clockCheckButton
.get_active():
1384 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Clock\n")
1385 if self
.clock1CheckButton
.get_active():
1386 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
))
1387 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_font = %s\n" % (self
.clock1FontButton
.get_font_name()))
1388 if self
.clock2CheckButton
.get_active():
1389 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
))
1390 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_font = %s\n" % (self
.clock2FontButton
.get_font_name()))
1392 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_font_color = %s %s\n" % (self
.getHexFromWidget(self
.clockFontColButton
),
1393 int(self
.clockFontColButton
.get_alpha() / 65535.0 * 100)))
1395 if self
.clockTooltipCheckButton
.get_active():
1396 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_tooltip = %s\n" % (self
.clockTooltipFormat
.get_text() if self
.clockTooltipFormat
.get_text() else CLOCK_TOOLTIP
))
1397 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
,
1398 self
.clockPadY
.get_text() if self
.clockPadY
.get_text() else CLOCK_PADDING_Y
))
1399 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_background_id = %s\n" % (self
.clockBg
.get_active()))
1400 if self
.clockLClick
.get_text():
1401 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_lclick_command = %s\n" % (self
.clockLClick
.get_text()))
1402 if self
.clockRClick
.get_text():
1403 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_rclick_command = %s\n" % (self
.clockRClick
.get_text()))
1404 if self
.clockTimezone1CheckButton
.get_active():
1405 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_timezone = %s\n" % (self
.clockTime1Timezone
.get_text() if self
.clockTime1Timezone
.get_text() else CLOCK_TIME1_TIMEZONE
))
1406 if self
.clockTimezone2CheckButton
.get_active():
1407 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_timezone = %s\n" % (self
.clockTime2Timezone
.get_text() if self
.clockTime2Timezone
.get_text() else CLOCK_TIME2_TIMEZONE
))
1408 if self
.clockTimezoneTooltipCheckButton
.get_active():
1409 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_tooltip_timezone = %s\n" % (self
.clockTooltipTimezone
.get_text() if self
.clockTooltipTimezone
.get_text() else CLOCK_TOOLTIP_TIMEZONE
))
1412 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tooltips\n")
1413 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip = %s\n" % int(self
.tooltipShow
.get_active()))
1414 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
,
1415 self
.tooltipPadY
.get_text() if self
.tooltipPadY
.get_text() else TOOLTIP_PADDING_Y
))
1416 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
))
1417 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
))
1418 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_background_id = %s\n" % (self
.tooltipBg
.get_active()))
1419 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font = %s\n" % (self
.tooltipFont
.get_font_name()))
1420 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font_color = %s %s\n" % (self
.getHexFromWidget(self
.tooltipFontColButton
),
1421 int(self
.tooltipFontColButton
.get_alpha() / 65535.0 * 100)))
1423 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Mouse\n")
1424 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_middle = %s\n" % (self
.mouseMiddle
.get_active_text()))
1425 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_right = %s\n" % (self
.mouseRight
.get_active_text()))
1426 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_up = %s\n" % (self
.mouseUp
.get_active_text()))
1427 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_down = %s\n" % (self
.mouseDown
.get_active_text()))
1429 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Battery\n")
1430 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery = %s\n" % int(self
.batteryCheckButton
.get_active()))
1431 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
))
1432 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
))
1433 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_hide = %s\n" % (self
.batteryHide
.get_text() if self
.batteryHide
.get_text() else BATTERY_HIDE
))
1434 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat1_font = %s\n" % (self
.bat1FontButton
.get_font_name()))
1435 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat2_font = %s\n" % (self
.bat2FontButton
.get_font_name()))
1436 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_font_color = %s %s\n" % (self
.getHexFromWidget(self
.batteryFontColButton
),
1437 int(self
.batteryFontColButton
.get_alpha() / 65535.0 * 100)))
1438 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
,
1439 self
.batteryPadY
.get_text() if self
.batteryPadY
.get_text() else BATTERY_PADDING_Y
))
1440 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_background_id = %s\n" % (self
.batteryBg
.get_active()))
1442 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# End of config")
1444 def getColorButton(self
, widget
):
1445 """Returns the color button associated with widget."""
1446 if widget
.get_name() == "fontCol":
1447 return self
.fontColButton
1448 elif widget
.get_name() == "fontActiveCol":
1449 return self
.fontActiveColButton
1450 elif widget
.get_name() == "fontUrgentCol":
1451 return self
.fontUrgentColButton
1452 elif widget
.get_name() == "fontIconifiedCol":
1453 return self
.fontIconifiedColButton
1454 elif widget
.get_name() == "clockFontCol":
1455 return self
.clockFontColButton
1456 elif widget
.get_name() == "batteryFontCol":
1457 return self
.batteryFontColButton
1458 elif widget
.get_name() == "tooltipFontCol":
1459 return self
.tooltipFontColButton
1460 elif widget
.get_name() == "bgColEntry":
1461 bgID
= self
.bgNotebook
.get_current_page()
1463 for child
in self
.bgs
[bgID
].get_children():
1464 if child
.get_name() == "bgCol":
1467 elif widget
.get_name() == "borderColEntry":
1468 bgID
= self
.bgNotebook
.get_current_page()
1470 for child
in self
.bgs
[bgID
].get_children():
1471 if child
.get_name() == "borderCol":
1475 # No button found which matches label
1478 def getColorLabel(self
, widget
):
1479 """Gets the color label associated with a color button."""
1480 if widget
.get_name() == "fontCol":
1482 elif widget
.get_name() == "fontActiveCol":
1483 return self
.fontActiveCol
1484 elif widget
.get_name() == "fontUrgentCol":
1485 return self
.fontUrgentCol
1486 elif widget
.get_name() == "fontIconifiedCol":
1487 return self
.fontIconifiedCol
1488 elif widget
.get_name() == "clockFontCol":
1489 return self
.clockFontCol
1490 elif widget
.get_name() == "batteryFontCol":
1491 return self
.batteryFontCol
1492 elif widget
.get_name() == "tooltipFontCol":
1493 return self
.tooltipFontCol
1494 elif widget
.get_name() == "bgCol":
1495 bgID
= self
.bgNotebook
.get_current_page()
1497 for child
in self
.bgs
[bgID
].get_children():
1498 if child
.get_name() == "bgColEntry":
1501 elif widget
.get_name() == "borderCol":
1502 bgID
= self
.bgNotebook
.get_current_page()
1504 for child
in self
.bgs
[bgID
].get_children():
1505 if child
.get_name() == "borderColEntry":
1509 # No label found which matches color button
1512 def getHexFromWidget(self
, widget
):
1513 """Returns the #RRGGBB value of a widget."""
1514 r
= widget
.get_color().red
1515 g
= widget
.get_color().green
1516 b
= widget
.get_color().blue
1518 return rgbToHex(r
, g
, b
)
1520 def help(self
, action
=None):
1521 """Opens the Help wiki page in the default web browser."""
1523 webbrowser
.open("http://code.google.com/p/tintwizard/wiki/Help")
1525 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/wiki/Help")
1528 """Enters the main loop."""
1531 def new(self
, action
=None):
1532 """Prepares a new config."""
1537 self
.filename
= None
1541 self
.generateConfig()
1542 self
.updateStatusBar("New Config File [*]")
1544 def openDef(self
, widget
=None):
1545 """Opens the default tint2 config."""
1546 self
.openFile(default
=True)
1548 def openFile(self
, widget
=None, default
=False):
1549 """Reads from a config file. If default=True, open the tint2 default config."""
1553 chooser
= gtk
.FileChooserDialog("Open Config File", self
, gtk
.FILE_CHOOSER_ACTION_OPEN
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
1554 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1556 if self
.curDir
!= None:
1557 chooser
.set_current_folder(self
.curDir
)
1559 chooserFilter
= gtk
.FileFilter()
1560 chooserFilter
.set_name("All files")
1561 chooserFilter
.add_pattern("*")
1562 chooser
.add_filter(chooserFilter
)
1565 response
= chooser
.run()
1567 if response
== gtk
.RESPONSE_OK
:
1568 self
.filename
= chooser
.get_filename()
1569 self
.curDir
= os
.path
.dirname(self
.filename
)
1576 self
.filename
= os
.path
.expandvars("$HOME/.config/tint2/tint2rc")
1577 self
.curDir
= os
.path
.expandvars("$HOME/.config/tint2")
1579 self
.readTint2Config()
1580 self
.generateConfig()
1581 self
.updateStatusBar()
1583 def parseBgs(self
, string
):
1584 """Parses the background definitions from a string."""
1585 s
= string
.split("\n")
1589 bgKeys
= ["border_width", "background_color", "border_color"]
1593 data
= [token
.strip() for token
in line
.split("=")]
1595 if data
[0] == "rounded": # It may be considered bad practice to
1596 bgDefs
+= [{"rounded": data[1]}
] # find each style definition with an
1597 elif data
[0] in bgKeys
: # arbitrary value, but tint2 does the same.
1598 bgDefs
[cur
][data
[0]] = data
[1] # This means that any existing configs must
1599 else: # start with 'rounded'.
1600 newString
+= "%s\n" % line
1602 self
.addBgDefs(bgDefs
)
1606 def parseConfig(self
, string
):
1607 """Parses the contents of a config file."""
1608 for line
in string
.split("\n"):
1609 s
= line
.split("=") # Create a list with KEY and VALUE
1611 e
= s
[0].strip() # Strip whitespace from KEY
1613 if e
== "time1_format": # Set the VALUE of KEY
1614 self
.parseProp(self
.getComponent(e
), s
[1], True, "time1")
1615 elif e
== "time2_format":
1616 self
.parseProp(self
.getComponent(e
), s
[1], True, "time2")
1617 elif e
== "clock_tooltip":
1618 self
.parseProp(self
.getComponent(e
), s
[1], True, "clock_tooltip")
1619 elif e
== "time1_timezone":
1620 self
.parseProp(self
.getComponent(e
), s
[1], True, "time1_timezone")
1621 elif e
== "time2_timezone":
1622 self
.parseProp(self
.getComponent(e
), s
[1], True, "time2_timezone")
1623 elif e
== "clock_tooltip_timezone":
1624 self
.parseProp(self
.getComponent(e
), s
[1], True, "tooltip_timezone")
1625 elif e
== "systray_padding":
1626 self
.parseProp(self
.getComponent(e
), s
[1], True, "tray")
1627 elif e
== "taskbar_active_background_id":
1628 self
.parseProp(self
.getComponent(e
), s
[1], True, "activeBg")
1630 component
= self
.getComponent(e
)
1631 if component
!= None:
1632 self
.parseProp(self
.getComponent(e
), s
[1])
1634 def parseProp(self
, prop
, string
, special
=False, propType
=""):
1635 """Parses a variable definition from the conf file and updates the correct UI widget."""
1636 string
= string
.strip() # Remove whitespace from the VALUE
1637 eType
= type(prop
) # Get widget type
1639 if special
: # 'Special' properties are those which are optional
1640 if propType
== "time1":
1641 self
.clockCheckButton
.set_active(True)
1642 self
.clock1CheckButton
.set_active(True)
1643 elif propType
== "time2":
1644 self
.clockCheckButton
.set_active(True)
1645 self
.clock2CheckButton
.set_active(True)
1646 elif propType
== "clock_tooltip":
1647 self
.clockCheckButton
.set_active(True)
1648 self
.clockTooltipCheckButton
.set_active(True)
1649 elif propType
== "time1_timezone":
1650 self
.clockTimezone1CheckButton
.set_active(True)
1651 elif propType
== "time2_timezone":
1652 self
.clockTimezone2CheckButton
.set_active(True)
1653 elif propType
== "tooltip_timezone":
1654 self
.clockTimezoneTooltipCheckButton
.set_active(True)
1655 elif propType
== "tray":
1656 self
.trayShow
.set_active(True)
1657 elif propType
== "activeBg":
1658 self
.taskbarActiveBgEnable
.set_active(True)
1660 if eType
== gtk
.Entry
:
1661 prop
.set_text(string
)
1663 elif eType
== gtk
.ComboBox
:
1664 # This allows us to select the correct combo-box value.
1665 if string
in ["bottom", "top", "left", "right", "center", "single_desktop", "multi_desktop", "single_monitor",
1666 "none", "close", "shade", "iconify", "toggle", "toggle_iconify", "maximize_restore",
1667 "desktop_left", "desktop_right", "horizontal", "vertical", "ascending", "descending",
1668 "left2right", "right2left", "next_task", "prev_task", "minimum", "follow_size", "normal"]:
1669 if string
in ["bottom", "left", "single_desktop", "none", "horizontal", "ascending"]:
1671 elif string
in ["top", "right", "multi_desktop", "close", "vertical", "descending", "minimum"]:
1673 elif string
in ["center", "single_monitor", "toggle", "left2right", "follow_size", "normal"]:
1675 elif string
in ["right2left"]:
1678 i
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore",
1679 "desktop_left", "desktop_right", "next_task", "prev_task"].index(string
)
1683 prop
.set_active(int(string
))
1684 elif eType
== gtk
.CheckButton
:
1685 prop
.set_active(bool(int(string
)))
1686 elif eType
== gtk
.FontButton
:
1687 prop
.set_font_name(string
)
1688 elif eType
== gtk
.ColorButton
:
1689 prop
.set_alpha(int(int(string
) * 65535 / 100.0))
1690 elif eType
== tuple: # If a property has more than 1 value, for example the x and y co-ords
1691 s
= string
.split(" ") # of the padding properties, then just we use recursion to set the
1692 for i
in range(len(prop
)): # value of each associated widget.
1694 self
.parseProp(prop
[i
], "0")
1696 self
.parseProp(prop
[i
], s
[i
])
1698 def quit(self
, widget
, event
=None):
1699 """Asks if user would like to save file before quitting, then quits the program."""
1701 if self
.oneConfigFile
:
1702 response
= gtk
.RESPONSE_YES
1704 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
))
1705 dialog
.get_content_area().add(gtk
.Label("Save config before quitting?"))
1706 dialog
.get_content_area().set_size_request(300, 100)
1708 response
= dialog
.run()
1711 if response
== gtk
.RESPONSE_CANCEL
:
1712 return True # Return True to stop it quitting when we hit "Cancel"
1713 elif response
== gtk
.RESPONSE_NO
:
1715 elif response
== gtk
.RESPONSE_YES
:
1722 """Reads the tintwizard configuration file - NOT tint2 config files."""
1723 self
.defaults
= {"font": None, "bgColor": None, "fgColor": None, "borderColor": None, "bgCount": None}
1725 if self
.oneConfigFile
:
1726 # don't need tintwizard.conf
1729 pathName
= os
.path
.expandvars("${HOME}") + "/.config/tint2/"
1731 if not os
.path
.exists(pathName
+ "tintwizard.conf"):
1735 f
= open(pathName
+ "tintwizard.conf", "r")
1741 if self
.defaults
.has_key(l
[0].strip()):
1742 self
.defaults
[l
[0].strip()] = l
[1].strip()
1744 def readTint2Config(self
):
1745 """Reads in from a config file."""
1746 f
= open(self
.filename
, "r")
1751 if (line
[0] != "#") and (len(line
) > 2):
1756 # Deselect the optional stuff, and we'll re-check them if the config has them enabled
1757 self
.clockCheckButton
.set_active(False)
1758 self
.clock1CheckButton
.set_active(False)
1759 self
.clock2CheckButton
.set_active(False)
1760 self
.clockTooltipCheckButton
.set_active(False)
1761 self
.clockTimezone1CheckButton
.set_active(False)
1762 self
.clockTimezone2CheckButton
.set_active(False)
1763 self
.clockTimezoneTooltipCheckButton
.set_active(False)
1764 self
.trayShow
.set_active(False)
1765 self
.taskbarActiveBgEnable
.set_active(False)
1767 # Remove all background styles so we can create new ones as we read them
1768 for i
in range(len(self
.bgs
)):
1769 self
.delBgClick(None, False)
1771 # As we parse background definitions, we build a new string
1772 # without the background related stuff. This means we don't
1773 # have to read through background defs AGAIN when parsing
1775 noBgDefs
= self
.parseBgs(string
)
1777 self
.parseConfig(noBgDefs
)
1779 def reportBug(self
, action
=None):
1780 """Opens the bug report page in the default web browser."""
1782 webbrowser
.open("http://code.google.com/p/tintwizard/issues/entry")
1784 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/issues/entry")
1787 def resetConfig(self
):
1788 """Resets all the widgets to their default values."""
1790 for i
in range(len(self
.bgs
)):
1791 self
.delBgClick(prompt
=False, init
=True)
1793 for i
in range(self
.defaults
["bgCount"]):
1794 self
.addBgClick(init
=True)
1796 self
.bgNotebook
.set_current_page(0)
1799 self
.panelPosY
.set_active(0)
1800 self
.panelPosX
.set_active(0)
1801 self
.panelOrientation
.set_active(0)
1802 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
1803 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
1804 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
1805 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
1806 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
1807 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
1808 self
.panelSpacing
.set_text(TASKBAR_SPACING
)
1809 self
.panelBg
.set_active(0)
1810 self
.panelMenu
.set_active(0)
1811 self
.panelDock
.set_active(0)
1812 self
.panelLayer
.set_active(0)
1813 self
.panelMonitor
.set_text(PANEL_MONITOR
)
1814 self
.panelAutohide
.set_active(0)
1815 self
.panelAutohideShow
.set_text(PANEL_AUTOHIDE_SHOW
)
1816 self
.panelAutohideHide
.set_text(PANEL_AUTOHIDE_HIDE
)
1817 self
.panelAutohideHeight
.set_text(PANEL_AUTOHIDE_HEIGHT
)
1818 self
.panelAutohideStrut
.set_active(0)
1820 self
.taskbarMode
.set_active(0)
1821 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
1822 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
1823 self
.taskbarSpacing
.set_text(TASK_SPACING
)
1824 self
.taskbarBg
.set_active(0)
1825 self
.taskbarActiveBg
.set_active(0)
1826 self
.taskbarActiveBgEnable
.set_active(0)
1828 self
.taskBlinks
.set_text(TASK_BLINKS
)
1829 self
.taskCentreCheckButton
.set_active(True)
1830 self
.taskTextCheckButton
.set_active(True)
1831 self
.taskIconCheckButton
.set_active(True)
1832 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
1833 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
1834 self
.taskPadX
.set_text(TASK_PADDING_X
)
1835 self
.taskPadY
.set_text(TASK_PADDING_Y
)
1836 self
.taskBg
.set_active(0)
1837 self
.taskActiveBg
.set_active(0)
1838 self
.taskUrgentBg
.set_active(0)
1839 self
.taskIconifiedBg
.set_active(0)
1841 self
.iconHue
.set_text(ICON_ALPHA
)
1842 self
.iconSat
.set_text(ICON_SAT
)
1843 self
.iconBri
.set_text(ICON_BRI
)
1844 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
1845 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
1846 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
1847 self
.urgentIconHue
.set_text(URGENT_ICON_ALPHA
)
1848 self
.urgentIconSat
.set_text(URGENT_ICON_SAT
)
1849 self
.urgentIconBri
.set_text(URGENT_ICON_BRI
)
1850 self
.iconifiedIconHue
.set_text(ICONIFIED_ICON_ALPHA
)
1851 self
.iconifiedIconSat
.set_text(ICONIFIED_ICON_SAT
)
1852 self
.iconifiedIconBri
.set_text(ICONIFIED_ICON_BRI
)
1854 self
.fontButton
.set_font_name(self
.defaults
["font"])
1855 self
.fontColButton
.set_alpha(65535)
1856 self
.fontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1857 self
.fontCol
.set_text(self
.defaults
["fgColor"])
1858 self
.fontActiveColButton
.set_alpha(65535)
1859 self
.fontActiveColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1860 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
1861 self
.fontUrgentColButton
.set_alpha(65535)
1862 self
.fontUrgentColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1863 self
.fontUrgentCol
.set_text(self
.defaults
["fgColor"])
1864 self
.fontIconifiedColButton
.set_alpha(65535)
1865 self
.fontIconifiedColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1866 self
.fontIconifiedCol
.set_text(self
.defaults
["fgColor"])
1867 self
.fontShadowCheckButton
.set_active(False)
1869 self
.trayShow
.set_active(True)
1870 self
.trayPadX
.set_text(TRAY_PADDING_X
)
1871 self
.trayPadY
.set_text(TRAY_PADDING_X
)
1872 self
.traySpacing
.set_text(TRAY_SPACING
)
1873 self
.trayOrder
.set_active(0)
1874 self
.trayBg
.set_active(0)
1875 self
.trayMaxIconSize
.set_text(TRAY_MAX_ICON_SIZE
)
1876 self
.trayIconHue
.set_text(TRAY_ICON_ALPHA
)
1877 self
.trayIconSat
.set_text(TRAY_ICON_SAT
)
1878 self
.trayIconBri
.set_text(TRAY_ICON_BRI
)
1880 self
.clockCheckButton
.set_active(True)
1881 self
.clock1Format
.set_text(CLOCK_FMT_1
)
1882 self
.clock1CheckButton
.set_active(True)
1883 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
1884 self
.clock2Format
.set_text(CLOCK_FMT_2
)
1885 self
.clock2CheckButton
.set_active(True)
1886 self
.clockTooltipFormat
.set_text(CLOCK_TOOLTIP
)
1887 self
.clockTooltipCheckButton
.set_active(False)
1888 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
1889 self
.clockFontColButton
.set_alpha(65535)
1890 self
.clockFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1891 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
1892 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
1893 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
1894 self
.clockBg
.set_active(0)
1895 self
.clockLClick
.set_text(CLOCK_LCLICK
)
1896 self
.clockRClick
.set_text(CLOCK_RCLICK
)
1897 self
.clockTime1Timezone
.set_text(CLOCK_TIME1_TIMEZONE
)
1898 self
.clockTimezone1CheckButton
.set_active(False)
1899 self
.clockTime2Timezone
.set_text(CLOCK_TIME2_TIMEZONE
)
1900 self
.clockTimezone2CheckButton
.set_active(False)
1901 self
.clockTooltipTimezone
.set_text(CLOCK_TOOLTIP_TIMEZONE
)
1902 self
.clockTimezoneTooltipCheckButton
.set_active(False)
1904 self
.tooltipShow
.set_active(False)
1905 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
1906 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
1907 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
1908 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
1909 self
.tooltipBg
.set_active(0)
1910 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1911 self
.tooltipFontColButton
.set_alpha(65535)
1912 self
.tooltipFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1913 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1915 self
.mouseMiddle
.set_active(0)
1916 self
.mouseRight
.set_active(0)
1917 self
.mouseUp
.set_active(0)
1918 self
.mouseDown
.set_active(0)
1920 self
.batteryCheckButton
.set_active(False)
1921 self
.batteryLow
.set_text(BATTERY_LOW
)
1922 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1923 self
.batteryHide
.set_text(BATTERY_HIDE
)
1924 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1925 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1926 self
.batteryFontColButton
.set_alpha(65535)
1927 self
.batteryFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1928 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1929 self
.batteryPadX
.set_text(BATTERY_PADDING_Y
)
1930 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1931 self
.batteryBg
.set_active(0)
1933 def save(self
, widget
=None, event
=None):
1934 """Saves the generated config file."""
1936 # This function returns the boolean status of whether or not the
1937 # file saved, so that the apply() function knows if it should
1938 # kill the tint2 process and apply the new config.
1940 # If no file has been selected, force the user to "Save As..."
1941 if self
.filename
== None:
1942 return self
.saveAs()
1944 self
.generateConfig()
1949 def saveAs(self
, widget
=None, event
=None):
1950 """Prompts the user to select a file and then saves the generated config file."""
1951 self
.generateConfig()
1953 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
))
1954 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1956 if self
.curDir
!= None:
1957 chooser
.set_current_folder(self
.curDir
)
1959 chooserFilter
= gtk
.FileFilter()
1960 chooserFilter
.set_name("All files")
1961 chooserFilter
.add_pattern("*")
1962 chooser
.add_filter(chooserFilter
)
1965 response
= chooser
.run()
1967 if response
== gtk
.RESPONSE_OK
:
1968 self
.filename
= chooser
.get_filename()
1970 if os
.path
.exists(self
.filename
):
1971 overwrite
= confirmDialog(self
, "This file already exists. Overwrite this file?")
1973 if overwrite
== gtk
.RESPONSE_YES
:
1978 self
.filename
= None
1986 self
.filename
= None
1990 def saveAsDef(self
, widget
=None, event
=None):
1991 """Saves the config as the default tint2 config."""
1992 if confirmDialog(self
, "Overwrite current tint2 default config?") == gtk
.RESPONSE_YES
:
1993 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1994 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
1996 # If, for whatever reason, tint2 has no default config - create one.
1997 if not os
.path
.isfile(self
.filename
):
1998 f
= open(self
.filename
, "w")
1999 f
.write("# tint2rc")
2002 self
.generateConfig()
2007 def savePrompt(self
):
2008 """Prompt the user to save before creating a new file."""
2009 if confirmDialog(self
, "Save current config?") == gtk
.RESPONSE_YES
:
2012 def switchPage(self
, notebook
, page
, page_num
):
2013 """Handles notebook page switch events."""
2015 # If user selects the 'View Config' tab, update the textarea within this tab.
2016 if notebook
.get_tab_label_text(notebook
.get_nth_page(page_num
)) == "View Config":
2017 self
.generateConfig()
2019 def updateComboBoxes(self
, i
, action
="add"):
2020 """Updates the contents of a combo box when a background style has been added/removed."""
2021 cbs
= [self
.batteryBg
, self
.clockBg
, self
.taskbarBg
, self
.taskbarActiveBg
, self
.trayBg
, self
.taskActiveBg
, self
.taskBg
, self
.panelBg
, self
.tooltipBg
, self
.taskUrgentBg
, self
.taskIconifiedBg
]
2025 cb
.append_text(str(i
+1))
2028 if cb
.get_active() == i
: # If background is selected, set to a different value
2033 def updateStatusBar(self
, message
="", change
=False):
2034 """Updates the message on the statusbar. A message can be provided,
2035 and if change is set to True (i.e. something has been modified) then
2036 an appropriate symbol [*] is shown beside filename."""
2037 contextID
= self
.statusBar
.get_context_id("")
2039 self
.statusBar
.pop(contextID
)
2042 message
= "%s %s" % (self
.filename
or "New Config File", "[*]" if change
else "")
2044 self
.statusBar
.push(contextID
, message
)
2046 def writeConf(self
):
2047 """Writes the tintwizard configuration file."""
2048 confStr
= "#Start\n[defaults]\n"
2050 for key
in self
.defaults
:
2051 confStr
+= "%s = %s\n" % (key
, str(self
.defaults
[key
]))
2055 pathName
= os
.path
.expandvars("${HOME}") + "/.config/tint2/"
2057 f
= open(pathName
+"tintwizard.conf", "w")
2063 def writeFile(self
):
2064 """Writes the contents of the config text buffer to file."""
2066 f
= open(self
.filename
, "w")
2068 f
.write(self
.configBuf
.get_text(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter()))
2074 self
.curDir
= os
.path
.dirname(self
.filename
)
2076 self
.updateStatusBar()
2078 errorDialog(self
, "Could not save file")
2080 # General use functions
2081 def createLabel(parent
, text
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xPadding
=0):
2082 """Creates a label and adds it to a parent widget."""
2084 temp
= gtk
.Label(text
)
2085 temp
.set_alignment(0, 0.5)
2086 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xpadding
=xPadding
)
2089 def createComboBox(parent
, choices
=["null"], active
=0, gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2090 """Creates a combo box with text choices and adds it to a parent widget."""
2091 temp
= gtk
.combo_box_new_text()
2093 for choice
in choices
:
2094 temp
.append_text(choice
)
2096 temp
.set_active(active
)
2099 temp
.connect("changed", handler
)
2101 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2105 def createEntry(parent
, maxSize
, width
, text
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None, name
=""):
2106 """Creates a text entry widget and adds it to a parent widget."""
2107 temp
= gtk
.Entry(maxSize
)
2108 temp
.set_width_chars(width
)
2113 temp
.connect("changed", handler
)
2115 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2119 def createCheckButton(parent
, text
="", active
=False, gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2120 """Creates a checkbox widget and adds it to a parent widget."""
2121 temp
= gtk
.CheckButton(text
if text
!= "" else None)
2122 temp
.set_active(active
)
2123 temp
.connect("toggled", handler
)
2125 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2129 def createButton(parent
, text
="", stock
=None, name
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2130 """Creates a button widget and adds it to a parent widget."""
2132 temp
= gtk
.Button(text
, stock
)
2134 temp
= gtk
.Button(text
)
2137 temp
.connect("clicked", handler
)
2139 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2143 def createFontButton(parent
, font
, gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2144 """Creates a font button widget and adds it to a parent widget."""
2145 temp
= gtk
.FontButton()
2146 temp
.set_font_name(font
)
2147 temp
.connect("font-set", handler
)
2149 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2153 def createColorButton(parent
, color
="#000000", useAlpha
=True, name
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2154 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(color
))
2155 temp
.set_use_alpha(useAlpha
)
2157 temp
.connect("color-set", handler
)
2159 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2163 def confirmDialog(parent
, message
):
2164 """Creates a confirmation dialog and returns the response."""
2165 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
, message
)
2167 response
= dialog
.run()
2171 def errorDialog(parent
=None, message
="An error has occured!"):
2172 """Creates an error dialog."""
2173 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
2179 """Convert integer n in range [0, 15] to hex."""
2181 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"][n
]
2185 def rgbToHex(r
, g
, b
):
2186 """Constructs a 6 digit hex representation of color (r, g, b)."""
2187 r2
= trunc(r
/ 65535.0 * 255)
2188 g2
= trunc(g
/ 65535.0 * 255)
2189 b2
= trunc(b
/ 65535.0 * 255)
2191 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))
2194 """Truncate a floating point number, rounding up or down appropriately."""
2195 c
= math
.fabs(math
.ceil(n
) - n
)
2196 f
= math
.fabs(math
.floor(n
) - n
)
2199 return int(math
.ceil(n
))
2201 return int(math
.floor(n
))
2203 # Direct execution of application
2204 if __name__
== "__main__":
2205 if len(sys
.argv
) > 1 and sys
.argv
[1] == "-version":
2209 tw
= TintWizardGUI()