#!/usr/bin/env python
from rqt_gui_py.plugin import Plugin

from python_qt_binding.QtCore import Qt
from python_qt_binding.QtGui import QInputDialog

from rqt_launchtree.launchtree_widget import LaunchtreeWidget


class LaunchtreePlugin(Plugin):

    def __init__(self, context):
        super(LaunchtreePlugin, self).__init__(context)

        self._widget = LaunchtreeWidget(context)
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))
        context.add_widget(self._widget)

    def shutdown_plugin(self):
        self._widget.shutdown()

    def save_settings(self, plugin_settings, instance_settings):
        instance_settings.set_value('editor', self._widget.editor)

    def restore_settings(self, plugin_settings, instance_settings):
        self._widget.editor = instance_settings.value('editor', 'gedit')

    def trigger_configuration(self):
        (text, ok) = QInputDialog.getText(self._widget,
            'Settings for %s' % self._widget.windowTitle(),
            'Command to edit launch files (vim, gedit, ...), can accept args:',
            text = self._widget.editor
        )
        if ok:
            self._widget.editor = text
@@ -15,16 +15,29 @@
  python%0A
+import rospy%0A
 from rqt
@@ -253,16 +253,95 @@
 ugin):%0A%0A
+    _SETTING_LASTPKG = 'last_pkg'%0A    _SETTING_LASTLAUNCHFILE = 'last_launch'%0A%0A
     def 
@@ -899,148 +899,695 @@
 or)%0A
-%0A    def restore_settings(self, plugin_settings, instance_settings):%0A        self._widget.editor = instance_settings.value('editor', 'gedit'
+        _curr_index = self._widget.package_select.currentIndex()%0A        rospy.logdebug('save_settings) currentIndex=%7B%7D'.format(_curr_index))%0A        instance_settings.set_value(self._SETTING_LASTPKG, _curr_index)%0A        instance_settings.set_value(self._SETTING_LASTLAUNCHFILE, self._widget.launchfile_select.currentIndex())%0A%0A    def restore_settings(self, plugin_settings, instance_settings):%0A        self._widget.editor = instance_settings.value('editor', 'gedit')%0A        self._widget.package_select.setCurrentIndex(int(instance_settings.value(self._SETTING_LASTPKG)))%0A        self._widget.launchfile_select.setCurrentIndex(int(instance_settings.value(self._SETTING_LASTLAUNCHFILE))
 )%0A%0A 

Save and restore last pkg and launch file (address #4).