def show_flags(use_flags, ebuild_use_flags, id_overrides=False, first_flag=True): """runs through the list of flags and formats and prints them""" #debug.dprint("SUMMARY: SHOW_PROPS(),show_flags(); use_flags = " +str( use_flags) + ", ebuild_use_flags = " + str(ebuild_use_flags)) #first_flag = True if id_overrides: full_list = abs_list(iuse) else: full_list = [] for flag in use_flags: if id_overrides: debug.dprint( "SUMMARY: SHOW_PROPS(),show_flags(); flag = " + str(flag) + " " + str(full_list)) else: debug.dprint( "SUMMARY: SHOW_PROPS(),show_flags(); flag = " + str(flag)) # Check to see if flag applies: flag_active = False myflag = abs_flag(flag) if myflag in ebuild_use_flags: debug.dprint( "SUMMARY: SHOW_PROPS(),show_flags(); flag in ebuild_use_flags = True" ) flag_active = True elif '-' + myflag in ebuild_use_flags: flag = '-' + myflag if not first_flag: append(", ", "value") else: first_flag = False show_flag(flag, flag_active, id_overrides) if myflag in full_list: full_list.remove(myflag) else: debug.dprint( "SUMMARY: SHOW_PROPS(),show_flags(); flag in full_list: " + myflag) if id_overrides and len(full_list): # print remaining flags for flag in full_list: if not first_flag: append(", ", "value") else: first_flag = False flag_override = False if flag in ebuild_use_flags: debug.dprint( "SUMMARY: SHOW_PROPS(),show_flags(); flag_override = True" ) flag_override = True elif '-' + flag in ebuild_use_flags: flag = '-' + flag show_flag(flag, False, flag_override)
def __init__(self, use_flags, ebuild): gtk.Widget.__init__(self) self.ebuild = ebuild debug.dprint("USEFLAGDIALOG: __INIT__()") size = len(use_flags) maxcol = 3 maxrow = (size-1) / (maxcol+1) table = gtk.Table(maxrow+2, maxcol+1, True) if maxrow+1 >= 6: scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.add(scrolledwindow) scrolledwindow.add_with_viewport(table) scrolledwindow.set_size_request(1,100) scrolledwindow.show() else: self.add(table) self.ufList = [] col = 0 row = 0 ebuild_use_flags = get_reduced_flags(ebuild) for flag in use_flags: if flag[0] == '-': button = UseFlagCheckbuttons(flag[1:], "-") elif flag[0] == '+': button = UseFlagCheckbuttons(flag[1:], "+") else: button = UseFlagCheckbuttons(flag, "") myflag = abs_flag(flag) if flag in ebuild_use_flags: button.enable_box.set_active(True) if flag[0] == '-': button.disable_box.set_active(True) elif flag[0] == '+': button.disable_box.set_active(False) self.ufList.append([button, flag]) button.set_has_tooltip=True try: button.set_tooltip_text(portage_lib.settings.UseFlagDict[myflag.lower()][2]) except KeyError: button.set_tooltip_text(_('Unsupported use flag')) table.attach(button, col, col+1, row, row+1) #connect to grab-focus so we can detect changes button.connect('grab-focus', self.on_toggled) button.show() #increment column and row col+=1 if col > maxcol: col = 0 row += 1 table.show() self.show()
def get_use_flags(self, ebuild=None): debug.dprint("USEFLAGS: get_use_flags()") flaglist = [] if ebuild is None: ebuild_use_flags = get_reduced_flags(self.ebuild) else: ebuild_use_flags = get_reduced_flags(ebuild) for child in self.ufList: #flag = child[1] flag = child[0].get_flag() base_flag = abs_flag(flag) if flag[0] == '+': if not flag[1:] in ebuild_use_flags: flaglist.append(flag) elif flag[0] == '-': if not flag in ebuild_use_flags: flaglist.append(flag) flags = ' '.join(flaglist) debug.dprint("USEFLAGS: get_use_flags(); flags = %s" %str(flags)) return flags
def build_use_flag_widget(self, use_flags, ebuild): """ Create a table layout and populate it with checkbox widgets representing the available use flags """ debug.dprint("ADVEMERGE: build_use_flag_widget()") UseFlagFrame = self.wtree.get_widget("frameUseFlags") button_make_conf = self.wtree.get_widget("button_make_conf") button_package_use = self.wtree.get_widget("button_package_use") # If frame has any children, remove them child = UseFlagFrame.child if child != None: UseFlagFrame.remove(child) # If no use flags, hide the frame if not use_flags: UseFlagFrame.hide() self.btnMakeConf.hide() self.btnPkgUse.hide() else: UseFlagFrame.show() if self.is_root or utils.can_gksu(): self.btnPkgUse.show() if config.Prefs.advemerge.show_make_conf_button: self.btnMakeConf.show() else: self.btnMakeConf.hide() # Build table to hold checkboxes size = 30 maxcol = 3 # = number of columns - 1 = index of last column maxrow = (size - 1) / (maxcol + 1) # = number of rows - 1 # resize the table if it's taller than it is wide table = gtk.Table(maxrow + 1, maxcol + 1, True) if maxrow + 1 >= 6: # perhaps have this number configurable? # perhaps add window based on size (in pixels) of table somehow... scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) UseFlagFrame.add(scrolledwindow) scrolledwindow.add_with_viewport(table) scrolledwindow.set_size_request(1, 100) # min height of 100 pixels scrolledwindow.show() else: UseFlagFrame.add(table) self.ufList = [] # Iterate through use flags collection, create checkboxes # and attach to table col = 0 row = 0 ebuild_use_flags = get_reduced_flags(ebuild) for flag in use_flags: flag_active = False myflag = abs_flag(flag) if myflag in ebuild_use_flags: flag_active = True button = gtk.CheckButton(flag) button.set_use_underline(False) button.set_active(flag_active) self.ufList.append([button, flag]) # Add tooltip, attach button to table and show it off # Use lower case flag, since that is how it is stored # in the UseFlagDict. In case flag doesn't exist # we'll trap the error button.set_has_tooltip(True) try: button.set_tooltip_text( portage_lib.settings.UseFlagDict[flag.lower()][2]) except KeyError: button.set_tooltip_text(_('Unsupported use flag')) table.attach(button, col, col + 1, row, row + 1) # connect to on_toggled so we can show changes button.connect("toggled", self.on_toggled) button.show() # Increment col & row counters col += 1 if col > maxcol: col = 0 row += 1 # Display the entire table table.show()