Reputation: 37328
I was trying to separate the group of windows per profile in Win7. I found out this is doable by creating a preference in ALL profiles of taskbar.grouping.useprofile
and setting it to true and restarting browser of all profiles (https://bugzilla.mozilla.org/show_bug.cgi?id=644914).
But how it works is it changes the defaultGroupId Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar).defaultGroupId
The problem with this is before this prefernce is created the Firefox uses the defaultGroupId
of the firefox.exe BUT after creating the pref profiles now have a defaultGroupId different from that. SO if initially, before creating that pref and restarting browsers, if user had firefox.exe
pinned then it will always be separate after the pref is created and browsers restarted.
So what I want to do is for the profile marked as Default=1
in profiles.ini I want to programatically make it use the defaultGroupId
of the firefox.exe
but the thing is once pref is created and browser restarted I can't figure out the defaultGroupId
of the firefox.exe
.
My last resort solution is: (1) On install of my addon if the pref of taskbar.grouping.useprofile
is there and set to true, then set it to false and ask user to restart then on restart it will figure out the defaultGrupId
and store it as a preference then I will add the pref back then ask user to restart again (really dont want to do this) (2) On install of my addon if if the pref of taskbar.grouping.useprofile
is not there and set to true then just set the preference to the value of the current defaultGroupId
.
Upvotes: 0
Views: 151
Reputation: 37328
Thanks to @Neil for letting me know that the default group id can be found in the registry, even after setting the preference of taskbar.grouping.useprofile
to true
.
ask.m.o :: How to calculate default group id (Win7+)
Solution from ask.m.o:
Thanks @Neil I got the value this way. The only possible problem I run into, is what if there is more than one value under TaskBarIDs, is this possible?
I also might run into problem if value type is of
0
which isTYPE_NONE
orREG_NONE
is it possible to read these values?var wrk = Cc['@mozilla.org/windows-registry-key;1'].createInstance(Components.interfaces.nsIWindowsRegKey); var keypath = 'Software\\Mozilla\\' + Services.appinfo.name + '\\TaskBarIDs'; //Services.appinfo.name == appInfo->GetName(appName) // http://mxr.mozilla.org/comm-central/source/mozilla/widget/windows/WinTaskbar.cpp#284 try { wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE, keypath, wrk.ACCESS_READ); } catch(ex) { //console.warn(ex) if (ex.message != 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWindowsRegKey.open]') { throw ex; } else { try { wrk.open(wrk.ROOT_KEY_CURRENT_USER, keypath, wrk.ACCESS_READ); } catch (ex) { throw ex; } } } //list children var numVals = wrk.valueCount; for (var i=0; i<numVals; i++) { var keyval = { Name: wrk.getValueName(i) }; keyval.Type = wrk.getValueType(keyval.Name); keyval.TypeStr = win_RegTypeStr_from_RegTypeInt(keyval.Type); if (keyval.Type == 0) { throw new Error('keyval.Type is `0` I have no idea how to read this value keyval.Type == `' + keyval.Type + '` and keyval. Name == `' + keyval.Name + '`'); } keyval.Value = wrk['read' + keyval.TypeStr + 'Value'](keyval.Name) console.log('keyval:', uneval(keyval), keyval); } wrk.close(); function win_RegTypeStr_from_RegTypeInt(int) { if (int == 1) { return 'String'; } else if (int == 3) { return 'Binary'; } else if (int == 4) { return 'Int'; } else if (int == 11) { return 'Int64'; } else if (int == 0) { return 'NONE'; } else { throw new Error('keyval.Type is not any of the expected values of 0, 2, 3, 4, or 11 so am now confused. keyval.Type == `' + int + '`'); } }
Upvotes: 0