示例#1
0
    def set_tree_tip(self, treeview, row_iter, col_index, tip):
        """Add the hover-over text for a cell to 'tip'.

        treeview is the gtk.TreeView object
        row_iter is the gtk.TreeIter for the row
        col_index is the index of the gtk.TreeColumn in
        e.g. treeview.get_columns()
        tip is the gtk.Tooltip object that the text needs to be set in.

        """
        model = treeview.get_model()
        stash_section_index = self.column_names.index("Section")
        stash_item_index = self.column_names.index("Item")
        stash_desc_index = self.column_names.index("Description")
        stash_request_num_index = self.column_names.index("#")
        stash_section = model.get_value(row_iter, stash_section_index)
        stash_item = model.get_value(row_iter, stash_item_index)
        stash_desc = model.get_value(row_iter, stash_desc_index)
        stash_request_num = model.get_value(row_iter, stash_request_num_index)
        if not stash_request_num or stash_request_num == "0":
            stash_request_num = "None"
        name = self.column_names[col_index]
        value = model.get_value(row_iter, col_index)
        help = None
        if value is None:
            return False
        if name == "?":
            name = "Requests Status"
            if value == rose.config_editor.SUMMARY_DATA_PANEL_MODIFIED_MARKUP:
                value = "changed"
            else:
                value = "no changes"
        elif name == "#":
            name = "Requests"
            if stash_request_num != "None":
                sect_streqs = self.request_lookup.get(stash_section, {})
                streqs = sect_streqs.get(stash_item, {}).keys()
                streqs.sort(rose.config.sort_settings)
                if streqs:
                    value = "\n    " + "\n    ".join(streqs)
                else:
                    value = stash_request_num + " total"
        if name == "Section":
            meta_key = self.STASH_PARSE_SECT_OPT + "=" + value
        elif name == "Description":
            metadata = stash_util.get_metadata_for_stash_section_item(
                self.stash_meta_lookup, stash_section, stash_item, value
            )
            help = metadata.get(rose.META_PROP_HELP)
            meta_key = self.STASH_PARSE_DESC_OPT + "=" + value
        else:
            meta_key = name + "=" + value
        value_meta = self.stash_meta_lookup.get(meta_key, {})
        title = value_meta.get(rose.META_PROP_TITLE, "")
        if help is None:
            help = value_meta.get(rose.META_PROP_HELP, "")
        if title and not help:
            value += "\n" + title
        if help:
            value += "\n" + rose.gtk.util.safe_str(help)
        text = name + ": " + str(value) + "\n\n"
        text += "Section: " + str(stash_section) + "\n"
        text += "Item: " + str(stash_item) + "\n"
        text += "Description: " + str(stash_desc) + "\n"
        if stash_request_num != "None":
            text += str(stash_request_num) + " request(s)"
        text = text.strip()
        tip.set_text(text)
        return True
示例#2
0
    def set_tree_tip(self, treeview, row_iter, col_index, tip):
        """Add the hover-over text for a cell to 'tip'.

        treeview is the gtk.TreeView object
        row_iter is the gtk.TreeIter for the row
        col_index is the index of the gtk.TreeColumn in
        e.g. treeview.get_columns()
        tip is the gtk.Tooltip object that the text needs to be set in.

        """
        model = treeview.get_model()
        stash_section_index = self.column_names.index("Section")
        stash_item_index = self.column_names.index("Item")
        stash_desc_index = self.column_names.index("Description")
        stash_request_num_index = self.column_names.index("#")
        stash_section = model.get_value(row_iter, stash_section_index)
        stash_item = model.get_value(row_iter, stash_item_index)
        stash_desc = model.get_value(row_iter, stash_desc_index)
        stash_request_num = model.get_value(row_iter, stash_request_num_index)
        if not stash_request_num or stash_request_num == "0":
            stash_request_num = "None"
        name = self.column_names[col_index]
        value = model.get_value(row_iter, col_index)
        help = None
        if value is None:
            return False
        if name == "?":
            name = "Requests Status"
            if value == rose.config_editor.SUMMARY_DATA_PANEL_MODIFIED_MARKUP:
                value = "changed"
            else:
                value = "no changes"
        elif name == "#":
            name = "Requests"
            if stash_request_num != "None":
                sect_streqs = self.request_lookup.get(stash_section, {})
                streqs = sect_streqs.get(stash_item, {}).keys()
                streqs.sort(rose.config.sort_settings)
                if streqs:
                    value = "\n    " + "\n    ".join(streqs)
                else:
                    value = stash_request_num + " total"
        if name == "Section":
            meta_key = self.STASH_PARSE_SECT_OPT + "=" + value
        elif name == "Description":
            metadata = stash_util.get_metadata_for_stash_section_item(
                self.stash_meta_lookup, stash_section, stash_item, value)
            help = metadata.get(rose.META_PROP_HELP)
            meta_key = self.STASH_PARSE_DESC_OPT + "=" + value
        else:
            meta_key = name + "=" + value
        value_meta = self.stash_meta_lookup.get(meta_key, {})
        title = value_meta.get(rose.META_PROP_TITLE, "")
        if help is None:
            help = value_meta.get(rose.META_PROP_HELP, "")
        if title and not help:
            value += "\n" + title
        if help:
            value += "\n" + rose.gtk.util.safe_str(help)
        text = name + ": " + str(value) + "\n\n"
        text += "Section: " + str(stash_section) + "\n"
        text += "Item: " + str(stash_item) + "\n"
        text += "Description: " + str(stash_desc) + "\n"
        if stash_request_num != "None":
            text += str(stash_request_num) + " request(s)"
        text = text.strip()
        tip.set_text(text)
        return True
