| 47 | | GCONF_KEYS = GCONF_PATH + 'keybindings/' |
| 48 | | GHOTKEYS = ((GCONF_KEYS+'global/show_hide', _('Toggle terminal visibility')),) |
| 49 | | LHOTKEYS = ((GCONF_KEYS+'local/new_tab', _('New tab'),), |
| 50 | | (GCONF_KEYS+'local/close_tab', _('Close tab')), |
| 51 | | (GCONF_KEYS+'local/previous_tab', _('Go to previous tab')), |
| 52 | | (GCONF_KEYS+'local/next_tab', _('Go to next tab'),), |
| 53 | | (GCONF_KEYS+'local/rename_tab', _('Rename current tab'),), |
| 54 | | (GCONF_KEYS+'local/clipboard_copy', _('Copy text to clipboard'),), |
| 55 | | (GCONF_KEYS+'local/clipboard_paste', _('Paste text from clipboard'),), |
| 56 | | (GCONF_KEYS+'local/toggle_fullscreen', _('Toggle Fullscreen'),), |
| | 48 | HKEYS = lambda x:GCONF_PATH + '/keybindings' + x |
| | 49 | GHOTKEYS = ((HKEYS('/global/show_hide'), _('Toggle terminal visibility')),) |
| | 50 | LHOTKEYS = ((HKEYS('/local/new_tab'), _('New tab'),), |
| | 51 | (HKEYS('/local/close_tab'), _('Close tab')), |
| | 52 | (HKEYS('/local/previous_tab'), _('Go to previous tab')), |
| | 53 | (HKEYS('/local/next_tab'), _('Go to next tab'),), |
| | 54 | (HKEYS('/local/rename_tab'), _('Rename current tab'),), |
| | 55 | (HKEYS('/local/clipboard_copy'), _('Copy text to clipboard'),), |
| | 56 | (HKEYS('/local/clipboard_paste'), _('Paste text from clipboard'),), |
| | 57 | (HKEYS('/local/toggle_fullscreen'), _('Toggle Fullscreen'),), |
| 59 | | class KeyEntry(object): |
| 60 | | def __init__(self, keycode, mask): |
| 61 | | self.keycode = keycode |
| 62 | | self.mask = mask |
| 63 | | |
| 64 | | def __repr__(self): |
| 65 | | return u'KeyEntry(%d, %d)' % ( |
| 66 | | self.keycode, self.mask) |
| 67 | | |
| 68 | | def __eq__(self, rval): |
| 69 | | return self.keycode == rval.keycode and \ |
| 70 | | self.mask == rval.mask |
| | 60 | class PrefsCallbacks(object): |
| | 61 | """Holds callbacks that will be used in the PrefsDialg class. |
| | 62 | """ |
| | 63 | |
| | 64 | def __init__(self): |
| | 65 | self.client = gconf.client_get_default() |
| | 66 | |
| | 67 | # general tab |
| | 68 | |
| | 69 | def on_default_shell_changed(self, combo): |
| | 70 | """Changes the activity of default_shell in gconf |
| | 71 | """ |
| | 72 | citer = combo.get_active_iter() |
| | 73 | if not citer: |
| | 74 | return |
| | 75 | shell = combo.get_model().get_value(citer, 0) |
| | 76 | self.client.set_string(KEY('/general/default_shell'), shell) |
| | 77 | |
| | 78 | def on_use_login_shell_toggled(self, chk): |
| | 79 | """Changes the activity of use_login_shell in gconf |
| | 80 | """ |
| | 81 | self.client.set_bool(KEY('/general/use_login_shell'), chk.get_active()) |
| | 82 | |
| | 83 | def on_use_trayicon_toggled(self, chk): |
| | 84 | """Changes the activity of use_trayicon in gconf |
| | 85 | """ |
| | 86 | self.client.set_bool(KEY('/general/use_trayicon'), chk.get_active()) |
| | 87 | |
| | 88 | def on_use_popup_toggled(self, chk): |
| | 89 | """Changes the activity of use_popup in gconf |
| | 90 | """ |
| | 91 | self.client.set_bool(KEY('/general/use_popup'), chk.get_active()) |
| | 92 | |
| | 93 | def on_window_ontop_toggled(self, chk): |
| | 94 | """Changes the activity of window_ontop in gconf |
| | 95 | """ |
| | 96 | self.client.set_bool(KEY('/general/window_ontop'), chk.get_active()) |
| | 97 | |
| | 98 | def on_window_losefocus_toggled(self, chk): |
| | 99 | """Changes the activity of window_losefocus in gconf |
| | 100 | """ |
| | 101 | self.client.set_bool(KEY('/general/window_losefocus'), chk.get_active()) |
| | 102 | |
| | 103 | def on_window_tabbar_toggled(self, chk): |
| | 104 | """Changes the activity of window_tabbar in gconf |
| | 105 | """ |
| | 106 | self.client.set_bool(KEY('/general/window_tabbar'), chk.get_active()) |
| | 107 | |
| | 108 | def on_window_size_value_changed(self, hscale): |
| | 109 | """Changes the value of window_size in gconf |
| | 110 | """ |
| | 111 | val = hscale.get_value() |
| | 112 | self.client.set_int(KEY('/general/window_size'), int(val)) |
| | 113 | |
| | 114 | # scrolling tab |
| | 115 | |
| | 116 | def on_use_scrollbar_toggled(self, chk): |
| | 117 | """Changes the activity of use_scrollbar in gconf |
| | 118 | """ |
| | 119 | self.client.set_bool(KEY('/general/use_scrollbar'), chk.get_active()) |
| | 120 | |
| | 121 | def on_history_size_value_changed(self, spin): |
| | 122 | """Changes the value of history_size in gconf |
| | 123 | """ |
| | 124 | val = int(spin.get_value()) |
| | 125 | self.client.set_int(KEY('/general/history_size'), val) |
| | 126 | |
| | 127 | def on_scroll_output_toggled(self, chk): |
| | 128 | """Changes the activity of scroll_output in gconf |
| | 129 | """ |
| | 130 | self.client.set_bool(KEY('/general/scroll_output'), chk.get_active()) |
| | 131 | |
| | 132 | def on_scroll_keystroke_toggled(self, chk): |
| | 133 | """Changes the activity of scroll_keystroke in gconf |
| | 134 | """ |
| | 135 | self.client.set_bool(KEY('/general/scroll_keystroke'), chk.get_active()) |
| | 136 | |
| | 137 | # appearance tab |
| | 138 | |
| | 139 | def on_use_default_font_toggled(self, chk): |
| | 140 | """Changes the activity of use_default_font in gconf |
| | 141 | """ |
| | 142 | self.client.set_bool(KEY('/general/use_default_font'), chk.get_active()) |
| | 143 | |
| | 144 | def on_font_style_font_set(self, fbtn): |
| | 145 | """Changes the value of font_style in gconf |
| | 146 | """ |
| | 147 | self.client.set_string(KEY('/style/font/style'), fbtn.get_font_name()) |
| | 148 | |
| | 149 | def on_font_color_color_set(self, btn): |
| | 150 | """Changes the value of font_color in gconf |
| | 151 | """ |
| | 152 | color = hexify_color(btn.get_color()) |
| | 153 | self.client.set_string(KEY('/style/font/color'), color) |
| | 154 | |
| | 155 | def on_background_color_color_set(self, btn): |
| | 156 | """Changes the value of background_color in gconf |
| | 157 | """ |
| | 158 | color = hexify_color(btn.get_color()) |
| | 159 | self.client.set_string(KEY('/style/background/color'), color) |
| | 160 | |
| | 161 | def on_background_image_changed(self, btn): |
| | 162 | """Changes the value of background_image in gconf |
| | 163 | """ |
| | 164 | filename = btn.get_filename() |
| | 165 | if filename: |
| | 166 | self.client.set_string(KEY('/style/background/image'), filename) |
| | 167 | |
| | 168 | def on_opacity_value_changed(self, hscale): |
| | 169 | """Changes the value of background_opacity in gconf |
| | 170 | """ |
| | 171 | value = hscale.get_value() |
| | 172 | self.client.set_int(KEY('/style/background/opacity'), int(value)) |
| | 173 | |
| 175 | | val = self.client.get_int(GCONF_PATH+'general/history_size') |
| 176 | | self.get_widget('historysize-spinbutton').set_value(val) |
| 177 | | |
| 178 | | # scrollbar |
| 179 | | ac = self.client.get_bool(GCONF_PATH + 'general/use_scrollbar') |
| 180 | | self.get_widget('show-scrollbar-checkbutton').set_active(ac) |
| 181 | | |
| 182 | | # Tray icon |
| 183 | | ac = self.client.get_bool(GCONF_PATH + 'general/use_trayicon') |
| 184 | | self.get_widget('show-trayicon-checkbutton').set_active(ac) |
| 185 | | |
| 186 | | # hide on lost focus |
| 187 | | ac = self.client.get_bool(GCONF_PATH + 'general/hide_on_lost_focus') |
| 188 | | self.get_widget('hide-onlostfocus-checkbutton').set_active(ac) |
| 189 | | |
| 190 | | # animate flag |
| 191 | | #ac = self.client.get_bool(GCONF_PATH + 'general/window_animate') |
| 192 | | #self.get_widget('animate-checkbutton').set_active(ac) |
| 193 | | |
| 194 | | # on top flag |
| 195 | | ac = self.client.get_bool(GCONF_PATH + 'general/window_ontop') |
| 196 | | self.get_widget('ontop-checkbutton').set_active(ac) |
| 197 | | |
| 198 | | # winsize |
| 199 | | val = float(self.client.get_int(GCONF_PATH + 'general/window_size')) |
| 200 | | self.get_widget('winsize-hscale').set_value(val) |
| | 320 | value = self.client.get_int(KEY('/general/history_size')) |
| | 321 | self.get_widget('history_size').set_value(value) |
| | 322 | |
| | 323 | # scroll output |
| | 324 | value = self.client.get_bool(KEY('/general/scroll_output')) |
| | 325 | self.get_widget('scroll_output').set_active(value) |
| | 326 | |
| | 327 | # scroll keystroke |
| | 328 | value = self.client.get_bool(KEY('/general/scroll_keystroke')) |
| | 329 | self.get_widget('scroll_keystroke').set_active(value) |
| | 330 | |
| | 331 | # default font |
| | 332 | value = self.client.get_bool(KEY('/style/use_default_font')) |
| | 333 | self.get_widget('use_default_font').set_active(value) |
| 295 | | |
| 296 | | # -- callbacks -- |
| 297 | | |
| 298 | | def on_historysize_spinbutton_value_changed(self, spin): |
| 299 | | val = int(spin.get_value()) |
| 300 | | self.client.set_int(GCONF_PATH + 'general/history_size', val) |
| 301 | | |
| 302 | | def on_show_scrollbar_checkbutton_toggled(self, chk): |
| 303 | | fbool = chk.get_active() |
| 304 | | self.client.set_bool(GCONF_PATH + 'general/use_scrollbar', fbool) |
| 305 | | self.guake.toggle_scrollbars() |
| 306 | | |
| 307 | | def on_show_trayicon_checkbutton_toggled(self, chk): |
| 308 | | fbool = chk.get_active() |
| 309 | | self.client.set_bool(GCONF_PATH + 'general/use_trayicon', fbool) |
| 310 | | self.guake.toggle_trayicon() |
| 311 | | |
| 312 | | def on_show_popup_checkbutton_toggled(self, chk): |
| 313 | | fbool = chk.get_active() |
| 314 | | self.client.set_bool(GCONF_PATH + 'general/use_popup', fbool) |
| 315 | | |
| 316 | | def on_chk_lostfocus_toggled(self, chk): |
| 317 | | fbool = chk.get_active() |
| 318 | | self.client.set_bool(GCONF_PATH + 'general/hide_on_lost_focus', fbool) |
| 319 | | |
| 320 | | def on_shells_combobox_changed(self, combo): |
| 321 | | citer = combo.get_active_iter() |
| 322 | | if not citer: |
| 323 | | return |
| 324 | | shell = combo.get_model().get_value(citer, 0) |
| 325 | | self.client.set_string(GCONF_PATH + 'general/default_shell', shell) |
| 326 | | |
| 327 | | def on_animate_checkbutton_toggled(self, bnt): |
| 328 | | self.client.set_bool(GCONF_PATH + 'general/window_animate', |
| 329 | | bnt.get_active()) |
| 330 | | |
| 331 | | def on_ontop_checkbutton_toggled(self, bnt): |
| 332 | | self.client.set_bool(GCONF_PATH + 'general/window_ontop', |
| 333 | | bnt.get_active()) |
| 334 | | self.guake.toggle_ontop() |
| 335 | | |
| 336 | | def on_winsize_hscale_value_changed(self, hscale): |
| 337 | | val = hscale.get_value() |
| 338 | | self.client.set_int(GCONF_PATH + 'general/window_size', int(val)) |
| 339 | | self.guake.resize(*self.guake.get_final_window_size()) |
| 340 | | |
| 341 | | def on_fontbutton_font_set(self, fb): |
| 342 | | self.client.set_string(GCONF_PATH + 'style/font/style', |
| 343 | | fb.get_font_name()) |
| 344 | | self.guake.set_font() |
| 345 | | |
| 346 | | def on_font_colorbutton_color_set(self, bnt): |
| 347 | | c = hexify_color(bnt.get_color()) |
| 348 | | self.client.set_string(GCONF_PATH + 'style/font/color', c) |
| 349 | | self.guake.set_fgcolor() |
| 350 | | |
| 351 | | def on_bg_colorbutton_color_set(self, bnt): |
| 352 | | c = hexify_color(bnt.get_color()) |
| 353 | | self.client.set_string(GCONF_PATH + 'style/background/color', c) |
| 354 | | self.guake.set_bgcolor() |
| 355 | | |
| 356 | | def on_bgimage_filechooserbutton_selection_changed(self, bnt): |
| 357 | | f = bnt.get_filename() |
| 358 | | if f: |
| 359 | | self.client.set_string(GCONF_PATH + 'style/background/image', f) |
| 360 | | self.guake.set_bgimage() |
| 361 | | |
| 362 | | def on_chk_bg_transparent_toggled(self, togglebutton): |
| 363 | | value = togglebutton.get_active() |
| 364 | | self.client.set_bool(GCONF_PATH + 'general/use_bgimage', not value) |
| 365 | | self.guake.set_bgimage() |
| 366 | | |
| 367 | | def on_transparency_hscale_value_changed(self, hscale): |
| 368 | | val = hscale.get_value() |
| 369 | | self.client.set_int(GCONF_PATH + 'style/background/transparency', |
| 370 | | int(val)) |
| 371 | | self.guake.set_alpha() |
| | 426 | |
| | 427 | # ----------------------------------------------------------------------- |