Example #1
0
 def launch_new_config_dialog(self, root_directory):
     """Launch a dialog allowing naming of a new configuration."""
     existing_apps = os.listdir(root_directory)
     checker_function = lambda t: t not in existing_apps
     label = rose.config_editor.DIALOG_LABEL_CONFIG_CHOOSE_NAME
     ok_tip_text = rose.config_editor.TIP_CONFIG_CHOOSE_NAME
     err_tip_text = rose.config_editor.TIP_CONFIG_CHOOSE_NAME_ERROR
     dialog, container, name_entry = rose.gtk.dialog.get_naming_dialog(
         label, checker_function, ok_tip_text, err_tip_text
     )
     dialog.set_title(rose.config_editor.DIALOG_TITLE_CONFIG_CREATE)
     meta_hbox = gtk.HBox()
     meta_label = gtk.Label(rose.config_editor.DIALOG_LABEL_CONFIG_CHOOSE_META)
     meta_label.show()
     meta_entry = gtk.Entry()
     tip_text = rose.config_editor.TIP_CONFIG_CHOOSE_META
     meta_entry.set_tooltip_text(tip_text)
     meta_entry.connect("activate", lambda b: dialog.response(gtk.RESPONSE_ACCEPT))
     meta_entry.show()
     meta_hbox.pack_start(meta_label, expand=False, fill=False, padding=rose.config_editor.SPACING_SUB_PAGE)
     meta_hbox.pack_start(meta_entry, expand=False, fill=True, padding=rose.config_editor.SPACING_SUB_PAGE)
     meta_hbox.show()
     container.pack_start(meta_hbox, expand=False, fill=True, padding=rose.config_editor.SPACING_PAGE)
     response = dialog.run()
     name = None
     meta = None
     if name_entry.get_text():
         name = name_entry.get_text().strip().strip("/")
     if meta_entry.get_text():
         meta = meta_entry.get_text().strip()
     dialog.destroy()
     if response == gtk.RESPONSE_ACCEPT:
         return name, meta
     return None, None
Example #2
0
 def override_macro_defaults(self, optionals, methname):
     """Launch a dialog to handle capture of any override args to macro"""
     if not optionals:
         return {}
     res = {}
     #create the text input field
     entries = {}
     labels = {}
     errs = {}
     succeeded = False
     dialog = gtk.MessageDialog(
             None,
             gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
             gtk.MESSAGE_QUESTION,
             gtk.BUTTONS_OK_CANCEL,
             None)
     dialog.set_markup('Specify overrides for macro arguments:')
     dialog.set_title(methname)
     table = gtk.Table(len(optionals.items()), 2, False)
     dialog.vbox.add(table)
     for i in range(len(optionals.items())):
         k, v = optionals.items()[i]
         label = gtk.Label(str(k) + ":")
         entry = gtk.Entry()
         if isinstance(v,str):
             entry.set_text("'" + v + "'")
         else:
             entry.set_text(str(v))
         entry.connect("changed", self.check_entry_value, dialog,
                       entries, labels, optionals)
         entry.connect("activate", self.handle_macro_entry_activate,
                       dialog, entries)
         entries[k] = entry
         labels[k] = label
         table.attach(entry, 1, 2, i, i+1)
         hbox = gtk.HBox()
         hbox.pack_start(label, expand=False)
         table.attach(hbox, 0, 1, i, i+1)
     dialog.show_all()
     response = dialog.run()
     if (response == gtk.RESPONSE_CANCEL or
         response == gtk.RESPONSE_CLOSE):
         res = optionals
         dialog.destroy()
     else:
         res = {}
         for k,box in entries.items():
             res[k] = ast.literal_eval(box.get_text())
     dialog.destroy()
     return res
Example #3
0
 def override_macro_defaults(self, optionals, methname):
     """Launch a dialog to handle capture of any override args to macro"""
     if not optionals:
         return {}
     res = {}
     # create the text input field
     entries = {}
     labels = {}
     errs = {}
     succeeded = False
     dialog = gtk.MessageDialog(
         None,
         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
         gtk.MESSAGE_QUESTION,
         gtk.BUTTONS_OK_CANCEL,
         None)
     dialog.set_markup('Specify overrides for macro arguments:')
     dialog.set_title(methname)
     table = gtk.Table(len(optionals.items()), 2, False)
     dialog.vbox.add(table)
     for i in range(len(optionals.items())):
         k, v = optionals.items()[i]
         label = gtk.Label(str(k) + ":")
         entry = gtk.Entry()
         if isinstance(v, str):
             entry.set_text("'" + v + "'")
         else:
             entry.set_text(str(v))
         entry.connect("changed", self.check_entry_value, dialog,
                       entries, labels, optionals)
         entry.connect("activate", self.handle_macro_entry_activate,
                       dialog, entries)
         entries[k] = entry
         labels[k] = label
         table.attach(entry, 1, 2, i, i + 1)
         hbox = gtk.HBox()
         hbox.pack_start(label, expand=False)
         table.attach(hbox, 0, 1, i, i + 1)
     dialog.show_all()
     response = dialog.run()
     if response == gtk.RESPONSE_CANCEL or response == gtk.RESPONSE_CLOSE:
         res = optionals
         dialog.destroy()
     else:
         res = {}
         for k, box in entries.items():
             res[k] = ast.literal_eval(box.get_text())
     dialog.destroy()
     return res