示例#3
0
 def set_tree_tip(self, view, row_iter, col_index, tip):
     """(Override) Set the TreeView Tooltip."""
     sect_index = self.get_section_column_index()
     model = view.get_model()
     section = model.get_value(row_iter, sect_index)
     if section is None:
         return False
     col_name = self.column_names[col_index]
     stash_section_index = self.column_names.index(
         self.STREQ_NL_SECT_OPT)
     stash_item_index = self.column_names.index(
         self.STREQ_NL_ITEM_OPT)
     stash_section = model.get_value(row_iter, stash_section_index)
     stash_item = model.get_value(row_iter, stash_item_index)
     if (col_index == sect_index or
         col_name in [self.DESCRIPTION_TITLE, self.INCLUDED_TITLE]):
         option = None
         if section not in self.sections:
             return False
         id_data = self.sections[section]
         if col_index == sect_index:
             tip_text = section
         elif col_name in [self.DESCRIPTION_TITLE, self.INCLUDED_TITLE]:
             tip_text = str(model.get_value(row_iter, col_index))
             tip_text += "\n" + section
         if col_name == self.DESCRIPTION_TITLE:
             value = str(model.get_value(row_iter, col_index))
             metadata = stash_util.get_metadata_for_stash_section_item(
                 self._stashmaster_meta_lookup, stash_section, stash_item,
                 value
             )
             help = metadata.get(rose.META_PROP_HELP)
             if help is not None:
                 tip_text += "\n\n" + help
     else:
         option = self.column_names[col_index]
         id_ = self.util.get_id_from_section_option(section, option)
         if (id_ not in self.var_id_map):
             tip.set_text(str(
                 model.get_value(row_iter, col_index)))
             return True
         id_data = self.var_id_map[id_]
         value = str(model.get_value(row_iter, col_index))
         tip_text = rose.CONFIG_DELIMITER.join([section, option, value]) + "\n"
         if option in self.OPTION_NL_MAP and option in self._profile_location_map.keys():
             profile_id = self._profile_location_map[option].get(value)
             if profile_id is not None:
                 profile_sect = self.util.get_section_option_from_id(
                                                             profile_id)[0]
                 tip_text += "See " + profile_sect
     tip_text += id_data.metadata.get(rose.META_PROP_DESCRIPTION, "")
     if tip_text:
         tip_text += "\n"
     for key, value in id_data.error.items():
         tip_text += (
                 rose.config_editor.SUMMARY_DATA_PANEL_ERROR_TIP.format(
                                                             key, value))
     for key in id_data.ignored_reason:
         tip_text += "({0})\n".format(key)
     if option is None:
         change_text = self.sect_ops.get_section_changes(id_data)
     else:
         change_text = self.var_ops.get_var_changes(id_data)
     if change_text:
         tip_text += change_text + "\n"
     tip.set_text(tip_text.rstrip())
     return True
示例#4
0
 def set_tree_tip(self, view, row_iter, col_index, tip):
     """(Override) Set the TreeView Tooltip."""
     sect_index = self.get_section_column_index()
     model = view.get_model()
     section = model.get_value(row_iter, sect_index)
     if section is None:
         return False
     col_name = self.column_names[col_index]
     stash_section_index = self.column_names.index(self.STREQ_NL_SECT_OPT)
     stash_item_index = self.column_names.index(self.STREQ_NL_ITEM_OPT)
     stash_section = model.get_value(row_iter, stash_section_index)
     stash_item = model.get_value(row_iter, stash_item_index)
     if (col_index == sect_index
             or col_name in [self.DESCRIPTION_TITLE, self.INCLUDED_TITLE]):
         option = None
         if section not in self.sections:
             return False
         id_data = self.sections[section]
         if col_index == sect_index:
             tip_text = section
         elif col_name in [self.DESCRIPTION_TITLE, self.INCLUDED_TITLE]:
             tip_text = str(model.get_value(row_iter, col_index))
             tip_text += "\n" + section
         if col_name == self.DESCRIPTION_TITLE:
             value = str(model.get_value(row_iter, col_index))
             metadata = stash_util.get_metadata_for_stash_section_item(
                 self._stashmaster_meta_lookup, stash_section, stash_item,
                 value)
             help = metadata.get(rose.META_PROP_HELP)
             if help is not None:
                 tip_text += "\n\n" + help
     else:
         option = self.column_names[col_index]
         id_ = self.util.get_id_from_section_option(section, option)
         if (id_ not in self.var_id_map):
             tip.set_text(str(model.get_value(row_iter, col_index)))
             return True
         id_data = self.var_id_map[id_]
         value = str(model.get_value(row_iter, col_index))
         tip_text = rose.CONFIG_DELIMITER.join([section, option, value
                                                ]) + "\n"
         if (option in self.OPTION_NL_MAP
                 and option in self._profile_location_map.keys()):
             profile_id = self._profile_location_map[option].get(value)
             if profile_id is not None:
                 profile_sect = self.util.get_section_option_from_id(
                     profile_id)[0]
                 tip_text += "See " + profile_sect
     tip_text += id_data.metadata.get(rose.META_PROP_DESCRIPTION, "")
     if tip_text:
         tip_text += "\n"
     for key, value in id_data.error.items():
         tip_text += (
             rose.config_editor.SUMMARY_DATA_PANEL_ERROR_TIP.format(
                 key, value))
     for key in id_data.ignored_reason:
         tip_text += "({0})\n".format(key)
     if option is None:
         change_text = self.sect_ops.get_section_changes(id_data)
     else:
         change_text = self.var_ops.get_var_changes(id_data)
     if change_text:
         tip_text += change_text + "\n"
     tip.set_text(tip_text.rstrip())
     return True