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 # Create and add the status bar to the bottom of the main window
1241 self
.statusBar
= gtk
.Statusbar()
1242 self
.statusBar
.set_has_resize_grip(True)
1243 self
.updateStatusBar("New Config File [*]")
1244 self
.table
.attach(self
.statusBar
, 0, 4, 3, 4)
1246 self
.add(self
.table
)
1250 # Create our property dictionary. This holds the widgets which correspond to each property
1252 "panel_monitor": self
.panelMonitor
,
1253 "panel_position": (self
.panelPosY
, self
.panelPosX
, self
.panelOrientation
),
1254 "panel_size": (self
.panelSizeX
, self
.panelSizeY
),
1255 "panel_margin": (self
.panelMarginX
, self
.panelMarginY
),
1256 "panel_padding": (self
.panelPadX
, self
.panelPadY
, self
.panelSpacing
),
1257 "wm_menu": self
.panelMenu
,
1258 "panel_dock": self
.panelDock
,
1259 "panel_background_id": self
.panelBg
,
1260 "taskbar_mode": self
.taskbarMode
,
1261 "taskbar_padding": (self
.taskbarPadX
, self
.taskbarPadY
, self
.taskbarSpacing
),
1262 "taskbar_background_id": self
.taskbarBg
,
1263 "taskbar_active_background_id": self
.taskbarActiveBg
,
1264 "task_icon": self
.taskIconCheckButton
,
1265 "task_text": self
.taskTextCheckButton
,
1266 "task_centered": self
.taskCentreCheckButton
,
1267 "task_maximum_size": (self
.taskMaxSizeX
, self
.taskMaxSizeY
),
1268 "task_padding": (self
.taskPadX
, self
.taskPadY
),
1269 "task_background_id": self
.taskBg
,
1270 "task_active_background_id": self
.taskActiveBg
,
1271 "task_font": self
.fontButton
,
1272 "task_font_color": (self
.fontCol
, self
.fontColButton
),
1273 "task_active_font_color": (self
.fontActiveCol
, self
.fontActiveColButton
),
1274 "task_icon_asb": (self
.iconHue
, self
.iconSat
, self
.iconBri
),
1275 "task_active_icon_asb": (self
.activeIconHue
, self
.activeIconSat
, self
.activeIconBri
),
1276 "font_shadow": self
.fontShadowCheckButton
,
1277 "systray": self
.trayShow
,
1278 "systray_padding": (self
.trayPadX
, self
.trayPadY
, self
.traySpacing
),
1279 "systray_background_id": self
.trayBg
,
1280 "systray_sort": self
.trayOrder
,
1281 "time1_format": self
.clock1Format
,
1282 "time2_format": self
.clock2Format
,
1283 "time1_font": self
.clock1FontButton
,
1284 "time2_font": self
.clock2FontButton
,
1285 "clock_font_color": (self
.clockFontCol
, self
.clockFontColButton
),
1286 "clock_padding": (self
.clockPadX
, self
.clockPadY
),
1287 "clock_background_id": self
.clockBg
,
1288 "clock_lclick_command": self
.clockLClick
,
1289 "clock_rclick_command": self
.clockRClick
,
1290 "mouse_middle": self
.mouseMiddle
,
1291 "mouse_right": self
.mouseRight
,
1292 "mouse_scroll_up": self
.mouseUp
,
1293 "mouse_scroll_down": self
.mouseDown
,
1294 "tooltip": self
.tooltipShow
,
1295 "tooltip_padding": (self
.tooltipPadX
, self
.tooltipPadY
),
1296 "tooltip_show_timeout": self
.tooltipShowTime
,
1297 "tooltip_hide_timeout": self
.tooltipHideTime
,
1298 "tooltip_background_id": self
.tooltipBg
,
1299 "tooltip_font": self
.tooltipFont
,
1300 "tooltip_font_color": (self
.tooltipFontCol
, self
.tooltipFontColButton
),
1301 "battery": self
.batteryCheckButton
,
1302 "battery_low_status": self
.batteryLow
,
1303 "battery_low_cmd": self
.batteryLowAction
,
1304 "bat1_font": self
.bat1FontButton
,
1305 "bat2_font": self
.bat2FontButton
,
1306 "battery_font_color": (self
.batteryFontCol
, self
.batteryFontColButton
),
1307 "battery_padding": (self
.batteryPadX
, self
.batteryPadY
),
1308 "battery_background_id": self
.batteryBg
1311 if self
.oneConfigFile
:
1312 self
.readTint2Config()
1314 self
.generateConfig()
1316 def about(self
, action
=None):
1317 """Displays the About dialog."""
1318 about
= gtk
.AboutDialog()
1319 about
.set_program_name(NAME
)
1320 about
.set_version(VERSION
)
1321 about
.set_authors(AUTHORS
)
1322 about
.set_comments(COMMENTS
)
1323 about
.set_website(WEBSITE
)
1324 gtk
.about_dialog_set_url_hook(self
.aboutLinkCallback
)
1328 def aboutLinkCallback(dialog
, link
, data
=None):
1329 """Callback for when a URL is clicked in an About dialog."""
1331 webbrowser
.open(link
)
1333 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit %s" % link
)
1336 """Adds a new background to the list of backgrounds."""
1337 self
.bgs
+= [gtk
.Table(4, 3, False)]
1339 temp
= gtk
.Label("Corner Rounding (px)")
1340 temp
.set_alignment(0, 0.5)
1341 self
.bgs
[-1].attach(temp
, 0, 1, 0, 1, xpadding
=10)
1343 temp
.set_width_chars(9)
1344 temp
.set_name("rounded")
1345 temp
.set_text(BG_ROUNDING
)
1346 temp
.connect("changed", self
.changeOccurred
)
1347 self
.bgs
[-1].attach(temp
, 1, 2, 0, 1, xoptions
=gtk
.EXPAND
)
1349 temp
= gtk
.Label("Background Color")
1350 temp
.set_alignment(0, 0.5)
1351 self
.bgs
[-1].attach(temp
, 0, 1, 1, 2, xpadding
=10)
1353 temp
.set_width_chars(9)
1354 temp
.set_name("bgColEntry")
1355 temp
.set_text(self
.defaults
["bgColor"])
1356 temp
.connect("changed", self
.changeOccurred
)
1357 temp
.connect("activate", self
.colorTyped
)
1358 self
.bgs
[-1].attach(temp
, 1, 2, 1, 2, xoptions
=gtk
.EXPAND
)
1359 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["bgColor"]))
1360 temp
.set_use_alpha(True)
1361 temp
.set_name("bgCol")
1362 temp
.connect("color-set", self
.colorChange
)
1363 self
.bgs
[-1].attach(temp
, 2, 3, 1, 2, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1365 temp
= gtk
.Label("Border Width (px)")
1366 temp
.set_alignment(0, 0.5)
1367 self
.bgs
[-1].attach(temp
, 0, 1, 2, 3, xpadding
=10)
1369 temp
.set_width_chars(9)
1370 temp
.set_name("border")
1371 temp
.set_text(BG_BORDER
)
1372 temp
.connect("changed", self
.changeOccurred
)
1373 self
.bgs
[-1].attach(temp
, 1, 2, 2, 3, xoptions
=gtk
.EXPAND
)
1375 temp
= gtk
.Label("Border Color")
1376 temp
.set_alignment(0, 0.5)
1377 self
.bgs
[-1].attach(temp
, 0, 1, 3, 4, xpadding
=10)
1379 temp
.set_width_chars(9)
1380 temp
.set_name("borderColEntry")
1381 temp
.connect("activate", self
.colorTyped
)
1382 temp
.set_text(self
.defaults
["borderColor"])
1383 temp
.connect("changed", self
.changeOccurred
)
1384 self
.bgs
[-1].attach(temp
, 1, 2, 3, 4, xoptions
=gtk
.EXPAND
)
1385 temp
= gtk
.ColorButton(gtk
.gdk
.color_parse(self
.defaults
["borderColor"]))
1386 temp
.set_use_alpha(True)
1387 temp
.set_name("borderCol")
1388 temp
.connect("color-set", self
.colorChange
)
1389 self
.bgs
[-1].attach(temp
, 2, 3, 3, 4, xoptions
=gtk
.EXPAND
, yoptions
=gtk
.EXPAND
)
1391 # Note: Only set init to True when initialising background styles.
1392 # This prevents unwanted calls to changeOccurred()
1393 def addBgClick(self
, widget
=None, init
=False):
1394 """Creates a new background and adds a new tab to the notebook."""
1395 n
= self
.bgNotebook
.get_n_pages()
1397 if n
> (self
.defaults
["bgCount"] + 2):
1398 if confirmDialog(self
, "You already have %d background styles. Are you sure you would like another?" % n
) == gtk
.RESPONSE_NO
:
1403 newId
= len(self
.bgs
)
1405 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1407 self
.bgNotebook
.show_all()
1409 self
.updateComboBoxes(n
, "add")
1411 self
.bgNotebook
.set_current_page(n
)
1414 self
.changeOccurred()
1416 def apply(self
, widget
, event
=None, confirmChange
=True):
1417 """Applies the current config to tint2."""
1418 if confirmDialog(self
, "This will terminate all currently running instances of tint2 before applying config. Continue?") == gtk
.RESPONSE_YES
:
1422 #shutil.copyfile(self.filename, self.filename+".backup") # Create backup
1424 # Check if tint2 is running
1425 procs
= os
.popen('pidof "tint2"') # Check list of active processes for tint2
1426 pids
= [] # List of process ids for tint2
1428 for proc
in procs
.readlines():
1429 pids
+= [int(proc
.strip().split(" ")[0])]
1433 # If it is - kill it
1435 os
.kill(pid
, signal
.SIGTERM
)
1438 os
.spawnv(os
.P_NOWAIT
, self
.tint2Bin
, [self
.tint2Bin
, "-c" + self
.filename
])
1440 if confirmChange
and self
.filename
!= (os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc") and confirmDialog(self
, "Use this as default tint2 config?") == gtk
.RESPONSE_YES
:
1442 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
1444 shutil
.copyfile(tmp
, self
.filename
)
1445 except shutil
.Error
:
1448 #if confirmChange and confirmDialog(self, "Keep this config?") == gtk.RESPONSE_NO:
1449 # shutil.copyfile(self.filename+".backup", self.filename) # Create backup
1450 # self.apply(widget, event, False)
1452 def changeAllFonts(self
, widget
):
1453 """Changes all fonts at once."""
1454 dialog
= gtk
.FontSelectionDialog("Select Font")
1456 dialog
.set_font_name(self
.defaults
["font"])
1458 if dialog
.run() == gtk
.RESPONSE_OK
:
1459 newFont
= dialog
.get_font_name()
1461 self
.clock1FontButton
.set_font_name(newFont
)
1462 self
.clock2FontButton
.set_font_name(newFont
)
1463 self
.bat1FontButton
.set_font_name(newFont
)
1464 self
.bat2FontButton
.set_font_name(newFont
)
1465 self
.fontButton
.set_font_name(newFont
)
1469 self
.generateConfig()
1470 self
.changeOccurred()
1472 def changeDefaults(self
, widget
=None):
1473 """Shows the style preferences widget."""
1474 TintWizardPrefGUI(self
)
1476 def changeOccurred(self
, widget
=None):
1477 """Called when the user changes something, i.e. entry value"""
1480 self
.updateStatusBar(change
=True)
1482 if widget
== self
.panelOrientation
:
1483 if self
.panelOrientation
.get_active_text() == "horizontal":
1484 self
.panelSizeLabel
.set_text("Size (width, height)")
1486 self
.panelSizeLabel
.set_text("Size (height, width)")
1488 def colorChange(self
, widget
):
1489 """Update the text entry when a color button is updated."""
1490 r
= widget
.get_color().red
1491 g
= widget
.get_color().green
1492 b
= widget
.get_color().blue
1494 label
= self
.getColorLabel(widget
)
1500 label
.set_text(rgbToHex(r
, g
, b
))
1502 self
.changeOccurred()
1504 def colorTyped(self
, widget
):
1505 """Update the color button when a valid value is typed into the entry."""
1506 s
= widget
.get_text()
1508 # The color button associated with this widget.
1509 colorButton
= self
.getColorButton(widget
)
1511 # Just a precautionary check - this situation should never arise.
1513 #print "Error in colorTyped() -- unrecognised entry widget."
1516 # If the entered value is invalid, set textbox to the current
1517 # hex value of the associated color button.
1518 buttonHex
= self
.getHexFromWidget(colorButton
)
1521 errorDialog(self
, "Invalid color specification!")
1522 #self.colorChange(widget) TODO - remove this when issue 29 is verified
1523 widget
.set_text(buttonHex
)
1527 col
= gtk
.gdk
.Color(s
)
1529 errorDialog(self
, "Invalid color specification!")
1530 #self.colorChange(widget) TODO - remove this when issue 29 is verified
1531 widget
.set_text(buttonHex
)
1534 colorButton
.set_color(col
)
1536 # Note: only set init to True when removing backgrounds for a new config
1537 # This prevents unwanted calls to changeOccurred()
1538 def delBgClick(self
, widget
=None, prompt
=True, init
=False):
1539 """Deletes the selected background after confirming with the user."""
1540 selected
= self
.bgNotebook
.get_current_page()
1542 if selected
== -1: # Nothing to remove
1546 if confirmDialog(self
, "Remove this background?") != gtk
.RESPONSE_YES
:
1549 self
.bgNotebook
.remove_page(selected
)
1550 self
.bgs
.pop(selected
)
1552 for i
in range(self
.bgNotebook
.get_n_pages()):
1553 self
.bgNotebook
.set_tab_label_text(self
.bgNotebook
.get_nth_page(i
), "Background ID %d" % (i
+1))
1555 self
.bgNotebook
.show_all()
1557 self
.updateComboBoxes(len(self
.bgs
) + 1, "remove")
1560 self
.changeOccurred()
1562 def generateConfig(self
):
1563 """Reads values from each widget and generates a config."""
1564 self
.configBuf
.delete(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter())
1565 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Tint2 config file\n")
1566 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Generated by tintwizard (http://code.google.com/p/tintwizard/)\n")
1567 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")
1568 if not self
.oneConfigFile
:
1569 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# To use this as default tint2 config: save as $HOME/.config/tint2/tint2rc\n\n")
1571 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Background definitions\n")
1572 for i
in range(len(self
.bgs
)):
1573 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# ID %d\n" % (i
+ 1))
1575 for child
in self
.bgs
[i
].get_children():
1576 if child
.get_name() == "rounded":
1577 rounded
= child
.get_text() if child
.get_text() else BG_ROUNDING
1578 elif child
.get_name() == "border":
1579 borderW
= child
.get_text() if child
.get_text() else BG_BORDER
1580 elif child
.get_name() == "bgCol":
1581 bgCol
= self
.getHexFromWidget(child
)
1582 bgAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1583 elif child
.get_name() == "borderCol":
1584 borderCol
= self
.getHexFromWidget(child
)
1585 borderAlpha
= int(child
.get_alpha() / 65535.0 * 100)
1587 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "rounded = %s\n" % (rounded
))
1588 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_width = %s\n" % (borderW
))
1589 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "background_color = %s %d\n" % (bgCol
, bgAlpha
))
1590 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "border_color = %s %d\n\n" % (borderCol
, borderAlpha
))
1592 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "# Panel\n")
1593 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_monitor = %s\n" % (self
.panelMonitor
.get_text() if self
.panelMonitor
.get_text() else PANEL_MONITOR
))
1594 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()))
1595 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
,
1596 self
.panelSizeY
.get_text() if self
.panelSizeY
.get_text() else PANEL_SIZE_Y
))
1597 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
,
1598 self
.panelMarginY
.get_text() if self
.panelMarginY
.get_text() else PANEL_MARGIN_Y
))
1599 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
,
1600 self
.panelPadY
.get_text() if self
.panelPadY
.get_text() else PANEL_PADDING_Y
,
1601 self
.panelSpacing
.get_text() if self
.panelSpacing
.get_text() else TASKBAR_SPACING
))
1602 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_dock = %s\n" % int(self
.panelDock
.get_active()))
1603 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "wm_menu = %s\n" % int(self
.panelMenu
.get_active()))
1604 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "panel_background_id = %s\n" % (self
.panelBg
.get_active()))
1606 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Taskbar\n")
1607 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_mode = %s\n" % (self
.taskbarMode
.get_active_text()))
1608 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
,
1609 self
.taskbarPadY
.get_text() if self
.taskbarPadY
.get_text() else TASKBAR_PADDING_X
,
1610 self
.taskbarSpacing
.get_text() if self
.taskbarSpacing
.get_text() else TASK_SPACING
))
1611 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_background_id = %s\n" % (self
.taskbarBg
.get_active()))
1612 # Comment out the taskbar_active_background_id if user has "disabled" it
1613 if self
.taskbarActiveBgEnable
.get_active() == 0:
1614 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "#")
1615 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "taskbar_active_background_id = %s\n" % (self
.taskbarActiveBg
.get_active()))
1617 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tasks\n")
1618 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
))
1619 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_icon = %s\n" % int(self
.taskIconCheckButton
.get_active()))
1620 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_text = %s\n" % int(self
.taskTextCheckButton
.get_active()))
1621 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_centered = %s\n" % int(self
.taskCentreCheckButton
.get_active()))
1622 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
))
1623 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
,
1624 self
.taskPadY
.get_text() if self
.taskPadY
.get_text() else TASK_PADDING_Y
))
1625 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_background_id = %s\n" % (self
.taskBg
.get_active()))
1626 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_background_id = %s\n" % (self
.taskActiveBg
.get_active()))
1627 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
,
1628 self
.iconSat
.get_text() if self
.iconSat
.get_text() else ICON_SAT
,
1629 self
.iconBri
.get_text() if self
.iconBri
.get_text() else ICON_BRI
))
1630 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
,
1631 self
.activeIconSat
.get_text() if self
.activeIconSat
.get_text() else ACTIVE_ICON_SAT
,
1632 self
.activeIconBri
.get_text() if self
.activeIconBri
.get_text() else ACTIVE_ICON_BRI
))
1634 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Fonts\n")
1635 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font = %s\n" % (self
.fontButton
.get_font_name()))
1636 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontColButton
),
1637 int(self
.fontColButton
.get_alpha() / 65535.0 * 100)))
1638 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "task_active_font_color = %s %s\n" % (self
.getHexFromWidget(self
.fontActiveColButton
),
1639 int(self
.fontActiveColButton
.get_alpha() / 65535.0 * 100)))
1640 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "font_shadow = %s\n" % int(self
.fontShadowCheckButton
.get_active()))
1642 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Systray\n")
1643 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray = %s\n" % int(self
.trayShow
.get_active()))
1644 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
,
1645 self
.trayPadY
.get_text() if self
.trayPadY
.get_text() else TRAY_PADDING_Y
,
1646 self
.traySpacing
.get_text() if self
.traySpacing
.get_text() else TRAY_SPACING
))
1647 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_sort = %s\n" % (self
.trayOrder
.get_active_text()))
1648 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "systray_background_id = %s\n" % (self
.trayBg
.get_active()))
1650 if self
.clockCheckButton
.get_active():
1651 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Clock\n")
1652 if self
.clock1CheckButton
.get_active():
1653 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
))
1654 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time1_font = %s\n" % (self
.clock1FontButton
.get_font_name()))
1655 if self
.clock2CheckButton
.get_active():
1656 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
))
1657 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "time2_font = %s\n" % (self
.clock2FontButton
.get_font_name()))
1658 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_font_color = %s %s\n" % (self
.getHexFromWidget(self
.clockFontColButton
),
1659 int(self
.clockFontColButton
.get_alpha() / 65535.0 * 100)))
1660 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
,
1661 self
.clockPadY
.get_text() if self
.clockPadY
.get_text() else CLOCK_PADDING_Y
))
1662 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_background_id = %s\n" % (self
.clockBg
.get_active()))
1663 if self
.clockLClick
.get_text():
1664 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_lclick_command = %s\n" % (self
.clockLClick
.get_text()))
1665 if self
.clockRClick
.get_text():
1666 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "clock_rclick_command = %s\n" % (self
.clockRClick
.get_text()))
1668 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Tooltips\n")
1669 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip = %s\n" % int(self
.tooltipShow
.get_active()))
1670 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
,
1671 self
.tooltipPadY
.get_text() if self
.tooltipPadY
.get_text() else TOOLTIP_PADDING_Y
))
1672 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
))
1673 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
))
1674 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_background_id = %s\n" % (self
.tooltipBg
.get_active()))
1675 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font = %s\n" % (self
.tooltipFont
.get_font_name()))
1676 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "tooltip_font_color = %s %s\n" % (self
.getHexFromWidget(self
.tooltipFontColButton
),
1677 int(self
.tooltipFontColButton
.get_alpha() / 65535.0 * 100)))
1679 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Mouse\n")
1680 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_middle = %s\n" % (self
.mouseMiddle
.get_active_text()))
1681 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_right = %s\n" % (self
.mouseRight
.get_active_text()))
1682 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_up = %s\n" % (self
.mouseUp
.get_active_text()))
1683 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "mouse_scroll_down = %s\n" % (self
.mouseDown
.get_active_text()))
1685 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# Battery\n")
1686 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery = %s\n" % int(self
.batteryCheckButton
.get_active()))
1687 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
))
1688 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
))
1689 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat1_font = %s\n" % (self
.bat1FontButton
.get_font_name()))
1690 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "bat2_font = %s\n" % (self
.bat2FontButton
.get_font_name()))
1691 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_font_color = %s %s\n" % (self
.getHexFromWidget(self
.batteryFontColButton
),
1692 int(self
.batteryFontColButton
.get_alpha() / 65535.0 * 100)))
1693 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
,
1694 self
.batteryPadY
.get_text() if self
.batteryPadY
.get_text() else BATTERY_PADDING_Y
))
1695 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "battery_background_id = %s\n" % (self
.batteryBg
.get_active()))
1697 self
.configBuf
.insert(self
.configBuf
.get_end_iter(), "\n# End of config")
1699 def getColorButton(self
, widget
):
1700 """Returns the color button associated with widget."""
1701 if widget
.get_name() == "fontCol":
1702 return self
.fontColButton
1703 elif widget
.get_name() == "fontActiveCol":
1704 return self
.fontActiveColButton
1705 elif widget
.get_name() == "clockFontCol":
1706 return self
.clockFontColButton
1707 elif widget
.get_name() == "batteryFontCol":
1708 return self
.batteryFontColButton
1709 elif widget
.get_name() == "tooltipFontCol":
1710 return self
.tooltipFontColButton
1711 elif widget
.get_name() == "bgColEntry":
1712 bgID
= self
.bgNotebook
.get_current_page()
1714 for child
in self
.bgs
[bgID
].get_children():
1715 if child
.get_name() == "bgCol":
1718 elif widget
.get_name() == "borderColEntry":
1719 bgID
= self
.bgNotebook
.get_current_page()
1721 for child
in self
.bgs
[bgID
].get_children():
1722 if child
.get_name() == "borderCol":
1726 # No button found which matches label
1729 def getColorLabel(self
, widget
):
1730 """Gets the color label associated with a color button."""
1731 if widget
.get_name() == "fontCol":
1733 elif widget
.get_name() == "fontActiveCol":
1734 return self
.fontActiveCol
1735 elif widget
.get_name() == "clockFontCol":
1736 return self
.clockFontCol
1737 elif widget
.get_name() == "batteryFontCol":
1738 return self
.batteryFontCol
1739 elif widget
.get_name() == "tooltipFontCol":
1740 return self
.tooltipFontCol
1741 elif widget
.get_name() == "bgCol":
1742 bgID
= self
.bgNotebook
.get_current_page()
1744 for child
in self
.bgs
[bgID
].get_children():
1745 if child
.get_name() == "bgColEntry":
1748 elif widget
.get_name() == "borderCol":
1749 bgID
= self
.bgNotebook
.get_current_page()
1751 for child
in self
.bgs
[bgID
].get_children():
1752 if child
.get_name() == "borderColEntry":
1756 # No label found which matches color button
1759 def getHexFromWidget(self
, widget
):
1760 """Returns the #RRGGBB value of a widget."""
1761 r
= widget
.get_color().red
1762 g
= widget
.get_color().green
1763 b
= widget
.get_color().blue
1765 return rgbToHex(r
, g
, b
)
1767 def help(self
, action
=None):
1768 """Opens the Help wiki page in the default web browser."""
1770 webbrowser
.open("http://code.google.com/p/tintwizard/wiki/Help")
1772 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/wiki/Help")
1774 def reportBug(self
, action
=None):
1775 """Opens the bug report page in the default web browser."""
1777 webbrowser
.open("http://code.google.com/p/tintwizard/issues/entry")
1779 errorDialog(self
, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/issues/entry")
1782 """Enters the main loop."""
1785 def resetConfig(self
):
1786 """Resets all the widgets to their default values."""
1788 for i
in range(len(self
.bgs
)):
1789 self
.delBgClick(prompt
=False, init
=True)
1791 for i
in range(self
.defaults
["bgCount"]):
1792 self
.addBgClick(init
=True)
1794 self
.bgNotebook
.set_current_page(0)
1797 self
.panelPosY
.set_active(0)
1798 self
.panelPosX
.set_active(0)
1799 self
.panelOrientation
.set_active(0)
1800 self
.panelSizeX
.set_text(PANEL_SIZE_X
)
1801 self
.panelSizeY
.set_text(PANEL_SIZE_Y
)
1802 self
.panelMarginX
.set_text(PANEL_MARGIN_X
)
1803 self
.panelMarginY
.set_text(PANEL_MARGIN_Y
)
1804 self
.panelPadX
.set_text(PANEL_PADDING_Y
)
1805 self
.panelPadY
.set_text(PANEL_PADDING_Y
)
1806 self
.panelSpacing
.set_text(TASKBAR_SPACING
)
1807 self
.panelBg
.set_active(0)
1808 self
.panelMenu
.set_active(0)
1809 self
.panelDock
.set_active(0)
1810 self
.panelMonitor
.set_text(PANEL_MONITOR
)
1812 self
.taskbarMode
.set_active(0)
1813 self
.taskbarPadX
.set_text(TASKBAR_PADDING_X
)
1814 self
.taskbarPadY
.set_text(TASKBAR_PADDING_Y
)
1815 self
.taskbarSpacing
.set_text(TASK_SPACING
)
1816 self
.taskbarBg
.set_active(0)
1817 self
.taskbarActiveBg
.set_active(0)
1818 self
.taskbarActiveBgEnable
.set_active(0)
1820 self
.taskBlinks
.set_text(TASK_BLINKS
)
1821 self
.taskCentreCheckButton
.set_active(True)
1822 self
.taskTextCheckButton
.set_active(True)
1823 self
.taskIconCheckButton
.set_active(True)
1824 self
.taskMaxSizeX
.set_text(TASK_MAXIMUM_SIZE_X
)
1825 self
.taskMaxSizeY
.set_text(TASK_MAXIMUM_SIZE_Y
)
1826 self
.taskPadX
.set_text(TASK_PADDING_X
)
1827 self
.taskPadY
.set_text(TASK_PADDING_Y
)
1828 self
.taskBg
.set_active(0)
1829 self
.taskActiveBg
.set_active(0)
1831 self
.iconHue
.set_text(ICON_ALPHA
)
1832 self
.iconSat
.set_text(ICON_SAT
)
1833 self
.iconBri
.set_text(ICON_BRI
)
1834 self
.activeIconHue
.set_text(ACTIVE_ICON_ALPHA
)
1835 self
.activeIconSat
.set_text(ACTIVE_ICON_SAT
)
1836 self
.activeIconBri
.set_text(ACTIVE_ICON_BRI
)
1838 self
.fontButton
.set_font_name(self
.defaults
["font"])
1839 self
.fontColButton
.set_alpha(65535)
1840 self
.fontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1841 self
.fontCol
.set_text(self
.defaults
["fgColor"])
1842 self
.fontActiveColButton
.set_alpha(65535)
1843 self
.fontActiveColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1844 self
.fontActiveCol
.set_text(self
.defaults
["fgColor"])
1845 self
.fontShadowCheckButton
.set_active(False)
1847 self
.trayShow
.set_active(True)
1848 self
.trayPadX
.set_text(TRAY_PADDING_X
)
1849 self
.trayPadY
.set_text(TRAY_PADDING_X
)
1850 self
.traySpacing
.set_text(TRAY_SPACING
)
1851 self
.trayOrder
.set_active(0)
1852 self
.trayBg
.set_active(0)
1854 self
.clockCheckButton
.set_active(True)
1855 self
.clock1Format
.set_text(CLOCK_FMT_1
)
1856 self
.clock1CheckButton
.set_active(True)
1857 self
.clock1FontButton
.set_font_name(self
.defaults
["font"])
1858 self
.clock2Format
.set_text(CLOCK_FMT_2
)
1859 self
.clock2CheckButton
.set_active(True)
1860 self
.clock2FontButton
.set_font_name(self
.defaults
["font"])
1861 self
.clockFontColButton
.set_alpha(65535)
1862 self
.clockFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1863 self
.clockFontCol
.set_text(self
.defaults
["fgColor"])
1864 self
.clockPadX
.set_text(CLOCK_PADDING_X
)
1865 self
.clockPadY
.set_text(CLOCK_PADDING_Y
)
1866 self
.clockBg
.set_active(0)
1867 self
.clockLClick
.set_text(CLOCK_LCLICK
)
1868 self
.clockRClick
.set_text(CLOCK_RCLICK
)
1870 self
.tooltipShow
.set_active(False)
1871 self
.tooltipPadX
.set_text(TOOLTIP_PADDING_X
)
1872 self
.tooltipPadY
.set_text(TOOLTIP_PADDING_Y
)
1873 self
.tooltipShowTime
.set_text(TOOLTIP_SHOW_TIMEOUT
)
1874 self
.tooltipHideTime
.set_text(TOOLTIP_HIDE_TIMEOUT
)
1875 self
.tooltipBg
.set_active(0)
1876 self
.tooltipFont
.set_font_name(self
.defaults
["font"])
1877 self
.tooltipFontColButton
.set_alpha(65535)
1878 self
.tooltipFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1879 self
.tooltipFontCol
.set_text(self
.defaults
["fgColor"])
1881 self
.mouseMiddle
.set_active(0)
1882 self
.mouseRight
.set_active(0)
1883 self
.mouseUp
.set_active(0)
1884 self
.mouseDown
.set_active(0)
1886 self
.batteryCheckButton
.set_active(False)
1887 self
.batteryLow
.set_text(BATTERY_LOW
)
1888 self
.batteryLowAction
.set_text(BATTERY_ACTION
)
1889 self
.bat1FontButton
.set_font_name(self
.defaults
["font"])
1890 self
.bat2FontButton
.set_font_name(self
.defaults
["font"])
1891 self
.batteryFontColButton
.set_alpha(65535)
1892 self
.batteryFontColButton
.set_color(gtk
.gdk
.color_parse(self
.defaults
["fgColor"]))
1893 self
.batteryFontCol
.set_text(self
.defaults
["fgColor"])
1894 self
.batteryPadX
.set_text(BATTERY_PADDING_Y
)
1895 self
.batteryPadY
.set_text(BATTERY_PADDING_Y
)
1896 self
.batteryBg
.set_active(0)
1898 def new(self
, action
=None):
1899 """Prepares a new config."""
1904 self
.filename
= None
1908 self
.generateConfig()
1909 self
.updateStatusBar("New Config File [*]")
1911 def openDef(self
, widget
=None):
1912 """Opens the default tint2 config."""
1913 self
.openFile(default
=True)
1915 def openFile(self
, widget
=None, default
=False):
1916 """Reads from a config file. If default=True, open the tint2 default config."""
1920 chooser
= gtk
.FileChooserDialog("Open Config File", self
, gtk
.FILE_CHOOSER_ACTION_OPEN
, (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
1921 chooser
.set_default_response(gtk
.RESPONSE_OK
)
1923 if self
.curDir
!= None:
1924 chooser
.set_current_folder(self
.curDir
)
1926 chooserFilter
= gtk
.FileFilter()
1927 chooserFilter
.set_name("All files")
1928 chooserFilter
.add_pattern("*")
1929 chooser
.add_filter(chooserFilter
)
1932 response
= chooser
.run()
1934 if response
== gtk
.RESPONSE_OK
:
1935 self
.filename
= chooser
.get_filename()
1936 self
.curDir
= os
.path
.dirname(self
.filename
)
1943 self
.filename
= os
.path
.expandvars("$HOME/.config/tint2/tint2rc")
1944 self
.curDir
= os
.path
.expandvars("$HOME/.config/tint2")
1946 self
.readTint2Config()
1947 self
.generateConfig()
1948 self
.updateStatusBar()
1950 def addBgDefs(self
, bgDefs
):
1951 """Add interface elements for a list of background style definitions. bgDefs
1952 should be a list containing dictionaries with the following keys: rounded,
1953 border_width, background_color, border_color"""
1957 for child
in self
.bgs
[-1].get_children():
1958 if child
.get_name() == "rounded":
1959 child
.set_text(d
["rounded"])
1960 elif child
.get_name() == "border":
1961 child
.set_text(d
["border_width"])
1962 elif child
.get_name() == "bgColEntry":
1963 child
.set_text(d
["background_color"].split(" ")[0].strip())
1965 elif child
.get_name() == "borderColEntry":
1966 child
.set_text(d
["border_color"].split(" ")[0].strip())
1968 elif child
.get_name() == "bgCol":
1969 list = d
["background_color"].split(" ")
1971 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1973 child
.set_alpha(65535)
1974 elif child
.get_name() == "borderCol":
1975 list = d
["border_color"].split(" ")
1977 child
.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
1979 child
.set_alpha(65535)
1981 newId
= len(self
.bgs
)
1983 self
.bgNotebook
.append_page(self
.bgs
[newId
-1], gtk
.Label("Background ID %d" % (newId
)))
1985 self
.bgNotebook
.show_all()
1987 self
.updateComboBoxes(newId
-1, "add")
1989 self
.bgNotebook
.set_current_page(newId
)
1991 def parseBgs(self
, string
):
1992 """Parses the background definitions from a string."""
1993 s
= string
.split("\n")
1997 bgKeys
= ["border_width", "background_color", "border_color"]
2001 data
= [token
.strip() for token
in line
.split("=")]
2003 if data
[0] == "rounded": # It may be considered bad practice to
2004 bgDefs
+= [{"rounded": data[1]}
] # find each style definition with an
2005 elif data
[0] in bgKeys
: # arbitrary value, but tint2 does the same.
2006 bgDefs
[cur
][data
[0]] = data
[1] # This means that any existing configs must
2007 else: # start with 'rounded'.
2008 newString
+= "%s\n" % line
2010 self
.addBgDefs(bgDefs
)
2014 def parseConfig(self
, string
):
2015 """Parses the contents of a config file."""
2016 for line
in string
.split("\n"):
2017 s
= line
.split("=") # Create a list with KEY and VALUE
2019 e
= s
[0].strip() # Strip whitespace from KEY
2021 if e
== "time1_format": # Set the VALUE of KEY
2022 self
.parseProp(self
.propUI
[e
], s
[1], True, "time1")
2023 elif e
== "time2_format":
2024 self
.parseProp(self
.propUI
[e
], s
[1], True, "time2")
2025 elif e
== "systray_padding":
2026 self
.parseProp(self
.propUI
[e
], s
[1], True, "tray")
2027 elif e
== "taskbar_active_background_id":
2028 self
.parseProp(self
.propUI
[e
], s
[1], True, "activeBg")
2030 if self
.propUI
.has_key(e
):
2031 self
.parseProp(self
.propUI
[e
], s
[1])
2033 def parseProp(self
, prop
, string
, special
=False, propType
=""):
2034 """Parses a variable definition from the conf file and updates the correct UI widget."""
2035 string
= string
.strip() # Remove whitespace from the VALUE
2036 eType
= type(prop
) # Get widget type
2038 if special
: # 'Special' properties are those which are optional
2039 if propType
== "time1":
2040 self
.clockCheckButton
.set_active(True)
2041 self
.clock1CheckButton
.set_active(True)
2042 elif propType
== "time2":
2043 self
.clockCheckButton
.set_active(True)
2044 self
.clock2CheckButton
.set_active(True)
2045 elif propType
== "tray":
2046 self
.trayShow
.set_active(True)
2047 elif propType
== "activeBg":
2048 self
.taskbarActiveBgEnable
.set_active(True)
2050 if eType
== gtk
.Entry
:
2051 prop
.set_text(string
)
2053 elif eType
== gtk
.ComboBox
:
2054 if string
in ["bottom", "top", "left", "right", "center", "single_desktop", "multi_desktop", "single_monitor",
2055 "none", "close", "shade", "iconify", "toggle", "toggle_iconify", "maximize_restore",
2056 "desktop_left", "desktop_right", "horizontal", "vertical", "ascending", "descending",
2057 "left2right", "right2left"]:
2058 if string
in ["bottom", "left", "single_desktop", "none", "horizontal", "ascending"]:
2060 elif string
in ["top", "right", "multi_desktop", "close", "vertical", "descending"]:
2062 elif string
in ["center", "single_monitor", "toggle", "left2right"]:
2064 elif string
in ["right2left"]:
2067 i
= ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore",
2068 "desktop_left", "desktop_right"].index(string
)
2072 prop
.set_active(int(string
))
2073 elif eType
== gtk
.CheckButton
:
2074 prop
.set_active(bool(int(string
)))
2075 elif eType
== gtk
.FontButton
:
2076 prop
.set_font_name(string
)
2077 elif eType
== gtk
.ColorButton
:
2078 prop
.set_alpha(int(int(string
) * 65535 / 100.0))
2079 elif eType
== tuple: # If a property has more than 1 value, for example the x and y co-ords
2080 s
= string
.split(" ") # of the padding properties, then just we use recursion to set the
2081 for i
in range(len(prop
)): # value of each associated widget.
2083 self
.parseProp(prop
[i
], "0")
2085 self
.parseProp(prop
[i
], s
[i
])
2087 def quit(self
, widget
, event
=None):
2088 """Asks if user would like to save file before quitting, then quits the program."""
2090 if self
.oneConfigFile
:
2091 response
= gtk
.RESPONSE_YES
2093 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
))
2094 dialog
.get_content_area().add(gtk
.Label("Save config before quitting?"))
2095 dialog
.get_content_area().set_size_request(300, 100)
2097 response
= dialog
.run()
2100 if response
== gtk
.RESPONSE_CANCEL
:
2101 return True # Return True to stop it quitting when we hit "Cancel"
2102 elif response
== gtk
.RESPONSE_NO
:
2104 elif response
== gtk
.RESPONSE_YES
:
2111 """Reads the tintwizard configuration file - NOT tint2 config files."""
2112 self
.defaults
= {"font": None, "bgColor": None, "fgColor": None, "borderColor": None, "bgCount": None, "dir": None}
2114 if self
.oneConfigFile
:
2115 # don't need tintwizard.conf
2118 pathName
= os
.path
.dirname(sys
.argv
[0])
2123 if not os
.path
.exists(pathName
+ "tintwizard.conf"):
2127 f
= open(pathName
+ "tintwizard.conf", "r")
2133 if self
.defaults
.has_key(l
[0].strip()):
2134 self
.defaults
[l
[0].strip()] = l
[1].strip()
2136 def readTint2Config(self
):
2137 """Reads in from a config file."""
2138 f
= open(self
.filename
, "r")
2143 if (line
[0] != "#") and (len(line
) > 2):
2148 # Deselect the optional stuff, and we'll re-check them if the config has them enabled
2149 self
.clockCheckButton
.set_active(False)
2150 self
.clock1CheckButton
.set_active(False)
2151 self
.clock2CheckButton
.set_active(False)
2152 self
.trayShow
.set_active(False)
2153 self
.taskbarActiveBgEnable
.set_active(False)
2155 # Remove all background styles so we can create new ones as we read them
2156 for i
in range(len(self
.bgs
)):
2157 self
.delBgClick(None, False)
2159 # As we parse background definitions, we build a new string
2160 # without the background related stuff. This means we don't
2161 # have to read through background defs AGAIN when parsing
2163 noBgDefs
= self
.parseBgs(string
)
2165 self
.parseConfig(noBgDefs
)
2167 def save(self
, widget
=None, event
=None):
2168 """Saves the generated config file."""
2170 # This function returns the boolean status of whether or not the
2171 # file saved, so that the apply() function knows if it should
2172 # kill the tint2 process and apply the new config.
2174 # If no file has been selected, force the user to "Save As..."
2175 if self
.filename
== None:
2176 return self
.saveAs()
2178 self
.generateConfig()
2183 def saveAs(self
, widget
=None, event
=None):
2184 """Prompts the user to select a file and then saves the generated config file."""
2185 self
.generateConfig()
2187 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
))
2188 chooser
.set_default_response(gtk
.RESPONSE_OK
)
2190 if self
.curDir
!= None:
2191 chooser
.set_current_folder(self
.curDir
)
2193 chooserFilter
= gtk
.FileFilter()
2194 chooserFilter
.set_name("All files")
2195 chooserFilter
.add_pattern("*")
2196 chooser
.add_filter(chooserFilter
)
2199 response
= chooser
.run()
2201 if response
== gtk
.RESPONSE_OK
:
2202 self
.filename
= chooser
.get_filename()
2204 if os
.path
.exists(self
.filename
):
2205 overwrite
= confirmDialog(self
, "This file already exists. Overwrite this file?")
2207 if overwrite
== gtk
.RESPONSE_YES
:
2212 self
.filename
= None
2220 self
.filename
= None
2224 def saveAsDef(self
, widget
=None, event
=None):
2225 """Saves the config as the default tint2 config."""
2226 if confirmDialog(self
, "Overwrite current tint2 default config?") == gtk
.RESPONSE_YES
:
2227 self
.filename
= os
.path
.expandvars("${HOME}") + "/.config/tint2/tint2rc"
2228 self
.curDir
= os
.path
.expandvars("${HOME}") + "/.config/tint2"
2230 # If, for whatever reason, tint2 has no default config - create one.
2231 if not os
.path
.isfile(self
.filename
):
2232 f
= open(self
.filename
, "w")
2233 f
.write("# tint2rc")
2236 self
.generateConfig()
2241 def savePrompt(self
):
2242 """Prompt the user to save before creating a new file."""
2243 if confirmDialog(self
, "Save current config?") == gtk
.RESPONSE_YES
:
2246 def switchPage(self
, notebook
, page
, page_num
):
2247 """Handles notebook page switch events."""
2249 # If user selects the 'View Config' tab, update the textarea within this tab.
2250 if notebook
.get_tab_label_text(notebook
.get_nth_page(page_num
)) == "View Config":
2251 self
.generateConfig()
2253 def updateComboBoxes(self
, i
, action
="add"):
2254 """Updates the contents of a combo box when a background style has been added/removed."""
2255 cbs
= [self
.batteryBg
, self
.clockBg
, self
.taskbarBg
, self
.taskbarActiveBg
, self
.trayBg
, self
.taskActiveBg
, self
.taskBg
, self
.panelBg
, self
.tooltipBg
]
2259 cb
.append_text(str(i
+1))
2262 if cb
.get_active() == i
: # If background is selected, set to a different value
2267 def updateStatusBar(self
, message
="", change
=False):
2268 """Updates the message on the statusbar. A message can be provided,
2269 and if change is set to True (i.e. something has been modified) then
2270 an appropriate symbol [*] is shown beside filename."""
2271 contextID
= self
.statusBar
.get_context_id("")
2273 self
.statusBar
.pop(contextID
)
2276 message
= "%s %s" % (self
.filename
or "New Config File", "[*]" if change
else "")
2278 self
.statusBar
.push(contextID
, message
)
2280 def writeConf(self
):
2281 """Writes the tintwizard configuration file."""
2282 confStr
= "#Start\n[defaults]\n"
2284 for key
in self
.defaults
:
2285 confStr
+= "%s = %s\n" % (key
, str(self
.defaults
[key
]))
2289 pathName
= os
.path
.dirname(sys
.argv
[0])
2292 f
= open("tintwizard.conf", "w")
2294 f
= open(pathName
+"/tintwizard.conf", "w")
2300 def writeFile(self
):
2301 """Writes the contents of the config text buffer to file."""
2303 f
= open(self
.filename
, "w")
2305 f
.write(self
.configBuf
.get_text(self
.configBuf
.get_start_iter(), self
.configBuf
.get_end_iter()))
2311 self
.curDir
= os
.path
.dirname(self
.filename
)
2313 self
.updateStatusBar()
2315 errorDialog(self
, "Could not save file")
2317 # General use functions
2318 def confirmDialog(parent
, message
):
2319 """Creates a confirmation dialog and returns the response."""
2320 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
, message
)
2322 response
= dialog
.run()
2326 def errorDialog(parent
=None, message
="An error has occured!"):
2327 """Creates an error dialog."""
2328 dialog
= gtk
.MessageDialog(parent
, gtk
.DIALOG_MODAL
, gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
2334 """Convert integer n in range [0, 15] to hex."""
2336 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"][n
]
2340 def rgbToHex(r
, g
, b
):
2341 """Constructs a 6 digit hex representation of color (r, g, b)."""
2342 r2
= trunc(r
/ 65535.0 * 255)
2343 g2
= trunc(g
/ 65535.0 * 255)
2344 b2
= trunc(b
/ 65535.0 * 255)
2346 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))
2349 """Truncate a floating point number, rounding up or down appropriately."""
2350 c
= math
.fabs(math
.ceil(n
) - n
)
2351 f
= math
.fabs(math
.floor(n
) - n
)
2354 return int(math
.ceil(n
))
2356 return int(math
.floor(n
))
2358 # Direct execution of application
2359 if __name__
== "__main__":
2360 tw
= TintWizardGUI()