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: 14th June 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
50 PANEL_AUTOHIDE_SHOW
= "0.0"
51 PANEL_AUTOHIDE_HIDE
= "0.0"
52 PANEL_AUTOHIDE_HEIGHT
= "0"
53 TASKBAR_PADDING_X
= "0"
54 TASKBAR_PADDING_Y
= "0"
57 TASK_MAXIMUM_SIZE_X
= "200"
58 TASK_MAXIMUM_SIZE_Y
= "32"
65 TRAY_MAX_ICON_SIZE
= "0"
66 TRAY_ICON_ALPHA
= "100"
72 ACTIVE_ICON_ALPHA
= "100"
75 URGENT_ICON_ALPHA
= "100"
78 ICONIFIED_ICON_ALPHA
= "100"
79 ICONIFIED_ICON_SAT
= "0"
80 ICONIFIED_ICON_BRI
= "0"
82 CLOCK_FMT_2
= "%a %d %b"
84 CLOCK_TIME1_TIMEZONE
= ""
85 CLOCK_TIME2_TIMEZONE
= ""
86 CLOCK_TOOLTIP_TIMEZONE
= ""
91 TOOLTIP_PADDING_X
= "0"
92 TOOLTIP_PADDING_Y
= "0"
93 TOOLTIP_SHOW_TIMEOUT
= "0"
94 TOOLTIP_HIDE_TIMEOUT
= "0"
97 BATTERY_ACTION
= 'notify-send "battery low"'
98 BATTERY_PADDING_X
= "0"
99 BATTERY_PADDING_Y
= "0"
101 class TintWizardPrefGUI(gtk
.Window
):
102 """The dialog window which lets the user change the default preferences."""
103 def __init__(self
, tw
):
104 """Create and shows the window."""
107 # Create top-level window
108 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
110 self
.set_title("Preferences")
111 self
.connect("delete_event", self
.quit
)
113 self
.layout
= gtk
.Table(2, 2, False)
115 self
.table
= gtk
.Table(5, 2, False)
116 self
.table
.set_row_spacings(5)
117 self
.table
.set_col_spacings(5)
119 createLabel(self
.table
, text
="Default Font", gridX
=0, gridY
=0)
120 self
.font
= gtk
.FontButton(self
.tw
.defaults
["font"])
121 self
.font
.set_alignment(0, 0.5)
122 self
.table
.attach(self
.font
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
124 createLabel(self
.table
, text
="Default Background Color", gridX
=0, gridY
=1)
125 self
.bgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["bgColor"]))
126 self
.bgColor
.set_alignment(0, 0.5)
127 self
.table
.attach(self
.bgColor
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
129 createLabel(self
.table
, text
="Default Foreground Color", gridX
=0, gridY
=2)
130 self
.fgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["fgColor"]))
131 self
.fgColor
.set_alignment(0, 0.5)
132 self
.table
.attach(self
.fgColor
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
134 createLabel(self
.table
, text
="Default Border Color", gridX
=0, gridY
=3)
135 self
.borderColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["borderColor"]))
136 self
.borderColor
.set_alignment(0, 0.5)
137 self
.table
.attach(self
.borderColor
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
139 createLabel(self
.table
, text
="Number of background styles", gridX
=0, gridY
=4)
140 self
.bgCount
= createEntry(self
.table
, maxSize
=6, width
=8, text
=str(self
.tw
.defaults
["bgCount"]), gridX
=1, gridY
=4, xExpand
=True, yExpand
=True)
142 self
.layout
.attach(self
.table
, 0, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, xpadding
=20, ypadding
=5)
144 createButton(self
.layout
, text
="Save", stock
=gtk
.STOCK_SAVE
, name
="save", gridX
=0, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.save
)
145 createButton(self
.layout
, text
="Cancel", stock
=gtk
.STOCK_CANCEL
, name
="cancel", gridX
=1, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.quit
)
147 self
.add(self
.layout
)
151 def quit(self
, widget
=None, event
=None):
152 """Destroys the window."""
155 def save(self
, action
=None):
156 """Called when the Save button is clicked."""
157 if confirmDialog(self
, "Overwrite configuration file?") == gtk
.RESPONSE_YES
:
158 self
.tw
.defaults
["font"] = self
.font
.get_font_name()
159 self
.tw
.defaults
["bgColor"] = rgbToHex(self
.bgColor
.get_color().red
, self
.bgColor
.get_color().green
, self
.bgColor
.get_color().blue
)
160 self
.tw
.defaults
["fgColor"] = rgbToHex(self
.fgColor
.get_color().red
, self
.fgColor
.get_color().green
, self
.fgColor
.get_color().blue
)
161 self
.tw
.defaults
["borderColor"] = rgbToHex(self
.borderColor
.get_color().red
, self
.borderColor
.get_color().green
, self
.borderColor
.get_color().blue
)
164 self
.tw
.defaults
["bgCount"] = int(self
.bgCount
.get_text())
166 errorDialog(self
, "Invalid value for background count")
173 class TintWizardGUI(gtk
.Window
):
174 """The main window for the application."""
176 """Create and show the window."""
181 if len(sys
.argv
) > 1:
182 self
.filename
= sys
.argv
[1]
183 self
.oneConfigFile
= True
185 self
.oneConfigFile
= False
187 # Read conf file and set default values
190 if self
.defaults
["bgColor"] in [None, "None"]:
191 self
.defaults
["bgColor"] = "#000000"
193 if self
.defaults
["fgColor"] in [None, "None"]:
194 self
.defaults
["fgColor"] = "#ffffff"
196 if self
.defaults
["borderColor"] in [None, "None"]:
197 self
.defaults
["borderColor"] = "#ffffff"
199 if os
.path
.exists(os
.path
.expandvars("${HOME}") + "/.config/tint2"):
200 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
202 errorDialog("$HOME/.config/tint2/ directory not found! Is tint2 installed correctly?")
206 self
.defaults
["bgCount"] = int(self
.defaults
["bgCount"])
208 self
.defaults
["bgCount"] = 2
210 # Get the full location of the tint2 binary
211 which
= os
.popen('which tint2')
213 self
.tint2Bin
= which
.readline().strip()
217 if len(self
.tint2Bin
) == 0:
218 errorDialog(self
, "tint2 could not be found. Are you sure it is installed?")
221 # Create top-level window
222 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
224 self
.set_title("tintwizard")
226 self
.connect("delete_event", self
.quit
)
228 # self.table is our main layout manager
229 self
.table
= gtk
.Table(4, 1, False)
231 # Set up the dictionary to hold all registered widgets
234 # Create menus and toolbar items
237 <menubar name="MenuBar">
239 <menuitem action="New" />
240 <menuitem action="Open" />
242 <menuitem action="Save" />
243 <menuitem action="Save As..." />
245 <menuitem action="Quit" />
247 <menu action="Tint2">
248 <menuitem action="OpenDefault" />
249 <menuitem action="SaveDefault" />
251 <menuitem action="Apply" />
253 <menu action="Tools">
254 <menuitem action="FontChange" />
256 <menuitem action="Defaults" />
258 <menu action="HelpMenu">
259 <menuitem action="Help" />
260 <menuitem action="Report Bug" />
262 <menuitem action="About" />
265 <toolbar name="ToolBar">
266 <toolitem action="New" />
267 <toolitem action="Open" />
268 <toolitem action="Save" />
270 <toolitem action="Apply" />
276 self
.uiManager
= gtk
.UIManager()
278 accelGroup
= self
.uiManager
.get_accel_group()
279 self
.add_accel_group(accelGroup
)
281 self
.ag
= gtk
.ActionGroup("File")
282 self
.ag
.add_actions([("File", None, "_File"),
283 ("New",gtk
.STOCK_NEW
, "_New", None, "Create a new config", self
.new
),
284 ("Open", gtk
.STOCK_OPEN
, "_Open", None, "Open an existing config", self
.openFile
),
285 ("Save", gtk
.STOCK_SAVE
, "_Save", None, "Save the current config", self
.save
),
286 ("Save As...", gtk
.STOCK_SAVE_AS
, "Save As", None, "Save the current config as...", self
.saveAs
),
287 ("SaveDefault", None, "Save As tint2 Default", None, "Save the current config as the tint2 default", self
.saveAsDef
),
288 ("OpenDefault", None, "Open tint2 Default", None, "Open the current tint2 default config", self
.openDef
),
289 ("Apply", gtk
.STOCK_APPLY
, "Apply Config", None, "Apply the current config to tint2", self
.apply),
290 ("Quit", gtk
.STOCK_QUIT
, "_Quit", None, "Quit the program", self
.quit
),
291 ("Tools", None, "_Tools"),
292 ("Tint2", None, "Tint_2"),
293 ("HelpMenu", None, "_Help"),
294 ("FontChange",gtk
.STOCK_SELECT_FONT
, "Change All Fonts", None, "Change all fonts at once.", self
.changeAllFonts
),
295 ("Defaults",gtk
.STOCK_PREFERENCES
, "Change Defaults", None, "Change tintwizard defaults.", self
.changeDefaults
),
296 ("Help",gtk
.STOCK_HELP
, "_Help", None, "Get help with tintwizard", self
.help),
297 ("Report Bug",None, "Report Bug", None, "Report a problem with tintwizard", self
.reportBug
),
298 ("About",gtk
.STOCK_ABOUT
, "_About Tint Wizard", None, "Find out more about Tint Wizard", self
.about
)])
301 self
.uiManager
.insert_action_group(self
.ag
, -1)
302 self
.uiManager
.add_ui_from_string(ui
)
304 if not self
.oneConfigFile
:
305 # Attach menubar and toolbar to main window
306 self
.table
.attach(self
.uiManager
.get_widget("/MenuBar"), 0, 4, 0, 1)
307 self
.table
.attach(self
.uiManager
.get_widget("/ToolBar"), 0, 4, 1, 2)
310 self
.notebook
= gtk
.Notebook()
311 self
.notebook
.set_tab_pos(gtk
.POS_TOP
)
313 # Create notebook pages
315 self
.tableBgs
= gtk
.Table(rows
=1, columns
=1, homogeneous
=False)
316 self
.tableBgs
.set_row_spacings(5)
317 self
.tableBgs
.set_col_spacings(5)
319 self
.bgNotebook
= gtk
.Notebook()
320 self
.bgNotebook
.set_scrollable(True)
322 self
.tableBgs
.attach(self
.bgNotebook
, 0, 2, 0, 1)
326 # Add buttons for adding/deleting background styles
327 createButton(self
.tableBgs
, text
="New Background", stock
=gtk
.STOCK_NEW
, name
="addBg", gridX
=0, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.addBgClick
)
328 createButton(self
.tableBgs
, text
="Delete Background", stock
=gtk
.STOCK_DELETE
, name
="delBg", gridX
=1, gridY
=1, xExpand
=True, yExpand
=True, handler
=self
.delBgClick
)
331 self
.createPanelDisplayWidgets()
332 self
.createPanelSettingsWidgets()
333 self
.createPanelAutohideWidgets()
336 self
.createTaskbarWidgets()
339 self
.createTaskSettingsWidgets()
340 self
.createNormalTasksWidgets()
341 self
.createActiveTasksWidgets()
342 self
.createUrgentTasksWidgets()
343 self
.createIconifiedTasksWidgets()
346 self
.createSystemTrayWidgets()
349 self
.createClockDisplayWidgets()
350 self
.createClockSettingsWidgets()
353 self
.createMouseWidgets()
356 self
.createTooltipsWidgets()
359 self
.createBatteryWidgets()
362 self
.configArea
= gtk
.ScrolledWindow()
363 self
.configBuf
= gtk
.TextBuffer()
364 self
.configTextView
= gtk
.TextView(self
.configBuf
)
365 self
.configArea
.add_with_viewport(self
.configTextView
)
367 # Add backgrounds to notebooks
368 for i
in range(self
.defaults
["bgCount"]):
369 self
.addBgClick(None, init
=True)
371 self
.bgNotebook
.set_current_page(0)
373 # Create sub-notebooks
374 self
.panelNotebook
= gtk
.Notebook()
375 self
.panelNotebook
.set_tab_pos(gtk
.POS_TOP
)
376 self
.panelNotebook
.set_current_page(0)
378 self
.panelNotebook
.append_page(self
.tablePanelDisplay
, gtk
.Label("Panel Display"))
379 self
.panelNotebook
.append_page(self
.tablePanelSettings
, gtk
.Label("Panel Settings"))
380 self
.panelNotebook
.append_page(self
.tablePanelAutohide
, gtk
.Label("Panel Autohide"))
382 self
.taskNotebook
= gtk
.Notebook()
383 self
.taskNotebook
.set_tab_pos(gtk
.POS_TOP
)
384 self
.taskNotebook
.set_current_page(0)
386 self
.taskNotebook
.append_page(self
.tableTask
, gtk
.Label("Task Settings"))
387 self
.taskNotebook
.append_page(self
.tableTaskDefault
, gtk
.Label("Normal Tasks"))
388 self
.taskNotebook
.append_page(self
.tableTaskActive
, gtk
.Label("Active Tasks"))
389 self
.taskNotebook
.append_page(self
.tableTaskUrgent
, gtk
.Label("Urgent Tasks"))
390 self
.taskNotebook
.append_page(self
.tableTaskIconified
, gtk
.Label("Iconified Tasks"))
392 self
.clockNotebook
= gtk
.Notebook()
393 self
.clockNotebook
.set_tab_pos(gtk
.POS_TOP
)
394 self
.clockNotebook
.set_current_page(0)
396 self
.clockNotebook
.append_page(self
.tableClockDisplays
, gtk
.Label("Clock Display"))
397 self
.clockNotebook
.append_page(self
.tableClockSettings
, gtk
.Label("Clock Settings"))
399 # Add pages to notebook
400 self
.notebook
.append_page(self
.tableBgs
, gtk
.Label("Backgrounds"))
401 self
.notebook
.append_page(self
.panelNotebook
, gtk
.Label("Panel"))
402 self
.notebook
.append_page(self
.tableTaskbar
, gtk
.Label("Taskbar"))
403 self
.notebook
.append_page(self
.taskNotebook
, gtk
.Label("Tasks"))
404 self
.notebook
.append_page(self
.tableTray
, gtk
.Label("System Tray"))
405 self
.notebook
.append_page(self
.clockNotebook
, gtk
.Label("Clock"))
406 self
.notebook
.append_page(self
.tableMouse
, gtk
.Label("Mouse"))
407 self
.notebook
.append_page(self
.tableTooltip
, gtk
.Label("Tooltips"))
408 self
.notebook
.append_page(self
.tableBattery
, gtk
.Label("Battery"))
409 self
.notebook
.append_page(self
.configArea
, gtk
.Label("View Config"))
411 self
.notebook
.connect("switch-page", self
.switchPage
)
413 # Add notebook to window and show
414 self
.table
.attach(self
.notebook
, 0, 4, 2, 3, xpadding
=5, ypadding
=5)
416 if self
.oneConfigFile
:
417 # Add button Apply and Close
418 self
.box1
= gtk
.HBox(False, 20)
419 self
.table
.attach(self
.box1
, 0, 4, 3, 4, xpadding
=5, ypadding
=5)
420 temp
= gtk
.Button("Apply", gtk
.STOCK_APPLY
)
421 temp
.set_name("applyBg")
422 temp
.connect("clicked", self
.apply)
423 self
.box1
.pack_start(temp
, True, True, 0)
424 temp
= gtk
.Button("Close", gtk
.STOCK_CLOSE
)
425 temp
.set_name("closeBg")
426 temp
.connect("clicked", self
.quit
)
427 self
.box1
.pack_start(temp
, True, True, 0)
429 # Create and add the status bar to the bottom of the main window
430 self
.statusBar
= gtk
.Statusbar()
431 self
.statusBar
.set_has_resize_grip(True)
432 self
.updateStatusBar("New Config File [*]")
433 self
.table
.attach(self
.statusBar
, 0, 4, 4, 5)
439 # If tintwizard was launched with a tint2 config filename
440 # as an argument, load that config.
441 if self
.oneConfigFile
:
442 self
.readTint2Config()
444 self
.generateConfig()
446 def createPanelDisplayWidgets(self
):
447 """Create the Panel Display widgets."""
448 self
.tablePanelDisplay
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
449 self
.tablePanelDisplay
.set_row_spacings(5)
450 self
.tablePanelDisplay
.set_col_spacings(5)
452 createLabel(self
.tablePanelDisplay
, text
="Position", gridX
=0, gridY
=0, xPadding
=10)
453 self
.panelPosY
= createComboBox(self
.tablePanelDisplay
, ["bottom", "top", "center"], gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
454 self
.panelPosX
= createComboBox(self
.tablePanelDisplay
, ["left", "right", "center"], gridX
=2, gridY
=0, handler
=self
.changeOccurred
)
455 # Note: registered below
457 createLabel(self
.tablePanelDisplay
, text
="Panel Orientation", gridX
=0, gridY
=1, xPadding
=10)
458 self
.panelOrientation
= createComboBox(self
.tablePanelDisplay
, ["horizontal", "vertical"], gridX
=1, gridY
=1, handler
=self
.changeOccurred
)
459 self
.registerComponent("panel_position", (self
.panelPosY
, self
.panelPosX
, self
.panelOrientation
))
461 createLabel(self
.tablePanelDisplay
, text
="Panel Items", gridX
=0, gridY
=2, xPadding
=10)
462 self
.panelItems
= createEntry(self
.tablePanelDisplay
, maxSize
=7, width
=8, text
=PANEL_ITEMS
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
463 self
.registerComponent("panel_items", self
.panelItems
)
465 self
.panelSizeLabel
= createLabel(self
.tablePanelDisplay
, text
="Size (width, height)", gridX
=0, gridY
=3, xPadding
=10)
466 self
.panelSizeX
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_SIZE_X
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
467 self
.panelSizeY
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_SIZE_Y
, gridX
=2, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
468 self
.registerComponent("panel_size", (self
.panelSizeX
, self
.panelSizeY
))
470 createLabel(self
.tablePanelDisplay
, text
="Margin (x, y)", gridX
=0, gridY
=4, xPadding
=10)
471 self
.panelMarginX
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_MARGIN_X
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
472 self
.panelMarginY
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_MARGIN_Y
, gridX
=2, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
473 self
.registerComponent("panel_margin", (self
.panelMarginX
, self
.panelMarginY
))
475 createLabel(self
.tablePanelDisplay
, text
="Padding (x, y)", gridX
=0, gridY
=5, xPadding
=10)
476 self
.panelPadX
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_PADDING_X
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
477 self
.panelPadY
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=PANEL_PADDING_Y
, gridX
=2, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
480 createLabel(self
.tablePanelDisplay
, text
="Horizontal Spacing", gridX
=0, gridY
=6, xPadding
=10)
481 self
.panelSpacing
= createEntry(self
.tablePanelDisplay
, maxSize
=6, width
=8, text
=TASKBAR_SPACING
, gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
482 self
.registerComponent("panel_padding", (self
.panelPadX
, self
.panelPadY
, self
.panelSpacing
))
484 createLabel(self
.tablePanelDisplay
, text
="Panel Background ID", gridX
=0, gridY
=7, xPadding
=10)
485 self
.panelBg
= createComboBox(self
.tablePanelDisplay
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=7, handler
=self
.changeOccurred
)
486 self
.registerComponent("panel_background_id", self
.panelBg
)
488 def createPanelSettingsWidgets(self
):
489 """Create the Panel Settings widgets."""
490 self
.tablePanelSettings
= gtk
.Table(rows
=5, columns
=3, homogeneous
=False)
491 self
.tablePanelSettings
.set_row_spacings(5)
492 self
.tablePanelSettings
.set_col_spacings(5)
494 createLabel(self
.tablePanelSettings
, text
="Window Manager Menu", gridX
=0, gridY
=0, xPadding
=10)
495 self
.panelMenu
= createCheckButton(self
.tablePanelSettings
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
496 self
.registerComponent("wm_menu", self
.panelMenu
)
498 createLabel(self
.tablePanelSettings
, text
="Place In Window Manager Dock", gridX
=0, gridY
=1, xPadding
=10)
499 self
.panelDock
= createCheckButton(self
.tablePanelSettings
, active
=False, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
500 self
.registerComponent("panel_dock", self
.panelDock
)
502 createLabel(self
.tablePanelSettings
, text
="Panel Layer", gridX
=0, gridY
=2, xPadding
=10)
503 self
.panelLayer
= createComboBox(self
.tablePanelSettings
, ["bottom", "top", "normal"], gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
504 self
.registerComponent("panel_layer", self
.panelLayer
)
506 createLabel(self
.tablePanelSettings
, text
="Strut Policy", gridX
=0, gridY
=3, xPadding
=10)
507 self
.panelAutohideStrut
= createComboBox(self
.tablePanelSettings
, ["none", "minimum", "follow_size"], gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
508 self
.registerComponent("strut_policy", self
.panelAutohideStrut
)
510 createLabel(self
.tablePanelSettings
, text
="Panel Monitor (all, 1, 2, ...)", gridX
=0, gridY
=4, xPadding
=10)
511 self
.panelMonitor
= createEntry(self
.tablePanelSettings
, maxSize
=6, width
=8, text
=PANEL_MONITOR
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
512 self
.registerComponent("panel_monitor", self
.panelMonitor
)
514 def createPanelAutohideWidgets(self
):
515 """Create the Panel Autohide widgets."""
516 self
.tablePanelAutohide
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
517 self
.tablePanelAutohide
.set_row_spacings(5)
518 self
.tablePanelAutohide
.set_col_spacings(5)
520 createLabel(self
.tablePanelAutohide
, text
="Autohide Panel", gridX
=0, gridY
=0, xPadding
=10)
521 self
.panelAutohide
= createCheckButton(self
.tablePanelAutohide
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
522 self
.registerComponent("autohide", self
.panelAutohide
)
524 createLabel(self
.tablePanelAutohide
, text
="Autohide Show Timeout (seconds)", gridX
=0, gridY
=1, xPadding
=10)
525 self
.panelAutohideShow
= createEntry(self
.tablePanelAutohide
, maxSize
=6, width
=8, text
=PANEL_AUTOHIDE_SHOW
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
526 self
.registerComponent("autohide_show_timeout", self
.panelAutohideShow
)
528 createLabel(self
.tablePanelAutohide
, text
="Autohide Hide Timeout (seconds)", gridX
=0, gridY
=2, xPadding
=10)
529 self
.panelAutohideHide
= createEntry(self
.tablePanelAutohide
, maxSize
=6, width
=8, text
=PANEL_AUTOHIDE_HIDE
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
530 self
.registerComponent("autohide_hide_timeout", self
.panelAutohideHide
)
532 createLabel(self
.tablePanelAutohide
, text
="Autohide Hidden Height", gridX
=0, gridY
=3, xPadding
=10)
533 self
.panelAutohideHeight
= createEntry(self
.tablePanelAutohide
, maxSize
=6, width
=8, text
=PANEL_AUTOHIDE_HEIGHT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
534 self
.registerComponent("autohide_height", self
.panelAutohideHeight
)
536 def createTaskbarWidgets(self
):
537 """Create the Taskbar widgets."""
538 self
.tableTaskbar
= gtk
.Table(rows
=5, columns
=3, homogeneous
=False)
539 self
.tableTaskbar
.set_row_spacings(5)
540 self
.tableTaskbar
.set_col_spacings(5)
542 createLabel(self
.tableTaskbar
, text
="Taskbar Mode", gridX
=0, gridY
=0, xPadding
=10)
543 self
.taskbarMode
= createComboBox(self
.tableTaskbar
, ["single_desktop", "multi_desktop"], gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
544 self
.registerComponent("taskbar_mode", self
.taskbarMode
)
546 createLabel(self
.tableTaskbar
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
547 self
.taskbarPadX
= createEntry(self
.tableTaskbar
, maxSize
=6, width
=8, text
=TASKBAR_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
548 self
.taskbarPadY
= createEntry(self
.tableTaskbar
, maxSize
=6, width
=8, text
=TASKBAR_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
551 createLabel(self
.tableTaskbar
, text
="Horizontal Spacing", gridX
=0, gridY
=2, xPadding
=10)
552 self
.taskbarSpacing
= createEntry(self
.tableTaskbar
, maxSize
=6, width
=8, text
=TASK_SPACING
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
553 self
.registerComponent("taskbar_padding", (self
.taskbarPadX
, self
.taskbarPadY
, self
.taskbarSpacing
))
555 createLabel(self
.tableTaskbar
, text
="Taskbar Background ID", gridX
=0, gridY
=3, xPadding
=10)
556 self
.taskbarBg
= createComboBox(self
.tableTaskbar
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
557 self
.registerComponent("taskbar_background_id", self
.taskbarBg
)
559 createLabel(self
.tableTaskbar
, text
="Active Taskbar Background ID", gridX
=0, gridY
=4, xPadding
=10)
560 self
.taskbarActiveBg
= createComboBox(self
.tableTaskbar
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
561 self
.registerComponent("taskbar_active_background_id", self
.taskbarActiveBg
)
563 def createTaskSettingsWidgets(self
):
564 """Create the Task Settings widgets."""
565 self
.tableTask
= gtk
.Table(rows
=12, columns
=3, homogeneous
=False)
566 self
.tableTask
.set_row_spacings(5)
567 self
.tableTask
.set_col_spacings(5)
569 createLabel(self
.tableTask
, text
="Number of 'Blinks' on Urgent Event", gridX
=0, gridY
=0, xPadding
=10)
570 self
.taskBlinks
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_BLINKS
, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
571 self
.registerComponent("urgent_nb_of_blink", self
.taskBlinks
)
573 createLabel(self
.tableTask
, text
="Show Icons", gridX
=0, gridY
=1, xPadding
=10)
574 self
.taskIconCheckButton
= createCheckButton(self
.tableTask
, active
=True, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
575 self
.registerComponent("task_icon", self
.taskIconCheckButton
)
577 createLabel(self
.tableTask
, text
="Show Text", gridX
=0, gridY
=2, xPadding
=10)
578 self
.taskTextCheckButton
= createCheckButton(self
.tableTask
, active
=True, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
579 self
.registerComponent("task_text", self
.taskTextCheckButton
)
581 createLabel(self
.tableTask
, text
="Centre Text", gridX
=0, gridY
=3, xPadding
=10)
582 self
.taskCentreCheckButton
= createCheckButton(self
.tableTask
, active
=True, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
583 self
.registerComponent("task_centered", self
.taskCentreCheckButton
)
585 createLabel(self
.tableTask
, text
="Font", gridX
=0, gridY
=4, xPadding
=10)
586 self
.fontButton
= gtk
.FontButton()
588 if self
.defaults
["font"] in [None, "None"]: # If there was no font specified in the config file
589 self
.defaults
["font"] = self
.fontButton
.get_font_name() # Use the gtk default
591 self
.fontButton
= createFontButton(self
.tableTask
, font
=self
.defaults
["font"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
592 self
.registerComponent("task_font", self
.fontButton
)
594 createLabel(self
.tableTask
, text
="Show Font Shadow", gridX
=0, gridY
=5, xPadding
=10)
595 self
.fontShadowCheckButton
= createCheckButton(self
.tableTask
, active
=False, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
596 self
.registerComponent("font_shadow", self
.fontShadowCheckButton
)
598 createLabel(self
.tableTask
, text
="Maximum Size (x, y)", gridX
=0, gridY
=6, xPadding
=10)
599 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
)
600 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
)
601 self
.registerComponent("task_maximum_size", (self
.taskMaxSizeX
, self
.taskMaxSizeY
))
603 createLabel(self
.tableTask
, text
="Padding (x, y)", gridX
=0, gridY
=7, xPadding
=10)
604 self
.taskPadX
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_PADDING_X
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
605 self
.taskPadY
= createEntry(self
.tableTask
, maxSize
=6, width
=8, text
=TASK_PADDING_Y
, gridX
=2, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
606 self
.registerComponent("task_padding", (self
.taskPadX
, self
.taskPadY
))
608 def createNormalTasksWidgets(self
):
609 """Create the Normal Tasks widgets."""
610 self
.tableTaskDefault
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
611 self
.tableTaskDefault
.set_row_spacings(5)
612 self
.tableTaskDefault
.set_col_spacings(5)
614 createLabel(self
.tableTaskDefault
, text
="Normal Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
615 self
.taskBg
= createComboBox(self
.tableTaskDefault
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
616 self
.registerComponent("task_background_id", self
.taskBg
)
618 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)
620 createLabel(self
.tableTaskDefault
, text
="Normal Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
621 self
.iconHue
= createEntry(self
.tableTaskDefault
, maxSize
=6, width
=8, text
=ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
624 createLabel(self
.tableTaskDefault
, text
="Normal Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
625 self
.iconSat
= createEntry(self
.tableTaskDefault
, maxSize
=6, width
=8, text
=ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
628 createLabel(self
.tableTaskDefault
, text
="Normal Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
629 self
.iconBri
= createEntry(self
.tableTaskDefault
, maxSize
=6, width
=8, text
=ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
630 self
.registerComponent("task_icon_asb", (self
.iconHue
, self
.iconSat
, self
.iconBri
))
632 createLabel(self
.tableTaskDefault
, text
="Normal Font Color", gridX
=0, gridY
=5, xPadding
=10)
633 self
.fontCol
= createEntry(self
.tableTaskDefault
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontCol")
634 self
.fontCol
.connect("activate", self
.colorTyped
)
635 self
.fontColButton
= createColorButton(self
.tableTaskDefault
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
636 self
.fontCol
.set_text(self
.defaults
["fgColor"])
637 # Add this AFTER we set color to avoid "changed" event
638 self
.fontCol
.connect("changed", self
.changeOccurred
)
639 self
.registerComponent("task_font_color", (self
.fontCol
, self
.fontColButton
))
641 def createActiveTasksWidgets(self
):
642 """Create the Active Tasks widgets."""
643 self
.tableTaskActive
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
644 self
.tableTaskActive
.set_row_spacings(5)
645 self
.tableTaskActive
.set_col_spacings(5)
647 createLabel(self
.tableTaskActive
, text
="Active Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
648 self
.taskActiveBg
= createComboBox(self
.tableTaskActive
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
649 self
.registerComponent("task_active_background_id", self
.taskActiveBg
)
651 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)
653 createLabel(self
.tableTaskActive
, text
="Active Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
654 self
.activeIconHue
= createEntry(self
.tableTaskActive
, maxSize
=6, width
=8, text
=ACTIVE_ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
657 createLabel(self
.tableTaskActive
, text
="Active Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
658 self
.activeIconSat
= createEntry(self
.tableTaskActive
, maxSize
=6, width
=8, text
=ACTIVE_ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
661 createLabel(self
.tableTaskActive
, text
="Active Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
662 self
.activeIconBri
= createEntry(self
.tableTaskActive
, maxSize
=6, width
=8, text
=ACTIVE_ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
663 self
.registerComponent("task_active_icon_asb", (self
.activeIconHue
, self
.activeIconSat
, self
.activeIconBri
))
665 createLabel(self
.tableTaskActive
, text
="Active Font Color", gridX
=0, gridY
=5, xPadding
=10)
666 self
.fontActiveCol
= createEntry(self
.tableTaskActive
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontActiveCol")
667 self
.fontActiveCol
.connect("activate", self
.colorTyped
)
668 self
.fontActiveColButton
= createColorButton(self
.tableTaskActive
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontActiveCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
669 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
670 # Add this AFTER we set color to avoid "changed" event
671 self
.fontActiveCol
.connect("changed", self
.changeOccurred
)
672 self
.registerComponent("task_active_font_color", (self
.fontActiveCol
, self
.fontActiveColButton
))
674 def createUrgentTasksWidgets(self
):
675 """Create the Urgent Tasks widgets."""
676 self
.tableTaskUrgent
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
677 self
.tableTaskUrgent
.set_row_spacings(5)
678 self
.tableTaskUrgent
.set_col_spacings(5)
680 createLabel(self
.tableTaskUrgent
, text
="Urgent Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
681 self
.taskUrgentBg
= createComboBox(self
.tableTaskUrgent
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
682 self
.registerComponent("task_urgent_background_id", self
.taskUrgentBg
)
684 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)
686 createLabel(self
.tableTaskUrgent
, text
="Urgent Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
687 self
.urgentIconHue
= createEntry(self
.tableTaskUrgent
, maxSize
=6, width
=8, text
=URGENT_ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
690 createLabel(self
.tableTaskUrgent
, text
="Urgent Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
691 self
.urgentIconSat
= createEntry(self
.tableTaskUrgent
, maxSize
=6, width
=8, text
=URGENT_ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
694 createLabel(self
.tableTaskUrgent
, text
="Urgent Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
695 self
.urgentIconBri
= createEntry(self
.tableTaskUrgent
, maxSize
=6, width
=8, text
=URGENT_ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
696 self
.registerComponent("task_urgent_icon_asb", (self
.urgentIconHue
, self
.urgentIconSat
, self
.urgentIconBri
))
698 createLabel(self
.tableTaskUrgent
, text
="Urgent Font Color", gridX
=0, gridY
=5, xPadding
=10)
699 self
.fontUrgentCol
= createEntry(self
.tableTaskUrgent
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontUrgentCol")
700 self
.fontUrgentCol
.connect("activate", self
.colorTyped
)
701 self
.fontUrgentColButton
= createColorButton(self
.tableTaskUrgent
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontUrgentCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
702 self
.fontUrgentCol
.set_text(self
.defaults
["fgColor"])
703 # Add this AFTER we set color to avoid "changed" event
704 self
.fontUrgentCol
.connect("changed", self
.changeOccurred
)
705 self
.registerComponent("task_urgent_font_color", (self
.fontUrgentCol
, self
.fontUrgentColButton
))
707 def createIconifiedTasksWidgets(self
):
708 """Create the Iconified Tasks widgets."""
709 self
.tableTaskIconified
= gtk
.Table(rows
=6, columns
=3, homogeneous
=False)
710 self
.tableTaskIconified
.set_row_spacings(5)
711 self
.tableTaskIconified
.set_col_spacings(5)
713 createLabel(self
.tableTaskIconified
, text
="Iconified Task Background ID", gridX
=0, gridY
=0, xPadding
=10)
714 self
.taskIconifiedBg
= createComboBox(self
.tableTaskIconified
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
715 self
.registerComponent("task_iconified_background_id", self
.taskIconifiedBg
)
717 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)
719 createLabel(self
.tableTaskIconified
, text
="Iconified Icon Alpha (0 to 100)", gridX
=0, gridY
=2, xPadding
=10)
720 self
.iconifiedIconHue
= createEntry(self
.tableTaskIconified
, maxSize
=6, width
=8, text
=ICONIFIED_ICON_ALPHA
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
723 createLabel(self
.tableTaskIconified
, text
="Iconified Icon Saturation (-100 to 100)", gridX
=0, gridY
=3, xPadding
=10)
724 self
.iconifiedIconSat
= createEntry(self
.tableTaskIconified
, maxSize
=6, width
=8, text
=ICONIFIED_ICON_SAT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
727 createLabel(self
.tableTaskIconified
, text
="Iconified Icon Brightness (-100 to 100)", gridX
=0, gridY
=4, xPadding
=10)
728 self
.iconifiedIconBri
= createEntry(self
.tableTaskIconified
, maxSize
=6, width
=8, text
=ICONIFIED_ICON_BRI
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
729 self
.registerComponent("task_iconified_icon_asb", (self
.iconifiedIconHue
, self
.iconifiedIconSat
, self
.iconifiedIconBri
))
731 createLabel(self
.tableTaskIconified
, text
="Iconified Font Color", gridX
=0, gridY
=5, xPadding
=10)
732 self
.fontIconifiedCol
= createEntry(self
.tableTaskIconified
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=None, name
="fontIconifiedCol")
733 self
.fontIconifiedCol
.connect("activate", self
.colorTyped
)
734 self
.fontIconifiedColButton
= createColorButton(self
.tableTaskIconified
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="fontIconifiedCol", gridX
=2, gridY
=5, handler
=self
.colorChange
)
735 self
.fontIconifiedCol
.set_text(self
.defaults
["fgColor"])
736 # Add this AFTER we set color to avoid "changed" event
737 self
.fontIconifiedCol
.connect("changed", self
.changeOccurred
)
738 self
.registerComponent("task_iconified_font_color", (self
.fontIconifiedCol
, self
.fontIconifiedColButton
))
740 def createSystemTrayWidgets(self
):
741 """Create the System Tray widgets."""
742 self
.tableTray
= gtk
.Table(rows
=9, columns
=3, homogeneous
=False)
743 self
.tableTray
.set_row_spacings(5)
744 self
.tableTray
.set_col_spacings(5)
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
="Time 1 Format", gridX
=0, gridY
=1, xPadding
=10)
786 self
.clock1Format
= createEntry(self
.tableClockDisplays
, maxSize
=50, width
=20, text
=CLOCK_FMT_1
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
787 self
.registerComponent("time1_format", self
.clock1Format
)
789 createLabel(self
.tableClockDisplays
, text
="Time 1 Font", gridX
=0, gridY
=2, xPadding
=10)
790 self
.clock1FontButton
= createFontButton(self
.tableClockDisplays
, font
=self
.defaults
["font"], gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
791 self
.registerComponent("time1_font", self
.clock1FontButton
)
793 createLabel(self
.tableClockDisplays
, text
="Time 2 Format", gridX
=0, gridY
=3, xPadding
=10)
794 self
.clock2Format
= createEntry(self
.tableClockDisplays
, maxSize
=50, width
=20, text
=CLOCK_FMT_2
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
795 self
.registerComponent("time2_format", self
.clock2Format
)
797 createLabel(self
.tableClockDisplays
, text
="Time 2 Font", gridX
=0, gridY
=4, xPadding
=10)
798 self
.clock2FontButton
= createFontButton(self
.tableClockDisplays
, font
=self
.defaults
["font"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
799 self
.registerComponent("time2_font", self
.clock2FontButton
)
801 createLabel(self
.tableClockDisplays
, text
="Tooltip Format", gridX
=0, gridY
=5, xPadding
=10)
802 self
.clockTooltipFormat
= createEntry(self
.tableClockDisplays
, maxSize
=50, width
=20, text
=CLOCK_TOOLTIP
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
803 self
.registerComponent("clock_tooltip", self
.clockTooltipFormat
)
805 self
.clockArea
= gtk
.ScrolledWindow()
806 self
.clockBuf
= gtk
.TextBuffer()
807 self
.clockTextView
= gtk
.TextView(self
.clockBuf
)
808 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")
809 self
.clockTextView
.set_editable(False)
810 self
.clockArea
.add_with_viewport(self
.clockTextView
)
811 self
.tableClockDisplays
.attach(self
.clockArea
, 0, 3, 6, 7, xpadding
=10)
813 def createClockSettingsWidgets(self
):
814 """Create the Clock Settings widgets."""
815 self
.tableClockSettings
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
816 self
.tableClockSettings
.set_row_spacings(5)
817 self
.tableClockSettings
.set_col_spacings(5)
819 createLabel(self
.tableClockSettings
, text
="Clock Font Color", gridX
=0, gridY
=0, xPadding
=10)
820 self
.clockFontCol
= createEntry(self
.tableClockSettings
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=None, name
="clockFontCol")
821 self
.clockFontCol
.connect("activate", self
.colorTyped
)
822 self
.clockFontColButton
= createColorButton(self
.tableClockSettings
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="clockFontCol", gridX
=2, gridY
=0, handler
=self
.colorChange
)
823 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
824 # Add this AFTER we set color to avoid "changed" event
825 self
.clockFontCol
.connect("changed", self
.changeOccurred
)
826 self
.registerComponent("clock_font_color", (self
.clockFontCol
, self
.clockFontColButton
))
828 createLabel(self
.tableClockSettings
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
829 self
.clockPadX
= createEntry(self
.tableClockSettings
, maxSize
=6, width
=8, text
=CLOCK_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
830 self
.clockPadY
= createEntry(self
.tableClockSettings
, maxSize
=6, width
=8, text
=CLOCK_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
831 self
.registerComponent("clock_padding", (self
.clockPadX
, self
.clockPadY
))
833 createLabel(self
.tableClockSettings
, text
="Clock Background ID", gridX
=0, gridY
=2, xPadding
=10)
834 self
.clockBg
= createComboBox(self
.tableClockSettings
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
835 self
.registerComponent("clock_background_id", self
.clockBg
)
837 createLabel(self
.tableClockSettings
, text
="Left Click Command", gridX
=0, gridY
=3, xPadding
=10)
838 self
.clockLClick
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_LCLICK
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
839 self
.registerComponent("clock_lclick_command", self
.clockLClick
)
841 createLabel(self
.tableClockSettings
, text
="Right Click Command", gridX
=0, gridY
=4, xPadding
=10)
842 self
.clockRClick
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_RCLICK
, gridX
=1, gridY
=4, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
843 self
.registerComponent("clock_rclick_command", self
.clockRClick
)
845 createLabel(self
.tableClockSettings
, text
="Time 1 Timezone", gridX
=0, gridY
=5, xPadding
=10)
846 self
.clockTime1Timezone
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_TIME1_TIMEZONE
, gridX
=1, gridY
=5, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
847 self
.registerComponent("time1_timezone", self
.clockTime1Timezone
)
849 createLabel(self
.tableClockSettings
, text
="Time 2 Timezone", gridX
=0, gridY
=6, xPadding
=10)
850 self
.clockTime2Timezone
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_TIME2_TIMEZONE
, gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
851 self
.registerComponent("time2_timezone", self
.clockTime2Timezone
)
853 createLabel(self
.tableClockSettings
, text
="Tooltip Timezone", gridX
=0, gridY
=7, xPadding
=10)
854 self
.clockTooltipTimezone
= createEntry(self
.tableClockSettings
, maxSize
=50, width
=20, text
=CLOCK_TOOLTIP_TIMEZONE
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
855 self
.registerComponent("clock_tooltip_timezone", self
.clockTooltipTimezone
)
857 def createMouseWidgets(self
):
858 """Creates the Mouse widgets."""
859 self
.tableMouse
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
860 self
.tableMouse
.set_row_spacings(5)
861 self
.tableMouse
.set_col_spacings(5)
863 mouseCmds
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore", "desktop_left", "desktop_right", "next_task", "prev_task"]
865 createLabel(self
.tableMouse
, text
="Middle Mouse Click Action", gridX
=0, gridY
=0, xPadding
=10)
866 self
.mouseMiddle
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=0, handler
=self
.changeOccurred
)
867 self
.registerComponent("mouse_middle", self
.mouseMiddle
)
869 createLabel(self
.tableMouse
, text
="Right Mouse Click Action", gridX
=0, gridY
=1, xPadding
=10)
870 self
.mouseRight
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=1, handler
=self
.changeOccurred
)
871 self
.registerComponent("mouse_right", self
.mouseRight
)
873 createLabel(self
.tableMouse
, text
="Mouse Wheel Scroll Up Action", gridX
=0, gridY
=2, xPadding
=10)
874 self
.mouseUp
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=2, handler
=self
.changeOccurred
)
875 self
.registerComponent("mouse_scroll_up", self
.mouseUp
)
877 createLabel(self
.tableMouse
, text
="Mouse Wheel Scroll Down Action", gridX
=0, gridY
=3, xPadding
=10)
878 self
.mouseDown
= createComboBox(self
.tableMouse
, mouseCmds
, gridX
=1, gridY
=3, handler
=self
.changeOccurred
)
879 self
.registerComponent("mouse_scroll_down", self
.mouseDown
)
881 def createTooltipsWidgets(self
):
882 """Creates the Tooltips widgets."""
883 self
.tableTooltip
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
884 self
.tableTooltip
.set_row_spacings(5)
885 self
.tableTooltip
.set_col_spacings(5)
887 createLabel(self
.tableTooltip
, text
="Show Tooltips", gridX
=0, gridY
=0, xPadding
=10)
888 self
.tooltipShow
= createCheckButton(self
.tableTooltip
, active
=False, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
889 self
.registerComponent("tooltip", self
.tooltipShow
)
891 createLabel(self
.tableTooltip
, text
="Padding (x, y)", gridX
=0, gridY
=1, xPadding
=10)
892 self
.tooltipPadX
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_PADDING_X
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
893 self
.tooltipPadY
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_PADDING_Y
, gridX
=2, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
894 self
.registerComponent("tooltip_padding", (self
.tooltipPadX
, self
.tooltipPadY
))
896 createLabel(self
.tableTooltip
, text
="Tooltip Show Timeout (seconds)", gridX
=0, gridY
=2, xPadding
=10)
897 self
.tooltipShowTime
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_SHOW_TIMEOUT
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
898 self
.registerComponent("tooltip_show_timeout", self
.tooltipShowTime
)
900 createLabel(self
.tableTooltip
, text
="Tooltip Hide Timeout (seconds)", gridX
=0, gridY
=3, xPadding
=10)
901 self
.tooltipHideTime
= createEntry(self
.tableTooltip
, maxSize
=6, width
=8, text
=TOOLTIP_HIDE_TIMEOUT
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
902 self
.registerComponent("tooltip_hide_timeout", self
.tooltipHideTime
)
904 createLabel(self
.tableTooltip
, text
="Tooltip Background ID", gridX
=0, gridY
=4, xPadding
=10)
905 self
.tooltipBg
= createComboBox(self
.tableTooltip
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
906 self
.registerComponent("tooltip_background_id", self
.tooltipBg
)
908 createLabel(self
.tableTooltip
, text
="Tooltip Font", gridX
=0, gridY
=5, xPadding
=10)
909 self
.tooltipFont
= createFontButton(self
.tableTooltip
, font
=self
.defaults
["font"], gridX
=1, gridY
=5, handler
=self
.changeOccurred
)
910 self
.registerComponent("tooltip_font", self
.tooltipFont
)
912 createLabel(self
.tableTooltip
, text
="Tooltip Font Color", gridX
=0, gridY
=6, xPadding
=10)
913 self
.tooltipFontCol
= createEntry(self
.tableTooltip
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=None, name
="tooltipFontCol")
914 self
.tooltipFontCol
.connect("activate", self
.colorTyped
)
915 self
.tooltipFontColButton
= createColorButton(self
.tableTooltip
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="tooltipFontCol", gridX
=2, gridY
=6, handler
=self
.colorChange
)
916 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
917 # Add this AFTER we set color to avoid "changed" event
918 self
.tooltipFontCol
.connect("changed", self
.changeOccurred
)
919 self
.registerComponent("tooltip_font_color", (self
.tooltipFontCol
, self
.tooltipFontColButton
))
921 def createBatteryWidgets(self
):
922 """Creates the Battery widgets."""
923 self
.tableBattery
= gtk
.Table(rows
=8, columns
=3, homogeneous
=False)
924 self
.tableBattery
.set_row_spacings(5)
925 self
.tableBattery
.set_col_spacings(5)
927 createLabel(self
.tableBattery
, text
="Battery Low Status (%)", gridX
=0, gridY
=1, xPadding
=10)
928 self
.batteryLow
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_LOW
, gridX
=1, gridY
=1, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
929 self
.registerComponent("battery_low_status", self
.batteryLow
)
931 createLabel(self
.tableBattery
, text
="Battery Low Action", gridX
=0, gridY
=2, xPadding
=10)
932 self
.batteryLowAction
= createEntry(self
.tableBattery
, maxSize
=150, width
=32, text
=BATTERY_ACTION
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
933 self
.registerComponent("battery_low_cmd", self
.batteryLowAction
)
935 createLabel(self
.tableBattery
, text
="Battery Hide (0 to 100)", gridX
=0, gridY
=3, xPadding
=10)
936 self
.batteryHide
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_HIDE
, gridX
=1, gridY
=3, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
937 self
.registerComponent("battery_hide", self
.batteryHide
)
939 createLabel(self
.tableBattery
, text
="Battery 1 Font", gridX
=0, gridY
=4, xPadding
=10)
940 self
.bat1FontButton
= createFontButton(self
.tableBattery
, font
=self
.defaults
["font"], gridX
=1, gridY
=4, handler
=self
.changeOccurred
)
941 self
.registerComponent("bat1_font", self
.bat1FontButton
)
943 createLabel(self
.tableBattery
, text
="Battery 2 Font", gridX
=0, gridY
=5, xPadding
=10)
944 self
.bat2FontButton
= createFontButton(self
.tableBattery
, font
=self
.defaults
["font"], gridX
=1, gridY
=5, handler
=self
.changeOccurred
)
945 self
.registerComponent("bat2_font", self
.bat2FontButton
)
947 createLabel(self
.tableBattery
, text
="Battery Font Color", gridX
=0, gridY
=6, xPadding
=10)
948 self
.batteryFontCol
= createEntry(self
.tableBattery
, maxSize
=7, width
=9, text
="", gridX
=1, gridY
=6, xExpand
=True, yExpand
=False, handler
=None, name
="batteryFontCol")
949 self
.batteryFontCol
.connect("activate", self
.colorTyped
)
950 self
.batteryFontColButton
= createColorButton(self
.tableBattery
, color
=self
.defaults
["fgColor"], useAlpha
=True, name
="batteryFontCol", gridX
=2, gridY
=6, handler
=self
.colorChange
)
951 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
952 # Add this AFTER we set color to avoid "changed" event
953 self
.batteryFontCol
.connect("changed", self
.changeOccurred
)
954 self
.registerComponent("battery_font_color", (self
.batteryFontCol
, self
.batteryFontColButton
))
956 createLabel(self
.tableBattery
, text
="Padding (x, y)", gridX
=0, gridY
=7, xPadding
=10)
957 self
.batteryPadX
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_PADDING_X
, gridX
=1, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
958 self
.batteryPadY
= createEntry(self
.tableBattery
, maxSize
=6, width
=8, text
=BATTERY_PADDING_Y
, gridX
=2, gridY
=7, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
)
959 self
.registerComponent("battery_padding", (self
.batteryPadX
, self
.batteryPadY
))
961 createLabel(self
.tableBattery
, text
="Battery Background ID", gridX
=0, gridY
=8, xPadding
=10)
962 self
.batteryBg
= createComboBox(self
.tableBattery
, ["0 (fully transparent)"] + range(1, len(self
.bgs
)), gridX
=1, gridY
=8, handler
=self
.changeOccurred
)
963 self
.registerComponent("battery_background_id", self
.batteryBg
)
965 def registerComponent(self
, configProperty
, component
):
966 """Registers a component with a particular property from
967 a tint2 config. Note: a component may be a double or
968 triple if that property has more than one value associated
970 self
.propUI
[configProperty
] = component
972 def getComponent(self
, configProperty
):
973 """Fetches the component associated with a tint2 property."""
974 return self
.propUI
[configProperty
] if configProperty
in self
.propUI
else None
976 def about(self
, action
=None):
977 """Displays the About dialog."""
978 about
= gtk
.AboutDialog()
979 about
.set_program_name(NAME
)
980 about
.set_version(VERSION
)
981 about
.set_authors(AUTHORS
)
982 about
.set_comments(COMMENTS
)
983 about
.set_website(WEBSITE
)
984 gtk
.about_dialog_set_url_hook(self
.aboutLinkCallback
)
988 def aboutLinkCallback(dialog
, link
, data
=None):
989 """Callback for when a URL is clicked in an About dialog."""
991 webbrowser
.open(link
)
993 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit %s" % link
)
996 """Adds a new background to the list of backgrounds."""
997 self
.bgs
+= [gtk
.Table(4, 3, False)]
999 createLabel(self
.bgs
[-1], text
="Corner Rounding (px)", gridX
=0, gridY
=0, xPadding
=10)
1000 createEntry(self
.bgs
[-1], maxSize
=7, width
=9, text
=BG_ROUNDING
, gridX
=1, gridY
=0, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
, name
="rounded")
1002 createLabel(self
.bgs
[-1], text
="Background Color", gridX
=0, gridY
=1, xPadding
=10)
1004 temp
.set_width_chars(9)
1005 temp
.set_name("bgColEntry")
1006 temp
.set_text(self
.defaults
["bgColor"])
1007 temp
.connect("changed", self
.changeOccurred
)
1008 temp
.connect("activate", self
.colorTyped
)
1009 self
.bgs
[-1].attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1010 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["bgColor"]))
1011 temp
.set_use_alpha(True)
1012 temp
.set_name("bgCol")
1013 temp
.connect("color-set", self
.colorChange
)
1014 self
.bgs
[-1].attach(temp
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1016 createLabel(self
.bgs
[-1], text
="Border Width (px)", gridX
=0, gridY
=2, xPadding
=10)
1017 createEntry(self
.bgs
[-1], maxSize
=7, width
=9, text
=BG_BORDER
, gridX
=1, gridY
=2, xExpand
=True, yExpand
=False, handler
=self
.changeOccurred
, name
="border")
1019 createLabel(self
.bgs
[-1], text
="Border Color", gridX
=0, gridY
=3, xPadding
=10)
1021 temp
.set_width_chars(9)
1022 temp
.set_name("borderColEntry")
1023 temp
.connect("activate", self
.colorTyped
)
1024 temp
.set_text(self
.defaults
["borderColor"])
1025 temp
.connect("changed", self
.changeOccurred
)
1026 self
.bgs
[-1].attach(temp
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
1027 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["borderColor"]))
1028 temp
.set_use_alpha(True)
1029 temp
.set_name("borderCol")
1030 temp
.connect("color-set", self
.colorChange
)
1031 self
.bgs
[-1].attach(temp
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1033 # Note: Only set init to True when initialising background styles.
1034 # This prevents unwanted calls to changeOccurred()
1035 def addBgClick(self
, widget
=None, init
=False):
1036 """Creates a new background and adds a new tab to the notebook."""
1037 n
= self
.bgNotebook
.get_n_pages()
1039 if n
> (self
.defaults
["bgCount"] + 2):
1040 if confirmDialog(self
, "You already have %d background styles. Are you sure you would like another?" % n
) == gtk
.RESPONSE_NO
:
1045 newId
= len(self
.bgs
)
1047 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1049 self
.bgNotebook
.show_all()
1051 self
.updateComboBoxes(n
, "add")
1053 self
.bgNotebook
.set_current_page(n
)
1056 self
.changeOccurred()
1058 def addBgDefs(self
, bgDefs
):
1059 """Add interface elements for a list of background style definitions. bgDefs
1060 should be a list containing dictionaries with the following keys: rounded,
1061 border_width, background_color, border_color"""
1065 for child
in self
.bgs
[-1].get_children():
1066 if child
.get_name() == "rounded":
1067 child
.set_text(d
["rounded"])
1068 elif child
.get_name() == "border":
1069 child
.set_text(d
["border_width"])
1070 elif child
.get_name() == "bgColEntry":
1071 child
.set_text(d
["background_color"].split(" ")[0].strip())
1073 elif child
.get_name() == "borderColEntry":
1074 child
.set_text(d
["border_color"].split(" ")[0].strip())
1076 elif child
.get_name() == "bgCol":
1077 list = d
["background_color"].split(" ")
1079 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1081 child
.set_alpha(65535)
1082 elif child
.get_name() == "borderCol":
1083 list = d
["border_color"].split(" ")
1085 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1087 child
.set_alpha(65535)
1089 newId
= len(self
.bgs
)
1091 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1093 self
.bgNotebook
.show_all()
1095 self
.updateComboBoxes(newId
-1, "add")
1097 self
.bgNotebook
.set_current_page(newId
)
1099 def apply(self
, widget
, event
=None, confirmChange
=True):
1100 """Applies the current config to tint2."""
1101 # Check if tint2 is running
1102 procs
= os
.popen('pgrep -x "tint2"') # Check list of active processes for tint2
1103 pids
= [] # List of process ids for tint2
1105 for proc
in procs
.readlines():
1106 pids
+= [int(proc
.strip().split(" ")[0])]
1110 if self
.oneConfigFile
:
1111 # Save and copy as default
1113 tmpSrc
= self
.filename
1114 tmpDest
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1116 shutil
.copyfile(tmpSrc
, tmpDest
)
1117 except shutil
.Error
:
1119 # Ask tint2 to reload config
1121 os
.kill(pid
, signal
.SIGUSR1
)
1123 if confirmDialog(self
, "This will terminate all currently running instances of tint2 before applying config. Continue?") == gtk
.RESPONSE_YES
:
1127 #shutil.copyfile(self.filename, self.filename+".backup") # Create backup
1129 # If it is - kill it
1131 os
.kill(pid
, signal
.SIGTERM
)
1134 os
.spawnv(os
.P_NOWAIT
, self
.tint2Bin
, [self
.tint2Bin
, "-c", self
.filename
])
1136 if confirmChange
and self
.filename
!= (os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc") and confirmDialog(self
, "Use this as default tint2 config?") == gtk
.RESPONSE_YES
:
1138 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1140 shutil
.copyfile(tmp
, self
.filename
)
1141 except shutil
.Error
:
1144 #if confirmChange and confirmDialog(self, "Keep this config?") == gtk.RESPONSE_NO:
1145 # shutil.copyfile(self.filename+".backup", self.filename) # Create backup
1146 # self.apply(widget, event, False)
1148 def changeAllFonts(self
, widget
):
1149 """Changes all fonts at once."""
1150 dialog
= gtk
.FontSelectionDialog("Select Font")
1152 dialog
.set_font_name(self
.defaults
["font"])
1154 if dialog
.run() == gtk
.RESPONSE_OK
:
1155 newFont
= dialog
.get_font_name()
1157 self
.clock1FontButton
.set_font_name(newFont
)
1158 self
.clock2FontButton
.set_font_name(newFont
)
1159 self
.bat1FontButton
.set_font_name(newFont
)
1160 self
.bat2FontButton
.set_font_name(newFont
)
1161 self
.fontButton
.set_font_name(newFont
)
1165 self
.generateConfig()
1166 self
.changeOccurred()
1168 def changeDefaults(self
, widget
=None):
1169 """Shows the style preferences widget."""
1170 TintWizardPrefGUI(self
)
1172 def changeOccurred(self
, widget
=None):
1173 """Called when the user changes something, i.e. entry value"""
1176 self
.updateStatusBar(change
=True)
1178 if widget
== self
.panelOrientation
:
1179 if self
.panelOrientation
.get_active_text() == "horizontal":
1180 self
.panelSizeLabel
.set_text("Size (width, height)")
1182 self
.panelSizeLabel
.set_text("Size (height, width)")
1184 def colorChange(self
, widget
):
1185 """Update the text entry when a color button is updated."""
1186 r
= widget
.get_color().red
1187 g
= widget
.get_color().green
1188 b
= widget
.get_color().blue
1190 label
= self
.getColorLabel(widget
)
1196 label
.set_text(rgbToHex(r
, g
, b
))
1198 self
.changeOccurred()
1200 def colorTyped(self
, widget
):
1201 """Update the color button when a valid value is typed into the entry."""
1202 s
= widget
.get_text()
1204 # The color button associated with this widget.
1205 colorButton
= self
.getColorButton(widget
)
1207 # Just a precautionary check - this situation should never arise.
1209 #print "Error in colorTyped() -- unrecognised entry widget."
1212 # If the entered value is invalid, set textbox to the current
1213 # hex value of the associated color button.
1214 buttonHex
= self
.getHexFromWidget(colorButton
)
1217 errorDialog(self
, "Invalid color specification: [%s]" % s
)
1218 widget
.set_text(buttonHex
)
1222 col
= gtk
.gdk
.Color(s
)
1224 errorDialog(self
, "Invalid color specification: [%s]" % s
)
1225 widget
.set_text(buttonHex
)
1228 colorButton
.set_color(col
)
1230 # Note: only set init to True when removing backgrounds for a new config
1231 # This prevents unwanted calls to changeOccurred()
1232 def delBgClick(self
, widget
=None, prompt
=True, init
=False):
1233 """Deletes the selected background after confirming with the user."""
1234 selected
= self
.bgNotebook
.get_current_page()
1236 if selected
== -1: # Nothing to remove
1240 if confirmDialog(self
, "Remove this background?") != gtk
.RESPONSE_YES
:
1243 self
.bgNotebook
.remove_page(selected
)
1244 self
.bgs
.pop(selected
)
1246 for i
in range(self
.bgNotebook
.get_n_pages()):
1247 self
.bgNotebook
.set_tab_label_text(self
.bgNotebook
.get_nth_page(i
), "Background ID %d" % (i
+1))
1249 self
.bgNotebook
.show_all()
1251 self
.updateComboBoxes(len(self
.bgs
) + 1, "remove")
1254 self
.changeOccurred()
1256 def generateConfig(self
):
1257 """Reads values from each widget and generates a config."""
1258 self
.configBuf
.delete(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter())
1259 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Tint2 config file\n")
1260 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Generated by tintwizard (http://code.google.com/p/tintwizard/)\n")
1261 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")
1262 if not self
.oneConfigFile
:
1263 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# To use this as default tint2 config: save as $HOME/.config/tint2/tint2rc\n\n")
1265 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Background definitions\n")
1266 for i
in range(len(self
.bgs
)):
1267 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# ID %d\n" % (i
+ 1))
1269 for child
in self
.bgs
[i
].get_children():
1270 if child
.get_name() == "rounded":
1271 rounded
= child
.get_text() if child
.get_text() else BG_ROUNDING
1272 elif child
.get_name() == "border":
1273 borderW
= child
.get_text() if child
.get_text() else BG_BORDER
1274 elif child
.get_name() == "bgCol":
1275 bgCol
= self
.getHexFromWidget(child
)
1276 bgAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1277 elif child
.get_name() == "borderCol":
1278 borderCol
= self
.getHexFromWidget(child
)
1279 borderAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1281 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "rounded = %s\n" % (rounded
))
1282 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_width = %s\n" % (borderW
))
1283 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "background_color = %s %d\n" % (bgCol
, bgAlpha
))
1284 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_color = %s %d\n\n" % (borderCol
, borderAlpha
))
1286 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Panel\n")
1287 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_monitor = %s\n" % (self
.panelMonitor
.get_text() if self
.panelMonitor
.get_text() else PANEL_MONITOR
))
1288 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()))
1289 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
,
1290 self
.panelSizeY
.get_text() if self
.panelSizeY
.get_text() else PANEL_SIZE_Y
))
1291 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
,
1292 self
.panelMarginY
.get_text() if self
.panelMarginY
.get_text() else PANEL_MARGIN_Y
))
1293 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
,
1294 self
.panelPadY
.get_text() if self
.panelPadY
.get_text() else PANEL_PADDING_Y
,
1295 self
.panelSpacing
.get_text() if self
.panelSpacing
.get_text() else TASKBAR_SPACING
))
1296 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_dock = %s\n" % int(self
.panelDock
.get_active()))
1297 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "wm_menu = %s\n" % int(self
.panelMenu
.get_active()))
1298 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_layer = %s\n" % (self
.panelLayer
.get_active_text()))
1299 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_background_id = %s\n" % (self
.panelBg
.get_active()))
1301 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Panel Autohide\n")
1302 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "autohide = %s\n" % int(self
.panelAutohide
.get_active()))
1303 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
))
1304 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
))
1305 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
))
1306 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
))
1308 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Taskbar\n")
1309 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_mode = %s\n" % (self
.taskbarMode
.get_active_text()))
1310 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
,
1311 self
.taskbarPadY
.get_text() if self
.taskbarPadY
.get_text() else TASKBAR_PADDING_X
,
1312 self
.taskbarSpacing
.get_text() if self
.taskbarSpacing
.get_text() else TASK_SPACING
))
1313 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_background_id = %s\n" % (self
.taskbarBg
.get_active()))
1314 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_active_background_id = %s\n" % (self
.taskbarActiveBg
.get_active()))
1316 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tasks\n")
1317 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
))
1318 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_icon = %s\n" % int(self
.taskIconCheckButton
.get_active()))
1319 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_text = %s\n" % int(self
.taskTextCheckButton
.get_active()))
1320 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_centered = %s\n" % int(self
.taskCentreCheckButton
.get_active()))
1321 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
))
1322 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
,
1323 self
.taskPadY
.get_text() if self
.taskPadY
.get_text() else TASK_PADDING_Y
))
1324 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_background_id = %s\n" % (self
.taskBg
.get_active()))
1325 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_background_id = %s\n" % (self
.taskActiveBg
.get_active()))
1326 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_urgent_background_id = %s\n" % (self
.taskUrgentBg
.get_active()))
1327 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_iconified_background_id = %s\n" % (self
.taskIconifiedBg
.get_active()))
1329 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Task Icons\n")
1330 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
,
1331 self
.iconSat
.get_text() if self
.iconSat
.get_text() else ICON_SAT
,
1332 self
.iconBri
.get_text() if self
.iconBri
.get_text() else ICON_BRI
))
1333 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
,
1334 self
.activeIconSat
.get_text() if self
.activeIconSat
.get_text() else ACTIVE_ICON_SAT
,
1335 self
.activeIconBri
.get_text() if self
.activeIconBri
.get_text() else ACTIVE_ICON_BRI
))
1336 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
,
1337 self
.urgentIconSat
.get_text() if self
.urgentIconSat
.get_text() else URGENT_ICON_SAT
,
1338 self
.urgentIconBri
.get_text() if self
.urgentIconBri
.get_text() else URGENT_ICON_BRI
))
1339 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
,
1340 self
.iconifiedIconSat
.get_text() if self
.iconifiedIconSat
.get_text() else ICONIFIED_ICON_SAT
,
1341 self
.iconifiedIconBri
.get_text() if self
.iconifiedIconBri
.get_text() else ICONIFIED_ICON_BRI
))
1343 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Fonts\n")
1344 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font = %s\n" % (self
.fontButton
.get_font_name()))
1345 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontColButton
),
1346 int(self
.fontColButton
.get_alpha() / 65535.0 * 100)))
1347 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontActiveColButton
),
1348 int(self
.fontActiveColButton
.get_alpha() / 65535.0 * 100)))
1349 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_urgent_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontUrgentColButton
),
1350 int(self
.fontUrgentColButton
.get_alpha() / 65535.0 * 100)))
1351 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_iconified_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontIconifiedColButton
),
1352 int(self
.fontIconifiedColButton
.get_alpha() / 65535.0 * 100)))
1353 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "font_shadow = %s\n" % int(self
.fontShadowCheckButton
.get_active()))
1355 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# System Tray\n")
1356 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
,
1357 self
.trayPadY
.get_text() if self
.trayPadY
.get_text() else TRAY_PADDING_Y
,
1358 self
.traySpacing
.get_text() if self
.traySpacing
.get_text() else TRAY_SPACING
))
1359 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_sort = %s\n" % (self
.trayOrder
.get_active_text()))
1360 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_background_id = %s\n" % (self
.trayBg
.get_active()))
1361 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
))
1362 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
,
1363 self
.trayIconSat
.get_text() if self
.trayIconSat
.get_text() else TRAY_ICON_SAT
,
1364 self
.trayIconBri
.get_text() if self
.trayIconBri
.get_text() else TRAY_ICON_BRI
))
1366 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Clock\n")
1367 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
))
1368 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_font = %s\n" % (self
.clock1FontButton
.get_font_name()))
1369 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
))
1370 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_font = %s\n" % (self
.clock2FontButton
.get_font_name()))
1372 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_font_color = %s %s\n" % (self
.getHexFromWidget(self
.clockFontColButton
),
1373 int(self
.clockFontColButton
.get_alpha() / 65535.0 * 100)))
1375 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_tooltip = %s\n" % (self
.clockTooltipFormat
.get_text() if self
.clockTooltipFormat
.get_text() else CLOCK_TOOLTIP
))
1376 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
,
1377 self
.clockPadY
.get_text() if self
.clockPadY
.get_text() else CLOCK_PADDING_Y
))
1378 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_background_id = %s\n" % (self
.clockBg
.get_active()))
1379 if self
.clockLClick
.get_text():
1380 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_lclick_command = %s\n" % (self
.clockLClick
.get_text()))
1381 if self
.clockRClick
.get_text():
1382 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_rclick_command = %s\n" % (self
.clockRClick
.get_text()))
1383 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
))
1384 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
))
1385 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
))
1388 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tooltips\n")
1389 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip = %s\n" % int(self
.tooltipShow
.get_active()))
1390 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
,
1391 self
.tooltipPadY
.get_text() if self
.tooltipPadY
.get_text() else TOOLTIP_PADDING_Y
))
1392 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
))
1393 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
))
1394 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_background_id = %s\n" % (self
.tooltipBg
.get_active()))
1395 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font = %s\n" % (self
.tooltipFont
.get_font_name()))
1396 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font_color = %s %s\n" % (self
.getHexFromWidget(self
.tooltipFontColButton
),
1397 int(self
.tooltipFontColButton
.get_alpha() / 65535.0 * 100)))
1399 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Mouse\n")
1400 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_middle = %s\n" % (self
.mouseMiddle
.get_active_text()))
1401 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_right = %s\n" % (self
.mouseRight
.get_active_text()))
1402 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_up = %s\n" % (self
.mouseUp
.get_active_text()))
1403 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_down = %s\n" % (self
.mouseDown
.get_active_text()))
1405 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Battery\n")
1406 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
))
1407 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
))
1408 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_hide = %s\n" % (self
.batteryHide
.get_text() if self
.batteryHide
.get_text() else BATTERY_HIDE
))
1409 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat1_font = %s\n" % (self
.bat1FontButton
.get_font_name()))
1410 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat2_font = %s\n" % (self
.bat2FontButton
.get_font_name()))
1411 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_font_color = %s %s\n" % (self
.getHexFromWidget(self
.batteryFontColButton
),
1412 int(self
.batteryFontColButton
.get_alpha() / 65535.0 * 100)))
1413 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
,
1414 self
.batteryPadY
.get_text() if self
.batteryPadY
.get_text() else BATTERY_PADDING_Y
))
1415 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_background_id = %s\n" % (self
.batteryBg
.get_active()))
1417 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# End of config")
1419 def getColorButton(self
, widget
):
1420 """Returns the color button associated with widget."""
1421 if widget
.get_name() == "fontCol":
1422 return self
.fontColButton
1423 elif widget
.get_name() == "fontActiveCol":
1424 return self
.fontActiveColButton
1425 elif widget
.get_name() == "fontUrgentCol":
1426 return self
.fontUrgentColButton
1427 elif widget
.get_name() == "fontIconifiedCol":
1428 return self
.fontIconifiedColButton
1429 elif widget
.get_name() == "clockFontCol":
1430 return self
.clockFontColButton
1431 elif widget
.get_name() == "batteryFontCol":
1432 return self
.batteryFontColButton
1433 elif widget
.get_name() == "tooltipFontCol":
1434 return self
.tooltipFontColButton
1435 elif widget
.get_name() == "bgColEntry":
1436 bgID
= self
.bgNotebook
.get_current_page()
1438 for child
in self
.bgs
[bgID
].get_children():
1439 if child
.get_name() == "bgCol":
1442 elif widget
.get_name() == "borderColEntry":
1443 bgID
= self
.bgNotebook
.get_current_page()
1445 for child
in self
.bgs
[bgID
].get_children():
1446 if child
.get_name() == "borderCol":
1450 # No button found which matches label
1453 def getColorLabel(self
, widget
):
1454 """Gets the color label associated with a color button."""
1455 if widget
.get_name() == "fontCol":
1457 elif widget
.get_name() == "fontActiveCol":
1458 return self
.fontActiveCol
1459 elif widget
.get_name() == "fontUrgentCol":
1460 return self
.fontUrgentCol
1461 elif widget
.get_name() == "fontIconifiedCol":
1462 return self
.fontIconifiedCol
1463 elif widget
.get_name() == "clockFontCol":
1464 return self
.clockFontCol
1465 elif widget
.get_name() == "batteryFontCol":
1466 return self
.batteryFontCol
1467 elif widget
.get_name() == "tooltipFontCol":
1468 return self
.tooltipFontCol
1469 elif widget
.get_name() == "bgCol":
1470 bgID
= self
.bgNotebook
.get_current_page()
1472 for child
in self
.bgs
[bgID
].get_children():
1473 if child
.get_name() == "bgColEntry":
1476 elif widget
.get_name() == "borderCol":
1477 bgID
= self
.bgNotebook
.get_current_page()
1479 for child
in self
.bgs
[bgID
].get_children():
1480 if child
.get_name() == "borderColEntry":
1484 # No label found which matches color button
1487 def getHexFromWidget(self
, widget
):
1488 """Returns the #RRGGBB value of a widget."""
1489 r
= widget
.get_color().red
1490 g
= widget
.get_color().green
1491 b
= widget
.get_color().blue
1493 return rgbToHex(r
, g
, b
)
1495 def help(self
, action
=None):
1496 """Opens the Help wiki page in the default web browser."""
1498 webbrowser
.open("http://code.google.com/p/tintwizard/wiki/Help")
1500 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/wiki/Help")
1503 """Enters the main loop."""
1506 def new(self
, action
=None):
1507 """Prepares a new config."""
1512 self
.filename
= None
1516 self
.generateConfig()
1517 self
.updateStatusBar("New Config File [*]")
1519 def openDef(self
, widget
=None):
1520 """Opens the default tint2 config."""
1521 self
.openFile(default
=True)
1523 def openFile(self
, widget
=None, default
=False):
1524 """Reads from a config file. If default=True, open the tint2 default config."""
1528 chooser
= gtk
.FileChooserDialog("Open Config File", self
, gtk
.FILE_CHOOSER_ACTION_OPEN
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
1529 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1531 if self
.curDir
!= None:
1532 chooser
.set_current_folder(self
.curDir
)
1534 chooserFilter
= gtk
.FileFilter()
1535 chooserFilter
.set_name("All files")
1536 chooserFilter
.add_pattern("*")
1537 chooser
.add_filter(chooserFilter
)
1540 response
= chooser
.run()
1542 if response
== gtk
.RESPONSE_OK
:
1543 self
.filename
= chooser
.get_filename()
1544 self
.curDir
= os
.path
.dirname(self
.filename
)
1551 self
.filename
= os
.path
.expandvars("$HOME/.config/tint2/tint2rc")
1552 self
.curDir
= os
.path
.expandvars("$HOME/.config/tint2")
1554 self
.readTint2Config()
1555 self
.generateConfig()
1556 self
.updateStatusBar()
1558 def parseBgs(self
, string
):
1559 """Parses the background definitions from a string."""
1560 s
= string
.split("\n")
1564 bgKeys
= ["border_width", "background_color", "border_color"]
1568 data
= [token
.strip() for token
in line
.split("=")]
1570 if data
[0] == "rounded": # It may be considered bad practice to
1571 bgDefs
+= [{"rounded": data[1]}
] # find each style definition with an
1572 elif data
[0] in bgKeys
: # arbitrary value, but tint2 does the same.
1573 bgDefs
[cur
][data
[0]] = data
[1] # This means that any existing configs must
1574 else: # start with 'rounded'.
1575 newString
+= "%s\n" % line
1577 self
.addBgDefs(bgDefs
)
1581 def parseConfig(self
, string
):
1582 """Parses the contents of a config file."""
1583 for line
in string
.split("\n"):
1584 s
= line
.split("=") # Create a list with KEY and VALUE
1586 e
= s
[0].strip() # Strip whitespace from KEY
1588 if e
== "time1_format": # Set the VALUE of KEY
1589 self
.parseProp(self
.getComponent(e
), s
[1], True, "time1")
1590 elif e
== "time2_format":
1591 self
.parseProp(self
.getComponent(e
), s
[1], True, "time2")
1592 elif e
== "clock_tooltip":
1593 self
.parseProp(self
.getComponent(e
), s
[1], True, "clock_tooltip")
1594 elif e
== "time1_timezone":
1595 self
.parseProp(self
.getComponent(e
), s
[1], True, "time1_timezone")
1596 elif e
== "time2_timezone":
1597 self
.parseProp(self
.getComponent(e
), s
[1], True, "time2_timezone")
1598 elif e
== "clock_tooltip_timezone":
1599 self
.parseProp(self
.getComponent(e
), s
[1], True, "tooltip_timezone")
1600 elif e
== "systray_padding":
1601 self
.parseProp(self
.getComponent(e
), s
[1], True, "tray")
1602 elif e
== "taskbar_active_background_id":
1603 self
.parseProp(self
.getComponent(e
), s
[1], True, "activeBg")
1605 component
= self
.getComponent(e
)
1606 if component
!= None:
1607 self
.parseProp(self
.getComponent(e
), s
[1])
1609 def parseProp(self
, prop
, string
, special
=False, propType
=""):
1610 """Parses a variable definition from the conf file and updates the correct UI widget."""
1611 string
= string
.strip() # Remove whitespace from the VALUE
1612 eType
= type(prop
) # Get widget type
1614 if eType
== gtk
.Entry
:
1615 prop
.set_text(string
)
1617 elif eType
== gtk
.ComboBox
:
1618 # This allows us to select the correct combo-box value.
1619 if string
in ["bottom", "top", "left", "right", "center", "single_desktop", "multi_desktop", "single_monitor",
1620 "none", "close", "shade", "iconify", "toggle", "toggle_iconify", "maximize_restore",
1621 "desktop_left", "desktop_right", "horizontal", "vertical", "ascending", "descending",
1622 "left2right", "right2left", "next_task", "prev_task", "minimum", "follow_size", "normal"]:
1623 if string
in ["bottom", "left", "single_desktop", "none", "horizontal", "ascending"]:
1625 elif string
in ["top", "right", "multi_desktop", "close", "vertical", "descending", "minimum"]:
1627 elif string
in ["center", "single_monitor", "toggle", "left2right", "follow_size", "normal"]:
1629 elif string
in ["right2left"]:
1632 i
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore",
1633 "desktop_left", "desktop_right", "next_task", "prev_task"].index(string
)
1637 prop
.set_active(int(string
))
1638 elif eType
== gtk
.CheckButton
:
1639 prop
.set_active(bool(int(string
)))
1640 elif eType
== gtk
.FontButton
:
1641 prop
.set_font_name(string
)
1642 elif eType
== gtk
.ColorButton
:
1643 prop
.set_alpha(int(int(string
) * 65535 / 100.0))
1644 elif eType
== tuple: # If a property has more than 1 value, for example the x and y co-ords
1645 s
= string
.split(" ") # of the padding properties, then just we use recursion to set the
1646 for i
in range(len(prop
)): # value of each associated widget.
1648 self
.parseProp(prop
[i
], "0")
1650 self
.parseProp(prop
[i
], s
[i
])
1652 def quit(self
, widget
, event
=None):
1653 """Asks if user would like to save file before quitting, then quits the program."""
1655 if self
.oneConfigFile
:
1656 response
= gtk
.RESPONSE_YES
1658 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
))
1659 dialog
.get_content_area().add(gtk
.Label("Save config before quitting?"))
1660 dialog
.get_content_area().set_size_request(300, 100)
1662 response
= dialog
.run()
1665 if response
== gtk
.RESPONSE_CANCEL
:
1666 return True # Return True to stop it quitting when we hit "Cancel"
1667 elif response
== gtk
.RESPONSE_NO
:
1669 elif response
== gtk
.RESPONSE_YES
:
1676 """Reads the tintwizard configuration file - NOT tint2 config files."""
1677 self
.defaults
= {"font": None, "bgColor": None, "fgColor": None, "borderColor": None, "bgCount": None}
1679 if self
.oneConfigFile
:
1680 # don't need tintwizard.conf
1683 pathName
= os
.path
.expandvars("${HOME}") + "/.config/tint2/"
1685 if not os
.path
.exists(pathName
+ "tintwizard.conf"):
1689 f
= open(pathName
+ "tintwizard.conf", "r")
1695 if self
.defaults
.has_key(l
[0].strip()):
1696 self
.defaults
[l
[0].strip()] = l
[1].strip()
1698 def readTint2Config(self
):
1699 """Reads in from a config file."""
1700 f
= open(self
.filename
, "r")
1705 if (line
[0] != "#") and (len(line
) > 2):
1710 # Remove all background styles so we can create new ones as we read them
1711 for i
in range(len(self
.bgs
)):
1712 self
.delBgClick(None, False)
1714 # As we parse background definitions, we build a new string
1715 # without the background related stuff. This means we don't
1716 # have to read through background defs AGAIN when parsing
1718 noBgDefs
= self
.parseBgs(string
)
1720 self
.parseConfig(noBgDefs
)
1722 def reportBug(self
, action
=None):
1723 """Opens the bug report page in the default web browser."""
1725 webbrowser
.open("http://code.google.com/p/tintwizard/issues/entry")
1727 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/issues/entry")
1730 def resetConfig(self
):
1731 """Resets all the widgets to their default values."""
1733 for i
in range(len(self
.bgs
)):
1734 self
.delBgClick(prompt
=False, init
=True)
1736 for i
in range(self
.defaults
["bgCount"]):
1737 self
.addBgClick(init
=True)
1739 self
.bgNotebook
.set_current_page(0)
1742 self
.panelPosY
.set_active(0)
1743 self
.panelPosX
.set_active(0)
1744 self
.panelOrientation
.set_active(0)
1745 self
.panelItems
.set_text(PANEL_ITEMS
)
1746 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
1747 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
1748 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
1749 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
1750 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
1751 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
1752 self
.panelSpacing
.set_text(TASKBAR_SPACING
)
1753 self
.panelBg
.set_active(0)
1754 self
.panelMenu
.set_active(0)
1755 self
.panelDock
.set_active(0)
1756 self
.panelLayer
.set_active(0)
1757 self
.panelMonitor
.set_text(PANEL_MONITOR
)
1758 self
.panelAutohide
.set_active(0)
1759 self
.panelAutohideShow
.set_text(PANEL_AUTOHIDE_SHOW
)
1760 self
.panelAutohideHide
.set_text(PANEL_AUTOHIDE_HIDE
)
1761 self
.panelAutohideHeight
.set_text(PANEL_AUTOHIDE_HEIGHT
)
1762 self
.panelAutohideStrut
.set_active(0)
1764 self
.taskbarMode
.set_active(0)
1765 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
1766 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
1767 self
.taskbarSpacing
.set_text(TASK_SPACING
)
1768 self
.taskbarBg
.set_active(0)
1769 self
.taskbarActiveBg
.set_active(0)
1771 self
.taskBlinks
.set_text(TASK_BLINKS
)
1772 self
.taskCentreCheckButton
.set_active(True)
1773 self
.taskTextCheckButton
.set_active(True)
1774 self
.taskIconCheckButton
.set_active(True)
1775 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
1776 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
1777 self
.taskPadX
.set_text(TASK_PADDING_X
)
1778 self
.taskPadY
.set_text(TASK_PADDING_Y
)
1779 self
.taskBg
.set_active(0)
1780 self
.taskActiveBg
.set_active(0)
1781 self
.taskUrgentBg
.set_active(0)
1782 self
.taskIconifiedBg
.set_active(0)
1784 self
.iconHue
.set_text(ICON_ALPHA
)
1785 self
.iconSat
.set_text(ICON_SAT
)
1786 self
.iconBri
.set_text(ICON_BRI
)
1787 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
1788 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
1789 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
1790 self
.urgentIconHue
.set_text(URGENT_ICON_ALPHA
)
1791 self
.urgentIconSat
.set_text(URGENT_ICON_SAT
)
1792 self
.urgentIconBri
.set_text(URGENT_ICON_BRI
)
1793 self
.iconifiedIconHue
.set_text(ICONIFIED_ICON_ALPHA
)
1794 self
.iconifiedIconSat
.set_text(ICONIFIED_ICON_SAT
)
1795 self
.iconifiedIconBri
.set_text(ICONIFIED_ICON_BRI
)
1797 self
.fontButton
.set_font_name(self
.defaults
["font"])
1798 self
.fontColButton
.set_alpha(65535)
1799 self
.fontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1800 self
.fontCol
.set_text(self
.defaults
["fgColor"])
1801 self
.fontActiveColButton
.set_alpha(65535)
1802 self
.fontActiveColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1803 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
1804 self
.fontUrgentColButton
.set_alpha(65535)
1805 self
.fontUrgentColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1806 self
.fontUrgentCol
.set_text(self
.defaults
["fgColor"])
1807 self
.fontIconifiedColButton
.set_alpha(65535)
1808 self
.fontIconifiedColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1809 self
.fontIconifiedCol
.set_text(self
.defaults
["fgColor"])
1810 self
.fontShadowCheckButton
.set_active(False)
1812 self
.trayPadX
.set_text(TRAY_PADDING_X
)
1813 self
.trayPadY
.set_text(TRAY_PADDING_X
)
1814 self
.traySpacing
.set_text(TRAY_SPACING
)
1815 self
.trayOrder
.set_active(0)
1816 self
.trayBg
.set_active(0)
1817 self
.trayMaxIconSize
.set_text(TRAY_MAX_ICON_SIZE
)
1818 self
.trayIconHue
.set_text(TRAY_ICON_ALPHA
)
1819 self
.trayIconSat
.set_text(TRAY_ICON_SAT
)
1820 self
.trayIconBri
.set_text(TRAY_ICON_BRI
)
1822 self
.clock1Format
.set_text(CLOCK_FMT_1
)
1823 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
1824 self
.clock2Format
.set_text(CLOCK_FMT_2
)
1825 self
.clockTooltipFormat
.set_text(CLOCK_TOOLTIP
)
1826 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
1827 self
.clockFontColButton
.set_alpha(65535)
1828 self
.clockFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1829 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
1830 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
1831 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
1832 self
.clockBg
.set_active(0)
1833 self
.clockLClick
.set_text(CLOCK_LCLICK
)
1834 self
.clockRClick
.set_text(CLOCK_RCLICK
)
1835 self
.clockTime1Timezone
.set_text(CLOCK_TIME1_TIMEZONE
)
1836 self
.clockTime2Timezone
.set_text(CLOCK_TIME2_TIMEZONE
)
1837 self
.clockTooltipTimezone
.set_text(CLOCK_TOOLTIP_TIMEZONE
)
1839 self
.tooltipShow
.set_active(False)
1840 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
1841 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
1842 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
1843 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
1844 self
.tooltipBg
.set_active(0)
1845 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1846 self
.tooltipFontColButton
.set_alpha(65535)
1847 self
.tooltipFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1848 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1850 self
.mouseMiddle
.set_active(0)
1851 self
.mouseRight
.set_active(0)
1852 self
.mouseUp
.set_active(0)
1853 self
.mouseDown
.set_active(0)
1855 self
.batteryLow
.set_text(BATTERY_LOW
)
1856 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1857 self
.batteryHide
.set_text(BATTERY_HIDE
)
1858 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1859 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1860 self
.batteryFontColButton
.set_alpha(65535)
1861 self
.batteryFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1862 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1863 self
.batteryPadX
.set_text(BATTERY_PADDING_Y
)
1864 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1865 self
.batteryBg
.set_active(0)
1867 def save(self
, widget
=None, event
=None):
1868 """Saves the generated config file."""
1870 # This function returns the boolean status of whether or not the
1871 # file saved, so that the apply() function knows if it should
1872 # kill the tint2 process and apply the new config.
1874 # If no file has been selected, force the user to "Save As..."
1875 if self
.filename
== None:
1876 return self
.saveAs()
1878 self
.generateConfig()
1883 def saveAs(self
, widget
=None, event
=None):
1884 """Prompts the user to select a file and then saves the generated config file."""
1885 self
.generateConfig()
1887 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
))
1888 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1890 if self
.curDir
!= None:
1891 chooser
.set_current_folder(self
.curDir
)
1893 chooserFilter
= gtk
.FileFilter()
1894 chooserFilter
.set_name("All files")
1895 chooserFilter
.add_pattern("*")
1896 chooser
.add_filter(chooserFilter
)
1899 response
= chooser
.run()
1901 if response
== gtk
.RESPONSE_OK
:
1902 self
.filename
= chooser
.get_filename()
1904 if os
.path
.exists(self
.filename
):
1905 overwrite
= confirmDialog(self
, "This file already exists. Overwrite this file?")
1907 if overwrite
== gtk
.RESPONSE_YES
:
1912 self
.filename
= None
1920 self
.filename
= None
1924 def saveAsDef(self
, widget
=None, event
=None):
1925 """Saves the config as the default tint2 config."""
1926 if confirmDialog(self
, "Overwrite current tint2 default config?") == gtk
.RESPONSE_YES
:
1927 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1928 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
1930 # If, for whatever reason, tint2 has no default config - create one.
1931 if not os
.path
.isfile(self
.filename
):
1932 f
= open(self
.filename
, "w")
1933 f
.write("# tint2rc")
1936 self
.generateConfig()
1941 def savePrompt(self
):
1942 """Prompt the user to save before creating a new file."""
1943 if confirmDialog(self
, "Save current config?") == gtk
.RESPONSE_YES
:
1946 def switchPage(self
, notebook
, page
, page_num
):
1947 """Handles notebook page switch events."""
1949 # If user selects the 'View Config' tab, update the textarea within this tab.
1950 if notebook
.get_tab_label_text(notebook
.get_nth_page(page_num
)) == "View Config":
1951 self
.generateConfig()
1953 def updateComboBoxes(self
, i
, action
="add"):
1954 """Updates the contents of a combo box when a background style has been added/removed."""
1955 cbs
= [self
.batteryBg
, self
.clockBg
, self
.taskbarBg
, self
.taskbarActiveBg
, self
.trayBg
, self
.taskActiveBg
, self
.taskBg
, self
.panelBg
, self
.tooltipBg
, self
.taskUrgentBg
, self
.taskIconifiedBg
]
1959 cb
.append_text(str(i
+1))
1962 if cb
.get_active() == i
: # If background is selected, set to a different value
1967 def updateStatusBar(self
, message
="", change
=False):
1968 """Updates the message on the statusbar. A message can be provided,
1969 and if change is set to True (i.e. something has been modified) then
1970 an appropriate symbol [*] is shown beside filename."""
1971 contextID
= self
.statusBar
.get_context_id("")
1973 self
.statusBar
.pop(contextID
)
1976 message
= "%s %s" % (self
.filename
or "New Config File", "[*]" if change
else "")
1978 self
.statusBar
.push(contextID
, message
)
1980 def writeConf(self
):
1981 """Writes the tintwizard configuration file."""
1982 confStr
= "#Start\n[defaults]\n"
1984 for key
in self
.defaults
:
1985 confStr
+= "%s = %s\n" % (key
, str(self
.defaults
[key
]))
1989 pathName
= os
.path
.expandvars("${HOME}") + "/.config/tint2/"
1991 f
= open(pathName
+"tintwizard.conf", "w")
1997 def writeFile(self
):
1998 """Writes the contents of the config text buffer to file."""
2000 f
= open(self
.filename
, "w")
2002 f
.write(self
.configBuf
.get_text(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter()))
2008 self
.curDir
= os
.path
.dirname(self
.filename
)
2010 self
.updateStatusBar()
2012 errorDialog(self
, "Could not save file")
2014 # General use functions
2015 def createLabel(parent
, text
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xPadding
=0):
2016 """Creates a label and adds it to a parent widget."""
2018 temp
= gtk
.Label(text
)
2019 temp
.set_alignment(0, 0.5)
2020 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xpadding
=xPadding
)
2023 def createComboBox(parent
, choices
=["null"], active
=0, gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2024 """Creates a combo box with text choices and adds it to a parent widget."""
2025 temp
= gtk
.combo_box_new_text()
2027 for choice
in choices
:
2028 temp
.append_text(choice
)
2030 temp
.set_active(active
)
2033 temp
.connect("changed", handler
)
2035 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2039 def createEntry(parent
, maxSize
, width
, text
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None, name
=""):
2040 """Creates a text entry widget and adds it to a parent widget."""
2041 temp
= gtk
.Entry(maxSize
)
2042 temp
.set_width_chars(width
)
2047 temp
.connect("changed", handler
)
2049 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2053 def createCheckButton(parent
, text
="", active
=False, gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2054 """Creates a checkbox widget and adds it to a parent widget."""
2055 temp
= gtk
.CheckButton(text
if text
!= "" else None)
2056 temp
.set_active(active
)
2057 temp
.connect("toggled", handler
)
2059 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2063 def createButton(parent
, text
="", stock
=None, name
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2064 """Creates a button widget and adds it to a parent widget."""
2066 temp
= gtk
.Button(text
, stock
)
2068 temp
= gtk
.Button(text
)
2071 temp
.connect("clicked", handler
)
2073 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2077 def createFontButton(parent
, font
, gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2078 """Creates a font button widget and adds it to a parent widget."""
2079 temp
= gtk
.FontButton()
2080 temp
.set_font_name(font
)
2081 temp
.connect("font-set", handler
)
2083 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2087 def createColorButton(parent
, color
="#000000", useAlpha
=True, name
="", gridX
=0, gridY
=0, sizeX
=1, sizeY
=1, xExpand
=True, yExpand
=True, handler
=None):
2088 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(color
))
2089 temp
.set_use_alpha(useAlpha
)
2091 temp
.connect("color-set", handler
)
2093 parent
.attach(temp
, gridX
, gridX
+sizeX
, gridY
, gridY
+sizeY
, xoptions
=gtk
.EXPAND
if xExpand
else 0, yoptions
=gtk
.EXPAND
if yExpand
else 0)
2097 def confirmDialog(parent
, message
):
2098 """Creates a confirmation dialog and returns the response."""
2099 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
, message
)
2101 response
= dialog
.run()
2105 def errorDialog(parent
=None, message
="An error has occured!"):
2106 """Creates an error dialog."""
2107 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
2113 """Convert integer n in range [0, 15] to hex."""
2115 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"][n
]
2119 def rgbToHex(r
, g
, b
):
2120 """Constructs a 6 digit hex representation of color (r, g, b)."""
2121 r2
= trunc(r
/ 65535.0 * 255)
2122 g2
= trunc(g
/ 65535.0 * 255)
2123 b2
= trunc(b
/ 65535.0 * 255)
2125 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))
2128 """Truncate a floating point number, rounding up or down appropriately."""
2129 c
= math
.fabs(math
.ceil(n
) - n
)
2130 f
= math
.fabs(math
.floor(n
) - n
)
2133 return int(math
.ceil(n
))
2135 return int(math
.floor(n
))
2137 # Direct execution of application
2138 if __name__
== "__main__":
2139 if len(sys
.argv
) > 1 and sys
.argv
[1] == "-version":
2143 tw
= TintWizardGUI()