Example #4
0
 def launch_new_config_dialog(self, root_directory):
     """Launch a dialog allowing naming of a new configuration."""
     existing_apps = os.listdir(root_directory)
     checker_function = lambda t: t not in existing_apps
     label = rose.config_editor.DIALOG_LABEL_CONFIG_CHOOSE_NAME
     ok_tip_text = rose.config_editor.TIP_CONFIG_CHOOSE_NAME
     err_tip_text = rose.config_editor.TIP_CONFIG_CHOOSE_NAME_ERROR
     dialog, container, name_entry = rose.gtk.dialog.get_naming_dialog(
         label, checker_function, ok_tip_text, err_tip_text)
     dialog.set_title(rose.config_editor.DIALOG_TITLE_CONFIG_CREATE)
     meta_hbox = gtk.HBox()
     meta_label = gtk.Label(
         rose.config_editor.DIALOG_LABEL_CONFIG_CHOOSE_META)
     meta_label.show()
     meta_entry = gtk.Entry()
     tip_text = rose.config_editor.TIP_CONFIG_CHOOSE_META
     meta_entry.set_tooltip_text(tip_text)
     meta_entry.connect("activate",
                        lambda b: dialog.response(gtk.RESPONSE_ACCEPT))
     meta_entry.show()
     meta_hbox.pack_start(meta_label,
                          expand=False,
                          fill=False,
                          padding=rose.config_editor.SPACING_SUB_PAGE)
     meta_hbox.pack_start(meta_entry,
                          expand=False,
                          fill=True,
                          padding=rose.config_editor.SPACING_SUB_PAGE)
     meta_hbox.show()
     container.pack_start(meta_hbox,
                          expand=False,
                          fill=True,
                          padding=rose.config_editor.SPACING_PAGE)
     response = dialog.run()
     name = None
     meta = None
     if name_entry.get_text():
         name = name_entry.get_text().strip().strip('/')
     if meta_entry.get_text():
         meta = meta_entry.get_text().strip()
     dialog.destroy()
     if response == gtk.RESPONSE_ACCEPT:
         return name, meta
     return None, None
Example #5
0
    def launch_metadata_manager(self, paths):
        """
        Launches a dialogue where users may add or remove custom meta data
        paths.
        """
        dialog = gtk.Dialog(
            title=rose.config_editor.DIALOG_TITLE_MANAGE_METADATA,
            buttons=(gtk.STOCK_CANCEL,
                     gtk.RESPONSE_CANCEL,
                     gtk.STOCK_OK,
                     gtk.RESPONSE_OK)
        )

        # add description
        label = gtk.Label('Specify metadata paths to override the default '
                          'metadata.\n')
        dialog.vbox.pack_start(label)
        label.show()

        # create table of paths
        table = MetadataTable(paths, dialog.vbox)

        # create add path button
        button = gtk.Button('Add Path')

        def add_path():
            _path = self.launch_load_metadata_dialog()
            if _path:
                table.add_row(_path)
        button.connect('clicked', lambda b: add_path())
        dialog.vbox.pack_start(button)
        button.show()

        # open the dialogue
        response = dialog.run()
        if response in [gtk.RESPONSE_OK, gtk.RESPONSE_ACCEPT,
                        gtk.RESPONSE_YES]:
            # if user clicked 'ok'
            dialog.destroy()
            return table.paths
        else:
            dialog.destroy()
            return None
Example #6
0
File: window.py Project: kinow/rose
    def launch_metadata_manager(self, paths):
        """
        Launches a dialogue where users may add or remove custom meta data
        paths.
        """
        dialog = gtk.Dialog(
            title=rose.config_editor.DIALOG_TITLE_MANAGE_METADATA,
            buttons=(gtk.STOCK_CANCEL,
                     gtk.RESPONSE_CANCEL,
                     gtk.STOCK_OK,
                     gtk.RESPONSE_OK)
        )

        # add description
        label = gtk.Label('Specify metadata paths to override the default '
                          'metadata.\n')
        dialog.vbox.pack_start(label)
        label.show()

        # create table of paths
        table = MetadataTable(paths, dialog.vbox)

        # create add path button
        button = gtk.Button('Add Path')

        def add_path():
            _path = self.launch_load_metadata_dialog()
            if _path:
                table.add_row(_path)
        button.connect('clicked', lambda b: add_path())
        dialog.vbox.pack_start(button)
        button.show()

        # open the dialogue
        response = dialog.run()
        if response in [gtk.RESPONSE_OK, gtk.RESPONSE_ACCEPT,
                        gtk.RESPONSE_YES]:
            # if user clicked 'ok'
            dialog.destroy()
            return table.paths
        else:
            dialog.destroy()
            return None