Skip to content

Commit

Permalink
[developer] Control fontsize of hex diff/dump display - #1681
Browse files Browse the repository at this point in the history
Add user specification of the font size to use for the hex diff/dump
display, without affecting any other Chirp displays.
This is done with a new chirp.config integer property diff_fontsize
in a new [developer] section. The default is unchanged at 11.
Values between 4 and 144 are accepted; others result in the default.

Add a new file README.developers at the top level of the repository
to document chirp.config [developer] section properties.

#1681
  • Loading branch information
Dan Drogichen committed Jun 7, 2014
1 parent 27eeda6 commit f12aadb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
31 changes: 31 additions & 0 deletions README.developers
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
This file describes some features in the Chirp Developer's Functions
that allow some customization of their behavior, but are only
accessible through editing the chirp.config file before starting
Chirp, and are not accessible through the GUI.

The Developer Functions are enabled in the GUI by checking the box
in the "Help" tab. They enable the Image Browser tab in the left
sidebar, and several tools under the View -> Developer tab.

These directives are similar to other chirp.config entries in syntax.
They reside in the [developer] section in chirp.config.
This section, and all the directives, are not required to be present;
all the options have defaults.

Here is an example [developer] section listing all the directives,
followed by an explanation of each directive:

===================================
[developer]
diff_fontsize = 16

===================================

diff_fontize = <integer>
This specifies the fontsize used in the hex dump/diff display which is
invoked by selecting View -> Developer -> Diff tabs, and then in the
"Diff Radios" popup, selecting < 0 for either or both memory locations.

The default size is 11. Values less than 4, greater than 144, or not
recognized as an integer will result in a log message and the default
size will be used.
14 changes: 12 additions & 2 deletions chirpui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import traceback

from chirp import errors
from chirpui import reporting
from chirpui import reporting, config

CONF = config.get()

class Editor(gobject.GObject):
__gsignals__ = {
Expand Down Expand Up @@ -391,6 +393,14 @@ def show_diff_blob(title, result):
tag.set_property("weight", pango.WEIGHT_BOLD)
tags.add(tag)

try:
fontsize = CONF.get_int("diff_fontsize", "developer")
except Exception:
fontsize = 11
if fontsize < 4 or fontsize > 144:
print "Unsupported diff_fontsize %i. Using 11." % fontsize
fontsize = 11

lines = result.split(os.linesep)
for line in lines:
if line.startswith("-"):
Expand All @@ -401,7 +411,7 @@ def show_diff_blob(title, result):
tags = ()
b.insert_with_tags_by_name(b.get_end_iter(), line + os.linesep, *tags)
v = gtk.TextView(b)
fontdesc = pango.FontDescription("Courier 11")
fontdesc = pango.FontDescription("Courier %i" % fontsize)
v.modify_font(fontdesc)
v.set_editable(False)
v.show()
Expand Down

0 comments on commit f12aadb

Please sign in to comment.