add reset and factory buttons to CPB

parent 9c7520dd
......@@ -20,6 +20,8 @@ Overview of changes in v9.1 "Dial T for TNT"
- use monospaced font in the input fields
- add scrollbars to the Custom Prompt Builder (prevents window from getting
immensively huge when inserting large prompts like Equinox)
- add "Reset" button: reset to last saved user configuration
- add "Factory" button: reset to vendor or factory configuration
* show what category the user is currently in, in the header
* added missing revert-to-default icons for PWD Length Spinbutton
......
......@@ -5924,6 +5924,92 @@ vimdoc.sourceforge.net/htmldoc/options.html</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cpb_reset">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<child>
<object class="GtkBox" id="cpb_reset.box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="cpb_reset.icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">gtk-revert-to-saved</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="cpb_reset.label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Revert</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cpb_factory">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<child>
<object class="GtkBox" id="cpb_factory.box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="cpb_factory.icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">gtk-delete</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="cpb_factory.label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Factory</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
......
......@@ -17,7 +17,7 @@ lang.install(names=['_'])
import args
args.CmdArgs()
print(_("\nBashStyle-NG version %s starting" % os.getenv('BSNG_UI_VERSION')))
print(_("\nBashStyle-NG Version %s starting" % os.getenv('BSNG_UI_VERSION')))
MODULES = [ 'os.path', 'sys', 'string', 'shutil', 'optparse', 'subprocess',
'undobuffer', 'lockfile', 'config', 'widgethandler',
......@@ -53,9 +53,6 @@ class BashStyleNG(object):
config.LoadConfig()
config.CheckConfig()
######################## cd into $HOME #############################################
os.chdir(os.getenv("HOME"))
######################## load translations & widgethandler #########################
gtkbuilder = widgethandler.gtkbuilder
WidgetHandler = widgethandler.WidgetHandler(config.cfo, config.udc, config.fdc)
......@@ -273,7 +270,7 @@ class BashStyleNG(object):
######################## Custom Prompt Builder #####################################
WidgetHandler.InitWidget("use_custom_prompt", "Custom", "use_custom_prompt", "bool", None)
promptbuilder.PromptBuilder(config.cfo)
promptbuilder.PromptBuilder(config.cfo, config.udc, config.fdc)
######################## Load the Main-Window ######################################
self.bashstyle = gtkbuilder.get_object("bashstyle")
......
......@@ -31,7 +31,7 @@ if FAILED:
class PromptBuilder(object):
def __init__(self, config):
def __init__(self, config, userconfig, factoryconfig):
######################## load translations & widgethandler #########################
gtkbuilder = widgethandler.gtkbuilder
......@@ -89,28 +89,44 @@ class PromptBuilder(object):
self.empty = gtkbuilder.get_object("cpb_empty")
self.undo = gtkbuilder.get_object("cpb_undo")
self.redo = gtkbuilder.get_object("cpb_redo")
self.reset = gtkbuilder.get_object("cpb_reset")
self.factory = gtkbuilder.get_object("cpb_factory")
def do_empty(widget, data=None):
def do_empty(widget):
if self.active_buffer == "P_C":
self.prompt_command_buffer.set_text("")
elif self.active_buffer == "PS1":
self.custom_prompt_buffer.set_text("")
def do_undo(widget, data=None):
def do_undo(widget):
if self.active_buffer == "P_C":
self.prompt_command_buffer.undo()
elif self.active_buffer == "PS1":
self.custom_prompt_buffer.undo()
def do_redo(widget, data=None):
def do_redo(widget):
if self.active_buffer == "P_C":
self.prompt_command_buffer.redo()
elif self.active_buffer == "PS1":
self.custom_prompt_buffer.redo()
def do_reset(widget):
if self.active_buffer == "P_C":
self.prompt_command_buffer.set_text("%s" % userconfig["Custom"]["command"])
elif self.active_buffer == "PS1":
self.custom_prompt_buffer.set_text("%s" % userconfig["Custom"]["prompt"])
def do_revert(widget):
if self.active_buffer == "P_C":
self.prompt_command_buffer.set_text("%s" % factoryconfig["Custom"]["command"])
elif self.active_buffer == "PS1":
self.custom_prompt_buffer.set_text("%s" % factoryconfig["Custom"]["prompt"])
self.empty.connect("clicked", do_empty)
self.undo.connect("clicked", do_undo)
self.redo.connect("clicked", do_redo)
self.reset.connect("clicked", do_reset)
self.factory.connect("clicked", do_revert)
######################## Toolbox ###################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment