3 #**************************************************************************
6 # Copyright (C) 2009 Euan Freeman <euan04@gmail.com>
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License version 3
10 # as published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #*************************************************************************/
20 # Last modified: 27th September 2009
34 AUTHORS
= ["Euan Freeman <euan04@gmail.com>"]
36 COMMENTS
= "tintwizard generates config files for the lightweight panel replacement tint2"
37 WEBSITE
= "http://code.google.com/p/tintwizard/"
39 # Default values for text entry fields
49 TASKBAR_PADDING_X
= "0"
50 TASKBAR_PADDING_Y
= "0"
53 TASK_MAXIMUM_SIZE_X
= "200"
54 TASK_MAXIMUM_SIZE_Y
= "32"
64 ACTIVE_ICON_ALPHA
= "100"
68 CLOCK_FMT_2
= "%a %d %b"
73 TOOLTIP_PADDING_X
= "0"
74 TOOLTIP_PADDING_Y
= "0"
75 TOOLTIP_SHOW_TIMEOUT
= "0"
76 TOOLTIP_HIDE_TIMEOUT
= "0"
78 BATTERY_ACTION
= 'notify-send "battery low"'
79 BATTERY_PADDING_X
= "0"
80 BATTERY_PADDING_Y
= "0"
82 class TintWizardPrefGUI(gtk
.Window
):
83 """The dialog window which lets the user change the default preferences."""
84 def __init__(self
, tw
):
85 """Create and shows the window."""
88 # Create top-level window
89 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
91 self
.set_title("Preferences")
92 self
.connect("delete_event", self
.quit
)
94 self
.layout
= gtk
.Table(2, 2, False)
96 self
.table
= gtk
.Table(5, 2, False)
97 self
.table
.set_row_spacings(5)
98 self
.table
.set_col_spacings(5)
100 temp
= gtk
.Label("Default Font")
101 temp
.set_alignment(0, 0.5)
102 self
.table
.attach(temp
, 0, 1, 0, 1)
103 self
.font
= gtk
.FontButton(self
.tw
.defaults
["font"])
104 self
.font
.set_alignment(0, 0.5)
105 self
.table
.attach(self
.font
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
107 temp
= gtk
.Label("Default Background Color")
108 temp
.set_alignment(0, 0.5)
109 self
.table
.attach(temp
, 0, 1, 1, 2)
110 self
.bgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["bgColor"]))
111 self
.bgColor
.set_alignment(0, 0.5)
112 self
.table
.attach(self
.bgColor
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
114 temp
= gtk
.Label("Default Foreground Color")
115 temp
.set_alignment(0, 0.5)
116 self
.table
.attach(temp
, 0, 1, 2, 3)
117 self
.fgColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["fgColor"]))
118 self
.fgColor
.set_alignment(0, 0.5)
119 self
.table
.attach(self
.fgColor
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
121 temp
= gtk
.Label("Default Border Color")
122 temp
.set_alignment(0, 0.5)
123 self
.table
.attach(temp
, 0, 1, 3, 4)
124 self
.borderColor
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.tw
.defaults
["borderColor"]))
125 self
.borderColor
.set_alignment(0, 0.5)
126 self
.table
.attach(self
.borderColor
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
128 temp
= gtk
.Label("Number of Background Styles")
129 temp
.set_alignment(0, 0.5)
130 self
.table
.attach(temp
, 0, 1, 4, 5)
131 self
.bgCount
= gtk
.Entry(6)
132 self
.bgCount
.set_width_chars(8)
133 self
.bgCount
.set_text(str(self
.tw
.defaults
["bgCount"]))
134 self
.table
.attach(self
.bgCount
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
136 temp
= gtk
.Label("Default directory")
137 temp
.set_alignment(0, 0.5)
138 self
.table
.attach(temp
, 0, 1, 5, 6)
139 self
.dir = gtk
.Button(self
.tw
.defaults
["dir"])
140 self
.dir.connect("clicked", self
.chooseFolder
)
141 self
.table
.attach(self
.dir, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
143 self
.layout
.attach(self
.table
, 0, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, xpadding
=20, ypadding
=5)
145 temp
= gtk
.Button("Save", gtk
.STOCK_SAVE
)
146 temp
.set_name("save")
147 temp
.connect("clicked", self
.save
)
148 self
.layout
.attach(temp
, 0, 1, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, ypadding
=20)
149 temp
= gtk
.Button("Cancel", gtk
.STOCK_CANCEL
)
150 temp
.set_name("cancel")
151 temp
.connect("clicked", self
.quit
)
152 self
.layout
.attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
, ypadding
=20)
154 self
.add(self
.layout
)
158 def chooseFolder(self
, widget
=None, direction
=None):
159 """Called every time the folder button is clicked. Shows a file chooser."""
160 chooser
= gtk
.FileChooserDialog("Choose Default Folder", self
, gtk
.FILE_CHOOSER_ACTION_SELECT_FOLDER
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
161 chooser
.set_default_response(gtk
.RESPONSE_OK
)
163 if self
.tw
.curDir
!= None:
164 chooser
.set_current_folder(self
.tw
.curDir
)
168 response
= chooser
.run()
170 if response
== gtk
.RESPONSE_OK
:
171 self
.dir.set_label(chooser
.get_filename())
178 def quit(self
, widget
=None, event
=None):
179 """Destroys the window."""
182 def save(self
, action
=None):
183 """Called when the Save button is clicked."""
184 if confirmDialog(self
, "Overwrite configuration file?") == gtk
.RESPONSE_YES
:
185 self
.tw
.defaults
["font"] = self
.font
.get_font_name()
186 self
.tw
.defaults
["bgColor"] = rgbToHex(self
.bgColor
.get_color().red
, self
.bgColor
.get_color().green
, self
.bgColor
.get_color().blue
)
187 self
.tw
.defaults
["fgColor"] = rgbToHex(self
.fgColor
.get_color().red
, self
.fgColor
.get_color().green
, self
.fgColor
.get_color().blue
)
188 self
.tw
.defaults
["borderColor"] = rgbToHex(self
.borderColor
.get_color().red
, self
.borderColor
.get_color().green
, self
.borderColor
.get_color().blue
)
191 self
.tw
.defaults
["bgCount"] = int(self
.bgCount
.get_text())
193 errorDialog(self
, "Invalid value for background count")
196 self
.tw
.defaults
["dir"] = self
.dir.get_label()
197 self
.curDir
= self
.tw
.defaults
["dir"]
203 class TintWizardGUI(gtk
.Window
):
204 """The main window for the application."""
206 """Create and show the window."""
211 if len(sys
.argv
) > 1:
212 self
.filename
= sys
.argv
[1]
213 self
.oneConfigFile
= True
215 self
.oneConfigFile
= False
217 # Read conf file and set default values
220 if self
.defaults
["bgColor"] in [None, "None"]:
221 self
.defaults
["bgColor"] = "#000000"
223 if self
.defaults
["fgColor"] in [None, "None"]:
224 self
.defaults
["fgColor"] = "#ffffff"
226 if self
.defaults
["borderColor"] in [None, "None"]:
227 self
.defaults
["borderColor"] = "#ffffff"
229 if self
.defaults
["dir"] in [None, "None"]:
230 if os
.path
.exists(os
.path
.expandvars("${HOME}") + "/.config/tint2"):
231 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
235 self
.curDir
= os
.path
.expandvars(self
.defaults
["dir"])
237 if not os
.path
.exists(os
.path
.expandvars(self
.curDir
)):
238 if os
.path
.exists(os
.path
.expandvars("${HOME}") + "/.config/tint2"):
239 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
244 self
.defaults
["bgCount"] = int(self
.defaults
["bgCount"])
246 self
.defaults
["bgCount"] = 2
248 # Get the full location of the tint2 binary
249 which
= os
.popen('which tint2')
251 self
.tint2Bin
= which
.readline().strip()
255 if len(self
.tint2Bin
) == 0:
256 errorDialog(self
, "tint2 could not be found. Are you sure it is installed?")
259 # Create top-level window
260 gtk
.Window
.__init
__(self
, gtk
.WINDOW_TOPLEVEL
)
262 self
.set_title("tintwizard")
264 self
.connect("delete_event", self
.quit
)
266 # self.table is our main layout manager
267 self
.table
= gtk
.Table(4, 1, False)
269 # Create menus and toolbar items
272 <menubar name="MenuBar">
274 <menuitem action="New" />
275 <menuitem action="Open" />
277 <menuitem action="Save" />
278 <menuitem action="Save As..." />
280 <menuitem action="Quit" />
282 <menu action="Tint2">
283 <menuitem action="OpenDefault" />
284 <menuitem action="SaveDefault" />
286 <menuitem action="Apply" />
288 <menu action="Tools">
289 <menuitem action="FontChange" />
291 <menuitem action="Defaults" />
293 <menu action="HelpMenu">
294 <menuitem action="Help" />
295 <menuitem action="Report Bug" />
297 <menuitem action="About" />
300 <toolbar name="ToolBar">
301 <toolitem action="New" />
302 <toolitem action="Open" />
303 <toolitem action="Save" />
305 <toolitem action="Apply" />
311 self
.uiManager
= gtk
.UIManager()
313 accelGroup
= self
.uiManager
.get_accel_group()
314 self
.add_accel_group(accelGroup
)
316 self
.ag
= gtk
.ActionGroup("File")
317 self
.ag
.add_actions([("File", None, "_File"),
318 ("New",gtk
.STOCK_NEW
, "_New", None, "Create a new config", self
.new
),
319 ("Open", gtk
.STOCK_OPEN
, "_Open", None, "Open an existing config", self
.openFile
),
320 ("Save", gtk
.STOCK_SAVE
, "_Save", None, "Save the current config", self
.save
),
321 ("Save As...", gtk
.STOCK_SAVE_AS
, "Save As", None, "Save the current config as...", self
.saveAs
),
322 ("SaveDefault", None, "Save As tint2 Default", None, "Save the current config as the tint2 default", self
.saveAsDef
),
323 ("OpenDefault", None, "Open tint2 Default", None, "Open the current tint2 default config", self
.openDef
),
324 ("Apply", gtk
.STOCK_APPLY
, "Apply Config", None, "Apply the current config to tint2", self
.apply),
325 ("Quit", gtk
.STOCK_QUIT
, "_Quit", None, "Quit the program", self
.quit
),
326 ("Tools", None, "_Tools"),
327 ("Tint2", None, "Tint_2"),
328 ("HelpMenu", None, "_Help"),
329 ("FontChange",gtk
.STOCK_SELECT_FONT
, "Change All Fonts", None, "Change all fonts at once.", self
.changeAllFonts
),
330 ("Defaults",gtk
.STOCK_PREFERENCES
, "Change Defaults", None, "Change tintwizard defaults.", self
.changeDefaults
),
331 ("Help",gtk
.STOCK_HELP
, "_Help", None, "Get help with tintwizard", self
.help),
332 ("Report Bug",None, "Report Bug", None, "Report a problem with tintwizard", self
.reportBug
),
333 ("About",gtk
.STOCK_ABOUT
, "_About Tint Wizard", None, "Find out more about Tint Wizard", self
.about
)])
337 self
.uiManager
.insert_action_group(self
.ag
)
338 self
.uiManager
.add_ui_from_string(ui
)
340 if not self
.oneConfigFile
:
341 # Attach menubar and toolbar to main window
342 self
.table
.attach(self
.uiManager
.get_widget("/MenuBar"), 0, 4, 0, 1)
343 self
.table
.attach(self
.uiManager
.get_widget("/ToolBar"), 0, 4, 1, 2)
346 self
.notebook
= gtk
.Notebook()
347 self
.notebook
.set_tab_pos(gtk
.POS_TOP
)
349 # Create notebook pages
351 self
.tableBgs
= gtk
.Table(rows
=1, columns
=1, homogeneous
=False)
352 self
.tableBgs
.set_row_spacings(5)
353 self
.tableBgs
.set_col_spacings(5)
355 self
.bgNotebook
= gtk
.Notebook()
356 self
.bgNotebook
.set_scrollable(True)
358 self
.tableBgs
.attach(self
.bgNotebook
, 0, 2, 0, 1)
362 # Add buttons for adding/deleting background styles
363 temp
= gtk
.Button("New Background", gtk
.STOCK_NEW
)
364 temp
.set_name("addBg")
365 temp
.connect("clicked", self
.addBgClick
)
366 self
.tableBgs
.attach(temp
, 0, 1, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
367 temp
= gtk
.Button("Delete Background", gtk
.STOCK_DELETE
)
368 temp
.set_name("delBg")
369 temp
.connect("clicked", self
.delBgClick
)
370 self
.tableBgs
.attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
373 self
.tablePanel
= gtk
.Table(rows
=9, columns
=3, homogeneous
=False)
374 self
.tablePanel
.set_row_spacings(5)
375 self
.tablePanel
.set_col_spacings(5)
377 temp
= gtk
.Label("Position")
378 temp
.set_alignment(0, 0.5)
379 self
.tablePanel
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
380 self
.panelPosY
= gtk
.combo_box_new_text()
381 self
.panelPosY
.append_text("bottom")
382 self
.panelPosY
.append_text("top")
383 self
.panelPosY
.append_text("center")
384 self
.panelPosY
.set_active(0)
385 self
.panelPosY
.connect("changed", self
.changeOccurred
)
386 self
.tablePanel
.attach(self
.panelPosY
, 2, 3, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
387 self
.panelPosX
= gtk
.combo_box_new_text()
388 self
.panelPosX
.append_text("left")
389 self
.panelPosX
.append_text("right")
390 self
.panelPosX
.append_text("center")
391 self
.panelPosX
.set_active(0)
392 self
.panelPosX
.connect("changed", self
.changeOccurred
)
393 self
.tablePanel
.attach(self
.panelPosX
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
395 temp
= gtk
.Label("Panel Orientation")
396 temp
.set_alignment(0, 0.5)
397 self
.tablePanel
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
398 self
.panelOrientation
= gtk
.combo_box_new_text()
399 self
.panelOrientation
.append_text("horizontal")
400 self
.panelOrientation
.append_text("vertical")
401 self
.panelOrientation
.set_active(0)
402 self
.panelOrientation
.connect("changed", self
.changeOccurred
)
403 self
.tablePanel
.attach(self
.panelOrientation
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
405 self
.panelSizeLabel
= gtk
.Label("Size (width, height)")
406 self
.panelSizeLabel
.set_alignment(0, 0.5)
407 self
.tablePanel
.attach(self
.panelSizeLabel
, 0, 1, 2, 3, xpadding
=10)
408 self
.panelSizeX
= gtk
.Entry(6)
409 self
.panelSizeX
.set_width_chars(8)
410 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
411 self
.panelSizeX
.connect("changed", self
.changeOccurred
)
412 self
.tablePanel
.attach(self
.panelSizeX
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
413 self
.panelSizeY
= gtk
.Entry(6)
414 self
.panelSizeY
.set_width_chars(8)
415 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
416 self
.panelSizeY
.connect("changed", self
.changeOccurred
)
417 self
.tablePanel
.attach(self
.panelSizeY
, 2, 3, 2, 3, xoptions
=gtk
.EXPAND
)
419 temp
= gtk
.Label("Margin (x, y)")
420 temp
.set_alignment(0, 0.5)
421 self
.tablePanel
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
422 self
.panelMarginX
= gtk
.Entry(6)
423 self
.panelMarginX
.set_width_chars(8)
424 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
425 self
.panelMarginX
.connect("changed", self
.changeOccurred
)
426 self
.tablePanel
.attach(self
.panelMarginX
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
427 self
.panelMarginY
= gtk
.Entry(6)
428 self
.panelMarginY
.set_width_chars(8)
429 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
430 self
.panelMarginY
.connect("changed", self
.changeOccurred
)
431 self
.tablePanel
.attach(self
.panelMarginY
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
)
433 temp
= gtk
.Label("Padding (x, y)")
434 temp
.set_alignment(0, 0.5)
435 self
.tablePanel
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
436 self
.panelPadX
= gtk
.Entry(6)
437 self
.panelPadX
.set_width_chars(8)
438 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
439 self
.panelPadX
.connect("changed", self
.changeOccurred
)
440 self
.tablePanel
.attach(self
.panelPadX
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
441 self
.panelPadY
= gtk
.Entry(6)
442 self
.panelPadY
.set_width_chars(8)
443 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
444 self
.panelPadY
.connect("changed", self
.changeOccurred
)
445 self
.tablePanel
.attach(self
.panelPadY
, 2, 3, 4, 5, xoptions
=gtk
.EXPAND
)
447 temp
= gtk
.Label("Panel Background ID")
448 temp
.set_alignment(0, 0.5)
449 self
.tablePanel
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
450 self
.panelBg
= gtk
.combo_box_new_text()
451 self
.panelBg
.append_text("0 (fully transparent)")
452 for i
in range(len(self
.bgs
)):
453 self
.panelBg
.append_text(str(i
+1))
454 self
.panelBg
.set_active(0)
455 self
.panelBg
.connect("changed", self
.changeOccurred
)
456 self
.tablePanel
.attach(self
.panelBg
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
458 temp
= gtk
.Label("Window Manager Menu")
459 temp
.set_alignment(0, 0.5)
460 self
.tablePanel
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
461 self
.panelMenu
= gtk
.CheckButton()
462 self
.panelMenu
.set_active(False)
463 self
.panelMenu
.connect("toggled", self
.changeOccurred
)
464 self
.tablePanel
.attach(self
.panelMenu
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
466 temp
= gtk
.Label("Place In Window Manager Dock")
467 temp
.set_alignment(0, 0.5)
468 self
.tablePanel
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
469 self
.panelDock
= gtk
.CheckButton()
470 self
.panelDock
.set_active(False)
471 self
.panelDock
.connect("toggled", self
.changeOccurred
)
472 self
.tablePanel
.attach(self
.panelDock
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
)
474 temp
= gtk
.Label("Panel Monitor (all, 1, 2...)")
475 temp
.set_alignment(0, 0.5)
476 self
.tablePanel
.attach(temp
, 0, 1, 8, 9, xpadding
=10)
477 self
.panelMonitor
= gtk
.Entry(6)
478 self
.panelMonitor
.set_width_chars(8)
479 self
.panelMonitor
.set_text(PANEL_MONITOR
)
480 self
.panelMonitor
.connect("changed", self
.changeOccurred
)
481 self
.tablePanel
.attach(self
.panelMonitor
, 1, 2, 8, 9, xoptions
=gtk
.EXPAND
)
484 self
.tableTaskbar
= gtk
.Table(rows
=5, columns
=3, homogeneous
=False)
485 self
.tableTaskbar
.set_row_spacings(5)
486 self
.tableTaskbar
.set_col_spacings(5)
488 temp
= gtk
.Label("Taskbar Mode")
489 temp
.set_alignment(0, 0.5)
490 self
.tableTaskbar
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
491 self
.taskbarMode
= gtk
.combo_box_new_text()
492 self
.taskbarMode
.append_text("single_desktop")
493 self
.taskbarMode
.append_text("multi_desktop")
494 self
.taskbarMode
.set_active(0)
495 self
.taskbarMode
.connect("changed", self
.changeOccurred
)
496 self
.tableTaskbar
.attach(self
.taskbarMode
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
498 temp
= gtk
.Label("Padding (x, y)")
499 temp
.set_alignment(0, 0.5)
500 self
.tableTaskbar
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
501 self
.taskbarPadX
= gtk
.Entry(6)
502 self
.taskbarPadX
.set_width_chars(8)
503 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
504 self
.taskbarPadX
.connect("changed", self
.changeOccurred
)
505 self
.tableTaskbar
.attach(self
.taskbarPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
506 self
.taskbarPadY
= gtk
.Entry(6)
507 self
.taskbarPadY
.set_width_chars(8)
508 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
509 self
.taskbarPadY
.connect("changed", self
.changeOccurred
)
510 self
.tableTaskbar
.attach(self
.taskbarPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
512 temp
= gtk
.Label("Horizontal Spacing")
513 temp
.set_alignment(0, 0.5)
514 self
.tableTaskbar
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
515 self
.panelSpacing
= gtk
.Entry(6)
516 self
.panelSpacing
.set_width_chars(8)
517 self
.panelSpacing
.set_text(TASKBAR_SPACING
)
518 self
.panelSpacing
.connect("changed", self
.changeOccurred
)
519 self
.tableTaskbar
.attach(self
.panelSpacing
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
521 temp
= gtk
.Label("Taskbar Background ID")
522 temp
.set_alignment(0, 0.5)
523 self
.tableTaskbar
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
524 self
.taskbarBg
= gtk
.combo_box_new_text()
525 self
.taskbarBg
.append_text("0 (fully transparent)")
526 for i
in range(len(self
.bgs
)):
527 self
.taskbarBg
.append_text(str(i
+1))
528 self
.taskbarBg
.set_active(0)
529 self
.taskbarBg
.connect("changed", self
.changeOccurred
)
530 self
.tableTaskbar
.attach(self
.taskbarBg
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
532 temp
= gtk
.Label("Active Taskbar Background ID")
533 temp
.set_alignment(0, 0.5)
534 self
.tableTaskbar
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
535 self
.taskbarActiveBg
= gtk
.combo_box_new_text()
536 self
.taskbarActiveBg
.append_text("0 (fully transparent)")
537 for i
in range(len(self
.bgs
)):
538 self
.taskbarActiveBg
.append_text(str(i
+1))
539 self
.taskbarActiveBg
.set_active(0)
540 self
.taskbarActiveBg
.connect("changed", self
.changeOccurred
)
541 self
.tableTaskbar
.attach(self
.taskbarActiveBg
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
542 self
.taskbarActiveBgEnable
= gtk
.CheckButton("Enable")
543 self
.taskbarActiveBgEnable
.set_active(False)
544 self
.taskbarActiveBgEnable
.connect("toggled", self
.changeOccurred
)
545 self
.tableTaskbar
.attach(self
.taskbarActiveBgEnable
, 2, 3, 5, 6, xoptions
=gtk
.EXPAND
)
548 self
.tableTask
= gtk
.Table(rows
=12, columns
=3, homogeneous
=False)
549 self
.tableTask
.set_row_spacings(5)
550 self
.tableTask
.set_col_spacings(5)
552 temp
= gtk
.Label("Number of 'Blinks' on Urgent Event")
553 temp
.set_alignment(0, 0.5)
554 self
.tableTask
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
555 self
.taskBlinks
= gtk
.Entry(6)
556 self
.taskBlinks
.set_width_chars(8)
557 self
.taskBlinks
.set_text(TASK_BLINKS
)
558 self
.taskBlinks
.connect("changed", self
.changeOccurred
)
559 self
.tableTask
.attach(self
.taskBlinks
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
561 temp
= gtk
.Label("Show Text")
562 temp
.set_alignment(0, 0.5)
563 self
.tableTask
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
564 self
.taskTextCheckButton
= gtk
.CheckButton()
565 self
.taskTextCheckButton
.set_active(True)
566 self
.taskTextCheckButton
.connect("toggled", self
.changeOccurred
)
567 self
.tableTask
.attach(self
.taskTextCheckButton
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
569 temp
= gtk
.Label("Centre Text")
570 temp
.set_alignment(0, 0.5)
571 self
.tableTask
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
572 self
.taskCentreCheckButton
= gtk
.CheckButton()
573 self
.taskCentreCheckButton
.set_active(True)
574 self
.taskCentreCheckButton
.connect("toggled", self
.changeOccurred
)
575 self
.tableTask
.attach(self
.taskCentreCheckButton
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
577 temp
= gtk
.Label("Maximum Size (x, y)")
578 temp
.set_alignment(0, 0.5)
579 self
.tableTask
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
580 self
.taskMaxSizeX
= gtk
.Entry(6)
581 self
.taskMaxSizeX
.set_width_chars(8)
582 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
583 self
.taskMaxSizeX
.connect("changed", self
.changeOccurred
)
584 self
.tableTask
.attach(self
.taskMaxSizeX
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
585 self
.taskMaxSizeY
= gtk
.Entry(6)
586 self
.taskMaxSizeY
.set_width_chars(8)
587 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
588 self
.taskMaxSizeY
.connect("changed", self
.changeOccurred
)
589 self
.tableTask
.attach(self
.taskMaxSizeY
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
)
591 temp
= gtk
.Label("Padding (x, y)")
592 temp
.set_alignment(0, 0.5)
593 self
.tableTask
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
594 self
.taskPadX
= gtk
.Entry(6)
595 self
.taskPadX
.set_width_chars(8)
596 self
.taskPadX
.set_text(TASK_PADDING_X
)
597 self
.taskPadX
.connect("changed", self
.changeOccurred
)
598 self
.tableTask
.attach(self
.taskPadX
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
599 self
.taskPadY
= gtk
.Entry(6)
600 self
.taskPadY
.set_width_chars(8)
601 self
.taskPadY
.set_text(TASK_PADDING_Y
)
602 self
.taskPadY
.connect("changed", self
.changeOccurred
)
603 self
.tableTask
.attach(self
.taskPadY
, 2, 3, 4, 5, xoptions
=gtk
.EXPAND
)
605 temp
= gtk
.Label("Horizontal Spacing")
606 temp
.set_alignment(0, 0.5)
607 self
.tableTask
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
608 self
.taskbarSpacing
= gtk
.Entry(6)
609 self
.taskbarSpacing
.set_width_chars(8)
610 self
.taskbarSpacing
.set_text(TASK_SPACING
)
611 self
.taskbarSpacing
.connect("changed", self
.changeOccurred
)
612 self
.tableTask
.attach(self
.taskbarSpacing
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
)
614 temp
= gtk
.Label("Task Background ID")
615 temp
.set_alignment(0, 0.5)
616 self
.tableTask
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
617 self
.taskBg
= gtk
.combo_box_new_text()
618 self
.taskBg
.append_text("0 (fully transparent)")
619 for i
in range(len(self
.bgs
)):
620 self
.taskBg
.append_text(str(i
+1))
621 self
.taskBg
.set_active(0)
622 self
.taskBg
.connect("changed", self
.changeOccurred
)
623 self
.tableTask
.attach(self
.taskBg
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
625 temp
= gtk
.Label("Task Active Background ID")
626 temp
.set_alignment(0, 0.5)
627 self
.tableTask
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
628 self
.taskActiveBg
= gtk
.combo_box_new_text()
629 self
.taskActiveBg
.append_text("0 (fully transparent)")
630 for i
in range(len(self
.bgs
)):
631 self
.taskActiveBg
.append_text(str(i
+1))
632 self
.taskActiveBg
.set_active(0)
633 self
.taskActiveBg
.connect("changed", self
.changeOccurred
)
634 self
.tableTask
.attach(self
.taskActiveBg
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
637 self
.tableIcon
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
638 self
.tableIcon
.set_row_spacings(5)
639 self
.tableIcon
.set_col_spacings(5)
641 temp
= gtk
.Label("Show Icons")
642 temp
.set_alignment(0, 0.5)
643 self
.tableIcon
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
644 self
.taskIconCheckButton
= gtk
.CheckButton()
645 self
.taskIconCheckButton
.set_active(True)
646 self
.taskIconCheckButton
.connect("toggled", self
.changeOccurred
)
647 self
.tableIcon
.attach(self
.taskIconCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
649 temp
= gtk
.Label("Note: Default values of 0 for each of these settings leaves icons unchanged!")
650 temp
.set_alignment(0, 0.5)
651 self
.tableIcon
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
653 temp
= gtk
.Label("Icon Alpha (0 to 100)")
654 temp
.set_alignment(0, 0.5)
655 self
.tableIcon
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
656 self
.iconHue
= gtk
.Entry(6)
657 self
.iconHue
.set_width_chars(8)
658 self
.iconHue
.set_text(ICON_ALPHA
)
659 self
.iconHue
.connect("changed", self
.changeOccurred
)
660 self
.tableIcon
.attach(self
.iconHue
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
662 temp
= gtk
.Label("Icon Saturation (-100 to 100)")
663 temp
.set_alignment(0, 0.5)
664 self
.tableIcon
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
665 self
.iconSat
= gtk
.Entry(6)
666 self
.iconSat
.set_width_chars(8)
667 self
.iconSat
.set_text(ICON_SAT
)
668 self
.iconSat
.connect("changed", self
.changeOccurred
)
669 self
.tableIcon
.attach(self
.iconSat
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
671 temp
= gtk
.Label("Icon Brightness (-100 to 100)")
672 temp
.set_alignment(0, 0.5)
673 self
.tableIcon
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
674 self
.iconBri
= gtk
.Entry(6)
675 self
.iconBri
.set_width_chars(8)
676 self
.iconBri
.set_text(ICON_BRI
)
677 self
.iconBri
.connect("changed", self
.changeOccurred
)
678 self
.tableIcon
.attach(self
.iconBri
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
680 temp
= gtk
.Label("Active Icon Alpha (0 to 100)")
681 temp
.set_alignment(0, 0.5)
682 self
.tableIcon
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
683 self
.activeIconHue
= gtk
.Entry(6)
684 self
.activeIconHue
.set_width_chars(8)
685 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
686 self
.activeIconHue
.connect("changed", self
.changeOccurred
)
687 self
.tableIcon
.attach(self
.activeIconHue
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
)
689 temp
= gtk
.Label("Active Icon Saturation (-100 to 100)")
690 temp
.set_alignment(0, 0.5)
691 self
.tableIcon
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
692 self
.activeIconSat
= gtk
.Entry(6)
693 self
.activeIconSat
.set_width_chars(8)
694 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
695 self
.activeIconSat
.connect("changed", self
.changeOccurred
)
696 self
.tableIcon
.attach(self
.activeIconSat
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
698 temp
= gtk
.Label("Active Icon Brightness (-100 to 100)")
699 temp
.set_alignment(0, 0.5)
700 self
.tableIcon
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
701 self
.activeIconBri
= gtk
.Entry(6)
702 self
.activeIconBri
.set_width_chars(8)
703 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
704 self
.activeIconBri
.connect("changed", self
.changeOccurred
)
705 self
.tableIcon
.attach(self
.activeIconBri
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
)
708 self
.tableFont
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
709 self
.tableFont
.set_row_spacings(5)
710 self
.tableFont
.set_col_spacings(5)
712 temp
= gtk
.Label("Font")
713 temp
.set_alignment(0, 0.5)
714 self
.tableFont
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
715 self
.fontButton
= gtk
.FontButton()
717 if self
.defaults
["font"] in [None, "None"]: # If there was no font specified in the config file
718 self
.defaults
["font"] = self
.fontButton
.get_font_name() # Use the gtk default
720 self
.fontButton
.set_font_name(self
.defaults
["font"])
721 self
.fontButton
.connect("font-set", self
.changeOccurred
)
722 self
.tableFont
.attach(self
.fontButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
724 temp
= gtk
.Label("Font Color")
725 temp
.set_alignment(0, 0.5)
726 self
.tableFont
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
727 self
.fontCol
= gtk
.Entry(7)
728 self
.fontCol
.set_width_chars(9)
729 self
.fontCol
.set_name("fontCol")
730 self
.fontCol
.connect("activate", self
.colorTyped
)
731 self
.tableFont
.attach(self
.fontCol
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
732 self
.fontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
733 self
.fontColButton
.set_use_alpha(True)
734 self
.fontColButton
.set_name("fontCol")
735 self
.fontColButton
.connect("color-set", self
.colorChange
)
736 self
.tableFont
.attach(self
.fontColButton
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
737 self
.fontCol
.set_text(self
.defaults
["fgColor"])
738 # Add this AFTER we set color to avoid "changed" event
739 self
.fontCol
.connect("changed", self
.changeOccurred
)
741 temp
= gtk
.Label("Active Font Color")
742 temp
.set_alignment(0, 0.5)
743 self
.tableFont
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
744 self
.fontActiveCol
= gtk
.Entry(7)
745 self
.fontActiveCol
.set_width_chars(9)
746 self
.fontActiveCol
.set_name("fontActiveCol")
747 self
.fontActiveCol
.connect("activate", self
.colorTyped
)
748 self
.tableFont
.attach(self
.fontActiveCol
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
749 self
.fontActiveColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
750 self
.fontActiveColButton
.set_use_alpha(True)
751 self
.fontActiveColButton
.set_name("fontActiveCol")
752 self
.fontActiveColButton
.connect("color-set", self
.colorChange
)
753 self
.tableFont
.attach(self
.fontActiveColButton
, 2, 3, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
754 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
755 # Add this AFTER we set color to avoid "changed" event
756 self
.fontActiveCol
.connect("changed", self
.changeOccurred
)
758 temp
= gtk
.Label("Font Shadow")
759 temp
.set_alignment(0, 0.5)
760 self
.tableFont
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
761 self
.fontShadowCheckButton
= gtk
.CheckButton()
762 self
.fontShadowCheckButton
.set_active(False)
763 self
.fontShadowCheckButton
.connect("toggled", self
.changeOccurred
)
764 self
.tableFont
.attach(self
.fontShadowCheckButton
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
767 self
.tableTray
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
768 self
.tableTray
.set_row_spacings(5)
769 self
.tableTray
.set_col_spacings(5)
771 temp
= gtk
.Label("Show Systray")
772 temp
.set_alignment(0, 0.5)
773 self
.tableTray
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
774 self
.trayShow
= gtk
.CheckButton()
775 self
.trayShow
.set_active(True)
776 self
.trayShow
.connect("toggled", self
.changeOccurred
)
777 self
.tableTray
.attach(self
.trayShow
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
779 temp
= gtk
.Label("Padding (x, y)")
780 temp
.set_alignment(0, 0.5)
781 self
.tableTray
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
782 self
.trayPadX
= gtk
.Entry(6)
783 self
.trayPadX
.set_width_chars(8)
784 self
.trayPadX
.set_text(TRAY_PADDING_X
)
785 self
.trayPadX
.connect("changed", self
.changeOccurred
)
786 self
.tableTray
.attach(self
.trayPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
787 self
.trayPadY
= gtk
.Entry(6)
788 self
.trayPadY
.set_width_chars(8)
789 self
.trayPadY
.set_text(TRAY_PADDING_Y
)
790 self
.trayPadY
.connect("changed", self
.changeOccurred
)
791 self
.tableTray
.attach(self
.trayPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
793 temp
= gtk
.Label("Horizontal Spacing")
794 temp
.set_alignment(0, 0.5)
795 self
.tableTray
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
796 self
.traySpacing
= gtk
.Entry(6)
797 self
.traySpacing
.set_width_chars(8)
798 self
.traySpacing
.set_text(TRAY_SPACING
)
799 self
.traySpacing
.connect("changed", self
.changeOccurred
)
800 self
.tableTray
.attach(self
.traySpacing
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
802 temp
= gtk
.Label("Icon Ordering")
803 temp
.set_alignment(0, 0.5)
804 self
.tableTray
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
805 self
.trayOrder
= gtk
.combo_box_new_text()
806 self
.trayOrder
.append_text("ascending")
807 self
.trayOrder
.append_text("descending")
808 self
.trayOrder
.append_text("left2right")
809 self
.trayOrder
.append_text("right2left")
810 self
.trayOrder
.set_active(0)
811 self
.trayOrder
.connect("changed", self
.changeOccurred
)
812 self
.tableTray
.attach(self
.trayOrder
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
814 temp
= gtk
.Label("Systray Background ID")
815 temp
.set_alignment(0, 0.5)
816 self
.tableTray
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
817 self
.trayBg
= gtk
.combo_box_new_text()
818 self
.trayBg
.append_text("0 (fully transparent)")
819 for i
in range(len(self
.bgs
)):
820 self
.trayBg
.append_text(str(i
+1))
821 self
.trayBg
.set_active(0)
822 self
.trayBg
.connect("changed", self
.changeOccurred
)
823 self
.tableTray
.attach(self
.trayBg
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
826 self
.tableClockDisplays
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
827 self
.tableClockDisplays
.set_row_spacings(5)
828 self
.tableClockDisplays
.set_col_spacings(5)
830 temp
= gtk
.Label("Show Clock")
831 temp
.set_alignment(0, 0.5)
832 self
.tableClockDisplays
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
833 self
.clockCheckButton
= gtk
.CheckButton()
834 self
.clockCheckButton
.set_active(True)
835 self
.clockCheckButton
.connect("toggled", self
.changeOccurred
)
836 self
.tableClockDisplays
.attach(self
.clockCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
838 temp
= gtk
.Label("Time 1 Format")
839 temp
.set_alignment(0, 0.5)
840 self
.tableClockDisplays
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
841 self
.clock1Format
= gtk
.Entry(50)
842 self
.clock1Format
.set_width_chars(20)
843 self
.clock1Format
.set_text(CLOCK_FMT_1
)
844 self
.clock1Format
.connect("changed", self
.changeOccurred
)
845 self
.tableClockDisplays
.attach(self
.clock1Format
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
846 self
.clock1CheckButton
= gtk
.CheckButton("Show")
847 self
.clock1CheckButton
.set_active(True)
848 self
.clock1CheckButton
.connect("toggled", self
.changeOccurred
)
849 self
.tableClockDisplays
.attach(self
.clock1CheckButton
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
851 temp
= gtk
.Label("Time 1 Font")
852 temp
.set_alignment(0, 0.5)
853 self
.tableClockDisplays
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
854 self
.clock1FontButton
= gtk
.FontButton()
855 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
856 self
.clock1FontButton
.connect("font-set", self
.changeOccurred
)
857 self
.tableClockDisplays
.attach(self
.clock1FontButton
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
859 temp
= gtk
.Label("Time 2 Format")
860 temp
.set_alignment(0, 0.5)
861 self
.tableClockDisplays
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
862 self
.clock2Format
= gtk
.Entry(50)
863 self
.clock2Format
.set_width_chars(20)
864 self
.clock2Format
.set_text(CLOCK_FMT_2
)
865 self
.clock2Format
.connect("changed", self
.changeOccurred
)
866 self
.tableClockDisplays
.attach(self
.clock2Format
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
867 self
.clock2CheckButton
= gtk
.CheckButton("Show")
868 self
.clock2CheckButton
.set_active(True)
869 self
.clock2CheckButton
.connect("toggled", self
.changeOccurred
)
870 self
.tableClockDisplays
.attach(self
.clock2CheckButton
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
)
872 temp
= gtk
.Label("Time 2 Font")
873 temp
.set_alignment(0, 0.5)
874 self
.tableClockDisplays
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
875 self
.clock2FontButton
= gtk
.FontButton()
876 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
877 self
.clock2FontButton
.connect("font-set", self
.changeOccurred
)
878 self
.tableClockDisplays
.attach(self
.clock2FontButton
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
880 self
.clockArea
= gtk
.ScrolledWindow()
881 self
.clockBuf
= gtk
.TextBuffer()
882 self
.clockTextView
= gtk
.TextView(self
.clockBuf
)
883 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")
884 self
.clockTextView
.set_editable(False)
885 self
.clockArea
.add_with_viewport(self
.clockTextView
)
886 self
.tableClockDisplays
.attach(self
.clockArea
, 0, 3, 5, 6, xpadding
=10)
888 self
.tableClockSettings
= gtk
.Table(rows
=3, columns
=3, homogeneous
=False)
889 self
.tableClockSettings
.set_row_spacings(5)
890 self
.tableClockSettings
.set_col_spacings(5)
892 temp
= gtk
.Label("Clock Font Color")
893 temp
.set_alignment(0, 0.5)
894 self
.tableClockSettings
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
895 self
.clockFontCol
= gtk
.Entry(7)
896 self
.clockFontCol
.set_width_chars(9)
897 self
.clockFontCol
.set_name("clockFontCol")
898 self
.clockFontCol
.connect("activate", self
.colorTyped
)
899 self
.tableClockSettings
.attach(self
.clockFontCol
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
900 self
.clockFontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
901 self
.clockFontColButton
.set_use_alpha(True)
902 self
.clockFontColButton
.set_name("clockFontCol")
903 self
.clockFontColButton
.connect("color-set", self
.colorChange
)
904 self
.tableClockSettings
.attach(self
.clockFontColButton
, 2, 3, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
905 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
906 # Add this AFTER we set color to avoid "changed" event
907 self
.clockFontCol
.connect("changed", self
.changeOccurred
)
909 temp
= gtk
.Label("Padding (x, y)")
910 temp
.set_alignment(0, 0.5)
911 self
.tableClockSettings
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
912 self
.clockPadX
= gtk
.Entry(6)
913 self
.clockPadX
.set_width_chars(8)
914 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
915 self
.clockPadX
.connect("changed", self
.changeOccurred
)
916 self
.tableClockSettings
.attach(self
.clockPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
917 self
.clockPadY
= gtk
.Entry(6)
918 self
.clockPadY
.set_width_chars(8)
919 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
920 self
.clockPadY
.connect("changed", self
.changeOccurred
)
921 self
.tableClockSettings
.attach(self
.clockPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
923 temp
= gtk
.Label("Clock Background ID")
924 temp
.set_alignment(0, 0.5)
925 self
.tableClockSettings
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
926 self
.clockBg
= gtk
.combo_box_new_text()
927 self
.clockBg
.append_text("0 (fully transparent)")
928 for i
in range(len(self
.bgs
)):
929 self
.clockBg
.append_text(str(i
+1))
930 self
.clockBg
.set_active(0)
931 self
.clockBg
.connect("changed", self
.changeOccurred
)
932 self
.tableClockSettings
.attach(self
.clockBg
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
934 temp
= gtk
.Label("Left Click Command")
935 temp
.set_alignment(0, 0.5)
936 self
.tableClockSettings
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
937 self
.clockLClick
= gtk
.Entry(50)
938 self
.clockLClick
.set_width_chars(20)
939 self
.clockLClick
.set_text(CLOCK_LCLICK
)
940 self
.clockLClick
.connect("changed", self
.changeOccurred
)
941 self
.tableClockSettings
.attach(self
.clockLClick
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
943 temp
= gtk
.Label("Right Click Command")
944 temp
.set_alignment(0, 0.5)
945 self
.tableClockSettings
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
946 self
.clockRClick
= gtk
.Entry(50)
947 self
.clockRClick
.set_width_chars(20)
948 self
.clockRClick
.set_text(CLOCK_RCLICK
)
949 self
.clockRClick
.connect("changed", self
.changeOccurred
)
950 self
.tableClockSettings
.attach(self
.clockRClick
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
)
953 self
.tableTooltip
= gtk
.Table(rows
=7, columns
=3, homogeneous
=False)
954 self
.tableTooltip
.set_row_spacings(5)
955 self
.tableTooltip
.set_col_spacings(5)
957 temp
= gtk
.Label("Show Tooltips")
958 temp
.set_alignment(0, 0.5)
959 self
.tableTooltip
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
960 self
.tooltipShow
= gtk
.CheckButton()
961 self
.tooltipShow
.set_active(False)
962 self
.tooltipShow
.connect("toggled", self
.changeOccurred
)
963 self
.tableTooltip
.attach(self
.tooltipShow
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
965 temp
= gtk
.Label("Padding (x, y)")
966 temp
.set_alignment(0, 0.5)
967 self
.tableTooltip
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
968 self
.tooltipPadX
= gtk
.Entry(6)
969 self
.tooltipPadX
.set_width_chars(8)
970 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
971 self
.tooltipPadX
.connect("changed", self
.changeOccurred
)
972 self
.tableTooltip
.attach(self
.tooltipPadX
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
973 self
.tooltipPadY
= gtk
.Entry(6)
974 self
.tooltipPadY
.set_width_chars(8)
975 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
976 self
.tooltipPadY
.connect("changed", self
.changeOccurred
)
977 self
.tableTooltip
.attach(self
.tooltipPadY
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
)
979 temp
= gtk
.Label("Tooltip Show Timeout (seconds)")
980 temp
.set_alignment(0, 0.5)
981 self
.tableTooltip
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
982 self
.tooltipShowTime
= gtk
.Entry(6)
983 self
.tooltipShowTime
.set_width_chars(8)
984 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
985 self
.tooltipShowTime
.connect("changed", self
.changeOccurred
)
986 self
.tableTooltip
.attach(self
.tooltipShowTime
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
988 temp
= gtk
.Label("Tooltip Hide Timeout (seconds)")
989 temp
.set_alignment(0, 0.5)
990 self
.tableTooltip
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
991 self
.tooltipHideTime
= gtk
.Entry(6)
992 self
.tooltipHideTime
.set_width_chars(8)
993 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
994 self
.tooltipHideTime
.connect("changed", self
.changeOccurred
)
995 self
.tableTooltip
.attach(self
.tooltipHideTime
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
997 temp
= gtk
.Label("Tooltip Background ID")
998 temp
.set_alignment(0, 0.5)
999 self
.tableTooltip
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
1000 self
.tooltipBg
= gtk
.combo_box_new_text()
1001 self
.tooltipBg
.append_text("0 (fully transparent)")
1002 for i
in range(len(self
.bgs
)):
1003 self
.tooltipBg
.append_text(str(i
+1))
1004 self
.tooltipBg
.set_active(0)
1005 self
.tooltipBg
.connect("changed", self
.changeOccurred
)
1006 self
.tableTooltip
.attach(self
.tooltipBg
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1008 temp
= gtk
.Label("Tooltip Font")
1009 temp
.set_alignment(0, 0.5)
1010 self
.tableTooltip
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
1011 self
.tooltipFont
= gtk
.FontButton()
1012 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1013 self
.tooltipFont
.connect("font-set", self
.changeOccurred
)
1014 self
.tableTooltip
.attach(self
.tooltipFont
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1016 temp
= gtk
.Label("Tooltip Font Color")
1017 temp
.set_alignment(0, 0.5)
1018 self
.tableTooltip
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
1019 self
.tooltipFontCol
= gtk
.Entry(7)
1020 self
.tooltipFontCol
.set_width_chars(9)
1021 self
.tooltipFontCol
.set_name("tooltipFontCol")
1022 self
.tooltipFontCol
.connect("activate", self
.colorTyped
)
1023 self
.tableTooltip
.attach(self
.tooltipFontCol
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
1024 self
.tooltipFontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1025 self
.tooltipFontColButton
.set_use_alpha(True)
1026 self
.tooltipFontColButton
.set_name("tooltipFontCol")
1027 self
.tooltipFontColButton
.connect("color-set", self
.colorChange
)
1028 self
.tableTooltip
.attach(self
.tooltipFontColButton
, 2, 3, 6, 7, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1029 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1030 # Add this AFTER we set color to avoid "changed" event
1031 self
.clockFontCol
.connect("changed", self
.changeOccurred
)
1034 self
.tableMouse
= gtk
.Table(rows
=4, columns
=3, homogeneous
=False)
1035 self
.tableMouse
.set_row_spacings(5)
1036 self
.tableMouse
.set_col_spacings(5)
1038 temp
= gtk
.Label("Middle Mouse Click Action")
1039 temp
.set_alignment(0, 0.5)
1040 self
.tableMouse
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
1041 self
.mouseMiddle
= gtk
.combo_box_new_text()
1042 self
.mouseMiddle
.append_text("none")
1043 self
.mouseMiddle
.append_text("close")
1044 self
.mouseMiddle
.append_text("toggle")
1045 self
.mouseMiddle
.append_text("iconify")
1046 self
.mouseMiddle
.append_text("shade")
1047 self
.mouseMiddle
.append_text("toggle_iconify")
1048 self
.mouseMiddle
.append_text("maximize_restore")
1049 self
.mouseMiddle
.append_text("desktop_left")
1050 self
.mouseMiddle
.append_text("desktop_right")
1051 self
.mouseMiddle
.set_active(0)
1052 self
.mouseMiddle
.connect("changed", self
.changeOccurred
)
1053 self
.tableMouse
.attach(self
.mouseMiddle
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1055 temp
= gtk
.Label("Right Mouse Click Action")
1056 temp
.set_alignment(0, 0.5)
1057 self
.tableMouse
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
1058 self
.mouseRight
= gtk
.combo_box_new_text()
1059 self
.mouseRight
.append_text("none")
1060 self
.mouseRight
.append_text("close")
1061 self
.mouseRight
.append_text("toggle")
1062 self
.mouseRight
.append_text("iconify")
1063 self
.mouseRight
.append_text("shade")
1064 self
.mouseRight
.append_text("toggle_iconify")
1065 self
.mouseRight
.append_text("maximize_restore")
1066 self
.mouseRight
.append_text("desktop_left")
1067 self
.mouseRight
.append_text("desktop_right")
1068 self
.mouseRight
.set_active(0)
1069 self
.mouseRight
.connect("changed", self
.changeOccurred
)
1070 self
.tableMouse
.attach(self
.mouseRight
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1072 temp
= gtk
.Label("Mouse Wheel Scroll Up Action")
1073 temp
.set_alignment(0, 0.5)
1074 self
.tableMouse
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
1075 self
.mouseUp
= gtk
.combo_box_new_text()
1076 self
.mouseUp
.append_text("none")
1077 self
.mouseUp
.append_text("close")
1078 self
.mouseUp
.append_text("toggle")
1079 self
.mouseUp
.append_text("iconify")
1080 self
.mouseUp
.append_text("shade")
1081 self
.mouseUp
.append_text("toggle_iconify")
1082 self
.mouseUp
.append_text("maximize_restore")
1083 self
.mouseUp
.append_text("desktop_left")
1084 self
.mouseUp
.append_text("desktop_right")
1085 self
.mouseUp
.set_active(0)
1086 self
.mouseUp
.connect("changed", self
.changeOccurred
)
1087 self
.tableMouse
.attach(self
.mouseUp
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1089 temp
= gtk
.Label("Mouse Wheel Scroll Down Action")
1090 temp
.set_alignment(0, 0.5)
1091 self
.tableMouse
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
1092 self
.mouseDown
= gtk
.combo_box_new_text()
1093 self
.mouseDown
.append_text("none")
1094 self
.mouseDown
.append_text("close")
1095 self
.mouseDown
.append_text("toggle")
1096 self
.mouseDown
.append_text("iconify")
1097 self
.mouseDown
.append_text("shade")
1098 self
.mouseDown
.append_text("toggle_iconify")
1099 self
.mouseDown
.append_text("maximize_restore")
1100 self
.mouseDown
.append_text("desktop_left")
1101 self
.mouseDown
.append_text("desktop_right")
1102 self
.mouseDown
.set_active(0)
1103 self
.mouseDown
.connect("changed", self
.changeOccurred
)
1104 self
.tableMouse
.attach(self
.mouseDown
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1107 self
.tableBattery
= gtk
.Table(rows
=8, columns
=3, homogeneous
=False)
1108 self
.tableBattery
.set_row_spacings(5)
1109 self
.tableBattery
.set_col_spacings(5)
1111 temp
= gtk
.Label("Show Battery Applet")
1112 temp
.set_alignment(0, 0.5)
1113 self
.tableBattery
.attach(temp
, 0, 1, 0, 1, xpadding
=10)
1114 self
.batteryCheckButton
= gtk
.CheckButton()
1115 self
.batteryCheckButton
.set_active(False)
1116 self
.batteryCheckButton
.connect("toggled", self
.changeOccurred
)
1117 self
.tableBattery
.attach(self
.batteryCheckButton
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
1119 temp
= gtk
.Label("Battery Low Status (%)")
1120 temp
.set_alignment(0, 0.5)
1121 self
.tableBattery
.attach(temp
, 0, 1, 1, 2, xpadding
=10)
1122 self
.batteryLow
= gtk
.Entry(6)
1123 self
.batteryLow
.set_width_chars(8)
1124 self
.batteryLow
.set_text(BATTERY_LOW
)
1125 self
.batteryLow
.connect("changed", self
.changeOccurred
)
1126 self
.tableBattery
.attach(self
.batteryLow
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1128 temp
= gtk
.Label("Battery Low Action")
1129 temp
.set_alignment(0, 0.5)
1130 self
.tableBattery
.attach(temp
, 0, 1, 2, 3, xpadding
=10)
1131 self
.batteryLowAction
= gtk
.Entry(150)
1132 self
.batteryLowAction
.set_width_chars(32)
1133 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1134 self
.batteryLowAction
.connect("changed", self
.changeOccurred
)
1135 self
.tableBattery
.attach(self
.batteryLowAction
, 1, 3, 2, 3, xoptions
=gtk
.EXPAND
)
1137 temp
= gtk
.Label("Battery 1 Font")
1138 temp
.set_alignment(0, 0.5)
1139 self
.tableBattery
.attach(temp
, 0, 1, 3, 4, xpadding
=10)
1140 self
.bat1FontButton
= gtk
.FontButton()
1141 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1142 self
.bat1FontButton
.connect("font-set", self
.changeOccurred
)
1143 self
.tableBattery
.attach(self
.bat1FontButton
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1145 temp
= gtk
.Label("Battery 2 Font")
1146 temp
.set_alignment(0, 0.5)
1147 self
.tableBattery
.attach(temp
, 0, 1, 4, 5, xpadding
=10)
1148 self
.bat2FontButton
= gtk
.FontButton()
1149 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1150 self
.bat2FontButton
.connect("font-set", self
.changeOccurred
)
1151 self
.tableBattery
.attach(self
.bat2FontButton
, 1, 2, 4, 5, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1153 temp
= gtk
.Label("Battery Font Color")
1154 temp
.set_alignment(0, 0.5)
1155 self
.tableBattery
.attach(temp
, 0, 1, 5, 6, xpadding
=10)
1156 self
.batteryFontCol
= gtk
.Entry(7)
1157 self
.batteryFontCol
.set_width_chars(9)
1158 self
.batteryFontCol
.set_name("batteryFontCol")
1159 self
.batteryFontCol
.connect("activate", self
.colorTyped
)
1160 self
.tableBattery
.attach(self
.batteryFontCol
, 1, 2, 5, 6, xoptions
=gtk
.EXPAND
)
1161 self
.batteryFontColButton
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1162 self
.batteryFontColButton
.set_use_alpha(True)
1163 self
.batteryFontColButton
.set_name("batteryFontCol")
1164 self
.batteryFontColButton
.connect("color-set", self
.colorChange
)
1165 self
.tableBattery
.attach(self
.batteryFontColButton
, 2, 3, 5, 6, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1166 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1167 # Add this AFTER we set color to avoid "changed" event
1168 self
.batteryFontCol
.connect("changed", self
.changeOccurred
)
1170 temp
= gtk
.Label("Padding (x, y)")
1171 temp
.set_alignment(0, 0.5)
1172 self
.tableBattery
.attach(temp
, 0, 1, 6, 7, xpadding
=10)
1173 self
.batteryPadX
= gtk
.Entry(6)
1174 self
.batteryPadX
.set_width_chars(8)
1175 self
.batteryPadX
.set_text(BATTERY_PADDING_X
)
1176 self
.batteryPadX
.connect("changed", self
.changeOccurred
)
1177 self
.tableBattery
.attach(self
.batteryPadX
, 1, 2, 6, 7, xoptions
=gtk
.EXPAND
)
1178 self
.batteryPadY
= gtk
.Entry(6)
1179 self
.batteryPadY
.set_width_chars(8)
1180 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1181 self
.batteryPadY
.connect("changed", self
.changeOccurred
)
1182 self
.tableBattery
.attach(self
.batteryPadY
, 2, 3, 6, 7, xoptions
=gtk
.EXPAND
)
1184 temp
= gtk
.Label("Battery Background ID")
1185 temp
.set_alignment(0, 0.5)
1186 self
.tableBattery
.attach(temp
, 0, 1, 7, 8, xpadding
=10)
1187 self
.batteryBg
= gtk
.combo_box_new_text()
1188 self
.batteryBg
.append_text("0 (fully transparent)")
1189 for i
in range(len(self
.bgs
)):
1190 self
.batteryBg
.append_text(str(i
+1))
1191 self
.batteryBg
.set_active(0)
1192 self
.batteryBg
.connect("changed", self
.changeOccurred
)
1193 self
.tableBattery
.attach(self
.batteryBg
, 1, 2, 7, 8, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1196 self
.configArea
= gtk
.ScrolledWindow()
1197 self
.configBuf
= gtk
.TextBuffer()
1198 self
.configTextView
= gtk
.TextView(self
.configBuf
)
1199 self
.configArea
.add_with_viewport(self
.configTextView
)
1201 # Add backgrounds to notebooks
1202 for i
in range(self
.defaults
["bgCount"]):
1203 self
.addBgClick(None, init
=True)
1205 self
.bgNotebook
.set_current_page(0)
1207 # Create sub-notebooks
1208 self
.taskNotebook
= gtk
.Notebook()
1209 self
.taskNotebook
.set_tab_pos(gtk
.POS_TOP
)
1210 self
.taskNotebook
.set_current_page(0)
1212 self
.taskNotebook
.append_page(self
.tableTask
, gtk
.Label("Task Settings"))
1213 self
.taskNotebook
.append_page(self
.tableIcon
, gtk
.Label("Task Icons"))
1214 self
.taskNotebook
.append_page(self
.tableFont
, gtk
.Label("Task Fonts"))
1216 self
.clockNotebook
= gtk
.Notebook()
1217 self
.clockNotebook
.set_tab_pos(gtk
.POS_TOP
)
1218 self
.clockNotebook
.set_current_page(0)
1220 self
.clockNotebook
.append_page(self
.tableClockDisplays
, gtk
.Label("Clock Display"))
1221 self
.clockNotebook
.append_page(self
.tableClockSettings
, gtk
.Label("Clock Settings"))
1223 # Add pages to notebook
1224 self
.notebook
.append_page(self
.tableBgs
, gtk
.Label("Backgrounds"))
1225 self
.notebook
.append_page(self
.tablePanel
, gtk
.Label("Panel"))
1226 self
.notebook
.append_page(self
.tableTaskbar
, gtk
.Label("Taskbar"))
1227 self
.notebook
.append_page(self
.taskNotebook
, gtk
.Label("Tasks"))
1228 self
.notebook
.append_page(self
.tableTray
, gtk
.Label("Systray"))
1229 self
.notebook
.append_page(self
.clockNotebook
, gtk
.Label("Clock"))
1230 self
.notebook
.append_page(self
.tableMouse
, gtk
.Label("Mouse"))
1231 self
.notebook
.append_page(self
.tableTooltip
, gtk
.Label("Tooltips"))
1232 self
.notebook
.append_page(self
.tableBattery
, gtk
.Label("Battery"))
1233 self
.notebook
.append_page(self
.configArea
, gtk
.Label("View Config"))
1235 self
.notebook
.connect("switch-page", self
.switchPage
)
1237 # Add notebook to window and show
1238 self
.table
.attach(self
.notebook
, 0, 4, 2, 3, xpadding
=5, ypadding
=5)
1240 if self
.oneConfigFile
:
1241 # Add button Apply and Close
1242 self
.box1
= gtk
.HBox(False, 20)
1243 self
.table
.attach(self
.box1
, 0, 4, 3, 4, xpadding
=5, ypadding
=5)
1244 temp
= gtk
.Button("Apply", gtk
.STOCK_APPLY
)
1245 temp
.set_name("applyBg")
1246 temp
.connect("clicked", self
.apply)
1247 self
.box1
.pack_start(temp
, True, True, 0)
1248 temp
= gtk
.Button("Close", gtk
.STOCK_CLOSE
)
1249 temp
.set_name("closeBg")
1250 temp
.connect("clicked", self
.quit
)
1251 self
.box1
.pack_start(temp
, True, True, 0)
1253 # Create and add the status bar to the bottom of the main window
1254 self
.statusBar
= gtk
.Statusbar()
1255 self
.statusBar
.set_has_resize_grip(True)
1256 self
.updateStatusBar("New Config File [*]")
1257 self
.table
.attach(self
.statusBar
, 0, 4, 4, 5)
1259 self
.add(self
.table
)
1263 # Create our property dictionary. This holds the widgets which correspond to each property
1265 "panel_monitor": self
.panelMonitor
,
1266 "panel_position": (self
.panelPosY
, self
.panelPosX
, self
.panelOrientation
),
1267 "panel_size": (self
.panelSizeX
, self
.panelSizeY
),
1268 "panel_margin": (self
.panelMarginX
, self
.panelMarginY
),
1269 "panel_padding": (self
.panelPadX
, self
.panelPadY
, self
.panelSpacing
),
1270 "wm_menu": self
.panelMenu
,
1271 "panel_dock": self
.panelDock
,
1272 "panel_background_id": self
.panelBg
,
1273 "taskbar_mode": self
.taskbarMode
,
1274 "taskbar_padding": (self
.taskbarPadX
, self
.taskbarPadY
, self
.taskbarSpacing
),
1275 "taskbar_background_id": self
.taskbarBg
,
1276 "taskbar_active_background_id": self
.taskbarActiveBg
,
1277 "task_icon": self
.taskIconCheckButton
,
1278 "task_text": self
.taskTextCheckButton
,
1279 "task_centered": self
.taskCentreCheckButton
,
1280 "task_maximum_size": (self
.taskMaxSizeX
, self
.taskMaxSizeY
),
1281 "task_padding": (self
.taskPadX
, self
.taskPadY
),
1282 "task_background_id": self
.taskBg
,
1283 "task_active_background_id": self
.taskActiveBg
,
1284 "task_font": self
.fontButton
,
1285 "task_font_color": (self
.fontCol
, self
.fontColButton
),
1286 "task_active_font_color": (self
.fontActiveCol
, self
.fontActiveColButton
),
1287 "task_icon_asb": (self
.iconHue
, self
.iconSat
, self
.iconBri
),
1288 "task_active_icon_asb": (self
.activeIconHue
, self
.activeIconSat
, self
.activeIconBri
),
1289 "font_shadow": self
.fontShadowCheckButton
,
1290 "systray": self
.trayShow
,
1291 "systray_padding": (self
.trayPadX
, self
.trayPadY
, self
.traySpacing
),
1292 "systray_background_id": self
.trayBg
,
1293 "systray_sort": self
.trayOrder
,
1294 "time1_format": self
.clock1Format
,
1295 "time2_format": self
.clock2Format
,
1296 "time1_font": self
.clock1FontButton
,
1297 "time2_font": self
.clock2FontButton
,
1298 "clock_font_color": (self
.clockFontCol
, self
.clockFontColButton
),
1299 "clock_padding": (self
.clockPadX
, self
.clockPadY
),
1300 "clock_background_id": self
.clockBg
,
1301 "clock_lclick_command": self
.clockLClick
,
1302 "clock_rclick_command": self
.clockRClick
,
1303 "mouse_middle": self
.mouseMiddle
,
1304 "mouse_right": self
.mouseRight
,
1305 "mouse_scroll_up": self
.mouseUp
,
1306 "mouse_scroll_down": self
.mouseDown
,
1307 "tooltip": self
.tooltipShow
,
1308 "tooltip_padding": (self
.tooltipPadX
, self
.tooltipPadY
),
1309 "tooltip_show_timeout": self
.tooltipShowTime
,
1310 "tooltip_hide_timeout": self
.tooltipHideTime
,
1311 "tooltip_background_id": self
.tooltipBg
,
1312 "tooltip_font": self
.tooltipFont
,
1313 "tooltip_font_color": (self
.tooltipFontCol
, self
.tooltipFontColButton
),
1314 "battery": self
.batteryCheckButton
,
1315 "battery_low_status": self
.batteryLow
,
1316 "battery_low_cmd": self
.batteryLowAction
,
1317 "bat1_font": self
.bat1FontButton
,
1318 "bat2_font": self
.bat2FontButton
,
1319 "battery_font_color": (self
.batteryFontCol
, self
.batteryFontColButton
),
1320 "battery_padding": (self
.batteryPadX
, self
.batteryPadY
),
1321 "battery_background_id": self
.batteryBg
1324 if self
.oneConfigFile
:
1325 self
.readTint2Config()
1327 self
.generateConfig()
1329 def about(self
, action
=None):
1330 """Displays the About dialog."""
1331 about
= gtk
.AboutDialog()
1332 about
.set_program_name(NAME
)
1333 about
.set_version(VERSION
)
1334 about
.set_authors(AUTHORS
)
1335 about
.set_comments(COMMENTS
)
1336 about
.set_website(WEBSITE
)
1337 gtk
.about_dialog_set_url_hook(self
.aboutLinkCallback
)
1341 def aboutLinkCallback(dialog
, link
, data
=None):
1342 """Callback for when a URL is clicked in an About dialog."""
1344 webbrowser
.open(link
)
1346 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit %s" % link
)
1349 """Adds a new background to the list of backgrounds."""
1350 self
.bgs
+= [gtk
.Table(4, 3, False)]
1352 temp
= gtk
.Label("Corner Rounding (px)")
1353 temp
.set_alignment(0, 0.5)
1354 self
.bgs
[-1].attach(temp
, 0, 1, 0, 1, xpadding
=10)
1356 temp
.set_width_chars(9)
1357 temp
.set_name("rounded")
1358 temp
.set_text(BG_ROUNDING
)
1359 temp
.connect("changed", self
.changeOccurred
)
1360 self
.bgs
[-1].attach(temp
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
1362 temp
= gtk
.Label("Background Color")
1363 temp
.set_alignment(0, 0.5)
1364 self
.bgs
[-1].attach(temp
, 0, 1, 1, 2, xpadding
=10)
1366 temp
.set_width_chars(9)
1367 temp
.set_name("bgColEntry")
1368 temp
.set_text(self
.defaults
["bgColor"])
1369 temp
.connect("changed", self
.changeOccurred
)
1370 temp
.connect("activate", self
.colorTyped
)
1371 self
.bgs
[-1].attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1372 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["bgColor"]))
1373 temp
.set_use_alpha(True)
1374 temp
.set_name("bgCol")
1375 temp
.connect("color-set", self
.colorChange
)
1376 self
.bgs
[-1].attach(temp
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1378 temp
= gtk
.Label("Border Width (px)")
1379 temp
.set_alignment(0, 0.5)
1380 self
.bgs
[-1].attach(temp
, 0, 1, 2, 3, xpadding
=10)
1382 temp
.set_width_chars(9)
1383 temp
.set_name("border")
1384 temp
.set_text(BG_BORDER
)
1385 temp
.connect("changed", self
.changeOccurred
)
1386 self
.bgs
[-1].attach(temp
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
1388 temp
= gtk
.Label("Border Color")
1389 temp
.set_alignment(0, 0.5)
1390 self
.bgs
[-1].attach(temp
, 0, 1, 3, 4, xpadding
=10)
1392 temp
.set_width_chars(9)
1393 temp
.set_name("borderColEntry")
1394 temp
.connect("activate", self
.colorTyped
)
1395 temp
.set_text(self
.defaults
["borderColor"])
1396 temp
.connect("changed", self
.changeOccurred
)
1397 self
.bgs
[-1].attach(temp
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
1398 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["borderColor"]))
1399 temp
.set_use_alpha(True)
1400 temp
.set_name("borderCol")
1401 temp
.connect("color-set", self
.colorChange
)
1402 self
.bgs
[-1].attach(temp
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1404 # Note: Only set init to True when initialising background styles.
1405 # This prevents unwanted calls to changeOccurred()
1406 def addBgClick(self
, widget
=None, init
=False):
1407 """Creates a new background and adds a new tab to the notebook."""
1408 n
= self
.bgNotebook
.get_n_pages()
1410 if n
> (self
.defaults
["bgCount"] + 2):
1411 if confirmDialog(self
, "You already have %d background styles. Are you sure you would like another?" % n
) == gtk
.RESPONSE_NO
:
1416 newId
= len(self
.bgs
)
1418 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1420 self
.bgNotebook
.show_all()
1422 self
.updateComboBoxes(n
, "add")
1424 self
.bgNotebook
.set_current_page(n
)
1427 self
.changeOccurred()
1429 def apply(self
, widget
, event
=None, confirmChange
=True):
1430 """Applies the current config to tint2."""
1431 # Check if tint2 is running
1432 procs
= os
.popen('pidof "tint2"') # Check list of active processes for tint2
1433 pids
= [] # List of process ids for tint2
1435 for proc
in procs
.readlines():
1436 pids
+= [int(proc
.strip().split(" ")[0])]
1440 if self
.oneConfigFile
:
1441 # Save and copy as default
1443 tmpSrc
= self
.filename
1444 tmpDest
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1446 shutil
.copyfile(tmpSrc
, tmpDest
)
1447 except shutil
.Error
:
1449 # Ask tint2 to reload config
1451 os
.kill(pid
, signal
.SIGUSR1
)
1453 if confirmDialog(self
, "This will terminate all currently running instances of tint2 before applying config. Continue?") == gtk
.RESPONSE_YES
:
1457 #shutil.copyfile(self.filename, self.filename+".backup") # Create backup
1459 # If it is - kill it
1461 os
.kill(pid
, signal
.SIGTERM
)
1464 os
.spawnv(os
.P_NOWAIT
, self
.tint2Bin
, [self
.tint2Bin
, "-c" + self
.filename
])
1466 if confirmChange
and self
.filename
!= (os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc") and confirmDialog(self
, "Use this as default tint2 config?") == gtk
.RESPONSE_YES
:
1468 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1470 shutil
.copyfile(tmp
, self
.filename
)
1471 except shutil
.Error
:
1474 #if confirmChange and confirmDialog(self, "Keep this config?") == gtk.RESPONSE_NO:
1475 # shutil.copyfile(self.filename+".backup", self.filename) # Create backup
1476 # self.apply(widget, event, False)
1478 def changeAllFonts(self
, widget
):
1479 """Changes all fonts at once."""
1480 dialog
= gtk
.FontSelectionDialog("Select Font")
1482 dialog
.set_font_name(self
.defaults
["font"])
1484 if dialog
.run() == gtk
.RESPONSE_OK
:
1485 newFont
= dialog
.get_font_name()
1487 self
.clock1FontButton
.set_font_name(newFont
)
1488 self
.clock2FontButton
.set_font_name(newFont
)
1489 self
.bat1FontButton
.set_font_name(newFont
)
1490 self
.bat2FontButton
.set_font_name(newFont
)
1491 self
.fontButton
.set_font_name(newFont
)
1495 self
.generateConfig()
1496 self
.changeOccurred()
1498 def changeDefaults(self
, widget
=None):
1499 """Shows the style preferences widget."""
1500 TintWizardPrefGUI(self
)
1502 def changeOccurred(self
, widget
=None):
1503 """Called when the user changes something, i.e. entry value"""
1506 self
.updateStatusBar(change
=True)
1508 if widget
== self
.panelOrientation
:
1509 if self
.panelOrientation
.get_active_text() == "horizontal":
1510 self
.panelSizeLabel
.set_text("Size (width, height)")
1512 self
.panelSizeLabel
.set_text("Size (height, width)")
1514 def colorChange(self
, widget
):
1515 """Update the text entry when a color button is updated."""
1516 r
= widget
.get_color().red
1517 g
= widget
.get_color().green
1518 b
= widget
.get_color().blue
1520 label
= self
.getColorLabel(widget
)
1526 label
.set_text(rgbToHex(r
, g
, b
))
1528 self
.changeOccurred()
1530 def colorTyped(self
, widget
):
1531 """Update the color button when a valid value is typed into the entry."""
1532 s
= widget
.get_text()
1534 # The color button associated with this widget.
1535 colorButton
= self
.getColorButton(widget
)
1537 # Just a precautionary check - this situation should never arise.
1539 #print "Error in colorTyped() -- unrecognised entry widget."
1542 # If the entered value is invalid, set textbox to the current
1543 # hex value of the associated color button.
1544 buttonHex
= self
.getHexFromWidget(colorButton
)
1547 errorDialog(self
, "Invalid color specification!")
1548 #self.colorChange(widget) TODO - remove this when issue 29 is verified
1549 widget
.set_text(buttonHex
)
1553 col
= gtk
.gdk
.Color(s
)
1555 errorDialog(self
, "Invalid color specification!")
1556 #self.colorChange(widget) TODO - remove this when issue 29 is verified
1557 widget
.set_text(buttonHex
)
1560 colorButton
.set_color(col
)
1562 # Note: only set init to True when removing backgrounds for a new config
1563 # This prevents unwanted calls to changeOccurred()
1564 def delBgClick(self
, widget
=None, prompt
=True, init
=False):
1565 """Deletes the selected background after confirming with the user."""
1566 selected
= self
.bgNotebook
.get_current_page()
1568 if selected
== -1: # Nothing to remove
1572 if confirmDialog(self
, "Remove this background?") != gtk
.RESPONSE_YES
:
1575 self
.bgNotebook
.remove_page(selected
)
1576 self
.bgs
.pop(selected
)
1578 for i
in range(self
.bgNotebook
.get_n_pages()):
1579 self
.bgNotebook
.set_tab_label_text(self
.bgNotebook
.get_nth_page(i
), "Background ID %d" % (i
+1))
1581 self
.bgNotebook
.show_all()
1583 self
.updateComboBoxes(len(self
.bgs
) + 1, "remove")
1586 self
.changeOccurred()
1588 def generateConfig(self
):
1589 """Reads values from each widget and generates a config."""
1590 self
.configBuf
.delete(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter())
1591 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Tint2 config file\n")
1592 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Generated by tintwizard (http://code.google.com/p/tintwizard/)\n")
1593 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")
1594 if not self
.oneConfigFile
:
1595 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# To use this as default tint2 config: save as $HOME/.config/tint2/tint2rc\n\n")
1597 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Background definitions\n")
1598 for i
in range(len(self
.bgs
)):
1599 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# ID %d\n" % (i
+ 1))
1601 for child
in self
.bgs
[i
].get_children():
1602 if child
.get_name() == "rounded":
1603 rounded
= child
.get_text() if child
.get_text() else BG_ROUNDING
1604 elif child
.get_name() == "border":
1605 borderW
= child
.get_text() if child
.get_text() else BG_BORDER
1606 elif child
.get_name() == "bgCol":
1607 bgCol
= self
.getHexFromWidget(child
)
1608 bgAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1609 elif child
.get_name() == "borderCol":
1610 borderCol
= self
.getHexFromWidget(child
)
1611 borderAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1613 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "rounded = %s\n" % (rounded
))
1614 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_width = %s\n" % (borderW
))
1615 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "background_color = %s %d\n" % (bgCol
, bgAlpha
))
1616 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_color = %s %d\n\n" % (borderCol
, borderAlpha
))
1618 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Panel\n")
1619 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_monitor = %s\n" % (self
.panelMonitor
.get_text() if self
.panelMonitor
.get_text() else PANEL_MONITOR
))
1620 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()))
1621 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
,
1622 self
.panelSizeY
.get_text() if self
.panelSizeY
.get_text() else PANEL_SIZE_Y
))
1623 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
,
1624 self
.panelMarginY
.get_text() if self
.panelMarginY
.get_text() else PANEL_MARGIN_Y
))
1625 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
,
1626 self
.panelPadY
.get_text() if self
.panelPadY
.get_text() else PANEL_PADDING_Y
,
1627 self
.panelSpacing
.get_text() if self
.panelSpacing
.get_text() else TASKBAR_SPACING
))
1628 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_dock = %s\n" % int(self
.panelDock
.get_active()))
1629 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "wm_menu = %s\n" % int(self
.panelMenu
.get_active()))
1630 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_background_id = %s\n" % (self
.panelBg
.get_active()))
1632 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Taskbar\n")
1633 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_mode = %s\n" % (self
.taskbarMode
.get_active_text()))
1634 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
,
1635 self
.taskbarPadY
.get_text() if self
.taskbarPadY
.get_text() else TASKBAR_PADDING_X
,
1636 self
.taskbarSpacing
.get_text() if self
.taskbarSpacing
.get_text() else TASK_SPACING
))
1637 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_background_id = %s\n" % (self
.taskbarBg
.get_active()))
1638 # Comment out the taskbar_active_background_id if user has "disabled" it
1639 if self
.taskbarActiveBgEnable
.get_active() == 0:
1640 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "#")
1641 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_active_background_id = %s\n" % (self
.taskbarActiveBg
.get_active()))
1643 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tasks\n")
1644 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
))
1645 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_icon = %s\n" % int(self
.taskIconCheckButton
.get_active()))
1646 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_text = %s\n" % int(self
.taskTextCheckButton
.get_active()))
1647 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_centered = %s\n" % int(self
.taskCentreCheckButton
.get_active()))
1648 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
))
1649 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
,
1650 self
.taskPadY
.get_text() if self
.taskPadY
.get_text() else TASK_PADDING_Y
))
1651 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_background_id = %s\n" % (self
.taskBg
.get_active()))
1652 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_background_id = %s\n" % (self
.taskActiveBg
.get_active()))
1653 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
,
1654 self
.iconSat
.get_text() if self
.iconSat
.get_text() else ICON_SAT
,
1655 self
.iconBri
.get_text() if self
.iconBri
.get_text() else ICON_BRI
))
1656 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
,
1657 self
.activeIconSat
.get_text() if self
.activeIconSat
.get_text() else ACTIVE_ICON_SAT
,
1658 self
.activeIconBri
.get_text() if self
.activeIconBri
.get_text() else ACTIVE_ICON_BRI
))
1660 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Fonts\n")
1661 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font = %s\n" % (self
.fontButton
.get_font_name()))
1662 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontColButton
),
1663 int(self
.fontColButton
.get_alpha() / 65535.0 * 100)))
1664 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontActiveColButton
),
1665 int(self
.fontActiveColButton
.get_alpha() / 65535.0 * 100)))
1666 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "font_shadow = %s\n" % int(self
.fontShadowCheckButton
.get_active()))
1668 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Systray\n")
1669 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray = %s\n" % int(self
.trayShow
.get_active()))
1670 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
,
1671 self
.trayPadY
.get_text() if self
.trayPadY
.get_text() else TRAY_PADDING_Y
,
1672 self
.traySpacing
.get_text() if self
.traySpacing
.get_text() else TRAY_SPACING
))
1673 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_sort = %s\n" % (self
.trayOrder
.get_active_text()))
1674 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_background_id = %s\n" % (self
.trayBg
.get_active()))
1676 if self
.clockCheckButton
.get_active():
1677 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Clock\n")
1678 if self
.clock1CheckButton
.get_active():
1679 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
))
1680 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_font = %s\n" % (self
.clock1FontButton
.get_font_name()))
1681 if self
.clock2CheckButton
.get_active():
1682 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
))
1683 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_font = %s\n" % (self
.clock2FontButton
.get_font_name()))
1684 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_font_color = %s %s\n" % (self
.getHexFromWidget(self
.clockFontColButton
),
1685 int(self
.clockFontColButton
.get_alpha() / 65535.0 * 100)))
1686 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
,
1687 self
.clockPadY
.get_text() if self
.clockPadY
.get_text() else CLOCK_PADDING_Y
))
1688 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_background_id = %s\n" % (self
.clockBg
.get_active()))
1689 if self
.clockLClick
.get_text():
1690 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_lclick_command = %s\n" % (self
.clockLClick
.get_text()))
1691 if self
.clockRClick
.get_text():
1692 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_rclick_command = %s\n" % (self
.clockRClick
.get_text()))
1694 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tooltips\n")
1695 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip = %s\n" % int(self
.tooltipShow
.get_active()))
1696 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
,
1697 self
.tooltipPadY
.get_text() if self
.tooltipPadY
.get_text() else TOOLTIP_PADDING_Y
))
1698 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
))
1699 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
))
1700 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_background_id = %s\n" % (self
.tooltipBg
.get_active()))
1701 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font = %s\n" % (self
.tooltipFont
.get_font_name()))
1702 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font_color = %s %s\n" % (self
.getHexFromWidget(self
.tooltipFontColButton
),
1703 int(self
.tooltipFontColButton
.get_alpha() / 65535.0 * 100)))
1705 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Mouse\n")
1706 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_middle = %s\n" % (self
.mouseMiddle
.get_active_text()))
1707 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_right = %s\n" % (self
.mouseRight
.get_active_text()))
1708 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_up = %s\n" % (self
.mouseUp
.get_active_text()))
1709 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_down = %s\n" % (self
.mouseDown
.get_active_text()))
1711 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Battery\n")
1712 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery = %s\n" % int(self
.batteryCheckButton
.get_active()))
1713 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
))
1714 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
))
1715 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat1_font = %s\n" % (self
.bat1FontButton
.get_font_name()))
1716 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat2_font = %s\n" % (self
.bat2FontButton
.get_font_name()))
1717 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_font_color = %s %s\n" % (self
.getHexFromWidget(self
.batteryFontColButton
),
1718 int(self
.batteryFontColButton
.get_alpha() / 65535.0 * 100)))
1719 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
,
1720 self
.batteryPadY
.get_text() if self
.batteryPadY
.get_text() else BATTERY_PADDING_Y
))
1721 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_background_id = %s\n" % (self
.batteryBg
.get_active()))
1723 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# End of config")
1725 def getColorButton(self
, widget
):
1726 """Returns the color button associated with widget."""
1727 if widget
.get_name() == "fontCol":
1728 return self
.fontColButton
1729 elif widget
.get_name() == "fontActiveCol":
1730 return self
.fontActiveColButton
1731 elif widget
.get_name() == "clockFontCol":
1732 return self
.clockFontColButton
1733 elif widget
.get_name() == "batteryFontCol":
1734 return self
.batteryFontColButton
1735 elif widget
.get_name() == "tooltipFontCol":
1736 return self
.tooltipFontColButton
1737 elif widget
.get_name() == "bgColEntry":
1738 bgID
= self
.bgNotebook
.get_current_page()
1740 for child
in self
.bgs
[bgID
].get_children():
1741 if child
.get_name() == "bgCol":
1744 elif widget
.get_name() == "borderColEntry":
1745 bgID
= self
.bgNotebook
.get_current_page()
1747 for child
in self
.bgs
[bgID
].get_children():
1748 if child
.get_name() == "borderCol":
1752 # No button found which matches label
1755 def getColorLabel(self
, widget
):
1756 """Gets the color label associated with a color button."""
1757 if widget
.get_name() == "fontCol":
1759 elif widget
.get_name() == "fontActiveCol":
1760 return self
.fontActiveCol
1761 elif widget
.get_name() == "clockFontCol":
1762 return self
.clockFontCol
1763 elif widget
.get_name() == "batteryFontCol":
1764 return self
.batteryFontCol
1765 elif widget
.get_name() == "tooltipFontCol":
1766 return self
.tooltipFontCol
1767 elif widget
.get_name() == "bgCol":
1768 bgID
= self
.bgNotebook
.get_current_page()
1770 for child
in self
.bgs
[bgID
].get_children():
1771 if child
.get_name() == "bgColEntry":
1774 elif widget
.get_name() == "borderCol":
1775 bgID
= self
.bgNotebook
.get_current_page()
1777 for child
in self
.bgs
[bgID
].get_children():
1778 if child
.get_name() == "borderColEntry":
1782 # No label found which matches color button
1785 def getHexFromWidget(self
, widget
):
1786 """Returns the #RRGGBB value of a widget."""
1787 r
= widget
.get_color().red
1788 g
= widget
.get_color().green
1789 b
= widget
.get_color().blue
1791 return rgbToHex(r
, g
, b
)
1793 def help(self
, action
=None):
1794 """Opens the Help wiki page in the default web browser."""
1796 webbrowser
.open("http://code.google.com/p/tintwizard/wiki/Help")
1798 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/wiki/Help")
1800 def reportBug(self
, action
=None):
1801 """Opens the bug report page in the default web browser."""
1803 webbrowser
.open("http://code.google.com/p/tintwizard/issues/entry")
1805 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/issues/entry")
1808 """Enters the main loop."""
1811 def resetConfig(self
):
1812 """Resets all the widgets to their default values."""
1814 for i
in range(len(self
.bgs
)):
1815 self
.delBgClick(prompt
=False, init
=True)
1817 for i
in range(self
.defaults
["bgCount"]):
1818 self
.addBgClick(init
=True)
1820 self
.bgNotebook
.set_current_page(0)
1823 self
.panelPosY
.set_active(0)
1824 self
.panelPosX
.set_active(0)
1825 self
.panelOrientation
.set_active(0)
1826 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
1827 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
1828 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
1829 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
1830 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
1831 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
1832 self
.panelSpacing
.set_text(TASKBAR_SPACING
)
1833 self
.panelBg
.set_active(0)
1834 self
.panelMenu
.set_active(0)
1835 self
.panelDock
.set_active(0)
1836 self
.panelMonitor
.set_text(PANEL_MONITOR
)
1838 self
.taskbarMode
.set_active(0)
1839 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
1840 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
1841 self
.taskbarSpacing
.set_text(TASK_SPACING
)
1842 self
.taskbarBg
.set_active(0)
1843 self
.taskbarActiveBg
.set_active(0)
1844 self
.taskbarActiveBgEnable
.set_active(0)
1846 self
.taskBlinks
.set_text(TASK_BLINKS
)
1847 self
.taskCentreCheckButton
.set_active(True)
1848 self
.taskTextCheckButton
.set_active(True)
1849 self
.taskIconCheckButton
.set_active(True)
1850 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
1851 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
1852 self
.taskPadX
.set_text(TASK_PADDING_X
)
1853 self
.taskPadY
.set_text(TASK_PADDING_Y
)
1854 self
.taskBg
.set_active(0)
1855 self
.taskActiveBg
.set_active(0)
1857 self
.iconHue
.set_text(ICON_ALPHA
)
1858 self
.iconSat
.set_text(ICON_SAT
)
1859 self
.iconBri
.set_text(ICON_BRI
)
1860 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
1861 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
1862 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
1864 self
.fontButton
.set_font_name(self
.defaults
["font"])
1865 self
.fontColButton
.set_alpha(65535)
1866 self
.fontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1867 self
.fontCol
.set_text(self
.defaults
["fgColor"])
1868 self
.fontActiveColButton
.set_alpha(65535)
1869 self
.fontActiveColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1870 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
1871 self
.fontShadowCheckButton
.set_active(False)
1873 self
.trayShow
.set_active(True)
1874 self
.trayPadX
.set_text(TRAY_PADDING_X
)
1875 self
.trayPadY
.set_text(TRAY_PADDING_X
)
1876 self
.traySpacing
.set_text(TRAY_SPACING
)
1877 self
.trayOrder
.set_active(0)
1878 self
.trayBg
.set_active(0)
1880 self
.clockCheckButton
.set_active(True)
1881 self
.clock1Format
.set_text(CLOCK_FMT_1
)
1882 self
.clock1CheckButton
.set_active(True)
1883 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
1884 self
.clock2Format
.set_text(CLOCK_FMT_2
)
1885 self
.clock2CheckButton
.set_active(True)
1886 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
1887 self
.clockFontColButton
.set_alpha(65535)
1888 self
.clockFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1889 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
1890 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
1891 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
1892 self
.clockBg
.set_active(0)
1893 self
.clockLClick
.set_text(CLOCK_LCLICK
)
1894 self
.clockRClick
.set_text(CLOCK_RCLICK
)
1896 self
.tooltipShow
.set_active(False)
1897 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
1898 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
1899 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
1900 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
1901 self
.tooltipBg
.set_active(0)
1902 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1903 self
.tooltipFontColButton
.set_alpha(65535)
1904 self
.tooltipFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1905 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1907 self
.mouseMiddle
.set_active(0)
1908 self
.mouseRight
.set_active(0)
1909 self
.mouseUp
.set_active(0)
1910 self
.mouseDown
.set_active(0)
1912 self
.batteryCheckButton
.set_active(False)
1913 self
.batteryLow
.set_text(BATTERY_LOW
)
1914 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1915 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1916 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1917 self
.batteryFontColButton
.set_alpha(65535)
1918 self
.batteryFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1919 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1920 self
.batteryPadX
.set_text(BATTERY_PADDING_Y
)
1921 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1922 self
.batteryBg
.set_active(0)
1924 def new(self
, action
=None):
1925 """Prepares a new config."""
1930 self
.filename
= None
1934 self
.generateConfig()
1935 self
.updateStatusBar("New Config File [*]")
1937 def openDef(self
, widget
=None):
1938 """Opens the default tint2 config."""
1939 self
.openFile(default
=True)
1941 def openFile(self
, widget
=None, default
=False):
1942 """Reads from a config file. If default=True, open the tint2 default config."""
1946 chooser
= gtk
.FileChooserDialog("Open Config File", self
, gtk
.FILE_CHOOSER_ACTION_OPEN
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
1947 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1949 if self
.curDir
!= None:
1950 chooser
.set_current_folder(self
.curDir
)
1952 chooserFilter
= gtk
.FileFilter()
1953 chooserFilter
.set_name("All files")
1954 chooserFilter
.add_pattern("*")
1955 chooser
.add_filter(chooserFilter
)
1958 response
= chooser
.run()
1960 if response
== gtk
.RESPONSE_OK
:
1961 self
.filename
= chooser
.get_filename()
1962 self
.curDir
= os
.path
.dirname(self
.filename
)
1969 self
.filename
= os
.path
.expandvars("$HOME/.config/tint2/tint2rc")
1970 self
.curDir
= os
.path
.expandvars("$HOME/.config/tint2")
1972 self
.readTint2Config()
1973 self
.generateConfig()
1974 self
.updateStatusBar()
1976 def addBgDefs(self
, bgDefs
):
1977 """Add interface elements for a list of background style definitions. bgDefs
1978 should be a list containing dictionaries with the following keys: rounded,
1979 border_width, background_color, border_color"""
1983 for child
in self
.bgs
[-1].get_children():
1984 if child
.get_name() == "rounded":
1985 child
.set_text(d
["rounded"])
1986 elif child
.get_name() == "border":
1987 child
.set_text(d
["border_width"])
1988 elif child
.get_name() == "bgColEntry":
1989 child
.set_text(d
["background_color"].split(" ")[0].strip())
1991 elif child
.get_name() == "borderColEntry":
1992 child
.set_text(d
["border_color"].split(" ")[0].strip())
1994 elif child
.get_name() == "bgCol":
1995 list = d
["background_color"].split(" ")
1997 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1999 child
.set_alpha(65535)
2000 elif child
.get_name() == "borderCol":
2001 list = d
["border_color"].split(" ")
2003 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
2005 child
.set_alpha(65535)
2007 newId
= len(self
.bgs
)
2009 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
2011 self
.bgNotebook
.show_all()
2013 self
.updateComboBoxes(newId
-1, "add")
2015 self
.bgNotebook
.set_current_page(newId
)
2017 def parseBgs(self
, string
):
2018 """Parses the background definitions from a string."""
2019 s
= string
.split("\n")
2023 bgKeys
= ["border_width", "background_color", "border_color"]
2027 data
= [token
.strip() for token
in line
.split("=")]
2029 if data
[0] == "rounded": # It may be considered bad practice to
2030 bgDefs
+= [{"rounded": data[1]}
] # find each style definition with an
2031 elif data
[0] in bgKeys
: # arbitrary value, but tint2 does the same.
2032 bgDefs
[cur
][data
[0]] = data
[1] # This means that any existing configs must
2033 else: # start with 'rounded'.
2034 newString
+= "%s\n" % line
2036 self
.addBgDefs(bgDefs
)
2040 def parseConfig(self
, string
):
2041 """Parses the contents of a config file."""
2042 for line
in string
.split("\n"):
2043 s
= line
.split("=") # Create a list with KEY and VALUE
2045 e
= s
[0].strip() # Strip whitespace from KEY
2047 if e
== "time1_format": # Set the VALUE of KEY
2048 self
.parseProp(self
.propUI
[e
], s
[1], True, "time1")
2049 elif e
== "time2_format":
2050 self
.parseProp(self
.propUI
[e
], s
[1], True, "time2")
2051 elif e
== "systray_padding":
2052 self
.parseProp(self
.propUI
[e
], s
[1], True, "tray")
2053 elif e
== "taskbar_active_background_id":
2054 self
.parseProp(self
.propUI
[e
], s
[1], True, "activeBg")
2056 if self
.propUI
.has_key(e
):
2057 self
.parseProp(self
.propUI
[e
], s
[1])
2059 def parseProp(self
, prop
, string
, special
=False, propType
=""):
2060 """Parses a variable definition from the conf file and updates the correct UI widget."""
2061 string
= string
.strip() # Remove whitespace from the VALUE
2062 eType
= type(prop
) # Get widget type
2064 if special
: # 'Special' properties are those which are optional
2065 if propType
== "time1":
2066 self
.clockCheckButton
.set_active(True)
2067 self
.clock1CheckButton
.set_active(True)
2068 elif propType
== "time2":
2069 self
.clockCheckButton
.set_active(True)
2070 self
.clock2CheckButton
.set_active(True)
2071 elif propType
== "tray":
2072 self
.trayShow
.set_active(True)
2073 elif propType
== "activeBg":
2074 self
.taskbarActiveBgEnable
.set_active(True)
2076 if eType
== gtk
.Entry
:
2077 prop
.set_text(string
)
2079 elif eType
== gtk
.ComboBox
:
2080 if string
in ["bottom", "top", "left", "right", "center", "single_desktop", "multi_desktop", "single_monitor",
2081 "none", "close", "shade", "iconify", "toggle", "toggle_iconify", "maximize_restore",
2082 "desktop_left", "desktop_right", "horizontal", "vertical", "ascending", "descending",
2083 "left2right", "right2left"]:
2084 if string
in ["bottom", "left", "single_desktop", "none", "horizontal", "ascending"]:
2086 elif string
in ["top", "right", "multi_desktop", "close", "vertical", "descending"]:
2088 elif string
in ["center", "single_monitor", "toggle", "left2right"]:
2090 elif string
in ["right2left"]:
2093 i
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore",
2094 "desktop_left", "desktop_right"].index(string
)
2098 prop
.set_active(int(string
))
2099 elif eType
== gtk
.CheckButton
:
2100 prop
.set_active(bool(int(string
)))
2101 elif eType
== gtk
.FontButton
:
2102 prop
.set_font_name(string
)
2103 elif eType
== gtk
.ColorButton
:
2104 prop
.set_alpha(int(int(string
) * 65535 / 100.0))
2105 elif eType
== tuple: # If a property has more than 1 value, for example the x and y co-ords
2106 s
= string
.split(" ") # of the padding properties, then just we use recursion to set the
2107 for i
in range(len(prop
)): # value of each associated widget.
2109 self
.parseProp(prop
[i
], "0")
2111 self
.parseProp(prop
[i
], s
[i
])
2113 def quit(self
, widget
, event
=None):
2114 """Asks if user would like to save file before quitting, then quits the program."""
2116 if self
.oneConfigFile
:
2117 response
= gtk
.RESPONSE_YES
2119 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
))
2120 dialog
.get_content_area().add(gtk
.Label("Save config before quitting?"))
2121 dialog
.get_content_area().set_size_request(300, 100)
2123 response
= dialog
.run()
2126 if response
== gtk
.RESPONSE_CANCEL
:
2127 return True # Return True to stop it quitting when we hit "Cancel"
2128 elif response
== gtk
.RESPONSE_NO
:
2130 elif response
== gtk
.RESPONSE_YES
:
2137 """Reads the tintwizard configuration file - NOT tint2 config files."""
2138 self
.defaults
= {"font": None, "bgColor": None, "fgColor": None, "borderColor": None, "bgCount": None, "dir": None}
2140 if self
.oneConfigFile
:
2141 # don't need tintwizard.conf
2144 pathName
= os
.path
.dirname(sys
.argv
[0])
2149 if not os
.path
.exists(pathName
+ "tintwizard.conf"):
2153 f
= open(pathName
+ "tintwizard.conf", "r")
2159 if self
.defaults
.has_key(l
[0].strip()):
2160 self
.defaults
[l
[0].strip()] = l
[1].strip()
2162 def readTint2Config(self
):
2163 """Reads in from a config file."""
2164 f
= open(self
.filename
, "r")
2169 if (line
[0] != "#") and (len(line
) > 2):
2174 # Deselect the optional stuff, and we'll re-check them if the config has them enabled
2175 self
.clockCheckButton
.set_active(False)
2176 self
.clock1CheckButton
.set_active(False)
2177 self
.clock2CheckButton
.set_active(False)
2178 self
.trayShow
.set_active(False)
2179 self
.taskbarActiveBgEnable
.set_active(False)
2181 # Remove all background styles so we can create new ones as we read them
2182 for i
in range(len(self
.bgs
)):
2183 self
.delBgClick(None, False)
2185 # As we parse background definitions, we build a new string
2186 # without the background related stuff. This means we don't
2187 # have to read through background defs AGAIN when parsing
2189 noBgDefs
= self
.parseBgs(string
)
2191 self
.parseConfig(noBgDefs
)
2193 def save(self
, widget
=None, event
=None):
2194 """Saves the generated config file."""
2196 # This function returns the boolean status of whether or not the
2197 # file saved, so that the apply() function knows if it should
2198 # kill the tint2 process and apply the new config.
2200 # If no file has been selected, force the user to "Save As..."
2201 if self
.filename
== None:
2202 return self
.saveAs()
2204 self
.generateConfig()
2209 def saveAs(self
, widget
=None, event
=None):
2210 """Prompts the user to select a file and then saves the generated config file."""
2211 self
.generateConfig()
2213 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
))
2214 chooser
.set_default_response(gtk
.RESPONSE_OK
)
2216 if self
.curDir
!= None:
2217 chooser
.set_current_folder(self
.curDir
)
2219 chooserFilter
= gtk
.FileFilter()
2220 chooserFilter
.set_name("All files")
2221 chooserFilter
.add_pattern("*")
2222 chooser
.add_filter(chooserFilter
)
2225 response
= chooser
.run()
2227 if response
== gtk
.RESPONSE_OK
:
2228 self
.filename
= chooser
.get_filename()
2230 if os
.path
.exists(self
.filename
):
2231 overwrite
= confirmDialog(self
, "This file already exists. Overwrite this file?")
2233 if overwrite
== gtk
.RESPONSE_YES
:
2238 self
.filename
= None
2246 self
.filename
= None
2250 def saveAsDef(self
, widget
=None, event
=None):
2251 """Saves the config as the default tint2 config."""
2252 if confirmDialog(self
, "Overwrite current tint2 default config?") == gtk
.RESPONSE_YES
:
2253 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
2254 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
2256 # If, for whatever reason, tint2 has no default config - create one.
2257 if not os
.path
.isfile(self
.filename
):
2258 f
= open(self
.filename
, "w")
2259 f
.write("# tint2rc")
2262 self
.generateConfig()
2267 def savePrompt(self
):
2268 """Prompt the user to save before creating a new file."""
2269 if confirmDialog(self
, "Save current config?") == gtk
.RESPONSE_YES
:
2272 def switchPage(self
, notebook
, page
, page_num
):
2273 """Handles notebook page switch events."""
2275 # If user selects the 'View Config' tab, update the textarea within this tab.
2276 if notebook
.get_tab_label_text(notebook
.get_nth_page(page_num
)) == "View Config":
2277 self
.generateConfig()
2279 def updateComboBoxes(self
, i
, action
="add"):
2280 """Updates the contents of a combo box when a background style has been added/removed."""
2281 cbs
= [self
.batteryBg
, self
.clockBg
, self
.taskbarBg
, self
.taskbarActiveBg
, self
.trayBg
, self
.taskActiveBg
, self
.taskBg
, self
.panelBg
, self
.tooltipBg
]
2285 cb
.append_text(str(i
+1))
2288 if cb
.get_active() == i
: # If background is selected, set to a different value
2293 def updateStatusBar(self
, message
="", change
=False):
2294 """Updates the message on the statusbar. A message can be provided,
2295 and if change is set to True (i.e. something has been modified) then
2296 an appropriate symbol [*] is shown beside filename."""
2297 contextID
= self
.statusBar
.get_context_id("")
2299 self
.statusBar
.pop(contextID
)
2302 message
= "%s %s" % (self
.filename
or "New Config File", "[*]" if change
else "")
2304 self
.statusBar
.push(contextID
, message
)
2306 def writeConf(self
):
2307 """Writes the tintwizard configuration file."""
2308 confStr
= "#Start\n[defaults]\n"
2310 for key
in self
.defaults
:
2311 confStr
+= "%s = %s\n" % (key
, str(self
.defaults
[key
]))
2315 pathName
= os
.path
.dirname(sys
.argv
[0])
2318 f
= open("tintwizard.conf", "w")
2320 f
= open(pathName
+"/tintwizard.conf", "w")
2326 def writeFile(self
):
2327 """Writes the contents of the config text buffer to file."""
2329 f
= open(self
.filename
, "w")
2331 f
.write(self
.configBuf
.get_text(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter()))
2337 self
.curDir
= os
.path
.dirname(self
.filename
)
2339 self
.updateStatusBar()
2341 errorDialog(self
, "Could not save file")
2343 # General use functions
2344 def confirmDialog(parent
, message
):
2345 """Creates a confirmation dialog and returns the response."""
2346 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
, message
)
2348 response
= dialog
.run()
2352 def errorDialog(parent
=None, message
="An error has occured!"):
2353 """Creates an error dialog."""
2354 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
2360 """Convert integer n in range [0, 15] to hex."""
2362 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"][n
]
2366 def rgbToHex(r
, g
, b
):
2367 """Constructs a 6 digit hex representation of color (r, g, b)."""
2368 r2
= trunc(r
/ 65535.0 * 255)
2369 g2
= trunc(g
/ 65535.0 * 255)
2370 b2
= trunc(b
/ 65535.0 * 255)
2372 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))
2375 """Truncate a floating point number, rounding up or down appropriately."""
2376 c
= math
.fabs(math
.ceil(n
) - n
)
2377 f
= math
.fabs(math
.floor(n
) - n
)
2380 return int(math
.ceil(n
))
2382 return int(math
.floor(n
))
2384 # Direct execution of application
2385 if __name__
== "__main__":
2386 tw
= TintWizardGUI()