mirror of
https://github.com/tromey/gdb-gui.git
synced 2025-07-21 13:01:16 +02:00
add "set gui font"
This commit is contained in:
@@ -18,9 +18,11 @@
|
||||
import gdb
|
||||
import gui.toplevel
|
||||
import gui.startup
|
||||
from gi.repository import Gtk, Pango
|
||||
import functools
|
||||
|
||||
from gi.repository import Gtk, Pango
|
||||
from gui.startup import in_gtk_thread
|
||||
|
||||
default_log_window = None
|
||||
|
||||
class LogWindow(gui.toplevel.Toplevel):
|
||||
@@ -36,12 +38,16 @@ class LogWindow(gui.toplevel.Toplevel):
|
||||
|
||||
self.window = builder.get_object('logwindow')
|
||||
self.view = builder.get_object('textview')
|
||||
self.view.modify_font(Pango.FontDescription('monospace'))
|
||||
self.view.modify_font(gui.params.font_manager.get_font())
|
||||
self.buffer = builder.get_object('buffer')
|
||||
|
||||
self.window.set_title('GDB Log @%d' % self.number)
|
||||
self.window.show()
|
||||
|
||||
@in_gtk_thread
|
||||
def set_font(self, font):
|
||||
self.view.modify_font(Pango.FontDescription(font_name))
|
||||
|
||||
def deleted(self, *args):
|
||||
if default_log_window == self:
|
||||
default_log_window = None
|
||||
@@ -52,3 +58,7 @@ class LogWindow(gui.toplevel.Toplevel):
|
||||
|
||||
def append(self, text):
|
||||
gui.startup.send_to_gtk(functools.partial(self._append, text))
|
||||
|
||||
@in_gtk_thread
|
||||
def set_font(self, pango_font):
|
||||
self.view.modify_font(pango_font)
|
||||
|
@@ -16,10 +16,12 @@
|
||||
# Parameters
|
||||
|
||||
import gdb
|
||||
from gi.repository import GtkSource
|
||||
import gui.startup
|
||||
from gui.startup import in_gdb_thread, in_gtk_thread
|
||||
import gui.storage
|
||||
import gui.toplevel
|
||||
|
||||
from gui.startup import in_gdb_thread, in_gtk_thread
|
||||
from gi.repository import GtkSource, Pango
|
||||
|
||||
class _SetBase(gdb.Command):
|
||||
def __init__(self):
|
||||
@@ -62,6 +64,34 @@ class _Theme(gdb.Parameter):
|
||||
self.buffer_manager.change_theme()
|
||||
return ""
|
||||
|
||||
class _Font(gdb.Parameter):
|
||||
def __init__(self):
|
||||
self.manager = GtkSource.StyleSchemeManager.get_default()
|
||||
self.storage = gui.storage.storage_manager
|
||||
super(_Font, self).__init__('gui font', gdb.COMMAND_NONE,
|
||||
gdb.PARAM_STRING)
|
||||
val = self.storage.get('font')
|
||||
if val is not None:
|
||||
self.value = val
|
||||
else:
|
||||
self.value = 'monospace'
|
||||
|
||||
@in_gtk_thread
|
||||
def get_font(self):
|
||||
# Sorta racy
|
||||
return Pango.FontDescription(self.value)
|
||||
|
||||
@in_gdb_thread
|
||||
def get_show_string(self, pvalue):
|
||||
return "The current font is: " + self.value
|
||||
|
||||
@in_gdb_thread
|
||||
def get_set_string(self):
|
||||
gui.toplevel.state.set_font(self.value)
|
||||
self.storage.set('font', self.value)
|
||||
return ""
|
||||
|
||||
_SetBase()
|
||||
_ShowBase()
|
||||
source_theme = _Theme()
|
||||
font_manager = _Font()
|
||||
|
@@ -220,9 +220,7 @@ class SourceWindow(gui.updatewindow.UpdateWindow):
|
||||
for name in BUTTON_NAMES:
|
||||
self.buttons[name] = builder.get_object(name)
|
||||
|
||||
font_desc = Pango.FontDescription('monospace')
|
||||
if font_desc:
|
||||
self.view.modify_font(font_desc)
|
||||
self.view.modify_font(gui.params.font_manager.get_font())
|
||||
|
||||
attrs = GtkSource.MarkAttributes()
|
||||
# FIXME: really we want a little green dot...
|
||||
@@ -289,3 +287,7 @@ class SourceWindow(gui.updatewindow.UpdateWindow):
|
||||
buffer_manager.release_buffer(old_buffer)
|
||||
GObject.idle_add(self._do_scroll, buff, srcline - 1)
|
||||
# self.view.scroll_to_iter(buff.get_iter_at_line(srcline), 0.0)
|
||||
|
||||
@in_gtk_thread
|
||||
def set_font(self, pango_font):
|
||||
self.view.modify_font(pango_font)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2013 Tom Tromey <tom@tromey.com>
|
||||
# Copyright (C) 2013, 2015 Tom Tromey <tom@tromey.com>
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -18,6 +18,8 @@
|
||||
import gdb
|
||||
import gui.startup
|
||||
import threading
|
||||
from gi.repository import Pango
|
||||
from gui.startup import in_gdb_thread, in_gtk_thread
|
||||
|
||||
class _ToplevelState(object):
|
||||
def __init__(self):
|
||||
@@ -57,6 +59,17 @@ class _ToplevelState(object):
|
||||
print ' %3d %s' % (window.number,
|
||||
window.window.get_title())
|
||||
|
||||
@in_gtk_thread
|
||||
def _do_set_font(self, font_name):
|
||||
pango_font = Pango.FontDescription(font_name)
|
||||
with self.toplevel_lock:
|
||||
for num in self.toplevels:
|
||||
self.toplevels[num].set_font(pango_font)
|
||||
|
||||
@in_gdb_thread
|
||||
def set_font(self, font_name):
|
||||
gui.startup.send_to_gtk(lambda: self._do_set_font(font_name))
|
||||
|
||||
state = _ToplevelState()
|
||||
|
||||
class Toplevel(object):
|
||||
@@ -72,3 +85,9 @@ class Toplevel(object):
|
||||
|
||||
def valid(self):
|
||||
return self.window is not None
|
||||
|
||||
@in_gtk_thread
|
||||
def set_font(self, pango_font):
|
||||
# Subclasses can override this to be notified when the user
|
||||
# changes the font.
|
||||
pass
|
||||
|
Reference in New Issue
Block a user